Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #include "fpdfsdk/javascript/app.h" | 7 #include "fpdfsdk/javascript/app.h" |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 106 FX_BOOL app::activeDocs(IJS_Context* cc, | 106 FX_BOOL app::activeDocs(IJS_Context* cc, |
| 107 CJS_PropValue& vp, | 107 CJS_PropValue& vp, |
| 108 CFX_WideString& sError) { | 108 CFX_WideString& sError) { |
| 109 if (!vp.IsGetting()) | 109 if (!vp.IsGetting()) |
| 110 return FALSE; | 110 return FALSE; |
| 111 | 111 |
| 112 CJS_Context* pContext = (CJS_Context*)cc; | 112 CJS_Context* pContext = (CJS_Context*)cc; |
| 113 CPDFDoc_Environment* pApp = pContext->GetReaderApp(); | 113 CPDFDoc_Environment* pApp = pContext->GetReaderApp(); |
| 114 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 114 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
| 115 CPDFSDK_Document* pCurDoc = pContext->GetReaderDocument(); | 115 CPDFSDK_Document* pCurDoc = pContext->GetReaderDocument(); |
| 116 CJS_Array aDocs(pRuntime); | 116 CJS_Array aDocs; |
| 117 if (CPDFSDK_Document* pDoc = pApp->GetSDKDocument()) { | 117 if (CPDFSDK_Document* pDoc = pApp->GetSDKDocument()) { |
| 118 CJS_Document* pJSDocument = nullptr; | 118 CJS_Document* pJSDocument = nullptr; |
| 119 if (pDoc == pCurDoc) { | 119 if (pDoc == pCurDoc) { |
| 120 v8::Local<v8::Object> pObj = FXJS_GetThisObj(pRuntime->GetIsolate()); | 120 v8::Local<v8::Object> pObj = FXJS_GetThisObj(pRuntime->GetIsolate()); |
| 121 if (FXJS_GetObjDefnID(pObj) == CJS_Document::g_nObjDefnID) | 121 if (FXJS_GetObjDefnID(pObj) == CJS_Document::g_nObjDefnID) |
| 122 pJSDocument = | 122 pJSDocument = |
| 123 (CJS_Document*)FXJS_GetPrivate(pRuntime->GetIsolate(), pObj); | 123 (CJS_Document*)FXJS_GetPrivate(pRuntime->GetIsolate(), pObj); |
| 124 } else { | 124 } else { |
| 125 v8::Local<v8::Object> pObj = FXJS_NewFxDynamicObj( | 125 v8::Local<v8::Object> pObj = FXJS_NewFxDynamicObj( |
| 126 pRuntime->GetIsolate(), pRuntime, CJS_Document::g_nObjDefnID); | 126 pRuntime->GetIsolate(), pRuntime, CJS_Document::g_nObjDefnID); |
| 127 pJSDocument = | 127 pJSDocument = |
| 128 (CJS_Document*)FXJS_GetPrivate(pRuntime->GetIsolate(), pObj); | 128 (CJS_Document*)FXJS_GetPrivate(pRuntime->GetIsolate(), pObj); |
| 129 ASSERT(pJSDocument); | 129 ASSERT(pJSDocument); |
| 130 } | 130 } |
| 131 aDocs.SetElement(0, CJS_Value(pRuntime, pJSDocument)); | 131 aDocs.SetElement(pRuntime->GetIsolate(), 0, |
| 132 CJS_Value(pRuntime, pJSDocument)); | |
| 132 } | 133 } |
| 133 if (aDocs.GetLength() > 0) | 134 if (aDocs.GetLength() > 0) |
| 134 vp << aDocs; | 135 vp << aDocs; |
| 135 else | 136 else |
| 136 vp.SetNull(); | 137 vp.SetNull(); |
| 137 | 138 |
| 138 return TRUE; | 139 return TRUE; |
| 139 } | 140 } |
| 140 | 141 |
| 141 FX_BOOL app::calculate(IJS_Context* cc, | 142 FX_BOOL app::calculate(IJS_Context* cc, |
| 142 CJS_PropValue& vp, | 143 CJS_PropValue& vp, |
| 143 CFX_WideString& sError) { | 144 CFX_WideString& sError) { |
| 144 if (vp.IsSetting()) { | 145 if (vp.IsSetting()) { |
| 145 bool bVP; | 146 bool bVP; |
| 146 vp >> bVP; | 147 vp >> bVP; |
| 147 m_bCalculate = (FX_BOOL)bVP; | 148 m_bCalculate = (FX_BOOL)bVP; |
| 148 | 149 |
| 149 CJS_Context* pContext = (CJS_Context*)cc; | 150 CJS_Context* pContext = (CJS_Context*)cc; |
| 150 CPDFDoc_Environment* pApp = pContext->GetReaderApp(); | 151 CPDFDoc_Environment* pApp = pContext->GetReaderApp(); |
| 151 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 152 // CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
|
Lei Zhang
2016/08/05 17:41:58
Delete?
Tom Sepez
2016/08/08 16:25:50
Done.
| |
| 152 CJS_Array aDocs(pRuntime); | 153 CJS_Array aDocs; |
| 153 if (CPDFSDK_Document* pDoc = pApp->GetSDKDocument()) | 154 if (CPDFSDK_Document* pDoc = pApp->GetSDKDocument()) |
| 154 pDoc->GetInterForm()->EnableCalculate((FX_BOOL)m_bCalculate); | 155 pDoc->GetInterForm()->EnableCalculate((FX_BOOL)m_bCalculate); |
| 155 } else { | 156 } else { |
| 156 vp << (bool)m_bCalculate; | 157 vp << (bool)m_bCalculate; |
| 157 } | 158 } |
| 158 return TRUE; | 159 return TRUE; |
| 159 } | 160 } |
| 160 | 161 |
| 161 FX_BOOL app::formsVersion(IJS_Context* cc, | 162 FX_BOOL app::formsVersion(IJS_Context* cc, |
| 162 CJS_PropValue& vp, | 163 CJS_PropValue& vp, |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 281 std::vector<CJS_Value> newParams = JS_ExpandKeywordParams( | 282 std::vector<CJS_Value> newParams = JS_ExpandKeywordParams( |
| 282 pRuntime, params, 4, L"cMsg", L"nIcon", L"nType", L"cTitle"); | 283 pRuntime, params, 4, L"cMsg", L"nIcon", L"nType", L"cTitle"); |
| 283 | 284 |
| 284 if (newParams[0].GetType() == CJS_Value::VT_unknown) { | 285 if (newParams[0].GetType() == CJS_Value::VT_unknown) { |
| 285 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); | 286 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); |
| 286 return FALSE; | 287 return FALSE; |
| 287 } | 288 } |
| 288 | 289 |
| 289 CFX_WideString swMsg; | 290 CFX_WideString swMsg; |
| 290 if (newParams[0].GetType() == CJS_Value::VT_object) { | 291 if (newParams[0].GetType() == CJS_Value::VT_object) { |
| 291 CJS_Array carray(pRuntime); | 292 CJS_Array carray; |
| 292 if (newParams[0].ConvertToArray(carray)) { | 293 if (newParams[0].ConvertToArray(carray)) { |
| 293 swMsg = L"["; | 294 swMsg = L"["; |
| 294 CJS_Value element(pRuntime); | 295 CJS_Value element(pRuntime); |
| 295 for (int i = 0; i < carray.GetLength(); ++i) { | 296 for (int i = 0; i < carray.GetLength(); ++i) { |
| 296 if (i) | 297 if (i) |
| 297 swMsg += L", "; | 298 swMsg += L", "; |
| 298 carray.GetElement(i, element); | 299 carray.GetElement(pRuntime->GetIsolate(), i, element); |
| 299 swMsg += element.ToCFXWideString(); | 300 swMsg += element.ToCFXWideString(); |
| 300 } | 301 } |
| 301 swMsg += L"]"; | 302 swMsg += L"]"; |
| 302 } else { | 303 } else { |
| 303 swMsg = newParams[0].ToCFXWideString(); | 304 swMsg = newParams[0].ToCFXWideString(); |
| 304 } | 305 } |
| 305 } else { | 306 } else { |
| 306 swMsg = newParams[0].ToCFXWideString(); | 307 swMsg = newParams[0].ToCFXWideString(); |
| 307 } | 308 } |
| 308 | 309 |
| (...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 717 FX_BOOL app::media(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) { | 718 FX_BOOL app::media(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) { |
| 718 return FALSE; | 719 return FALSE; |
| 719 } | 720 } |
| 720 | 721 |
| 721 FX_BOOL app::execDialog(IJS_Context* cc, | 722 FX_BOOL app::execDialog(IJS_Context* cc, |
| 722 const std::vector<CJS_Value>& params, | 723 const std::vector<CJS_Value>& params, |
| 723 CJS_Value& vRet, | 724 CJS_Value& vRet, |
| 724 CFX_WideString& sError) { | 725 CFX_WideString& sError) { |
| 725 return TRUE; | 726 return TRUE; |
| 726 } | 727 } |
| OLD | NEW |