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 "../../../third_party/base/nonstd_unique_ptr.h" | 7 #include "../../../third_party/base/nonstd_unique_ptr.h" |
8 #include "../../include/javascript/JavaScript.h" | 8 #include "../../include/javascript/JavaScript.h" |
9 #include "../../include/javascript/IJavaScript.h" | 9 #include "../../include/javascript/IJavaScript.h" |
10 #include "../../include/javascript/JS_Define.h" | 10 #include "../../include/javascript/JS_Define.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) : |
Lei Zhang
2015/07/16 17:05:06
':' on next line
Tom Sepez
2015/07/16 18:01:28
Done.
| |
123 CJS_EmbedObj(pJSObject), | |
123 m_bCalculate(true), | 124 m_bCalculate(true), |
124 m_bRuntimeHighLight(false) | 125 m_bRuntimeHighLight(false) |
125 // m_pMenuHead(NULL) | |
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()) |
Lei Zhang
2015/07/16 17:05:06
if (!vp.IsGetting())
return FALSE:
// uninden
Tom Sepez
2015/07/16 18:01:28
Done.
| |
140 » { | 140 { |
141 CJS_Context* pContext = (CJS_Context *)cc; | |
142 CPDFDoc_Environment* pApp = pContext->GetReaderApp(); | |
143 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | |
144 CPDFSDK_Document* pCurDoc = pContext->GetReaderDocument(); | |
145 CJS_Array aDocs(pRuntime->GetIsolate()); | |
146 if (CPDFSDK_Document* pDoc = pApp->GetSDKDocument()) | |
147 { | |
148 CJS_Document* pJSDocument = NULL; | |
149 if (pDoc == pCurDoc) | |
150 { | |
151 JSFXObject pObj = JS_GetThisObj(*pRuntime); | |
152 if (JS_GetObjDefnID(pObj) == JS_GetObjDefnID(*pRuntime, L"Docume nt")) | |
153 pJSDocument = (CJS_Document*)JS_GetPrivate(pRuntime->GetIsol ate(),pObj); | |
154 } | |
155 else | |
156 { | |
157 JSFXObject pObj = JS_NewFxDynamicObj(*pRuntime, pContext, JS_Get ObjDefnID(*pRuntime,L"Document")); | |
158 pJSDocument = (CJS_Document*)JS_GetPrivate(pRuntime->GetIsolate( ),pObj); | |
159 ASSERT(pJSDocument != NULL); | |
160 } | |
161 aDocs.SetElement(0,CJS_Value(pRuntime->GetIsolate(),pJSDocument)); | |
162 } | |
163 if (aDocs.GetLength() > 0) | |
164 vp << aDocs; | |
165 else | |
166 vp.SetNull(); | |
141 | 167 |
142 » » CJS_Context* pContext = (CJS_Context *)cc; | 168 return TRUE; |
143 » » ASSERT(pContext != NULL); | 169 } |
144 | 170 return FALSE; |
145 » » CPDFDoc_Environment* pApp = pContext->GetReaderApp(); | |
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 } | 171 } |
194 | 172 |
195 FX_BOOL app::calculate(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sEr ror) | 173 FX_BOOL app::calculate(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sEr ror) |
196 { | 174 { |
197 if (vp.IsSetting()) | 175 if (vp.IsSetting()) |
198 { | 176 { |
199 bool bVP; | 177 bool bVP; |
200 vp >> bVP; | 178 vp >> bVP; |
201 m_bCalculate = (FX_BOOL)bVP; | 179 m_bCalculate = (FX_BOOL)bVP; |
202 | 180 |
203 CJS_Context* pContext = (CJS_Context*)cc; | 181 CJS_Context* pContext = (CJS_Context*)cc; |
204 ASSERT(pContext != NULL); | |
205 | |
206 CPDFDoc_Environment* pApp = pContext->GetReaderApp(); | 182 CPDFDoc_Environment* pApp = pContext->GetReaderApp(); |
207 ASSERT(pApp != NULL); | |
208 | |
209 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 183 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
210 ASSERT(pRuntime != NULL); | |
211 | |
212 CJS_Array aDocs(pRuntime->GetIsolate()); | 184 CJS_Array aDocs(pRuntime->GetIsolate()); |
213 » » if (CPDFSDK_Document* pDoc = pApp->GetCurrentDoc()) | 185 » » if (CPDFSDK_Document* pDoc = pApp->GetSDKDocument()) |
214 » » { | 186 » » » 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 } | 187 } |
220 else | 188 else |
221 { | 189 { |
222 vp << (bool)m_bCalculate; | 190 vp << (bool)m_bCalculate; |
223 } | 191 } |
224 | |
225 return TRUE; | 192 return TRUE; |
226 } | 193 } |
227 | 194 |
228 FX_BOOL app::formsVersion(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) | 195 FX_BOOL app::formsVersion(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) |
229 { | 196 { |
230 if (vp.IsGetting()) | 197 if (vp.IsGetting()) |
231 { | 198 { |
232 vp << JS_NUM_FORMSVERSION; | 199 vp << JS_NUM_FORMSVERSION; |
233 return TRUE; | 200 return TRUE; |
234 } | 201 } |
(...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
920 | 887 |
921 FX_BOOL app::media(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) | 888 FX_BOOL app::media(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) |
922 { | 889 { |
923 return FALSE; | 890 return FALSE; |
924 } | 891 } |
925 | 892 |
926 FX_BOOL app::execDialog(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Val ue& vRet, CFX_WideString& sError) | 893 FX_BOOL app::execDialog(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Val ue& vRet, CFX_WideString& sError) |
927 { | 894 { |
928 return TRUE; | 895 return TRUE; |
929 } | 896 } |
OLD | NEW |