summaryrefslogtreecommitdiff
path: root/fpdfsdk/src/javascript/PublicMethods.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'fpdfsdk/src/javascript/PublicMethods.cpp')
-rw-r--r--fpdfsdk/src/javascript/PublicMethods.cpp98
1 files changed, 48 insertions, 50 deletions
diff --git a/fpdfsdk/src/javascript/PublicMethods.cpp b/fpdfsdk/src/javascript/PublicMethods.cpp
index 6a9839ebf5..539d7c780a 100644
--- a/fpdfsdk/src/javascript/PublicMethods.cpp
+++ b/fpdfsdk/src/javascript/PublicMethods.cpp
@@ -104,7 +104,7 @@ static FX_LPCWSTR fullmonths[] =
FX_BOOL CJS_PublicMethods::IsNumber(FX_LPCWSTR string)
{
CFX_WideString sTrim = StrTrim(string);
- FX_LPCWSTR pTrim = sTrim;
+ FX_LPCWSTR pTrim = sTrim.c_str();
FX_LPCWSTR p = pTrim;
@@ -231,7 +231,7 @@ CFX_WideString CJS_PublicMethods::StrRTrim(FX_LPCWSTR pStr)
CFX_WideString CJS_PublicMethods::StrTrim(FX_LPCWSTR pStr)
{
- return StrRTrim(StrLTrim(pStr));
+ return StrRTrim(StrLTrim(pStr).c_str());
}
CFX_ByteString CJS_PublicMethods::StrLTrim(FX_LPCSTR pStr)
@@ -591,7 +591,7 @@ double CJS_PublicMethods::ParseNormalDate(const CFX_WideString & value, FX_BOOL&
CFX_WideString swTemp;
swTemp.Format(L"%d/%d/%d %d:%d:%d",nMonth,nDay,nYear,nHour,nMin,nSec);
- return JS_DateParse(swTemp);
+ return JS_DateParse(swTemp.c_str());
}
double CJS_PublicMethods::MakeRegularDate(const CFX_WideString & value, const CFX_WideString & format, FX_BOOL& bWrongFormat)
@@ -796,7 +796,7 @@ double CJS_PublicMethods::MakeRegularDate(const CFX_WideString & value, const CF
CFX_WideString sFullMonths = fullmonths[m];
sFullMonths.MakeLower();
- if (sFullMonths.Find(sMonth, 0) != -1)
+ if (sFullMonths.Find(sMonth.c_str(), 0) != -1)
{
nMonth = m + 1;
i += 4;
@@ -888,7 +888,7 @@ double CJS_PublicMethods::MakeRegularDate(const CFX_WideString & value, const CF
if (JS_PortIsNan(dRet))
{
- dRet = JS_DateParse(value);
+ dRet = JS_DateParse(value.c_str());
}
}
@@ -1075,7 +1075,7 @@ FX_BOOL CJS_PublicMethods::AFNumber_Format(IFXJS_Context* cc, const CJS_Paramete
int iSepStyle = params[1].ToInt();
int iNegStyle = params[2].ToInt();
// params[3] is iCurrStyle, it's not used.
- std::wstring wstrCurrency(params[4].ToCFXWideString());
+ std::wstring wstrCurrency(params[4].ToCFXWideString().c_str());
FX_BOOL bCurrencyPrepend = params[5].ToBool();
if (iDec < 0) iDec = -iDec;
@@ -1169,8 +1169,7 @@ FX_BOOL CJS_PublicMethods::AFNumber_Format(IFXJS_Context* cc, const CJS_Paramete
//for processing currency string
Value = CFX_WideString::FromLocal(strValue);
-
- std::wstring strValue2(Value);
+ std::wstring strValue2 = Value.c_str();
if (bCurrencyPrepend)
strValue2 = wstrCurrency + strValue2;
@@ -1281,25 +1280,24 @@ FX_BOOL CJS_PublicMethods::AFNumber_Keystroke(IFXJS_Context* cc, const CJS_Param
if (pEvent->WillCommit())
{
CFX_WideString wstrChange = w_strChange;
- CFX_WideString wstrValue = StrLTrim(w_strValue);
+ CFX_WideString wstrValue = StrLTrim(w_strValue.c_str());
if (wstrValue.IsEmpty())
return TRUE;
CFX_WideString swTemp = wstrValue;
swTemp.Replace(L",", L".");
- if (!IsNumber(swTemp)) //!(IsNumber(wstrChange) &&
+ if (!IsNumber(swTemp.c_str()))
{
pEvent->Rc() = FALSE;
sError = JSGetStringFromID(pContext, IDS_STRING_JSAFNUMBER_KEYSTROKE);
- Alert(pContext, sError);
+ Alert(pContext, sError.c_str());
return TRUE;
}
return TRUE; // it happens after the last keystroke and before validating,
}
-
- std::wstring w_strValue2 (w_strValue);
- std::wstring w_strChange2(w_strChange);
-
+
+ std::wstring w_strValue2 = w_strValue.c_str();
+ std::wstring w_strChange2 = w_strChange.c_str();
std::wstring w_strSelected;
if(-1 != pEvent->SelStart())
w_strSelected = w_strValue2.substr(pEvent->SelStart(),(pEvent->SelEnd() - pEvent->SelStart()));
@@ -1544,8 +1542,8 @@ FX_BOOL CJS_PublicMethods::AFDate_FormatEx(IFXJS_Context* cc, const CJS_Paramete
if (JS_PortIsNan(dDate))
{
CFX_WideString swMsg;
- swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSPARSEDATE), sFormat.c_str());
- Alert(pContext, swMsg);
+ swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSPARSEDATE).c_str(), sFormat.c_str());
+ Alert(pContext, swMsg.c_str());
return FALSE;
}
@@ -1597,17 +1595,17 @@ double CJS_PublicMethods::MakeInterDate(CFX_WideString strValue)
if(sTemp.Compare(L"Nov") == 0) nMonth = 11;
if(sTemp.Compare(L"Dec") == 0) nMonth = 12;
- nDay = (int)ParseStringToNumber(wsArray[2]);
- nHour = (int)ParseStringToNumber(wsArray[3]);
- nMin = (int)ParseStringToNumber(wsArray[4]);
- nSec = (int)ParseStringToNumber(wsArray[5]);
- nYear = (int)ParseStringToNumber(wsArray[7]);
+ nDay = (int)ParseStringToNumber(wsArray[2].c_str());
+ nHour = (int)ParseStringToNumber(wsArray[3].c_str());
+ nMin = (int)ParseStringToNumber(wsArray[4].c_str());
+ nSec = (int)ParseStringToNumber(wsArray[5].c_str());
+ nYear = (int)ParseStringToNumber(wsArray[7].c_str());
double dRet = JS_MakeDate(JS_MakeDay(nYear,nMonth - 1,nDay),JS_MakeTime(nHour, nMin, nSec, 0));
if (JS_PortIsNan(dRet))
{
- dRet = JS_DateParse(strValue);
+ dRet = JS_DateParse(strValue.c_str());
}
return dRet;
@@ -1641,8 +1639,8 @@ FX_BOOL CJS_PublicMethods::AFDate_KeystrokeEx(IFXJS_Context* cc, const CJS_Param
if (bWrongFormat || JS_PortIsNan(dRet))
{
CFX_WideString swMsg;
- swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSPARSEDATE), sFormat.c_str());
- Alert(pContext, swMsg);
+ swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSPARSEDATE).c_str(), sFormat.c_str());
+ Alert(pContext, swMsg.c_str());
pEvent->Rc() = FALSE;
return TRUE;
}
@@ -1851,7 +1849,7 @@ FX_BOOL CJS_PublicMethods::AFSpecial_KeystrokeEx(IFXJS_Context* cc, const CJS_Pa
if (wstrMask.IsEmpty())
return TRUE;
- std::wstring wstrValue(valEvent);
+ std::wstring wstrValue = valEvent.c_str();
if (pEvent->WillCommit())
{
@@ -1868,14 +1866,14 @@ 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));
+ Alert(pContext, JSGetStringFromID(pContext, IDS_STRING_JSAFNUMBER_KEYSTROKE).c_str());
pEvent->Rc() = FALSE;
}
return TRUE;
}
CFX_WideString &wideChange = pEvent->Change();
- std::wstring wChange(wideChange);
+ std::wstring wChange = wideChange.c_str();
if (wChange.empty())
return TRUE;
@@ -1883,14 +1881,14 @@ FX_BOOL CJS_PublicMethods::AFSpecial_KeystrokeEx(IFXJS_Context* cc, const CJS_Pa
if (wstrValue.length() - (pEvent->SelEnd()-pEvent->SelStart()) + wChange.length() > (FX_DWORD)wstrMask.GetLength())
{
- Alert(pContext, JSGetStringFromID(pContext, IDS_STRING_JSPARAM_TOOLONG));
+ Alert(pContext, JSGetStringFromID(pContext, IDS_STRING_JSPARAM_TOOLONG).c_str());
pEvent->Rc() = FALSE;
return TRUE;
}
if (iIndexMask >= wstrMask.GetLength() && (!wChange.empty()))
{
- Alert(pContext, JSGetStringFromID(pContext, IDS_STRING_JSPARAM_TOOLONG));
+ Alert(pContext, JSGetStringFromID(pContext, IDS_STRING_JSPARAM_TOOLONG).c_str());
pEvent->Rc() = FALSE;
return TRUE;
}
@@ -1899,7 +1897,7 @@ FX_BOOL CJS_PublicMethods::AFSpecial_KeystrokeEx(IFXJS_Context* cc, const CJS_Pa
{
if (iIndexMask >= wstrMask.GetLength())
{
- Alert(pContext, JSGetStringFromID(pContext, IDS_STRING_JSPARAM_TOOLONG));
+ Alert(pContext, JSGetStringFromID(pContext, IDS_STRING_JSPARAM_TOOLONG).c_str());
pEvent->Rc() = FALSE;
return TRUE;
}
@@ -1946,8 +1944,8 @@ FX_BOOL CJS_PublicMethods::AFSpecial_Keystroke(IFXJS_Context* cc, const CJS_Para
//CJS_Value val = pEvent->Value();
CFX_WideString& val = pEvent->Value();
std::string strSrc = CFX_ByteString::FromUnicode(val).c_str();
- std::wstring wstrChange(pEvent->Change());
-
+ std::wstring wstrChange = pEvent->Change().c_str();
+
switch (iIndex)
{
case 0:
@@ -2001,7 +1999,7 @@ FX_BOOL CJS_PublicMethods::AFMergeChange(IFXJS_Context* cc, const CJS_Parameters
if (pEventHandler->WillCommit())
{
- vRet = swValue;
+ vRet = swValue.c_str();
return TRUE;
}
@@ -2017,7 +2015,7 @@ FX_BOOL CJS_PublicMethods::AFMergeChange(IFXJS_Context* cc, const CJS_Parameters
postfix = swValue.Mid(pEventHandler->SelEnd(), swValue.GetLength() - pEventHandler->SelEnd());
else postfix = L"";
- vRet = prefix + pEventHandler->Change() + postfix;
+ vRet = (prefix + pEventHandler->Change() + postfix).c_str();
return TRUE;
}
@@ -2042,8 +2040,8 @@ FX_BOOL CJS_PublicMethods::AFParseDateEx(IFXJS_Context* cc, const CJS_Parameters
if (JS_PortIsNan(dDate))
{
CFX_WideString swMsg;
- swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSPARSEDATE), sFormat.c_str());
- Alert((CJS_Context *)cc, swMsg);
+ swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSPARSEDATE).c_str(), sFormat.c_str());
+ Alert((CJS_Context *)cc, swMsg.c_str());
return FALSE;
}
@@ -2062,7 +2060,7 @@ FX_BOOL CJS_PublicMethods::AFSimple(IFXJS_Context* cc, const CJS_Parameters& par
return FALSE;
}
- vRet = (double)AF_Simple(params[0].ToCFXWideString(), params[1].ToDouble(), params[2].ToDouble());
+ vRet = (double)AF_Simple(params[0].ToCFXWideString().c_str(), params[1].ToDouble(), params[2].ToDouble());
return TRUE;
}
@@ -2076,7 +2074,7 @@ FX_BOOL CJS_PublicMethods::AFMakeNumber(IFXJS_Context* cc, const CJS_Parameters&
sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
return FALSE;
}
- vRet = ParseStringToNumber(params[0].ToCFXWideString());
+ vRet = ParseStringToNumber(params[0].ToCFXWideString().c_str());
return TRUE;
}
@@ -2112,7 +2110,7 @@ FX_BOOL CJS_PublicMethods::AFSimple_Calculate(IFXJS_Context* cc, const CJS_Param
double dValue;
CFX_WideString sFunction = params[0].ToCFXWideString();
- if (wcscmp(sFunction, L"PRD") == 0)
+ if (wcscmp(sFunction.c_str(), L"PRD") == 0)
dValue = 1.0;
else
dValue = 0.0;
@@ -2138,7 +2136,7 @@ FX_BOOL CJS_PublicMethods::AFSimple_Calculate(IFXJS_Context* cc, const CJS_Param
case FIELDTYPE_TEXTFIELD:
case FIELDTYPE_COMBOBOX:
{
- dTemp = ParseStringToNumber(pFormField->GetValue());
+ dTemp = ParseStringToNumber(pFormField->GetValue().c_str());
break;
}
case FIELDTYPE_PUSHBUTTON:
@@ -2156,7 +2154,7 @@ FX_BOOL CJS_PublicMethods::AFSimple_Calculate(IFXJS_Context* cc, const CJS_Param
{
if (pFormCtrl->IsChecked())
{
- dTemp += ParseStringToNumber(pFormCtrl->GetExportValue());
+ dTemp += ParseStringToNumber(pFormCtrl->GetExportValue().c_str());
break;
}
else
@@ -2172,7 +2170,7 @@ FX_BOOL CJS_PublicMethods::AFSimple_Calculate(IFXJS_Context* cc, const CJS_Param
break;
else
{
- dTemp = ParseStringToNumber(pFormField->GetValue());
+ dTemp = ParseStringToNumber(pFormField->GetValue().c_str());
break;
}
}
@@ -2180,17 +2178,17 @@ FX_BOOL CJS_PublicMethods::AFSimple_Calculate(IFXJS_Context* cc, const CJS_Param
break;
}
- if (i == 0 && j == 0 && (wcscmp(sFunction,L"MIN") == 0 || wcscmp(sFunction, L"MAX") == 0))
+ if (i == 0 && j == 0 && (wcscmp(sFunction.c_str(), L"MIN") == 0 || wcscmp(sFunction.c_str(), L"MAX") == 0))
dValue = dTemp;
- dValue = AF_Simple(sFunction, dValue, dTemp);
+ dValue = AF_Simple(sFunction.c_str(), dValue, dTemp);
nFieldsCount++;
}
}
}
- if (wcscmp(sFunction, L"AVG") == 0 && nFieldsCount > 0)
+ if (wcscmp(sFunction.c_str(), L"AVG") == 0 && nFieldsCount > 0)
dValue /= nFieldsCount;
dValue = (double)floor(dValue * FXSYS_pow((double)10,(double)6) + 0.49) / FXSYS_pow((double)10,(double)6);
@@ -2231,26 +2229,26 @@ FX_BOOL CJS_PublicMethods::AFRange_Validate(IFXJS_Context* cc, const CJS_Paramet
if (bGreaterThan && bLessThan)
{
if (dEentValue < dGreaterThan || dEentValue > dLessThan)
- swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSRANGE1),
+ swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSRANGE1).c_str(),
params[1].ToCFXWideString().c_str(),
params[3].ToCFXWideString().c_str());
}
else if (bGreaterThan)
{
if (dEentValue < dGreaterThan)
- swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSRANGE2),
+ swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSRANGE2).c_str(),
params[1].ToCFXWideString().c_str());
}
else if (bLessThan)
{
if (dEentValue > dLessThan)
- swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSRANGE3),
+ swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSRANGE3).c_str(),
params[3].ToCFXWideString().c_str());
}
if (!swMsg.IsEmpty())
{
- Alert(pContext, swMsg);
+ Alert(pContext, swMsg.c_str());
pEvent->Rc() = FALSE;
}
return TRUE;