summaryrefslogtreecommitdiff
path: root/xfa
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-01-03 15:45:10 -0500
committerChromium commit bot <commit-bot@chromium.org>2017-01-03 21:08:58 +0000
commit3cdcfeb04b5c496199d8c88ebd2402c3db4413ab (patch)
treeabab4708b78aae2bec75ae6d1e9446aec863d159 /xfa
parente8f6897c2a80242217da785318b427c82c00ad40 (diff)
downloadpdfium-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')
-rw-r--r--xfa/fxfa/fm2js/xfa_fm2jscontext.cpp340
-rw-r--r--xfa/fxfa/fm2js/xfa_fm2jscontext.h11
-rw-r--r--xfa/fxfa/fxfa.h19
-rw-r--r--xfa/fxfa/parser/cscript_hostpseudomodel.cpp69
-rw-r--r--xfa/fxfa/parser/cscript_hostpseudomodel.h10
-rw-r--r--xfa/fxfa/parser/cscript_layoutpseudomodel.cpp18
-rw-r--r--xfa/fxfa/parser/cscript_layoutpseudomodel.h3
-rw-r--r--xfa/fxfa/parser/cscript_signaturepseudomodel.cpp8
-rw-r--r--xfa/fxfa/parser/cxfa_node.cpp1157
-rw-r--r--xfa/fxfa/parser/cxfa_nodelist.cpp111
-rw-r--r--xfa/fxfa/parser/cxfa_object.cpp27
-rw-r--r--xfa/fxfa/parser/xfa_object.h13
12 files changed, 891 insertions, 895 deletions
diff --git a/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp b/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp
index 862571e0af..7661679b41 100644
--- a/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp
+++ b/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp
@@ -513,8 +513,7 @@ void CXFA_FM2JSContext::Abs(CFXJSE_Value* pThis,
const CFX_ByteStringC& szFuncName,
CFXJSE_Arguments& args) {
if (args.GetLength() != 1) {
- ToJSContext(pThis, nullptr)
- ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Abs");
+ ToJSContext(pThis, nullptr)->ThrowParamCountMismatchException(L"Abs");
return;
}
@@ -605,8 +604,7 @@ void CXFA_FM2JSContext::Ceil(CFXJSE_Value* pThis,
const CFX_ByteStringC& szFuncName,
CFXJSE_Arguments& args) {
if (args.GetLength() != 1) {
- ToJSContext(pThis, nullptr)
- ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Ceil");
+ ToJSContext(pThis, nullptr)->ThrowParamCountMismatchException(L"Ceil");
return;
}
@@ -638,7 +636,7 @@ void CXFA_FM2JSContext::Count(CFXJSE_Value* pThis,
int32_t iLength = lengthValue->ToInteger();
if (iLength <= 2) {
- pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
+ pContext->ThrowArgumentMismatchException();
return;
}
@@ -681,8 +679,7 @@ void CXFA_FM2JSContext::Floor(CFXJSE_Value* pThis,
const CFX_ByteStringC& szFuncName,
CFXJSE_Arguments& args) {
if (args.GetLength() != 1) {
- ToJSContext(pThis, nullptr)
- ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Floor");
+ ToJSContext(pThis, nullptr)->ThrowParamCountMismatchException(L"Floor");
return;
}
@@ -714,7 +711,7 @@ void CXFA_FM2JSContext::Max(CFXJSE_Value* pThis,
argValue->GetObjectProperty("length", lengthValue.get());
int32_t iLength = lengthValue->ToInteger();
if (iLength <= 2) {
- pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
+ pContext->ThrowArgumentMismatchException();
return;
}
@@ -790,7 +787,7 @@ void CXFA_FM2JSContext::Min(CFXJSE_Value* pThis,
argValue->GetObjectProperty("length", lengthValue.get());
int32_t iLength = lengthValue->ToInteger();
if (iLength <= 2) {
- pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
+ pContext->ThrowArgumentMismatchException();
return;
}
@@ -854,7 +851,7 @@ void CXFA_FM2JSContext::Mod(CFXJSE_Value* pThis,
CFXJSE_Arguments& args) {
CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr);
if (args.GetLength() != 2) {
- pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Mod");
+ pContext->ThrowParamCountMismatchException(L"Mod");
return;
}
@@ -870,12 +867,12 @@ void CXFA_FM2JSContext::Mod(CFXJSE_Value* pThis,
bool argTwoResult;
FX_DOUBLE dDivisor = ExtractDouble(pThis, argTwo.get(), &argTwoResult);
if (!argOneResult || !argTwoResult) {
- pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
+ pContext->ThrowArgumentMismatchException();
return;
}
if (dDivisor == 0.0) {
- pContext->ThrowException(XFA_IDS_DIVIDE_ZERO);
+ pContext->ThrowDivideByZeroException();
return;
}
@@ -890,7 +887,7 @@ void CXFA_FM2JSContext::Round(CFXJSE_Value* pThis,
CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr);
int32_t argc = args.GetLength();
if (argc < 1 || argc > 2) {
- pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Round");
+ pContext->ThrowParamCountMismatchException(L"Round");
return;
}
@@ -903,7 +900,7 @@ void CXFA_FM2JSContext::Round(CFXJSE_Value* pThis,
bool dValueRet;
FX_DOUBLE dValue = ExtractDouble(pThis, argOne.get(), &dValueRet);
if (!dValueRet) {
- pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
+ pContext->ThrowArgumentMismatchException();
return;
}
@@ -918,7 +915,7 @@ void CXFA_FM2JSContext::Round(CFXJSE_Value* pThis,
bool dPrecisionRet;
FX_DOUBLE dPrecision = ExtractDouble(pThis, argTwo.get(), &dPrecisionRet);
if (!dPrecisionRet) {
- pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
+ pContext->ThrowArgumentMismatchException();
return;
}
@@ -955,7 +952,7 @@ void CXFA_FM2JSContext::Sum(CFXJSE_Value* pThis,
argValue->GetObjectProperty("length", lengthValue.get());
int32_t iLength = lengthValue->ToInteger();
if (iLength <= 2) {
- pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
+ pContext->ThrowArgumentMismatchException();
return;
}
@@ -1013,8 +1010,7 @@ void CXFA_FM2JSContext::Date(CFXJSE_Value* pThis,
const CFX_ByteStringC& szFuncName,
CFXJSE_Arguments& args) {
if (args.GetLength() != 0) {
- ToJSContext(pThis, nullptr)
- ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Date");
+ ToJSContext(pThis, nullptr)->ThrowParamCountMismatchException(L"Date");
return;
}
@@ -1039,8 +1035,7 @@ void CXFA_FM2JSContext::Date2Num(CFXJSE_Value* pThis,
CFXJSE_Arguments& args) {
int32_t argc = args.GetLength();
if (argc < 1 || argc > 3) {
- ToJSContext(pThis, nullptr)
- ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Date2Num");
+ ToJSContext(pThis, nullptr)->ThrowParamCountMismatchException(L"Date2Num");
return;
}
@@ -1090,8 +1085,7 @@ void CXFA_FM2JSContext::DateFmt(CFXJSE_Value* pThis,
CFXJSE_Arguments& args) {
int32_t argc = args.GetLength();
if (argc > 2) {
- ToJSContext(pThis, nullptr)
- ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Date2Num");
+ ToJSContext(pThis, nullptr)->ThrowParamCountMismatchException(L"Date2Num");
return;
}
@@ -1129,7 +1123,7 @@ void CXFA_FM2JSContext::IsoDate2Num(CFXJSE_Value* pThis,
CFXJSE_Arguments& args) {
if (args.GetLength() != 1) {
ToJSContext(pThis, nullptr)
- ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"IsoDate2Num");
+ ->ThrowParamCountMismatchException(L"IsoDate2Num");
return;
}
@@ -1150,8 +1144,7 @@ void CXFA_FM2JSContext::IsoTime2Num(CFXJSE_Value* pThis,
CFXJSE_Arguments& args) {
CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr);
if (args.GetLength() != 1) {
- pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD,
- L"IsoTime2Num");
+ pContext->ThrowParamCountMismatchException(L"IsoTime2Num");
return;
}
@@ -1210,7 +1203,7 @@ void CXFA_FM2JSContext::LocalDateFmt(CFXJSE_Value* pThis,
int32_t argc = args.GetLength();
if (argc > 2) {
ToJSContext(pThis, nullptr)
- ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"LocalDateFmt");
+ ->ThrowParamCountMismatchException(L"LocalDateFmt");
return;
}
@@ -1248,7 +1241,7 @@ void CXFA_FM2JSContext::LocalTimeFmt(CFXJSE_Value* pThis,
int32_t argc = args.GetLength();
if (argc > 2) {
ToJSContext(pThis, nullptr)
- ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"LocalTimeFmt");
+ ->ThrowParamCountMismatchException(L"LocalTimeFmt");
return;
}
@@ -1285,8 +1278,7 @@ void CXFA_FM2JSContext::Num2Date(CFXJSE_Value* pThis,
CFXJSE_Arguments& args) {
int32_t argc = args.GetLength();
if (argc < 1 || argc > 3) {
- ToJSContext(pThis, nullptr)
- ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Num2Date");
+ ToJSContext(pThis, nullptr)->ThrowParamCountMismatchException(L"Num2Date");
return;
}
@@ -1428,7 +1420,7 @@ void CXFA_FM2JSContext::Num2GMTime(CFXJSE_Value* pThis,
int32_t argc = args.GetLength();
if (argc < 1 || argc > 3) {
ToJSContext(pThis, nullptr)
- ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Num2GMTime");
+ ->ThrowParamCountMismatchException(L"Num2GMTime");
return;
}
@@ -1475,8 +1467,7 @@ void CXFA_FM2JSContext::Num2Time(CFXJSE_Value* pThis,
CFXJSE_Arguments& args) {
int32_t argc = args.GetLength();
if (argc < 1 || argc > 3) {
- ToJSContext(pThis, nullptr)
- ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Num2Time");
+ ToJSContext(pThis, nullptr)->ThrowParamCountMismatchException(L"Num2Time");
return;
}
@@ -1522,8 +1513,7 @@ void CXFA_FM2JSContext::Time(CFXJSE_Value* pThis,
const CFX_ByteStringC& szFuncName,
CFXJSE_Arguments& args) {
if (args.GetLength() != 0) {
- ToJSContext(pThis, nullptr)
- ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Time");
+ ToJSContext(pThis, nullptr)->ThrowParamCountMismatchException(L"Time");
return;
}
@@ -1541,8 +1531,7 @@ void CXFA_FM2JSContext::Time2Num(CFXJSE_Value* pThis,
CFXJSE_Arguments& args) {
int32_t argc = args.GetLength();
if (argc < 1 || argc > 3) {
- ToJSContext(pThis, nullptr)
- ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Time2Num");
+ ToJSContext(pThis, nullptr)->ThrowParamCountMismatchException(L"Time2Num");
return;
}
@@ -1632,8 +1621,7 @@ void CXFA_FM2JSContext::TimeFmt(CFXJSE_Value* pThis,
CFXJSE_Arguments& args) {
int32_t argc = args.GetLength();
if (argc > 2) {
- ToJSContext(pThis, nullptr)
- ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"TimeFmt");
+ ToJSContext(pThis, nullptr)->ThrowParamCountMismatchException(L"TimeFmt");
return;
}
@@ -2364,7 +2352,7 @@ void CXFA_FM2JSContext::Apr(CFXJSE_Value* pThis,
CFXJSE_Arguments& args) {
CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr);
if (args.GetLength() != 3) {
- pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Apr");
+ pContext->ThrowParamCountMismatchException(L"Apr");
return;
}
@@ -2381,7 +2369,7 @@ void CXFA_FM2JSContext::Apr(CFXJSE_Value* pThis,
FX_DOUBLE nPayment = ValueToDouble(pThis, argTwo.get());
FX_DOUBLE nPeriods = ValueToDouble(pThis, argThree.get());
if (nPrincipal <= 0 || nPayment <= 0 || nPeriods <= 0) {
- pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
+ pContext->ThrowArgumentMismatchException();
return;
}
@@ -2418,7 +2406,7 @@ void CXFA_FM2JSContext::CTerm(CFXJSE_Value* pThis,
CFXJSE_Arguments& args) {
CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr);
if (args.GetLength() != 3) {
- pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"CTerm");
+ pContext->ThrowParamCountMismatchException(L"CTerm");
return;
}
@@ -2435,7 +2423,7 @@ void CXFA_FM2JSContext::CTerm(CFXJSE_Value* pThis,
FX_FLOAT nFutureValue = ValueToFloat(pThis, argTwo.get());
FX_FLOAT nInitAmount = ValueToFloat(pThis, argThree.get());
if ((nRate <= 0) || (nFutureValue <= 0) || (nInitAmount <= 0)) {
- pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
+ pContext->ThrowArgumentMismatchException();
return;
}
@@ -2450,7 +2438,7 @@ void CXFA_FM2JSContext::FV(CFXJSE_Value* pThis,
CFXJSE_Arguments& args) {
CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr);
if (args.GetLength() != 3) {
- pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"FV");
+ pContext->ThrowParamCountMismatchException(L"FV");
return;
}
@@ -2467,7 +2455,7 @@ void CXFA_FM2JSContext::FV(CFXJSE_Value* pThis,
FX_DOUBLE nRate = ValueToDouble(pThis, argTwo.get());
FX_DOUBLE nPeriod = ValueToDouble(pThis, argThree.get());
if ((nRate < 0) || (nPeriod <= 0) || (nAmount <= 0)) {
- pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
+ pContext->ThrowArgumentMismatchException();
return;
}
@@ -2491,7 +2479,7 @@ void CXFA_FM2JSContext::IPmt(CFXJSE_Value* pThis,
CFXJSE_Arguments& args) {
CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr);
if (args.GetLength() != 5) {
- pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"IPmt");
+ pContext->ThrowParamCountMismatchException(L"IPmt");
return;
}
@@ -2514,7 +2502,7 @@ void CXFA_FM2JSContext::IPmt(CFXJSE_Value* pThis,
FX_FLOAT nNumberOfMonths = ValueToFloat(pThis, argFive.get());
if ((nPrincipalAmount <= 0) || (nRate <= 0) || (nPayment <= 0) ||
(nFirstMonth < 0) || (nNumberOfMonths < 0)) {
- pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
+ pContext->ThrowArgumentMismatchException();
return;
}
@@ -2549,7 +2537,7 @@ void CXFA_FM2JSContext::NPV(CFXJSE_Value* pThis,
CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr);
int32_t argc = args.GetLength();
if (argc < 3) {
- pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"NPV");
+ pContext->ThrowParamCountMismatchException(L"NPV");
return;
}
@@ -2564,7 +2552,7 @@ void CXFA_FM2JSContext::NPV(CFXJSE_Value* pThis,
FX_DOUBLE nRate = ValueToDouble(pThis, argValues[0].get());
if (nRate <= 0) {
- pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
+ pContext->ThrowArgumentMismatchException();
return;
}
@@ -2591,7 +2579,7 @@ void CXFA_FM2JSContext::Pmt(CFXJSE_Value* pThis,
CFXJSE_Arguments& args) {
CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr);
if (args.GetLength() != 3) {
- pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Pmt");
+ pContext->ThrowParamCountMismatchException(L"Pmt");
return;
}
@@ -2608,7 +2596,7 @@ void CXFA_FM2JSContext::Pmt(CFXJSE_Value* pThis,
FX_FLOAT nRate = ValueToFloat(pThis, argTwo.get());
FX_FLOAT nPeriods = ValueToFloat(pThis, argThree.get());
if ((nPrincipal <= 0) || (nRate <= 0) || (nPeriods <= 0)) {
- pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
+ pContext->ThrowArgumentMismatchException();
return;
}
@@ -2626,7 +2614,7 @@ void CXFA_FM2JSContext::PPmt(CFXJSE_Value* pThis,
CFXJSE_Arguments& args) {
CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr);
if (args.GetLength() != 5) {
- pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"PPmt");
+ pContext->ThrowParamCountMismatchException(L"PPmt");
return;
}
@@ -2649,7 +2637,7 @@ void CXFA_FM2JSContext::PPmt(CFXJSE_Value* pThis,
FX_FLOAT nNumberOfMonths = ValueToFloat(pThis, argFive.get());
if ((nPrincipalAmount <= 0) || (nRate <= 0) || (nPayment <= 0) ||
(nFirstMonth < 0) || (nNumberOfMonths < 0)) {
- pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
+ pContext->ThrowArgumentMismatchException();
return;
}
@@ -2660,7 +2648,7 @@ void CXFA_FM2JSContext::PPmt(CFXJSE_Value* pThis,
FXSYS_log10((FX_FLOAT)(1 + nRateOfMonth)));
int32_t iEnd = std::min((int32_t)(nFirstMonth + nNumberOfMonths - 1), iNums);
if (nPayment < nPrincipalAmount * nRateOfMonth) {
- pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
+ pContext->ThrowArgumentMismatchException();
return;
}
@@ -2684,7 +2672,7 @@ void CXFA_FM2JSContext::PV(CFXJSE_Value* pThis,
CFXJSE_Arguments& args) {
CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr);
if (args.GetLength() != 3) {
- pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"PV");
+ pContext->ThrowParamCountMismatchException(L"PV");
return;
}
@@ -2701,7 +2689,7 @@ void CXFA_FM2JSContext::PV(CFXJSE_Value* pThis,
FX_DOUBLE nRate = ValueToDouble(pThis, argTwo.get());
FX_DOUBLE nPeriod = ValueToDouble(pThis, argThree.get());
if ((nAmount <= 0) || (nRate < 0) || (nPeriod <= 0)) {
- pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
+ pContext->ThrowArgumentMismatchException();
return;
}
@@ -2719,7 +2707,7 @@ void CXFA_FM2JSContext::Rate(CFXJSE_Value* pThis,
CFXJSE_Arguments& args) {
CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr);
if (args.GetLength() != 3) {
- pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Rate");
+ pContext->ThrowParamCountMismatchException(L"Rate");
return;
}
@@ -2736,7 +2724,7 @@ void CXFA_FM2JSContext::Rate(CFXJSE_Value* pThis,
FX_FLOAT nPresent = ValueToFloat(pThis, argTwo.get());
FX_FLOAT nTotalNumber = ValueToFloat(pThis, argThree.get());
if ((nFuture <= 0) || (nPresent < 0) || (nTotalNumber <= 0)) {
- pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
+ pContext->ThrowArgumentMismatchException();
return;
}
@@ -2751,7 +2739,7 @@ void CXFA_FM2JSContext::Term(CFXJSE_Value* pThis,
CFXJSE_Arguments& args) {
CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr);
if (args.GetLength() != 3) {
- pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Term");
+ pContext->ThrowParamCountMismatchException(L"Term");
return;
}
@@ -2768,7 +2756,7 @@ void CXFA_FM2JSContext::Term(CFXJSE_Value* pThis,
FX_FLOAT nRate = ValueToFloat(pThis, argTwo.get());
FX_FLOAT nFuture = ValueToFloat(pThis, argThree.get());
if ((nMount <= 0) || (nRate <= 0) || (nFuture <= 0)) {
- pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
+ pContext->ThrowArgumentMismatchException();
return;
}
@@ -2784,7 +2772,7 @@ void CXFA_FM2JSContext::Choose(CFXJSE_Value* pThis,
CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr);
int32_t argc = args.GetLength();
if (argc < 2) {
- pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Choose");
+ pContext->ThrowParamCountMismatchException(L"Choose");
return;
}
@@ -2854,8 +2842,7 @@ void CXFA_FM2JSContext::Exists(CFXJSE_Value* pThis,
const CFX_ByteStringC& szFuncName,
CFXJSE_Arguments& args) {
if (args.GetLength() != 1) {
- ToJSContext(pThis, nullptr)
- ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Exists");
+ ToJSContext(pThis, nullptr)->ThrowParamCountMismatchException(L"Exists");
return;
}
args.GetReturnValue()->SetInteger(args.GetValue(0)->IsObject());
@@ -2866,8 +2853,7 @@ void CXFA_FM2JSContext::HasValue(CFXJSE_Value* pThis,
const CFX_ByteStringC& szFuncName,
CFXJSE_Arguments& args) {
if (args.GetLength() != 1) {
- ToJSContext(pThis, nullptr)
- ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"HasValue");
+ ToJSContext(pThis, nullptr)->ThrowParamCountMismatchException(L"HasValue");
return;
}
@@ -2888,8 +2874,7 @@ void CXFA_FM2JSContext::Oneof(CFXJSE_Value* pThis,
const CFX_ByteStringC& szFuncName,
CFXJSE_Arguments& args) {
if (args.GetLength() < 2) {
- ToJSContext(pThis, nullptr)
- ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Oneof");
+ ToJSContext(pThis, nullptr)->ThrowParamCountMismatchException(L"Oneof");
return;
}
@@ -2916,8 +2901,7 @@ void CXFA_FM2JSContext::Within(CFXJSE_Value* pThis,
const CFX_ByteStringC& szFuncName,
CFXJSE_Arguments& args) {
if (args.GetLength() != 3) {
- ToJSContext(pThis, nullptr)
- ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Within");
+ ToJSContext(pThis, nullptr)->ThrowParamCountMismatchException(L"Within");
return;
}
@@ -2954,8 +2938,7 @@ void CXFA_FM2JSContext::If(CFXJSE_Value* pThis,
const CFX_ByteStringC& szFuncName,
CFXJSE_Arguments& args) {
if (args.GetLength() != 3) {
- ToJSContext(pThis, nullptr)
- ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"If");
+ ToJSContext(pThis, nullptr)->ThrowParamCountMismatchException(L"If");
return;
}
@@ -2970,7 +2953,7 @@ void CXFA_FM2JSContext::Eval(CFXJSE_Value* pThis,
CFXJSE_Arguments& args) {
CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr);
if (args.GetLength() != 1) {
- pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Eval");
+ pContext->ThrowParamCountMismatchException(L"Eval");
return;
}
@@ -3007,14 +2990,14 @@ void CXFA_FM2JSContext::Ref(CFXJSE_Value* pThis,
CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr);
v8::Isolate* pIsolate = pContext->GetScriptRuntime();
if (args.GetLength() != 1) {
- pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Ref");
+ pContext->ThrowParamCountMismatchException(L"Ref");
return;
}
std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0);
if (!argOne->IsArray() && !argOne->IsObject() && !argOne->IsBoolean() &&
!argOne->IsString() && !argOne->IsNull() && !argOne->IsNumber()) {
- pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
+ pContext->ThrowArgumentMismatchException();
return;
}
@@ -3047,7 +3030,7 @@ void CXFA_FM2JSContext::Ref(CFXJSE_Value* pThis,
for (int32_t i = 0; i < 3; i++)
delete rgValues[i];
- pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
+ pContext->ThrowArgumentMismatchException();
return;
}
@@ -3069,8 +3052,7 @@ void CXFA_FM2JSContext::UnitType(CFXJSE_Value* pThis,
const CFX_ByteStringC& szFuncName,
CFXJSE_Arguments& args) {
if (args.GetLength() != 1) {
- ToJSContext(pThis, nullptr)
- ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"UnitType");
+ ToJSContext(pThis, nullptr)->ThrowParamCountMismatchException(L"UnitType");
return;
}
@@ -3183,8 +3165,7 @@ void CXFA_FM2JSContext::UnitValue(CFXJSE_Value* pThis,
CFXJSE_Arguments& args) {
int32_t argc = args.GetLength();
if (argc < 1 || argc > 2) {
- ToJSContext(pThis, nullptr)
- ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"UnitValue");
+ ToJSContext(pThis, nullptr)->ThrowParamCountMismatchException(L"UnitValue");
return;
}
@@ -3327,8 +3308,7 @@ void CXFA_FM2JSContext::At(CFXJSE_Value* pThis,
const CFX_ByteStringC& szFuncName,
CFXJSE_Arguments& args) {
if (args.GetLength() != 2) {
- ToJSContext(pThis, nullptr)
- ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"At");
+ ToJSContext(pThis, nullptr)->ThrowParamCountMismatchException(L"At");
return;
}
@@ -3358,8 +3338,7 @@ void CXFA_FM2JSContext::Concat(CFXJSE_Value* pThis,
CFXJSE_Arguments& args) {
int32_t argc = args.GetLength();
if (argc < 1) {
- ToJSContext(pThis, nullptr)
- ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Concat");
+ ToJSContext(pThis, nullptr)->ThrowParamCountMismatchException(L"Concat");
return;
}
@@ -3391,8 +3370,7 @@ void CXFA_FM2JSContext::Decode(CFXJSE_Value* pThis,
CFXJSE_Arguments& args) {
int32_t argc = args.GetLength();
if (argc < 1 || argc > 2) {
- ToJSContext(pThis, nullptr)
- ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Decode");
+ ToJSContext(pThis, nullptr)->ThrowParamCountMismatchException(L"Decode");
return;
}
@@ -3666,8 +3644,7 @@ void CXFA_FM2JSContext::Encode(CFXJSE_Value* pThis,
CFXJSE_Arguments& args) {
int32_t argc = args.GetLength();
if (argc < 1 || argc > 2) {
- ToJSContext(pThis, nullptr)
- ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Encode");
+ ToJSContext(pThis, nullptr)->ThrowParamCountMismatchException(L"Encode");
return;
}
@@ -3985,7 +3962,7 @@ void CXFA_FM2JSContext::Format(CFXJSE_Value* pThis,
CFXJSE_Arguments& args) {
CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr);
if (args.GetLength() < 2) {
- pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Format");
+ pContext->ThrowParamCountMismatchException(L"Format");
return;
}
@@ -4063,8 +4040,7 @@ void CXFA_FM2JSContext::Left(CFXJSE_Value* pThis,
const CFX_ByteStringC& szFuncName,
CFXJSE_Arguments& args) {
if (args.GetLength() != 2) {
- ToJSContext(pThis, nullptr)
- ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Left");
+ ToJSContext(pThis, nullptr)->ThrowParamCountMismatchException(L"Left");
return;
}
@@ -4087,8 +4063,7 @@ void CXFA_FM2JSContext::Len(CFXJSE_Value* pThis,
const CFX_ByteStringC& szFuncName,
CFXJSE_Arguments& args) {
if (args.GetLength() != 1) {
- ToJSContext(pThis, nullptr)
- ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Len");
+ ToJSContext(pThis, nullptr)->ThrowParamCountMismatchException(L"Len");
return;
}
@@ -4109,8 +4084,7 @@ void CXFA_FM2JSContext::Lower(CFXJSE_Value* pThis,
CFXJSE_Arguments& args) {
int32_t argc = args.GetLength();
if (argc < 1 || argc > 2) {
- ToJSContext(pThis, nullptr)
- ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Lower");
+ ToJSContext(pThis, nullptr)->ThrowParamCountMismatchException(L"Lower");
return;
}
@@ -4148,8 +4122,7 @@ void CXFA_FM2JSContext::Ltrim(CFXJSE_Value* pThis,
const CFX_ByteStringC& szFuncName,
CFXJSE_Arguments& args) {
if (args.GetLength() != 1) {
- ToJSContext(pThis, nullptr)
- ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Ltrim");
+ ToJSContext(pThis, nullptr)->ThrowParamCountMismatchException(L"Ltrim");
return;
}
@@ -4171,7 +4144,7 @@ void CXFA_FM2JSContext::Parse(CFXJSE_Value* pThis,
CFXJSE_Arguments& args) {
CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr);
if (args.GetLength() != 2) {
- pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Parse");
+ pContext->ThrowParamCountMismatchException(L"Parse");
return;
}
@@ -4302,8 +4275,7 @@ void CXFA_FM2JSContext::Replace(CFXJSE_Value* pThis,
CFXJSE_Arguments& args) {
int32_t argc = args.GetLength();
if (argc < 2 || argc > 3) {
- ToJSContext(pThis, nullptr)
- ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Replace");
+ ToJSContext(pThis, nullptr)->ThrowParamCountMismatchException(L"Replace");
return;
}
@@ -4361,8 +4333,7 @@ void CXFA_FM2JSContext::Right(CFXJSE_Value* pThis,
const CFX_ByteStringC& szFuncName,
CFXJSE_Arguments& args) {
if (args.GetLength() != 2) {
- ToJSContext(pThis, nullptr)
- ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Right");
+ ToJSContext(pThis, nullptr)->ThrowParamCountMismatchException(L"Right");
return;
}
@@ -4385,8 +4356,7 @@ void CXFA_FM2JSContext::Rtrim(CFXJSE_Value* pThis,
const CFX_ByteStringC& szFuncName,
CFXJSE_Arguments& args) {
if (args.GetLength() != 1) {
- ToJSContext(pThis, nullptr)
- ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Rtrim");
+ ToJSContext(pThis, nullptr)->ThrowParamCountMismatchException(L"Rtrim");
return;
}
@@ -4407,8 +4377,7 @@ void CXFA_FM2JSContext::Space(CFXJSE_Value* pThis,
const CFX_ByteStringC& szFuncName,
CFXJSE_Arguments& args) {
if (args.GetLength() != 1) {
- ToJSContext(pThis, nullptr)
- ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Space");
+ ToJSContext(pThis, nullptr)->ThrowParamCountMismatchException(L"Space");
return;
}
@@ -4435,8 +4404,7 @@ void CXFA_FM2JSContext::Str(CFXJSE_Value* pThis,
CFXJSE_Arguments& args) {
int32_t argc = args.GetLength();
if (argc < 1 || argc > 3) {
- ToJSContext(pThis, nullptr)
- ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Str");
+ ToJSContext(pThis, nullptr)->ThrowParamCountMismatchException(L"Str");
return;
}
@@ -4552,8 +4520,7 @@ void CXFA_FM2JSContext::Stuff(CFXJSE_Value* pThis,
CFXJSE_Arguments& args) {
int32_t argc = args.GetLength();
if (argc < 3 || argc > 4) {
- ToJSContext(pThis, nullptr)
- ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Stuff");
+ ToJSContext(pThis, nullptr)->ThrowParamCountMismatchException(L"Stuff");
return;
}
@@ -4602,8 +4569,7 @@ void CXFA_FM2JSContext::Substr(CFXJSE_Value* pThis,
const CFX_ByteStringC& szFuncName,
CFXJSE_Arguments& args) {
if (args.GetLength() != 3) {
- ToJSContext(pThis, nullptr)
- ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Substr");
+ ToJSContext(pThis, nullptr)->ThrowParamCountMismatchException(L"Substr");
return;
}
@@ -4643,8 +4609,7 @@ void CXFA_FM2JSContext::Uuid(CFXJSE_Value* pThis,
CFXJSE_Arguments& args) {
int32_t argc = args.GetLength();
if (argc < 0 || argc > 1) {
- ToJSContext(pThis, nullptr)
- ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Uuid");
+ ToJSContext(pThis, nullptr)->ThrowParamCountMismatchException(L"Uuid");
return;
}
@@ -4667,8 +4632,7 @@ void CXFA_FM2JSContext::Upper(CFXJSE_Value* pThis,
CFXJSE_Arguments& args) {
int32_t argc = args.GetLength();
if (argc < 1 || argc > 2) {
- ToJSContext(pThis, nullptr)
- ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Upper");
+ ToJSContext(pThis, nullptr)->ThrowParamCountMismatchException(L"Upper");
return;
}
@@ -4708,8 +4672,7 @@ void CXFA_FM2JSContext::WordNum(CFXJSE_Value* pThis,
CFXJSE_Arguments& args) {
int32_t argc = args.GetLength();
if (argc < 1 || argc > 3) {
- ToJSContext(pThis, nullptr)
- ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"WordNum");
+ ToJSContext(pThis, nullptr)->ThrowParamCountMismatchException(L"WordNum");
return;
}
@@ -4909,7 +4872,7 @@ void CXFA_FM2JSContext::Get(CFXJSE_Value* pThis,
CFXJSE_Arguments& args) {
CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr);
if (args.GetLength() != 1) {
- pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Get");
+ pContext->ThrowParamCountMismatchException(L"Get");
return;
}
@@ -4942,7 +4905,7 @@ void CXFA_FM2JSContext::Post(CFXJSE_Value* pThis,
CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr);
int32_t argc = args.GetLength();
if (argc < 2 || argc > 5) {
- pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Post");
+ pContext->ThrowParamCountMismatchException(L"Post");
return;
}
@@ -4987,7 +4950,7 @@ void CXFA_FM2JSContext::Post(CFXJSE_Value* pThis,
CFX_WideString::FromUTF8(bsContentType.AsStringC()),
CFX_WideString::FromUTF8(bsEncode.AsStringC()),
CFX_WideString::FromUTF8(bsHeader.AsStringC()), decodedResponse)) {
- pContext->ThrowException(XFA_IDS_SERVER_DENY);
+ pContext->ThrowServerDeniedException();
return;
}
@@ -5003,7 +4966,7 @@ void CXFA_FM2JSContext::Put(CFXJSE_Value* pThis,
CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr);
int32_t argc = args.GetLength();
if (argc < 2 || argc > 3) {
- pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Put");
+ pContext->ThrowParamCountMismatchException(L"Put");
return;
}
@@ -5033,7 +4996,7 @@ void CXFA_FM2JSContext::Put(CFXJSE_Value* pThis,
CFX_WideString::FromUTF8(bsURL.AsStringC()),
CFX_WideString::FromUTF8(bsData.AsStringC()),
CFX_WideString::FromUTF8(bsEncode.AsStringC()))) {
- pContext->ThrowException(XFA_IDS_SERVER_DENY);
+ pContext->ThrowServerDeniedException();
return;
}
@@ -5046,7 +5009,7 @@ void CXFA_FM2JSContext::assign_value_operator(CFXJSE_Value* pThis,
CFXJSE_Arguments& args) {
CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr);
if (args.GetLength() != 2) {
- pContext->ThrowException(XFA_IDS_COMPILER_ERROR);
+ pContext->ThrowCompilerErrorException();
return;
}
@@ -5064,7 +5027,7 @@ void CXFA_FM2JSContext::assign_value_operator(CFXJSE_Value* pThis,
for (int32_t i = 2; i < iLeftLength; i++) {
lValue->GetObjectPropertyByIdx(i, jsObjectValue.get());
if (!SetObjectDefaultValue(jsObjectValue.get(), rValue.get())) {
- pContext->ThrowException(XFA_IDS_NOT_DEFAUL_VALUE);
+ pContext->ThrowNoDefaultPropertyException(szFuncName);
return;
}
}
@@ -5077,7 +5040,7 @@ void CXFA_FM2JSContext::assign_value_operator(CFXJSE_Value* pThis,
}
} else if (lValue->IsObject()) {
if (!SetObjectDefaultValue(lValue.get(), rValue.get())) {
- pContext->ThrowException(XFA_IDS_NOT_DEFAUL_VALUE);
+ pContext->ThrowNoDefaultPropertyException(szFuncName);
return;
}
}
@@ -5089,7 +5052,7 @@ void CXFA_FM2JSContext::logical_or_operator(CFXJSE_Value* pThis,
const CFX_ByteStringC& szFuncName,
CFXJSE_Arguments& args) {
if (args.GetLength() != 2) {
- ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR);
+ ToJSContext(pThis, nullptr)->ThrowCompilerErrorException();
return;
}
@@ -5110,7 +5073,7 @@ void CXFA_FM2JSContext::logical_and_operator(CFXJSE_Value* pThis,
const CFX_ByteStringC& szFuncName,
CFXJSE_Arguments& args) {
if (args.GetLength() != 2) {
- ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR);
+ ToJSContext(pThis, nullptr)->ThrowCompilerErrorException();
return;
}
@@ -5131,7 +5094,7 @@ void CXFA_FM2JSContext::equality_operator(CFXJSE_Value* pThis,
const CFX_ByteStringC& szFuncName,
CFXJSE_Arguments& args) {
if (args.GetLength() != 2) {
- ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR);
+ ToJSContext(pThis, nullptr)->ThrowCompilerErrorException();
return;
}
@@ -5164,7 +5127,7 @@ void CXFA_FM2JSContext::notequality_operator(CFXJSE_Value* pThis,
const CFX_ByteStringC& szFuncName,
CFXJSE_Arguments& args) {
if (args.GetLength() != 2) {
- ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR);
+ ToJSContext(pThis, nullptr)->ThrowCompilerErrorException();
return;
}
@@ -5224,7 +5187,7 @@ void CXFA_FM2JSContext::less_operator(CFXJSE_Value* pThis,
const CFX_ByteStringC& szFuncName,
CFXJSE_Arguments& args) {
if (args.GetLength() != 2) {
- ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR);
+ ToJSContext(pThis, nullptr)->ThrowCompilerErrorException();
return;
}
@@ -5251,7 +5214,7 @@ void CXFA_FM2JSContext::lessequal_operator(CFXJSE_Value* pThis,
const CFX_ByteStringC& szFuncName,
CFXJSE_Arguments& args) {
if (args.GetLength() != 2) {
- ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR);
+ ToJSContext(pThis, nullptr)->ThrowCompilerErrorException();
return;
}
@@ -5279,7 +5242,7 @@ void CXFA_FM2JSContext::greater_operator(CFXJSE_Value* pThis,
const CFX_ByteStringC& szFuncName,
CFXJSE_Arguments& args) {
if (args.GetLength() != 2) {
- ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR);
+ ToJSContext(pThis, nullptr)->ThrowCompilerErrorException();
return;
}
@@ -5306,7 +5269,7 @@ void CXFA_FM2JSContext::greaterequal_operator(CFXJSE_Value* pThis,
const CFX_ByteStringC& szFuncName,
CFXJSE_Arguments& args) {
if (args.GetLength() != 2) {
- ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR);
+ ToJSContext(pThis, nullptr)->ThrowCompilerErrorException();
return;
}
@@ -5334,7 +5297,7 @@ void CXFA_FM2JSContext::plus_operator(CFXJSE_Value* pThis,
const CFX_ByteStringC& szFuncName,
CFXJSE_Arguments& args) {
if (args.GetLength() != 2) {
- ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR);
+ ToJSContext(pThis, nullptr)->ThrowCompilerErrorException();
return;
}
@@ -5356,7 +5319,7 @@ void CXFA_FM2JSContext::minus_operator(CFXJSE_Value* pThis,
const CFX_ByteStringC& szFuncName,
CFXJSE_Arguments& args) {
if (args.GetLength() != 2) {
- ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR);
+ ToJSContext(pThis, nullptr)->ThrowCompilerErrorException();
return;
}
@@ -5377,7 +5340,7 @@ void CXFA_FM2JSContext::multiple_operator(CFXJSE_Value* pThis,
const CFX_ByteStringC& szFuncName,
CFXJSE_Arguments& args) {
if (args.GetLength() != 2) {
- ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR);
+ ToJSContext(pThis, nullptr)->ThrowCompilerErrorException();
return;
}
@@ -5399,7 +5362,7 @@ void CXFA_FM2JSContext::divide_operator(CFXJSE_Value* pThis,
CFXJSE_Arguments& args) {
CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr);
if (args.GetLength() != 2) {
- pContext->ThrowException(XFA_IDS_COMPILER_ERROR);
+ pContext->ThrowCompilerErrorException();
return;
}
@@ -5412,7 +5375,7 @@ void CXFA_FM2JSContext::divide_operator(CFXJSE_Value* pThis,
FX_DOUBLE second = ValueToDouble(pThis, argSecond.get());
if (second == 0.0) {
- pContext->ThrowException(XFA_IDS_DIVIDE_ZERO);
+ pContext->ThrowDivideByZeroException();
return;
}
@@ -5425,7 +5388,7 @@ void CXFA_FM2JSContext::positive_operator(CFXJSE_Value* pThis,
const CFX_ByteStringC& szFuncName,
CFXJSE_Arguments& args) {
if (args.GetLength() != 1) {
- ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR);
+ ToJSContext(pThis, nullptr)->ThrowCompilerErrorException();
return;
}
@@ -5442,7 +5405,7 @@ void CXFA_FM2JSContext::negative_operator(CFXJSE_Value* pThis,
const CFX_ByteStringC& szFuncName,
CFXJSE_Arguments& args) {
if (args.GetLength() != 1) {
- ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR);
+ ToJSContext(pThis, nullptr)->ThrowCompilerErrorException();
return;
}
@@ -5459,7 +5422,7 @@ void CXFA_FM2JSContext::logical_not_operator(CFXJSE_Value* pThis,
const CFX_ByteStringC& szFuncName,
CFXJSE_Arguments& args) {
if (args.GetLength() != 1) {
- ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR);
+ ToJSContext(pThis, nullptr)->ThrowCompilerErrorException();
return;
}
@@ -5481,7 +5444,7 @@ void CXFA_FM2JSContext::dot_accessor(CFXJSE_Value* pThis,
v8::Isolate* pIsolate = pContext->GetScriptRuntime();
int32_t argc = args.GetLength();
if (argc < 4 || argc > 5) {
- pContext->ThrowException(XFA_IDS_COMPILER_ERROR);
+ pContext->ThrowCompilerErrorException();
return;
}
@@ -5522,12 +5485,9 @@ void CXFA_FM2JSContext::dot_accessor(CFXJSE_Value* pThis,
}
}
if (iCounter < 1) {
- CFX_WideString wsPropertyName =
- CFX_WideString::FromUTF8(szName.AsStringC());
- CFX_WideString wsSomExpression =
- CFX_WideString::FromUTF8(szSomExp.AsStringC());
- pContext->ThrowException(XFA_IDS_ACCESS_PROPERTY_IN_NOT_OBJECT,
- wsPropertyName.c_str(), wsSomExpression.c_str());
+ pContext->ThrowPropertyNotInObjectException(
+ CFX_WideString::FromUTF8(szName.AsStringC()),
+ CFX_WideString::FromUTF8(szSomExp.AsStringC()));
return;
}
@@ -5581,12 +5541,9 @@ void CXFA_FM2JSContext::dot_accessor(CFXJSE_Value* pThis,
resoveNodeRS, true, szName.IsEmpty());
}
if (iRet < 1) {
- CFX_WideString wsPropertyName =
- CFX_WideString::FromUTF8(szName.AsStringC());
- CFX_WideString wsSomExpression =
- CFX_WideString::FromUTF8(szSomExp.AsStringC());
- pContext->ThrowException(XFA_IDS_ACCESS_PROPERTY_IN_NOT_OBJECT,
- wsPropertyName.c_str(), wsSomExpression.c_str());
+ pContext->ThrowPropertyNotInObjectException(
+ CFX_WideString::FromUTF8(szName.AsStringC()),
+ CFX_WideString::FromUTF8(szSomExp.AsStringC()));
return;
}
@@ -5626,7 +5583,7 @@ void CXFA_FM2JSContext::dotdot_accessor(CFXJSE_Value* pThis,
v8::Isolate* pIsolate = pContext->GetScriptRuntime();
int32_t argc = args.GetLength();
if (argc < 4 || argc > 5) {
- pContext->ThrowException(XFA_IDS_COMPILER_ERROR);
+ pContext->ThrowCompilerErrorException();
return;
}
@@ -5664,12 +5621,9 @@ void CXFA_FM2JSContext::dotdot_accessor(CFXJSE_Value* pThis,
}
}
if (iCounter < 1) {
- CFX_WideString wsPropertyName =
- CFX_WideString::FromUTF8(szName.AsStringC());
- CFX_WideString wsSomExpression =
- CFX_WideString::FromUTF8(szSomExp.AsStringC());
- pContext->ThrowException(XFA_IDS_ACCESS_PROPERTY_IN_NOT_OBJECT,
- wsPropertyName.c_str(), wsSomExpression.c_str());
+ pContext->ThrowPropertyNotInObjectException(
+ CFX_WideString::FromUTF8(szName.AsStringC()),
+ CFX_WideString::FromUTF8(szSomExp.AsStringC()));
return;
}
@@ -5719,12 +5673,9 @@ void CXFA_FM2JSContext::dotdot_accessor(CFXJSE_Value* pThis,
resoveNodeRS, false);
}
if (iRet < 1) {
- CFX_WideString wsPropertyName =
- CFX_WideString::FromUTF8(szName.AsStringC());
- CFX_WideString wsSomExpression =
- CFX_WideString::FromUTF8(szSomExp.AsStringC());
- pContext->ThrowException(XFA_IDS_ACCESS_PROPERTY_IN_NOT_OBJECT,
- wsPropertyName.c_str(), wsSomExpression.c_str());
+ pContext->ThrowPropertyNotInObjectException(
+ CFX_WideString::FromUTF8(szName.AsStringC()),
+ CFX_WideString::FromUTF8(szSomExp.AsStringC()));
return;
}
@@ -5763,7 +5714,7 @@ void CXFA_FM2JSContext::eval_translation(CFXJSE_Value* pThis,
CFXJSE_Arguments& args) {
CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr);
if (args.GetLength() != 1) {
- pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Eval");
+ pContext->ThrowParamCountMismatchException(L"Eval");
return;
}
@@ -5771,7 +5722,7 @@ void CXFA_FM2JSContext::eval_translation(CFXJSE_Value* pThis,
CFX_ByteString argString;
ValueToUTF8String(argOne.get(), argString);
if (argString.IsEmpty()) {
- pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
+ pContext->ThrowArgumentMismatchException();
return;
}
@@ -5781,7 +5732,7 @@ void CXFA_FM2JSContext::eval_translation(CFXJSE_Value* pThis,
CXFA_FM2JSContext::Translate(scriptString.AsStringC(), wsJavaScriptBuf,
wsError);
if (!wsError.IsEmpty()) {
- pContext->ThrowException(XFA_IDS_COMPILER_ERROR);
+ pContext->ThrowCompilerErrorException();
return;
}
@@ -5822,7 +5773,7 @@ void CXFA_FM2JSContext::get_fm_value(CFXJSE_Value* pThis,
CFXJSE_Arguments& args) {
CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr);
if (args.GetLength() != 1) {
- pContext->ThrowException(XFA_IDS_COMPILER_ERROR);
+ pContext->ThrowCompilerErrorException();
return;
}
@@ -5856,7 +5807,7 @@ void CXFA_FM2JSContext::get_fm_jsobj(CFXJSE_Value* pThis,
const CFX_ByteStringC& szFuncName,
CFXJSE_Arguments& args) {
if (args.GetLength() != 1) {
- ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR);
+ ToJSContext(pThis, nullptr)->ThrowCompilerErrorException();
return;
}
@@ -5883,7 +5834,7 @@ void CXFA_FM2JSContext::fm_var_filter(CFXJSE_Value* pThis,
CFXJSE_Arguments& args) {
CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr);
if (args.GetLength() != 1) {
- pContext->ThrowException(XFA_IDS_COMPILER_ERROR);
+ pContext->ThrowCompilerErrorException();
return;
}
@@ -5928,7 +5879,7 @@ void CXFA_FM2JSContext::fm_var_filter(CFXJSE_Value* pThis,
std::unique_ptr<CFXJSE_Value> objectValue(new CFXJSE_Value(pIsolate));
argOne->GetObjectPropertyByIdx(2, objectValue.get());
if (objectValue->IsNull()) {
- pContext->ThrowException(XFA_IDS_COMPILER_ERROR);
+ pContext->ThrowCompilerErrorException();
return;
}
args.GetReturnValue()->Assign(argOne.get());
@@ -6509,14 +6460,47 @@ void CXFA_FM2JSContext::GlobalPropertyGetter(CFXJSE_Value* pValue) {
pValue->Assign(m_pValue.get());
}
-void CXFA_FM2JSContext::ThrowException(int32_t iStringID, ...) {
- IXFA_AppProvider* pAppProvider = m_pDocument->GetNotify()->GetAppProvider();
- ASSERT(pAppProvider);
+void CXFA_FM2JSContext::ThrowNoDefaultPropertyException(
+ const CFX_ByteStringC& name) const {
+ ThrowException(L"%s doesn't have a default property.", name.c_str());
+}
+
+void CXFA_FM2JSContext::ThrowCompilerErrorException() const {
+ ThrowException(L"Compiler error.");
+}
+
+void CXFA_FM2JSContext::ThrowDivideByZeroException() const {
+ ThrowException(L"Divide by zero.");
+}
+
+void CXFA_FM2JSContext::ThrowServerDeniedException() const {
+ ThrowException(L"Server does not permit operation.");
+}
+
+void CXFA_FM2JSContext::ThrowPropertyNotInObjectException(
+ const CFX_WideString& name,
+ const CFX_WideString& exp) const {
+ ThrowException(
+ L"An attempt was made to reference property '%s' of a non-object "
+ L"in SOM expression %s.",
+ name.c_str(), exp.c_str());
+}
+
+void CXFA_FM2JSContext::ThrowParamCountMismatchException(
+ const CFX_WideString& method) const {
+ ThrowException(L"Incorrect number of parameters calling method '%s'.",
+ method.c_str());
+}
+
+void CXFA_FM2JSContext::ThrowArgumentMismatchException() const {
+ ThrowException(L"Argument mismatch in property or function argument.");
+}
+void CXFA_FM2JSContext::ThrowException(const FX_WCHAR* str, ...) const {
CFX_WideString wsMessage;
va_list arg_ptr;
- va_start(arg_ptr, iStringID);
- wsMessage.FormatV(pAppProvider->LoadString(iStringID).c_str(), arg_ptr);
+ va_start(arg_ptr, str);
+ wsMessage.FormatV(str, arg_ptr);
va_end(arg_ptr);
FXJSE_ThrowMessage(
FX_UTF8Encode(wsMessage.c_str(), wsMessage.GetLength()).AsStringC());
diff --git a/xfa/fxfa/fm2js/xfa_fm2jscontext.h b/xfa/fxfa/fm2js/xfa_fm2jscontext.h
index f6be186c15..413cb3027a 100644
--- a/xfa/fxfa/fm2js/xfa_fm2jscontext.h
+++ b/xfa/fxfa/fm2js/xfa_fm2jscontext.h
@@ -452,7 +452,16 @@ class CXFA_FM2JSContext : public CFXJSE_HostObject {
private:
v8::Isolate* GetScriptRuntime() const { return m_pIsolate; }
CXFA_Document* GetDocument() const { return m_pDocument; }
- void ThrowException(int32_t iStringID, ...);
+
+ void ThrowNoDefaultPropertyException(const CFX_ByteStringC& name) const;
+ void ThrowCompilerErrorException() const;
+ void ThrowDivideByZeroException() const;
+ void ThrowServerDeniedException() const;
+ void ThrowPropertyNotInObjectException(const CFX_WideString& name,
+ const CFX_WideString& exp) const;
+ void ThrowArgumentMismatchException() const;
+ void ThrowParamCountMismatchException(const CFX_WideString& method) const;
+ void ThrowException(const FX_WCHAR* str, ...) const;
v8::Isolate* m_pIsolate;
CFXJSE_Class* m_pFMClass;
diff --git a/xfa/fxfa/fxfa.h b/xfa/fxfa/fxfa.h
index 26569476b5..dd5fc0fcbc 100644
--- a/xfa/fxfa/fxfa.h
+++ b/xfa/fxfa/fxfa.h
@@ -39,24 +39,6 @@ class IXFA_WidgetIterator;
#define XFA_IDNo 3
#define XFA_IDYes 4
-#define XFA_IDS_INVAlID_PROP_SET 13
-#define XFA_IDS_NOT_DEFAUL_VALUE 14
-#define XFA_IDS_UNABLE_SET_LANGUAGE 15
-#define XFA_IDS_UNABLE_SET_NUMPAGES 16
-#define XFA_IDS_UNABLE_SET_PLATFORM 17
-#define XFA_IDS_UNABLE_SET_VARIATION 19
-#define XFA_IDS_UNABLE_SET_VERSION 20
-#define XFA_IDS_UNABLE_SET_READY 21
-#define XFA_IDS_COMPILER_ERROR 35
-#define XFA_IDS_DIVIDE_ZERO 44
-#define XFA_IDS_ACCESS_PROPERTY_IN_NOT_OBJECT 61
-#define XFA_IDS_INDEX_OUT_OF_BOUNDS 64
-#define XFA_IDS_INCORRECT_NUMBER_OF_METHOD 65
-#define XFA_IDS_ARGUMENT_MISMATCH 66
-#define XFA_IDS_NOT_HAVE_PROPERTY 70
-#define XFA_IDS_VIOLATE_BOUNDARY 72
-#define XFA_IDS_SERVER_DENY 73
-
#define XFA_DOCVIEW_View 0x00000000
#define XFA_DOCVIEW_MasterPage 0x00000001
#define XFA_DOCVIEW_Design 0x00000002
@@ -242,7 +224,6 @@ class IXFA_AppProvider {
const CFX_WideString& wsData,
const CFX_WideString& wsEncode) = 0;
- virtual CFX_WideString LoadString(int32_t iStringID) = 0;
virtual IFWL_AdapterTimerMgr* GetTimerMgr() = 0;
};
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.");
+}
diff --git a/xfa/fxfa/parser/cscript_hostpseudomodel.h b/xfa/fxfa/parser/cscript_hostpseudomodel.h
index 76c910b801..7d24a1d2b4 100644
--- a/xfa/fxfa/parser/cscript_hostpseudomodel.h
+++ b/xfa/fxfa/parser/cscript_hostpseudomodel.h
@@ -51,12 +51,16 @@ class CScript_HostPseudoModel : public CXFA_Object {
void CurrentDateTime(CFXJSE_Arguments* pArguments);
protected:
- void LoadString(CFXJSE_Value* pValue,
- CXFA_FFNotify* pNotify,
- uint32_t dwFlag);
bool ValidateArgsForMsg(CFXJSE_Arguments* pArguments,
int32_t iArgIndex,
CFX_WideString& wsValue);
+
+ private:
+ void ThrowSetLanguageException() const;
+ void ThrowSetNumPagesException() const;
+ void ThrowSetPlatformException() const;
+ void ThrowSetVariationException() const;
+ void ThrowSetVersionException() const;
};
#endif // XFA_FXFA_PARSER_CSCRIPT_HOSTPSEUDOMODEL_H_
diff --git a/xfa/fxfa/parser/cscript_layoutpseudomodel.cpp b/xfa/fxfa/parser/cscript_layoutpseudomodel.cpp
index a9c63666b3..a1d1ca5785 100644
--- a/xfa/fxfa/parser/cscript_layoutpseudomodel.cpp
+++ b/xfa/fxfa/parser/cscript_layoutpseudomodel.cpp
@@ -39,7 +39,7 @@ void CScript_LayoutPseudoModel::Ready(CFXJSE_Value* pValue,
return;
}
if (bSetting) {
- ThrowException(XFA_IDS_UNABLE_SET_READY);
+ ThrowSetReadyException();
return;
}
int32_t iStatus = pNotify->GetLayoutStatus();
@@ -65,7 +65,7 @@ void CScript_LayoutPseudoModel::HWXY(CFXJSE_Arguments* pArguments,
methodName = L"y";
break;
}
- ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, methodName);
+ ThrowParamCountMismatchException(methodName);
return;
}
CXFA_Node* pNode = nullptr;
@@ -177,7 +177,7 @@ void CScript_LayoutPseudoModel::PageCount(CFXJSE_Arguments* pArguments) {
void CScript_LayoutPseudoModel::PageSpan(CFXJSE_Arguments* pArguments) {
int32_t iLength = pArguments->GetLength();
if (iLength != 1) {
- ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"pageSpan");
+ ThrowParamCountMismatchException(L"pageSpan");
return;
}
CXFA_Node* pNode = nullptr;
@@ -343,7 +343,7 @@ void CScript_LayoutPseudoModel::GetObjArray(CXFA_LayoutProcessor* pDocLayout,
void CScript_LayoutPseudoModel::PageContent(CFXJSE_Arguments* pArguments) {
int32_t iLength = pArguments->GetLength();
if (iLength < 1 || iLength > 3) {
- ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"pageContent");
+ ThrowParamCountMismatchException(L"pageContent");
return;
}
int32_t iIndex = 0;
@@ -411,7 +411,7 @@ void CScript_LayoutPseudoModel::AbsPageSpan(CFXJSE_Arguments* pArguments) {
void CScript_LayoutPseudoModel::AbsPageInBatch(CFXJSE_Arguments* pArguments) {
if (pArguments->GetLength() != 1) {
- ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"absPageInBatch");
+ ThrowParamCountMismatchException(L"absPageInBatch");
return;
}
@@ -422,7 +422,7 @@ void CScript_LayoutPseudoModel::AbsPageInBatch(CFXJSE_Arguments* pArguments) {
void CScript_LayoutPseudoModel::SheetInBatch(CFXJSE_Arguments* pArguments) {
if (pArguments->GetLength() != 1) {
- ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"sheetInBatch");
+ ThrowParamCountMismatchException(L"sheetInBatch");
return;
}
@@ -456,7 +456,7 @@ void CScript_LayoutPseudoModel::PageImp(CFXJSE_Arguments* pArguments,
} else {
methodName = L"page";
}
- ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, methodName);
+ ThrowParamCountMismatchException(methodName);
return;
}
CXFA_Node* pNode = nullptr;
@@ -481,3 +481,7 @@ void CScript_LayoutPseudoModel::PageImp(CFXJSE_Arguments* pArguments,
if (pValue)
pValue->SetInteger(bAbsPage ? iPage : iPage + 1);
}
+
+void CScript_LayoutPseudoModel::ThrowSetReadyException() const {
+ ThrowException(L"Unable to set ready value.");
+}
diff --git a/xfa/fxfa/parser/cscript_layoutpseudomodel.h b/xfa/fxfa/parser/cscript_layoutpseudomodel.h
index ad64417bf3..55a00db14a 100644
--- a/xfa/fxfa/parser/cscript_layoutpseudomodel.h
+++ b/xfa/fxfa/parser/cscript_layoutpseudomodel.h
@@ -55,6 +55,9 @@ class CScript_LayoutPseudoModel : public CXFA_Object {
bool bOnPageArea,
CXFA_NodeArray& retArray);
void PageImp(CFXJSE_Arguments* pArguments, bool bAbsPage);
+
+ private:
+ void ThrowSetReadyException() const;
};
#endif // XFA_FXFA_PARSER_CSCRIPT_LAYOUTPSEUDOMODEL_H_
diff --git a/xfa/fxfa/parser/cscript_signaturepseudomodel.cpp b/xfa/fxfa/parser/cscript_signaturepseudomodel.cpp
index 391f3be381..e5874a61cc 100644
--- a/xfa/fxfa/parser/cscript_signaturepseudomodel.cpp
+++ b/xfa/fxfa/parser/cscript_signaturepseudomodel.cpp
@@ -26,7 +26,7 @@ CScript_SignaturePseudoModel::~CScript_SignaturePseudoModel() {}
void CScript_SignaturePseudoModel::Verify(CFXJSE_Arguments* pArguments) {
int32_t iLength = pArguments->GetLength();
if (iLength < 1 || iLength > 4) {
- ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"verify");
+ ThrowParamCountMismatchException(L"verify");
return;
}
@@ -38,7 +38,7 @@ void CScript_SignaturePseudoModel::Verify(CFXJSE_Arguments* pArguments) {
void CScript_SignaturePseudoModel::Sign(CFXJSE_Arguments* pArguments) {
int32_t iLength = pArguments->GetLength();
if (iLength < 3 || iLength > 7) {
- ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"sign");
+ ThrowParamCountMismatchException(L"sign");
return;
}
@@ -49,7 +49,7 @@ void CScript_SignaturePseudoModel::Sign(CFXJSE_Arguments* pArguments) {
void CScript_SignaturePseudoModel::Enumerate(CFXJSE_Arguments* pArguments) {
if (pArguments->GetLength() != 0) {
- ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"enumerate");
+ ThrowParamCountMismatchException(L"enumerate");
return;
}
return;
@@ -58,7 +58,7 @@ void CScript_SignaturePseudoModel::Enumerate(CFXJSE_Arguments* pArguments) {
void CScript_SignaturePseudoModel::Clear(CFXJSE_Arguments* pArguments) {
int32_t iLength = pArguments->GetLength();
if (iLength < 1 || iLength > 2) {
- ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"clear");
+ ThrowParamCountMismatchException(L"clear");
return;
}
diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp
index cabf87fa7f..1bde816d3d 100644
--- a/xfa/fxfa/parser/cxfa_node.cpp
+++ b/xfa/fxfa/parser/cxfa_node.cpp
@@ -994,7 +994,7 @@ void CXFA_Node::SetDataDescriptionNode(CXFA_Node* pDataDescriptionNode) {
void CXFA_Node::Script_TreeClass_ResolveNode(CFXJSE_Arguments* pArguments) {
int32_t iLength = pArguments->GetLength();
if (iLength != 1) {
- ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"resolveNode");
+ ThrowParamCountMismatchException(L"resolveNode");
return;
}
CFX_WideString wsExpression =
@@ -1037,7 +1037,7 @@ void CXFA_Node::Script_TreeClass_ResolveNode(CFXJSE_Arguments* pArguments) {
void CXFA_Node::Script_TreeClass_ResolveNodes(CFXJSE_Arguments* pArguments) {
int32_t iLength = pArguments->GetLength();
if (iLength != 1) {
- ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"resolveNodes");
+ ThrowParamCountMismatchException(L"resolveNodes");
return;
}
CFX_WideString wsExpression =
@@ -1090,14 +1090,15 @@ void CXFA_Node::Script_TreeClass_All(CFXJSE_Value* pValue,
bool bSetting,
XFA_ATTRIBUTE eAttribute) {
if (bSetting) {
- ThrowException(XFA_IDS_INVAlID_PROP_SET);
- } else {
- uint32_t dwFlag = XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_ALL;
- CFX_WideString wsName;
- GetAttribute(XFA_ATTRIBUTE_Name, wsName);
- CFX_WideString wsExpression = wsName + FX_WSTRC(L"[*]");
- Script_Som_ResolveNodeList(pValue, wsExpression, dwFlag);
+ ThrowInvalidPropertyException();
+ return;
}
+
+ uint32_t dwFlag = XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_ALL;
+ CFX_WideString wsName;
+ GetAttribute(XFA_ATTRIBUTE_Name, wsName);
+ CFX_WideString wsExpression = wsName + FX_WSTRC(L"[*]");
+ Script_Som_ResolveNodeList(pValue, wsExpression, dwFlag);
}
void CXFA_Node::Script_TreeClass_Nodes(CFXJSE_Value* pValue,
@@ -1120,65 +1121,67 @@ void CXFA_Node::Script_TreeClass_ClassAll(CFXJSE_Value* pValue,
bool bSetting,
XFA_ATTRIBUTE eAttribute) {
if (bSetting) {
- ThrowException(XFA_IDS_INVAlID_PROP_SET);
- } else {
- uint32_t dwFlag = XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_ALL;
- CFX_WideString wsExpression =
- FX_WSTRC(L"#") + GetClassName() + FX_WSTRC(L"[*]");
- Script_Som_ResolveNodeList(pValue, wsExpression, dwFlag);
+ ThrowInvalidPropertyException();
+ return;
}
+
+ uint32_t dwFlag = XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_ALL;
+ CFX_WideString wsExpression =
+ FX_WSTRC(L"#") + GetClassName() + FX_WSTRC(L"[*]");
+ Script_Som_ResolveNodeList(pValue, wsExpression, dwFlag);
}
void CXFA_Node::Script_TreeClass_Parent(CFXJSE_Value* pValue,
bool bSetting,
XFA_ATTRIBUTE eAttribute) {
if (bSetting) {
- ThrowException(XFA_IDS_INVAlID_PROP_SET);
+ ThrowInvalidPropertyException();
+ return;
+ }
+ CXFA_Node* pParent = GetNodeItem(XFA_NODEITEM_Parent);
+ if (pParent) {
+ pValue->Assign(m_pDocument->GetScriptContext()->GetJSValueFromMap(pParent));
} else {
- CXFA_Node* pParent = GetNodeItem(XFA_NODEITEM_Parent);
- if (pParent) {
- pValue->Assign(
- m_pDocument->GetScriptContext()->GetJSValueFromMap(pParent));
- } else {
- pValue->SetNull();
- }
+ pValue->SetNull();
}
}
void CXFA_Node::Script_TreeClass_Index(CFXJSE_Value* pValue,
bool bSetting,
XFA_ATTRIBUTE eAttribute) {
- if (bSetting)
- ThrowException(XFA_IDS_INVAlID_PROP_SET);
- else
- pValue->SetInteger(GetNodeSameNameIndex());
+ if (bSetting) {
+ ThrowInvalidPropertyException();
+ return;
+ }
+ pValue->SetInteger(GetNodeSameNameIndex());
}
void CXFA_Node::Script_TreeClass_ClassIndex(CFXJSE_Value* pValue,
bool bSetting,
XFA_ATTRIBUTE eAttribute) {
- if (bSetting)
- ThrowException(XFA_IDS_INVAlID_PROP_SET);
- else
- pValue->SetInteger(GetNodeSameClassIndex());
+ if (bSetting) {
+ ThrowInvalidPropertyException();
+ return;
+ }
+ pValue->SetInteger(GetNodeSameClassIndex());
}
void CXFA_Node::Script_TreeClass_SomExpression(CFXJSE_Value* pValue,
bool bSetting,
XFA_ATTRIBUTE eAttribute) {
if (bSetting) {
- ThrowException(XFA_IDS_INVAlID_PROP_SET);
- } else {
- CFX_WideString wsSOMExpression;
- GetSOMExpression(wsSOMExpression);
- pValue->SetString(FX_UTF8Encode(wsSOMExpression).AsStringC());
+ ThrowInvalidPropertyException();
+ return;
}
+ CFX_WideString wsSOMExpression;
+ GetSOMExpression(wsSOMExpression);
+ pValue->SetString(FX_UTF8Encode(wsSOMExpression).AsStringC());
}
void CXFA_Node::Script_NodeClass_ApplyXSL(CFXJSE_Arguments* pArguments) {
int32_t iLength = pArguments->GetLength();
if (iLength != 1) {
- ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"applyXSL");
+ ThrowParamCountMismatchException(L"applyXSL");
return;
}
CFX_WideString wsExpression =
@@ -1191,7 +1194,7 @@ void CXFA_Node::Script_NodeClass_ApplyXSL(CFXJSE_Arguments* pArguments) {
void CXFA_Node::Script_NodeClass_AssignNode(CFXJSE_Arguments* pArguments) {
int32_t iLength = pArguments->GetLength();
if (iLength < 1 || iLength > 3) {
- ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"assignNode");
+ ThrowParamCountMismatchException(L"assignNode");
return;
}
CFX_WideString wsExpression;
@@ -1215,7 +1218,7 @@ void CXFA_Node::Script_NodeClass_AssignNode(CFXJSE_Arguments* pArguments) {
void CXFA_Node::Script_NodeClass_Clone(CFXJSE_Arguments* pArguments) {
int32_t iLength = pArguments->GetLength();
if (iLength != 1) {
- ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"clone");
+ ThrowParamCountMismatchException(L"clone");
return;
}
bool bClone = !!pArguments->GetInt32(0);
@@ -1227,7 +1230,7 @@ void CXFA_Node::Script_NodeClass_Clone(CFXJSE_Arguments* pArguments) {
void CXFA_Node::Script_NodeClass_GetAttribute(CFXJSE_Arguments* pArguments) {
int32_t iLength = pArguments->GetLength();
if (iLength != 1) {
- ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"getAttribute");
+ ThrowParamCountMismatchException(L"getAttribute");
return;
}
CFX_WideString wsExpression =
@@ -1242,7 +1245,7 @@ void CXFA_Node::Script_NodeClass_GetAttribute(CFXJSE_Arguments* pArguments) {
void CXFA_Node::Script_NodeClass_GetElement(CFXJSE_Arguments* pArguments) {
int32_t iLength = pArguments->GetLength();
if (iLength < 1 || iLength > 2) {
- ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"getElement");
+ ThrowParamCountMismatchException(L"getElement");
return;
}
CFX_WideString wsExpression;
@@ -1261,7 +1264,7 @@ void CXFA_Node::Script_NodeClass_IsPropertySpecified(
CFXJSE_Arguments* pArguments) {
int32_t iLength = pArguments->GetLength();
if (iLength < 1 || iLength > 3) {
- ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"isPropertySpecified");
+ ThrowParamCountMismatchException(L"isPropertySpecified");
return;
}
CFX_WideString wsExpression;
@@ -1297,7 +1300,7 @@ void CXFA_Node::Script_NodeClass_IsPropertySpecified(
void CXFA_Node::Script_NodeClass_LoadXML(CFXJSE_Arguments* pArguments) {
int32_t iLength = pArguments->GetLength();
if (iLength < 1 || iLength > 3) {
- ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"loadXML");
+ ThrowParamCountMismatchException(L"loadXML");
return;
}
CFX_WideString wsExpression;
@@ -1417,13 +1420,13 @@ void CXFA_Node::Script_NodeClass_SaveFilteredXML(CFXJSE_Arguments* pArguments) {
void CXFA_Node::Script_NodeClass_SaveXML(CFXJSE_Arguments* pArguments) {
int32_t iLength = pArguments->GetLength();
if (iLength < 0 || iLength > 1) {
- ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"saveXML");
+ ThrowParamCountMismatchException(L"saveXML");
return;
}
bool bPrettyMode = false;
if (iLength == 1) {
if (pArguments->GetUTF8String(0) != "pretty") {
- ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
+ ThrowArgumentMismatchException();
return;
}
bPrettyMode = true;
@@ -1471,7 +1474,7 @@ void CXFA_Node::Script_NodeClass_SaveXML(CFXJSE_Arguments* pArguments) {
void CXFA_Node::Script_NodeClass_SetAttribute(CFXJSE_Arguments* pArguments) {
int32_t iLength = pArguments->GetLength();
if (iLength != 2) {
- ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"setAttribute");
+ ThrowParamCountMismatchException(L"setAttribute");
return;
}
CFX_WideString wsAttributeValue =
@@ -1484,7 +1487,7 @@ void CXFA_Node::Script_NodeClass_SetAttribute(CFXJSE_Arguments* pArguments) {
void CXFA_Node::Script_NodeClass_SetElement(CFXJSE_Arguments* pArguments) {
int32_t iLength = pArguments->GetLength();
if (iLength != 1 && iLength != 2) {
- ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"setElement");
+ ThrowParamCountMismatchException(L"setElement");
return;
}
CXFA_Node* pNode = nullptr;
@@ -1502,61 +1505,64 @@ void CXFA_Node::Script_NodeClass_Ns(CFXJSE_Value* pValue,
bool bSetting,
XFA_ATTRIBUTE eAttribute) {
if (bSetting) {
- ThrowException(XFA_IDS_INVAlID_PROP_SET);
- } else {
- CFX_WideString wsNameSpace;
- TryNamespace(wsNameSpace);
- pValue->SetString(FX_UTF8Encode(wsNameSpace).AsStringC());
+ ThrowInvalidPropertyException();
+ return;
}
+
+ CFX_WideString wsNameSpace;
+ TryNamespace(wsNameSpace);
+ pValue->SetString(FX_UTF8Encode(wsNameSpace).AsStringC());
}
void CXFA_Node::Script_NodeClass_Model(CFXJSE_Value* pValue,
bool bSetting,
XFA_ATTRIBUTE eAttribute) {
if (bSetting) {
- ThrowException(XFA_IDS_INVAlID_PROP_SET);
- } else {
- pValue->Assign(
- m_pDocument->GetScriptContext()->GetJSValueFromMap(GetModelNode()));
+ ThrowInvalidPropertyException();
+ return;
}
+ pValue->Assign(
+ m_pDocument->GetScriptContext()->GetJSValueFromMap(GetModelNode()));
}
void CXFA_Node::Script_NodeClass_IsContainer(CFXJSE_Value* pValue,
bool bSetting,
XFA_ATTRIBUTE eAttribute) {
- if (bSetting)
- ThrowException(XFA_IDS_INVAlID_PROP_SET);
- else
- pValue->SetBoolean(IsContainerNode());
+ if (bSetting) {
+ ThrowInvalidPropertyException();
+ return;
+ }
+ pValue->SetBoolean(IsContainerNode());
}
void CXFA_Node::Script_NodeClass_IsNull(CFXJSE_Value* pValue,
bool bSetting,
XFA_ATTRIBUTE eAttribute) {
if (bSetting) {
- ThrowException(XFA_IDS_INVAlID_PROP_SET);
- } else {
- if (GetElementType() == XFA_Element::Subform) {
- pValue->SetBoolean(false);
- return;
- }
- CFX_WideString strValue;
- pValue->SetBoolean(!TryContent(strValue) || strValue.IsEmpty());
+ ThrowInvalidPropertyException();
+ return;
}
+ if (GetElementType() == XFA_Element::Subform) {
+ pValue->SetBoolean(false);
+ return;
+ }
+ CFX_WideString strValue;
+ pValue->SetBoolean(!TryContent(strValue) || strValue.IsEmpty());
}
void CXFA_Node::Script_NodeClass_OneOfChild(CFXJSE_Value* pValue,
bool bSetting,
XFA_ATTRIBUTE eAttribute) {
if (bSetting) {
- ThrowException(XFA_IDS_INVAlID_PROP_SET);
- } else {
- CXFA_NodeArray properts;
- int32_t iSize = GetNodeList(properts, XFA_NODEFILTER_OneOfProperty);
- if (iSize > 0) {
- pValue->Assign(
- m_pDocument->GetScriptContext()->GetJSValueFromMap(properts[0]));
- }
+ ThrowInvalidPropertyException();
+ return;
+ }
+
+ CXFA_NodeArray properts;
+ int32_t iSize = GetNodeList(properts, XFA_NODEFILTER_OneOfProperty);
+ if (iSize > 0) {
+ pValue->Assign(
+ m_pDocument->GetScriptContext()->GetJSValueFromMap(properts[0]));
}
}
@@ -1577,7 +1583,7 @@ void CXFA_Node::Script_ModelClass_CreateNode(CFXJSE_Arguments* pArguments) {
void CXFA_Node::Script_ModelClass_IsCompatibleNS(CFXJSE_Arguments* pArguments) {
int32_t iLength = pArguments->GetLength();
if (iLength < 1) {
- ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"isCompatibleNS");
+ ThrowParamCountMismatchException(L"isCompatibleNS");
return;
}
CFX_WideString wsNameSpace;
@@ -1613,11 +1619,11 @@ void CXFA_Node::Script_Attribute_Integer(CFXJSE_Value* pValue,
void CXFA_Node::Script_Attribute_IntegerRead(CFXJSE_Value* pValue,
bool bSetting,
XFA_ATTRIBUTE eAttribute) {
- if (!bSetting) {
- pValue->SetInteger(GetInteger(eAttribute));
- } else {
- ThrowException(XFA_IDS_INVAlID_PROP_SET);
+ if (bSetting) {
+ ThrowInvalidPropertyException();
+ return;
}
+ pValue->SetInteger(GetInteger(eAttribute));
}
void CXFA_Node::Script_Attribute_BOOL(CFXJSE_Value* pValue,
@@ -1633,11 +1639,11 @@ void CXFA_Node::Script_Attribute_BOOL(CFXJSE_Value* pValue,
void CXFA_Node::Script_Attribute_BOOLRead(CFXJSE_Value* pValue,
bool bSetting,
XFA_ATTRIBUTE eAttribute) {
- if (!bSetting) {
- pValue->SetString(GetBoolean(eAttribute) ? "1" : "0");
- } else {
- ThrowException(XFA_IDS_INVAlID_PROP_SET);
+ if (bSetting) {
+ ThrowInvalidPropertyException();
+ return;
}
+ pValue->SetString(GetBoolean(eAttribute) ? "1" : "0");
}
void CXFA_Node::Script_Attribute_SendAttributeChangeMessage(
@@ -1863,31 +1869,29 @@ void CXFA_Node::Script_Attribute_String(CFXJSE_Value* pValue,
void CXFA_Node::Script_Attribute_StringRead(CFXJSE_Value* pValue,
bool bSetting,
XFA_ATTRIBUTE eAttribute) {
- if (!bSetting) {
- CFX_WideString wsValue;
- GetAttribute(eAttribute, wsValue);
- pValue->SetString(
- FX_UTF8Encode(wsValue.c_str(), wsValue.GetLength()).AsStringC());
- } else {
- ThrowException(XFA_IDS_INVAlID_PROP_SET);
+ if (bSetting) {
+ ThrowInvalidPropertyException();
+ return;
}
+
+ CFX_WideString wsValue;
+ GetAttribute(eAttribute, wsValue);
+ pValue->SetString(
+ FX_UTF8Encode(wsValue.c_str(), wsValue.GetLength()).AsStringC());
}
void CXFA_Node::Script_WsdlConnection_Execute(CFXJSE_Arguments* pArguments) {
int32_t argc = pArguments->GetLength();
- if ((argc == 0) || (argc == 1)) {
- pArguments->GetReturnValue()->SetBoolean(false);
- } else {
- ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execute");
+ if (argc != 0 && argc != 1) {
+ ThrowParamCountMismatchException(L"execute");
+ return;
}
+ pArguments->GetReturnValue()->SetBoolean(false);
}
void CXFA_Node::Script_Delta_Restore(CFXJSE_Arguments* pArguments) {
- int32_t argc = pArguments->GetLength();
- if (argc == 0) {
- } else {
- ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"restore");
- }
+ if (pArguments->GetLength() != 0)
+ ThrowParamCountMismatchException(L"restore");
}
void CXFA_Node::Script_Delta_CurrentValue(CFXJSE_Value* pValue,
@@ -1965,15 +1969,16 @@ void CXFA_Node::Script_Field_Length(CFXJSE_Value* pValue,
bool bSetting,
XFA_ATTRIBUTE eAttribute) {
if (bSetting) {
- ThrowException(XFA_IDS_INVAlID_PROP_SET);
- } else {
- CXFA_WidgetData* pWidgetData = GetWidgetData();
- if (!pWidgetData) {
- pValue->SetInteger(0);
- return;
- }
- pValue->SetInteger(pWidgetData->CountChoiceListItems(true));
+ ThrowInvalidPropertyException();
+ return;
}
+
+ CXFA_WidgetData* pWidgetData = GetWidgetData();
+ if (!pWidgetData) {
+ pValue->SetInteger(0);
+ return;
+ }
+ pValue->SetInteger(pWidgetData->CountChoiceListItems(true));
}
void CXFA_Node::Script_Som_DefaultValue(CFXJSE_Value* pValue,
@@ -2046,16 +2051,17 @@ void CXFA_Node::Script_Som_DefaultValue_Read(CFXJSE_Value* pValue,
bool bSetting,
XFA_ATTRIBUTE eAttribute) {
if (bSetting) {
- ThrowException(XFA_IDS_INVAlID_PROP_SET);
+ ThrowInvalidPropertyException();
return;
}
+
CFX_WideString content = GetScriptContent(true);
if (content.IsEmpty()) {
pValue->SetNull();
- } else {
- pValue->SetString(
- FX_UTF8Encode(content.c_str(), content.GetLength()).AsStringC());
+ return;
}
+ pValue->SetString(
+ FX_UTF8Encode(content.c_str(), content.GetLength()).AsStringC());
}
void CXFA_Node::Script_Boolean_Value(CFXJSE_Value* pValue,
@@ -2171,17 +2177,18 @@ void CXFA_Node::Script_Som_FillColor(CFXJSE_Value* pValue,
void CXFA_Node::Script_Som_DataNode(CFXJSE_Value* pValue,
bool bSetting,
XFA_ATTRIBUTE eAttribute) {
- if (!bSetting) {
- CXFA_Node* pDataNode = GetBindData();
- if (pDataNode) {
- pValue->Assign(
- m_pDocument->GetScriptContext()->GetJSValueFromMap(pDataNode));
- } else {
- pValue->SetNull();
- }
- } else {
- ThrowException(XFA_IDS_INVAlID_PROP_SET);
+ if (bSetting) {
+ ThrowInvalidPropertyException();
+ return;
}
+
+ CXFA_Node* pDataNode = GetBindData();
+ if (!pDataNode) {
+ pValue->SetNull();
+ return;
+ }
+
+ pValue->Assign(m_pDocument->GetScriptContext()->GetJSValueFromMap(pDataNode));
}
void CXFA_Node::Script_Draw_DefaultValue(CFXJSE_Value* pValue,
@@ -2376,10 +2383,10 @@ void CXFA_Node::Script_Field_ParentSubform(CFXJSE_Value* pValue,
bool bSetting,
XFA_ATTRIBUTE eAttribute) {
if (bSetting) {
- ThrowException(XFA_IDS_INVAlID_PROP_SET);
- } else {
- pValue->SetNull();
+ ThrowInvalidPropertyException();
+ return;
}
+ pValue->SetNull();
}
void CXFA_Node::Script_Field_SelectedIndex(CFXJSE_Value* pValue,
@@ -2410,38 +2417,39 @@ void CXFA_Node::Script_Field_ClearItems(CFXJSE_Arguments* pArguments) {
}
void CXFA_Node::Script_Field_ExecEvent(CFXJSE_Arguments* pArguments) {
- int32_t argc = pArguments->GetLength();
- if (argc == 1) {
- CFX_ByteString eventString = pArguments->GetUTF8String(0);
- int32_t iRet = execSingleEventByName(
- CFX_WideString::FromUTF8(eventString.AsStringC()).AsStringC(),
- XFA_Element::Field);
- if (eventString == "validate") {
- pArguments->GetReturnValue()->SetBoolean(
- (iRet == XFA_EVENTERROR_Error) ? false : true);
- }
- } else {
- ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execEvent");
+ if (pArguments->GetLength() != 1) {
+ ThrowParamCountMismatchException(L"execEvent");
+ return;
}
+
+ CFX_ByteString eventString = pArguments->GetUTF8String(0);
+ int32_t iRet = execSingleEventByName(
+ CFX_WideString::FromUTF8(eventString.AsStringC()).AsStringC(),
+ XFA_Element::Field);
+ if (eventString != "validate")
+ return;
+
+ pArguments->GetReturnValue()->SetBoolean(
+ (iRet == XFA_EVENTERROR_Error) ? false : true);
}
void CXFA_Node::Script_Field_ExecInitialize(CFXJSE_Arguments* pArguments) {
- int32_t argc = pArguments->GetLength();
- if (argc == 0) {
- CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
- if (!pNotify) {
- return;
- }
- pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Initialize, false, false);
- } else {
- ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execInitialize");
+ if (pArguments->GetLength() != 0) {
+ ThrowParamCountMismatchException(L"execInitialize");
+ return;
}
+
+ CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
+ if (!pNotify)
+ return;
+
+ pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Initialize, false, false);
}
void CXFA_Node::Script_Field_DeleteItem(CFXJSE_Arguments* pArguments) {
int32_t iLength = pArguments->GetLength();
if (iLength != 1) {
- ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"deleteItem");
+ ThrowParamCountMismatchException(L"deleteItem");
return;
}
CXFA_WidgetData* pWidgetData = GetWidgetData();
@@ -2458,7 +2466,7 @@ void CXFA_Node::Script_Field_DeleteItem(CFXJSE_Arguments* pArguments) {
void CXFA_Node::Script_Field_GetSaveItem(CFXJSE_Arguments* pArguments) {
int32_t iLength = pArguments->GetLength();
if (iLength != 1) {
- ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"getSaveItem");
+ ThrowParamCountMismatchException(L"getSaveItem");
return;
}
int32_t iIndex = pArguments->GetInt32(0);
@@ -2484,7 +2492,7 @@ void CXFA_Node::Script_Field_GetSaveItem(CFXJSE_Arguments* pArguments) {
void CXFA_Node::Script_Field_BoundItem(CFXJSE_Arguments* pArguments) {
int32_t iLength = pArguments->GetLength();
if (iLength != 1) {
- ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"boundItem");
+ ThrowParamCountMismatchException(L"boundItem");
return;
}
CXFA_WidgetData* pWidgetData = GetWidgetData();
@@ -2503,7 +2511,7 @@ void CXFA_Node::Script_Field_BoundItem(CFXJSE_Arguments* pArguments) {
void CXFA_Node::Script_Field_GetItemState(CFXJSE_Arguments* pArguments) {
int32_t iLength = pArguments->GetLength();
if (iLength != 1) {
- ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"getItemState");
+ ThrowParamCountMismatchException(L"getItemState");
return;
}
CXFA_WidgetData* pWidgetData = GetWidgetData();
@@ -2518,16 +2526,16 @@ void CXFA_Node::Script_Field_GetItemState(CFXJSE_Arguments* pArguments) {
}
void CXFA_Node::Script_Field_ExecCalculate(CFXJSE_Arguments* pArguments) {
- int32_t argc = pArguments->GetLength();
- if (argc == 0) {
- CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
- if (!pNotify) {
- return;
- }
- pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Calculate, false, false);
- } else {
- ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execCalculate");
+ if (pArguments->GetLength() != 0) {
+ ThrowParamCountMismatchException(L"execCalculate");
+ return;
}
+
+ CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
+ if (!pNotify)
+ return;
+
+ pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Calculate, false, false);
}
void CXFA_Node::Script_Field_SetItems(CFXJSE_Arguments* pArguments) {}
@@ -2535,7 +2543,7 @@ void CXFA_Node::Script_Field_SetItems(CFXJSE_Arguments* pArguments) {}
void CXFA_Node::Script_Field_GetDisplayItem(CFXJSE_Arguments* pArguments) {
int32_t iLength = pArguments->GetLength();
if (iLength != 1) {
- ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"getDisplayItem");
+ ThrowParamCountMismatchException(L"getDisplayItem");
return;
}
int32_t iIndex = pArguments->GetInt32(0);
@@ -2561,7 +2569,7 @@ void CXFA_Node::Script_Field_GetDisplayItem(CFXJSE_Arguments* pArguments) {
void CXFA_Node::Script_Field_SetItemState(CFXJSE_Arguments* pArguments) {
int32_t iLength = pArguments->GetLength();
if (iLength != 2) {
- ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"setItemState");
+ ThrowParamCountMismatchException(L"setItemState");
return;
}
CXFA_WidgetData* pWidgetData = GetWidgetData();
@@ -2580,7 +2588,7 @@ void CXFA_Node::Script_Field_SetItemState(CFXJSE_Arguments* pArguments) {
void CXFA_Node::Script_Field_AddItem(CFXJSE_Arguments* pArguments) {
int32_t iLength = pArguments->GetLength();
if (iLength < 1 || iLength > 2) {
- ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"addItem");
+ ThrowParamCountMismatchException(L"addItem");
return;
}
CXFA_WidgetData* pWidgetData = GetWidgetData();
@@ -2601,29 +2609,28 @@ void CXFA_Node::Script_Field_AddItem(CFXJSE_Arguments* pArguments) {
}
void CXFA_Node::Script_Field_ExecValidate(CFXJSE_Arguments* pArguments) {
- int32_t argc = pArguments->GetLength();
- if (argc == 0) {
- CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
- if (!pNotify) {
- pArguments->GetReturnValue()->SetBoolean(false);
- } else {
- int32_t iRet =
- pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Validate, false, false);
- pArguments->GetReturnValue()->SetBoolean(
- (iRet == XFA_EVENTERROR_Error) ? false : true);
- }
- } else {
- ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execValidate");
+ if (pArguments->GetLength() != 0) {
+ ThrowParamCountMismatchException(L"execValidate");
+ return;
+ }
+
+ CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
+ if (!pNotify) {
+ pArguments->GetReturnValue()->SetBoolean(false);
+ return;
}
+
+ int32_t iRet =
+ pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Validate, false, false);
+ pArguments->GetReturnValue()->SetBoolean(
+ (iRet == XFA_EVENTERROR_Error) ? false : true);
}
void CXFA_Node::Script_ExclGroup_ErrorText(CFXJSE_Value* pValue,
bool bSetting,
XFA_ATTRIBUTE eAttribute) {
- if (!bSetting) {
- } else {
- ThrowException(XFA_IDS_INVAlID_PROP_SET);
- }
+ if (bSetting)
+ ThrowInvalidPropertyException();
}
void CXFA_Node::Script_ExclGroup_DefaultAndRawValue(CFXJSE_Value* pValue,
@@ -2652,21 +2659,21 @@ void CXFA_Node::Script_ExclGroup_Transient(CFXJSE_Value* pValue,
XFA_ATTRIBUTE eAttribute) {}
void CXFA_Node::Script_ExclGroup_ExecEvent(CFXJSE_Arguments* pArguments) {
- int32_t argc = pArguments->GetLength();
- if (argc == 1) {
- CFX_ByteString eventString = pArguments->GetUTF8String(0);
- execSingleEventByName(
- CFX_WideString::FromUTF8(eventString.AsStringC()).AsStringC(),
- XFA_Element::ExclGroup);
- } else {
- ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execEvent");
+ if (pArguments->GetLength() != 1) {
+ ThrowParamCountMismatchException(L"execEvent");
+ return;
}
+
+ CFX_ByteString eventString = pArguments->GetUTF8String(0);
+ execSingleEventByName(
+ CFX_WideString::FromUTF8(eventString.AsStringC()).AsStringC(),
+ XFA_Element::ExclGroup);
}
void CXFA_Node::Script_ExclGroup_SelectedMember(CFXJSE_Arguments* pArguments) {
int32_t argc = pArguments->GetLength();
if (argc < 0 || argc > 1) {
- ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"selectedMember");
+ ThrowParamCountMismatchException(L"selectedMember");
return;
}
@@ -2694,45 +2701,46 @@ void CXFA_Node::Script_ExclGroup_SelectedMember(CFXJSE_Arguments* pArguments) {
}
void CXFA_Node::Script_ExclGroup_ExecInitialize(CFXJSE_Arguments* pArguments) {
- int32_t argc = pArguments->GetLength();
- if (argc == 0) {
- CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
- if (!pNotify) {
- return;
- }
- pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Initialize);
- } else {
- ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execInitialize");
+ if (pArguments->GetLength() != 0) {
+ ThrowParamCountMismatchException(L"execInitialize");
+ return;
}
+
+ CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
+ if (!pNotify)
+ return;
+
+ pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Initialize);
}
void CXFA_Node::Script_ExclGroup_ExecCalculate(CFXJSE_Arguments* pArguments) {
- int32_t argc = pArguments->GetLength();
- if (argc == 0) {
- CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
- if (!pNotify) {
- return;
- }
- pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Calculate);
- } else {
- ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execCalculate");
+ if (pArguments->GetLength() != 0) {
+ ThrowParamCountMismatchException(L"execCalculate");
+ return;
}
+
+ CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
+ if (!pNotify)
+ return;
+
+ pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Calculate);
}
void CXFA_Node::Script_ExclGroup_ExecValidate(CFXJSE_Arguments* pArguments) {
- int32_t argc = pArguments->GetLength();
- if (argc == 0) {
- CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
- if (!pNotify) {
- pArguments->GetReturnValue()->SetBoolean(false);
- } else {
- int32_t iRet = pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Validate);
- pArguments->GetReturnValue()->SetBoolean(
- (iRet == XFA_EVENTERROR_Error) ? false : true);
- }
- } else {
- ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execValidate");
+ if (pArguments->GetLength() != 0) {
+ ThrowParamCountMismatchException(L"execValidate");
+ return;
}
+
+ CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
+ if (!pNotify) {
+ pArguments->GetReturnValue()->SetBoolean(false);
+ return;
+ }
+
+ int32_t iRet = pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Validate);
+ pArguments->GetReturnValue()->SetBoolean(
+ (iRet == XFA_EVENTERROR_Error) ? false : true);
}
void CXFA_Node::Script_Som_InstanceIndex(CFXJSE_Value* pValue,
@@ -2774,29 +2782,31 @@ void CXFA_Node::Script_Som_InstanceIndex(CFXJSE_Value* pValue,
void CXFA_Node::Script_Subform_InstanceManager(CFXJSE_Value* pValue,
bool bSetting,
XFA_ATTRIBUTE eAttribute) {
- if (!bSetting) {
- CFX_WideStringC wsName = GetCData(XFA_ATTRIBUTE_Name);
- CXFA_Node* pInstanceMgr = nullptr;
- for (CXFA_Node* pNode = GetNodeItem(XFA_NODEITEM_PrevSibling); pNode;
- pNode = pNode->GetNodeItem(XFA_NODEITEM_PrevSibling)) {
- if (pNode->GetElementType() == XFA_Element::InstanceManager) {
- CFX_WideStringC wsInstMgrName = pNode->GetCData(XFA_ATTRIBUTE_Name);
- if (wsInstMgrName.GetLength() >= 1 && wsInstMgrName.GetAt(0) == '_' &&
- wsInstMgrName.Mid(1) == wsName) {
- pInstanceMgr = pNode;
- }
- break;
+ if (bSetting) {
+ ThrowInvalidPropertyException();
+ return;
+ }
+
+ CFX_WideStringC wsName = GetCData(XFA_ATTRIBUTE_Name);
+ CXFA_Node* pInstanceMgr = nullptr;
+ for (CXFA_Node* pNode = GetNodeItem(XFA_NODEITEM_PrevSibling); pNode;
+ pNode = pNode->GetNodeItem(XFA_NODEITEM_PrevSibling)) {
+ if (pNode->GetElementType() == XFA_Element::InstanceManager) {
+ CFX_WideStringC wsInstMgrName = pNode->GetCData(XFA_ATTRIBUTE_Name);
+ if (wsInstMgrName.GetLength() >= 1 && wsInstMgrName.GetAt(0) == '_' &&
+ wsInstMgrName.Mid(1) == wsName) {
+ pInstanceMgr = pNode;
}
+ break;
}
- if (pInstanceMgr) {
- pValue->Assign(
- m_pDocument->GetScriptContext()->GetJSValueFromMap(pInstanceMgr));
- } else {
- pValue->SetNull();
- }
- } else {
- ThrowException(XFA_IDS_INVAlID_PROP_SET);
}
+ if (!pInstanceMgr) {
+ pValue->SetNull();
+ return;
+ }
+
+ pValue->Assign(
+ m_pDocument->GetScriptContext()->GetJSValueFromMap(pInstanceMgr));
}
void CXFA_Node::Script_Subform_Locale(CFXJSE_Value* pValue,
@@ -2814,65 +2824,63 @@ void CXFA_Node::Script_Subform_Locale(CFXJSE_Value* pValue,
}
void CXFA_Node::Script_Subform_ExecEvent(CFXJSE_Arguments* pArguments) {
- int32_t argc = pArguments->GetLength();
- if (argc == 1) {
- CFX_ByteString eventString = pArguments->GetUTF8String(0);
- execSingleEventByName(
- CFX_WideString::FromUTF8(eventString.AsStringC()).AsStringC(),
- XFA_Element::Subform);
- } else {
- ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execEvent");
+ if (pArguments->GetLength() != 1) {
+ ThrowParamCountMismatchException(L"execEvent");
+ return;
}
+
+ CFX_ByteString eventString = pArguments->GetUTF8String(0);
+ execSingleEventByName(
+ CFX_WideString::FromUTF8(eventString.AsStringC()).AsStringC(),
+ XFA_Element::Subform);
}
void CXFA_Node::Script_Subform_ExecInitialize(CFXJSE_Arguments* pArguments) {
- int32_t argc = pArguments->GetLength();
- if (argc == 0) {
- CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
- if (!pNotify) {
- return;
- }
- pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Initialize);
- } else {
- ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execInitialize");
+ if (pArguments->GetLength() != 0) {
+ ThrowParamCountMismatchException(L"execInitialize");
+ return;
}
+
+ CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
+ if (!pNotify)
+ return;
+
+ pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Initialize);
}
void CXFA_Node::Script_Subform_ExecCalculate(CFXJSE_Arguments* pArguments) {
- int32_t argc = pArguments->GetLength();
- if (argc == 0) {
- CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
- if (!pNotify) {
- return;
- }
- pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Calculate);
- } else {
- ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execCalculate");
+ if (pArguments->GetLength() != 0) {
+ ThrowParamCountMismatchException(L"execCalculate");
+ return;
}
+
+ CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
+ if (!pNotify)
+ return;
+
+ pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Calculate);
}
void CXFA_Node::Script_Subform_ExecValidate(CFXJSE_Arguments* pArguments) {
- int32_t argc = pArguments->GetLength();
- if (argc == 0) {
- CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
- if (!pNotify) {
- pArguments->GetReturnValue()->SetBoolean(false);
- } else {
- int32_t iRet = pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Validate);
- pArguments->GetReturnValue()->SetBoolean(
- (iRet == XFA_EVENTERROR_Error) ? false : true);
- }
- } else {
- ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execValidate");
+ if (pArguments->GetLength() != 0) {
+ ThrowParamCountMismatchException(L"execValidate");
+ return;
}
+
+ CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
+ if (!pNotify) {
+ pArguments->GetReturnValue()->SetBoolean(false);
+ return;
+ }
+
+ int32_t iRet = pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Validate);
+ pArguments->GetReturnValue()->SetBoolean(
+ (iRet == XFA_EVENTERROR_Error) ? false : true);
}
void CXFA_Node::Script_Subform_GetInvalidObjects(CFXJSE_Arguments* pArguments) {
- int32_t argc = pArguments->GetLength();
- if (argc == 0) {
- } else {
- ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"getInvalidObjects");
- }
+ if (pArguments->GetLength() != 0)
+ ThrowParamCountMismatchException(L"getInvalidObjects");
}
int32_t CXFA_Node::Subform_and_SubformSet_InstanceIndex() {
@@ -2890,136 +2898,136 @@ int32_t CXFA_Node::Subform_and_SubformSet_InstanceIndex() {
}
void CXFA_Node::Script_Template_FormNodes(CFXJSE_Arguments* pArguments) {
- int32_t argc = pArguments->GetLength();
- if (argc == 1) {
- pArguments->GetReturnValue()->SetBoolean(true);
- } else {
- ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"formNodes");
+ if (pArguments->GetLength() != 1) {
+ ThrowParamCountMismatchException(L"formNodes");
+ return;
}
+ pArguments->GetReturnValue()->SetBoolean(true);
}
void CXFA_Node::Script_Template_Remerge(CFXJSE_Arguments* pArguments) {
- int32_t argc = pArguments->GetLength();
- if (argc == 0) {
- m_pDocument->DoDataRemerge(true);
- } else {
- ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"remerge");
+ if (pArguments->GetLength() != 0) {
+ ThrowParamCountMismatchException(L"remerge");
+ return;
}
+ m_pDocument->DoDataRemerge(true);
}
void CXFA_Node::Script_Template_ExecInitialize(CFXJSE_Arguments* pArguments) {
- int32_t argc = pArguments->GetLength();
- if (argc == 0) {
- CXFA_WidgetData* pWidgetData = GetWidgetData();
- if (!pWidgetData) {
- pArguments->GetReturnValue()->SetBoolean(false);
- } else {
- pArguments->GetReturnValue()->SetBoolean(true);
- }
- } else {
- ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execInitialize");
+ if (pArguments->GetLength() != 0) {
+ ThrowParamCountMismatchException(L"execInitialize");
+ return;
}
+
+ CXFA_WidgetData* pWidgetData = GetWidgetData();
+ if (!pWidgetData) {
+ pArguments->GetReturnValue()->SetBoolean(false);
+ return;
+ }
+ pArguments->GetReturnValue()->SetBoolean(true);
}
void CXFA_Node::Script_Template_CreateNode(CFXJSE_Arguments* pArguments) {
int32_t argc = pArguments->GetLength();
- if ((argc > 0) && (argc < 4)) {
- CFX_WideString strTagName;
- CFX_WideString strName;
- CFX_WideString strNameSpace;
- CFX_ByteString bsTagName = pArguments->GetUTF8String(0);
- strTagName = CFX_WideString::FromUTF8(bsTagName.AsStringC());
- if (argc > 1) {
- CFX_ByteString bsName = pArguments->GetUTF8String(1);
- strName = CFX_WideString::FromUTF8(bsName.AsStringC());
- if (argc == 3) {
- CFX_ByteString bsNameSpace = pArguments->GetUTF8String(2);
- strNameSpace = CFX_WideString::FromUTF8(bsNameSpace.AsStringC());
- }
- }
- XFA_Element eType = XFA_GetElementTypeForName(strTagName.AsStringC());
- CXFA_Node* pNewNode = CreateSamePacketNode(eType);
- if (!pNewNode) {
- pArguments->GetReturnValue()->SetNull();
- } else {
- if (!strName.IsEmpty()) {
- if (GetAttributeOfElement(eType, XFA_ATTRIBUTE_Name,
- XFA_XDPPACKET_UNKNOWN)) {
- pNewNode->SetAttribute(XFA_ATTRIBUTE_Name, strName.AsStringC(), true);
- if (pNewNode->GetPacketID() == XFA_XDPPACKET_Datasets) {
- pNewNode->CreateXMLMappingNode();
- }
- pArguments->GetReturnValue()->Assign(
- m_pDocument->GetScriptContext()->GetJSValueFromMap(pNewNode));
- } else {
- ThrowException(XFA_IDS_NOT_HAVE_PROPERTY, strTagName.c_str(),
- L"name");
- }
- } else {
- pArguments->GetReturnValue()->Assign(
- m_pDocument->GetScriptContext()->GetJSValueFromMap(pNewNode));
- }
+ if (argc <= 0 || argc >= 4) {
+ ThrowParamCountMismatchException(L"createNode");
+ return;
+ }
+
+ CFX_WideString strName;
+ CFX_WideString strNameSpace;
+ CFX_ByteString bsTagName = pArguments->GetUTF8String(0);
+ CFX_WideString strTagName = CFX_WideString::FromUTF8(bsTagName.AsStringC());
+ if (argc > 1) {
+ CFX_ByteString bsName = pArguments->GetUTF8String(1);
+ strName = CFX_WideString::FromUTF8(bsName.AsStringC());
+ if (argc == 3) {
+ CFX_ByteString bsNameSpace = pArguments->GetUTF8String(2);
+ strNameSpace = CFX_WideString::FromUTF8(bsNameSpace.AsStringC());
}
- } else {
- ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"createNode");
}
+
+ XFA_Element eType = XFA_GetElementTypeForName(strTagName.AsStringC());
+ CXFA_Node* pNewNode = CreateSamePacketNode(eType);
+ if (!pNewNode) {
+ pArguments->GetReturnValue()->SetNull();
+ return;
+ }
+
+ if (strName.IsEmpty()) {
+ pArguments->GetReturnValue()->Assign(
+ m_pDocument->GetScriptContext()->GetJSValueFromMap(pNewNode));
+ return;
+ }
+
+ if (!GetAttributeOfElement(eType, XFA_ATTRIBUTE_Name,
+ XFA_XDPPACKET_UNKNOWN)) {
+ ThrowMissingPropertyException(strTagName, L"name");
+ return;
+ }
+
+ pNewNode->SetAttribute(XFA_ATTRIBUTE_Name, strName.AsStringC(), true);
+ if (pNewNode->GetPacketID() == XFA_XDPPACKET_Datasets)
+ pNewNode->CreateXMLMappingNode();
+
+ pArguments->GetReturnValue()->Assign(
+ m_pDocument->GetScriptContext()->GetJSValueFromMap(pNewNode));
}
void CXFA_Node::Script_Template_Recalculate(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() == 1) {
- pArguments->GetReturnValue()->SetBoolean(true);
- } else {
- ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"recalculate");
+ if (pArguments->GetLength() != 1) {
+ ThrowParamCountMismatchException(L"recalculate");
+ return;
}
+ pArguments->GetReturnValue()->SetBoolean(true);
}
void CXFA_Node::Script_Template_ExecCalculate(CFXJSE_Arguments* pArguments) {
- int32_t argc = pArguments->GetLength();
- if (argc == 0) {
- CXFA_WidgetData* pWidgetData = GetWidgetData();
- if (!pWidgetData) {
- pArguments->GetReturnValue()->SetBoolean(false);
- } else {
- pArguments->GetReturnValue()->SetBoolean(true);
- }
- } else {
- ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execCalculate");
+ if (pArguments->GetLength() != 0) {
+ ThrowParamCountMismatchException(L"execCalculate");
+ return;
+ }
+
+ CXFA_WidgetData* pWidgetData = GetWidgetData();
+ if (!pWidgetData) {
+ pArguments->GetReturnValue()->SetBoolean(false);
+ return;
}
+ pArguments->GetReturnValue()->SetBoolean(true);
}
void CXFA_Node::Script_Template_ExecValidate(CFXJSE_Arguments* pArguments) {
- int32_t argc = pArguments->GetLength();
- if (argc == 0) {
- CXFA_WidgetData* pWidgetData = GetWidgetData();
- if (!pWidgetData) {
- pArguments->GetReturnValue()->SetBoolean(false);
- } else {
- pArguments->GetReturnValue()->SetBoolean(true);
- }
- } else {
- ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execValidate");
+ if (pArguments->GetLength() != 0) {
+ ThrowParamCountMismatchException(L"execValidate");
+ return;
+ }
+ CXFA_WidgetData* pWidgetData = GetWidgetData();
+ if (!pWidgetData) {
+ pArguments->GetReturnValue()->SetBoolean(false);
+ return;
}
+ pArguments->GetReturnValue()->SetBoolean(true);
}
void CXFA_Node::Script_Manifest_Evaluate(CFXJSE_Arguments* pArguments) {
- int32_t argc = pArguments->GetLength();
- if (argc == 0) {
- CXFA_WidgetData* pWidgetData = GetWidgetData();
- if (!pWidgetData) {
- pArguments->GetReturnValue()->SetBoolean(false);
- } else {
- pArguments->GetReturnValue()->SetBoolean(true);
- }
- } else {
- ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"evaluate");
+ if (pArguments->GetLength() != 0) {
+ ThrowParamCountMismatchException(L"evaluate");
+ return;
}
+
+ CXFA_WidgetData* pWidgetData = GetWidgetData();
+ if (!pWidgetData) {
+ pArguments->GetReturnValue()->SetBoolean(false);
+ return;
+ }
+ pArguments->GetReturnValue()->SetBoolean(true);
}
void CXFA_Node::Script_InstanceManager_Max(CFXJSE_Value* pValue,
bool bSetting,
XFA_ATTRIBUTE eAttribute) {
if (bSetting) {
- ThrowException(XFA_IDS_INVAlID_PROP_SET);
+ ThrowInvalidPropertyException();
return;
}
CXFA_Occur nodeOccur(GetOccurNode());
@@ -3030,7 +3038,7 @@ void CXFA_Node::Script_InstanceManager_Min(CFXJSE_Value* pValue,
bool bSetting,
XFA_ATTRIBUTE eAttribute) {
if (bSetting) {
- ThrowException(XFA_IDS_INVAlID_PROP_SET);
+ ThrowInvalidPropertyException();
return;
}
CXFA_Occur nodeOccur(GetOccurNode());
@@ -3050,8 +3058,7 @@ void CXFA_Node::Script_InstanceManager_Count(CFXJSE_Value* pValue,
void CXFA_Node::Script_InstanceManager_MoveInstance(
CFXJSE_Arguments* pArguments) {
- int32_t argc = pArguments->GetLength();
- if (argc != 2) {
+ if (pArguments->GetLength() != 2) {
pArguments->GetReturnValue()->SetUndefined();
return;
}
@@ -3075,21 +3082,20 @@ void CXFA_Node::Script_InstanceManager_MoveInstance(
void CXFA_Node::Script_InstanceManager_RemoveInstance(
CFXJSE_Arguments* pArguments) {
- int32_t argc = pArguments->GetLength();
- if (argc != 1) {
+ if (pArguments->GetLength() != 1) {
pArguments->GetReturnValue()->SetUndefined();
return;
}
int32_t iIndex = pArguments->GetInt32(0);
int32_t iCount = GetCount(this);
if (iIndex < 0 || iIndex >= iCount) {
- ThrowException(XFA_IDS_INDEX_OUT_OF_BOUNDS);
+ ThrowIndexOutOfBoundsException();
return;
}
CXFA_Occur nodeOccur(GetOccurNode());
int32_t iMin = nodeOccur.GetMin();
if (iCount - 1 < iMin) {
- ThrowException(XFA_IDS_VIOLATE_BOUNDARY, L"min");
+ ThrowTooManyOccurancesException(L"min");
return;
}
CXFA_Node* pRemoveInstance = GetItem(this, iIndex);
@@ -3114,8 +3120,7 @@ void CXFA_Node::Script_InstanceManager_RemoveInstance(
void CXFA_Node::Script_InstanceManager_SetInstances(
CFXJSE_Arguments* pArguments) {
- int32_t argc = pArguments->GetLength();
- if (argc != 1) {
+ if (pArguments->GetLength() != 1) {
pArguments->GetReturnValue()->SetUndefined();
return;
}
@@ -3126,8 +3131,8 @@ void CXFA_Node::Script_InstanceManager_SetInstances(
void CXFA_Node::Script_InstanceManager_AddInstance(
CFXJSE_Arguments* pArguments) {
int32_t argc = pArguments->GetLength();
- if ((argc != 0) && (argc != 1)) {
- ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"addInstance");
+ if (argc != 0 && argc != 1) {
+ ThrowParamCountMismatchException(L"addInstance");
return;
}
bool fFlags = true;
@@ -3138,7 +3143,7 @@ void CXFA_Node::Script_InstanceManager_AddInstance(
CXFA_Occur nodeOccur(GetOccurNode());
int32_t iMax = nodeOccur.GetMax();
if (iMax >= 0 && iCount >= iMax) {
- ThrowException(XFA_IDS_VIOLATE_BOUNDARY, L"max");
+ ThrowTooManyOccurancesException(L"max");
return;
}
CXFA_Node* pNewInstance = CreateInstance(this, fFlags);
@@ -3161,8 +3166,8 @@ void CXFA_Node::Script_InstanceManager_AddInstance(
void CXFA_Node::Script_InstanceManager_InsertInstance(
CFXJSE_Arguments* pArguments) {
int32_t argc = pArguments->GetLength();
- if ((argc != 1) && (argc != 2)) {
- ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"insertInstance");
+ if (argc != 1 && argc != 2) {
+ ThrowParamCountMismatchException(L"insertInstance");
return;
}
int32_t iIndex = pArguments->GetInt32(0);
@@ -3173,12 +3178,12 @@ void CXFA_Node::Script_InstanceManager_InsertInstance(
CXFA_Occur nodeOccur(GetOccurNode());
int32_t iCount = GetCount(this);
if (iIndex < 0 || iIndex > iCount) {
- ThrowException(XFA_IDS_INDEX_OUT_OF_BOUNDS);
+ ThrowIndexOutOfBoundsException();
return;
}
int32_t iMax = nodeOccur.GetMax();
if (iMax >= 0 && iCount >= iMax) {
- ThrowException(XFA_IDS_VIOLATE_BOUNDARY, L"max");
+ ThrowTooManyOccurancesException(L"max");
return;
}
CXFA_Node* pNewInstance = CreateInstance(this, bBind);
@@ -3203,11 +3208,11 @@ int32_t CXFA_Node::InstanceManager_SetInstances(int32_t iDesired) {
int32_t iMax = nodeOccur.GetMax();
int32_t iMin = nodeOccur.GetMin();
if (iDesired < iMin) {
- ThrowException(XFA_IDS_VIOLATE_BOUNDARY, L"min");
+ ThrowTooManyOccurancesException(L"min");
return 1;
}
if ((iMax >= 0) && (iDesired > iMax)) {
- ThrowException(XFA_IDS_VIOLATE_BOUNDARY, L"max");
+ ThrowTooManyOccurancesException(L"max");
return 2;
}
int32_t iCount = GetCount(this);
@@ -3262,7 +3267,7 @@ int32_t CXFA_Node::InstanceManager_SetInstances(int32_t iDesired) {
int32_t CXFA_Node::InstanceManager_MoveInstance(int32_t iTo, int32_t iFrom) {
int32_t iCount = GetCount(this);
if (iFrom > iCount || iTo > iCount - 1) {
- ThrowException(XFA_IDS_INDEX_OUT_OF_BOUNDS);
+ ThrowIndexOutOfBoundsException();
return 1;
}
if (iFrom < 0 || iTo < 0 || iFrom == iTo) {
@@ -3305,51 +3310,52 @@ void CXFA_Node::Script_Occur_Min(CFXJSE_Value* pValue,
void CXFA_Node::Script_Desc_Metadata(CFXJSE_Arguments* pArguments) {
int32_t argc = pArguments->GetLength();
- if ((argc == 0) || (argc == 1)) {
- pArguments->GetReturnValue()->SetString("");
- } else {
- ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"metadata");
+ if (argc != 0 && argc != 1) {
+ ThrowParamCountMismatchException(L"metadata");
+ return;
}
+ pArguments->GetReturnValue()->SetString("");
}
void CXFA_Node::Script_Form_FormNodes(CFXJSE_Arguments* pArguments) {
- int32_t argc = pArguments->GetLength();
- if (argc == 1) {
- CXFA_Node* pDataNode = static_cast<CXFA_Node*>(pArguments->GetObject(0));
- if (pDataNode) {
- CXFA_NodeArray formItems;
- CXFA_ArrayNodeList* pFormNodes = new CXFA_ArrayNodeList(m_pDocument);
- pFormNodes->SetArrayNodeList(formItems);
- pArguments->GetReturnValue()->SetObject(
- pFormNodes, m_pDocument->GetScriptContext()->GetJseNormalClass());
- } else {
- ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
- }
- } else {
- ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"formNodes");
+ if (pArguments->GetLength() != 1) {
+ ThrowParamCountMismatchException(L"formNodes");
+ return;
}
+
+ CXFA_Node* pDataNode = static_cast<CXFA_Node*>(pArguments->GetObject(0));
+ if (!pDataNode) {
+ ThrowArgumentMismatchException();
+ return;
+ }
+
+ CXFA_NodeArray formItems;
+ CXFA_ArrayNodeList* pFormNodes = new CXFA_ArrayNodeList(m_pDocument);
+ pFormNodes->SetArrayNodeList(formItems);
+ pArguments->GetReturnValue()->SetObject(
+ pFormNodes, m_pDocument->GetScriptContext()->GetJseNormalClass());
}
void CXFA_Node::Script_Form_Remerge(CFXJSE_Arguments* pArguments) {
- int32_t argc = pArguments->GetLength();
- if (argc == 0) {
- m_pDocument->DoDataRemerge(true);
- } else {
- ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"remerge");
+ if (pArguments->GetLength() != 0) {
+ ThrowParamCountMismatchException(L"remerge");
+ return;
}
+
+ m_pDocument->DoDataRemerge(true);
}
void CXFA_Node::Script_Form_ExecInitialize(CFXJSE_Arguments* pArguments) {
- int32_t argc = pArguments->GetLength();
- if (argc == 0) {
- CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
- if (!pNotify) {
- return;
- }
- pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Initialize);
- } else {
- ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execInitialize");
+ if (pArguments->GetLength() != 0) {
+ ThrowParamCountMismatchException(L"execInitialize");
+ return;
}
+
+ CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
+ if (!pNotify)
+ return;
+
+ pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Initialize);
}
void CXFA_Node::Script_Form_Recalculate(CFXJSE_Arguments* pArguments) {
@@ -3359,51 +3365,50 @@ void CXFA_Node::Script_Form_Recalculate(CFXJSE_Arguments* pArguments) {
pEventParam->m_eType == XFA_EVENT_InitCalculate) {
return;
}
- int32_t argc = pArguments->GetLength();
- if (argc == 1) {
- const bool bScriptFlags = pArguments->GetInt32(0) != 0;
- CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
- if (!pNotify) {
- return;
- }
- if (bScriptFlags) {
- pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Calculate);
- pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Validate);
- pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Ready, true);
- } else {
- }
- } else {
- ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"recalculate");
+ if (pArguments->GetLength() != 1) {
+ ThrowParamCountMismatchException(L"recalculate");
+ return;
}
+
+ CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
+ if (!pNotify)
+ return;
+ if (pArguments->GetInt32(0) != 0)
+ return;
+
+ pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Calculate);
+ pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Validate);
+ pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Ready, true);
}
void CXFA_Node::Script_Form_ExecCalculate(CFXJSE_Arguments* pArguments) {
- int32_t argc = pArguments->GetLength();
- if (argc == 0) {
- CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
- if (!pNotify) {
- return;
- }
- pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Calculate);
- } else {
- ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execCalculate");
+ if (pArguments->GetLength() != 0) {
+ ThrowParamCountMismatchException(L"execCalculate");
+ return;
}
+
+ CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
+ if (!pNotify)
+ return;
+
+ pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Calculate);
}
void CXFA_Node::Script_Form_ExecValidate(CFXJSE_Arguments* pArguments) {
- int32_t argc = pArguments->GetLength();
- if (argc == 0) {
- CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
- if (!pNotify) {
- pArguments->GetReturnValue()->SetBoolean(false);
- } else {
- int32_t iRet = pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Validate);
- pArguments->GetReturnValue()->SetBoolean(
- (iRet == XFA_EVENTERROR_Error) ? false : true);
- }
- } else {
- ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execValidate");
+ if (pArguments->GetLength() != 0) {
+ ThrowParamCountMismatchException(L"execValidate");
+ return;
}
+
+ CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
+ if (!pNotify) {
+ pArguments->GetReturnValue()->SetBoolean(false);
+ return;
+ }
+
+ int32_t iRet = pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Validate);
+ pArguments->GetReturnValue()->SetBoolean(
+ (iRet == XFA_EVENTERROR_Error) ? false : true);
}
void CXFA_Node::Script_Form_Checksum(CFXJSE_Value* pValue,
@@ -3411,66 +3416,67 @@ void CXFA_Node::Script_Form_Checksum(CFXJSE_Value* pValue,
XFA_ATTRIBUTE eAttribute) {
if (bSetting) {
SetAttribute(XFA_ATTRIBUTE_Checksum, pValue->ToWideString().AsStringC());
- } else {
- CFX_WideString wsChecksum;
- GetAttribute(XFA_ATTRIBUTE_Checksum, wsChecksum, false);
- pValue->SetString(
- FX_UTF8Encode(wsChecksum.c_str(), wsChecksum.GetLength()).AsStringC());
+ return;
}
+
+ CFX_WideString wsChecksum;
+ GetAttribute(XFA_ATTRIBUTE_Checksum, wsChecksum, false);
+ pValue->SetString(
+ FX_UTF8Encode(wsChecksum.c_str(), wsChecksum.GetLength()).AsStringC());
}
void CXFA_Node::Script_Packet_GetAttribute(CFXJSE_Arguments* pArguments) {
- int32_t argc = pArguments->GetLength();
- if (argc == 1) {
- CFX_ByteString bsAttributeName = pArguments->GetUTF8String(0);
- CFX_WideString wsAttributeValue;
- CFDE_XMLNode* pXMLNode = GetXMLMappingNode();
- if (pXMLNode && pXMLNode->GetType() == FDE_XMLNODE_Element) {
- static_cast<CFDE_XMLElement*>(pXMLNode)->GetString(
- CFX_WideString::FromUTF8(bsAttributeName.AsStringC()).c_str(),
- wsAttributeValue);
- }
- pArguments->GetReturnValue()->SetString(
- FX_UTF8Encode(wsAttributeValue.c_str(), wsAttributeValue.GetLength())
- .AsStringC());
- } else {
- ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"getAttribute");
+ if (pArguments->GetLength() != 1) {
+ ThrowParamCountMismatchException(L"getAttribute");
+ return;
}
+
+ CFX_ByteString bsAttributeName = pArguments->GetUTF8String(0);
+ CFX_WideString wsAttributeValue;
+ CFDE_XMLNode* pXMLNode = GetXMLMappingNode();
+ if (pXMLNode && pXMLNode->GetType() == FDE_XMLNODE_Element) {
+ static_cast<CFDE_XMLElement*>(pXMLNode)->GetString(
+ CFX_WideString::FromUTF8(bsAttributeName.AsStringC()).c_str(),
+ wsAttributeValue);
+ }
+ pArguments->GetReturnValue()->SetString(
+ FX_UTF8Encode(wsAttributeValue.c_str(), wsAttributeValue.GetLength())
+ .AsStringC());
}
void CXFA_Node::Script_Packet_SetAttribute(CFXJSE_Arguments* pArguments) {
- int32_t argc = pArguments->GetLength();
- if (argc == 2) {
- CFX_ByteString bsValue = pArguments->GetUTF8String(0);
- CFX_ByteString bsName = pArguments->GetUTF8String(1);
- CFDE_XMLNode* pXMLNode = GetXMLMappingNode();
- if (pXMLNode && pXMLNode->GetType() == FDE_XMLNODE_Element) {
- static_cast<CFDE_XMLElement*>(pXMLNode)->SetString(
- CFX_WideString::FromUTF8(bsName.AsStringC()),
- CFX_WideString::FromUTF8(bsValue.AsStringC()));
- }
- pArguments->GetReturnValue()->SetNull();
- } else {
- ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"setAttribute");
+ if (pArguments->GetLength() != 2) {
+ ThrowParamCountMismatchException(L"setAttribute");
+ return;
+ }
+
+ CFX_ByteString bsValue = pArguments->GetUTF8String(0);
+ CFX_ByteString bsName = pArguments->GetUTF8String(1);
+ CFDE_XMLNode* pXMLNode = GetXMLMappingNode();
+ if (pXMLNode && pXMLNode->GetType() == FDE_XMLNODE_Element) {
+ static_cast<CFDE_XMLElement*>(pXMLNode)->SetString(
+ CFX_WideString::FromUTF8(bsName.AsStringC()),
+ CFX_WideString::FromUTF8(bsValue.AsStringC()));
}
+ pArguments->GetReturnValue()->SetNull();
}
void CXFA_Node::Script_Packet_RemoveAttribute(CFXJSE_Arguments* pArguments) {
- int32_t argc = pArguments->GetLength();
- if (argc == 1) {
- CFX_ByteString bsName = pArguments->GetUTF8String(0);
- CFX_WideString wsName = CFX_WideString::FromUTF8(bsName.AsStringC());
- CFDE_XMLNode* pXMLNode = GetXMLMappingNode();
- if (pXMLNode && pXMLNode->GetType() == FDE_XMLNODE_Element) {
- CFDE_XMLElement* pXMLElement = static_cast<CFDE_XMLElement*>(pXMLNode);
- if (pXMLElement->HasAttribute(wsName.c_str())) {
- pXMLElement->RemoveAttribute(wsName.c_str());
- }
+ if (pArguments->GetLength() != 1) {
+ ThrowParamCountMismatchException(L"removeAttribute");
+ return;
+ }
+
+ CFX_ByteString bsName = pArguments->GetUTF8String(0);
+ CFX_WideString wsName = CFX_WideString::FromUTF8(bsName.AsStringC());
+ CFDE_XMLNode* pXMLNode = GetXMLMappingNode();
+ if (pXMLNode && pXMLNode->GetType() == FDE_XMLNODE_Element) {
+ CFDE_XMLElement* pXMLElement = static_cast<CFDE_XMLElement*>(pXMLNode);
+ if (pXMLElement->HasAttribute(wsName.c_str())) {
+ pXMLElement->RemoveAttribute(wsName.c_str());
}
- pArguments->GetReturnValue()->SetNull();
- } else {
- ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"removeAttribute");
}
+ pArguments->GetReturnValue()->SetNull();
}
void CXFA_Node::Script_Packet_Content(CFXJSE_Value* pValue,
@@ -3495,139 +3501,88 @@ void CXFA_Node::Script_Packet_Content(CFXJSE_Value* pValue,
}
void CXFA_Node::Script_Source_Next(CFXJSE_Arguments* pArguments) {
- int32_t argc = pArguments->GetLength();
- if (argc == 0) {
- } else {
- ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"next");
- }
+ if (pArguments->GetLength() != 0)
+ ThrowParamCountMismatchException(L"next");
}
void CXFA_Node::Script_Source_CancelBatch(CFXJSE_Arguments* pArguments) {
- int32_t argc = pArguments->GetLength();
- if (argc == 0) {
- } else {
- ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"cancelBatch");
- }
+ if (pArguments->GetLength() != 0)
+ ThrowParamCountMismatchException(L"cancelBatch");
}
void CXFA_Node::Script_Source_First(CFXJSE_Arguments* pArguments) {
- int32_t argc = pArguments->GetLength();
- if (argc == 0) {
- } else {
- ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"first");
- }
+ if (pArguments->GetLength() != 0)
+ ThrowParamCountMismatchException(L"first");
}
void CXFA_Node::Script_Source_UpdateBatch(CFXJSE_Arguments* pArguments) {
- int32_t argc = pArguments->GetLength();
- if (argc == 0) {
- } else {
- ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"updateBatch");
- }
+ if (pArguments->GetLength() != 0)
+ ThrowParamCountMismatchException(L"updateBatch");
}
void CXFA_Node::Script_Source_Previous(CFXJSE_Arguments* pArguments) {
- int32_t argc = pArguments->GetLength();
- if (argc == 0) {
- } else {
- ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"previous");
- }
+ if (pArguments->GetLength() != 0)
+ ThrowParamCountMismatchException(L"previous");
}
void CXFA_Node::Script_Source_IsBOF(CFXJSE_Arguments* pArguments) {
- int32_t argc = pArguments->GetLength();
- if (argc == 0) {
- } else {
- ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"isBOF");
- }
+ if (pArguments->GetLength() != 0)
+ ThrowParamCountMismatchException(L"isBOF");
}
void CXFA_Node::Script_Source_IsEOF(CFXJSE_Arguments* pArguments) {
- int32_t argc = pArguments->GetLength();
- if (argc == 0) {
- } else {
- ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"isEOF");
- }
+ if (pArguments->GetLength() != 0)
+ ThrowParamCountMismatchException(L"isEOF");
}
void CXFA_Node::Script_Source_Cancel(CFXJSE_Arguments* pArguments) {
- int32_t argc = pArguments->GetLength();
- if (argc == 0) {
- } else {
- ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"cancel");
- }
+ if (pArguments->GetLength() != 0)
+ ThrowParamCountMismatchException(L"cancel");
}
void CXFA_Node::Script_Source_Update(CFXJSE_Arguments* pArguments) {
- int32_t argc = pArguments->GetLength();
- if (argc == 0) {
- } else {
- ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"update");
- }
+ if (pArguments->GetLength() != 0)
+ ThrowParamCountMismatchException(L"update");
}
void CXFA_Node::Script_Source_Open(CFXJSE_Arguments* pArguments) {
- int32_t argc = pArguments->GetLength();
- if (argc == 0) {
- } else {
- ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"open");
- }
+ if (pArguments->GetLength() != 0)
+ ThrowParamCountMismatchException(L"open");
}
void CXFA_Node::Script_Source_Delete(CFXJSE_Arguments* pArguments) {
- int32_t argc = pArguments->GetLength();
- if (argc == 0) {
- } else {
- ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"delete");
- }
+ if (pArguments->GetLength() != 0)
+ ThrowParamCountMismatchException(L"delete");
}
void CXFA_Node::Script_Source_AddNew(CFXJSE_Arguments* pArguments) {
- int32_t argc = pArguments->GetLength();
- if (argc == 0) {
- } else {
- ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"addNew");
- }
+ if (pArguments->GetLength() != 0)
+ ThrowParamCountMismatchException(L"addNew");
}
void CXFA_Node::Script_Source_Requery(CFXJSE_Arguments* pArguments) {
- int32_t argc = pArguments->GetLength();
- if (argc == 0) {
- } else {
- ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"requery");
- }
+ if (pArguments->GetLength() != 0)
+ ThrowParamCountMismatchException(L"requery");
}
void CXFA_Node::Script_Source_Resync(CFXJSE_Arguments* pArguments) {
- int32_t argc = pArguments->GetLength();
- if (argc == 0) {
- } else {
- ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"resync");
- }
+ if (pArguments->GetLength() != 0)
+ ThrowParamCountMismatchException(L"resync");
}
void CXFA_Node::Script_Source_Close(CFXJSE_Arguments* pArguments) {
- int32_t argc = pArguments->GetLength();
- if (argc == 0) {
- } else {
- ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"close");
- }
+ if (pArguments->GetLength() != 0)
+ ThrowParamCountMismatchException(L"close");
}
void CXFA_Node::Script_Source_Last(CFXJSE_Arguments* pArguments) {
- int32_t argc = pArguments->GetLength();
- if (argc == 0) {
- } else {
- ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"last");
- }
+ if (pArguments->GetLength() != 0)
+ ThrowParamCountMismatchException(L"last");
}
void CXFA_Node::Script_Source_HasDataChanged(CFXJSE_Arguments* pArguments) {
- int32_t argc = pArguments->GetLength();
- if (argc == 0) {
- } else {
- ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"hasDataChanged");
- }
+ if (pArguments->GetLength() != 0)
+ ThrowParamCountMismatchException(L"hasDataChanged");
}
void CXFA_Node::Script_Source_Db(CFXJSE_Value* pValue,
@@ -3660,7 +3615,7 @@ void CXFA_Node::Script_Script_Stateless(CFXJSE_Value* pValue,
bool bSetting,
XFA_ATTRIBUTE eAttribute) {
if (bSetting) {
- ThrowException(XFA_IDS_INVAlID_PROP_SET);
+ ThrowInvalidPropertyException();
return;
}
pValue->SetString(FX_UTF8Encode(FX_WSTRC(L"0")).AsStringC());
@@ -5194,3 +5149,17 @@ void CXFA_Node::MoveBufferMapData(CXFA_Node* pSrcModule,
}
pSrcModule->MoveBufferMapData(pDstModule, pKey);
}
+
+void CXFA_Node::ThrowMissingPropertyException(
+ const CFX_WideString& obj,
+ const CFX_WideString& prop) const {
+ ThrowException(L"'%s' doesn't have property '%s'.", obj.c_str(),
+ prop.c_str());
+}
+
+void CXFA_Node::ThrowTooManyOccurancesException(
+ const CFX_WideString& obj) const {
+ ThrowException(
+ L"The element [%s] has violated its allowable number of occurrences.",
+ obj.c_str());
+}
diff --git a/xfa/fxfa/parser/cxfa_nodelist.cpp b/xfa/fxfa/parser/cxfa_nodelist.cpp
index cb09833d24..97c531f33b 100644
--- a/xfa/fxfa/parser/cxfa_nodelist.cpp
+++ b/xfa/fxfa/parser/cxfa_nodelist.cpp
@@ -36,85 +36,90 @@ CXFA_Node* CXFA_NodeList::NamedItem(const CFX_WideStringC& wsName) {
void CXFA_NodeList::Script_ListClass_Append(CFXJSE_Arguments* pArguments) {
int32_t argc = pArguments->GetLength();
- if (argc == 1) {
- CXFA_Node* pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0));
- if (pNode) {
- Append(pNode);
- } else {
- ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
- }
- } else {
- ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"append");
+ if (argc != 1) {
+ ThrowParamCountMismatchException(L"append");
+ return;
}
+
+ CXFA_Node* pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0));
+ if (!pNode) {
+ ThrowArgumentMismatchException();
+ return;
+ }
+ Append(pNode);
}
void CXFA_NodeList::Script_ListClass_Insert(CFXJSE_Arguments* pArguments) {
int32_t argc = pArguments->GetLength();
- if (argc == 2) {
- CXFA_Node* pNewNode = static_cast<CXFA_Node*>(pArguments->GetObject(0));
- CXFA_Node* pBeforeNode = static_cast<CXFA_Node*>(pArguments->GetObject(1));
- if (pNewNode) {
- Insert(pNewNode, pBeforeNode);
- } else {
- ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
- }
- } else {
- ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"insert");
+ if (argc != 2) {
+ ThrowParamCountMismatchException(L"insert");
+ return;
}
+
+ CXFA_Node* pNewNode = static_cast<CXFA_Node*>(pArguments->GetObject(0));
+ CXFA_Node* pBeforeNode = static_cast<CXFA_Node*>(pArguments->GetObject(1));
+ if (!pNewNode) {
+ ThrowArgumentMismatchException();
+ return;
+ }
+ Insert(pNewNode, pBeforeNode);
}
void CXFA_NodeList::Script_ListClass_Remove(CFXJSE_Arguments* pArguments) {
int32_t argc = pArguments->GetLength();
- if (argc == 1) {
- CXFA_Node* pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0));
- if (pNode) {
- Remove(pNode);
- } else {
- ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
- }
- } else {
- ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"remove");
+ if (argc != 1) {
+ ThrowParamCountMismatchException(L"remove");
+ return;
+ }
+
+ CXFA_Node* pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0));
+ if (!pNode) {
+ ThrowArgumentMismatchException();
+ return;
}
+ Remove(pNode);
}
void CXFA_NodeList::Script_ListClass_Item(CFXJSE_Arguments* pArguments) {
int32_t argc = pArguments->GetLength();
- if (argc == 1) {
- int32_t iIndex = pArguments->GetInt32(0);
- if ((iIndex >= 0) && (iIndex + 1 <= GetLength())) {
- pArguments->GetReturnValue()->Assign(
- m_pDocument->GetScriptContext()->GetJSValueFromMap(Item(iIndex)));
- } else {
- ThrowException(XFA_IDS_INDEX_OUT_OF_BOUNDS);
- }
- } else {
- ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"item");
+ if (argc != 1) {
+ ThrowParamCountMismatchException(L"item");
+ return;
+ }
+
+ int32_t iIndex = pArguments->GetInt32(0);
+ if (iIndex < 0 || iIndex >= GetLength()) {
+ ThrowIndexOutOfBoundsException();
+ return;
}
+ pArguments->GetReturnValue()->Assign(
+ m_pDocument->GetScriptContext()->GetJSValueFromMap(Item(iIndex)));
}
void CXFA_NodeList::Script_TreelistClass_NamedItem(
CFXJSE_Arguments* pArguments) {
int32_t argc = pArguments->GetLength();
- if (argc == 1) {
- CFX_ByteString szName = pArguments->GetUTF8String(0);
- CXFA_Node* pNode =
- NamedItem(CFX_WideString::FromUTF8(szName.AsStringC()).AsStringC());
- if (!pNode) {
- return;
- }
- pArguments->GetReturnValue()->Assign(
- m_pDocument->GetScriptContext()->GetJSValueFromMap(pNode));
- } else {
- ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"namedItem");
+ if (argc != 1) {
+ ThrowParamCountMismatchException(L"namedItem");
+ return;
}
+
+ CFX_ByteString szName = pArguments->GetUTF8String(0);
+ CXFA_Node* pNode =
+ NamedItem(CFX_WideString::FromUTF8(szName.AsStringC()).AsStringC());
+ if (!pNode)
+ return;
+
+ pArguments->GetReturnValue()->Assign(
+ m_pDocument->GetScriptContext()->GetJSValueFromMap(pNode));
}
void CXFA_NodeList::Script_ListClass_Length(CFXJSE_Value* pValue,
bool bSetting,
XFA_ATTRIBUTE eAttribute) {
- if (!bSetting) {
- pValue->SetInteger(GetLength());
- } else {
- ThrowException(XFA_IDS_INVAlID_PROP_SET);
+ if (bSetting) {
+ ThrowInvalidPropertyException();
+ return;
}
+ pValue->SetInteger(GetLength());
}
diff --git a/xfa/fxfa/parser/cxfa_object.cpp b/xfa/fxfa/parser/cxfa_object.cpp
index c8ed7138a8..45e34424aa 100644
--- a/xfa/fxfa/parser/cxfa_object.cpp
+++ b/xfa/fxfa/parser/cxfa_object.cpp
@@ -39,7 +39,7 @@ void CXFA_Object::Script_ObjectClass_ClassName(CFXJSE_Value* pValue,
bool bSetting,
XFA_ATTRIBUTE eAttribute) {
if (bSetting) {
- ThrowException(XFA_IDS_INVAlID_PROP_SET);
+ ThrowInvalidPropertyException();
return;
}
CFX_WideStringC className = GetClassName();
@@ -47,14 +47,29 @@ void CXFA_Object::Script_ObjectClass_ClassName(CFXJSE_Value* pValue,
FX_UTF8Encode(className.c_str(), className.GetLength()).AsStringC());
}
-void CXFA_Object::ThrowException(int32_t iStringID, ...) {
- IXFA_AppProvider* pAppProvider = m_pDocument->GetNotify()->GetAppProvider();
- ASSERT(pAppProvider);
+void CXFA_Object::ThrowInvalidPropertyException() const {
+ ThrowException(L"Invalid property set operation.");
+}
+
+void CXFA_Object::ThrowIndexOutOfBoundsException() const {
+ ThrowException(L"Index value is out of bounds.");
+}
+
+void CXFA_Object::ThrowParamCountMismatchException(
+ const CFX_WideString& method) const {
+ ThrowException(L"Incorrect number of parameters calling method '%s'.",
+ method.c_str());
+}
+
+void CXFA_Object::ThrowArgumentMismatchException() const {
+ ThrowException(L"Argument mismatch in property or function argument.");
+}
+void CXFA_Object::ThrowException(const FX_WCHAR* str, ...) const {
CFX_WideString wsMessage;
va_list arg_ptr;
- va_start(arg_ptr, iStringID);
- wsMessage.FormatV(pAppProvider->LoadString(iStringID).c_str(), arg_ptr);
+ va_start(arg_ptr, str);
+ wsMessage.FormatV(str, arg_ptr);
va_end(arg_ptr);
FXJSE_ThrowMessage(
FX_UTF8Encode(wsMessage.c_str(), wsMessage.GetLength()).AsStringC());
diff --git a/xfa/fxfa/parser/xfa_object.h b/xfa/fxfa/parser/xfa_object.h
index c3686ac076..93f4e0145d 100644
--- a/xfa/fxfa/parser/xfa_object.h
+++ b/xfa/fxfa/parser/xfa_object.h
@@ -90,9 +90,15 @@ class CXFA_Object : public CFXJSE_HostObject {
void Script_ObjectClass_ClassName(CFXJSE_Value* pValue,
bool bSetting,
XFA_ATTRIBUTE eAttribute);
- void ThrowException(int32_t iStringID, ...);
+
+ void ThrowInvalidPropertyException() const;
+ void ThrowArgumentMismatchException() const;
+ void ThrowIndexOutOfBoundsException() const;
+ void ThrowParamCountMismatchException(const CFX_WideString& method) const;
protected:
+ void ThrowException(const FX_WCHAR* str, ...) const;
+
CXFA_Document* const m_pDocument;
const XFA_ObjectType m_objectType;
const XFA_Element m_elementType;
@@ -676,6 +682,11 @@ class CXFA_Node : public CXFA_Object {
uint32_t m_dwNameHash;
CXFA_Node* m_pAuxNode;
XFA_MAPMODULEDATA* m_pMapModuleData;
+
+ private:
+ void ThrowMissingPropertyException(const CFX_WideString& obj,
+ const CFX_WideString& prop) const;
+ void ThrowTooManyOccurancesException(const CFX_WideString& obj) const;
};
class CXFA_ThisProxy : public CXFA_Object {