| 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 "../../include/javascript/JavaScript.h" | 7 #include "../../include/javascript/JavaScript.h" |
| 8 #include "../../include/javascript/IJavaScript.h" | 8 #include "../../include/javascript/IJavaScript.h" |
| 9 #include "../../include/javascript/JS_Define.h" | 9 #include "../../include/javascript/JS_Define.h" |
| 10 #include "../../include/javascript/JS_Object.h" | 10 #include "../../include/javascript/JS_Object.h" |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 JS_STATIC_METHOD_ENTRY(openFDF) | 112 JS_STATIC_METHOD_ENTRY(openFDF) |
| 113 JS_STATIC_METHOD_ENTRY(popUpMenuEx) | 113 JS_STATIC_METHOD_ENTRY(popUpMenuEx) |
| 114 JS_STATIC_METHOD_ENTRY(popUpMenu) | 114 JS_STATIC_METHOD_ENTRY(popUpMenu) |
| 115 JS_STATIC_METHOD_ENTRY(response) | 115 JS_STATIC_METHOD_ENTRY(response) |
| 116 JS_STATIC_METHOD_ENTRY(setInterval) | 116 JS_STATIC_METHOD_ENTRY(setInterval) |
| 117 JS_STATIC_METHOD_ENTRY(setTimeOut) | 117 JS_STATIC_METHOD_ENTRY(setTimeOut) |
| 118 END_JS_STATIC_METHOD() | 118 END_JS_STATIC_METHOD() |
| 119 | 119 |
| 120 IMPLEMENT_JS_CLASS(CJS_App,app) | 120 IMPLEMENT_JS_CLASS(CJS_App,app) |
| 121 | 121 |
| 122 app::app(CJS_Object * pJSObject) : CJS_EmbedObj(pJSObject) , | 122 app::app(CJS_Object * pJSObject) |
| 123 » m_bCalculate(true), | 123 : CJS_EmbedObj(pJSObject), |
| 124 » m_bRuntimeHighLight(false) | 124 m_bCalculate(true), |
| 125 //» m_pMenuHead(NULL) | 125 m_bRuntimeHighLight(false) |
| 126 { | 126 { |
| 127 } | 127 } |
| 128 | 128 |
| 129 app::~app(void) | 129 app::~app(void) |
| 130 { | 130 { |
| 131 for (int i=0,sz=m_aTimer.GetSize(); i<sz; i++) | 131 for (int i=0,sz=m_aTimer.GetSize(); i<sz; i++) |
| 132 delete m_aTimer[i]; | 132 delete m_aTimer[i]; |
| 133 | 133 |
| 134 m_aTimer.RemoveAll(); | 134 m_aTimer.RemoveAll(); |
| 135 } | 135 } |
| 136 | 136 |
| 137 FX_BOOL app::activeDocs(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sE
rror) | 137 FX_BOOL app::activeDocs(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sE
rror) |
| 138 { | 138 { |
| 139 » if (vp.IsGetting()) | 139 if (!vp.IsGetting()) |
| 140 » { | 140 return FALSE; |
| 141 | 141 |
| 142 » » CJS_Context* pContext = (CJS_Context *)cc; | 142 CJS_Context* pContext = (CJS_Context *)cc; |
| 143 » » ASSERT(pContext != NULL); | 143 CPDFDoc_Environment* pApp = pContext->GetReaderApp(); |
| 144 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
| 145 CPDFSDK_Document* pCurDoc = pContext->GetReaderDocument(); |
| 146 CJS_Array aDocs(pRuntime->GetIsolate()); |
| 147 if (CPDFSDK_Document* pDoc = pApp->GetSDKDocument()) |
| 148 { |
| 149 CJS_Document* pJSDocument = NULL; |
| 150 if (pDoc == pCurDoc) |
| 151 { |
| 152 JSFXObject pObj = JS_GetThisObj(*pRuntime); |
| 153 if (JS_GetObjDefnID(pObj) == JS_GetObjDefnID(*pRuntime, L"Document")
) |
| 154 pJSDocument = (CJS_Document*)JS_GetPrivate(pRuntime->GetIsolate(
),pObj); |
| 155 } |
| 156 else |
| 157 { |
| 158 JSFXObject pObj = JS_NewFxDynamicObj(*pRuntime, pContext, JS_GetObjD
efnID(*pRuntime,L"Document")); |
| 159 pJSDocument = (CJS_Document*)JS_GetPrivate(pRuntime->GetIsolate(),pO
bj); |
| 160 ASSERT(pJSDocument != NULL); |
| 161 } |
| 162 aDocs.SetElement(0,CJS_Value(pRuntime->GetIsolate(),pJSDocument)); |
| 163 } |
| 164 if (aDocs.GetLength() > 0) |
| 165 vp << aDocs; |
| 166 else |
| 167 vp.SetNull(); |
| 144 | 168 |
| 145 » » CPDFDoc_Environment* pApp = pContext->GetReaderApp(); | 169 return TRUE; |
| 146 » » ASSERT(pApp != NULL); | |
| 147 | |
| 148 » » CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | |
| 149 » » ASSERT(pRuntime != NULL); | |
| 150 | |
| 151 » » CPDFSDK_Document* pCurDoc = pContext->GetReaderDocument(); | |
| 152 | |
| 153 » » CJS_Array aDocs(pRuntime->GetIsolate()); | |
| 154 //» » int iNumDocs = pApp->CountDocuments(); | |
| 155 | |
| 156 // » » for(int iIndex = 0; iIndex<iNumDocs; iIndex++) | |
| 157 // » » { | |
| 158 » » » CPDFSDK_Document* pDoc = pApp->GetCurrentDoc(); | |
| 159 » » » if (pDoc) | |
| 160 » » » { | |
| 161 » » » » CJS_Document * pJSDocument = NULL; | |
| 162 | |
| 163 » » » » if (pDoc == pCurDoc) | |
| 164 » » » » { | |
| 165 » » » » » JSFXObject pObj = JS_GetThisObj(*pRuntim
e); | |
| 166 | |
| 167 » » » » » if (JS_GetObjDefnID(pObj) == JS_GetObjDe
fnID(*pRuntime, L"Document")) | |
| 168 » » » » » { | |
| 169 » » » » » » pJSDocument = (CJS_Document*)JS_
GetPrivate(pRuntime->GetIsolate(),pObj); | |
| 170 » » » » » } | |
| 171 » » » » } | |
| 172 » » » » else | |
| 173 » » » » { | |
| 174 » » » » » JSFXObject pObj = JS_NewFxDynamicObj(*pR
untime, pContext, JS_GetObjDefnID(*pRuntime,L"Document")); | |
| 175 » » » » » pJSDocument = (CJS_Document*)JS_GetPriva
te(pRuntime->GetIsolate(),pObj); | |
| 176 » » » » » ASSERT(pJSDocument != NULL); | |
| 177 | |
| 178 | |
| 179 » » » » » //» » » pDocument->Attac
hDoc(pDoc); | |
| 180 » » » » } | |
| 181 | |
| 182 » » » » aDocs.SetElement(0,CJS_Value(pRuntime->GetIsolat
e(),pJSDocument)); | |
| 183 » » » } | |
| 184 » //» » } | |
| 185 | |
| 186 » » if (aDocs.GetLength() > 0) | |
| 187 » » » vp << aDocs; | |
| 188 » » else | |
| 189 » » » vp.SetNull(); | |
| 190 » » return TRUE; | |
| 191 » } | |
| 192 » return FALSE; | |
| 193 } | 170 } |
| 194 | 171 |
| 195 FX_BOOL app::calculate(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sEr
ror) | 172 FX_BOOL app::calculate(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sEr
ror) |
| 196 { | 173 { |
| 197 if (vp.IsSetting()) | 174 if (vp.IsSetting()) |
| 198 { | 175 { |
| 199 bool bVP; | 176 bool bVP; |
| 200 vp >> bVP; | 177 vp >> bVP; |
| 201 m_bCalculate = (FX_BOOL)bVP; | 178 m_bCalculate = (FX_BOOL)bVP; |
| 202 | 179 |
| 203 CJS_Context* pContext = (CJS_Context*)cc; | 180 CJS_Context* pContext = (CJS_Context*)cc; |
| 204 ASSERT(pContext != NULL); | |
| 205 | |
| 206 CPDFDoc_Environment* pApp = pContext->GetReaderApp(); | 181 CPDFDoc_Environment* pApp = pContext->GetReaderApp(); |
| 207 ASSERT(pApp != NULL); | |
| 208 | |
| 209 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 182 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
| 210 ASSERT(pRuntime != NULL); | |
| 211 | |
| 212 CJS_Array aDocs(pRuntime->GetIsolate()); | 183 CJS_Array aDocs(pRuntime->GetIsolate()); |
| 213 » » if (CPDFSDK_Document* pDoc = pApp->GetCurrentDoc()) | 184 » » if (CPDFSDK_Document* pDoc = pApp->GetSDKDocument()) |
| 214 » » { | 185 » » » pDoc->GetInterForm()->EnableCalculate((FX_BOOL)m_bCalcul
ate); |
| 215 » » » CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDoc
->GetInterForm(); | |
| 216 » » » ASSERT(pInterForm != NULL); | |
| 217 » » » pInterForm->EnableCalculate((FX_BOOL)m_bCalculate); | |
| 218 » » } | |
| 219 } | 186 } |
| 220 else | 187 else |
| 221 { | 188 { |
| 222 vp << (bool)m_bCalculate; | 189 vp << (bool)m_bCalculate; |
| 223 } | 190 } |
| 224 | |
| 225 return TRUE; | 191 return TRUE; |
| 226 } | 192 } |
| 227 | 193 |
| 228 FX_BOOL app::formsVersion(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString&
sError) | 194 FX_BOOL app::formsVersion(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString&
sError) |
| 229 { | 195 { |
| 230 if (vp.IsGetting()) | 196 if (vp.IsGetting()) |
| 231 { | 197 { |
| 232 vp << JS_NUM_FORMSVERSION; | 198 vp << JS_NUM_FORMSVERSION; |
| 233 return TRUE; | 199 return TRUE; |
| 234 } | 200 } |
| (...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 931 | 897 |
| 932 FX_BOOL app::media(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) | 898 FX_BOOL app::media(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) |
| 933 { | 899 { |
| 934 return FALSE; | 900 return FALSE; |
| 935 } | 901 } |
| 936 | 902 |
| 937 FX_BOOL app::execDialog(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Val
ue& vRet, CFX_WideString& sError) | 903 FX_BOOL app::execDialog(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Val
ue& vRet, CFX_WideString& sError) |
| 938 { | 904 { |
| 939 return TRUE; | 905 return TRUE; |
| 940 } | 906 } |
| OLD | NEW |