summaryrefslogtreecommitdiff
path: root/fpdfsdk
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2015-04-23 11:23:10 -0700
committerTom Sepez <tsepez@chromium.org>2015-04-23 11:23:10 -0700
commite4fde52cc2c827e637c96e8e1f76ba4644cf718a (patch)
tree01208f95d013429d2682a228577880a64ae1845b /fpdfsdk
parent4eeef1d776ce7368063f9a7698cfa736821d4186 (diff)
downloadpdfium-e4fde52cc2c827e637c96e8e1f76ba4644cf718a.tar.xz
Kill overloaded cast operators in CJS_Value.
The red-flag here is the explicit invocation of things like params[1].operator CFX_WideString() rather than static_cast<CFX_WideString>(params[1]) to invoke the conversion. Turns out the above won't compile due to ambiguity given the number of implicit constructors for widestrings. CJS_Value has both constructors and assignment operators for the primitive types, which means that conversions can take place unexpectedly in both directions, a second red flag. We don't want the compiler invoking these at will since it may hide bugs. In fact, when they are removed, three such places were discovered. Also rename ToJSValue to ToV8Value to match the other ToV8xxxxx functions added. R=thestig@chromium.org Review URL: https://codereview.chromium.org/1096813008
Diffstat (limited to 'fpdfsdk')
-rw-r--r--fpdfsdk/include/javascript/JS_Define.h6
-rw-r--r--fpdfsdk/include/javascript/JS_Value.h20
-rw-r--r--fpdfsdk/src/javascript/Document.cpp139
-rw-r--r--fpdfsdk/src/javascript/Field.cpp71
-rw-r--r--fpdfsdk/src/javascript/JS_Value.cpp57
-rw-r--r--fpdfsdk/src/javascript/PublicMethods.cpp148
-rw-r--r--fpdfsdk/src/javascript/app.cpp159
-rw-r--r--fpdfsdk/src/javascript/color.cpp16
-rw-r--r--fpdfsdk/src/javascript/event.cpp2
-rw-r--r--fpdfsdk/src/javascript/global.cpp23
-rw-r--r--fpdfsdk/src/javascript/util.cpp26
11 files changed, 305 insertions, 362 deletions
diff --git a/fpdfsdk/include/javascript/JS_Define.h b/fpdfsdk/include/javascript/JS_Define.h
index 67f283b40e..2a033d15c5 100644
--- a/fpdfsdk/include/javascript/JS_Define.h
+++ b/fpdfsdk/include/javascript/JS_Define.h
@@ -137,7 +137,7 @@ void JSMethod(const char* method_name_string,
JS_Error(isolate, JSFormatErrorString(class_name_string, method_name_string, sError));
return;
}
- info.GetReturnValue().Set(valueRes.ToJSValue());
+ info.GetReturnValue().Set(valueRes.ToV8Value());
}
#define JS_STATIC_METHOD(method_name, class_name) \
@@ -404,7 +404,7 @@ void JSGlobalFunc(const char *func_name_string,
JS_Error(isolate, JSFormatErrorString(func_name_string, nullptr, sError));
return;
}
- info.GetReturnValue().Set(valueRes.ToJSValue());
+ info.GetReturnValue().Set(valueRes.ToV8Value());
}
#define JS_STATIC_GLOBAL_FUN(fun_name) \
@@ -452,7 +452,7 @@ for (int i=0; i<size; i++) array.SetElement(i,CJS_Value(pRuntime,ArrayContent[i]
\
CJS_PropValue prop(pRuntime);\
prop << array;\
-if (JS_DefineGlobalConst(pRuntime, (const wchar_t*)ArrayName, prop.ToJSValue()) < 0)\
+if (JS_DefineGlobalConst(pRuntime, (const wchar_t*)ArrayName, prop.ToV8Value()) < 0)\
return -1
/* ============================================================ */
diff --git a/fpdfsdk/include/javascript/JS_Value.h b/fpdfsdk/include/javascript/JS_Value.h
index 1431349552..ecd0f832d4 100644
--- a/fpdfsdk/include/javascript/JS_Value.h
+++ b/fpdfsdk/include/javascript/JS_Value.h
@@ -39,16 +39,16 @@ public:
void Detach();
- operator int() const;
- operator bool() const;
- operator double() const;
- operator float() const;
- operator CJS_Object*() const;
- operator v8::Handle<v8::Object>() const;
- operator v8::Handle<v8::Array>() const;
- operator CFX_WideString() const;
- operator CFX_ByteString() const;
- v8::Handle<v8::Value> ToJSValue();
+ int ToInt() const;
+ bool ToBool() const;
+ double ToDouble() const;
+ float ToFloat() const;
+ CJS_Object* ToCJSObject() const;
+ CFX_WideString ToCFXWideString() const;
+ CFX_ByteString ToCFXByteString() const;
+ v8::Handle<v8::Object> ToV8Object() const;
+ v8::Handle<v8::Array> ToV8Array() const;
+ v8::Handle<v8::Value> ToV8Value() const;
void operator = (int iValue);
void operator = (bool bValue);
diff --git a/fpdfsdk/src/javascript/Document.cpp b/fpdfsdk/src/javascript/Document.cpp
index f823d8084f..00721bda82 100644
--- a/fpdfsdk/src/javascript/Document.cpp
+++ b/fpdfsdk/src/javascript/Document.cpp
@@ -326,7 +326,7 @@ FX_BOOL Document::getField(IFXJS_Context* cc, const CJS_Parameters& params, CJS_
if (params.size() < 1) return FALSE;
- CFX_WideString wideName = params[0].operator CFX_WideString();
+ CFX_WideString wideName = params[0].ToCFXWideString();
CPDFSDK_InterForm* pInterForm = m_pDocument->GetInterForm();
ASSERT(pInterForm != NULL);
@@ -364,7 +364,7 @@ FX_BOOL Document::getNthFieldName(IFXJS_Context* cc, const CJS_Parameters& param
{
ASSERT(m_pDocument != NULL);
- int nIndex = params.size() > 0 ? (int)params[0] : -1;
+ int nIndex = params.size() > 0 ? params[0].ToInt() : -1;
if (nIndex == -1) return FALSE;
CPDFSDK_InterForm* pInterForm = m_pDocument->GetInterForm();
@@ -412,12 +412,12 @@ FX_BOOL Document::mailForm(IFXJS_Context* cc, const CJS_Parameters& params, CJS_
int iLength = params.size();
- FX_BOOL bUI = iLength > 0 ? (FX_BOOL)params[0] : TRUE;
- CFX_WideString cTo = iLength > 1 ? (FX_LPCWSTR)params[1].operator CFX_WideString() : L"";
- CFX_WideString cCc = iLength > 2 ? (FX_LPCWSTR)params[2].operator CFX_WideString() : L"";
- CFX_WideString cBcc = iLength > 3 ? (FX_LPCWSTR)params[3].operator CFX_WideString() : L"";
- CFX_WideString cSubject = iLength > 4 ? (FX_LPCWSTR)params[4].operator CFX_WideString() : L"";
- CFX_WideString cMsg = iLength > 5 ? (FX_LPCWSTR)params[5].operator CFX_WideString() : L"";
+ FX_BOOL bUI = iLength > 0 ? params[0].ToBool() : TRUE;
+ CFX_WideString cTo = iLength > 1 ? params[1].ToCFXWideString() : L"";
+ CFX_WideString cCc = iLength > 2 ? params[2].ToCFXWideString() : L"";
+ CFX_WideString cBcc = iLength > 3 ? params[3].ToCFXWideString() : L"";
+ CFX_WideString cSubject = iLength > 4 ? params[4].ToCFXWideString() : L"";
+ CFX_WideString cMsg = iLength > 5 ? params[5].ToCFXWideString() : L"";
CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInterForm();
ASSERT(pInterForm != NULL);
@@ -460,11 +460,11 @@ FX_BOOL Document::print(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Val
{
if (params[8].GetType() == VT_fxobject)
{
- JSFXObject pObj = (JSFXObject)params[8];
+ JSFXObject pObj = params[8].ToV8Object();
{
if (JS_GetObjDefnID(pObj) == JS_GetObjDefnID(*pRuntime, L"PrintParamsObj"))
{
- if (CJS_Object* pJSObj = (CJS_Object*)params[8])
+ if (CJS_Object* pJSObj = params[8].ToCJSObject())
{
if (PrintParamsObj* pprintparamsObj = (PrintParamsObj*)pJSObj->GetEmbedObject())
{
@@ -485,21 +485,21 @@ FX_BOOL Document::print(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Val
else
{
if(nlength >= 1)
- bUI = params[0];
+ bUI = params[0].ToBool();
if(nlength >= 2)
- nStart = (int)params[1];
+ nStart = params[1].ToInt();
if(nlength >= 3)
- nEnd = (int)params[2];
+ nEnd = params[2].ToInt();
if(nlength >= 4)
- bSilent = params[3];
+ bSilent = params[3].ToBool();
if(nlength >= 5)
- bShrinkToFit = params[4];
+ bShrinkToFit = params[4].ToBool();
if(nlength >= 6)
- bPrintAsImage = params[5];
+ bPrintAsImage = params[5].ToBool();
if(nlength >= 7)
- bReverse = params[6];
+ bReverse = params[6].ToBool();
if(nlength >= 8)
- bAnnotations = params[7];
+ bAnnotations = params[7].ToBool();
}
ASSERT(m_pDocument != NULL);
@@ -526,7 +526,7 @@ FX_BOOL Document::removeField(IFXJS_Context* cc, const CJS_Parameters& params, C
if (params.size() < 1)
return TRUE;
- CFX_WideString sFieldName = params[0].operator CFX_WideString();
+ CFX_WideString sFieldName = params[0].ToCFXWideString();
CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInterForm();
ASSERT(pInterForm != NULL);
@@ -592,7 +592,7 @@ FX_BOOL Document::resetForm(IFXJS_Context* cc, const CJS_Parameters& params, CJS
switch (params[0].GetType())
{
default:
- aName.Attach(params[0]);
+ aName.Attach(params[0].ToV8Array());
break;
case VT_string:
aName.SetElement(0,params[0]);
@@ -605,7 +605,7 @@ FX_BOOL Document::resetForm(IFXJS_Context* cc, const CJS_Parameters& params, CJS
{
CJS_Value valElement(isolate);
aName.GetElement(i,valElement);
- CFX_WideString swVal = valElement.operator CFX_WideString();
+ CFX_WideString swVal = valElement.ToCFXWideString();
for (int j=0,jsz=pPDFForm->CountFields(swVal); j<jsz; j++)
{
@@ -656,26 +656,26 @@ FX_BOOL Document::submitForm(IFXJS_Context* cc, const CJS_Parameters& params, CJ
CJS_Value v = params[0];
if (v.GetType() == VT_string)
{
- strURL = params[0].operator CFX_WideString();
+ strURL = params[0].ToCFXWideString();
if (nSize > 1)
- bFDF = params[1];
+ bFDF = params[1].ToBool();
if (nSize > 2)
- bEmpty = params[2];
+ bEmpty = params[2].ToBool();
if (nSize > 3)
- aFields.Attach(params[3]);
+ aFields.Attach(params[3].ToV8Array());
}
else if (v.GetType() == VT_object)
{
- JSObject pObj = (JSObject)params[0];
- v8::Handle<v8::Value> pValue = JS_GetObjectElement(isolate,pObj, L"cURL");
+ JSObject pObj = params[0].ToV8Object();
+ v8::Handle<v8::Value> pValue = JS_GetObjectElement(isolate, pObj, L"cURL");
if (!pValue.IsEmpty())
- strURL = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue));
- pValue = JS_GetObjectElement(isolate,pObj, L"bFDF");
- bFDF = CJS_Value(isolate,pValue, GET_VALUE_TYPE(pValue));
- pValue = JS_GetObjectElement(isolate,pObj, L"bEmpty");
- bEmpty = CJS_Value(isolate,pValue, GET_VALUE_TYPE(pValue));
- pValue = JS_GetObjectElement(isolate,pObj,L"aFields");
- aFields.Attach(CJS_Value(isolate,pValue, GET_VALUE_TYPE(pValue)));
+ strURL = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString();
+ pValue = JS_GetObjectElement(isolate, pObj, L"bFDF");
+ bFDF = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToBool();
+ pValue = JS_GetObjectElement(isolate, pObj, L"bEmpty");
+ bEmpty = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToBool();
+ pValue = JS_GetObjectElement(isolate, pObj,L"aFields");
+ aFields.Attach(CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToV8Array());
}
CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInterForm();
@@ -710,7 +710,7 @@ FX_BOOL Document::submitForm(IFXJS_Context* cc, const CJS_Parameters& params, CJ
{
CJS_Value valName(isolate);
aFields.GetElement(i, valName);
- CFX_WideString sName = valName.operator CFX_WideString();
+ CFX_WideString sName = valName.ToCFXWideString();
CPDF_InterForm* pPDFForm = pInterForm->GetInterForm();
ASSERT(pPDFForm != NULL);
@@ -781,37 +781,42 @@ FX_BOOL Document::mailDoc(IFXJS_Context* cc, const CJS_Parameters& params, CJS_V
CFX_WideString cSubject = L"";
CFX_WideString cMsg = L"";
-
- bUI = params.size()>=1?static_cast<FX_BOOL>(params[0]):TRUE;
- cTo = params.size()>=2?(const wchar_t*)params[1].operator CFX_WideString():L"";
- cCc = params.size()>=3?(const wchar_t*)params[2].operator CFX_WideString():L"";
- cBcc = params.size()>=4?(const wchar_t*)params[3].operator CFX_WideString():L"";
- cSubject = params.size()>=5?(const wchar_t*)params[4].operator CFX_WideString():L"";
- cMsg = params.size()>=6?(const wchar_t*)params[5].operator CFX_WideString():L"";
+ if (params.size() >= 1)
+ bUI = params[0].ToBool();
+ if (params.size() >= 2)
+ cTo = params[1].ToCFXWideString();
+ if (params.size() >= 3)
+ cCc = params[2].ToCFXWideString();
+ if (params.size() >= 4)
+ cBcc = params[3].ToCFXWideString();
+ if (params.size() >= 5)
+ cSubject = params[4].ToCFXWideString();
+ if (params.size() >= 6)
+ cMsg = params[5].ToCFXWideString();
v8::Isolate* isolate = GetIsolate(cc);
- if(params.size()>=1 && params[0].GetType() == VT_object)
+ if(params.size() >= 1 && params[0].GetType() == VT_object)
{
- JSObject pObj = (JSObject )params[0];
+ JSObject pObj = params[0].ToV8Object();
v8::Handle<v8::Value> pValue = JS_GetObjectElement(isolate,pObj, L"bUI");
- bUI = (int)CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue));
+ bUI = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).ToInt();
pValue = JS_GetObjectElement(isolate,pObj, L"cTo");
- cTo = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).operator CFX_WideString();
+ cTo = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).ToCFXWideString();
pValue = JS_GetObjectElement(isolate,pObj, L"cCc");
- cCc = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).operator CFX_WideString();
+ cCc = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).ToCFXWideString();
pValue = JS_GetObjectElement(isolate,pObj, L"cBcc");
- cBcc = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).operator CFX_WideString();
+ cBcc = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).ToCFXWideString();
pValue = JS_GetObjectElement(isolate,pObj, L"cSubject");
- cSubject = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).operator CFX_WideString();
+ cSubject = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).ToCFXWideString();
pValue = JS_GetObjectElement(isolate,pObj, L"cMsg");
- cMsg = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).operator CFX_WideString();
+ cMsg = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).ToCFXWideString();
}
@@ -1459,12 +1464,12 @@ FX_BOOL Document::addIcon(IFXJS_Context* cc, const CJS_Parameters& params, CJS_V
CJS_Runtime* pRuntime = pContext->GetJSRuntime();
ASSERT(pRuntime != NULL);
- CFX_WideString swIconName = params[0].operator CFX_WideString();
+ CFX_WideString swIconName = params[0].ToCFXWideString();
- JSFXObject pJSIcon = (JSFXObject)params[1];
+ JSFXObject pJSIcon = params[1].ToV8Object();
if (JS_GetObjDefnID(pJSIcon) != JS_GetObjDefnID(*pRuntime, L"Icon")) return FALSE;
- CJS_EmbedObj* pEmbedObj = ((CJS_Object*)params[1])->GetEmbedObject();
+ CJS_EmbedObj* pEmbedObj = params[1].ToCJSObject()->GetEmbedObject();
if (!pEmbedObj)return FALSE;
Icon* pIcon = (Icon*)pEmbedObj;
@@ -1527,7 +1532,7 @@ FX_BOOL Document::getIcon(IFXJS_Context* cc, const CJS_Parameters& params, CJS_V
if (params.size() != 1)return FALSE;
if(!m_pIconTree)
return FALSE;
- CFX_WideString swIconName = params[0].operator CFX_WideString();
+ CFX_WideString swIconName = params[0].ToCFXWideString();
int iIconCounts = m_pIconTree->GetLength();
CJS_Context* pContext = (CJS_Context *)cc;
@@ -1563,7 +1568,7 @@ FX_BOOL Document::removeIcon(IFXJS_Context* cc, const CJS_Parameters& params, CJ
if (params.size() != 1)return FALSE;
if(!m_pIconTree)
return FALSE;
- CFX_WideString swIconName = params[0].operator CFX_WideString();
+ CFX_WideString swIconName = params[0].ToCFXWideString();
return TRUE;
}
@@ -1603,9 +1608,9 @@ FX_BOOL Document::getPageNthWord(IFXJS_Context* cc, const CJS_Parameters& params
if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) return FALSE;
- int nPageNo = params.GetSize() > 0 ? (int)params[0] : 0;
- int nWordNo = params.GetSize() > 1 ? (int)params[1] : 0;
- bool bStrip = params.GetSize() > 2 ? (bool)params[2] : true;
+ int nPageNo = params.GetSize() > 0 ? params[0].ToInt() : 0;
+ int nWordNo = params.GetSize() > 1 ? params[1].ToInt() : 0;
+ bool bStrip = params.GetSize() > 2 ? params[2].ToBool() : true;
CPDF_Document* pDocument = m_pDocument->GetDocument();
if (!pDocument) return FALSE;
@@ -1675,7 +1680,7 @@ FX_BOOL Document::getPageNumWords(IFXJS_Context* cc, const CJS_Parameters& param
if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) return FALSE;
- int nPageNo = params.GetSize() > 0 ? (int)params[0] : 0;
+ int nPageNo = params.GetSize() > 0 ? params[0].ToInt() : 0;
CPDF_Document* pDocument = m_pDocument->GetDocument();
ASSERT(pDocument != NULL);
@@ -1847,22 +1852,22 @@ FX_BOOL Document::deletePages(IFXJS_Context* cc, const CJS_Parameters& params, C
{
if (params[0].GetType() == VT_object)
{
- JSObject pObj = (JSObject )params[0];
- v8::Handle<v8::Value> pValue = JS_GetObjectElement(isolate,pObj, L"nStart");
- nStart = (int)CJS_Value(m_isolate,pValue,GET_VALUE_TYPE(pValue));
+ JSObject pObj = params[0].ToV8Object();
+ v8::Handle<v8::Value> pValue = JS_GetObjectElement(isolate, pObj, L"nStart");
+ nStart = CJS_Value(m_isolate, pValue, GET_VALUE_TYPE(pValue)).ToInt();
- pValue = JS_GetObjectElement(isolate,pObj, L"nEnd");
- nEnd = (int)CJS_Value(m_isolate,pValue,GET_VALUE_TYPE(pValue));
+ pValue = JS_GetObjectElement(isolate, pObj, L"nEnd");
+ nEnd = CJS_Value(m_isolate, pValue, GET_VALUE_TYPE(pValue)).ToInt();
}
else
{
- nStart = (int)params[0];
+ nStart = params[0].ToInt();
}
}
else
{
- nStart = (int)params[0];
- nEnd = (int)params[1];
+ nStart = params[0].ToInt();
+ nEnd = params[1].ToInt();
}
int nTotal = m_pDocument->GetPageCount();
diff --git a/fpdfsdk/src/javascript/Field.cpp b/fpdfsdk/src/javascript/Field.cpp
index 85b7d12c3f..36bd1caf42 100644
--- a/fpdfsdk/src/javascript/Field.cpp
+++ b/fpdfsdk/src/javascript/Field.cpp
@@ -1072,7 +1072,7 @@ FX_BOOL Field::currentValueIndices(IFXJS_Context* cc, CJS_PropValue& vp, CFX_Wid
for (int i=0,sz=SelArray.GetLength(); i<sz; i++)
{
SelArray.GetElement(i,SelValue);
- iSelecting = (FX_INT32)SelValue;
+ iSelecting = SelValue.ToInt();
array.Add(iSelecting);
}
}
@@ -2375,10 +2375,10 @@ FX_BOOL Field::rect(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError
rcArray.GetElement(3, Lower_Righty);
FX_FLOAT pArray[4] = {0.0f,0.0f,0.0f,0.0f};
- pArray[0] = (FX_FLOAT)(FX_INT32)Upper_Leftx;
- pArray[1] = (FX_FLOAT)(FX_INT32)Lower_Righty;
- pArray[2] = (FX_FLOAT)(FX_INT32)Lower_Rightx;
- pArray[3] = (FX_FLOAT)(FX_INT32)Upper_Lefty;
+ pArray[0] = (FX_FLOAT)Upper_Leftx.ToInt();
+ pArray[1] = (FX_FLOAT)Lower_Righty.ToInt();
+ pArray[2] = (FX_FLOAT)Lower_Rightx.ToInt();
+ pArray[3] = (FX_FLOAT)Upper_Lefty.ToInt();
CPDF_Rect crRect(pArray);
@@ -3085,7 +3085,7 @@ FX_BOOL Field::value(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sErro
{
CJS_Value ElementValue(m_isolate);
ValueArray.GetElement(i, ElementValue);
- strArray.Add(ElementValue.operator CFX_WideString());
+ strArray.Add(ElementValue.ToCFXWideString());
}
}
else
@@ -3149,7 +3149,7 @@ FX_BOOL Field::value(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sErro
{
iIndex = pFormField->GetSelectedIndex(i);
ElementValue = pFormField->GetOptionValue(iIndex);
- if (FXSYS_wcslen((FX_LPCWSTR)ElementValue.operator CFX_WideString()) == 0)
+ if (FXSYS_wcslen(ElementValue.ToCFXWideString().c_str()) == 0)
ElementValue = pFormField->GetOptionLabel(iIndex);
ValueArray.SetElement(i, ElementValue);
}
@@ -3374,8 +3374,8 @@ FX_BOOL Field::buttonGetCaption(IFXJS_Context* cc, const CJS_Parameters& params,
int nface = 0;
int iSize = params.size();
- if ( iSize >= 1)
- nface = (FX_INT32) params[0];
+ if (iSize >= 1)
+ nface = params[0].ToInt();
CFX_PtrArray FieldArray;
GetFormFields(m_FieldName,FieldArray);
@@ -3410,8 +3410,8 @@ FX_BOOL Field::buttonGetIcon(IFXJS_Context* cc, const CJS_Parameters& params, CJ
int nface = 0;
int iSize = params.size();
- if ( iSize >= 1)
- nface = (FX_INT32) params[0];
+ if (iSize >= 1)
+ nface = params[0].ToInt();
CFX_PtrArray FieldArray;
GetFormFields(m_FieldName,FieldArray);
@@ -3519,15 +3519,14 @@ FX_BOOL Field::checkThisBox(IFXJS_Context* cc, const CJS_Parameters& params, CJS
if (!m_bCanSet) return FALSE;
int iSize = params.size();
- int nWidget = -1;
- if ( iSize >= 1)
- nWidget= (FX_INT32) params[0];
- else
+ if (iSize < 1)
return FALSE;
- FX_BOOL bCheckit = TRUE;
- if ( iSize >= 2)
- bCheckit = params[1];
+ int nWidget = params[0].ToInt();
+
+ FX_BOOL bCheckit = TRUE;
+ if (iSize >= 2)
+ bCheckit = params[1].ToBool();
CFX_PtrArray FieldArray;
GetFormFields(m_FieldName,FieldArray);
@@ -3535,9 +3534,9 @@ FX_BOOL Field::checkThisBox(IFXJS_Context* cc, const CJS_Parameters& params, CJS
CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
ASSERT(pFormField != NULL);
-
+
if (pFormField->GetFieldType() != FIELDTYPE_CHECKBOX && pFormField->GetFieldType() != FIELDTYPE_RADIOBUTTON)
- return FALSE;
+ return FALSE;
if(nWidget <0 || nWidget >= pFormField->CountControls())
return FALSE;
if (pFormField->GetFieldType() == FIELDTYPE_RADIOBUTTON)
@@ -3546,7 +3545,6 @@ FX_BOOL Field::checkThisBox(IFXJS_Context* cc, const CJS_Parameters& params, CJS
pFormField->CheckControl(nWidget, bCheckit, TRUE);
UpdateFormField(m_pDocument, pFormField, TRUE, TRUE, TRUE);
-
return TRUE;
}
@@ -3562,14 +3560,10 @@ FX_BOOL Field::defaultIsChecked(IFXJS_Context* cc, const CJS_Parameters& params,
if (!m_bCanSet) return FALSE;
int iSize = params.size();
- int nWidget = -1;
- if ( iSize >= 1)
- nWidget= (FX_INT32) params[0];
- else
+ if (iSize < 1)
return FALSE;
- //FX_BOOL bIsDefaultChecked = TRUE;
- //if ( iSize >= 2)
- // bIsDefaultChecked = params[1];
+
+ int nWidget = params[0].ToInt();
CFX_PtrArray FieldArray;
GetFormFields(m_FieldName,FieldArray);
@@ -3665,16 +3659,15 @@ FX_BOOL Field::getArray(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Val
FX_BOOL Field::getItemAt(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
ASSERT(m_pDocument != NULL);
+ int iSize = params.size();
int nIdx = -1;
- if (params.size() >=1)
- nIdx = (FX_INT32) params[0];
+ if (iSize >= 1)
+ nIdx = params[0].ToInt();
+
FX_BOOL bExport = TRUE;
- int iSize = params.size();
- if ( iSize >= 2)
- {
- bExport =(FX_BOOL) params[1];
- }
+ if (iSize >= 2)
+ bExport = params[1].ToBool();
CFX_PtrArray FieldArray;
GetFormFields(m_FieldName,FieldArray);
@@ -3720,8 +3713,8 @@ FX_BOOL Field::isBoxChecked(IFXJS_Context* cc, const CJS_Parameters& params, CJS
ASSERT(m_pDocument != NULL);
int nIndex = -1;
- if (params.size() >=1)
- nIndex = (FX_INT32) params[0];
+ if (params.size() >= 1)
+ nIndex = params[0].ToInt();
CFX_PtrArray FieldArray;
GetFormFields(m_FieldName,FieldArray);
@@ -3755,8 +3748,8 @@ FX_BOOL Field::isDefaultChecked(IFXJS_Context* cc, const CJS_Parameters& params,
ASSERT(m_pDocument != NULL);
int nIndex = -1;
- if (params.size() >=1)
- nIndex = (FX_INT32) params[0];
+ if (params.size() >= 1)
+ nIndex = params[0].ToInt();
CFX_PtrArray FieldArray;
GetFormFields(m_FieldName,FieldArray);
diff --git a/fpdfsdk/src/javascript/JS_Value.cpp b/fpdfsdk/src/javascript/JS_Value.cpp
index 6743daa4d5..be374895e4 100644
--- a/fpdfsdk/src/javascript/JS_Value.cpp
+++ b/fpdfsdk/src/javascript/JS_Value.cpp
@@ -85,7 +85,7 @@ void CJS_Value::Attach(v8::Handle<v8::Value> pValue,FXJSVALUETYPE t)
void CJS_Value::Attach(CJS_Value *pValue)
{
if (pValue)
- Attach(pValue->ToJSValue(),pValue->GetType());
+ Attach(pValue->ToV8Value(), pValue->GetType());
}
void CJS_Value::Detach()
@@ -96,63 +96,53 @@ void CJS_Value::Detach()
/* ---------------------------------------------------------------------------------------- */
-CJS_Value::operator int() const
+int CJS_Value::ToInt() const
{
-
return JS_ToInt32(m_pValue);
-
}
-CJS_Value::operator bool() const
+bool CJS_Value::ToBool() const
{
-
return JS_ToBoolean(m_pValue);
-
}
-CJS_Value::operator double() const
+double CJS_Value::ToDouble() const
{
-
return JS_ToNumber(m_pValue);
-
}
-CJS_Value::operator float() const
+float CJS_Value::ToFloat() const
{
-
- return (float)JS_ToNumber(m_pValue);
-
+ return (float)ToDouble();
}
-CJS_Value::operator CJS_Object *() const
+CJS_Object* CJS_Value::ToCJSObject() const
{
-
v8::Handle<v8::Object> pObj = JS_ToObject(m_pValue);
return (CJS_Object*)JS_GetPrivate(m_isolate, pObj);
}
-CJS_Value::operator v8::Handle<v8::Object>() const
+v8::Handle<v8::Object> CJS_Value::ToV8Object() const
{
return JS_ToObject(m_pValue);
}
-CJS_Value::operator CFX_WideString() const
+CFX_WideString CJS_Value::ToCFXWideString() const
{
return JS_ToString(m_pValue);
}
-CJS_Value::operator CFX_ByteString() const
+CFX_ByteString CJS_Value::ToCFXByteString() const
{
- return CFX_ByteString::FromUnicode(operator CFX_WideString());
+ return CFX_ByteString::FromUnicode(ToCFXWideString());
}
-v8::Handle<v8::Value> CJS_Value::ToJSValue()
+v8::Handle<v8::Value> CJS_Value::ToV8Value() const
{
return m_pValue;
}
-
-CJS_Value::operator v8::Handle<v8::Array>() const
+v8::Handle<v8::Array>CJS_Value::ToV8Array() const
{
if (IsArrayObject())
return v8::Handle<v8::Array>::Cast(JS_ToObject(m_pValue));
@@ -245,7 +235,7 @@ void CJS_Value::operator = (CJS_Date & date)
void CJS_Value::operator = (CJS_Value value)
{
- m_pValue = value.ToJSValue();
+ m_pValue = value.ToV8Value();
m_eType = value.m_eType;
}
@@ -342,7 +332,7 @@ void CJS_PropValue::operator <<(int iValue)
void CJS_PropValue::operator >>(int & iValue) const
{
ASSERT(m_bIsSetting);
- iValue = CJS_Value::operator int();
+ iValue = CJS_Value::ToInt();
}
@@ -355,8 +345,7 @@ void CJS_PropValue::operator <<(bool bValue)
void CJS_PropValue::operator >>(bool& bValue) const
{
ASSERT(m_bIsSetting);
- bValue = CJS_Value::operator bool();
-
+ bValue = CJS_Value::ToBool();
}
void CJS_PropValue::operator <<(double dValue)
@@ -368,7 +357,7 @@ void CJS_PropValue::operator <<(double dValue)
void CJS_PropValue::operator >>(double& dValue) const
{
ASSERT(m_bIsSetting);
- dValue = CJS_Value::operator double();
+ dValue = CJS_Value::ToDouble();
}
void CJS_PropValue::operator <<(CJS_Object* pObj)
@@ -380,7 +369,7 @@ void CJS_PropValue::operator <<(CJS_Object* pObj)
void CJS_PropValue::operator >>(CJS_Object*& ppObj) const
{
ASSERT(m_bIsSetting);
- ppObj = CJS_Value::operator CJS_Object *();
+ ppObj = CJS_Value::ToCJSObject();
}
void CJS_PropValue::operator <<(CJS_Document* pJsDoc)
@@ -392,7 +381,7 @@ void CJS_PropValue::operator <<(CJS_Document* pJsDoc)
void CJS_PropValue::operator >>(CJS_Document*& ppJsDoc) const
{
ASSERT(m_bIsSetting);
- ppJsDoc = static_cast<CJS_Document*>(CJS_Value::operator CJS_Object *());
+ ppJsDoc = static_cast<CJS_Document*>(CJS_Value::ToCJSObject());
}
void CJS_PropValue::operator<<(JSFXObject pObj)
@@ -404,7 +393,7 @@ void CJS_PropValue::operator<<(JSFXObject pObj)
void CJS_PropValue::operator>>(JSFXObject &ppObj) const
{
ASSERT(m_bIsSetting);
- ppObj = CJS_Value::operator JSFXObject ();
+ ppObj = CJS_Value::ToV8Object();
}
@@ -426,7 +415,7 @@ void CJS_PropValue::operator <<(CFX_ByteString string)
void CJS_PropValue::operator >>(CFX_ByteString &string) const
{
ASSERT(m_bIsSetting);
- string = CJS_Value::operator CFX_ByteString();
+ string = CJS_Value::ToCFXByteString();
}
void CJS_PropValue::operator <<(FX_LPCWSTR c_string)
@@ -438,7 +427,7 @@ void CJS_PropValue::operator <<(FX_LPCWSTR c_string)
void CJS_PropValue::operator >>(CFX_WideString &wide_string) const
{
ASSERT(m_bIsSetting);
- wide_string = CJS_Value::operator CFX_WideString();
+ wide_string = CJS_Value::ToCFXWideString();
}
void CJS_PropValue::operator <<(CFX_WideString wide_string)
@@ -508,7 +497,7 @@ void CJS_Array::SetElement(unsigned index,CJS_Value value)
if (m_pArray.IsEmpty())
m_pArray = JS_NewArray(m_isolate);
- JS_PutArrayElement(m_pArray,index,value.ToJSValue(),value.GetType());
+ JS_PutArrayElement(m_pArray, index, value.ToV8Value(), value.GetType());
}
int CJS_Array::GetLength()
diff --git a/fpdfsdk/src/javascript/PublicMethods.cpp b/fpdfsdk/src/javascript/PublicMethods.cpp
index e3479f1fa4..ff5b9a787a 100644
--- a/fpdfsdk/src/javascript/PublicMethods.cpp
+++ b/fpdfsdk/src/javascript/PublicMethods.cpp
@@ -430,7 +430,7 @@ CJS_Array CJS_PublicMethods::AF_MakeArrayFromList(v8::Isolate* isolate, CJS_Valu
val.ConvertToArray(StrArray);
return StrArray;
}
- CFX_WideString wsStr = val.operator CFX_WideString();
+ CFX_WideString wsStr = val.ToCFXWideString();
CFX_ByteString t = CFX_ByteString::FromUnicode(wsStr);
const char * p = (const char *)t;
@@ -1071,12 +1071,12 @@ FX_BOOL CJS_PublicMethods::AFNumber_Format(IFXJS_Context* cc, const CJS_Paramete
if (strValue.IsEmpty()) return TRUE;
- int iDec = params[0];
- int iSepStyle = params[1];
- int iNegStyle = params[2];
+ 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].operator CFX_WideString());
- FX_BOOL bCurrencyPrepend = params[5];
+ std::wstring wstrCurrency(params[4].ToCFXWideString());
+ FX_BOOL bCurrencyPrepend = params[5].ToBool();
if (iDec < 0) iDec = -iDec;
@@ -1268,7 +1268,7 @@ FX_BOOL CJS_PublicMethods::AFNumber_Keystroke(IFXJS_Context* cc, const CJS_Param
if(params.size() < 2)
return FALSE;
- int iSepStyle = params[1];
+ int iSepStyle = params[1].ToInt();
if (iSepStyle < 0 || iSepStyle > 3)
iSepStyle = 0;
@@ -1406,30 +1406,20 @@ FX_BOOL CJS_PublicMethods::AFPercent_Format(IFXJS_Context* cc, const CJS_Paramet
}
if(!pEvent->m_pValue)
return FALSE;
+
CFX_WideString& Value = pEvent->Value();
-
-// HWND hMainFrame = NULL;
-//
-// CPDFSDK_FormFillApp *pApp = pContext->GetReaderApp();
-// ASSERT(pApp);
-// hMainFrame = pApp->GetMainFrameWnd();
-
CFX_ByteString strValue = StrTrim(CFX_ByteString::FromUnicode(Value));
-
if (strValue.IsEmpty())
return TRUE;
-
- int iDec = params[0];
- int iSepStyle = params[1];
-
- //ASSERT(iDec > 0);
+
+ int iDec = params[0].ToInt();
if (iDec < 0)
iDec = -iDec;
-
+
+ int iSepStyle = params[1].ToInt();
if (iSepStyle < 0 || iSepStyle > 3)
iSepStyle = 0;
-
-
+
//////////////////////////////////////////////////////
//for processing decimal places
double dValue = atof(strValue);
@@ -1527,16 +1517,16 @@ FX_BOOL CJS_PublicMethods::AFDate_FormatEx(IFXJS_Context* cc, const CJS_Paramete
{
sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
return FALSE;
- }
+ }
if(!pEvent->m_pValue)
return FALSE;
- CFX_WideString& val = pEvent->Value();
-
- CFX_WideString strValue = val;
- if (strValue.IsEmpty()) return TRUE;
- CFX_WideString sFormat = params[0].operator CFX_WideString();
+ CFX_WideString& val = pEvent->Value();
+ CFX_WideString strValue = val;
+ if (strValue.IsEmpty())
+ return TRUE;
+ CFX_WideString sFormat = params[0].ToCFXWideString();
FX_BOOL bWrongFormat = FALSE;
double dDate = 0.0f;
@@ -1558,9 +1548,8 @@ FX_BOOL CJS_PublicMethods::AFDate_FormatEx(IFXJS_Context* cc, const CJS_Paramete
Alert(pContext, swMsg);
return FALSE;
}
-
- val = MakeFormatDate(dDate,sFormat);
+ val = MakeFormatDate(dDate,sFormat);
return TRUE;
}
@@ -1636,17 +1625,17 @@ FX_BOOL CJS_PublicMethods::AFDate_KeystrokeEx(IFXJS_Context* cc, const CJS_Param
{
sError = L"AFDate_KeystrokeEx's parameters' size r not correct";
return FALSE;
- }
-
+ }
+
if (pEvent->WillCommit())
{
if(!pEvent->m_pValue)
return FALSE;
CFX_WideString strValue = pEvent->Value();
- if (strValue.IsEmpty()) return TRUE;
-
- CFX_WideString sFormat = params[0].operator CFX_WideString();
+ if (strValue.IsEmpty())
+ return TRUE;
+ CFX_WideString sFormat = params[0].ToCFXWideString();
FX_BOOL bWrongFormat = FALSE;
double dRet = MakeRegularDate(strValue,sFormat,bWrongFormat);
if (bWrongFormat || JS_PortIsNan(dRet))
@@ -1674,7 +1663,7 @@ FX_BOOL CJS_PublicMethods::AFDate_Format(IFXJS_Context* cc, const CJS_Parameters
return FALSE;
}
- int iIndex = params[0];
+ int iIndex = params[0].ToInt();
FX_LPCWSTR cFormats[] = {L"m/d", L"m/d/yy", L"mm/dd/yy", L"mm/yy", L"d-mmm", L"d-mmm-yy", L"dd-mmm-yy",
L"yy-mm-dd", L"mmm-yy", L"mmmm-yy", L"mmm d, yyyy", L"mmmm d, yyyy",
L"m/d/yy h:MM tt", L"m/d/yy HH:MM" };
@@ -1705,7 +1694,7 @@ FX_BOOL CJS_PublicMethods::AFDate_Keystroke(IFXJS_Context* cc, const CJS_Paramet
return FALSE;
}
- int iIndex = params[0];
+ int iIndex = params[0].ToInt();
FX_LPCWSTR cFormats[] = {L"m/d", L"m/d/yy", L"mm/dd/yy", L"mm/yy", L"d-mmm", L"d-mmm-yy", L"dd-mmm-yy",
L"yy-mm-dd", L"mmm-yy", L"mmmm-yy", L"mmm d, yyyy", L"mmmm d, yyyy",
L"m/d/yy h:MM tt", L"m/d/yy HH:MM" };
@@ -1735,7 +1724,7 @@ FX_BOOL CJS_PublicMethods::AFTime_Format(IFXJS_Context* cc, const CJS_Parameters
return FALSE;
}
- int iIndex = params[0];
+ int iIndex = params[0].ToInt();
FX_LPCWSTR cFormats[] = {L"HH:MM", L"h:MM tt", L"HH:MM:ss", L"h:MM:ss tt"};
ASSERT(iIndex<FX_ArraySize(cFormats));
@@ -1761,7 +1750,7 @@ FX_BOOL CJS_PublicMethods::AFTime_Keystroke(IFXJS_Context* cc, const CJS_Paramet
return FALSE;
}
- int iIndex = params[0];
+ int iIndex = params[0].ToInt();
FX_LPCWSTR cFormats[] = {L"HH:MM", L"h:MM tt", L"HH:MM:ss", L"h:MM:ss tt"};
ASSERT(iIndex<FX_ArraySize(cFormats));
@@ -1799,7 +1788,7 @@ FX_BOOL CJS_PublicMethods::AFSpecial_Format(IFXJS_Context* cc, const CJS_Paramet
}
std::string cFormat;
- int iIndex = params[0];
+ int iIndex = params[0].ToInt();
CJS_EventHandler* pEvent = pContext->GetEventHandler();
ASSERT(pEvent != NULL);
@@ -1858,11 +1847,12 @@ FX_BOOL CJS_PublicMethods::AFSpecial_KeystrokeEx(IFXJS_Context* cc, const CJS_Pa
return FALSE;
CFX_WideString& valEvent = pEvent->Value();
- CFX_WideString wstrMask = params[0].operator CFX_WideString();
- if (wstrMask.IsEmpty()) return TRUE;
-
+ CFX_WideString wstrMask = params[0].ToCFXWideString();
+ if (wstrMask.IsEmpty())
+ return TRUE;
+
std::wstring wstrValue(valEvent);
-
+
if (pEvent->WillCommit())
{
if (wstrValue.empty())
@@ -1871,7 +1861,7 @@ FX_BOOL CJS_PublicMethods::AFSpecial_KeystrokeEx(IFXJS_Context* cc, const CJS_Pa
for (std::wstring::iterator it = wstrValue.begin(); it != wstrValue.end(); it++)
{
wchar_t w_Value = *it;
- if (!maskSatisfied(w_Value,wstrMask[iIndexMask]))
+ if (!maskSatisfied(w_Value,wstrMask[iIndexMask]))
break;
iIndexMask++;
}
@@ -1884,31 +1874,27 @@ FX_BOOL CJS_PublicMethods::AFSpecial_KeystrokeEx(IFXJS_Context* cc, const CJS_Pa
return TRUE;
}
-
CFX_WideString &wideChange = pEvent->Change();
std::wstring wChange(wideChange);
-
if (wChange.empty())
return TRUE;
- int iIndexMask = pEvent->SelStart();
- //iIndexMask++;
-
-
+
+ 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));
pEvent->Rc() = FALSE;
return TRUE;
}
-
-
+
if (iIndexMask >= wstrMask.GetLength() && (!wChange.empty()))
{
Alert(pContext, JSGetStringFromID(pContext, IDS_STRING_JSPARAM_TOOLONG));
pEvent->Rc() = FALSE;
return TRUE;
}
-
+
for (std::wstring::iterator it = wChange.begin(); it != wChange.end(); it++)
{
if (iIndexMask >= wstrMask.GetLength())
@@ -1920,21 +1906,18 @@ FX_BOOL CJS_PublicMethods::AFSpecial_KeystrokeEx(IFXJS_Context* cc, const CJS_Pa
wchar_t w_Mask = wstrMask[iIndexMask];
if (!isReservedMaskChar(w_Mask))
{
- //wChange.insert(it,w_Mask);
*it = w_Mask;
}
wchar_t w_Change = *it;
-
- if (!maskSatisfied(w_Change,w_Mask))
+ if (!maskSatisfied(w_Change,w_Mask))
{
pEvent->Rc() = FALSE;
return TRUE;
}
iIndexMask++;
}
-
- wideChange = wChange.c_str();
-
+
+ wideChange = wChange.c_str();
return TRUE;
}
@@ -1956,7 +1939,7 @@ FX_BOOL CJS_PublicMethods::AFSpecial_Keystroke(IFXJS_Context* cc, const CJS_Para
}
std::string cFormat;
- int iIndex = (int)params[0];
+ int iIndex = params[0].ToInt();
if(!pEvent->m_pValue)
return FALSE;
@@ -2050,8 +2033,8 @@ FX_BOOL CJS_PublicMethods::AFParseDateEx(IFXJS_Context* cc, const CJS_Parameters
return FALSE;
}
- CFX_WideString sValue = params[0].operator CFX_WideString();
- CFX_WideString sFormat = params[1].operator CFX_WideString();
+ CFX_WideString sValue = params[0].ToCFXWideString();
+ CFX_WideString sFormat = params[1].ToCFXWideString();
FX_BOOL bWrongFormat = FALSE;
double dDate = MakeRegularDate(sValue,sFormat,bWrongFormat);
@@ -2063,9 +2046,8 @@ FX_BOOL CJS_PublicMethods::AFParseDateEx(IFXJS_Context* cc, const CJS_Parameters
Alert((CJS_Context *)cc, swMsg);
return FALSE;
}
-
- vRet = dDate;
+ vRet = dDate;
return TRUE;
}
@@ -2080,7 +2062,7 @@ FX_BOOL CJS_PublicMethods::AFSimple(IFXJS_Context* cc, const CJS_Parameters& par
return FALSE;
}
- vRet = (double)AF_Simple(params[0].operator CFX_WideString(), (double)params[1], (double)params[2]);
+ vRet = (double)AF_Simple(params[0].ToCFXWideString(), params[1].ToDouble(), params[2].ToDouble());
return TRUE;
}
@@ -2094,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].operator CFX_WideString());
+ vRet = ParseStringToNumber(params[0].ToCFXWideString());
return TRUE;
}
@@ -2118,7 +2100,7 @@ FX_BOOL CJS_PublicMethods::AFSimple_Calculate(IFXJS_Context* cc, const CJS_Param
sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
return FALSE;
}
-
+
CPDFSDK_Document* pReaderDoc = pContext->GetReaderDocument();
ASSERT(pReaderDoc != NULL);
@@ -2129,7 +2111,7 @@ FX_BOOL CJS_PublicMethods::AFSimple_Calculate(IFXJS_Context* cc, const CJS_Param
ASSERT(pInterForm != NULL);
double dValue;
- CFX_WideString sFunction = params[0].operator CFX_WideString();
+ CFX_WideString sFunction = params[0].ToCFXWideString();
if (wcscmp(sFunction, L"PRD") == 0)
dValue = 1.0;
else
@@ -2143,7 +2125,7 @@ FX_BOOL CJS_PublicMethods::AFSimple_Calculate(IFXJS_Context* cc, const CJS_Param
{
CJS_Value jsValue(isolate);
FieldNameArray.GetElement(i,jsValue);
- CFX_WideString wsFieldName = jsValue.operator CFX_WideString();
+ CFX_WideString wsFieldName = jsValue.ToCFXWideString();
for (int j=0,jsz=pInterForm->CountFields(wsFieldName); j<jsz; j++)
{
@@ -2214,7 +2196,7 @@ FX_BOOL CJS_PublicMethods::AFSimple_Calculate(IFXJS_Context* cc, const CJS_Param
dValue = (double)floor(dValue * FXSYS_pow((double)10,(double)6) + 0.49) / FXSYS_pow((double)10,(double)6);
CJS_Value jsValue(isolate,dValue);
if((CJS_EventHandler*)pContext->GetEventHandler()->m_pValue)
- ((CJS_EventHandler*)pContext->GetEventHandler())->Value() = jsValue;
+ ((CJS_EventHandler*)pContext->GetEventHandler())->Value() = jsValue.ToCFXWideString();
return TRUE;
}
@@ -2240,28 +2222,30 @@ FX_BOOL CJS_PublicMethods::AFRange_Validate(IFXJS_Context* cc, const CJS_Paramet
if (pEvent->Value().IsEmpty() )
return TRUE;
double dEentValue = atof(CFX_ByteString::FromUnicode(pEvent->Value()));
- FX_BOOL bGreaterThan, bLessThan;
- double dGreaterThan, dLessThan;
- bGreaterThan = (FX_BOOL)params[0];
+ FX_BOOL bGreaterThan = params[0].ToBool();
+ double dGreaterThan = params[1].ToDouble();
+ FX_BOOL bLessThan = params[2].ToBool();
+ double dLessThan = params[3].ToDouble();
CFX_WideString swMsg;
- dGreaterThan = (double)params[1];
- bLessThan = (FX_BOOL)params[2];
- dLessThan = (double)params[3];
if (bGreaterThan && bLessThan)
{
if (dEentValue < dGreaterThan || dEentValue > dLessThan)
- swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSRANGE1),(FX_LPCWSTR)params[1].operator CFX_WideString(), (FX_LPCWSTR)params[3].operator CFX_WideString());
+ 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), (FX_LPCWSTR)params[1].operator CFX_WideString());
+ 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), (FX_LPCWSTR)params[3].operator CFX_WideString());
+ swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSRANGE3),
+ params[3].ToCFXWideString().c_str());
}
if (!swMsg.IsEmpty())
@@ -2286,7 +2270,7 @@ FX_BOOL CJS_PublicMethods::AFExtractNums(IFXJS_Context* cc, const CJS_Parameters
CJS_Array nums(isolate);
- CFX_WideString str = params[0].operator CFX_WideString();
+ CFX_WideString str = params[0].ToCFXWideString();
CFX_WideString sPart;
if (str.GetAt(0) == L'.' || str.GetAt(0) == L',')
diff --git a/fpdfsdk/src/javascript/app.cpp b/fpdfsdk/src/javascript/app.cpp
index e17857b12b..57d9cfeaf2 100644
--- a/fpdfsdk/src/javascript/app.cpp
+++ b/fpdfsdk/src/javascript/app.cpp
@@ -325,19 +325,19 @@ FX_BOOL app::alert(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& v
{
if (params[0].GetType() == VT_object)
{
- JSObject pObj = params[0];
+ JSObject pObj = params[0].ToV8Object();
{
v8::Handle<v8::Value> pValue = JS_GetObjectElement(isolate, pObj, L"cMsg");
- swMsg = CJS_Value(isolate,pValue,VT_unknown).operator CFX_WideString();
+ swMsg = CJS_Value(isolate, pValue, VT_unknown).ToCFXWideString();
- pValue = JS_GetObjectElement(isolate,pObj,L"cTitle");
- swTitle = CJS_Value(isolate, pValue,VT_unknown).operator CFX_WideString();
+ pValue = JS_GetObjectElement(isolate, pObj, L"cTitle");
+ swTitle = CJS_Value(isolate, pValue, VT_unknown).ToCFXWideString();
- pValue = JS_GetObjectElement(isolate,pObj,L"nIcon");
- iIcon = (int)CJS_Value(isolate,pValue,VT_unknown);
+ pValue = JS_GetObjectElement(isolate, pObj, L"nIcon");
+ iIcon = CJS_Value(isolate, pValue, VT_unknown).ToInt();
- pValue = JS_GetObjectElement(isolate,pObj,L"nType");
- iType = (int)CJS_Value(isolate,pValue,VT_unknown);
+ pValue = JS_GetObjectElement(isolate, pObj, L"nType");
+ iType = CJS_Value(isolate, pValue, VT_unknown).ToInt();
}
if (swMsg == L"")
@@ -355,22 +355,12 @@ FX_BOOL app::alert(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& v
for(int i = 0; i < iLenth; i++)
{
carray.GetElement(i, *pValue);
- swMsg += (*pValue).operator CFX_WideString();
+ swMsg += (*pValue).ToCFXWideString();
if (i < iLenth - 1)
swMsg += L", ";
}
if(pValue) delete pValue;
-// if ((iLenth > 1) && pValue)
-// {
-// delete[]pValue;
-// pValue = NULL;
-// }
-// else if ((iLenth == 1) && pValue)
-// {
-// delete pValue;
-// pValue = NULL;
-// }
}
}
@@ -379,7 +369,7 @@ FX_BOOL app::alert(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& v
}
else if (params[0].GetType() == VT_boolean)
{
- FX_BOOL bGet = (FX_BOOL)params[0];
+ FX_BOOL bGet = params[0].ToBool();
if (bGet)
swMsg = L"true";
else
@@ -389,7 +379,7 @@ FX_BOOL app::alert(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& v
}
else
{
- swMsg = params[0];
+ swMsg = params[0].ToCFXWideString();
swTitle = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSALERT);
}
}
@@ -397,7 +387,7 @@ FX_BOOL app::alert(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& v
{
if (params[0].GetType() == VT_boolean)
{
- FX_BOOL bGet = (FX_BOOL)params[0];
+ FX_BOOL bGet = params[0].ToBool();
if (bGet)
swMsg = L"true";
else
@@ -405,18 +395,18 @@ FX_BOOL app::alert(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& v
}
else
{
- swMsg = params[0];
+ swMsg = params[0].ToCFXWideString();
}
swTitle = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSALERT);
for(int i = 1;i<iSize;i++)
{
if (i == 1)
- iIcon = int(params[i]);
+ iIcon = params[i].ToInt();
if (i == 2)
- iType = int(params[i]);
+ iType = params[i].ToInt();
if (i == 3)
- swTitle = params[i];
+ swTitle = params[i].ToCFXWideString();
}
}
@@ -440,15 +430,12 @@ FX_BOOL app::beep(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vR
CJS_Context* pContext = (CJS_Context*)cc;
CJS_Runtime* pRuntime = pContext->GetJSRuntime();
CPDFDoc_Environment * pEnv = pRuntime->GetReaderApp();
- pEnv->JS_appBeep((int)params[0]);
-
+ pEnv->JS_appBeep(params[0].ToInt());
return TRUE;
}
- else
- {
- sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSPARAMERROR);
- return FALSE;
- }
+
+ sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSPARAMERROR);
+ return FALSE;
}
FX_BOOL app::findComponent(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
@@ -479,14 +466,14 @@ FX_BOOL app::setInterval(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Va
CJS_Runtime* pRuntime = pContext->GetJSRuntime();
ASSERT(pRuntime != NULL);
- CFX_WideString script = params.size() > 0 ? (FX_LPCWSTR)(params[0].operator CFX_WideString()) : 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);
return TRUE;
}
- FX_DWORD dwInterval = params.size() > 1 ? (int)params[1] : 1000;
+ FX_DWORD dwInterval = params.size() > 1 ? params[1].ToInt() : 1000;
CPDFDoc_Environment* pApp = pRuntime->GetReaderApp();
ASSERT(pApp);
@@ -528,17 +515,18 @@ 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 ? (FX_LPCWSTR)(params[0].operator CFX_WideString()) : 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);
return TRUE;
}
- FX_DWORD dwTimeOut = params.size() > 1 ? (int)params[1] : 1000;
+ FX_DWORD dwTimeOut = params.size() > 1 ? params[1].ToInt() : 1000;
CPDFDoc_Environment* pApp = pRuntime->GetReaderApp();
ASSERT(pApp);
+
CJS_Timer* pTimer = new CJS_Timer(this, pApp);
m_aTimer.Add(pTimer);
@@ -546,12 +534,9 @@ FX_BOOL app::setTimeOut(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Val
pTimer->SetRuntime(pRuntime);
pTimer->SetJScript(script);
pTimer->SetTimeOut(dwTimeOut);
-// pTimer->SetStartTime(GetTickCount());
-// pTimer->SetJSTimer(1000);
pTimer->SetJSTimer(dwTimeOut);
JSFXObject pRetObj = JS_NewFxDynamicObj(*pRuntime, pContext, JS_GetObjDefnID(*pRuntime, L"TimerObj"));
-// ASSERT(pRetObj != NULL);
CJS_TimerObj* pJS_TimerObj = (CJS_TimerObj*)JS_GetPrivate(pRuntime->GetIsolate(),pRetObj);
ASSERT(pJS_TimerObj != NULL);
@@ -581,11 +566,11 @@ FX_BOOL app::clearTimeOut(IFXJS_Context* cc, const CJS_Parameters& params, CJS_V
if (params[0].GetType() == VT_fxobject)
{
- JSFXObject pObj = (JSFXObject)params[0];
+ JSFXObject pObj = params[0].ToV8Object();
{
if (JS_GetObjDefnID(pObj) == JS_GetObjDefnID(*pRuntime, L"TimerObj"))
{
- if (CJS_Object* pJSObj = (CJS_Object*)params[0])
+ if (CJS_Object* pJSObj = params[0].ToCJSObject())
{
if (TimerObj* pTimerObj = (TimerObj*)pJSObj->GetEmbedObject())
{
@@ -629,11 +614,11 @@ FX_BOOL app::clearInterval(IFXJS_Context* cc, const CJS_Parameters& params, CJS_
if (params[0].GetType() == VT_fxobject)
{
- JSFXObject pObj = (JSFXObject)params[0];
+ JSFXObject pObj = params[0].ToV8Object();
{
if (JS_GetObjDefnID(pObj) == JS_GetObjDefnID(*pRuntime, L"TimerObj"))
{
- if (CJS_Object* pJSObj = (CJS_Object*)params[0])
+ if (CJS_Object* pJSObj = params[0].ToCJSObject())
{
if (TimerObj* pTimerObj = (TimerObj*)pJSObj->GetEmbedObject())
{
@@ -717,8 +702,6 @@ FX_BOOL app::goForward(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Valu
FX_BOOL app::mailMsg(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
CJS_Context* pContext = (CJS_Context*)cc;
- ASSERT(pContext != NULL);
-
v8::Isolate* isolate = GetIsolate(cc);
FX_BOOL bUI = TRUE;
@@ -727,42 +710,48 @@ FX_BOOL app::mailMsg(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value&
CFX_WideString cBcc = L"";
CFX_WideString cSubject = L"";
CFX_WideString cMsg = L"";
- if(params.size() < 2)
- return FALSE;
-
- bUI = params.size()>=1?(int)params[0]:TRUE;
- cTo = params.size()>=2?(const wchar_t*)(FX_LPCWSTR)params[1].operator CFX_WideString():L"";
- cCc = params.size()>=3?(const wchar_t*)(FX_LPCWSTR)params[2].operator CFX_WideString():L"";
- cBcc = params.size()>=4?(const wchar_t*)(FX_LPCWSTR)params[3].operator CFX_WideString():L"";
- cSubject = params.size()>=5?(const wchar_t*)(FX_LPCWSTR)params[4].operator CFX_WideString():L"";
- cMsg = params.size()>=6?(const wchar_t*)(FX_LPCWSTR)params[5].operator CFX_WideString():L"";
+ if (params.size() < 1)
+ return FALSE;
if (params[0].GetType() == VT_object)
{
- JSObject pObj = (JSObject)params[0];
+ JSObject pObj = params[0].ToV8Object();
- v8::Handle<v8::Value> pValue = JS_GetObjectElement(isolate,pObj, L"bUI");
- bUI = (int)CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue));
+ v8::Handle<v8::Value> pValue = JS_GetObjectElement(isolate, pObj, L"bUI");
+ bUI = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToBool();
pValue = JS_GetObjectElement(isolate, pObj, L"cTo");
- cTo = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).operator CFX_WideString();
-
- pValue = JS_GetObjectElement(isolate,pObj, L"cCc");
- cCc = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).operator CFX_WideString();
-
- pValue = JS_GetObjectElement(isolate,pObj, L"cBcc");
- cBcc = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).operator CFX_WideString();
-
- pValue = JS_GetObjectElement(isolate,pObj, L"cSubject");
- cSubject = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).operator CFX_WideString();
-
- pValue = JS_GetObjectElement(isolate,pObj, L"cMsg");
- cMsg = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).operator CFX_WideString();
+ cTo = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString();
+
+ pValue = JS_GetObjectElement(isolate, pObj, L"cCc");
+ cCc = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString();
+
+ pValue = JS_GetObjectElement(isolate, pObj, L"cBcc");
+ cBcc = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString();
+
+ pValue = JS_GetObjectElement(isolate, pObj, L"cSubject");
+ cSubject = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString();
+
+ pValue = JS_GetObjectElement(isolate, pObj, L"cMsg");
+ cMsg = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString();
+ } else {
+ if (params.size() < 2)
+ return FALSE;
+
+ bUI = params[0].ToBool();
+ cTo = params[1].ToCFXWideString();
+
+ if (params.size() >= 3)
+ cCc = params[2].ToCFXWideString();
+ if (params.size() >= 4)
+ cBcc = params[3].ToCFXWideString();
+ if (params.size() >= 5)
+ cSubject = params[4].ToCFXWideString();
+ if (params.size() >= 6)
+ cMsg = params[5].ToCFXWideString();
}
-
-
CJS_Runtime* pRuntime = pContext->GetJSRuntime();
ASSERT(pRuntime != NULL);
@@ -771,10 +760,8 @@ FX_BOOL app::mailMsg(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value&
pRuntime->BeginBlock();
pApp->JS_docmailForm(NULL, 0, bUI, cTo.c_str(), cSubject.c_str(), cCc.c_str(), cBcc.c_str(), cMsg.c_str());
- ///////////////////////////////////////////////////////////////////////////////////////////////
pRuntime->EndBlock();
- //return bRet;
return FALSE;
}
@@ -864,40 +851,40 @@ FX_BOOL app::response(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value
int iLength = params.size();
if (iLength > 0 && params[0].GetType() == VT_object)
{
- JSObject pObj = (JSObject )params[0];
+ JSObject pObj = params[0].ToV8Object();
v8::Handle<v8::Value> pValue = JS_GetObjectElement(isolate,pObj,L"cQuestion");
- swQuestion = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).operator CFX_WideString();
+ swQuestion = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).ToCFXWideString();
pValue = JS_GetObjectElement(isolate,pObj,L"cTitle");
- swTitle = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).operator CFX_WideString();
+ swTitle = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).ToCFXWideString();
pValue = JS_GetObjectElement(isolate,pObj,L"cDefault");
- swDefault = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).operator CFX_WideString();
+ swDefault = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).ToCFXWideString();
pValue = JS_GetObjectElement(isolate,pObj,L"cLabel");
- swLabel = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).operator CFX_WideString();
+ swLabel = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).ToCFXWideString();
pValue = JS_GetObjectElement(isolate,pObj,L"bPassword");
- bPassWord = (bool)CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue));
+ bPassWord = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).ToBool();
}
else
{
switch(iLength)
{
case 5:
- swLabel = params[4];
+ swLabel = params[4].ToCFXWideString();
// FALLTHROUGH
case 4:
- bPassWord = params[3];
+ bPassWord = params[3].ToBool();
// FALLTHROUGH
case 3:
- swDefault = params[2];
+ swDefault = params[2].ToCFXWideString();
// FALLTHROUGH
case 2:
- swTitle = params[1];
+ swTitle = params[1].ToCFXWideString();
// FALLTHROUGH
case 1:
- swQuestion = params[0];
+ swQuestion = params[0].ToCFXWideString();
// FALLTHROUGH
default:
break;
diff --git a/fpdfsdk/src/javascript/color.cpp b/fpdfsdk/src/javascript/color.cpp
index a338624bd9..ddf6ed4361 100644
--- a/fpdfsdk/src/javascript/color.cpp
+++ b/fpdfsdk/src/javascript/color.cpp
@@ -104,9 +104,8 @@ void color::ConvertArrayToPWLColor(CJS_Array& array, CPWL_Color& color)
if (nArrayLen < 1) return;
CJS_Value value(array.GetIsolate());
- CFX_ByteString sSpace;
array.GetElement(0, value);
- sSpace = value;
+ CFX_ByteString sSpace = value.ToCFXByteString();
double d1 = 0;
double d2 = 0;
@@ -116,25 +115,25 @@ void color::ConvertArrayToPWLColor(CJS_Array& array, CPWL_Color& color)
if (nArrayLen > 1)
{
array.GetElement(1, value);
- d1 = value;
+ d1 = value.ToDouble();
}
if (nArrayLen > 2)
{
array.GetElement(2, value);
- d2 = value;
+ d2 = value.ToDouble();
}
if (nArrayLen > 3)
{
array.GetElement(3, value);
- d3 = value;
+ d3 = value.ToDouble();
}
if (nArrayLen > 4)
{
array.GetElement(4, value);
- d4 = value;
+ d4 = value.ToDouble();
}
if (sSpace == "T")
@@ -199,10 +198,9 @@ FX_BOOL color::convert(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Valu
CPWL_Color crSource;
ConvertArrayToPWLColor(aSource, crSource);
- CFX_ByteString sDestSpace = params[1];
-
+ CFX_ByteString sDestSpace = params[1].ToCFXByteString();
int nColorType = COLORTYPE_TRANSPARENT;
-
+
if (sDestSpace == "T")
{
nColorType = COLORTYPE_TRANSPARENT;
diff --git a/fpdfsdk/src/javascript/event.cpp b/fpdfsdk/src/javascript/event.cpp
index 620b43ebfa..fb57e741ee 100644
--- a/fpdfsdk/src/javascript/event.cpp
+++ b/fpdfsdk/src/javascript/event.cpp
@@ -352,7 +352,7 @@ FX_BOOL event::value(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sErro
CFX_WideString & val = pEvent->Value();
if (vp.IsSetting())
{
- val = vp;
+ vp >> val;
}
else
{
diff --git a/fpdfsdk/src/javascript/global.cpp b/fpdfsdk/src/javascript/global.cpp
index 4ed0d66b1e..6b5d5e2725 100644
--- a/fpdfsdk/src/javascript/global.cpp
+++ b/fpdfsdk/src/javascript/global.cpp
@@ -174,7 +174,7 @@ FX_BOOL global_alternate::DoProperty(IFXJS_Context* cc, FX_LPCWSTR propname, CJS
{
bool bData;
vp >> bData;
- return SetGlobalVariables(sPropName, JS_GLOBALDATA_TYPE_BOOLEAN, 0, (bool)vp, "", v8::Handle<v8::Object>(), FALSE);
+ return SetGlobalVariables(sPropName, JS_GLOBALDATA_TYPE_BOOLEAN, 0, bData, "", v8::Handle<v8::Object>(), FALSE);
}
case VT_string:
{
@@ -184,20 +184,9 @@ FX_BOOL global_alternate::DoProperty(IFXJS_Context* cc, FX_LPCWSTR propname, CJS
}
case VT_object:
{
- JSObject pData = (JSObject)vp;
+ JSObject pData;
+ vp >> pData;
return SetGlobalVariables(sPropName, JS_GLOBALDATA_TYPE_OBJECT, 0, false, "", pData, FALSE);
-// else
-// {
-// if (vp.IsArrayObject())
-// {
-// CJS_Array array;
-// vp.ConvertToArray(array);
-// return SetGlobalVariables(sPropName, JS_GLOBALDATA_TYPE_OBJECT, 0, false, "",
-// (Dobject*)(Darray*)array, FALSE);
-// }
-// else
-// return FALSE;
-// }
}
case VT_null:
{
@@ -278,14 +267,14 @@ FX_BOOL global_alternate::setPersistent(IFXJS_Context* cc, const CJS_Parameters&
return FALSE;
}
- CFX_ByteString sName = params[0];
+ CFX_ByteString sName = params[0].ToCFXByteString();
js_global_data* pData = NULL;
if (m_mapGlobal.Lookup(sName, (FX_LPVOID&)pData))
{
if (pData && !pData->bDeleted)
{
- pData->bPersistent = (bool)params[1];
+ pData->bPersistent = params[1].ToBool();
return TRUE;
}
}
@@ -434,7 +423,7 @@ void global_alternate::ObjectToArray(v8::Handle<v8::Object> pObj, CJS_GlobalVari
break;
case VT_string:
{
- CFX_ByteString sValue = CJS_Value(isolate, v, VT_string);
+ CFX_ByteString sValue = CJS_Value(isolate, v, VT_string).ToCFXByteString();
CJS_KeyValue* pObjElement = new CJS_KeyValue;
pObjElement->nType = JS_GLOBALDATA_TYPE_STRING;
pObjElement->sKey = sKey;
diff --git a/fpdfsdk/src/javascript/util.cpp b/fpdfsdk/src/javascript/util.cpp
index 0ac98ddbac..6898d0c1a2 100644
--- a/fpdfsdk/src/javascript/util.cpp
+++ b/fpdfsdk/src/javascript/util.cpp
@@ -142,7 +142,7 @@ FX_BOOL util::printf(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value&
int iSize = params.size();
if (iSize < 1)
return FALSE;
- std::wstring c_ConvChar((const wchar_t*)(FX_LPCWSTR)params[0].operator CFX_WideString());
+ std::wstring c_ConvChar(params[0].ToCFXWideString().c_str());
std::vector<std::wstring> c_strConvers;
int iOffset = 0;
int iOffend = 0;
@@ -182,13 +182,13 @@ FX_BOOL util::printf(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value&
switch (ParstDataType(&c_strFormat))
{
case UTIL_INT:
- strSegment.Format(c_strFormat.c_str(),(int)params[iIndex]);
+ strSegment.Format(c_strFormat.c_str(), params[iIndex].ToInt());
break;
case UTIL_DOUBLE:
- strSegment.Format(c_strFormat.c_str(),(double)params[iIndex]);
+ strSegment.Format(c_strFormat.c_str(), params[iIndex].ToDouble());
break;
case UTIL_STRING:
- strSegment.Format(c_strFormat.c_str(),(FX_LPCWSTR)params[iIndex].operator CFX_WideString());
+ strSegment.Format(c_strFormat.c_str(), params[iIndex].ToCFXWideString().c_str());
break;
default:
strSegment.Format(L"%S", c_strFormat.c_str());
@@ -229,8 +229,7 @@ FX_BOOL util::printd(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value&
if (p1.GetType() == VT_number)
{
- int nFormat = p1;
-
+ int nFormat = p1.ToInt();
CFX_WideString swResult;
switch (nFormat)
@@ -271,13 +270,12 @@ FX_BOOL util::printd(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value&
}
else if (p1.GetType() == VT_string)
{
- std::basic_string<wchar_t> cFormat = (FX_LPCWSTR)p1.operator CFX_WideString();
+ std::basic_string<wchar_t> cFormat = p1.ToCFXWideString().c_str();
bool bXFAPicture = false;
if (iSize > 2)
{
- //CJS_Value value;
- bXFAPicture = params[2];
+ bXFAPicture = params[2].ToBool();
}
if (bXFAPicture)
@@ -467,8 +465,8 @@ FX_BOOL util::printx(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value&
int iSize = params.size();
if (iSize<2)
return FALSE;
- CFX_WideString sFormat = params[0].operator CFX_WideString();
- CFX_WideString sSource = params[1].operator CFX_WideString();
+ CFX_WideString sFormat = params[0].ToCFXWideString();
+ CFX_WideString sSource = params[1].ToCFXWideString();
std::string cFormat = CFX_ByteString::FromUnicode(sFormat).c_str();
std::string cSource = CFX_ByteString::FromUnicode(sSource).c_str();
std::string cDest;
@@ -582,9 +580,9 @@ FX_BOOL util::scand(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value&
int iSize = params.size();
if (iSize < 2)
return FALSE;
- CFX_WideString sFormat = params[0].operator CFX_WideString();
- CFX_WideString sDate = params[1].operator CFX_WideString();
+ CFX_WideString sFormat = params[0].ToCFXWideString();
+ CFX_WideString sDate = params[1].ToCFXWideString();
double dDate = JS_GetDateTime();
if (sDate.GetLength() > 0)
{
@@ -638,7 +636,7 @@ FX_BOOL util::byteToChar(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Va
int iSize = params.size();
if (iSize == 0)
return FALSE;
- int nByte = (int)params[0];
+ int nByte = params[0].ToInt();
unsigned char cByte = (unsigned char)nByte;
CFX_WideString csValue;
csValue.Format(L"%c", cByte);