diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2017-01-03 15:45:10 -0500 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-01-03 21:08:58 +0000 |
commit | 3cdcfeb04b5c496199d8c88ebd2402c3db4413ab (patch) | |
tree | abab4708b78aae2bec75ae6d1e9446aec863d159 /xfa/fxfa/parser/cscript_hostpseudomodel.cpp | |
parent | e8f6897c2a80242217da785318b427c82c00ad40 (diff) | |
download | pdfium-3cdcfeb04b5c496199d8c88ebd2402c3db4413ab.tar.xz |
Create individual exception methods.
This CL removes the LoadString method from CPDFXFA_Context and, instead,
creates individual exception methods for each of the loaded strings and
calls as needed.
BUG=pdfium:549
Change-Id: I1d975f01f13f45a885946a9952f24b13387dc3e4
Reviewed-on: https://pdfium-review.googlesource.com/2135
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa/fxfa/parser/cscript_hostpseudomodel.cpp')
-rw-r--r-- | xfa/fxfa/parser/cscript_hostpseudomodel.cpp | 69 |
1 files changed, 40 insertions, 29 deletions
diff --git a/xfa/fxfa/parser/cscript_hostpseudomodel.cpp b/xfa/fxfa/parser/cscript_hostpseudomodel.cpp index b4559669b7..97f16f01e7 100644 --- a/xfa/fxfa/parser/cscript_hostpseudomodel.cpp +++ b/xfa/fxfa/parser/cscript_hostpseudomodel.cpp @@ -34,13 +34,6 @@ CScript_HostPseudoModel::CScript_HostPseudoModel(CXFA_Document* pDocument) CScript_HostPseudoModel::~CScript_HostPseudoModel() {} -void CScript_HostPseudoModel::LoadString(CFXJSE_Value* pValue, - CXFA_FFNotify* pNotify, - uint32_t dwFlag) { - pValue->SetString( - FX_UTF8Encode(pNotify->GetAppProvider()->LoadString(dwFlag)).AsStringC()); -} - void CScript_HostPseudoModel::AppType(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { @@ -48,7 +41,7 @@ void CScript_HostPseudoModel::AppType(CFXJSE_Value* pValue, if (!pNotify) return; if (bSetting) { - ThrowException(XFA_IDS_INVAlID_PROP_SET); + ThrowInvalidPropertyException(); return; } pValue->SetString("Exchange"); @@ -89,11 +82,10 @@ void CScript_HostPseudoModel::Language(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); - if (!pNotify) { + if (!pNotify) return; - } if (bSetting) { - ThrowException(XFA_IDS_UNABLE_SET_LANGUAGE); + ThrowSetLanguageException(); return; } pValue->SetString( @@ -109,7 +101,7 @@ void CScript_HostPseudoModel::NumPages(CFXJSE_Value* pValue, } CXFA_FFDoc* hDoc = pNotify->GetHDOC(); if (bSetting) { - ThrowException(XFA_IDS_UNABLE_SET_NUMPAGES); + ThrowSetNumPagesException(); return; } pValue->SetInteger(pNotify->GetDocEnvironment()->CountPages(hDoc)); @@ -119,11 +111,10 @@ void CScript_HostPseudoModel::Platform(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); - if (!pNotify) { + if (!pNotify) return; - } if (bSetting) { - ThrowException(XFA_IDS_UNABLE_SET_PLATFORM); + ThrowSetPlatformException(); return; } pValue->SetString( @@ -176,7 +167,7 @@ void CScript_HostPseudoModel::Variation(CFXJSE_Value* pValue, if (!pNotify) return; if (bSetting) { - ThrowException(XFA_IDS_UNABLE_SET_VARIATION); + ThrowSetVariationException(); return; } pValue->SetString("Full"); @@ -190,7 +181,7 @@ void CScript_HostPseudoModel::Version(CFXJSE_Value* pValue, return; } if (bSetting) { - ThrowException(XFA_IDS_UNABLE_SET_VERSION); + ThrowSetVersionException(); return; } pValue->SetString("11"); @@ -204,7 +195,7 @@ void CScript_HostPseudoModel::Name(CFXJSE_Value* pValue, return; } if (bSetting) { - ThrowException(XFA_IDS_INVAlID_PROP_SET); + ThrowInvalidPropertyException(); return; } pValue->SetString( @@ -217,7 +208,7 @@ void CScript_HostPseudoModel::GotoURL(CFXJSE_Arguments* pArguments) { } int32_t iLength = pArguments->GetLength(); if (iLength != 1) { - ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"gotoURL"); + ThrowParamCountMismatchException(L"gotoURL"); return; } CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); @@ -238,7 +229,7 @@ void CScript_HostPseudoModel::OpenList(CFXJSE_Arguments* pArguments) { } int32_t iLength = pArguments->GetLength(); if (iLength != 1) { - ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"openList"); + ThrowParamCountMismatchException(L"openList"); return; } CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); @@ -285,7 +276,7 @@ void CScript_HostPseudoModel::OpenList(CFXJSE_Arguments* pArguments) { void CScript_HostPseudoModel::Response(CFXJSE_Arguments* pArguments) { int32_t iLength = pArguments->GetLength(); if (iLength < 1 || iLength > 4) { - ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"response"); + ThrowParamCountMismatchException(L"response"); return; } CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); @@ -349,7 +340,7 @@ static int32_t XFA_FilterName(const CFX_WideStringC& wsExpression, void CScript_HostPseudoModel::ResetData(CFXJSE_Arguments* pArguments) { int32_t iLength = pArguments->GetLength(); if (iLength < 0 || iLength > 1) { - ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"resetData"); + ThrowParamCountMismatchException(L"resetData"); return; } CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); @@ -400,7 +391,7 @@ void CScript_HostPseudoModel::Beep(CFXJSE_Arguments* pArguments) { } int32_t iLength = pArguments->GetLength(); if (iLength < 0 || iLength > 1) { - ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"beep"); + ThrowParamCountMismatchException(L"beep"); return; } CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); @@ -419,7 +410,7 @@ void CScript_HostPseudoModel::SetFocus(CFXJSE_Arguments* pArguments) { } int32_t iLength = pArguments->GetLength(); if (iLength != 1) { - ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"setFocus"); + ThrowParamCountMismatchException(L"setFocus"); return; } CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); @@ -472,7 +463,7 @@ void CScript_HostPseudoModel::MessageBox(CFXJSE_Arguments* pArguments) { } int32_t iLength = pArguments->GetLength(); if (iLength < 1 || iLength > 4) { - ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"messageBox"); + ThrowParamCountMismatchException(L"messageBox"); return; } CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); @@ -524,7 +515,7 @@ bool CScript_HostPseudoModel::ValidateArgsForMsg(CFXJSE_Arguments* pArguments, } std::unique_ptr<CFXJSE_Value> pValueArg(pArguments->GetValue(iArgIndex)); if (!pValueArg->IsString() && bIsJsType) { - ThrowException(XFA_IDS_ARGUMENT_MISMATCH); + ThrowArgumentMismatchException(); return false; } if (pValueArg->IsNull()) { @@ -545,7 +536,7 @@ void CScript_HostPseudoModel::Print(CFXJSE_Arguments* pArguments) { } int32_t iLength = pArguments->GetLength(); if (iLength != 8) { - ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"print"); + ThrowParamCountMismatchException(L"print"); return; } CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); @@ -611,7 +602,7 @@ void CScript_HostPseudoModel::Print(CFXJSE_Arguments* pArguments) { void CScript_HostPseudoModel::ImportData(CFXJSE_Arguments* pArguments) { int32_t iLength = pArguments->GetLength(); if (iLength < 0 || iLength > 1) { - ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"importData"); + ThrowParamCountMismatchException(L"importData"); return; } // Not implemented. @@ -620,7 +611,7 @@ void CScript_HostPseudoModel::ImportData(CFXJSE_Arguments* pArguments) { void CScript_HostPseudoModel::ExportData(CFXJSE_Arguments* pArguments) { int32_t iLength = pArguments->GetLength(); if (iLength < 0 || iLength > 2) { - ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"exportData"); + ThrowParamCountMismatchException(L"exportData"); return; } CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); @@ -685,3 +676,23 @@ void CScript_HostPseudoModel::CurrentDateTime(CFXJSE_Arguments* pArguments) { if (pValue) pValue->SetString(FX_UTF8Encode(wsDataTime).AsStringC()); } + +void CScript_HostPseudoModel::ThrowSetLanguageException() const { + ThrowException(L"Unable to set language value."); +} + +void CScript_HostPseudoModel::ThrowSetNumPagesException() const { + ThrowException(L"Unable to set numPages value."); +} + +void CScript_HostPseudoModel::ThrowSetPlatformException() const { + ThrowException(L"Unable to set platform value."); +} + +void CScript_HostPseudoModel::ThrowSetVariationException() const { + ThrowException(L"Unable to set variation value."); +} + +void CScript_HostPseudoModel::ThrowSetVersionException() const { + ThrowException(L"Unable to set version value."); +} |