From c8fd3318a8deca3e1eabd6f7a9449ae4a0fa964d Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Mon, 2 Jan 2017 17:17:02 -0500 Subject: 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 Commit-Queue: dsinclair --- fpdfsdk/fpdfxfa/cpdfxfa_context.cpp | 116 ++++++++++-------------------------- fpdfsdk/fpdfxfa/cpdfxfa_context.h | 9 +-- 2 files changed, 36 insertions(+), 89 deletions(-) (limited to 'fpdfsdk/fpdfxfa') diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp index 7a0ffeb256..29888c314e 100644 --- a/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp +++ b/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp @@ -231,19 +231,20 @@ v8::Isolate* CPDFXFA_Context::GetJSERuntime() const { return runtime->GetIsolate(); } -void CPDFXFA_Context::GetAppName(CFX_WideString& wsName) { - if (m_pFormFillEnv) - wsName = m_pFormFillEnv->FFI_GetAppName(); +CFX_WideString CPDFXFA_Context::GetAppTitle() const { + return L"PDFium"; } -void CPDFXFA_Context::GetLanguage(CFX_WideString& wsLanguage) { - if (m_pFormFillEnv) - wsLanguage = m_pFormFillEnv->GetLanguage(); +CFX_WideString CPDFXFA_Context::GetAppName() { + return m_pFormFillEnv ? m_pFormFillEnv->FFI_GetAppName() : L""; } -void CPDFXFA_Context::GetPlatform(CFX_WideString& wsPlatform) { - if (m_pFormFillEnv) - wsPlatform = m_pFormFillEnv->GetPlatform(); +CFX_WideString CPDFXFA_Context::GetLanguage() { + return m_pFormFillEnv ? m_pFormFillEnv->GetLanguage() : L""; +} + +CFX_WideString CPDFXFA_Context::GetPlatform() { + return m_pFormFillEnv ? m_pFormFillEnv->GetPlatform() : L""; } void CPDFXFA_Context::Beep(uint32_t dwType) { @@ -357,101 +358,46 @@ bool CPDFXFA_Context::PutRequestURL(const CFX_WideString& wsURL, wsEncode.c_str()); } -void CPDFXFA_Context::LoadString(int32_t iStringID, CFX_WideString& wsString) { +CFX_WideString CPDFXFA_Context::LoadString(int32_t iStringID) { switch (iStringID) { - case XFA_IDS_ValidateFailed: - wsString = L"%s validation failed"; - return; - case XFA_IDS_CalcOverride: - wsString = L"Calculate Override"; - return; - case XFA_IDS_ModifyField: - wsString = L"Are you sure you want to modify this field?"; - return; - case XFA_IDS_NotModifyField: - wsString = L"You are not allowed to modify this field."; - return; - case XFA_IDS_AppName: - wsString = L"pdfium"; - return; - case XFA_IDS_Unable_TO_SET: - wsString = L"Unable to set "; - return; case XFA_IDS_INVAlID_PROP_SET: - wsString = L"Invalid property set operation."; - return; + return L"Invalid property set operation."; case XFA_IDS_NOT_DEFAUL_VALUE: - wsString = L" doesn't have a default property."; - return; + return L" doesn't have a default property."; case XFA_IDS_UNABLE_SET_LANGUAGE: - wsString = L"Unable to set language value."; - return; + return L"Unable to set language value."; case XFA_IDS_UNABLE_SET_NUMPAGES: - wsString = L"Unable to set numPages value."; - return; + return L"Unable to set numPages value."; case XFA_IDS_UNABLE_SET_PLATFORM: - wsString = L"Unable to set platform value."; - return; + return L"Unable to set platform value."; case XFA_IDS_UNABLE_SET_VARIATION: - wsString = L"Unable to set variation value."; - return; + return L"Unable to set variation value."; case XFA_IDS_UNABLE_SET_VERSION: - wsString = L"Unable to set version value."; - return; + return L"Unable to set version value."; case XFA_IDS_UNABLE_SET_READY: - wsString = L"Unable to set ready value."; - return; + return L"Unable to set ready value."; case XFA_IDS_COMPILER_ERROR: - wsString = L"Compiler error."; - return; + return L"Compiler error."; case XFA_IDS_DIVIDE_ZERO: - wsString = L"Divide by zero."; - return; + return L"Divide by zero."; case XFA_IDS_ACCESS_PROPERTY_IN_NOT_OBJECT: - wsString = - L"An attempt was made to reference property '%s' of a non-object in " - L"SOM expression %s."; - return; + return L"An attempt was made to reference property '%s' of a non-object " + L"in SOM expression %s."; case XFA_IDS_INDEX_OUT_OF_BOUNDS: - wsString = L"Index value is out of bounds."; - return; + return L"Index value is out of bounds."; case XFA_IDS_INCORRECT_NUMBER_OF_METHOD: - wsString = L"Incorrect number of parameters calling method '%s'."; - return; + return L"Incorrect number of parameters calling method '%s'."; case XFA_IDS_ARGUMENT_MISMATCH: - wsString = L"Argument mismatch in property or function argument."; - return; + return L"Argument mismatch in property or function argument."; case XFA_IDS_NOT_HAVE_PROPERTY: - wsString = L"'%s' doesn't have property '%s'."; - return; + return L"'%s' doesn't have property '%s'."; case XFA_IDS_VIOLATE_BOUNDARY: - wsString = - L"The element [%s] has violated its allowable number of occurrences."; - return; + return L"The element [%s] has violated its allowable number of " + L"occurrences."; case XFA_IDS_SERVER_DENY: - wsString = L"Server does not permit."; - return; - case XFA_IDS_ValidateLimit: - wsString = - L"Message limit exceeded. Remaining %d validation errors not " - L"reported."; - return; - case XFA_IDS_ValidateNullWarning: - wsString = - L"%s cannot be blank. To ignore validations for %s, click Ignore."; - return; - case XFA_IDS_ValidateNullError: - wsString = L"%s cannot be blank."; - return; - case XFA_IDS_ValidateWarning: - wsString = - L"The value you entered for %s is invalid. To ignore validations for " - L"%s, click Ignore."; - return; - case XFA_IDS_ValidateError: - wsString = L"The value you entered for %s is invalid."; - return; + return L"Server does not permit."; } + return L""; } IFWL_AdapterTimerMgr* CPDFXFA_Context::GetTimerMgr() { diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_context.h b/fpdfsdk/fpdfxfa/cpdfxfa_context.h index 8b9daea26f..52b16891de 100644 --- a/fpdfsdk/fpdfxfa/cpdfxfa_context.h +++ b/fpdfsdk/fpdfxfa/cpdfxfa_context.h @@ -54,9 +54,10 @@ class CPDFXFA_Context : public IXFA_AppProvider { void ClearChangeMark(); // IFXA_AppProvider: - void GetLanguage(CFX_WideString& wsLanguage) override; - void GetPlatform(CFX_WideString& wsPlatform) override; - void GetAppName(CFX_WideString& wsName) override; + CFX_WideString GetLanguage() override; + CFX_WideString GetPlatform() override; + CFX_WideString GetAppName() override; + CFX_WideString GetAppTitle() const override; void Beep(uint32_t dwType) override; int32_t MsgBox(const CFX_WideString& wsMessage, @@ -79,7 +80,7 @@ class CPDFXFA_Context : public IXFA_AppProvider { const CFX_WideString& wsData, const CFX_WideString& wsEncode) override; - void LoadString(int32_t iStringID, CFX_WideString& wsString) override; + CFX_WideString LoadString(int32_t iStringID) override; IFWL_AdapterTimerMgr* GetTimerMgr() override; protected: -- cgit v1.2.3