summaryrefslogtreecommitdiff
path: root/xfa/fxfa/app
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-01-02 17:17:02 -0500
committerChromium commit bot <commit-bot@chromium.org>2017-01-03 19:54:37 +0000
commitc8fd3318a8deca3e1eabd6f7a9449ae4a0fa964d (patch)
treea5aedd888a3981f53722b7d65ea969d246f267c8 /xfa/fxfa/app
parentdb194cf018069b930d0e3d5fc0242e14f70e8620 (diff)
downloadpdfium-c8fd3318a8deca3e1eabd6f7a9449ae4a0fa964d.tar.xz
Cleaning out params in CPDFXFA_Context
This CL cleans up some of the out params in CPDFXFA_Context. In the process several of the strings returned by ::LoadString() are inlined in their call sites and the defines removed. BUG=pdfium:549 Change-Id: I41a7ceeba3962299eecd0cb714ddb03d28dbb0ea Reviewed-on: https://pdfium-review.googlesource.com/2134 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa/fxfa/app')
-rw-r--r--xfa/fxfa/app/xfa_ffdocview.cpp18
-rw-r--r--xfa/fxfa/app/xfa_fffield.cpp21
-rw-r--r--xfa/fxfa/app/xfa_fftextedit.cpp11
-rw-r--r--xfa/fxfa/app/xfa_ffwidgetacc.cpp92
-rw-r--r--xfa/fxfa/app/xfa_fwltheme.cpp77
5 files changed, 60 insertions, 159 deletions
diff --git a/xfa/fxfa/app/xfa_ffdocview.cpp b/xfa/fxfa/app/xfa_ffdocview.cpp
index e88517c00c..3d81699ded 100644
--- a/xfa/fxfa/app/xfa_ffdocview.cpp
+++ b/xfa/fxfa/app/xfa_ffdocview.cpp
@@ -159,17 +159,15 @@ void CXFA_FFDocView::ShowNullTestMsg() {
wsMsg += m_arrNullTestMsg[i] + FX_WSTRC(L"\n");
}
if (iRemain > 0) {
- CFX_WideString wsLimit;
- pAppProvider->LoadString(XFA_IDS_ValidateLimit, wsLimit);
- if (!wsLimit.IsEmpty()) {
- CFX_WideString wsTemp;
- wsTemp.Format(wsLimit.c_str(), iRemain);
- wsMsg += FX_WSTRC(L"\n") + wsTemp;
- }
+ CFX_WideString wsTemp;
+ wsTemp.Format(
+ L"Message limit exceeded. Remaining %d "
+ L"validation errors not reported.",
+ iRemain);
+ wsMsg += FX_WSTRC(L"\n") + wsTemp;
}
- CFX_WideString wsTitle;
- pAppProvider->LoadString(XFA_IDS_AppName, wsTitle);
- pAppProvider->MsgBox(wsMsg, wsTitle, XFA_MBICON_Status, XFA_MB_OK);
+ pAppProvider->MsgBox(wsMsg, pAppProvider->GetAppTitle(), XFA_MBICON_Status,
+ XFA_MB_OK);
}
m_arrNullTestMsg.clear();
}
diff --git a/xfa/fxfa/app/xfa_fffield.cpp b/xfa/fxfa/app/xfa_fffield.cpp
index 68db2ba765..2e15696ab7 100644
--- a/xfa/fxfa/app/xfa_fffield.cpp
+++ b/xfa/fxfa/app/xfa_fffield.cpp
@@ -687,13 +687,8 @@ int32_t CXFA_FFField::CalculateWidgetAcc(CXFA_WidgetAcc* pAcc) {
}
IXFA_AppProvider* pAppProvider = GetApp()->GetAppProvider();
if (pAppProvider) {
- CFX_WideString wsMessage;
- CFX_WideString wsWarning;
- pAppProvider->LoadString(XFA_IDS_NotModifyField, wsWarning);
- wsMessage += wsWarning;
- CFX_WideString wsTitle;
- pAppProvider->LoadString(XFA_IDS_CalcOverride, wsTitle);
- pAppProvider->MsgBox(wsMessage, wsTitle, XFA_MBICON_Warning,
+ pAppProvider->MsgBox(L"You are not allowed to modify this field.",
+ L"Calculate Override", XFA_MBICON_Warning,
XFA_MB_OK);
}
}
@@ -717,15 +712,11 @@ int32_t CXFA_FFField::CalculateWidgetAcc(CXFA_WidgetAcc* pAcc) {
if (pAppProvider) {
CFX_WideString wsMessage;
calc.GetMessageText(wsMessage);
- if (!wsMessage.IsEmpty()) {
+ if (!wsMessage.IsEmpty())
wsMessage += L"\r\n";
- }
- CFX_WideString wsWarning;
- pAppProvider->LoadString(XFA_IDS_ModifyField, wsWarning);
- wsMessage += wsWarning;
- CFX_WideString wsTitle;
- pAppProvider->LoadString(XFA_IDS_CalcOverride, wsTitle);
- if (pAppProvider->MsgBox(wsMessage, wsTitle, XFA_MBICON_Warning,
+ wsMessage += L"Are you sure you want to modify this field?";
+ if (pAppProvider->MsgBox(wsMessage, L"Calculate Override",
+ XFA_MBICON_Warning,
XFA_MB_YesNo) == XFA_IDYes) {
pAcc->GetNode()->SetFlag(XFA_NodeFlag_UserInteractive, false);
return 1;
diff --git a/xfa/fxfa/app/xfa_fftextedit.cpp b/xfa/fxfa/app/xfa_fftextedit.cpp
index 74bd99a55d..26e3512c40 100644
--- a/xfa/fxfa/app/xfa_fftextedit.cpp
+++ b/xfa/fxfa/app/xfa_fftextedit.cpp
@@ -195,15 +195,14 @@ void CXFA_FFTextEdit::ValidateNumberField(const CFX_WideString& wsText) {
if (pAcc && pAcc->GetUIType() == XFA_Element::NumericEdit) {
IXFA_AppProvider* pAppProvider = GetApp()->GetAppProvider();
if (pAppProvider) {
- CFX_WideString wsTitle;
- pAppProvider->LoadString(XFA_IDS_AppName, wsTitle);
- CFX_WideString wsError;
- pAppProvider->LoadString(XFA_IDS_ValidateNumberError, wsError);
CFX_WideString wsSomField;
pAcc->GetNode()->GetSOMExpression(wsSomField);
+
CFX_WideString wsMessage;
- wsMessage.Format(wsError.c_str(), wsText.c_str(), wsSomField.c_str());
- pAppProvider->MsgBox(wsMessage, wsTitle, XFA_MBICON_Error, XFA_MB_OK);
+ wsMessage.Format(L"%s can not contain %s", wsText.c_str(),
+ wsSomField.c_str());
+ pAppProvider->MsgBox(wsMessage, pAppProvider->GetAppTitle(),
+ XFA_MBICON_Error, XFA_MB_OK);
}
}
}
diff --git a/xfa/fxfa/app/xfa_ffwidgetacc.cpp b/xfa/fxfa/app/xfa_ffwidgetacc.cpp
index c1c18ebbb3..3ff159aa41 100644
--- a/xfa/fxfa/app/xfa_ffwidgetacc.cpp
+++ b/xfa/fxfa/app/xfa_ffwidgetacc.cpp
@@ -380,8 +380,7 @@ void CXFA_WidgetAcc::ProcessScriptTestValidate(CXFA_Validate validate,
if (!pAppProvider) {
return;
}
- CFX_WideString wsTitle;
- pAppProvider->LoadString(XFA_IDS_AppName, wsTitle);
+ CFX_WideString wsTitle = pAppProvider->GetAppTitle();
CFX_WideString wsScriptMsg;
validate.GetScriptMessageText(wsScriptMsg);
int32_t eScriptTest = validate.GetScriptTest();
@@ -389,7 +388,7 @@ void CXFA_WidgetAcc::ProcessScriptTestValidate(CXFA_Validate validate,
if (GetNode()->IsUserInteractive())
return;
if (wsScriptMsg.IsEmpty())
- GetValidateMessage(pAppProvider, wsScriptMsg, false, bVersionFlag);
+ wsScriptMsg = GetValidateMessage(false, bVersionFlag);
if (bVersionFlag) {
pAppProvider->MsgBox(wsScriptMsg, wsTitle, XFA_MBICON_Warning,
@@ -401,9 +400,8 @@ void CXFA_WidgetAcc::ProcessScriptTestValidate(CXFA_Validate validate,
GetNode()->SetFlag(XFA_NodeFlag_UserInteractive, false);
}
} else {
- if (wsScriptMsg.IsEmpty()) {
- GetValidateMessage(pAppProvider, wsScriptMsg, true, bVersionFlag);
- }
+ if (wsScriptMsg.IsEmpty())
+ wsScriptMsg = GetValidateMessage(true, bVersionFlag);
pAppProvider->MsgBox(wsScriptMsg, wsTitle, XFA_MBICON_Error, XFA_MB_OK);
}
}
@@ -430,20 +428,18 @@ int32_t CXFA_WidgetAcc::ProcessFormatTestValidate(CXFA_Validate validate,
}
CFX_WideString wsFormatMsg;
validate.GetFormatMessageText(wsFormatMsg);
- CFX_WideString wsTitle;
- pAppProvider->LoadString(XFA_IDS_AppName, wsTitle);
+ CFX_WideString wsTitle = pAppProvider->GetAppTitle();
int32_t eFormatTest = validate.GetFormatTest();
if (eFormatTest == XFA_ATTRIBUTEENUM_Error) {
- if (wsFormatMsg.IsEmpty()) {
- GetValidateMessage(pAppProvider, wsFormatMsg, true, bVersionFlag);
- }
+ if (wsFormatMsg.IsEmpty())
+ wsFormatMsg = GetValidateMessage(true, bVersionFlag);
pAppProvider->MsgBox(wsFormatMsg, wsTitle, XFA_MBICON_Error, XFA_MB_OK);
return XFA_EVENTERROR_Success;
}
if (GetNode()->IsUserInteractive())
return XFA_EVENTERROR_NotExist;
if (wsFormatMsg.IsEmpty())
- GetValidateMessage(pAppProvider, wsFormatMsg, false, bVersionFlag);
+ wsFormatMsg = GetValidateMessage(false, bVersionFlag);
if (bVersionFlag) {
pAppProvider->MsgBox(wsFormatMsg, wsTitle, XFA_MBICON_Warning,
@@ -496,15 +492,12 @@ int32_t CXFA_WidgetAcc::ProcessNullTestValidate(CXFA_Validate validate,
return XFA_EVENTERROR_NotExist;
}
CFX_WideString wsCaptionName;
- CFX_WideString wsTitle;
- pAppProvider->LoadString(XFA_IDS_AppName, wsTitle);
+ CFX_WideString wsTitle = pAppProvider->GetAppTitle();
switch (eNullTest) {
case XFA_ATTRIBUTEENUM_Error: {
if (wsNullMsg.IsEmpty()) {
- GetValidateCaptionName(wsCaptionName, bVersionFlag);
- CFX_WideString wsError;
- pAppProvider->LoadString(XFA_IDS_ValidateNullError, wsError);
- wsNullMsg.Format(wsError.c_str(), wsCaptionName.c_str());
+ wsCaptionName = GetValidateCaptionName(bVersionFlag);
+ wsNullMsg.Format(L"%s cannot be blank.", wsCaptionName.c_str());
}
pAppProvider->MsgBox(wsNullMsg, wsTitle, XFA_MBICON_Status, XFA_MB_OK);
return XFA_EVENTERROR_Error;
@@ -514,11 +507,10 @@ int32_t CXFA_WidgetAcc::ProcessNullTestValidate(CXFA_Validate validate,
return true;
if (wsNullMsg.IsEmpty()) {
- GetValidateCaptionName(wsCaptionName, bVersionFlag);
- CFX_WideString wsWarning;
- pAppProvider->LoadString(XFA_IDS_ValidateNullWarning, wsWarning);
- wsNullMsg.Format(wsWarning.c_str(), wsCaptionName.c_str(),
- wsCaptionName.c_str());
+ wsCaptionName = GetValidateCaptionName(bVersionFlag);
+ wsNullMsg.Format(
+ L"%s cannot be blank. To ignore validations for %s, click Ignore.",
+ wsCaptionName.c_str(), wsCaptionName.c_str());
}
if (pAppProvider->MsgBox(wsNullMsg, wsTitle, XFA_MBICON_Warning,
XFA_MB_YesNo) == XFA_IDYes) {
@@ -532,46 +524,44 @@ int32_t CXFA_WidgetAcc::ProcessNullTestValidate(CXFA_Validate validate,
}
return XFA_EVENTERROR_Success;
}
-void CXFA_WidgetAcc::GetValidateCaptionName(CFX_WideString& wsCaptionName,
- bool bVersionFlag) {
+
+CFX_WideString CXFA_WidgetAcc::GetValidateCaptionName(bool bVersionFlag) {
+ CFX_WideString wsCaptionName;
+
if (!bVersionFlag) {
- CXFA_Caption caption = GetCaption();
- if (caption) {
- CXFA_Value capValue = caption.GetValue();
- if (capValue) {
- CXFA_Text capText = capValue.GetText();
- if (capText) {
+ if (CXFA_Caption caption = GetCaption()) {
+ if (CXFA_Value capValue = caption.GetValue()) {
+ if (CXFA_Text capText = capValue.GetText())
capText.GetContent(wsCaptionName);
- }
}
}
}
- if (wsCaptionName.IsEmpty()) {
+ if (wsCaptionName.IsEmpty())
GetName(wsCaptionName);
- }
+
+ return wsCaptionName;
}
-void CXFA_WidgetAcc::GetValidateMessage(IXFA_AppProvider* pAppProvider,
- CFX_WideString& wsMessage,
- bool bError,
- bool bVersionFlag) {
- CFX_WideString wsCaptionName;
- GetValidateCaptionName(wsCaptionName, bVersionFlag);
- CFX_WideString wsError;
+
+CFX_WideString CXFA_WidgetAcc::GetValidateMessage(bool bError,
+ bool bVersionFlag) {
+ CFX_WideString wsCaptionName = GetValidateCaptionName(bVersionFlag);
+ CFX_WideString wsMessage;
if (bVersionFlag) {
- pAppProvider->LoadString(XFA_IDS_ValidateFailed, wsError);
- wsMessage.Format(wsError.c_str(), wsCaptionName.c_str());
- return;
+ wsMessage.Format(L"%s validation failed", wsCaptionName.c_str());
+ return wsMessage;
}
if (bError) {
- pAppProvider->LoadString(XFA_IDS_ValidateError, wsError);
- wsMessage.Format(wsError.c_str(), wsCaptionName.c_str());
- return;
+ wsMessage.Format(L"The value you entered for %s is invalid.",
+ wsCaptionName.c_str());
+ return wsMessage;
}
- CFX_WideString wsWarning;
- pAppProvider->LoadString(XFA_IDS_ValidateWarning, wsWarning);
- wsMessage.Format(wsWarning.c_str(), wsCaptionName.c_str(),
- wsCaptionName.c_str());
+ wsMessage.Format(
+ L"The value you entered for %s is invalid. To ignore "
+ L"validations for %s, click Ignore.",
+ wsCaptionName.c_str(), wsCaptionName.c_str());
+ return wsMessage;
}
+
int32_t CXFA_WidgetAcc::ProcessValidate(int32_t iFlags) {
if (GetElementType() == XFA_Element::Draw) {
return XFA_EVENTERROR_NotExist;
diff --git a/xfa/fxfa/app/xfa_fwltheme.cpp b/xfa/fxfa/app/xfa_fwltheme.cpp
index 5a494f1231..c08e51f807 100644
--- a/xfa/fxfa/app/xfa_fwltheme.cpp
+++ b/xfa/fxfa/app/xfa_fwltheme.cpp
@@ -228,83 +228,6 @@ void* CXFA_FWLTheme::GetCapacity(CFWL_ThemePart* pThemePart,
default:
break;
}
-
- int dwCapValue = static_cast<int>(dwCapacity);
- if (pThemePart->m_pWidget->GetClassID() == FWL_Type::MonthCalendar &&
- dwCapValue >= static_cast<int>(CFWL_WidgetCapacity::Today) &&
- dwCapValue <= static_cast<int>(CFWL_WidgetCapacity::December)) {
- if (CXFA_FFWidget* pWidget =
- XFA_ThemeGetOuterWidget(pThemePart->m_pWidget)) {
- IXFA_AppProvider* pAppProvider = pWidget->GetAppProvider();
- m_wsResource.clear();
- switch (dwCapacity) {
- case CFWL_WidgetCapacity::Sun:
- pAppProvider->LoadString(XFA_IDS_StringWeekDay_Sun, m_wsResource);
- break;
- case CFWL_WidgetCapacity::Mon:
- pAppProvider->LoadString(XFA_IDS_StringWeekDay_Mon, m_wsResource);
- break;
- case CFWL_WidgetCapacity::Tue:
- pAppProvider->LoadString(XFA_IDS_StringWeekDay_Tue, m_wsResource);
- break;
- case CFWL_WidgetCapacity::Wed:
- pAppProvider->LoadString(XFA_IDS_StringWeekDay_Wed, m_wsResource);
- break;
- case CFWL_WidgetCapacity::Thu:
- pAppProvider->LoadString(XFA_IDS_StringWeekDay_Thu, m_wsResource);
- break;
- case CFWL_WidgetCapacity::Fri:
- pAppProvider->LoadString(XFA_IDS_StringWeekDay_Fri, m_wsResource);
- break;
- case CFWL_WidgetCapacity::Sat:
- pAppProvider->LoadString(XFA_IDS_StringWeekDay_Sat, m_wsResource);
- break;
- case CFWL_WidgetCapacity::January:
- pAppProvider->LoadString(XFA_IDS_StringMonth_Jan, m_wsResource);
- break;
- case CFWL_WidgetCapacity::February:
- pAppProvider->LoadString(XFA_IDS_StringMonth_Feb, m_wsResource);
- break;
- case CFWL_WidgetCapacity::March:
- pAppProvider->LoadString(XFA_IDS_StringMonth_March, m_wsResource);
- break;
- case CFWL_WidgetCapacity::April:
- pAppProvider->LoadString(XFA_IDS_StringMonth_April, m_wsResource);
- break;
- case CFWL_WidgetCapacity::May:
- pAppProvider->LoadString(XFA_IDS_StringMonth_May, m_wsResource);
- break;
- case CFWL_WidgetCapacity::June:
- pAppProvider->LoadString(XFA_IDS_StringMonth_June, m_wsResource);
- break;
- case CFWL_WidgetCapacity::July:
- pAppProvider->LoadString(XFA_IDS_StringMonth_July, m_wsResource);
- break;
- case CFWL_WidgetCapacity::August:
- pAppProvider->LoadString(XFA_IDS_StringMonth_Aug, m_wsResource);
- break;
- case CFWL_WidgetCapacity::September:
- pAppProvider->LoadString(XFA_IDS_StringMonth_Sept, m_wsResource);
- break;
- case CFWL_WidgetCapacity::October:
- pAppProvider->LoadString(XFA_IDS_StringMonth_Oct, m_wsResource);
- break;
- case CFWL_WidgetCapacity::November:
- pAppProvider->LoadString(XFA_IDS_StringMonth_Nov, m_wsResource);
- break;
- case CFWL_WidgetCapacity::December:
- pAppProvider->LoadString(XFA_IDS_StringMonth_Dec, m_wsResource);
- break;
- case CFWL_WidgetCapacity::Today:
- pAppProvider->LoadString(XFA_IDS_String_Today, m_wsResource);
- break;
- default:
- break;
- }
- if (!m_wsResource.IsEmpty())
- return &m_wsResource;
- }
- }
return GetTheme(pThemePart->m_pWidget)->GetCapacity(pThemePart, dwCapacity);
}