diff options
author | Tom Sepez <tsepez@chromium.org> | 2015-07-23 13:26:26 -0700 |
---|---|---|
committer | Tom Sepez <tsepez@chromium.org> | 2015-07-23 13:26:26 -0700 |
commit | 320b2313d19869333ed453af546e61a9fc2b81c9 (patch) | |
tree | 25f2eb8a0991ac485ca6354f0d3caf7fd775e732 /fpdfsdk/src/javascript/PublicMethods.cpp | |
parent | 065e9321b84fc0490f3da9099e8840c65e06868d (diff) | |
download | pdfium-320b2313d19869333ed453af546e61a9fc2b81c9.tar.xz |
FX_BOOL considered harmful, part 2.
Fully automatic change, execpt for cleanup in fx_system.h
R=thestig@chromium.org
Review URL: https://codereview.chromium.org/1254703002 .
Diffstat (limited to 'fpdfsdk/src/javascript/PublicMethods.cpp')
-rw-r--r-- | fpdfsdk/src/javascript/PublicMethods.cpp | 376 |
1 files changed, 188 insertions, 188 deletions
diff --git a/fpdfsdk/src/javascript/PublicMethods.cpp b/fpdfsdk/src/javascript/PublicMethods.cpp index daecdbec89..0aa23d16a9 100644 --- a/fpdfsdk/src/javascript/PublicMethods.cpp +++ b/fpdfsdk/src/javascript/PublicMethods.cpp @@ -72,76 +72,76 @@ static const FX_WCHAR* fullmonths[] = L"January", L"February", L"March", L"April", L"May", L"June", L"July", L"August", L"September", L"October", L"November", L"December" }; -FX_BOOL CJS_PublicMethods::IsNumber(const FX_WCHAR* string) +bool CJS_PublicMethods::IsNumber(const FX_WCHAR* string) { CFX_WideString sTrim = StrTrim(string); const FX_WCHAR* pTrim = sTrim.c_str(); const FX_WCHAR* p = pTrim; - FX_BOOL bDot = FALSE; - FX_BOOL bKXJS = FALSE; + bool bDot = false; + bool bKXJS = false; wchar_t c; while ((c = *p)) { if (c == '.' || c == ',') { - if (bDot) return FALSE; - bDot = TRUE; + if (bDot) return false; + bDot = true; } else if (c == '-' || c == '+') { if (p != pTrim) - return FALSE; + return false; } else if (c == 'e' || c == 'E') { if (bKXJS) - return FALSE; + return false; p++; c = *p; if (c == '+' || c == '-') { - bKXJS = TRUE; + bKXJS = true; } else { - return FALSE; + return false; } } else if (!IsDigit(c)) { - return FALSE; + return false; } p++; } - return TRUE; + return true; } -FX_BOOL CJS_PublicMethods::IsDigit(wchar_t ch) +bool CJS_PublicMethods::IsDigit(wchar_t ch) { return (ch >= L'0' && ch <= L'9'); } -FX_BOOL CJS_PublicMethods::IsDigit(char ch) +bool CJS_PublicMethods::IsDigit(char ch) { return (ch >= '0' && ch <= '9'); } -FX_BOOL CJS_PublicMethods::IsAlphabetic(wchar_t ch) +bool CJS_PublicMethods::IsAlphabetic(wchar_t ch) { return ((ch >= L'a' && ch <= L'z') || (ch >= L'A' && ch <= L'Z')); } -FX_BOOL CJS_PublicMethods::IsAlphaNumeric(wchar_t ch) +bool CJS_PublicMethods::IsAlphaNumeric(wchar_t ch) { return (IsDigit(ch) || IsAlphabetic(ch)); } -FX_BOOL CJS_PublicMethods::maskSatisfied(wchar_t c_Change,wchar_t c_Mask) +bool CJS_PublicMethods::maskSatisfied(wchar_t c_Change,wchar_t c_Mask) { switch (c_Mask) { @@ -152,13 +152,13 @@ FX_BOOL CJS_PublicMethods::maskSatisfied(wchar_t c_Change,wchar_t c_Mask) case L'O': return IsAlphaNumeric(c_Change); case L'X': - return TRUE; + return true; default: return (c_Change == c_Mask); } } -FX_BOOL CJS_PublicMethods::isReservedMaskChar(wchar_t ch) +bool CJS_PublicMethods::isReservedMaskChar(wchar_t ch) { return ch == L'9' || ch == L'A' || ch == L'O' || ch == L'X'; } @@ -226,13 +226,13 @@ CFX_ByteString CJS_PublicMethods::StrTrim(const FX_CHAR* pStr) return StrRTrim(StrLTrim(pStr)); } -double CJS_PublicMethods::ParseNumber(const FX_WCHAR* swSource, FX_BOOL& bAllDigits, FX_BOOL& bDot, FX_BOOL& bSign, FX_BOOL& bKXJS) +double CJS_PublicMethods::ParseNumber(const FX_WCHAR* swSource, bool& bAllDigits, bool& bDot, bool& bSign, bool& bKXJS) { - bDot = FALSE; - bSign = FALSE; - bKXJS = FALSE; + bDot = false; + bSign = false; + bKXJS = false; - FX_BOOL bDigitExist = FALSE; + bool bDigitExist = false; const FX_WCHAR* p = swSource; wchar_t c; @@ -253,7 +253,7 @@ double CJS_PublicMethods::ParseNumber(const FX_WCHAR* swSource, FX_BOOL& bAllDig if (!pStart) { - bAllDigits = FALSE; + bAllDigits = false; return 0; } @@ -267,7 +267,7 @@ double CJS_PublicMethods::ParseNumber(const FX_WCHAR* swSource, FX_BOOL& bAllDig double dRet = 0; p = pStart; - bAllDigits = TRUE; + bAllDigits = true; CFX_WideString swDigits; while (p <= pEnd) @@ -277,14 +277,14 @@ double CJS_PublicMethods::ParseNumber(const FX_WCHAR* swSource, FX_BOOL& bAllDig if (IsDigit(c)) { swDigits += c; - bDigitExist = TRUE; + bDigitExist = true; } else { switch (c) { case L' ': - bAllDigits = FALSE; + bAllDigits = false; break; case L'.': case L',': @@ -298,10 +298,10 @@ double CJS_PublicMethods::ParseNumber(const FX_WCHAR* swSource, FX_BOOL& bAllDig { swDigits += L'0'; swDigits += L'.'; - bDigitExist = TRUE; + bDigitExist = true; } - bDot = TRUE; + bDot = true; break; } case 'e': @@ -312,7 +312,7 @@ double CJS_PublicMethods::ParseNumber(const FX_WCHAR* swSource, FX_BOOL& bAllDig c = *p; if (c == '+' || c == '-') { - bKXJS = TRUE; + bKXJS = true; swDigits += 'e'; swDigits += c; } @@ -322,21 +322,21 @@ double CJS_PublicMethods::ParseNumber(const FX_WCHAR* swSource, FX_BOOL& bAllDig if (!bDigitExist && !bSign) { swDigits += c; - bSign = TRUE; + bSign = true; break; } default: - bAllDigits = FALSE; + bAllDigits = false; if (p != pStart && !bDot && bDigitExist) { swDigits += L'.'; - bDot = TRUE; + bDot = true; } else { - bDot = FALSE; - bDigitExist = FALSE; + bDot = false; + bDigitExist = false; swDigits = L""; } break; @@ -374,19 +374,19 @@ double CJS_PublicMethods::ParseNumber(const FX_WCHAR* swSource, FX_BOOL& bAllDig double CJS_PublicMethods::ParseStringToNumber(const FX_WCHAR* swSource) { - FX_BOOL bAllDigits = FALSE; - FX_BOOL bDot = FALSE; - FX_BOOL bSign = FALSE; - FX_BOOL bKXJS = FALSE; + bool bAllDigits = false; + bool bDot = false; + bool bSign = false; + bool bKXJS = false; return ParseNumber(swSource, bAllDigits, bDot, bSign, bKXJS); } -FX_BOOL CJS_PublicMethods::ConvertStringToNumber(const FX_WCHAR* swSource, double & dRet, FX_BOOL & bDot) +bool CJS_PublicMethods::ConvertStringToNumber(const FX_WCHAR* swSource, double & dRet, bool & bDot) { - FX_BOOL bAllDigits = FALSE; - FX_BOOL bSign = FALSE; - FX_BOOL bKXJS = FALSE; + bool bAllDigits = false; + bool bSign = false; + bool bKXJS = false; dRet = ParseNumber(swSource, bAllDigits, bDot, bSign, bKXJS); @@ -477,7 +477,7 @@ CFX_WideString CJS_PublicMethods::ParseStringString(const CFX_WideString& string return swRet; } -double CJS_PublicMethods::ParseNormalDate(const CFX_WideString & value, FX_BOOL& bWrongFormat) +double CJS_PublicMethods::ParseNormalDate(const CFX_WideString & value, bool& bWrongFormat) { double dt = JS_GetDateTime(); @@ -525,7 +525,7 @@ double CJS_PublicMethods::ParseNormalDate(const CFX_WideString & value, FX_BOOL& nMonth = number[1]; } - bWrongFormat = FALSE; + bWrongFormat = false; } else if (nIndex == 3) { @@ -552,11 +552,11 @@ double CJS_PublicMethods::ParseNormalDate(const CFX_WideString & value, FX_BOOL& nYear = number[2]; } - bWrongFormat = FALSE; + bWrongFormat = false; } else { - bWrongFormat = TRUE; + bWrongFormat = true; return dt; } @@ -565,7 +565,7 @@ double CJS_PublicMethods::ParseNormalDate(const CFX_WideString & value, FX_BOOL& return JS_DateParse(swTemp.c_str()); } -double CJS_PublicMethods::MakeRegularDate(const CFX_WideString & value, const CFX_WideString & format, FX_BOOL& bWrongFormat) +double CJS_PublicMethods::MakeRegularDate(const CFX_WideString & value, const CFX_WideString & format, bool& bWrongFormat) { double dt = JS_GetDateTime(); @@ -581,9 +581,9 @@ double CJS_PublicMethods::MakeRegularDate(const CFX_WideString & value, const CF int nYearSub = 99; //nYear - 2000; - FX_BOOL bPm = FALSE; - FX_BOOL bExit = FALSE; - bWrongFormat = FALSE; + bool bPm = false; + bool bExit = false; + bWrongFormat = false; int i=0; int j=0; @@ -715,7 +715,7 @@ double CJS_PublicMethods::MakeRegularDate(const CFX_WideString & value, const CF case 'm': { CFX_WideString sMonth = ParseStringString(value, j, nSkip); - FX_BOOL bFind = FALSE; + bool bFind = false; for (int m = 0; m < 12; m++) { if (sMonth.CompareNoCase(months[m]) == 0) @@ -723,7 +723,7 @@ double CJS_PublicMethods::MakeRegularDate(const CFX_WideString & value, const CF nMonth = m + 1; i+=3; j+=nSkip; - bFind = TRUE; + bFind = true; break; } } @@ -757,7 +757,7 @@ double CJS_PublicMethods::MakeRegularDate(const CFX_WideString & value, const CF break; case 'm': { - FX_BOOL bFind = FALSE; + bool bFind = false; CFX_WideString sMonth = ParseStringString(value, j, nSkip); sMonth.MakeLower(); @@ -772,7 +772,7 @@ double CJS_PublicMethods::MakeRegularDate(const CFX_WideString & value, const CF nMonth = m + 1; i += 4; j += nSkip; - bFind = TRUE; + bFind = true; break; } } @@ -795,8 +795,8 @@ double CJS_PublicMethods::MakeRegularDate(const CFX_WideString & value, const CF { if (j >= value.GetLength() || format.GetAt(i) != value.GetAt(j)) { - bWrongFormat = TRUE; - bExit = TRUE; + bWrongFormat = true; + bExit = true; } i++; j++; @@ -804,8 +804,8 @@ double CJS_PublicMethods::MakeRegularDate(const CFX_WideString & value, const CF if (oldj == j) { - bWrongFormat = TRUE; - bExit = TRUE; + bWrongFormat = true; + bExit = true; } } @@ -813,12 +813,12 @@ double CJS_PublicMethods::MakeRegularDate(const CFX_WideString & value, const CF default: if (value.GetLength() <= j) { - bExit = TRUE; + bExit = true; } else if (format.GetAt(i) != value.GetAt(j)) { - bWrongFormat = TRUE; - bExit = TRUE; + bWrongFormat = true; + bExit = true; } i++; @@ -833,19 +833,19 @@ double CJS_PublicMethods::MakeRegularDate(const CFX_WideString & value, const CF nYear += 2000; if (nMonth < 1 || nMonth > 12) - bWrongFormat = TRUE; + bWrongFormat = true; if (nDay < 1 || nDay > 31) - bWrongFormat = TRUE; + bWrongFormat = true; if (nHour < 0 || nHour > 24) - bWrongFormat = TRUE; + bWrongFormat = true; if (nMin < 0 || nMin > 60) - bWrongFormat = TRUE; + bWrongFormat = true; if (nSec < 0 || nSec > 60) - bWrongFormat = TRUE; + bWrongFormat = true; double dRet = 0; @@ -1021,7 +1021,7 @@ CFX_WideString CJS_PublicMethods::MakeFormatDate(double dDate, const CFX_WideStr /* -------------------------------------------------------------------------- */ //function AFNumber_Format(nDec, sepStyle, negStyle, currStyle, strCurrency, bCurrencyPrepend) -FX_BOOL CJS_PublicMethods::AFNumber_Format(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError) +bool CJS_PublicMethods::AFNumber_Format(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError) { #if _FX_OS_ != _FX_ANDROID_ v8::Isolate* isolate = ::GetIsolate(cc); @@ -1033,21 +1033,21 @@ FX_BOOL CJS_PublicMethods::AFNumber_Format(IFXJS_Context* cc, const CJS_Paramete if (params.size() != 6) { sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); - return FALSE; + return false; } if(!pEvent->m_pValue) - return FALSE; + return false; CFX_WideString& Value = pEvent->Value(); CFX_ByteString strValue = StrTrim(CFX_ByteString::FromUnicode(Value)); - if (strValue.IsEmpty()) return TRUE; + if (strValue.IsEmpty()) return true; int iDec = params[0].ToInt(); int iSepStyle = params[1].ToInt(); int iNegStyle = params[2].ToInt(); // params[3] is iCurrStyle, it's not used. std::wstring wstrCurrency(params[4].ToCFXWideString().c_str()); - FX_BOOL bCurrencyPrepend = params[5].ToBool(); + bool bCurrencyPrepend = params[5].ToBool(); if (iDec < 0) iDec = -iDec; @@ -1224,11 +1224,11 @@ FX_BOOL CJS_PublicMethods::AFNumber_Format(IFXJS_Context* cc, const CJS_Paramete } Value = strValue2.c_str(); #endif - return TRUE; + return true; } //function AFNumber_Keystroke(nDec, sepStyle, negStyle, currStyle, strCurrency, bCurrencyPrepend) -FX_BOOL CJS_PublicMethods::AFNumber_Keystroke(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError) +bool CJS_PublicMethods::AFNumber_Keystroke(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError) { CJS_Context* pContext = (CJS_Context *)cc; ASSERT(pContext != NULL); @@ -1236,13 +1236,13 @@ FX_BOOL CJS_PublicMethods::AFNumber_Keystroke(IFXJS_Context* cc, const CJS_Param ASSERT(pEvent != NULL); if(params.size() < 2) - return FALSE; + return false; int iSepStyle = params[1].ToInt(); if (iSepStyle < 0 || iSepStyle > 3) iSepStyle = 0; if(!pEvent->m_pValue) - return FALSE; + return false; CFX_WideString & val = pEvent->Value(); CFX_WideString & w_strChange = pEvent->Change(); CFX_WideString w_strValue = val; @@ -1252,18 +1252,18 @@ FX_BOOL CJS_PublicMethods::AFNumber_Keystroke(IFXJS_Context* cc, const CJS_Param CFX_WideString wstrChange = w_strChange; CFX_WideString wstrValue = StrLTrim(w_strValue.c_str()); if (wstrValue.IsEmpty()) - return TRUE; + return true; CFX_WideString swTemp = wstrValue; swTemp.Replace(L",", L"."); if (!IsNumber(swTemp.c_str())) { - pEvent->Rc() = FALSE; + pEvent->Rc() = false; sError = JSGetStringFromID(pContext, IDS_STRING_JSAFNUMBER_KEYSTROKE); Alert(pContext, sError.c_str()); - return TRUE; + return true; } - return TRUE; // it happens after the last keystroke and before validating, + return true; // it happens after the last keystroke and before validating, } std::wstring w_strValue2 = w_strValue.c_str(); @@ -1271,15 +1271,15 @@ FX_BOOL CJS_PublicMethods::AFNumber_Keystroke(IFXJS_Context* cc, const CJS_Param std::wstring w_strSelected; if(-1 != pEvent->SelStart()) w_strSelected = w_strValue2.substr(pEvent->SelStart(),(pEvent->SelEnd() - pEvent->SelStart())); - FX_BOOL bHasSign = (w_strValue2.find('-') != -1) && (w_strSelected.find('-') == -1); + bool bHasSign = (w_strValue2.find('-') != -1) && (w_strSelected.find('-') == -1); if (bHasSign) { //can't insert "change" in front to sign postion. if (pEvent->SelStart() == 0) { - FX_BOOL &bRc = pEvent->Rc(); - bRc = FALSE; - return TRUE; + bool &bRc = pEvent->Rc(); + bRc = false; + return true; } } @@ -1297,49 +1297,49 @@ FX_BOOL CJS_PublicMethods::AFNumber_Keystroke(IFXJS_Context* cc, const CJS_Param break; } - FX_BOOL bHasSep = (w_strValue2.find(cSep) != -1); + bool bHasSep = (w_strValue2.find(cSep) != -1); for (std::wstring::iterator it = w_strChange2.begin(); it != w_strChange2.end(); it++) { if (*it == cSep) { if (bHasSep) { - FX_BOOL &bRc = pEvent->Rc(); - bRc = FALSE; - return TRUE; + bool &bRc = pEvent->Rc(); + bRc = false; + return true; } - bHasSep = TRUE; + bHasSep = true; continue; } if (*it == L'-') { if (bHasSign) { - FX_BOOL &bRc = pEvent->Rc(); - bRc = FALSE; - return TRUE; + bool &bRc = pEvent->Rc(); + bRc = false; + return true; } if (it != w_strChange2.begin()) //sign's position is not correct { - FX_BOOL &bRc = pEvent->Rc(); - bRc = FALSE; - return TRUE; + bool &bRc = pEvent->Rc(); + bRc = false; + return true; } if (pEvent->SelStart() != 0) { - FX_BOOL &bRc = pEvent->Rc(); - bRc = FALSE; - return TRUE; + bool &bRc = pEvent->Rc(); + bRc = false; + return true; } - bHasSign = TRUE; + bHasSign = true; continue; } if (!IsDigit(*it)) { - FX_BOOL &bRc = pEvent->Rc(); - bRc = FALSE; - return TRUE; + bool &bRc = pEvent->Rc(); + bRc = false; + return true; } } @@ -1351,12 +1351,12 @@ FX_BOOL CJS_PublicMethods::AFNumber_Keystroke(IFXJS_Context* cc, const CJS_Param w_strValue2 = w_prefix + w_strChange2 + w_postfix; w_strValue = w_strValue2.c_str(); val = w_strValue; - return TRUE; + return true; } //function AFPercent_Format(nDec, sepStyle) -FX_BOOL CJS_PublicMethods::AFPercent_Format(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError) +bool CJS_PublicMethods::AFPercent_Format(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError) { #if _FX_OS_ != _FX_ANDROID_ CJS_Context* pContext = (CJS_Context *)cc; @@ -1367,15 +1367,15 @@ FX_BOOL CJS_PublicMethods::AFPercent_Format(IFXJS_Context* cc, const CJS_Paramet if (params.size() != 2) { sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); - return FALSE; + return false; } if(!pEvent->m_pValue) - return FALSE; + return false; CFX_WideString& Value = pEvent->Value(); CFX_ByteString strValue = StrTrim(CFX_ByteString::FromUnicode(Value)); if (strValue.IsEmpty()) - return TRUE; + return true; int iDec = params[0].ToInt(); if (iDec < 0) @@ -1461,16 +1461,16 @@ FX_BOOL CJS_PublicMethods::AFPercent_Format(IFXJS_Context* cc, const CJS_Paramet strValue += "%"; Value = CFX_WideString::FromLocal(strValue); #endif - return TRUE; + return true; } //AFPercent_Keystroke(nDec, sepStyle) -FX_BOOL CJS_PublicMethods::AFPercent_Keystroke(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError) +bool CJS_PublicMethods::AFPercent_Keystroke(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError) { return AFNumber_Keystroke(cc,params,vRet,sError); } //function AFDate_FormatEx(cFormat) -FX_BOOL CJS_PublicMethods::AFDate_FormatEx(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError) +bool CJS_PublicMethods::AFDate_FormatEx(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError) { CJS_Context* pContext = (CJS_Context *)cc; ASSERT(pContext != NULL); @@ -1480,18 +1480,18 @@ FX_BOOL CJS_PublicMethods::AFDate_FormatEx(IFXJS_Context* cc, const CJS_Paramete if (params.size() != 1) { sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); - return FALSE; + return false; } if(!pEvent->m_pValue) - return FALSE; + return false; CFX_WideString& val = pEvent->Value(); CFX_WideString strValue = val; if (strValue.IsEmpty()) - return TRUE; + return true; CFX_WideString sFormat = params[0].ToCFXWideString(); - FX_BOOL bWrongFormat = FALSE; + bool bWrongFormat = false; double dDate = 0.0f; if(strValue.Find(L"GMT") != -1) @@ -1510,11 +1510,11 @@ FX_BOOL CJS_PublicMethods::AFDate_FormatEx(IFXJS_Context* cc, const CJS_Paramete CFX_WideString swMsg; swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSPARSEDATE).c_str(), sFormat.c_str()); Alert(pContext, swMsg.c_str()); - return FALSE; + return false; } val = MakeFormatDate(dDate,sFormat); - return TRUE; + return true; } double CJS_PublicMethods::MakeInterDate(CFX_WideString strValue) @@ -1578,7 +1578,7 @@ double CJS_PublicMethods::MakeInterDate(CFX_WideString strValue) } //AFDate_KeystrokeEx(cFormat) -FX_BOOL CJS_PublicMethods::AFDate_KeystrokeEx(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError) +bool CJS_PublicMethods::AFDate_KeystrokeEx(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError) { CJS_Context* pContext = (CJS_Context *)cc; ASSERT(pContext != NULL); @@ -1588,33 +1588,33 @@ FX_BOOL CJS_PublicMethods::AFDate_KeystrokeEx(IFXJS_Context* cc, const CJS_Param if (params.size() != 1) { sError = L"AFDate_KeystrokeEx's parameters' size r not correct"; - return FALSE; + return false; } if (pEvent->WillCommit()) { if(!pEvent->m_pValue) - return FALSE; + return false; CFX_WideString strValue = pEvent->Value(); if (strValue.IsEmpty()) - return TRUE; + return true; CFX_WideString sFormat = params[0].ToCFXWideString(); - FX_BOOL bWrongFormat = FALSE; + bool bWrongFormat = false; double dRet = MakeRegularDate(strValue,sFormat,bWrongFormat); if (bWrongFormat || JS_PortIsNan(dRet)) { CFX_WideString swMsg; swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSPARSEDATE).c_str(), sFormat.c_str()); Alert(pContext, swMsg.c_str()); - pEvent->Rc() = FALSE; - return TRUE; + pEvent->Rc() = false; + return true; } } - return TRUE; + return true; } -FX_BOOL CJS_PublicMethods::AFDate_Format(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError) +bool CJS_PublicMethods::AFDate_Format(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError) { v8::Isolate* isolate = ::GetIsolate(cc); @@ -1624,7 +1624,7 @@ FX_BOOL CJS_PublicMethods::AFDate_Format(IFXJS_Context* cc, const CJS_Parameters ASSERT(pContext != NULL); sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); - return FALSE; + return false; } int iIndex = params[0].ToInt(); @@ -1645,7 +1645,7 @@ FX_BOOL CJS_PublicMethods::AFDate_Format(IFXJS_Context* cc, const CJS_Parameters } //AFDate_KeystrokeEx(cFormat) -FX_BOOL CJS_PublicMethods::AFDate_Keystroke(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError) +bool CJS_PublicMethods::AFDate_Keystroke(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError) { v8::Isolate* isolate = ::GetIsolate(cc); @@ -1655,7 +1655,7 @@ FX_BOOL CJS_PublicMethods::AFDate_Keystroke(IFXJS_Context* cc, const CJS_Paramet ASSERT(pContext != NULL); sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); - return FALSE; + return false; } int iIndex = params[0].ToInt(); @@ -1676,7 +1676,7 @@ FX_BOOL CJS_PublicMethods::AFDate_Keystroke(IFXJS_Context* cc, const CJS_Paramet } //function AFTime_Format(ptf) -FX_BOOL CJS_PublicMethods::AFTime_Format(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError) +bool CJS_PublicMethods::AFTime_Format(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError) { v8::Isolate* isolate = ::GetIsolate(cc); @@ -1685,7 +1685,7 @@ FX_BOOL CJS_PublicMethods::AFTime_Format(IFXJS_Context* cc, const CJS_Parameters CJS_Context* pContext = (CJS_Context*)cc; ASSERT(pContext != NULL); sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); - return FALSE; + return false; } int iIndex = params[0].ToInt(); @@ -1703,7 +1703,7 @@ FX_BOOL CJS_PublicMethods::AFTime_Format(IFXJS_Context* cc, const CJS_Parameters return AFDate_FormatEx(cc,newParams,vRet,sError); } -FX_BOOL CJS_PublicMethods::AFTime_Keystroke(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError) +bool CJS_PublicMethods::AFTime_Keystroke(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError) { v8::Isolate* isolate = ::GetIsolate(cc); if (params.size() != 1) @@ -1711,7 +1711,7 @@ FX_BOOL CJS_PublicMethods::AFTime_Keystroke(IFXJS_Context* cc, const CJS_Paramet CJS_Context* pContext = (CJS_Context*)cc; ASSERT(pContext != NULL); sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); - return FALSE; + return false; } int iIndex = params[0].ToInt(); @@ -1729,18 +1729,18 @@ FX_BOOL CJS_PublicMethods::AFTime_Keystroke(IFXJS_Context* cc, const CJS_Paramet return AFDate_KeystrokeEx(cc,newParams,vRet,sError); } -FX_BOOL CJS_PublicMethods::AFTime_FormatEx(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError) +bool CJS_PublicMethods::AFTime_FormatEx(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError) { return AFDate_FormatEx(cc,params,vRet,sError); } -FX_BOOL CJS_PublicMethods::AFTime_KeystrokeEx(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError) +bool CJS_PublicMethods::AFTime_KeystrokeEx(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError) { return AFDate_KeystrokeEx(cc,params,vRet,sError); } //function AFSpecial_Format(psf) -FX_BOOL CJS_PublicMethods::AFSpecial_Format(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError) +bool CJS_PublicMethods::AFSpecial_Format(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError) { CJS_Context* pContext = (CJS_Context *)cc; ASSERT(pContext != NULL); @@ -1748,7 +1748,7 @@ FX_BOOL CJS_PublicMethods::AFSpecial_Format(IFXJS_Context* cc, const CJS_Paramet if (params.size() != 1) { sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); - return FALSE; + return false; } std::string cFormat; @@ -1758,7 +1758,7 @@ FX_BOOL CJS_PublicMethods::AFSpecial_Format(IFXJS_Context* cc, const CJS_Paramet ASSERT(pEvent != NULL); if(!pEvent->m_pValue) - return FALSE; + return false; CFX_WideString& Value = pEvent->Value(); std::string strSrc = CFX_ByteString::FromUnicode(Value).c_str(); @@ -1788,12 +1788,12 @@ FX_BOOL CJS_PublicMethods::AFSpecial_Format(IFXJS_Context* cc, const CJS_Paramet std::string strDes; util::printx(cFormat,strSrc,strDes); Value = CFX_WideString::FromLocal(strDes.c_str()); - return TRUE; + return true; } //function AFSpecial_KeystrokeEx(mask) -FX_BOOL CJS_PublicMethods::AFSpecial_KeystrokeEx(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError) +bool CJS_PublicMethods::AFSpecial_KeystrokeEx(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError) { CJS_Context* pContext = (CJS_Context *)cc; ASSERT(pContext != NULL); @@ -1804,23 +1804,23 @@ FX_BOOL CJS_PublicMethods::AFSpecial_KeystrokeEx(IFXJS_Context* cc, const CJS_Pa if (params.size() < 1) { sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); - return FALSE; + return false; } if(!pEvent->m_pValue) - return FALSE; + return false; CFX_WideString& valEvent = pEvent->Value(); CFX_WideString wstrMask = params[0].ToCFXWideString(); if (wstrMask.IsEmpty()) - return TRUE; + return true; std::wstring wstrValue = valEvent.c_str(); if (pEvent->WillCommit()) { if (wstrValue.empty()) - return TRUE; + return true; int iIndexMask = 0; for (std::wstring::iterator it = wstrValue.begin(); it != wstrValue.end(); it++) { @@ -1833,30 +1833,30 @@ FX_BOOL CJS_PublicMethods::AFSpecial_KeystrokeEx(IFXJS_Context* cc, const CJS_Pa if (iIndexMask != wstrMask.GetLength() || (iIndexMask != wstrValue.size() && wstrMask.GetLength() != 0)) { Alert(pContext, JSGetStringFromID(pContext, IDS_STRING_JSAFNUMBER_KEYSTROKE).c_str()); - pEvent->Rc() = FALSE; + pEvent->Rc() = false; } - return TRUE; + return true; } CFX_WideString &wideChange = pEvent->Change(); std::wstring wChange = wideChange.c_str(); if (wChange.empty()) - return TRUE; + return true; int iIndexMask = pEvent->SelStart(); if (wstrValue.length() - (pEvent->SelEnd()-pEvent->SelStart()) + wChange.length() > (FX_DWORD)wstrMask.GetLength()) { Alert(pContext, JSGetStringFromID(pContext, IDS_STRING_JSPARAM_TOOLONG).c_str()); - pEvent->Rc() = FALSE; - return TRUE; + pEvent->Rc() = false; + return true; } if (iIndexMask >= wstrMask.GetLength() && (!wChange.empty())) { Alert(pContext, JSGetStringFromID(pContext, IDS_STRING_JSPARAM_TOOLONG).c_str()); - pEvent->Rc() = FALSE; - return TRUE; + pEvent->Rc() = false; + return true; } for (std::wstring::iterator it = wChange.begin(); it != wChange.end(); it++) @@ -1864,8 +1864,8 @@ FX_BOOL CJS_PublicMethods::AFSpecial_KeystrokeEx(IFXJS_Context* cc, const CJS_Pa if (iIndexMask >= wstrMask.GetLength()) { Alert(pContext, JSGetStringFromID(pContext, IDS_STRING_JSPARAM_TOOLONG).c_str()); - pEvent->Rc() = FALSE; - return TRUE; + pEvent->Rc() = false; + return true; } wchar_t w_Mask = wstrMask[iIndexMask]; if (!isReservedMaskChar(w_Mask)) @@ -1875,19 +1875,19 @@ FX_BOOL CJS_PublicMethods::AFSpecial_KeystrokeEx(IFXJS_Context* cc, const CJS_Pa wchar_t w_Change = *it; if (!maskSatisfied(w_Change,w_Mask)) { - pEvent->Rc() = FALSE; - return TRUE; + pEvent->Rc() = false; + return true; } iIndexMask++; } wideChange = wChange.c_str(); - return TRUE; + return true; } //function AFSpecial_Keystroke(psf) -FX_BOOL CJS_PublicMethods::AFSpecial_Keystroke(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError) +bool CJS_PublicMethods::AFSpecial_Keystroke(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError) { v8::Isolate* isolate = ::GetIsolate(cc); @@ -1899,14 +1899,14 @@ FX_BOOL CJS_PublicMethods::AFSpecial_Keystroke(IFXJS_Context* cc, const CJS_Para if (params.size() != 1) { sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); - return FALSE; + return false; } std::string cFormat; int iIndex = params[0].ToInt(); if(!pEvent->m_pValue) - return FALSE; + return false; //CJS_Value val = pEvent->Value(); CFX_WideString& val = pEvent->Value(); std::string strSrc = CFX_ByteString::FromUnicode(val).c_str(); @@ -1946,7 +1946,7 @@ FX_BOOL CJS_PublicMethods::AFSpecial_Keystroke(IFXJS_Context* cc, const CJS_Para return AFSpecial_KeystrokeEx(cc,params2,vRet,sError); } -FX_BOOL CJS_PublicMethods::AFMergeChange(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError) +bool CJS_PublicMethods::AFMergeChange(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError) { CJS_Context* pContext = (CJS_Context *)cc; ASSERT(pContext != NULL); @@ -1956,7 +1956,7 @@ FX_BOOL CJS_PublicMethods::AFMergeChange(IFXJS_Context* cc, const CJS_Parameters if (params.size() != 1) { sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); - return FALSE; + return false; } CFX_WideString swValue; @@ -1966,7 +1966,7 @@ FX_BOOL CJS_PublicMethods::AFMergeChange(IFXJS_Context* cc, const CJS_Parameters if (pEventHandler->WillCommit()) { vRet = swValue.c_str(); - return TRUE; + return true; } CFX_WideString prefix,postfix; @@ -1983,10 +1983,10 @@ FX_BOOL CJS_PublicMethods::AFMergeChange(IFXJS_Context* cc, const CJS_Parameters vRet = (prefix + pEventHandler->Change() + postfix).c_str(); - return TRUE; + return true; } -FX_BOOL CJS_PublicMethods::AFParseDateEx(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError) +bool CJS_PublicMethods::AFParseDateEx(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError) { CJS_Context* pContext = (CJS_Context *)cc; ASSERT(pContext != NULL); @@ -1994,13 +1994,13 @@ FX_BOOL CJS_PublicMethods::AFParseDateEx(IFXJS_Context* cc, const CJS_Parameters if (params.size() != 2) { sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); - return FALSE; + return false; } CFX_WideString sValue = params[0].ToCFXWideString(); CFX_WideString sFormat = params[1].ToCFXWideString(); - FX_BOOL bWrongFormat = FALSE; + bool bWrongFormat = false; double dDate = MakeRegularDate(sValue,sFormat,bWrongFormat); if (JS_PortIsNan(dDate)) @@ -2008,14 +2008,14 @@ FX_BOOL CJS_PublicMethods::AFParseDateEx(IFXJS_Context* cc, const CJS_Parameters CFX_WideString swMsg; swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSPARSEDATE).c_str(), sFormat.c_str()); Alert((CJS_Context *)cc, swMsg.c_str()); - return FALSE; + return false; } vRet = dDate; - return TRUE; + return true; } -FX_BOOL CJS_PublicMethods::AFSimple(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError) +bool CJS_PublicMethods::AFSimple(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError) { if (params.size() != 3) { @@ -2023,14 +2023,14 @@ FX_BOOL CJS_PublicMethods::AFSimple(IFXJS_Context* cc, const CJS_Parameters& par ASSERT(pContext != NULL); sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); - return FALSE; + return false; } vRet = (double)AF_Simple(params[0].ToCFXWideString().c_str(), params[1].ToDouble(), params[2].ToDouble()); - return TRUE; + return true; } -FX_BOOL CJS_PublicMethods::AFMakeNumber(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError) +bool CJS_PublicMethods::AFMakeNumber(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError) { if (params.size() != 1) { @@ -2038,13 +2038,13 @@ FX_BOOL CJS_PublicMethods::AFMakeNumber(IFXJS_Context* cc, const CJS_Parameters& ASSERT(pContext != NULL); sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); - return FALSE; + return false; } vRet = ParseStringToNumber(params[0].ToCFXWideString().c_str()); - return TRUE; + return true; } -FX_BOOL CJS_PublicMethods::AFSimple_Calculate(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError) +bool CJS_PublicMethods::AFSimple_Calculate(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError) { v8::Isolate* isolate = ::GetIsolate(cc); @@ -2054,7 +2054,7 @@ FX_BOOL CJS_PublicMethods::AFSimple_Calculate(IFXJS_Context* cc, const CJS_Param if (params.size() != 2) { sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); - return FALSE; + return false; } CJS_Value params1 = params[1]; @@ -2062,7 +2062,7 @@ FX_BOOL CJS_PublicMethods::AFSimple_Calculate(IFXJS_Context* cc, const CJS_Param if (!params1.IsArrayObject() && params1.GetType() != VT_string) { sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); - return FALSE; + return false; } CPDFSDK_Document* pReaderDoc = pContext->GetReaderDocument(); @@ -2162,13 +2162,13 @@ FX_BOOL CJS_PublicMethods::AFSimple_Calculate(IFXJS_Context* cc, const CJS_Param if((CJS_EventHandler*)pContext->GetEventHandler()->m_pValue) ((CJS_EventHandler*)pContext->GetEventHandler())->Value() = jsValue.ToCFXWideString(); - return TRUE; + return true; } /* This function validates the current event to ensure that its value is ** within the specified range. */ -FX_BOOL CJS_PublicMethods::AFRange_Validate(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError) +bool CJS_PublicMethods::AFRange_Validate(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError) { CJS_Context* pContext = (CJS_Context *)cc; ASSERT(pContext != NULL); @@ -2178,17 +2178,17 @@ FX_BOOL CJS_PublicMethods::AFRange_Validate(IFXJS_Context* cc, const CJS_Paramet if (params.size() != 4) { sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); - return FALSE; + return false; } if(!pEvent->m_pValue) - return FALSE; + return false; if (pEvent->Value().IsEmpty() ) - return TRUE; + return true; double dEentValue = atof(CFX_ByteString::FromUnicode(pEvent->Value())); - FX_BOOL bGreaterThan = params[0].ToBool(); + bool bGreaterThan = params[0].ToBool(); double dGreaterThan = params[1].ToDouble(); - FX_BOOL bLessThan = params[2].ToBool(); + bool bLessThan = params[2].ToBool(); double dLessThan = params[3].ToDouble(); CFX_WideString swMsg; @@ -2215,12 +2215,12 @@ FX_BOOL CJS_PublicMethods::AFRange_Validate(IFXJS_Context* cc, const CJS_Paramet if (!swMsg.IsEmpty()) { Alert(pContext, swMsg.c_str()); - pEvent->Rc() = FALSE; + pEvent->Rc() = false; } - return TRUE; + return true; } -FX_BOOL CJS_PublicMethods::AFExtractNums(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError) +bool CJS_PublicMethods::AFExtractNums(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError) { v8::Isolate* isolate = ::GetIsolate(cc); CJS_Context* pContext = (CJS_Context*)cc; @@ -2229,7 +2229,7 @@ FX_BOOL CJS_PublicMethods::AFExtractNums(IFXJS_Context* cc, const CJS_Parameters if (params.size() != 1) { sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); - return FALSE; + return false; } CJS_Array nums(isolate); @@ -2269,5 +2269,5 @@ FX_BOOL CJS_PublicMethods::AFExtractNums(IFXJS_Context* cc, const CJS_Parameters else vRet.SetNull(); - return TRUE; + return true; } |