diff options
author | Tom Sepez <tsepez@chromium.org> | 2015-04-27 11:31:26 -0700 |
---|---|---|
committer | Tom Sepez <tsepez@chromium.org> | 2015-04-27 11:31:26 -0700 |
commit | f7a7d7e07396c3a0fae617ed8f15f29fd491bc3a (patch) | |
tree | 53e22c58375eb36abe97f5b8f2631b4eba111fbc /fpdfsdk/src/javascript | |
parent | 15a62973b9b89c3e229cc0ab501c45967f91b325 (diff) | |
download | pdfium-f7a7d7e07396c3a0fae617ed8f15f29fd491bc3a.tar.xz |
Revert "Kill operator LPCWSTR from CFX_WideString()."
This reverts commit 15a62973b9b89c3e229cc0ab501c45967f91b325.
Reason for revert: broke build on windows, mac. I must have missed
some platform-specific conversions.
TBR=brucedawson@chromium.org
Review URL: https://codereview.chromium.org/1108883002
Diffstat (limited to 'fpdfsdk/src/javascript')
-rw-r--r-- | fpdfsdk/src/javascript/Document.cpp | 28 | ||||
-rw-r--r-- | fpdfsdk/src/javascript/Field.cpp | 28 | ||||
-rw-r--r-- | fpdfsdk/src/javascript/JS_Context.cpp | 4 | ||||
-rw-r--r-- | fpdfsdk/src/javascript/JS_GlobalData.cpp | 5 | ||||
-rw-r--r-- | fpdfsdk/src/javascript/JS_Value.cpp | 4 | ||||
-rw-r--r-- | fpdfsdk/src/javascript/PublicMethods.cpp | 98 | ||||
-rw-r--r-- | fpdfsdk/src/javascript/app.cpp | 22 | ||||
-rw-r--r-- | fpdfsdk/src/javascript/global.cpp | 24 | ||||
-rw-r--r-- | fpdfsdk/src/javascript/util.cpp | 16 |
9 files changed, 118 insertions, 111 deletions
diff --git a/fpdfsdk/src/javascript/Document.cpp b/fpdfsdk/src/javascript/Document.cpp index be568e10cc..624cad7eb2 100644 --- a/fpdfsdk/src/javascript/Document.cpp +++ b/fpdfsdk/src/javascript/Document.cpp @@ -370,7 +370,7 @@ FX_BOOL Document::getNthFieldName(IFXJS_Context* cc, const CJS_Parameters& param if (!pField) return FALSE; - vRet = pField->GetFullName().c_str(); + vRet = pField->GetFullName(); return TRUE; } @@ -878,15 +878,15 @@ FX_BOOL Document::info(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sEr JSFXObject pObj = JS_NewFxDynamicObj(*pRuntime, pContext, -1); - JS_PutObjectString(isolate, pObj, L"Author", cwAuthor.c_str()); - JS_PutObjectString(isolate, pObj, L"Title", cwTitle.c_str()); - JS_PutObjectString(isolate, pObj, L"Subject", cwSubject.c_str()); - JS_PutObjectString(isolate, pObj, L"Keywords", cwKeywords.c_str()); - JS_PutObjectString(isolate, pObj, L"Creator", cwCreator.c_str()); - JS_PutObjectString(isolate, pObj, L"Producer", cwProducer.c_str()); - JS_PutObjectString(isolate, pObj, L"CreationDate", cwCreationDate.c_str()); - JS_PutObjectString(isolate, pObj, L"ModDate", cwModDate.c_str()); - JS_PutObjectString(isolate, pObj, L"Trapped", cwTrapped.c_str()); + JS_PutObjectString(isolate,pObj, L"Author", cwAuthor); + JS_PutObjectString(isolate,pObj, L"Title", cwTitle); + JS_PutObjectString(isolate,pObj, L"Subject", cwSubject); + JS_PutObjectString(isolate,pObj, L"Keywords", cwKeywords); + JS_PutObjectString(isolate,pObj, L"Creator", cwCreator); + JS_PutObjectString(isolate,pObj, L"Producer", cwProducer); + JS_PutObjectString(isolate,pObj, L"CreationDate", cwCreationDate); + JS_PutObjectString(isolate,pObj, L"ModDate", cwModDate); + JS_PutObjectString(isolate,pObj, L"Trapped", cwTrapped); // It's to be compatible to non-standard info dictionary. FX_POSITION pos = pDictionary->GetStartPos(); @@ -896,11 +896,11 @@ FX_BOOL Document::info(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sEr CPDF_Object* pValueObj = pDictionary->GetNextElement(pos, bsKey); CFX_WideString wsKey = CFX_WideString::FromUTF8(bsKey, bsKey.GetLength()); if((pValueObj->GetType()==PDFOBJ_STRING) || (pValueObj->GetType()==PDFOBJ_NAME) ) - JS_PutObjectString(isolate, pObj, wsKey.c_str(), pValueObj->GetUnicodeText().c_str()); + JS_PutObjectString(isolate,pObj, wsKey, pValueObj->GetUnicodeText()); if(pValueObj->GetType()==PDFOBJ_NUMBER) - JS_PutObjectNumber(isolate,pObj, wsKey.c_str(), (float)pValueObj->GetNumber()); + JS_PutObjectNumber(isolate,pObj, wsKey, (float)pValueObj->GetNumber()); if(pValueObj->GetType()==PDFOBJ_BOOLEAN) - JS_PutObjectBoolean(isolate,pObj, wsKey.c_str(), (bool)pValueObj->GetInteger()); + JS_PutObjectBoolean(isolate,pObj, wsKey, (bool)pValueObj->GetInteger()); } vp << pObj; @@ -1672,7 +1672,7 @@ FX_BOOL Document::getPageNthWord(IFXJS_Context* cc, const CJS_Parameters& params swRet.TrimRight(); } - vRet = swRet.c_str(); + vRet = swRet; return TRUE; } diff --git a/fpdfsdk/src/javascript/Field.cpp b/fpdfsdk/src/javascript/Field.cpp index 7476fa5728..e5572da3e6 100644 --- a/fpdfsdk/src/javascript/Field.cpp +++ b/fpdfsdk/src/javascript/Field.cpp @@ -11,6 +11,7 @@ #include "../../include/javascript/JS_Value.h" #include "../../include/javascript/Field.h" #include "../../include/javascript/JS_EventHandler.h" +//#include "../include/JS_ResMgr.h" #include "../../include/javascript/JS_Context.h" #include "../../include/javascript/JS_Runtime.h" #include "../../include/javascript/Document.h" @@ -258,7 +259,7 @@ void Field::UpdateFormField(CPDFSDK_Document* pDocument, CPDF_FormField* pFormFi FX_BOOL bFormated = FALSE; CFX_WideString sValue = pWidget->OnFormat(0, bFormated); if (bFormated) - pWidget->ResetAppearance(sValue.c_str(), FALSE); + pWidget->ResetAppearance(sValue, FALSE); else pWidget->ResetAppearance(NULL, FALSE); } @@ -315,7 +316,7 @@ void Field::UpdateFormControl(CPDFSDK_Document* pDocument, CPDF_FormControl* pFo FX_BOOL bFormated = FALSE; CFX_WideString sValue = pWidget->OnFormat(0, bFormated); if (bFormated) - pWidget->ResetAppearance(sValue.c_str(), FALSE); + pWidget->ResetAppearance(sValue, FALSE); else pWidget->ResetAppearance(NULL, FALSE); } @@ -3126,7 +3127,7 @@ FX_BOOL Field::value(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sErro double dRet; FX_BOOL bDot; - if (CJS_PublicMethods::ConvertStringToNumber(swValue.c_str(), dRet, bDot)) + if (CJS_PublicMethods::ConvertStringToNumber(swValue,dRet,bDot)) { if (bDot) vp << dRet; @@ -3147,9 +3148,9 @@ FX_BOOL Field::value(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sErro for (int i = 0, sz = pFormField->CountSelectedItems(); i < sz; i++) { iIndex = pFormField->GetSelectedIndex(i); - ElementValue = pFormField->GetOptionValue(iIndex).c_str(); + ElementValue = pFormField->GetOptionValue(iIndex); if (FXSYS_wcslen(ElementValue.ToCFXWideString().c_str()) == 0) - ElementValue = pFormField->GetOptionLabel(iIndex).c_str(); + ElementValue = pFormField->GetOptionLabel(iIndex); ValueArray.SetElement(i, ElementValue); } vp << ValueArray; @@ -3160,7 +3161,7 @@ FX_BOOL Field::value(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sErro double dRet; FX_BOOL bDot; - if (CJS_PublicMethods::ConvertStringToNumber(swValue.c_str(), dRet, bDot)) + if (CJS_PublicMethods::ConvertStringToNumber(swValue,dRet,bDot)) { if (bDot) vp << dRet; @@ -3181,9 +3182,10 @@ FX_BOOL Field::value(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sErro if (pFormField->GetControl(i)->IsChecked()) { CFX_WideString swValue = pFormField->GetControl(i)->GetExportValue(); + double dRet; FX_BOOL bDot; - if (CJS_PublicMethods::ConvertStringToNumber(swValue.c_str(), dRet, bDot)) + if (CJS_PublicMethods::ConvertStringToNumber(swValue,dRet,bDot)) { if (bDot) vp << dRet; @@ -3389,11 +3391,11 @@ FX_BOOL Field::buttonGetCaption(IFXJS_Context* cc, const CJS_Parameters& params, if (!pFormControl)return FALSE; if (nface == 0) - vRet = pFormControl->GetNormalCaption().c_str(); + vRet = pFormControl->GetNormalCaption(); else if (nface == 1) - vRet = pFormControl->GetDownCaption().c_str(); + vRet = pFormControl->GetDownCaption(); else if (nface == 2) - vRet = pFormControl->GetRolloverCaption().c_str(); + vRet = pFormControl->GetRolloverCaption(); else return FALSE; @@ -3683,12 +3685,12 @@ FX_BOOL Field::getItemAt(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Va { CFX_WideString strval = pFormField->GetOptionValue(nIdx); if (strval.IsEmpty()) - vRet = pFormField->GetOptionLabel(nIdx).c_str(); + vRet = pFormField->GetOptionLabel(nIdx); else - vRet = strval.c_str(); + vRet = strval; } else - vRet = pFormField->GetOptionLabel(nIdx).c_str(); + vRet = pFormField->GetOptionLabel(nIdx); } else return FALSE; diff --git a/fpdfsdk/src/javascript/JS_Context.cpp b/fpdfsdk/src/javascript/JS_Context.cpp index 277abc08e5..bdcb1ac542 100644 --- a/fpdfsdk/src/javascript/JS_Context.cpp +++ b/fpdfsdk/src/javascript/JS_Context.cpp @@ -72,11 +72,11 @@ FX_BOOL CJS_Context::DoJob(int nMode, const CFX_WideString& script, CFX_WideStri { if (nMode == 0) { - nRet = JS_Execute(*m_pRuntime, this, script.c_str(), script.GetLength(), &error); + nRet = JS_Execute(*m_pRuntime, this, script, script.GetLength(), &error); } else { - nRet = JS_Parse(*m_pRuntime, this, script.c_str(), script.GetLength(), &error); + nRet = JS_Parse(*m_pRuntime, this, script, script.GetLength(), &error); } } diff --git a/fpdfsdk/src/javascript/JS_GlobalData.cpp b/fpdfsdk/src/javascript/JS_GlobalData.cpp index b4e4a5b108..83771dfe57 100644 --- a/fpdfsdk/src/javascript/JS_GlobalData.cpp +++ b/fpdfsdk/src/javascript/JS_GlobalData.cpp @@ -353,7 +353,8 @@ void CJS_GlobalData::LoadGlobalPersistentVariables() FX_LPBYTE pBuffer = NULL; FX_INT32 nLength = 0; - LoadFileBuffer(m_sFilePath.c_str(), pBuffer, nLength); + LoadFileBuffer(m_sFilePath, pBuffer, nLength); + CRYPT_ArcFourCryptBlock(pBuffer, nLength, JS_RC4KEY, sizeof(JS_RC4KEY)); if (pBuffer) @@ -508,7 +509,7 @@ void CJS_GlobalData::SaveGlobalPersisitentVariables() sFile.AppendBlock(sData.GetBuffer(), sData.GetSize()); CRYPT_ArcFourCryptBlock(sFile.GetBuffer(), sFile.GetSize(), JS_RC4KEY, sizeof(JS_RC4KEY)); - WriteFileBuffer(m_sFilePath.c_str(), (FX_LPCSTR)sFile.GetBuffer(), sFile.GetSize()); + WriteFileBuffer(m_sFilePath, (FX_LPCSTR)sFile.GetBuffer(), sFile.GetSize()); } void CJS_GlobalData::LoadFileBuffer(FX_LPCWSTR sFilePath, FX_LPBYTE& pBuffer, FX_INT32& nLength) diff --git a/fpdfsdk/src/javascript/JS_Value.cpp b/fpdfsdk/src/javascript/JS_Value.cpp index 1b36f314ca..be374895e4 100644 --- a/fpdfsdk/src/javascript/JS_Value.cpp +++ b/fpdfsdk/src/javascript/JS_Value.cpp @@ -216,7 +216,7 @@ void CJS_Value::SetNull() void CJS_Value::operator = (FX_LPCSTR pStr) { - operator = (CFX_WideString::FromLocal(pStr).c_str()); + operator = (CFX_WideString::FromLocal(pStr)); } void CJS_Value::operator = (CJS_Array & array) @@ -433,7 +433,7 @@ void CJS_PropValue::operator >>(CFX_WideString &wide_string) const void CJS_PropValue::operator <<(CFX_WideString wide_string) { ASSERT(!m_bIsSetting); - CJS_Value::operator = (wide_string.c_str()); + CJS_Value::operator = (wide_string); } void CJS_PropValue::operator >>(CJS_Array &array) const diff --git a/fpdfsdk/src/javascript/PublicMethods.cpp b/fpdfsdk/src/javascript/PublicMethods.cpp index 539d7c780a..6a9839ebf5 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.c_str(); + FX_LPCWSTR pTrim = sTrim; 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).c_str()); + return StrRTrim(StrLTrim(pStr)); } 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.c_str()); + return JS_DateParse(swTemp); } 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.c_str(), 0) != -1) + if (sFullMonths.Find(sMonth, 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.c_str()); + dRet = JS_DateParse(value); } } @@ -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().c_str()); + std::wstring wstrCurrency(params[4].ToCFXWideString()); FX_BOOL bCurrencyPrepend = params[5].ToBool(); if (iDec < 0) iDec = -iDec; @@ -1169,7 +1169,8 @@ 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.c_str(); + + std::wstring strValue2(Value); if (bCurrencyPrepend) strValue2 = wstrCurrency + strValue2; @@ -1280,24 +1281,25 @@ 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.c_str()); + CFX_WideString wstrValue = StrLTrim(w_strValue); if (wstrValue.IsEmpty()) return TRUE; CFX_WideString swTemp = wstrValue; swTemp.Replace(L",", L"."); - if (!IsNumber(swTemp.c_str())) + if (!IsNumber(swTemp)) //!(IsNumber(wstrChange) && { pEvent->Rc() = FALSE; sError = JSGetStringFromID(pContext, IDS_STRING_JSAFNUMBER_KEYSTROKE); - Alert(pContext, sError.c_str()); + Alert(pContext, sError); return TRUE; } return TRUE; // it happens after the last keystroke and before validating, } - - std::wstring w_strValue2 = w_strValue.c_str(); - std::wstring w_strChange2 = w_strChange.c_str(); + + std::wstring w_strValue2 (w_strValue); + std::wstring w_strChange2(w_strChange); + std::wstring w_strSelected; if(-1 != pEvent->SelStart()) w_strSelected = w_strValue2.substr(pEvent->SelStart(),(pEvent->SelEnd() - pEvent->SelStart())); @@ -1542,8 +1544,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).c_str(), sFormat.c_str()); - Alert(pContext, swMsg.c_str()); + swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSPARSEDATE), sFormat.c_str()); + Alert(pContext, swMsg); return FALSE; } @@ -1595,17 +1597,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].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()); + 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]); double dRet = JS_MakeDate(JS_MakeDay(nYear,nMonth - 1,nDay),JS_MakeTime(nHour, nMin, nSec, 0)); if (JS_PortIsNan(dRet)) { - dRet = JS_DateParse(strValue.c_str()); + dRet = JS_DateParse(strValue); } return dRet; @@ -1639,8 +1641,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).c_str(), sFormat.c_str()); - Alert(pContext, swMsg.c_str()); + swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSPARSEDATE), sFormat.c_str()); + Alert(pContext, swMsg); pEvent->Rc() = FALSE; return TRUE; } @@ -1849,7 +1851,7 @@ FX_BOOL CJS_PublicMethods::AFSpecial_KeystrokeEx(IFXJS_Context* cc, const CJS_Pa if (wstrMask.IsEmpty()) return TRUE; - std::wstring wstrValue = valEvent.c_str(); + std::wstring wstrValue(valEvent); if (pEvent->WillCommit()) { @@ -1866,14 +1868,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).c_str()); + Alert(pContext, JSGetStringFromID(pContext, IDS_STRING_JSAFNUMBER_KEYSTROKE)); pEvent->Rc() = FALSE; } return TRUE; } CFX_WideString &wideChange = pEvent->Change(); - std::wstring wChange = wideChange.c_str(); + std::wstring wChange(wideChange); if (wChange.empty()) return TRUE; @@ -1881,14 +1883,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).c_str()); + Alert(pContext, JSGetStringFromID(pContext, IDS_STRING_JSPARAM_TOOLONG)); pEvent->Rc() = FALSE; return TRUE; } if (iIndexMask >= wstrMask.GetLength() && (!wChange.empty())) { - Alert(pContext, JSGetStringFromID(pContext, IDS_STRING_JSPARAM_TOOLONG).c_str()); + Alert(pContext, JSGetStringFromID(pContext, IDS_STRING_JSPARAM_TOOLONG)); pEvent->Rc() = FALSE; return TRUE; } @@ -1897,7 +1899,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).c_str()); + Alert(pContext, JSGetStringFromID(pContext, IDS_STRING_JSPARAM_TOOLONG)); pEvent->Rc() = FALSE; return TRUE; } @@ -1944,8 +1946,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().c_str(); - + std::wstring wstrChange(pEvent->Change()); + switch (iIndex) { case 0: @@ -1999,7 +2001,7 @@ FX_BOOL CJS_PublicMethods::AFMergeChange(IFXJS_Context* cc, const CJS_Parameters if (pEventHandler->WillCommit()) { - vRet = swValue.c_str(); + vRet = swValue; return TRUE; } @@ -2015,7 +2017,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).c_str(); + vRet = prefix + pEventHandler->Change() + postfix; return TRUE; } @@ -2040,8 +2042,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).c_str(), sFormat.c_str()); - Alert((CJS_Context *)cc, swMsg.c_str()); + swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSPARSEDATE), sFormat.c_str()); + Alert((CJS_Context *)cc, swMsg); return FALSE; } @@ -2060,7 +2062,7 @@ FX_BOOL CJS_PublicMethods::AFSimple(IFXJS_Context* cc, const CJS_Parameters& par return FALSE; } - vRet = (double)AF_Simple(params[0].ToCFXWideString().c_str(), params[1].ToDouble(), params[2].ToDouble()); + vRet = (double)AF_Simple(params[0].ToCFXWideString(), params[1].ToDouble(), params[2].ToDouble()); return TRUE; } @@ -2074,7 +2076,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().c_str()); + vRet = ParseStringToNumber(params[0].ToCFXWideString()); return TRUE; } @@ -2110,7 +2112,7 @@ FX_BOOL CJS_PublicMethods::AFSimple_Calculate(IFXJS_Context* cc, const CJS_Param double dValue; CFX_WideString sFunction = params[0].ToCFXWideString(); - if (wcscmp(sFunction.c_str(), L"PRD") == 0) + if (wcscmp(sFunction, L"PRD") == 0) dValue = 1.0; else dValue = 0.0; @@ -2136,7 +2138,7 @@ FX_BOOL CJS_PublicMethods::AFSimple_Calculate(IFXJS_Context* cc, const CJS_Param case FIELDTYPE_TEXTFIELD: case FIELDTYPE_COMBOBOX: { - dTemp = ParseStringToNumber(pFormField->GetValue().c_str()); + dTemp = ParseStringToNumber(pFormField->GetValue()); break; } case FIELDTYPE_PUSHBUTTON: @@ -2154,7 +2156,7 @@ FX_BOOL CJS_PublicMethods::AFSimple_Calculate(IFXJS_Context* cc, const CJS_Param { if (pFormCtrl->IsChecked()) { - dTemp += ParseStringToNumber(pFormCtrl->GetExportValue().c_str()); + dTemp += ParseStringToNumber(pFormCtrl->GetExportValue()); break; } else @@ -2170,7 +2172,7 @@ FX_BOOL CJS_PublicMethods::AFSimple_Calculate(IFXJS_Context* cc, const CJS_Param break; else { - dTemp = ParseStringToNumber(pFormField->GetValue().c_str()); + dTemp = ParseStringToNumber(pFormField->GetValue()); break; } } @@ -2178,17 +2180,17 @@ FX_BOOL CJS_PublicMethods::AFSimple_Calculate(IFXJS_Context* cc, const CJS_Param break; } - if (i == 0 && j == 0 && (wcscmp(sFunction.c_str(), L"MIN") == 0 || wcscmp(sFunction.c_str(), L"MAX") == 0)) + if (i == 0 && j == 0 && (wcscmp(sFunction,L"MIN") == 0 || wcscmp(sFunction, L"MAX") == 0)) dValue = dTemp; - dValue = AF_Simple(sFunction.c_str(), dValue, dTemp); + dValue = AF_Simple(sFunction, dValue, dTemp); nFieldsCount++; } } } - if (wcscmp(sFunction.c_str(), L"AVG") == 0 && nFieldsCount > 0) + if (wcscmp(sFunction, 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); @@ -2229,26 +2231,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).c_str(), + swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSRANGE1), params[1].ToCFXWideString().c_str(), params[3].ToCFXWideString().c_str()); } else if (bGreaterThan) { if (dEentValue < dGreaterThan) - swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSRANGE2).c_str(), + swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSRANGE2), params[1].ToCFXWideString().c_str()); } else if (bLessThan) { if (dEentValue > dLessThan) - swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSRANGE3).c_str(), + swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSRANGE3), params[3].ToCFXWideString().c_str()); } if (!swMsg.IsEmpty()) { - Alert(pContext, swMsg.c_str()); + Alert(pContext, swMsg); pEvent->Rc() = FALSE; } return TRUE; diff --git a/fpdfsdk/src/javascript/app.cpp b/fpdfsdk/src/javascript/app.cpp index 552d26854d..2cb7f67f27 100644 --- a/fpdfsdk/src/javascript/app.cpp +++ b/fpdfsdk/src/javascript/app.cpp @@ -416,7 +416,7 @@ FX_BOOL app::alert(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& v CJS_Runtime* pRuntime = pContext->GetJSRuntime(); ASSERT(pRuntime != NULL); pRuntime->BeginBlock(); - vRet = MsgBox(pRuntime->GetReaderApp(), JSGetPageView(cc), swMsg.c_str(), swTitle.c_str(), iType, iIcon); + vRet = MsgBox(pRuntime->GetReaderApp(), JSGetPageView(cc),swMsg,swTitle,iType,iIcon); pRuntime->EndBlock(); return TRUE; @@ -455,21 +455,24 @@ FX_BOOL app::fs(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) FX_BOOL app::setInterval(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError) { - CJS_Context* pContext = (CJS_Context*)cc; if (params.size() > 2 || params.size() == 0) { - sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); + sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSPARAMERROR); return FALSE; } - CFX_WideString script = params.size() > 0 ? params[0].ToCFXWideString() : L""; + CJS_Context* pContext = (CJS_Context*)cc; + ASSERT(pContext != NULL); + CJS_Runtime* pRuntime = pContext->GetJSRuntime(); + ASSERT(pRuntime != NULL); + + CFX_WideString script = params.size() > 0 ? (FX_LPCWSTR)(params[0].ToCFXWideString()) : L""; if (script.IsEmpty()) { - sError = JSGetStringFromID(pContext, IDS_STRING_JSAFNUMBER_KEYSTROKE); + sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSAFNUMBER_KEYSTROKE); return TRUE; } - CJS_Runtime* pRuntime = pContext->GetJSRuntime(); FX_DWORD dwInterval = params.size() > 1 ? params[1].ToInt() : 1000; CPDFDoc_Environment* pApp = pRuntime->GetReaderApp(); @@ -512,7 +515,7 @@ FX_BOOL app::setTimeOut(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Val CJS_Runtime* pRuntime = pContext->GetJSRuntime(); ASSERT(pRuntime != NULL); - CFX_WideString script = params.size() > 0 ? params[0].ToCFXWideString() : L""; + CFX_WideString script = params.size() > 0 ? (FX_LPCWSTR)(params[0].ToCFXWideString()) : L""; if (script.IsEmpty()) { sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSAFNUMBER_KEYSTROKE); @@ -900,8 +903,7 @@ FX_BOOL app::response(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value return FALSE; memset(pBuff, 0, MAX_INPUT_BYTES + 2); - int nLengthBytes = pApp->JS_appResponse(swQuestion.c_str(), swTitle.c_str(), swDefault.c_str(), - swLabel.c_str(), bPassWord, pBuff, MAX_INPUT_BYTES); + int nLengthBytes = pApp->JS_appResponse(swQuestion, swTitle, swDefault, swLabel, bPassWord, pBuff, MAX_INPUT_BYTES); if (nLengthBytes <= 0) { vRet.SetNull(); @@ -911,7 +913,7 @@ FX_BOOL app::response(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value if (nLengthBytes > MAX_INPUT_BYTES) nLengthBytes = MAX_INPUT_BYTES; - vRet = CFX_WideString::FromUTF16LE((unsigned short*)pBuff, nLengthBytes / sizeof(unsigned short)).c_str(); + vRet = CFX_WideString::FromUTF16LE((unsigned short*)pBuff, nLengthBytes / sizeof(unsigned short)); delete[] pBuff; return TRUE; } diff --git a/fpdfsdk/src/javascript/global.cpp b/fpdfsdk/src/javascript/global.cpp index 418508f89e..c3d11b0a84 100644 --- a/fpdfsdk/src/javascript/global.cpp +++ b/fpdfsdk/src/javascript/global.cpp @@ -297,18 +297,18 @@ void global_alternate::UpdateGlobalPersistentVariables() case JS_GLOBALDATA_TYPE_NUMBER: this->SetGlobalVariables(pData->data.sKey, JS_GLOBALDATA_TYPE_NUMBER, pData->data.dData, false, "", v8::Handle<v8::Object>(), pData->bPersistent == 1); JS_PutObjectNumber(NULL,(JSFXObject)(*m_pJSObject), - pData->data.sKey.UTF8Decode().c_str(), pData->data.dData); + pData->data.sKey.UTF8Decode(), pData->data.dData); break; case JS_GLOBALDATA_TYPE_BOOLEAN: this->SetGlobalVariables(pData->data.sKey, JS_GLOBALDATA_TYPE_BOOLEAN, 0, (bool)(pData->data.bData == 1), "", v8::Handle<v8::Object>(), pData->bPersistent == 1); JS_PutObjectBoolean(NULL,(JSFXObject)(*m_pJSObject), - pData->data.sKey.UTF8Decode().c_str(), (bool)(pData->data.bData == 1)); + pData->data.sKey.UTF8Decode(), (bool)(pData->data.bData == 1)); break; case JS_GLOBALDATA_TYPE_STRING: this->SetGlobalVariables(pData->data.sKey, JS_GLOBALDATA_TYPE_STRING, 0, false, pData->data.sData, v8::Handle<v8::Object>(), pData->bPersistent == 1); - JS_PutObjectString(NULL, (JSFXObject)(*m_pJSObject), - pData->data.sKey.UTF8Decode().c_str(), - pData->data.sData.UTF8Decode().c_str()); + JS_PutObjectString(NULL,(JSFXObject)(*m_pJSObject), + pData->data.sKey.UTF8Decode(), + pData->data.sData.UTF8Decode()); break; case JS_GLOBALDATA_TYPE_OBJECT: { @@ -320,13 +320,13 @@ void global_alternate::UpdateGlobalPersistentVariables() this->SetGlobalVariables(pData->data.sKey, JS_GLOBALDATA_TYPE_OBJECT, 0, false, "", (JSObject)pObj, pData->bPersistent == 1); JS_PutObjectObject(NULL,(JSFXObject)(*m_pJSObject), - pData->data.sKey.UTF8Decode().c_str(), (JSObject)pObj); + pData->data.sKey.UTF8Decode(), (JSObject)pObj); } break; case JS_GLOBALDATA_TYPE_NULL: this->SetGlobalVariables(pData->data.sKey, JS_GLOBALDATA_TYPE_NULL, 0, false, "", v8::Handle<v8::Object>(), pData->bPersistent == 1); JS_PutObjectNull(NULL,(JSFXObject)(*m_pJSObject), - pData->data.sKey.UTF8Decode().c_str()); + pData->data.sKey.UTF8Decode()); break; } } @@ -466,24 +466,24 @@ void global_alternate::PutObjectProperty(v8::Handle<v8::Object> pObj, CJS_KeyVal switch (pObjData->nType) { case JS_GLOBALDATA_TYPE_NUMBER: - JS_PutObjectNumber(NULL,(JSObject)pObj, pObjData->sKey.UTF8Decode().c_str(), pObjData->dData); + JS_PutObjectNumber(NULL,(JSObject)pObj, pObjData->sKey.UTF8Decode(), pObjData->dData); break; case JS_GLOBALDATA_TYPE_BOOLEAN: - JS_PutObjectBoolean(NULL,(JSObject)pObj, pObjData->sKey.UTF8Decode().c_str(), (bool)(pObjData->bData == 1)); + JS_PutObjectBoolean(NULL,(JSObject)pObj, pObjData->sKey.UTF8Decode(), (bool)(pObjData->bData == 1)); break; case JS_GLOBALDATA_TYPE_STRING: - JS_PutObjectString(NULL,(JSObject)pObj, pObjData->sKey.UTF8Decode().c_str(), pObjData->sData.UTF8Decode().c_str()); + JS_PutObjectString(NULL,(JSObject)pObj, pObjData->sKey.UTF8Decode(), pObjData->sData.UTF8Decode()); break; case JS_GLOBALDATA_TYPE_OBJECT: { IJS_Runtime* pRuntime = JS_GetRuntime((JSFXObject)(*m_pJSObject)); v8::Handle<v8::Object> pNewObj = JS_NewFxDynamicObj(pRuntime, NULL, -1); PutObjectProperty(pNewObj, pObjData); - JS_PutObjectObject(NULL, (JSObject)pObj, pObjData->sKey.UTF8Decode().c_str(), (JSObject)pNewObj); + JS_PutObjectObject(NULL, (JSObject)pObj, pObjData->sKey.UTF8Decode(), (JSObject)pNewObj); } break; case JS_GLOBALDATA_TYPE_NULL: - JS_PutObjectNull(NULL,(JSObject)pObj, pObjData->sKey.UTF8Decode().c_str()); + JS_PutObjectNull(NULL,(JSObject)pObj, pObjData->sKey.UTF8Decode()); break; } } diff --git a/fpdfsdk/src/javascript/util.cpp b/fpdfsdk/src/javascript/util.cpp index 26c59a32ad..f7e97acb1f 100644 --- a/fpdfsdk/src/javascript/util.cpp +++ b/fpdfsdk/src/javascript/util.cpp @@ -265,7 +265,7 @@ FX_BOOL util::printd(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& return FALSE; } - vRet = swResult.c_str(); + vRet = swResult; return TRUE; } else if (p1.GetType() == VT_string) @@ -288,9 +288,9 @@ FX_BOOL util::printd(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& { int iStart = 0; int iEnd; - while((iEnd = cFormat.find(fcTable[iIndex].lpszJSMark, iStart)) != -1) + while((iEnd = cFormat.find((CFX_WideString)fcTable[iIndex].lpszJSMark, iStart)) != -1) { - cFormat.replace(iEnd, FXSYS_wcslen(fcTable[iIndex].lpszJSMark), fcTable[iIndex].lpszCppMark); + cFormat.replace(iEnd, FXSYS_wcslen(fcTable[iIndex].lpszJSMark), (CFX_WideString)fcTable[iIndex].lpszCppMark); iStart = iEnd; } } @@ -342,7 +342,7 @@ FX_BOOL util::printd(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& //strFormat.Format(strFormat,cTableAd[iIndex].iValue); int iStart = 0; int iEnd; - while((iEnd = cFormat.find(cTableAd[iIndex].lpszJSMark, iStart)) != -1) + while((iEnd = cFormat.find((CFX_WideString)cTableAd[iIndex].lpszJSMark,iStart)) != -1) { if (iEnd > 0) { @@ -384,9 +384,9 @@ void util::printd(const std::wstring &cFormat2, CJS_Date jsDate, bool bXFAPictur { int iStart = 0; int iEnd; - while((iEnd = cFormat.find(fcTable[iIndex].lpszJSMark, iStart)) != -1) + while((iEnd = cFormat.find((CFX_WideString)fcTable[iIndex].lpszJSMark,iStart)) != -1) { - cFormat.replace(iEnd,FXSYS_wcslen(fcTable[iIndex].lpszJSMark), fcTable[iIndex].lpszCppMark); + cFormat.replace(iEnd,FXSYS_wcslen(fcTable[iIndex].lpszJSMark), (CFX_WideString)fcTable[iIndex].lpszCppMark); iStart = iEnd; } } @@ -438,7 +438,7 @@ void util::printd(const std::wstring &cFormat2, CJS_Date jsDate, bool bXFAPictur //strFormat.Format(strFormat,cTableAd[iIndex].iValue); int iStart = 0; int iEnd; - while((iEnd = cFormat.find(cTableAd[iIndex].lpszJSMark, iStart)) != -1) + while((iEnd = cFormat.find((CFX_WideString)cTableAd[iIndex].lpszJSMark,iStart)) != -1) { if (iEnd > 0) { @@ -640,6 +640,6 @@ FX_BOOL util::byteToChar(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Va unsigned char cByte = (unsigned char)nByte; CFX_WideString csValue; csValue.Format(L"%c", cByte); - vRet = csValue.c_str(); + vRet = csValue; return TRUE; } |