From f51e4dc24b3784a3af09278f2d38cf0ba1c4c8cd Mon Sep 17 00:00:00 2001 From: dsinclair Date: Thu, 13 Oct 2016 07:43:19 -0700 Subject: Cleanup CPDFXFA_App methods This CL removes methods which are never called, or are only called once and return a static value. Those values are inlined at the calling site. Review-Url: https://codereview.chromium.org/2418633002 --- fpdfsdk/fpdfxfa/cpdfxfa_app.cpp | 23 ++--------------------- fpdfsdk/fpdfxfa/cpdfxfa_app.h | 6 ------ fpdfsdk/fpdfxfa/cxfa_fwladaptertimermgr.h | 5 ----- fpdfsdk/javascript/app.cpp | 4 ++-- xfa/fxfa/fxfa.h | 18 ------------------ xfa/fxfa/parser/cscript_hostpseudomodel.cpp | 23 ++++++++--------------- 6 files changed, 12 insertions(+), 67 deletions(-) diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_app.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_app.cpp index 626a07eb29..61694d0a28 100644 --- a/fpdfsdk/fpdfxfa/cpdfxfa_app.cpp +++ b/fpdfsdk/fpdfxfa/cpdfxfa_app.cpp @@ -35,9 +35,7 @@ void CPDFXFA_App::ReleaseInstance() { } CPDFXFA_App::CPDFXFA_App() - : m_bJavaScriptInitialized(FALSE), - m_pIsolate(nullptr), - m_csAppType(JS_STR_VIEWERTYPE_STANDARD) { + : m_bJavaScriptInitialized(FALSE), m_pIsolate(nullptr) { m_pFormFillEnvList.RemoveAll(); } @@ -86,20 +84,12 @@ FX_BOOL CPDFXFA_App::RemoveFormFillEnv( return FALSE; } -void CPDFXFA_App::GetAppType(CFX_WideString& wsAppType) { - wsAppType = m_csAppType; -} - void CPDFXFA_App::GetAppName(CFX_WideString& wsName) { CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pFormFillEnvList.GetAt(0); if (pFormFillEnv) wsName = pFormFillEnv->FFI_GetAppName(); } -void CPDFXFA_App::SetAppType(const CFX_WideStringC& wsAppType) { - m_csAppType = wsAppType; -} - void CPDFXFA_App::GetLanguage(CFX_WideString& wsLanguage) { CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pFormFillEnvList.GetAt(0); if (pFormFillEnv) @@ -113,19 +103,10 @@ void CPDFXFA_App::GetPlatform(CFX_WideString& wsPlatform) { } } -void CPDFXFA_App::GetVariation(CFX_WideString& wsVariation) { - wsVariation = JS_STR_VIEWERVARIATION; -} - -void CPDFXFA_App::GetVersion(CFX_WideString& wsVersion) { - wsVersion = JS_STR_VIEWERVERSION_XFA; -} - void CPDFXFA_App::Beep(uint32_t dwType) { CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pFormFillEnvList.GetAt(0); - if (pFormFillEnv) { + if (pFormFillEnv) pFormFillEnv->JS_appBeep(dwType); - } } int32_t CPDFXFA_App::MsgBox(const CFX_WideString& wsMessage, diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_app.h b/fpdfsdk/fpdfxfa/cpdfxfa_app.h index 6deaeacff0..78184d1434 100644 --- a/fpdfsdk/fpdfxfa/cpdfxfa_app.h +++ b/fpdfsdk/fpdfxfa/cpdfxfa_app.h @@ -34,13 +34,8 @@ class CPDFXFA_App : public IXFA_AppProvider { v8::Isolate* GetJSERuntime() const { return m_pIsolate; } // IFXA_AppProvider: - void GetAppType(CFX_WideString& wsAppType) override; - void SetAppType(const CFX_WideStringC& wsAppType) override; - void GetLanguage(CFX_WideString& wsLanguage) override; void GetPlatform(CFX_WideString& wsPlatform) override; - void GetVariation(CFX_WideString& wsVariation) override; - void GetVersion(CFX_WideString& wsVersion) override; void GetAppName(CFX_WideString& wsName) override; void Beep(uint32_t dwType) override; @@ -73,7 +68,6 @@ class CPDFXFA_App : public IXFA_AppProvider { FX_BOOL m_bJavaScriptInitialized; std::unique_ptr m_pXFAApp; v8::Isolate* m_pIsolate; - CFX_WideString m_csAppType; }; #endif // FPDFSDK_FPDFXFA_CPDFXFA_APP_H_ diff --git a/fpdfsdk/fpdfxfa/cxfa_fwladaptertimermgr.h b/fpdfsdk/fpdfxfa/cxfa_fwladaptertimermgr.h index 5f5017b5d8..3fc56ee0e7 100644 --- a/fpdfsdk/fpdfxfa/cxfa_fwladaptertimermgr.h +++ b/fpdfsdk/fpdfxfa/cxfa_fwladaptertimermgr.h @@ -12,11 +12,6 @@ #include "fpdfsdk/fpdfxfa/cpdfxfa_document.h" #include "xfa/fwl/core/ifwl_adaptertimermgr.h" -#define JS_STR_VIEWERTYPE_STANDARD L"Exchange" -#define JS_STR_LANGUANGE L"ENU" -#define JS_STR_VIEWERVARIATION L"Full" -#define JS_STR_VIEWERVERSION_XFA L"11" - struct CFWL_TimerInfo; class CXFA_FWLAdapterTimerMgr : public IFWL_AdapterTimerMgr { diff --git a/fpdfsdk/javascript/app.cpp b/fpdfsdk/javascript/app.cpp index 325a84b1f8..394f49e143 100644 --- a/fpdfsdk/javascript/app.cpp +++ b/fpdfsdk/javascript/app.cpp @@ -152,7 +152,7 @@ void TimerObj::SetTimer(GlobalTimer* pTimer) { #define JS_STR_VIEWERTYPE L"pdfium" #define JS_STR_VIEWERVARIATION L"Full" #define JS_STR_PLATFORM L"WIN" -#define JS_STR_LANGUANGE L"ENU" +#define JS_STR_LANGUAGE L"ENU" #define JS_NUM_VIEWERVERSION 8 #ifdef PDF_ENABLE_XFA #define JS_NUM_VIEWERVERSION_XFA 11 @@ -338,7 +338,7 @@ FX_BOOL app::language(IJS_Context* cc, return TRUE; } #endif - vp << JS_STR_LANGUANGE; + vp << JS_STR_LANGUAGE; return TRUE; } diff --git a/xfa/fxfa/fxfa.h b/xfa/fxfa/fxfa.h index 412d36b7c2..a86fb63c4d 100644 --- a/xfa/fxfa/fxfa.h +++ b/xfa/fxfa/fxfa.h @@ -176,13 +176,6 @@ class IXFA_AppProvider { public: virtual ~IXFA_AppProvider() {} - /** - * Specifies the name of the client application in which a form currently - * exists. Such as Exchange-Pro. - */ - virtual void SetAppType(const CFX_WideStringC& wsAppType) = 0; - virtual void GetAppType(CFX_WideString& wsAppType) = 0; - /** * Returns the language of the running host application. Such as zh_CN */ @@ -193,17 +186,6 @@ class IXFA_AppProvider { */ virtual void GetPlatform(CFX_WideString& wsPlatform) = 0; - /** - * Indicates the packaging of the application that is running the script. Such - * as Full - */ - virtual void GetVariation(CFX_WideString& wsVariation) = 0; - - /** - * Indicates the version number of the current application. Such as 9 - */ - virtual void GetVersion(CFX_WideString& wsVersion) = 0; - /** * Get application name, such as Phantom. */ diff --git a/xfa/fxfa/parser/cscript_hostpseudomodel.cpp b/xfa/fxfa/parser/cscript_hostpseudomodel.cpp index 1525b0629b..89230c34e9 100644 --- a/xfa/fxfa/parser/cscript_hostpseudomodel.cpp +++ b/xfa/fxfa/parser/cscript_hostpseudomodel.cpp @@ -44,16 +44,13 @@ void CScript_HostPseudoModel::AppType(CFXJSE_Value* pValue, FX_BOOL bSetting, XFA_ATTRIBUTE eAttribute) { CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); - if (!pNotify) { + if (!pNotify) return; - } if (bSetting) { ThrowException(XFA_IDS_INVAlID_PROP_SET); return; } - CFX_WideString wsAppType; - pNotify->GetAppProvider()->GetAppType(wsAppType); - pValue->SetString(FX_UTF8Encode(wsAppType).AsStringC()); + pValue->SetString("Exchange"); } void CScript_HostPseudoModel::CalculationsEnabled(CFXJSE_Value* pValue, @@ -169,23 +166,21 @@ void CScript_HostPseudoModel::ValidationsEnabled(CFXJSE_Value* pValue, FX_BOOL bEnabled = pNotify->GetDocEnvironment()->IsValidationsEnabled(hDoc); pValue->SetBoolean(bEnabled); } + void CScript_HostPseudoModel::Variation(CFXJSE_Value* pValue, FX_BOOL bSetting, XFA_ATTRIBUTE eAttribute) { - if (!m_pDocument->GetScriptContext()->IsRunAtClient()) { + if (!m_pDocument->GetScriptContext()->IsRunAtClient()) return; - } + CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); - if (!pNotify) { + if (!pNotify) return; - } if (bSetting) { ThrowException(XFA_IDS_UNABLE_SET_VARIATION); return; } - CFX_WideString wsVariation; - pNotify->GetAppProvider()->GetVariation(wsVariation); - pValue->SetString(FX_UTF8Encode(wsVariation).AsStringC()); + pValue->SetString("Full"); } void CScript_HostPseudoModel::Version(CFXJSE_Value* pValue, @@ -199,9 +194,7 @@ void CScript_HostPseudoModel::Version(CFXJSE_Value* pValue, ThrowException(XFA_IDS_UNABLE_SET_VERSION); return; } - CFX_WideString wsVersion; - pNotify->GetAppProvider()->GetVersion(wsVersion); - pValue->SetString(FX_UTF8Encode(wsVersion).AsStringC()); + pValue->SetString("11"); } void CScript_HostPseudoModel::Name(CFXJSE_Value* pValue, -- cgit v1.2.3