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 27 matching lines...) Expand all Loading... |
38 END_JS_STATIC_PROP() | 38 END_JS_STATIC_PROP() |
39 | 39 |
40 BEGIN_JS_STATIC_METHOD(CJS_PrintParamsObj) | 40 BEGIN_JS_STATIC_METHOD(CJS_PrintParamsObj) |
41 END_JS_STATIC_METHOD() | 41 END_JS_STATIC_METHOD() |
42 | 42 |
43 IMPLEMENT_JS_CLASS(CJS_PrintParamsObj, PrintParamsObj) | 43 IMPLEMENT_JS_CLASS(CJS_PrintParamsObj, PrintParamsObj) |
44 | 44 |
45 PrintParamsObj::PrintParamsObj(CJS_Object* pJSObject) | 45 PrintParamsObj::PrintParamsObj(CJS_Object* pJSObject) |
46 : CJS_EmbedObj(pJSObject) | 46 : CJS_EmbedObj(pJSObject) |
47 { | 47 { |
48 » bUI = TRUE; | 48 » bUI = true; |
49 nStart = 0; | 49 nStart = 0; |
50 nEnd = 0; | 50 nEnd = 0; |
51 » bSilent = FALSE; | 51 » bSilent = false; |
52 » bShrinkToFit = FALSE; | 52 » bShrinkToFit = false; |
53 » bPrintAsImage = FALSE; | 53 » bPrintAsImage = false; |
54 » bReverse = FALSE; | 54 » bReverse = false; |
55 » bAnnotations = TRUE; | 55 » bAnnotations = true; |
56 } | 56 } |
57 | 57 |
58 /* ---------------------- Document ---------------------- */ | 58 /* ---------------------- Document ---------------------- */ |
59 | 59 |
60 #define MINWIDTH 5.0f | 60 #define MINWIDTH 5.0f |
61 #define MINHEIGHT 5.0f | 61 #define MINHEIGHT 5.0f |
62 | 62 |
63 BEGIN_JS_STATIC_CONST(CJS_Document) | 63 BEGIN_JS_STATIC_CONST(CJS_Document) |
64 END_JS_STATIC_CONST() | 64 END_JS_STATIC_CONST() |
65 | 65 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 JS_STATIC_METHOD_ENTRY(replacePages) | 135 JS_STATIC_METHOD_ENTRY(replacePages) |
136 JS_STATIC_METHOD_ENTRY(resetForm) | 136 JS_STATIC_METHOD_ENTRY(resetForm) |
137 JS_STATIC_METHOD_ENTRY(removeIcon) | 137 JS_STATIC_METHOD_ENTRY(removeIcon) |
138 JS_STATIC_METHOD_ENTRY(saveAs) | 138 JS_STATIC_METHOD_ENTRY(saveAs) |
139 JS_STATIC_METHOD_ENTRY(submitForm) | 139 JS_STATIC_METHOD_ENTRY(submitForm) |
140 JS_STATIC_METHOD_ENTRY(mailDoc) | 140 JS_STATIC_METHOD_ENTRY(mailDoc) |
141 END_JS_STATIC_METHOD() | 141 END_JS_STATIC_METHOD() |
142 | 142 |
143 IMPLEMENT_JS_CLASS(CJS_Document, Document) | 143 IMPLEMENT_JS_CLASS(CJS_Document, Document) |
144 | 144 |
145 FX_BOOL»CJS_Document::InitInstance(IFXJS_Context* cc) | 145 bool» CJS_Document::InitInstance(IFXJS_Context* cc) |
146 { | 146 { |
147 CJS_Context* pContext = (CJS_Context*)cc; | 147 CJS_Context* pContext = (CJS_Context*)cc; |
148 ASSERT(pContext != NULL); | 148 ASSERT(pContext != NULL); |
149 | 149 |
150 Document* pDoc = (Document*)GetEmbedObject(); | 150 Document* pDoc = (Document*)GetEmbedObject(); |
151 ASSERT(pDoc != NULL); | 151 ASSERT(pDoc != NULL); |
152 | 152 |
153 pDoc->AttachDoc(pContext->GetReaderDocument()); | 153 pDoc->AttachDoc(pContext->GetReaderDocument()); |
154 pDoc->SetIsolate(pContext->GetJSRuntime()->GetIsolate()); | 154 pDoc->SetIsolate(pContext->GetJSRuntime()->GetIsolate()); |
155 » return TRUE; | 155 » return true; |
156 }; | 156 }; |
157 | 157 |
158 /* --------------------------------- Document ---------------------------------
*/ | 158 /* --------------------------------- Document ---------------------------------
*/ |
159 | 159 |
160 Document::Document(CJS_Object* pJSObject) : CJS_EmbedObj(pJSObject), | 160 Document::Document(CJS_Object* pJSObject) : CJS_EmbedObj(pJSObject), |
161 m_isolate(NULL), | 161 m_isolate(NULL), |
162 m_pIconTree(NULL), | 162 m_pIconTree(NULL), |
163 m_pDocument(NULL), | 163 m_pDocument(NULL), |
164 m_cwBaseURL(L""), | 164 m_cwBaseURL(L""), |
165 » m_bDelay(FALSE) | 165 » m_bDelay(false) |
166 { | 166 { |
167 } | 167 } |
168 | 168 |
169 Document::~Document() | 169 Document::~Document() |
170 { | 170 { |
171 if (m_pIconTree) | 171 if (m_pIconTree) |
172 { | 172 { |
173 m_pIconTree->DeleteIconTree(); | 173 m_pIconTree->DeleteIconTree(); |
174 delete m_pIconTree; | 174 delete m_pIconTree; |
175 m_pIconTree = NULL; | 175 m_pIconTree = NULL; |
176 } | 176 } |
177 for (int i=0; i<m_DelayData.GetSize(); i++) | 177 for (int i=0; i<m_DelayData.GetSize(); i++) |
178 { | 178 { |
179 if (CJS_DelayData* pData = m_DelayData.GetAt(i)) | 179 if (CJS_DelayData* pData = m_DelayData.GetAt(i)) |
180 { | 180 { |
181 delete pData; | 181 delete pData; |
182 pData = NULL; | 182 pData = NULL; |
183 m_DelayData.SetAt(i, NULL); | 183 m_DelayData.SetAt(i, NULL); |
184 | 184 |
185 } | 185 } |
186 } | 186 } |
187 | 187 |
188 m_DelayData.RemoveAll(); | 188 m_DelayData.RemoveAll(); |
189 m_DelayAnnotData.RemoveAll(); | 189 m_DelayAnnotData.RemoveAll(); |
190 } | 190 } |
191 | 191 |
192 //the total number of fileds in document. | 192 //the total number of fileds in document. |
193 FX_BOOL Document::numFields(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString
& sError) | 193 bool Document::numFields(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& s
Error) |
194 { | 194 { |
195 if (vp.IsSetting()) { | 195 if (vp.IsSetting()) { |
196 CJS_Context* pContext = static_cast<CJS_Context*>(cc); | 196 CJS_Context* pContext = static_cast<CJS_Context*>(cc); |
197 sError = JSGetStringFromID(pContext, IDS_STRING_JSREADONLY); | 197 sError = JSGetStringFromID(pContext, IDS_STRING_JSREADONLY); |
198 » » return FALSE; | 198 » » return false; |
199 } | 199 } |
200 CPDFSDK_InterForm *pInterForm = m_pDocument->GetInterForm(); | 200 CPDFSDK_InterForm *pInterForm = m_pDocument->GetInterForm(); |
201 CPDF_InterForm *pPDFForm = pInterForm->GetInterForm(); | 201 CPDF_InterForm *pPDFForm = pInterForm->GetInterForm(); |
202 vp << (int)pPDFForm->CountFields(); | 202 vp << (int)pPDFForm->CountFields(); |
203 » return TRUE; | 203 » return true; |
204 } | 204 } |
205 | 205 |
206 FX_BOOL Document::dirty(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sE
rror) | 206 bool Document::dirty(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sErro
r) |
207 { | 207 { |
208 ASSERT(m_pDocument != NULL); | 208 ASSERT(m_pDocument != NULL); |
209 | 209 |
210 if (vp.IsGetting()) | 210 if (vp.IsGetting()) |
211 { | 211 { |
212 if (m_pDocument->GetChangeMark()) | 212 if (m_pDocument->GetChangeMark()) |
213 vp << true; | 213 vp << true; |
214 else | 214 else |
215 vp << false; | 215 vp << false; |
216 } | 216 } |
217 else | 217 else |
218 { | 218 { |
219 bool bChanged = false; | 219 bool bChanged = false; |
220 | 220 |
221 vp >> bChanged; | 221 vp >> bChanged; |
222 | 222 |
223 if (bChanged) | 223 if (bChanged) |
224 m_pDocument->SetChangeMark(); | 224 m_pDocument->SetChangeMark(); |
225 else | 225 else |
226 m_pDocument->ClearChangeMark(); | 226 m_pDocument->ClearChangeMark(); |
227 } | 227 } |
228 | 228 |
229 » return TRUE; | 229 » return true; |
230 } | 230 } |
231 | 231 |
232 FX_BOOL Document::ADBE(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sEr
ror) | 232 bool Document::ADBE(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError
) |
233 { | 233 { |
234 ASSERT(m_pDocument != NULL); | 234 ASSERT(m_pDocument != NULL); |
235 | 235 |
236 if (vp.IsGetting()) | 236 if (vp.IsGetting()) |
237 { | 237 { |
238 vp.SetNull(); | 238 vp.SetNull(); |
239 } | 239 } |
240 else | 240 else |
241 { | 241 { |
242 } | 242 } |
243 | 243 |
244 » return TRUE; | 244 » return true; |
245 } | 245 } |
246 | 246 |
247 FX_BOOL Document::pageNum(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString&
sError) | 247 bool Document::pageNum(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sEr
ror) |
248 { | 248 { |
249 ASSERT(m_pDocument != NULL); | 249 ASSERT(m_pDocument != NULL); |
250 | 250 |
251 if (vp.IsGetting()) | 251 if (vp.IsGetting()) |
252 { | 252 { |
253 if (CPDFSDK_PageView* pPageView = m_pDocument->GetCurrentView()) | 253 if (CPDFSDK_PageView* pPageView = m_pDocument->GetCurrentView()) |
254 { | 254 { |
255 vp << pPageView->GetPageIndex(); | 255 vp << pPageView->GetPageIndex(); |
256 } | 256 } |
257 } | 257 } |
(...skipping 11 matching lines...) Expand all Loading... |
269 else if (iPageNum >= iPageCount) | 269 else if (iPageNum >= iPageCount) |
270 { | 270 { |
271 pEnv->JS_docgotoPage(iPageCount-1); | 271 pEnv->JS_docgotoPage(iPageCount-1); |
272 } | 272 } |
273 else if (iPageNum < 0) | 273 else if (iPageNum < 0) |
274 { | 274 { |
275 pEnv->JS_docgotoPage(0); | 275 pEnv->JS_docgotoPage(0); |
276 } | 276 } |
277 } | 277 } |
278 | 278 |
279 » return TRUE; | 279 » return true; |
280 } | 280 } |
281 | 281 |
282 FX_BOOL Document::ParserParams(JSObject* pObj,CJS_AnnotObj& annotobj) | 282 bool Document::ParserParams(JSObject* pObj,CJS_AnnotObj& annotobj) |
283 { | 283 { |
284 // Not supported. | 284 // Not supported. |
285 » return TRUE; | 285 » return true; |
286 } | 286 } |
287 | 287 |
288 FX_BOOL Document::addAnnot(IFXJS_Context* cc, const CJS_Parameters& params, CJS_
Value& vRet, CFX_WideString& sError) | 288 bool Document::addAnnot(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Val
ue& vRet, CFX_WideString& sError) |
289 { | 289 { |
290 // Not supported. | 290 // Not supported. |
291 » return TRUE; | 291 » return true; |
292 } | 292 } |
293 | 293 |
294 FX_BOOL Document::addField(IFXJS_Context* cc, const CJS_Parameters& params, CJS_
Value& vRet, CFX_WideString& sError) | 294 bool Document::addField(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Val
ue& vRet, CFX_WideString& sError) |
295 { | 295 { |
296 // Not supported. | 296 // Not supported. |
297 » return TRUE; | 297 » return true; |
298 } | 298 } |
299 | 299 |
300 FX_BOOL Document::exportAsText(IFXJS_Context* cc, const CJS_Parameters& params,
CJS_Value& vRet, CFX_WideString& sError) | 300 bool Document::exportAsText(IFXJS_Context* cc, const CJS_Parameters& params, CJS
_Value& vRet, CFX_WideString& sError) |
301 { | 301 { |
302 // Unsafe, not supported. | 302 // Unsafe, not supported. |
303 » return TRUE; | 303 » return true; |
304 } | 304 } |
305 | 305 |
306 FX_BOOL Document::exportAsFDF(IFXJS_Context* cc, const CJS_Parameters& params, C
JS_Value& vRet, CFX_WideString& sError) | 306 bool Document::exportAsFDF(IFXJS_Context* cc, const CJS_Parameters& params, CJS_
Value& vRet, CFX_WideString& sError) |
307 { | 307 { |
308 // Unsafe, not supported. | 308 // Unsafe, not supported. |
309 » return TRUE; | 309 » return true; |
310 } | 310 } |
311 | 311 |
312 FX_BOOL Document::exportAsXFDF(IFXJS_Context* cc, const CJS_Parameters& params,
CJS_Value& vRet, CFX_WideString& sError) | 312 bool Document::exportAsXFDF(IFXJS_Context* cc, const CJS_Parameters& params, CJS
_Value& vRet, CFX_WideString& sError) |
313 { | 313 { |
314 // Unsafe, not supported. | 314 // Unsafe, not supported. |
315 » return TRUE; | 315 » return true; |
316 } | 316 } |
317 | 317 |
318 //Maps a field object in PDF document to a JavaScript variable | 318 //Maps a field object in PDF document to a JavaScript variable |
319 //comment: | 319 //comment: |
320 //note: the paremter cName, this is clue how to treat if the cName is not a vali
able filed name in this document | 320 //note: the paremter cName, this is clue how to treat if the cName is not a vali
able filed name in this document |
321 | 321 |
322 FX_BOOL Document::getField(IFXJS_Context* cc, const CJS_Parameters& params, CJS_
Value& vRet, CFX_WideString& sError) | 322 bool Document::getField(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Val
ue& vRet, CFX_WideString& sError) |
323 { | 323 { |
324 CJS_Context* pContext = (CJS_Context*)cc; | 324 CJS_Context* pContext = (CJS_Context*)cc; |
325 if (params.size() < 1) { | 325 if (params.size() < 1) { |
326 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); | 326 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); |
327 » » return FALSE; | 327 » » return false; |
328 } | 328 } |
329 | 329 |
330 CFX_WideString wideName = params[0].ToCFXWideString(); | 330 CFX_WideString wideName = params[0].ToCFXWideString(); |
331 | 331 |
332 CPDFSDK_InterForm* pInterForm = m_pDocument->GetInterForm(); | 332 CPDFSDK_InterForm* pInterForm = m_pDocument->GetInterForm(); |
333 CPDF_InterForm* pPDFForm = pInterForm->GetInterForm(); | 333 CPDF_InterForm* pPDFForm = pInterForm->GetInterForm(); |
334 if (pPDFForm->CountFields(wideName) <= 0) | 334 if (pPDFForm->CountFields(wideName) <= 0) |
335 { | 335 { |
336 vRet.SetNull(); | 336 vRet.SetNull(); |
337 » » return TRUE; | 337 » » return true; |
338 } | 338 } |
339 | 339 |
340 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 340 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
341 JSFXObject pFieldObj = JS_NewFxDynamicObj(*pRuntime, pContext, JS_GetObj
DefnID(*pRuntime, L"Field")); | 341 JSFXObject pFieldObj = JS_NewFxDynamicObj(*pRuntime, pContext, JS_GetObj
DefnID(*pRuntime, L"Field")); |
342 | 342 |
343 v8::Isolate* isolate = GetIsolate(cc); | 343 v8::Isolate* isolate = GetIsolate(cc); |
344 CJS_Field* pJSField = (CJS_Field*)JS_GetPrivate(isolate,pFieldObj); | 344 CJS_Field* pJSField = (CJS_Field*)JS_GetPrivate(isolate,pFieldObj); |
345 Field* pField = (Field *)pJSField->GetEmbedObject(); | 345 Field* pField = (Field *)pJSField->GetEmbedObject(); |
346 pField->AttachField(this, wideName); | 346 pField->AttachField(this, wideName); |
347 | 347 |
348 vRet = pJSField; | 348 vRet = pJSField; |
349 » return TRUE; | 349 » return true; |
350 } | 350 } |
351 | 351 |
352 //Gets the name of the nth field in the document | 352 //Gets the name of the nth field in the document |
353 FX_BOOL Document::getNthFieldName(IFXJS_Context* cc, const CJS_Parameters& param
s, CJS_Value& vRet, CFX_WideString& sError) | 353 bool Document::getNthFieldName(IFXJS_Context* cc, const CJS_Parameters& params,
CJS_Value& vRet, CFX_WideString& sError) |
354 { | 354 { |
355 CJS_Context* pContext = (CJS_Context*)cc; | 355 CJS_Context* pContext = (CJS_Context*)cc; |
356 if (params.size() != 1) { | 356 if (params.size() != 1) { |
357 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); | 357 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); |
358 » » return FALSE; | 358 » » return false; |
359 } | 359 } |
360 | 360 |
361 int nIndex = params[0].ToInt(); | 361 int nIndex = params[0].ToInt(); |
362 if (nIndex < 0) { | 362 if (nIndex < 0) { |
363 sError = JSGetStringFromID(pContext, IDS_STRING_JSVALUEERROR); | 363 sError = JSGetStringFromID(pContext, IDS_STRING_JSVALUEERROR); |
364 » » return FALSE; | 364 » » return false; |
365 } | 365 } |
366 | 366 |
367 CPDFSDK_InterForm* pInterForm = m_pDocument->GetInterForm(); | 367 CPDFSDK_InterForm* pInterForm = m_pDocument->GetInterForm(); |
368 CPDF_InterForm* pPDFForm = pInterForm->GetInterForm(); | 368 CPDF_InterForm* pPDFForm = pInterForm->GetInterForm(); |
369 CPDF_FormField* pField = pPDFForm->GetField(nIndex); | 369 CPDF_FormField* pField = pPDFForm->GetField(nIndex); |
370 if (!pField) | 370 if (!pField) |
371 » » return FALSE; | 371 » » return false; |
372 | 372 |
373 vRet = pField->GetFullName().c_str(); | 373 vRet = pField->GetFullName().c_str(); |
374 » return TRUE; | 374 » return true; |
375 } | 375 } |
376 | 376 |
377 FX_BOOL Document::importAnFDF(IFXJS_Context* cc, const CJS_Parameters& params, C
JS_Value& vRet, CFX_WideString& sError) | 377 bool Document::importAnFDF(IFXJS_Context* cc, const CJS_Parameters& params, CJS_
Value& vRet, CFX_WideString& sError) |
378 { | 378 { |
379 // Unsafe, not supported. | 379 // Unsafe, not supported. |
380 » return TRUE; | 380 » return true; |
381 } | 381 } |
382 | 382 |
383 FX_BOOL Document::importAnXFDF(IFXJS_Context* cc, const CJS_Parameters& params,
CJS_Value& vRet, CFX_WideString& sError) | 383 bool Document::importAnXFDF(IFXJS_Context* cc, const CJS_Parameters& params, CJS
_Value& vRet, CFX_WideString& sError) |
384 { | 384 { |
385 // Unsafe, not supported. | 385 // Unsafe, not supported. |
386 » return TRUE; | 386 » return true; |
387 } | 387 } |
388 | 388 |
389 FX_BOOL Document::importTextData(IFXJS_Context* cc, const CJS_Parameters& params
, CJS_Value& vRet, CFX_WideString& sError) | 389 bool Document::importTextData(IFXJS_Context* cc, const CJS_Parameters& params, C
JS_Value& vRet, CFX_WideString& sError) |
390 { | 390 { |
391 // Unsafe, not supported. | 391 // Unsafe, not supported. |
392 » return TRUE; | 392 » return true; |
393 } | 393 } |
394 | 394 |
395 //exports the form data and mails the resulting fdf file as an attachment to all
recipients. | 395 //exports the form data and mails the resulting fdf file as an attachment to all
recipients. |
396 //comment: need reader supports | 396 //comment: need reader supports |
397 //note: | 397 //note: |
398 //int CPDFSDK_Document::mailForm(FX_BOOL bUI,String cto,string ccc,string cbcc,s
tring cSubject,string cms); | 398 //int CPDFSDK_Document::mailForm(bool bUI,String cto,string ccc,string cbcc,stri
ng cSubject,string cms); |
399 | 399 |
400 FX_BOOL Document::mailForm(IFXJS_Context* cc, const CJS_Parameters& params, CJS_
Value& vRet, CFX_WideString& sError) | 400 bool Document::mailForm(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Val
ue& vRet, CFX_WideString& sError) |
401 { | 401 { |
402 ASSERT(m_pDocument != NULL); | 402 ASSERT(m_pDocument != NULL); |
403 | 403 |
404 » if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) return FALSE; | 404 » if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) return false; |
405 | 405 |
406 int iLength = params.size(); | 406 int iLength = params.size(); |
407 | 407 |
408 » FX_BOOL bUI = iLength > 0 ? params[0].ToBool() : TRUE; | 408 » bool bUI = iLength > 0 ? params[0].ToBool() : true; |
409 CFX_WideString cTo = iLength > 1 ? params[1].ToCFXWideString() : L""; | 409 CFX_WideString cTo = iLength > 1 ? params[1].ToCFXWideString() : L""; |
410 CFX_WideString cCc = iLength > 2 ? params[2].ToCFXWideString() : L""; | 410 CFX_WideString cCc = iLength > 2 ? params[2].ToCFXWideString() : L""; |
411 CFX_WideString cBcc = iLength > 3 ? params[3].ToCFXWideString() : L""; | 411 CFX_WideString cBcc = iLength > 3 ? params[3].ToCFXWideString() : L""; |
412 CFX_WideString cSubject = iLength > 4 ? params[4].ToCFXWideString() : L"
"; | 412 CFX_WideString cSubject = iLength > 4 ? params[4].ToCFXWideString() : L"
"; |
413 CFX_WideString cMsg = iLength > 5 ? params[5].ToCFXWideString() : L""; | 413 CFX_WideString cMsg = iLength > 5 ? params[5].ToCFXWideString() : L""; |
414 | 414 |
415 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInte
rForm(); | 415 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInte
rForm(); |
416 ASSERT(pInterForm != NULL); | 416 ASSERT(pInterForm != NULL); |
417 | 417 |
418 CFX_ByteTextBuf textBuf; | 418 CFX_ByteTextBuf textBuf; |
419 if (!pInterForm->ExportFormToFDFTextBuf(textBuf)) | 419 if (!pInterForm->ExportFormToFDFTextBuf(textBuf)) |
420 » » return FALSE; | 420 » » return false; |
421 | 421 |
422 CJS_Context* pContext = (CJS_Context*)cc; | 422 CJS_Context* pContext = (CJS_Context*)cc; |
423 ASSERT(pContext != NULL); | 423 ASSERT(pContext != NULL); |
424 CPDFDoc_Environment* pEnv = pContext->GetReaderApp(); | 424 CPDFDoc_Environment* pEnv = pContext->GetReaderApp(); |
425 ASSERT(pEnv != NULL); | 425 ASSERT(pEnv != NULL); |
426 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 426 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
427 ASSERT(pRuntime != NULL); | 427 ASSERT(pRuntime != NULL); |
428 | 428 |
429 pRuntime->BeginBlock(); | 429 pRuntime->BeginBlock(); |
430 pEnv->JS_docmailForm(textBuf.GetBuffer(), textBuf.GetLength(), bUI, cTo.
c_str(), cSubject.c_str(), cCc.c_str(), cBcc.c_str(), cMsg.c_str()); | 430 pEnv->JS_docmailForm(textBuf.GetBuffer(), textBuf.GetLength(), bUI, cTo.
c_str(), cSubject.c_str(), cCc.c_str(), cBcc.c_str(), cMsg.c_str()); |
431 pRuntime->EndBlock(); | 431 pRuntime->EndBlock(); |
432 » return TRUE; | 432 » return true; |
433 } | 433 } |
434 | 434 |
435 FX_BOOL Document::print(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Val
ue& vRet, CFX_WideString& sError) | 435 bool Document::print(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value&
vRet, CFX_WideString& sError) |
436 { | 436 { |
437 CJS_Context* pContext = (CJS_Context*)cc; | 437 CJS_Context* pContext = (CJS_Context*)cc; |
438 ASSERT(pContext != NULL); | 438 ASSERT(pContext != NULL); |
439 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 439 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
440 ASSERT(pRuntime != NULL); | 440 ASSERT(pRuntime != NULL); |
441 | 441 |
442 » FX_BOOL bUI = TRUE; | 442 » bool bUI = true; |
443 int nStart = 0; | 443 int nStart = 0; |
444 int nEnd = 0; | 444 int nEnd = 0; |
445 » FX_BOOL bSilent = FALSE; | 445 » bool bSilent = false; |
446 » FX_BOOL bShrinkToFit = FALSE; | 446 » bool bShrinkToFit = false; |
447 » FX_BOOL bPrintAsImage = FALSE; | 447 » bool bPrintAsImage = false; |
448 » FX_BOOL bReverse = FALSE; | 448 » bool bReverse = false; |
449 » FX_BOOL bAnnotations = FALSE; | 449 » bool bAnnotations = false; |
450 | 450 |
451 int nlength = params.size(); | 451 int nlength = params.size(); |
452 if(nlength ==9) | 452 if(nlength ==9) |
453 { | 453 { |
454 if (params[8].GetType() == VT_fxobject) | 454 if (params[8].GetType() == VT_fxobject) |
455 { | 455 { |
456 JSFXObject pObj = params[8].ToV8Object(); | 456 JSFXObject pObj = params[8].ToV8Object(); |
457 { | 457 { |
458 if (JS_GetObjDefnID(pObj) == JS_GetObjDefnID(*pR
untime, L"PrintParamsObj")) | 458 if (JS_GetObjDefnID(pObj) == JS_GetObjDefnID(*pR
untime, L"PrintParamsObj")) |
459 { | 459 { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
493 bReverse = params[6].ToBool(); | 493 bReverse = params[6].ToBool(); |
494 if(nlength >= 8) | 494 if(nlength >= 8) |
495 bAnnotations = params[7].ToBool(); | 495 bAnnotations = params[7].ToBool(); |
496 } | 496 } |
497 | 497 |
498 ASSERT(m_pDocument != NULL); | 498 ASSERT(m_pDocument != NULL); |
499 | 499 |
500 if (CPDFDoc_Environment* pEnv = m_pDocument->GetEnv()) | 500 if (CPDFDoc_Environment* pEnv = m_pDocument->GetEnv()) |
501 { | 501 { |
502 pEnv->JS_docprint(bUI, nStart, nEnd, bSilent, bShrinkToFit, bPri
ntAsImage, bReverse, bAnnotations); | 502 pEnv->JS_docprint(bUI, nStart, nEnd, bSilent, bShrinkToFit, bPri
ntAsImage, bReverse, bAnnotations); |
503 » » return TRUE; | 503 » » return true; |
504 } | 504 } |
505 » return FALSE; | 505 » return false; |
506 } | 506 } |
507 | 507 |
508 //removes the specified field from the document. | 508 //removes the specified field from the document. |
509 //comment: | 509 //comment: |
510 //note: if the filed name is not retional, adobe is dumb for it. | 510 //note: if the filed name is not retional, adobe is dumb for it. |
511 | 511 |
512 FX_BOOL Document::removeField(IFXJS_Context* cc, const CJS_Parameters& params, C
JS_Value& vRet, CFX_WideString& sError) | 512 bool Document::removeField(IFXJS_Context* cc, const CJS_Parameters& params, CJS_
Value& vRet, CFX_WideString& sError) |
513 { | 513 { |
514 ASSERT(m_pDocument != NULL); | 514 ASSERT(m_pDocument != NULL); |
515 | 515 |
516 if (!(m_pDocument->GetPermissions(FPDFPERM_MODIFY) || | 516 if (!(m_pDocument->GetPermissions(FPDFPERM_MODIFY) || |
517 » » m_pDocument->GetPermissions(FPDFPERM_ANNOT_FORM))) return FALSE; | 517 » » m_pDocument->GetPermissions(FPDFPERM_ANNOT_FORM))) return false; |
518 | 518 |
519 CJS_Context* pContext = (CJS_Context*)cc; | 519 CJS_Context* pContext = (CJS_Context*)cc; |
520 if (params.size() != 1) { | 520 if (params.size() != 1) { |
521 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); | 521 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); |
522 » » return FALSE; | 522 » » return false; |
523 } | 523 } |
524 | 524 |
525 CFX_WideString sFieldName = params[0].ToCFXWideString(); | 525 CFX_WideString sFieldName = params[0].ToCFXWideString(); |
526 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInte
rForm(); | 526 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInte
rForm(); |
527 ASSERT(pInterForm != NULL); | 527 ASSERT(pInterForm != NULL); |
528 | 528 |
529 CFX_PtrArray widgets; | 529 CFX_PtrArray widgets; |
530 pInterForm->GetWidgets(sFieldName, widgets); | 530 pInterForm->GetWidgets(sFieldName, widgets); |
531 | 531 |
532 int nSize = widgets.GetSize(); | 532 int nSize = widgets.GetSize(); |
(...skipping 18 matching lines...) Expand all Loading... |
551 ASSERT(pPage != NULL); | 551 ASSERT(pPage != NULL); |
552 | 552 |
553 CPDFSDK_PageView* pPageView = m_pDocument->GetPageView(p
Page); | 553 CPDFSDK_PageView* pPageView = m_pDocument->GetPageView(p
Page); |
554 pPageView->DeleteAnnot(pWidget); | 554 pPageView->DeleteAnnot(pWidget); |
555 | 555 |
556 pPageView->UpdateRects(aRefresh); | 556 pPageView->UpdateRects(aRefresh); |
557 } | 557 } |
558 m_pDocument->SetChangeMark(); | 558 m_pDocument->SetChangeMark(); |
559 } | 559 } |
560 | 560 |
561 » return TRUE; | 561 » return true; |
562 } | 562 } |
563 | 563 |
564 //reset filed values within a document. | 564 //reset filed values within a document. |
565 //comment: | 565 //comment: |
566 //note: if the fields names r not rational, aodbe is dumb for it. | 566 //note: if the fields names r not rational, aodbe is dumb for it. |
567 | 567 |
568 FX_BOOL Document::resetForm(IFXJS_Context* cc, const CJS_Parameters& params, CJS
_Value& vRet, CFX_WideString& sError) | 568 bool Document::resetForm(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Va
lue& vRet, CFX_WideString& sError) |
569 { | 569 { |
570 ASSERT(m_pDocument != NULL); | 570 ASSERT(m_pDocument != NULL); |
571 | 571 |
572 if (!(m_pDocument->GetPermissions(FPDFPERM_MODIFY) || | 572 if (!(m_pDocument->GetPermissions(FPDFPERM_MODIFY) || |
573 m_pDocument->GetPermissions(FPDFPERM_ANNOT_FORM) || | 573 m_pDocument->GetPermissions(FPDFPERM_ANNOT_FORM) || |
574 » » m_pDocument->GetPermissions(FPDFPERM_FILL_FORM))) return FALSE; | 574 » » m_pDocument->GetPermissions(FPDFPERM_FILL_FORM))) return false; |
575 | 575 |
576 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInte
rForm(); | 576 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInte
rForm(); |
577 ASSERT(pInterForm != NULL); | 577 ASSERT(pInterForm != NULL); |
578 | 578 |
579 CPDF_InterForm* pPDFForm = pInterForm->GetInterForm(); | 579 CPDF_InterForm* pPDFForm = pInterForm->GetInterForm(); |
580 ASSERT(pPDFForm != NULL); | 580 ASSERT(pPDFForm != NULL); |
581 | 581 |
582 v8::Isolate* isolate = GetIsolate(cc); | 582 v8::Isolate* isolate = GetIsolate(cc); |
583 CJS_Array aName(isolate); | 583 CJS_Array aName(isolate); |
584 | 584 |
(...skipping 18 matching lines...) Expand all Loading... |
603 CFX_WideString swVal = valElement.ToCFXWideString(); | 603 CFX_WideString swVal = valElement.ToCFXWideString(); |
604 | 604 |
605 for (int j=0,jsz=pPDFForm->CountFields(swVal); j<jsz; j+
+) | 605 for (int j=0,jsz=pPDFForm->CountFields(swVal); j<jsz; j+
+) |
606 { | 606 { |
607 aFields.Add((void*)pPDFForm->GetField(j,swVal)); | 607 aFields.Add((void*)pPDFForm->GetField(j,swVal)); |
608 } | 608 } |
609 } | 609 } |
610 | 610 |
611 if (aFields.GetSize() > 0) | 611 if (aFields.GetSize() > 0) |
612 { | 612 { |
613 » » » pPDFForm->ResetForm(aFields, TRUE, TRUE); | 613 » » » pPDFForm->ResetForm(aFields, true, true); |
614 m_pDocument->SetChangeMark(); | 614 m_pDocument->SetChangeMark(); |
615 | 615 |
616 } | 616 } |
617 } | 617 } |
618 else | 618 else |
619 { | 619 { |
620 » » pPDFForm->ResetForm(TRUE); | 620 » » pPDFForm->ResetForm(true); |
621 m_pDocument->SetChangeMark(); | 621 m_pDocument->SetChangeMark(); |
622 | 622 |
623 } | 623 } |
624 | 624 |
625 » return TRUE; | 625 » return true; |
626 } | 626 } |
627 | 627 |
628 | 628 |
629 FX_BOOL Document::saveAs(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Va
lue& vRet, CFX_WideString& sError) | 629 bool Document::saveAs(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value
& vRet, CFX_WideString& sError) |
630 { | 630 { |
631 // Unsafe, not supported. | 631 // Unsafe, not supported. |
632 return TRUE; | 632 return true; |
633 } | 633 } |
634 | 634 |
635 | 635 |
636 FX_BOOL Document::submitForm(IFXJS_Context* cc, const CJS_Parameters& params, CJ
S_Value& vRet, CFX_WideString& sError) | 636 bool Document::submitForm(IFXJS_Context* cc, const CJS_Parameters& params, CJS_V
alue& vRet, CFX_WideString& sError) |
637 { | 637 { |
638 ASSERT(m_pDocument != NULL); | 638 ASSERT(m_pDocument != NULL); |
639 CJS_Context* pContext = (CJS_Context*)cc; | 639 CJS_Context* pContext = (CJS_Context*)cc; |
640 int nSize = params.size(); | 640 int nSize = params.size(); |
641 if (nSize < 1) { | 641 if (nSize < 1) { |
642 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); | 642 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); |
643 » » return FALSE; | 643 » » return false; |
644 } | 644 } |
645 | 645 |
646 CFX_WideString strURL; | 646 CFX_WideString strURL; |
647 » FX_BOOL bFDF = TRUE; | 647 » bool bFDF = true; |
648 » FX_BOOL bEmpty = FALSE; | 648 » bool bEmpty = false; |
649 v8::Isolate* isolate = GetIsolate(cc); | 649 v8::Isolate* isolate = GetIsolate(cc); |
650 CJS_Array aFields(isolate); | 650 CJS_Array aFields(isolate); |
651 | 651 |
652 CJS_Value v = params[0]; | 652 CJS_Value v = params[0]; |
653 if (v.GetType() == VT_string) | 653 if (v.GetType() == VT_string) |
654 { | 654 { |
655 strURL = params[0].ToCFXWideString(); | 655 strURL = params[0].ToCFXWideString(); |
656 if (nSize > 1) | 656 if (nSize > 1) |
657 bFDF = params[1].ToBool(); | 657 bFDF = params[1].ToBool(); |
658 if (nSize > 2) | 658 if (nSize > 2) |
(...skipping 13 matching lines...) Expand all Loading... |
672 bEmpty = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToBo
ol(); | 672 bEmpty = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToBo
ol(); |
673 pValue = JS_GetObjectElement(isolate, pObj,L"aFields"); | 673 pValue = JS_GetObjectElement(isolate, pObj,L"aFields"); |
674 aFields.Attach(CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)
).ToV8Array()); | 674 aFields.Attach(CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)
).ToV8Array()); |
675 } | 675 } |
676 | 676 |
677 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInte
rForm(); | 677 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInte
rForm(); |
678 ASSERT(pInterForm != NULL); | 678 ASSERT(pInterForm != NULL); |
679 CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm(); | 679 CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm(); |
680 ASSERT(pPDFInterForm != NULL); | 680 ASSERT(pPDFInterForm != NULL); |
681 | 681 |
682 » FX_BOOL bAll = (aFields.GetLength() == 0); | 682 » bool bAll = (aFields.GetLength() == 0); |
683 | 683 |
684 if (bAll && bEmpty) | 684 if (bAll && bEmpty) |
685 { | 685 { |
686 CJS_Context* pContext = (CJS_Context*)cc; | 686 CJS_Context* pContext = (CJS_Context*)cc; |
687 ASSERT(pContext != NULL); | 687 ASSERT(pContext != NULL); |
688 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 688 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
689 ASSERT(pRuntime != NULL); | 689 ASSERT(pRuntime != NULL); |
690 | 690 |
691 | 691 |
692 if (pPDFInterForm->CheckRequiredFields()) | 692 if (pPDFInterForm->CheckRequiredFields()) |
693 { | 693 { |
694 pRuntime->BeginBlock(); | 694 pRuntime->BeginBlock(); |
695 » » » pInterForm->SubmitForm(strURL, FALSE); | 695 » » » pInterForm->SubmitForm(strURL, false); |
696 pRuntime->EndBlock(); | 696 pRuntime->EndBlock(); |
697 } | 697 } |
698 | 698 |
699 » » return TRUE; | 699 » » return true; |
700 } | 700 } |
701 else | 701 else |
702 { | 702 { |
703 CFX_PtrArray fieldObjects; | 703 CFX_PtrArray fieldObjects; |
704 | 704 |
705 for (int i=0,sz=aFields.GetLength(); i<sz; i++) | 705 for (int i=0,sz=aFields.GetLength(); i<sz; i++) |
706 { | 706 { |
707 CJS_Value valName(isolate); | 707 CJS_Value valName(isolate); |
708 aFields.GetElement(i, valName); | 708 aFields.GetElement(i, valName); |
709 CFX_WideString sName = valName.ToCFXWideString(); | 709 CFX_WideString sName = valName.ToCFXWideString(); |
(...skipping 10 matching lines...) Expand all Loading... |
720 fieldObjects.Add(pField); | 720 fieldObjects.Add(pField); |
721 } | 721 } |
722 } | 722 } |
723 | 723 |
724 CJS_Context* pContext = (CJS_Context*)cc; | 724 CJS_Context* pContext = (CJS_Context*)cc; |
725 ASSERT(pContext != NULL); | 725 ASSERT(pContext != NULL); |
726 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 726 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
727 ASSERT(pRuntime != NULL); | 727 ASSERT(pRuntime != NULL); |
728 | 728 |
729 | 729 |
730 » » if (pPDFInterForm->CheckRequiredFields(&fieldObjects, TRUE)) | 730 » » if (pPDFInterForm->CheckRequiredFields(&fieldObjects, true)) |
731 { | 731 { |
732 pRuntime->BeginBlock(); | 732 pRuntime->BeginBlock(); |
733 » » » pInterForm->SubmitFields(strURL, fieldObjects, TRUE, !bF
DF); | 733 » » » pInterForm->SubmitFields(strURL, fieldObjects, true, !bF
DF); |
734 pRuntime->EndBlock(); | 734 pRuntime->EndBlock(); |
735 } | 735 } |
736 | 736 |
737 » » return TRUE; | 737 » » return true; |
738 } | 738 } |
739 | 739 |
740 } | 740 } |
741 | 741 |
742 ////////////////////////////////////////////////////////////////////////////////
////////////// | 742 ////////////////////////////////////////////////////////////////////////////////
////////////// |
743 | 743 |
744 void Document::AttachDoc(CPDFSDK_Document *pDoc) | 744 void Document::AttachDoc(CPDFSDK_Document *pDoc) |
745 { | 745 { |
746 m_pDocument = pDoc; | 746 m_pDocument = pDoc; |
747 } | 747 } |
748 | 748 |
749 CPDFSDK_Document * Document::GetReaderDoc() | 749 CPDFSDK_Document * Document::GetReaderDoc() |
750 { | 750 { |
751 return m_pDocument; | 751 return m_pDocument; |
752 } | 752 } |
753 | 753 |
754 FX_BOOL Document::ExtractFileName(CPDFSDK_Document *pDoc,CFX_ByteString &strFile
Name) | 754 bool Document::ExtractFileName(CPDFSDK_Document *pDoc,CFX_ByteString &strFileNam
e) |
755 { | 755 { |
756 » return FALSE; | 756 » return false; |
757 } | 757 } |
758 | 758 |
759 FX_BOOL Document::ExtractFolderName(CPDFSDK_Document *pDoc,CFX_ByteString &strFo
lderName) | 759 bool Document::ExtractFolderName(CPDFSDK_Document *pDoc,CFX_ByteString &strFolde
rName) |
760 { | 760 { |
761 » return FALSE; | 761 » return false; |
762 } | 762 } |
763 | 763 |
764 FX_BOOL Document::bookmarkRoot(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideStr
ing& sError) | 764 bool Document::bookmarkRoot(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString
& sError) |
765 { | 765 { |
766 » return TRUE; | 766 » return true; |
767 } | 767 } |
768 | 768 |
769 FX_BOOL Document::mailDoc(IFXJS_Context* cc, const CJS_Parameters& params, CJS_V
alue& vRet, CFX_WideString& sError) | 769 bool Document::mailDoc(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Valu
e& vRet, CFX_WideString& sError) |
770 { | 770 { |
771 ASSERT(m_pDocument != NULL); | 771 ASSERT(m_pDocument != NULL); |
772 | 772 |
773 » FX_BOOL bUI = TRUE; | 773 » bool bUI = true; |
774 CFX_WideString cTo = L""; | 774 CFX_WideString cTo = L""; |
775 CFX_WideString cCc = L""; | 775 CFX_WideString cCc = L""; |
776 CFX_WideString cBcc = L""; | 776 CFX_WideString cBcc = L""; |
777 CFX_WideString cSubject = L""; | 777 CFX_WideString cSubject = L""; |
778 CFX_WideString cMsg = L""; | 778 CFX_WideString cMsg = L""; |
779 | 779 |
780 if (params.size() >= 1) | 780 if (params.size() >= 1) |
781 bUI = params[0].ToBool(); | 781 bUI = params[0].ToBool(); |
782 if (params.size() >= 2) | 782 if (params.size() >= 2) |
783 cTo = params[1].ToCFXWideString(); | 783 cTo = params[1].ToCFXWideString(); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
819 CJS_Context* pContext = (CJS_Context*)cc; | 819 CJS_Context* pContext = (CJS_Context*)cc; |
820 ASSERT(pContext != NULL); | 820 ASSERT(pContext != NULL); |
821 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 821 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
822 ASSERT(pRuntime != NULL); | 822 ASSERT(pRuntime != NULL); |
823 | 823 |
824 pRuntime->BeginBlock(); | 824 pRuntime->BeginBlock(); |
825 CPDFDoc_Environment* pEnv = pRuntime->GetReaderApp(); | 825 CPDFDoc_Environment* pEnv = pRuntime->GetReaderApp(); |
826 pEnv->JS_docmailForm(NULL, 0, bUI, cTo.c_str(), cSubject.c_str(), cCc.c_
str(), cBcc.c_str(), cMsg.c_str()); | 826 pEnv->JS_docmailForm(NULL, 0, bUI, cTo.c_str(), cSubject.c_str(), cCc.c_
str(), cBcc.c_str(), cMsg.c_str()); |
827 pRuntime->EndBlock(); | 827 pRuntime->EndBlock(); |
828 | 828 |
829 » return TRUE; | 829 » return true; |
830 } | 830 } |
831 | 831 |
832 FX_BOOL Document::author(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& s
Error) | 832 bool Document::author(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sErr
or) |
833 { | 833 { |
834 ASSERT(m_pDocument != NULL); | 834 ASSERT(m_pDocument != NULL); |
835 | 835 |
836 CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetInfo(); | 836 CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetInfo(); |
837 » if (!pDictionary)return FALSE; | 837 » if (!pDictionary)return false; |
838 | 838 |
839 if (vp.IsGetting()) | 839 if (vp.IsGetting()) |
840 { | 840 { |
841 vp << pDictionary->GetUnicodeText("Author"); | 841 vp << pDictionary->GetUnicodeText("Author"); |
842 » » return TRUE; | 842 » » return true; |
843 } | 843 } |
844 else | 844 else |
845 { | 845 { |
846 » » if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) return FALSE; | 846 » » if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) return false; |
847 | 847 |
848 CFX_WideString csAuthor; | 848 CFX_WideString csAuthor; |
849 vp >> csAuthor; | 849 vp >> csAuthor; |
850 pDictionary->SetAtString("Author", PDF_EncodeText(csAuthor)); | 850 pDictionary->SetAtString("Author", PDF_EncodeText(csAuthor)); |
851 m_pDocument->SetChangeMark(); | 851 m_pDocument->SetChangeMark(); |
852 » » return TRUE; | 852 » » return true; |
853 } | 853 } |
854 } | 854 } |
855 | 855 |
856 FX_BOOL Document::info(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sEr
ror) | 856 bool Document::info(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError
) |
857 { | 857 { |
858 ASSERT(m_pDocument != NULL); | 858 ASSERT(m_pDocument != NULL); |
859 | 859 |
860 CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetInfo(); | 860 CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetInfo(); |
861 » if (!pDictionary)return FALSE; | 861 » if (!pDictionary)return false; |
862 | 862 |
863 CFX_WideString cwAuthor = pDictionary->GetUnicodeText("A
uthor"); | 863 CFX_WideString cwAuthor = pDictionary->GetUnicodeText("A
uthor"); |
864 CFX_WideString cwTitle = pDictionary->GetUnicodeText("T
itle"); | 864 CFX_WideString cwTitle = pDictionary->GetUnicodeText("T
itle"); |
865 CFX_WideString cwSubject = pDictionary->GetUnicodeText("S
ubject"); | 865 CFX_WideString cwSubject = pDictionary->GetUnicodeText("S
ubject"); |
866 CFX_WideString cwKeywords = pDictionary->GetUnicodeText("K
eywords"); | 866 CFX_WideString cwKeywords = pDictionary->GetUnicodeText("K
eywords"); |
867 CFX_WideString cwCreator = pDictionary->GetUnicodeText("C
reator"); | 867 CFX_WideString cwCreator = pDictionary->GetUnicodeText("C
reator"); |
868 CFX_WideString cwProducer = pDictionary->GetUnicodeText("P
roducer"); | 868 CFX_WideString cwProducer = pDictionary->GetUnicodeText("P
roducer"); |
869 CFX_WideString cwCreationDate = pDictionary->GetUnicodeText("CreationD
ate"); | 869 CFX_WideString cwCreationDate = pDictionary->GetUnicodeText("CreationD
ate"); |
870 CFX_WideString cwModDate = pDictionary->GetUnicodeText("M
odDate"); | 870 CFX_WideString cwModDate = pDictionary->GetUnicodeText("M
odDate"); |
871 CFX_WideString cwTrapped = pDictionary->GetUnicodeText("T
rapped"); | 871 CFX_WideString cwTrapped = pDictionary->GetUnicodeText("T
rapped"); |
(...skipping 25 matching lines...) Expand all Loading... |
897 CFX_WideString wsKey = CFX_WideString::FromUTF8(bsKey,
bsKey.GetLength()); | 897 CFX_WideString wsKey = CFX_WideString::FromUTF8(bsKey,
bsKey.GetLength()); |
898 if((pValueObj->GetType()==PDFOBJ_STRING) || (pValueObj->
GetType()==PDFOBJ_NAME) ) | 898 if((pValueObj->GetType()==PDFOBJ_STRING) || (pValueObj->
GetType()==PDFOBJ_NAME) ) |
899 JS_PutObjectString(isolate, pObj, wsKey.c_str(),
pValueObj->GetUnicodeText().c_str()); | 899 JS_PutObjectString(isolate, pObj, wsKey.c_str(),
pValueObj->GetUnicodeText().c_str()); |
900 if(pValueObj->GetType()==PDFOBJ_NUMBER) | 900 if(pValueObj->GetType()==PDFOBJ_NUMBER) |
901 JS_PutObjectNumber(isolate,pObj, wsKey.c_str(),
(float)pValueObj->GetNumber()); | 901 JS_PutObjectNumber(isolate,pObj, wsKey.c_str(),
(float)pValueObj->GetNumber()); |
902 if(pValueObj->GetType()==PDFOBJ_BOOLEAN) | 902 if(pValueObj->GetType()==PDFOBJ_BOOLEAN) |
903 JS_PutObjectBoolean(isolate,pObj, wsKey.c_str(),
(bool)pValueObj->GetInteger()); | 903 JS_PutObjectBoolean(isolate,pObj, wsKey.c_str(),
(bool)pValueObj->GetInteger()); |
904 } | 904 } |
905 | 905 |
906 vp << pObj; | 906 vp << pObj; |
907 » » return TRUE; | 907 » » return true; |
908 } | 908 } |
909 else | 909 else |
910 { | 910 { |
911 » » return TRUE; | 911 » » return true; |
912 } | 912 } |
913 } | 913 } |
914 | 914 |
915 FX_BOOL Document::creationDate(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideStr
ing& sError) | 915 bool Document::creationDate(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString
& sError) |
916 { | 916 { |
917 ASSERT(m_pDocument != NULL); | 917 ASSERT(m_pDocument != NULL); |
918 | 918 |
919 CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetInfo(); | 919 CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetInfo(); |
920 » if (!pDictionary)return FALSE; | 920 » if (!pDictionary)return false; |
921 | 921 |
922 if (vp.IsGetting()) | 922 if (vp.IsGetting()) |
923 { | 923 { |
924 vp << pDictionary->GetUnicodeText("CreationDate"); | 924 vp << pDictionary->GetUnicodeText("CreationDate"); |
925 » » return TRUE; | 925 » » return true; |
926 } | 926 } |
927 else | 927 else |
928 { | 928 { |
929 » » if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) return FALSE; | 929 » » if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) return false; |
930 | 930 |
931 CFX_WideString csCreationDate; | 931 CFX_WideString csCreationDate; |
932 vp >> csCreationDate; | 932 vp >> csCreationDate; |
933 pDictionary->SetAtString("CreationDate", PDF_EncodeText(csCreati
onDate)); | 933 pDictionary->SetAtString("CreationDate", PDF_EncodeText(csCreati
onDate)); |
934 m_pDocument->SetChangeMark(); | 934 m_pDocument->SetChangeMark(); |
935 | 935 |
936 » » return TRUE; | 936 » » return true; |
937 } | 937 } |
938 } | 938 } |
939 | 939 |
940 FX_BOOL Document::creator(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString&
sError) | 940 bool Document::creator(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sEr
ror) |
941 { | 941 { |
942 ASSERT(m_pDocument != NULL); | 942 ASSERT(m_pDocument != NULL); |
943 | 943 |
944 CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetInfo(); | 944 CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetInfo(); |
945 » if (!pDictionary)return FALSE; | 945 » if (!pDictionary)return false; |
946 | 946 |
947 if (vp.IsGetting()) | 947 if (vp.IsGetting()) |
948 { | 948 { |
949 vp << pDictionary->GetUnicodeText("Creator"); | 949 vp << pDictionary->GetUnicodeText("Creator"); |
950 » » return TRUE; | 950 » » return true; |
951 } | 951 } |
952 else | 952 else |
953 { | 953 { |
954 » » if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) return FALSE; | 954 » » if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) return false; |
955 | 955 |
956 CFX_WideString csCreator; | 956 CFX_WideString csCreator; |
957 vp >> csCreator; | 957 vp >> csCreator; |
958 pDictionary->SetAtString("Creator", PDF_EncodeText(csCreator)); | 958 pDictionary->SetAtString("Creator", PDF_EncodeText(csCreator)); |
959 m_pDocument->SetChangeMark(); | 959 m_pDocument->SetChangeMark(); |
960 » » return TRUE; | 960 » » return true; |
961 } | 961 } |
962 } | 962 } |
963 | 963 |
964 FX_BOOL Document::delay(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sE
rror) | 964 bool Document::delay(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sErro
r) |
965 { | 965 { |
966 if (vp.IsGetting()) | 966 if (vp.IsGetting()) |
967 { | 967 { |
968 vp << m_bDelay; | 968 vp << m_bDelay; |
969 » » return TRUE; | 969 » » return true; |
970 } | 970 } |
971 else | 971 else |
972 { | 972 { |
973 ASSERT(m_pDocument != NULL); | 973 ASSERT(m_pDocument != NULL); |
974 | 974 |
975 » » if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) return FALSE; | 975 » » if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) return false; |
976 | 976 |
977 bool b; | 977 bool b; |
978 vp >> b; | 978 vp >> b; |
979 | 979 |
980 m_bDelay = b; | 980 m_bDelay = b; |
981 | 981 |
982 if (m_bDelay) | 982 if (m_bDelay) |
983 { | 983 { |
984 for (int i=0,sz=m_DelayData.GetSize(); i<sz; i++) | 984 for (int i=0,sz=m_DelayData.GetSize(); i<sz; i++) |
985 delete m_DelayData.GetAt(i); | 985 delete m_DelayData.GetAt(i); |
(...skipping 16 matching lines...) Expand all Loading... |
1002 | 1002 |
1003 for (int i=0,sz=DelayDataToProcess.GetSize(); i < sz; i+
+) | 1003 for (int i=0,sz=DelayDataToProcess.GetSize(); i < sz; i+
+) |
1004 { | 1004 { |
1005 CJS_DelayData* pData = DelayDataToProcess.GetAt(
i); | 1005 CJS_DelayData* pData = DelayDataToProcess.GetAt(
i); |
1006 Field::DoDelay(m_pDocument, pData); | 1006 Field::DoDelay(m_pDocument, pData); |
1007 DelayDataToProcess.SetAt(i,NULL); | 1007 DelayDataToProcess.SetAt(i,NULL); |
1008 delete pData; | 1008 delete pData; |
1009 } | 1009 } |
1010 } | 1010 } |
1011 | 1011 |
1012 » » return TRUE; | 1012 » » return true; |
1013 } | 1013 } |
1014 } | 1014 } |
1015 | 1015 |
1016 FX_BOOL Document::keywords(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString&
sError) | 1016 bool Document::keywords(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sE
rror) |
1017 { | 1017 { |
1018 ASSERT(m_pDocument != NULL); | 1018 ASSERT(m_pDocument != NULL); |
1019 | 1019 |
1020 CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetInfo(); | 1020 CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetInfo(); |
1021 » if (!pDictionary)return FALSE; | 1021 » if (!pDictionary)return false; |
1022 | 1022 |
1023 if (vp.IsGetting()) | 1023 if (vp.IsGetting()) |
1024 { | 1024 { |
1025 vp << pDictionary->GetUnicodeText("Keywords"); | 1025 vp << pDictionary->GetUnicodeText("Keywords"); |
1026 » » return TRUE; | 1026 » » return true; |
1027 } | 1027 } |
1028 else | 1028 else |
1029 { | 1029 { |
1030 » » if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) return FALSE; | 1030 » » if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) return false; |
1031 | 1031 |
1032 CFX_WideString csKeywords; | 1032 CFX_WideString csKeywords; |
1033 vp >> csKeywords; | 1033 vp >> csKeywords; |
1034 pDictionary->SetAtString("Keywords", PDF_EncodeText(csKeywords))
; | 1034 pDictionary->SetAtString("Keywords", PDF_EncodeText(csKeywords))
; |
1035 m_pDocument->SetChangeMark(); | 1035 m_pDocument->SetChangeMark(); |
1036 » » return TRUE; | 1036 » » return true; |
1037 } | 1037 } |
1038 } | 1038 } |
1039 | 1039 |
1040 FX_BOOL Document::modDate(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString&
sError) | 1040 bool Document::modDate(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sEr
ror) |
1041 { | 1041 { |
1042 ASSERT(m_pDocument != NULL); | 1042 ASSERT(m_pDocument != NULL); |
1043 | 1043 |
1044 CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetInfo(); | 1044 CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetInfo(); |
1045 » if (!pDictionary)return FALSE; | 1045 » if (!pDictionary)return false; |
1046 | 1046 |
1047 if (vp.IsGetting()) | 1047 if (vp.IsGetting()) |
1048 { | 1048 { |
1049 vp << pDictionary->GetUnicodeText("ModDate"); | 1049 vp << pDictionary->GetUnicodeText("ModDate"); |
1050 » » return TRUE; | 1050 » » return true; |
1051 } | 1051 } |
1052 else | 1052 else |
1053 { | 1053 { |
1054 » » if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) return FALSE; | 1054 » » if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) return false; |
1055 | 1055 |
1056 CFX_WideString csmodDate; | 1056 CFX_WideString csmodDate; |
1057 vp >> csmodDate; | 1057 vp >> csmodDate; |
1058 pDictionary->SetAtString("ModDate", PDF_EncodeText(csmodDate)); | 1058 pDictionary->SetAtString("ModDate", PDF_EncodeText(csmodDate)); |
1059 m_pDocument->SetChangeMark(); | 1059 m_pDocument->SetChangeMark(); |
1060 » » return TRUE; | 1060 » » return true; |
1061 } | 1061 } |
1062 } | 1062 } |
1063 | 1063 |
1064 FX_BOOL Document::producer(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString&
sError) | 1064 bool Document::producer(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sE
rror) |
1065 { | 1065 { |
1066 ASSERT(m_pDocument != NULL); | 1066 ASSERT(m_pDocument != NULL); |
1067 | 1067 |
1068 CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetInfo(); | 1068 CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetInfo(); |
1069 » if (!pDictionary)return FALSE; | 1069 » if (!pDictionary)return false; |
1070 | 1070 |
1071 if (vp.IsGetting()) | 1071 if (vp.IsGetting()) |
1072 { | 1072 { |
1073 vp << pDictionary->GetUnicodeText("Producer"); | 1073 vp << pDictionary->GetUnicodeText("Producer"); |
1074 » » return TRUE; | 1074 » » return true; |
1075 } | 1075 } |
1076 else | 1076 else |
1077 { | 1077 { |
1078 » » if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) return FALSE; | 1078 » » if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) return false; |
1079 | 1079 |
1080 CFX_WideString csproducer; | 1080 CFX_WideString csproducer; |
1081 vp >> csproducer; | 1081 vp >> csproducer; |
1082 pDictionary->SetAtString("Producer", PDF_EncodeText(csproducer))
; | 1082 pDictionary->SetAtString("Producer", PDF_EncodeText(csproducer))
; |
1083 m_pDocument->SetChangeMark(); | 1083 m_pDocument->SetChangeMark(); |
1084 » » return TRUE; | 1084 » » return true; |
1085 } | 1085 } |
1086 } | 1086 } |
1087 | 1087 |
1088 FX_BOOL Document::subject(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString&
sError) | 1088 bool Document::subject(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sEr
ror) |
1089 { | 1089 { |
1090 ASSERT(m_pDocument != NULL); | 1090 ASSERT(m_pDocument != NULL); |
1091 | 1091 |
1092 CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetInfo(); | 1092 CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetInfo(); |
1093 » if (!pDictionary)return FALSE; | 1093 » if (!pDictionary)return false; |
1094 | 1094 |
1095 if (vp.IsGetting()) | 1095 if (vp.IsGetting()) |
1096 { | 1096 { |
1097 vp << pDictionary->GetUnicodeText("Subject"); | 1097 vp << pDictionary->GetUnicodeText("Subject"); |
1098 » » return TRUE; | 1098 » » return true; |
1099 } | 1099 } |
1100 else | 1100 else |
1101 { | 1101 { |
1102 » » if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) return FALSE; | 1102 » » if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) return false; |
1103 | 1103 |
1104 CFX_WideString cssubject; | 1104 CFX_WideString cssubject; |
1105 vp >> cssubject; | 1105 vp >> cssubject; |
1106 pDictionary->SetAtString("Subject", PDF_EncodeText(cssubject)); | 1106 pDictionary->SetAtString("Subject", PDF_EncodeText(cssubject)); |
1107 m_pDocument->SetChangeMark(); | 1107 m_pDocument->SetChangeMark(); |
1108 » » return TRUE; | 1108 » » return true; |
1109 } | 1109 } |
1110 } | 1110 } |
1111 | 1111 |
1112 FX_BOOL Document::title(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sE
rror) | 1112 bool Document::title(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sErro
r) |
1113 { | 1113 { |
1114 ASSERT(m_pDocument != NULL); | 1114 ASSERT(m_pDocument != NULL); |
1115 | 1115 |
1116 if (m_pDocument == NULL || m_pDocument->GetDocument() == NULL) | 1116 if (m_pDocument == NULL || m_pDocument->GetDocument() == NULL) |
1117 » » return FALSE; | 1117 » » return false; |
1118 | 1118 |
1119 CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetInfo(); | 1119 CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetInfo(); |
1120 » if (!pDictionary)return FALSE; | 1120 » if (!pDictionary)return false; |
1121 | 1121 |
1122 if (vp.IsGetting()) | 1122 if (vp.IsGetting()) |
1123 { | 1123 { |
1124 vp << pDictionary->GetUnicodeText("Title"); | 1124 vp << pDictionary->GetUnicodeText("Title"); |
1125 » » return TRUE; | 1125 » » return true; |
1126 } | 1126 } |
1127 else | 1127 else |
1128 { | 1128 { |
1129 » » if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) return FALSE; | 1129 » » if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) return false; |
1130 | 1130 |
1131 CFX_WideString cstitle; | 1131 CFX_WideString cstitle; |
1132 vp >> cstitle; | 1132 vp >> cstitle; |
1133 pDictionary->SetAtString("Title", PDF_EncodeText(cstitle)); | 1133 pDictionary->SetAtString("Title", PDF_EncodeText(cstitle)); |
1134 m_pDocument->SetChangeMark(); | 1134 m_pDocument->SetChangeMark(); |
1135 » » return TRUE; | 1135 » » return true; |
1136 } | 1136 } |
1137 } | 1137 } |
1138 | 1138 |
1139 FX_BOOL Document::numPages(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString&
sError) | 1139 bool Document::numPages(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sE
rror) |
1140 { | 1140 { |
1141 if (vp.IsSetting()) { | 1141 if (vp.IsSetting()) { |
1142 CJS_Context* pContext = static_cast<CJS_Context*>(cc); | 1142 CJS_Context* pContext = static_cast<CJS_Context*>(cc); |
1143 sError = JSGetStringFromID(pContext, IDS_STRING_JSREADONLY); | 1143 sError = JSGetStringFromID(pContext, IDS_STRING_JSREADONLY); |
1144 » » return FALSE; | 1144 » » return false; |
1145 } | 1145 } |
1146 vp << m_pDocument->GetPageCount(); | 1146 vp << m_pDocument->GetPageCount(); |
1147 » return TRUE; | 1147 » return true; |
1148 } | 1148 } |
1149 | 1149 |
1150 FX_BOOL Document::external(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString&
sError) | 1150 bool Document::external(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sE
rror) |
1151 { | 1151 { |
1152 //In Chrome case,should always return true. | 1152 //In Chrome case,should always return true. |
1153 if (vp.IsGetting()) { | 1153 if (vp.IsGetting()) { |
1154 » » vp << TRUE; | 1154 » » vp << true; |
1155 } | 1155 } |
1156 » return TRUE; | 1156 » return true; |
1157 } | 1157 } |
1158 | 1158 |
1159 FX_BOOL Document::filesize(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString&
sError) | 1159 bool Document::filesize(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sE
rror) |
1160 { | 1160 { |
1161 if (vp.IsSetting()) { | 1161 if (vp.IsSetting()) { |
1162 CJS_Context* pContext = static_cast<CJS_Context*>(cc); | 1162 CJS_Context* pContext = static_cast<CJS_Context*>(cc); |
1163 sError = JSGetStringFromID(pContext, IDS_STRING_JSREADONLY); | 1163 sError = JSGetStringFromID(pContext, IDS_STRING_JSREADONLY); |
1164 » » return FALSE; | 1164 » » return false; |
1165 } | 1165 } |
1166 vp << 0; | 1166 vp << 0; |
1167 » return TRUE; | 1167 » return true; |
1168 } | 1168 } |
1169 | 1169 |
1170 FX_BOOL Document::mouseX(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& s
Error) | 1170 bool Document::mouseX(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sErr
or) |
1171 { | 1171 { |
1172 » return TRUE; | 1172 » return true; |
1173 } | 1173 } |
1174 | 1174 |
1175 FX_BOOL Document::mouseY(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& s
Error) | 1175 bool Document::mouseY(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sErr
or) |
1176 { | 1176 { |
1177 » return TRUE; | 1177 » return true; |
1178 } | 1178 } |
1179 | 1179 |
1180 FX_BOOL Document::baseURL(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString&
sError) | 1180 bool Document::baseURL(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sEr
ror) |
1181 { | 1181 { |
1182 if (vp.IsGetting()) | 1182 if (vp.IsGetting()) |
1183 { | 1183 { |
1184 vp << m_cwBaseURL; | 1184 vp << m_cwBaseURL; |
1185 } | 1185 } |
1186 else | 1186 else |
1187 { | 1187 { |
1188 vp >> m_cwBaseURL; | 1188 vp >> m_cwBaseURL; |
1189 } | 1189 } |
1190 » return TRUE; | 1190 » return true; |
1191 } | 1191 } |
1192 | 1192 |
1193 FX_BOOL Document::calculate(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString
& sError) | 1193 bool Document::calculate(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& s
Error) |
1194 { | 1194 { |
1195 ASSERT(m_pDocument != NULL); | 1195 ASSERT(m_pDocument != NULL); |
1196 | 1196 |
1197 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInte
rForm(); | 1197 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInte
rForm(); |
1198 ASSERT(pInterForm != NULL); | 1198 ASSERT(pInterForm != NULL); |
1199 | 1199 |
1200 if (vp.IsGetting()) | 1200 if (vp.IsGetting()) |
1201 { | 1201 { |
1202 if (pInterForm->IsCalculateEnabled()) | 1202 if (pInterForm->IsCalculateEnabled()) |
1203 vp << true; | 1203 vp << true; |
1204 else | 1204 else |
1205 vp << false; | 1205 vp << false; |
1206 } | 1206 } |
1207 else | 1207 else |
1208 { | 1208 { |
1209 bool bCalculate; | 1209 bool bCalculate; |
1210 vp >> bCalculate; | 1210 vp >> bCalculate; |
1211 | 1211 |
1212 pInterForm->EnableCalculate(bCalculate); | 1212 pInterForm->EnableCalculate(bCalculate); |
1213 } | 1213 } |
1214 | 1214 |
1215 » return TRUE; | 1215 » return true; |
1216 } | 1216 } |
1217 | 1217 |
1218 FX_BOOL Document::documentFileName(IFXJS_Context* cc, CJS_PropValue& vp, CFX_Wid
eString& sError) | 1218 bool Document::documentFileName(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideSt
ring& sError) |
1219 { | 1219 { |
1220 if (vp.IsSetting()) { | 1220 if (vp.IsSetting()) { |
1221 CJS_Context* pContext = static_cast<CJS_Context*>(cc); | 1221 CJS_Context* pContext = static_cast<CJS_Context*>(cc); |
1222 sError = JSGetStringFromID(pContext, IDS_STRING_JSREADONLY); | 1222 sError = JSGetStringFromID(pContext, IDS_STRING_JSREADONLY); |
1223 » » return FALSE; | 1223 » » return false; |
1224 } | 1224 } |
1225 CFX_WideString wsFilePath = m_pDocument->GetPath(); | 1225 CFX_WideString wsFilePath = m_pDocument->GetPath(); |
1226 int32_t i = wsFilePath.GetLength() - 1; | 1226 int32_t i = wsFilePath.GetLength() - 1; |
1227 for ( ; i >= 0; i-- ) | 1227 for ( ; i >= 0; i-- ) |
1228 { | 1228 { |
1229 if ( wsFilePath.GetAt( i ) == L'\\' || wsFilePath.GetAt( i ) ==
L'/' ) | 1229 if ( wsFilePath.GetAt( i ) == L'\\' || wsFilePath.GetAt( i ) ==
L'/' ) |
1230 break; | 1230 break; |
1231 } | 1231 } |
1232 if ( i >= 0 && i < wsFilePath.GetLength() - 1 ) | 1232 if ( i >= 0 && i < wsFilePath.GetLength() - 1 ) |
1233 { | 1233 { |
1234 vp << ( wsFilePath.GetBuffer( wsFilePath.GetLength() ) + i + 1 )
; | 1234 vp << ( wsFilePath.GetBuffer( wsFilePath.GetLength() ) + i + 1 )
; |
1235 }else{ | 1235 }else{ |
1236 vp << L""; | 1236 vp << L""; |
1237 } | 1237 } |
1238 » return TRUE; | 1238 » return true; |
1239 } | 1239 } |
1240 | 1240 |
1241 CFX_WideString Document::ReversalStr(CFX_WideString cbFrom) | 1241 CFX_WideString Document::ReversalStr(CFX_WideString cbFrom) |
1242 { | 1242 { |
1243 size_t iLength = cbFrom.GetLength(); | 1243 size_t iLength = cbFrom.GetLength(); |
1244 pdfium::base::CheckedNumeric<size_t> iSize = sizeof(wchar_t); | 1244 pdfium::base::CheckedNumeric<size_t> iSize = sizeof(wchar_t); |
1245 iSize *= (iLength + 1); | 1245 iSize *= (iLength + 1); |
1246 wchar_t* pResult = (wchar_t*)malloc(iSize.ValueOrDie()); | 1246 wchar_t* pResult = (wchar_t*)malloc(iSize.ValueOrDie()); |
1247 wchar_t* pFrom = (wchar_t*)cbFrom.GetBuffer(iLength); | 1247 wchar_t* pFrom = (wchar_t*)cbFrom.GetBuffer(iLength); |
1248 | 1248 |
(...skipping 29 matching lines...) Expand all Loading... |
1278 } | 1278 } |
1279 pResult[iLength] = L'\0'; | 1279 pResult[iLength] = L'\0'; |
1280 | 1280 |
1281 cbFrom.ReleaseBuffer(); | 1281 cbFrom.ReleaseBuffer(); |
1282 CFX_WideString cbRet = CFX_WideString(pResult); | 1282 CFX_WideString cbRet = CFX_WideString(pResult); |
1283 free(pResult); | 1283 free(pResult); |
1284 pResult = NULL; | 1284 pResult = NULL; |
1285 return cbRet; | 1285 return cbRet; |
1286 } | 1286 } |
1287 | 1287 |
1288 FX_BOOL Document::path(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sEr
ror) | 1288 bool Document::path(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError
) |
1289 { | 1289 { |
1290 if (vp.IsSetting()) { | 1290 if (vp.IsSetting()) { |
1291 CJS_Context* pContext = static_cast<CJS_Context*>(cc); | 1291 CJS_Context* pContext = static_cast<CJS_Context*>(cc); |
1292 sError = JSGetStringFromID(pContext, IDS_STRING_JSREADONLY); | 1292 sError = JSGetStringFromID(pContext, IDS_STRING_JSREADONLY); |
1293 » » return FALSE; | 1293 » » return false; |
1294 } | 1294 } |
1295 vp << app::SysPathToPDFPath(m_pDocument->GetPath()); | 1295 vp << app::SysPathToPDFPath(m_pDocument->GetPath()); |
1296 » return TRUE; | 1296 » return true; |
1297 } | 1297 } |
1298 | 1298 |
1299 FX_BOOL Document::pageWindowRect(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideS
tring& sError) | 1299 bool Document::pageWindowRect(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideStri
ng& sError) |
1300 { | 1300 { |
1301 » return TRUE; | 1301 » return true; |
1302 } | 1302 } |
1303 | 1303 |
1304 FX_BOOL Document::layout(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& s
Error) | 1304 bool Document::layout(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sErr
or) |
1305 { | 1305 { |
1306 » return TRUE; | 1306 » return true; |
1307 } | 1307 } |
1308 | 1308 |
1309 FX_BOOL Document::addLink(IFXJS_Context* cc, const CJS_Parameters& params, CJS_V
alue& vRet, CFX_WideString& sError) | 1309 bool Document::addLink(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Valu
e& vRet, CFX_WideString& sError) |
1310 { | 1310 { |
1311 » return TRUE; | 1311 » return true; |
1312 } | 1312 } |
1313 | 1313 |
1314 FX_BOOL Document::closeDoc(IFXJS_Context* cc, const CJS_Parameters& params, CJS_
Value& vRet, CFX_WideString& sError) | 1314 bool Document::closeDoc(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Val
ue& vRet, CFX_WideString& sError) |
1315 { | 1315 { |
1316 ASSERT(m_pDocument != NULL); | 1316 ASSERT(m_pDocument != NULL); |
1317 » return TRUE; | 1317 » return true; |
1318 } | 1318 } |
1319 | 1319 |
1320 FX_BOOL Document::getPageBox(IFXJS_Context* cc, const CJS_Parameters& params, CJ
S_Value& vRet, CFX_WideString& sError) | 1320 bool Document::getPageBox(IFXJS_Context* cc, const CJS_Parameters& params, CJS_V
alue& vRet, CFX_WideString& sError) |
1321 { | 1321 { |
1322 » return TRUE; | 1322 » return true; |
1323 } | 1323 } |
1324 | 1324 |
1325 FX_BOOL Document::getAnnot(IFXJS_Context* cc, const CJS_Parameters& params, CJS_
Value& vRet, CFX_WideString& sError) | 1325 bool Document::getAnnot(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Val
ue& vRet, CFX_WideString& sError) |
1326 { | 1326 { |
1327 » return TRUE; | 1327 » return true; |
1328 } | 1328 } |
1329 | 1329 |
1330 FX_BOOL Document::getAnnots(IFXJS_Context* cc, const CJS_Parameters& params, CJS
_Value& vRet, CFX_WideString& sError) | 1330 bool Document::getAnnots(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Va
lue& vRet, CFX_WideString& sError) |
1331 { | 1331 { |
1332 vRet.SetNull(); | 1332 vRet.SetNull(); |
1333 » return TRUE; | 1333 » return true; |
1334 } | 1334 } |
1335 | 1335 |
1336 FX_BOOL Document::getAnnot3D(IFXJS_Context* cc, const CJS_Parameters& params, CJ
S_Value& vRet, CFX_WideString& sError) | 1336 bool Document::getAnnot3D(IFXJS_Context* cc, const CJS_Parameters& params, CJS_V
alue& vRet, CFX_WideString& sError) |
1337 { | 1337 { |
1338 vRet.SetNull(); | 1338 vRet.SetNull(); |
1339 » return TRUE; | 1339 » return true; |
1340 } | 1340 } |
1341 | 1341 |
1342 FX_BOOL Document::getAnnots3D(IFXJS_Context* cc, const CJS_Parameters& params, C
JS_Value& vRet, CFX_WideString& sError) | 1342 bool Document::getAnnots3D(IFXJS_Context* cc, const CJS_Parameters& params, CJS_
Value& vRet, CFX_WideString& sError) |
1343 { | 1343 { |
1344 vRet = VT_undefined; | 1344 vRet = VT_undefined; |
1345 » return TRUE; | 1345 » return true; |
1346 } | 1346 } |
1347 | 1347 |
1348 FX_BOOL Document::getOCGs(IFXJS_Context* cc, const CJS_Parameters& params, CJS_V
alue& vRet, CFX_WideString& sError) | 1348 bool Document::getOCGs(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Valu
e& vRet, CFX_WideString& sError) |
1349 { | 1349 { |
1350 » return TRUE; | 1350 » return true; |
1351 } | 1351 } |
1352 | 1352 |
1353 FX_BOOL Document::getLinks(IFXJS_Context* cc, const CJS_Parameters& params, CJS_
Value& vRet, CFX_WideString& sError) | 1353 bool Document::getLinks(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Val
ue& vRet, CFX_WideString& sError) |
1354 { | 1354 { |
1355 » return TRUE; | 1355 » return true; |
1356 } | 1356 } |
1357 | 1357 |
1358 bool Document::IsEnclosedInRect(CFX_FloatRect rect, CFX_FloatRect LinkRect) | 1358 bool Document::IsEnclosedInRect(CFX_FloatRect rect, CFX_FloatRect LinkRect) |
1359 { | 1359 { |
1360 if (rect.left <= LinkRect.left | 1360 if (rect.left <= LinkRect.left |
1361 && rect.top <= LinkRect.top | 1361 && rect.top <= LinkRect.top |
1362 && rect.right >= LinkRect.right | 1362 && rect.right >= LinkRect.right |
1363 && rect.bottom >= LinkRect.bottom) | 1363 && rect.bottom >= LinkRect.bottom) |
1364 return true; | 1364 return true; |
1365 else | 1365 else |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1413 for (int i = 0; i < iIndex; i++) | 1413 for (int i = 0; i < iIndex; i++) |
1414 { | 1414 { |
1415 pTemp = pTemp->NextIcon; | 1415 pTemp = pTemp->NextIcon; |
1416 } | 1416 } |
1417 return pTemp; | 1417 return pTemp; |
1418 } | 1418 } |
1419 else | 1419 else |
1420 return NULL; | 1420 return NULL; |
1421 } | 1421 } |
1422 | 1422 |
1423 FX_BOOL Document::addIcon(IFXJS_Context* cc, const CJS_Parameters& params, CJS_V
alue& vRet, CFX_WideString& sError) | 1423 bool Document::addIcon(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Valu
e& vRet, CFX_WideString& sError) |
1424 { | 1424 { |
1425 CJS_Context* pContext = (CJS_Context*)cc; | 1425 CJS_Context* pContext = (CJS_Context*)cc; |
1426 if (params.size() != 2) { | 1426 if (params.size() != 2) { |
1427 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); | 1427 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); |
1428 » » return FALSE; | 1428 » » return false; |
1429 } | 1429 } |
1430 | 1430 |
1431 CFX_WideString swIconName = params[0].ToCFXWideString(); | 1431 CFX_WideString swIconName = params[0].ToCFXWideString(); |
1432 JSFXObject pJSIcon = params[1].ToV8Object(); | 1432 JSFXObject pJSIcon = params[1].ToV8Object(); |
1433 | 1433 |
1434 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 1434 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
1435 if (JS_GetObjDefnID(pJSIcon) != JS_GetObjDefnID(*pRuntime, L"Icon")) { | 1435 if (JS_GetObjDefnID(pJSIcon) != JS_GetObjDefnID(*pRuntime, L"Icon")) { |
1436 sError = JSGetStringFromID(pContext, IDS_STRING_JSTYPEERROR); | 1436 sError = JSGetStringFromID(pContext, IDS_STRING_JSTYPEERROR); |
1437 » » return FALSE; | 1437 » » return false; |
1438 } | 1438 } |
1439 | 1439 |
1440 CJS_EmbedObj* pEmbedObj = params[1].ToCJSObject()->GetEmbedObject(); | 1440 CJS_EmbedObj* pEmbedObj = params[1].ToCJSObject()->GetEmbedObject(); |
1441 if (!pEmbedObj) { | 1441 if (!pEmbedObj) { |
1442 sError = JSGetStringFromID(pContext, IDS_STRING_JSTYPEERROR); | 1442 sError = JSGetStringFromID(pContext, IDS_STRING_JSTYPEERROR); |
1443 » » return FALSE; | 1443 » » return false; |
1444 } | 1444 } |
1445 | 1445 |
1446 Icon* pIcon = (Icon*)pEmbedObj; | 1446 Icon* pIcon = (Icon*)pEmbedObj; |
1447 if (!m_pIconTree) | 1447 if (!m_pIconTree) |
1448 m_pIconTree = new IconTree(); | 1448 m_pIconTree = new IconTree(); |
1449 | 1449 |
1450 IconElement* pNewIcon = new IconElement(); | 1450 IconElement* pNewIcon = new IconElement(); |
1451 pNewIcon->IconName = swIconName; | 1451 pNewIcon->IconName = swIconName; |
1452 pNewIcon->NextIcon = NULL; | 1452 pNewIcon->NextIcon = NULL; |
1453 pNewIcon->IconStream = pIcon; | 1453 pNewIcon->IconStream = pIcon; |
1454 m_pIconTree->InsertIconElement(pNewIcon); | 1454 m_pIconTree->InsertIconElement(pNewIcon); |
1455 » return TRUE; | 1455 » return true; |
1456 } | 1456 } |
1457 | 1457 |
1458 FX_BOOL Document::icons(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sE
rror) | 1458 bool Document::icons(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sErro
r) |
1459 { | 1459 { |
1460 if (vp.IsSetting()) { | 1460 if (vp.IsSetting()) { |
1461 CJS_Context* pContext = static_cast<CJS_Context*>(cc); | 1461 CJS_Context* pContext = static_cast<CJS_Context*>(cc); |
1462 sError = JSGetStringFromID(pContext, IDS_STRING_JSREADONLY); | 1462 sError = JSGetStringFromID(pContext, IDS_STRING_JSREADONLY); |
1463 » » return FALSE; | 1463 » » return false; |
1464 } | 1464 } |
1465 | 1465 |
1466 if (!m_pIconTree) | 1466 if (!m_pIconTree) |
1467 { | 1467 { |
1468 vp.SetNull(); | 1468 vp.SetNull(); |
1469 » » return TRUE; | 1469 » » return true; |
1470 } | 1470 } |
1471 | 1471 |
1472 CJS_Array Icons(m_isolate); | 1472 CJS_Array Icons(m_isolate); |
1473 IconElement* pIconElement = NULL; | 1473 IconElement* pIconElement = NULL; |
1474 int iIconTreeLength = m_pIconTree->GetLength(); | 1474 int iIconTreeLength = m_pIconTree->GetLength(); |
1475 | 1475 |
1476 CJS_Context* pContext = (CJS_Context *)cc; | 1476 CJS_Context* pContext = (CJS_Context *)cc; |
1477 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 1477 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
1478 | 1478 |
1479 for (int i = 0; i < iIconTreeLength; i++) | 1479 for (int i = 0; i < iIconTreeLength; i++) |
1480 { | 1480 { |
1481 pIconElement = (*m_pIconTree)[i]; | 1481 pIconElement = (*m_pIconTree)[i]; |
1482 | 1482 |
1483 JSFXObject pObj = JS_NewFxDynamicObj(*pRuntime, pContext, JS_Ge
tObjDefnID(*pRuntime, L"Icon")); | 1483 JSFXObject pObj = JS_NewFxDynamicObj(*pRuntime, pContext, JS_Ge
tObjDefnID(*pRuntime, L"Icon")); |
1484 » » if (pObj.IsEmpty()) return FALSE; | 1484 » » if (pObj.IsEmpty()) return false; |
1485 | 1485 |
1486 CJS_Icon * pJS_Icon = (CJS_Icon *)JS_GetPrivate(pObj); | 1486 CJS_Icon * pJS_Icon = (CJS_Icon *)JS_GetPrivate(pObj); |
1487 » » if (!pJS_Icon) return FALSE; | 1487 » » if (!pJS_Icon) return false; |
1488 | 1488 |
1489 Icon* pIcon = (Icon*)pJS_Icon->GetEmbedObject(); | 1489 Icon* pIcon = (Icon*)pJS_Icon->GetEmbedObject(); |
1490 » » if (!pIcon)return FALSE; | 1490 » » if (!pIcon)return false; |
1491 | 1491 |
1492 pIcon->SetStream(pIconElement->IconStream->GetStream()); | 1492 pIcon->SetStream(pIconElement->IconStream->GetStream()); |
1493 pIcon->SetIconName(pIconElement->IconName); | 1493 pIcon->SetIconName(pIconElement->IconName); |
1494 Icons.SetElement(i, CJS_Value(m_isolate,pJS_Icon)); | 1494 Icons.SetElement(i, CJS_Value(m_isolate,pJS_Icon)); |
1495 } | 1495 } |
1496 | 1496 |
1497 vp << Icons; | 1497 vp << Icons; |
1498 » return TRUE; | 1498 » return true; |
1499 } | 1499 } |
1500 | 1500 |
1501 FX_BOOL Document::getIcon(IFXJS_Context* cc, const CJS_Parameters& params, CJS_V
alue& vRet, CFX_WideString& sError) | 1501 bool Document::getIcon(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Valu
e& vRet, CFX_WideString& sError) |
1502 { | 1502 { |
1503 CJS_Context* pContext = (CJS_Context *)cc; | 1503 CJS_Context* pContext = (CJS_Context *)cc; |
1504 if (params.size() != 1) { | 1504 if (params.size() != 1) { |
1505 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); | 1505 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); |
1506 » » return FALSE; | 1506 » » return false; |
1507 } | 1507 } |
1508 | 1508 |
1509 if(!m_pIconTree) | 1509 if(!m_pIconTree) |
1510 » » return FALSE; | 1510 » » return false; |
1511 CFX_WideString swIconName = params[0].ToCFXWideString(); | 1511 CFX_WideString swIconName = params[0].ToCFXWideString(); |
1512 int iIconCounts = m_pIconTree->GetLength(); | 1512 int iIconCounts = m_pIconTree->GetLength(); |
1513 | 1513 |
1514 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 1514 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
1515 | 1515 |
1516 for (int i = 0; i < iIconCounts; i++) | 1516 for (int i = 0; i < iIconCounts; i++) |
1517 { | 1517 { |
1518 if ((*m_pIconTree)[i]->IconName == swIconName) | 1518 if ((*m_pIconTree)[i]->IconName == swIconName) |
1519 { | 1519 { |
1520 Icon* pRetIcon = (*m_pIconTree)[i]->IconStream; | 1520 Icon* pRetIcon = (*m_pIconTree)[i]->IconStream; |
1521 | 1521 |
1522 JSFXObject pObj = JS_NewFxDynamicObj(*pRuntime, pContex
t, JS_GetObjDefnID(*pRuntime, L"Icon")); | 1522 JSFXObject pObj = JS_NewFxDynamicObj(*pRuntime, pContex
t, JS_GetObjDefnID(*pRuntime, L"Icon")); |
1523 » » » if (pObj.IsEmpty()) return FALSE; | 1523 » » » if (pObj.IsEmpty()) return false; |
1524 | 1524 |
1525 CJS_Icon * pJS_Icon = (CJS_Icon *)JS_GetPrivate(pObj); | 1525 CJS_Icon * pJS_Icon = (CJS_Icon *)JS_GetPrivate(pObj); |
1526 » » » if (!pJS_Icon) return FALSE; | 1526 » » » if (!pJS_Icon) return false; |
1527 | 1527 |
1528 Icon* pIcon = (Icon*)pJS_Icon->GetEmbedObject(); | 1528 Icon* pIcon = (Icon*)pJS_Icon->GetEmbedObject(); |
1529 » » » if (!pIcon)return FALSE; | 1529 » » » if (!pIcon)return false; |
1530 | 1530 |
1531 pIcon->SetIconName(swIconName); | 1531 pIcon->SetIconName(swIconName); |
1532 pIcon->SetStream(pRetIcon->GetStream()); | 1532 pIcon->SetStream(pRetIcon->GetStream()); |
1533 vRet = pJS_Icon; | 1533 vRet = pJS_Icon; |
1534 » » » return TRUE; | 1534 » » » return true; |
1535 } | 1535 } |
1536 } | 1536 } |
1537 | 1537 |
1538 » return FALSE; | 1538 » return false; |
1539 } | 1539 } |
1540 | 1540 |
1541 FX_BOOL Document::removeIcon(IFXJS_Context* cc, const CJS_Parameters& params, CJ
S_Value& vRet, CFX_WideString& sError) | 1541 bool Document::removeIcon(IFXJS_Context* cc, const CJS_Parameters& params, CJS_V
alue& vRet, CFX_WideString& sError) |
1542 { | 1542 { |
1543 // Unsafe, no supported. | 1543 // Unsafe, no supported. |
1544 return TRUE; | 1544 return true; |
1545 } | 1545 } |
1546 | 1546 |
1547 FX_BOOL Document::createDataObject(IFXJS_Context* cc, const CJS_Parameters& para
ms, CJS_Value& vRet, CFX_WideString& sError) | 1547 bool Document::createDataObject(IFXJS_Context* cc, const CJS_Parameters& params,
CJS_Value& vRet, CFX_WideString& sError) |
1548 { | 1548 { |
1549 // Unsafe, not implemented. | 1549 // Unsafe, not implemented. |
1550 return TRUE; | 1550 return true; |
1551 } | 1551 } |
1552 | 1552 |
1553 FX_BOOL Document::media(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sE
rror) | 1553 bool Document::media(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sErro
r) |
1554 { | 1554 { |
1555 » return TRUE; | 1555 » return true; |
1556 } | 1556 } |
1557 | 1557 |
1558 FX_BOOL Document::calculateNow(IFXJS_Context* cc, const CJS_Parameters& params,
CJS_Value& vRet, CFX_WideString& sError) | 1558 bool Document::calculateNow(IFXJS_Context* cc, const CJS_Parameters& params, CJS
_Value& vRet, CFX_WideString& sError) |
1559 { | 1559 { |
1560 ASSERT(m_pDocument != NULL); | 1560 ASSERT(m_pDocument != NULL); |
1561 | 1561 |
1562 if (!(m_pDocument->GetPermissions(FPDFPERM_MODIFY) || | 1562 if (!(m_pDocument->GetPermissions(FPDFPERM_MODIFY) || |
1563 m_pDocument->GetPermissions(FPDFPERM_ANNOT_FORM) || | 1563 m_pDocument->GetPermissions(FPDFPERM_ANNOT_FORM) || |
1564 » » m_pDocument->GetPermissions(FPDFPERM_FILL_FORM))) return FALSE; | 1564 » » m_pDocument->GetPermissions(FPDFPERM_FILL_FORM))) return false; |
1565 | 1565 |
1566 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInte
rForm(); | 1566 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInte
rForm(); |
1567 ASSERT(pInterForm != NULL); | 1567 ASSERT(pInterForm != NULL); |
1568 pInterForm->OnCalculate(); | 1568 pInterForm->OnCalculate(); |
1569 » return TRUE; | 1569 » return true; |
1570 } | 1570 } |
1571 | 1571 |
1572 FX_BOOL Document::Collab(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& s
Error) | 1572 bool Document::Collab(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sErr
or) |
1573 { | 1573 { |
1574 » return TRUE; | 1574 » return true; |
1575 } | 1575 } |
1576 | 1576 |
1577 FX_BOOL Document::getPageNthWord(IFXJS_Context* cc, const CJS_Parameters& params
, CJS_Value& vRet, CFX_WideString& sError) | 1577 bool Document::getPageNthWord(IFXJS_Context* cc, const CJS_Parameters& params, C
JS_Value& vRet, CFX_WideString& sError) |
1578 { | 1578 { |
1579 ASSERT(m_pDocument != NULL); | 1579 ASSERT(m_pDocument != NULL); |
1580 | 1580 |
1581 » if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) return FALSE; | 1581 » if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) return false; |
1582 | 1582 |
1583 int nPageNo = params.GetSize() > 0 ? params[0].ToInt() : 0; | 1583 int nPageNo = params.GetSize() > 0 ? params[0].ToInt() : 0; |
1584 int nWordNo = params.GetSize() > 1 ? params[1].ToInt() : 0; | 1584 int nWordNo = params.GetSize() > 1 ? params[1].ToInt() : 0; |
1585 bool bStrip = params.GetSize() > 2 ? params[2].ToBool() : true; | 1585 bool bStrip = params.GetSize() > 2 ? params[2].ToBool() : true; |
1586 | 1586 |
1587 CPDF_Document* pDocument = m_pDocument->GetDocument(); | 1587 CPDF_Document* pDocument = m_pDocument->GetDocument(); |
1588 » if (!pDocument) return FALSE; | 1588 » if (!pDocument) return false; |
1589 | 1589 |
1590 CJS_Context* pContext = static_cast<CJS_Context*>(cc); | 1590 CJS_Context* pContext = static_cast<CJS_Context*>(cc); |
1591 if (nPageNo < 0 || nPageNo >= pDocument->GetPageCount()) | 1591 if (nPageNo < 0 || nPageNo >= pDocument->GetPageCount()) |
1592 { | 1592 { |
1593 sError = JSGetStringFromID(pContext, IDS_STRING_JSVALUEERROR); | 1593 sError = JSGetStringFromID(pContext, IDS_STRING_JSVALUEERROR); |
1594 » » return FALSE; | 1594 » » return false; |
1595 } | 1595 } |
1596 | 1596 |
1597 CPDF_Dictionary* pPageDict = pDocument->GetPage(nPageNo); | 1597 CPDF_Dictionary* pPageDict = pDocument->GetPage(nPageNo); |
1598 » if (!pPageDict) return FALSE; | 1598 » if (!pPageDict) return false; |
1599 | 1599 |
1600 CPDF_Page page; | 1600 CPDF_Page page; |
1601 page.Load(pDocument, pPageDict); | 1601 page.Load(pDocument, pPageDict); |
1602 page.StartParse(); | 1602 page.StartParse(); |
1603 page.ParseContent(); | 1603 page.ParseContent(); |
1604 | 1604 |
1605 FX_POSITION pos = page.GetFirstObjectPosition(); | 1605 FX_POSITION pos = page.GetFirstObjectPosition(); |
1606 | 1606 |
1607 int nWords = 0; | 1607 int nWords = 0; |
1608 | 1608 |
(...skipping 18 matching lines...) Expand all Loading... |
1627 } | 1627 } |
1628 } | 1628 } |
1629 | 1629 |
1630 if (bStrip) | 1630 if (bStrip) |
1631 { | 1631 { |
1632 swRet.TrimLeft(); | 1632 swRet.TrimLeft(); |
1633 swRet.TrimRight(); | 1633 swRet.TrimRight(); |
1634 } | 1634 } |
1635 | 1635 |
1636 vRet = swRet.c_str(); | 1636 vRet = swRet.c_str(); |
1637 » return TRUE; | 1637 » return true; |
1638 } | 1638 } |
1639 | 1639 |
1640 FX_BOOL Document::getPageNthWordQuads(IFXJS_Context* cc, const CJS_Parameters& p
arams, CJS_Value& vRet, CFX_WideString& sError) | 1640 bool Document::getPageNthWordQuads(IFXJS_Context* cc, const CJS_Parameters& para
ms, CJS_Value& vRet, CFX_WideString& sError) |
1641 { | 1641 { |
1642 ASSERT(m_pDocument != NULL); | 1642 ASSERT(m_pDocument != NULL); |
1643 | 1643 |
1644 » if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) return FALSE; | 1644 » if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) return false; |
1645 | 1645 |
1646 » return FALSE; | 1646 » return false; |
1647 } | 1647 } |
1648 | 1648 |
1649 FX_BOOL Document::getPageNumWords(IFXJS_Context* cc, const CJS_Parameters& param
s, CJS_Value& vRet, CFX_WideString& sError) | 1649 bool Document::getPageNumWords(IFXJS_Context* cc, const CJS_Parameters& params,
CJS_Value& vRet, CFX_WideString& sError) |
1650 { | 1650 { |
1651 ASSERT(m_pDocument != NULL); | 1651 ASSERT(m_pDocument != NULL); |
1652 | 1652 |
1653 » if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) return FALSE; | 1653 » if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) return false; |
1654 | 1654 |
1655 int nPageNo = params.GetSize() > 0 ? params[0].ToInt() : 0; | 1655 int nPageNo = params.GetSize() > 0 ? params[0].ToInt() : 0; |
1656 | 1656 |
1657 CPDF_Document* pDocument = m_pDocument->GetDocument(); | 1657 CPDF_Document* pDocument = m_pDocument->GetDocument(); |
1658 ASSERT(pDocument != NULL); | 1658 ASSERT(pDocument != NULL); |
1659 | 1659 |
1660 CJS_Context* pContext = static_cast<CJS_Context*>(cc); | 1660 CJS_Context* pContext = static_cast<CJS_Context*>(cc); |
1661 if (nPageNo < 0 || nPageNo >= pDocument->GetPageCount()) | 1661 if (nPageNo < 0 || nPageNo >= pDocument->GetPageCount()) |
1662 { | 1662 { |
1663 sError = JSGetStringFromID(pContext, IDS_STRING_JSVALUEERROR); | 1663 sError = JSGetStringFromID(pContext, IDS_STRING_JSVALUEERROR); |
1664 » » return FALSE; | 1664 » » return false; |
1665 } | 1665 } |
1666 | 1666 |
1667 CPDF_Dictionary* pPageDict = pDocument->GetPage(nPageNo); | 1667 CPDF_Dictionary* pPageDict = pDocument->GetPage(nPageNo); |
1668 » if (!pPageDict) return FALSE; | 1668 » if (!pPageDict) return false; |
1669 | 1669 |
1670 CPDF_Page page; | 1670 CPDF_Page page; |
1671 page.Load(pDocument, pPageDict); | 1671 page.Load(pDocument, pPageDict); |
1672 page.StartParse(); | 1672 page.StartParse(); |
1673 page.ParseContent(); | 1673 page.ParseContent(); |
1674 | 1674 |
1675 FX_POSITION pos = page.GetFirstObjectPosition(); | 1675 FX_POSITION pos = page.GetFirstObjectPosition(); |
1676 | 1676 |
1677 int nWords = 0; | 1677 int nWords = 0; |
1678 | 1678 |
1679 while (pos) | 1679 while (pos) |
1680 { | 1680 { |
1681 if (CPDF_PageObject* pPageObj = page.GetNextObject(pos)) | 1681 if (CPDF_PageObject* pPageObj = page.GetNextObject(pos)) |
1682 { | 1682 { |
1683 if (pPageObj->m_Type == PDFPAGE_TEXT) | 1683 if (pPageObj->m_Type == PDFPAGE_TEXT) |
1684 { | 1684 { |
1685 CPDF_TextObject* pTextObj = (CPDF_TextObject*)pP
ageObj; | 1685 CPDF_TextObject* pTextObj = (CPDF_TextObject*)pP
ageObj; |
1686 nWords += CountWords(pTextObj); | 1686 nWords += CountWords(pTextObj); |
1687 } | 1687 } |
1688 } | 1688 } |
1689 } | 1689 } |
1690 | 1690 |
1691 vRet = nWords; | 1691 vRet = nWords; |
1692 | 1692 |
1693 » return TRUE; | 1693 » return true; |
1694 } | 1694 } |
1695 | 1695 |
1696 FX_BOOL Document::getPrintParams(IFXJS_Context* cc, const CJS_Parameters& params
, CJS_Value& vRet, CFX_WideString& sError) | 1696 bool Document::getPrintParams(IFXJS_Context* cc, const CJS_Parameters& params, C
JS_Value& vRet, CFX_WideString& sError) |
1697 { | 1697 { |
1698 CJS_Context* pContext = (CJS_Context*)cc; | 1698 CJS_Context* pContext = (CJS_Context*)cc; |
1699 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 1699 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
1700 JSFXObject pRetObj = JS_NewFxDynamicObj(*pRuntime, pContext, JS_GetObjDe
fnID(*pRuntime, L"PrintParamsObj")); | 1700 JSFXObject pRetObj = JS_NewFxDynamicObj(*pRuntime, pContext, JS_GetObjDe
fnID(*pRuntime, L"PrintParamsObj")); |
1701 | 1701 |
1702 // Not implemented yet. | 1702 // Not implemented yet. |
1703 | 1703 |
1704 vRet = pRetObj; | 1704 vRet = pRetObj; |
1705 » return TRUE; | 1705 » return true; |
1706 } | 1706 } |
1707 | 1707 |
1708 #define ISLATINWORD(u) (u != 0x20 && u <= 0x28FF) | 1708 #define ISLATINWORD(u) (u != 0x20 && u <= 0x28FF) |
1709 | 1709 |
1710 int Document::CountWords(CPDF_TextObject* pTextObj) | 1710 int Document::CountWords(CPDF_TextObject* pTextObj) |
1711 { | 1711 { |
1712 if (!pTextObj) return 0; | 1712 if (!pTextObj) return 0; |
1713 | 1713 |
1714 int nWords = 0; | 1714 int nWords = 0; |
1715 | 1715 |
1716 CPDF_Font* pFont = pTextObj->GetFont(); | 1716 CPDF_Font* pFont = pTextObj->GetFont(); |
1717 if (!pFont) return 0; | 1717 if (!pFont) return 0; |
1718 | 1718 |
1719 » FX_BOOL bIsLatin = FALSE; | 1719 » bool bIsLatin = false; |
1720 | 1720 |
1721 for (int i=0, sz=pTextObj->CountChars(); i<sz; i++) | 1721 for (int i=0, sz=pTextObj->CountChars(); i<sz; i++) |
1722 { | 1722 { |
1723 FX_DWORD charcode = -1; | 1723 FX_DWORD charcode = -1; |
1724 FX_FLOAT kerning; | 1724 FX_FLOAT kerning; |
1725 | 1725 |
1726 pTextObj->GetCharInfo(i, charcode, kerning); | 1726 pTextObj->GetCharInfo(i, charcode, kerning); |
1727 CFX_WideString swUnicode = pFont->UnicodeFromCharCode(charcode); | 1727 CFX_WideString swUnicode = pFont->UnicodeFromCharCode(charcode); |
1728 | 1728 |
1729 FX_WORD unicode = 0; | 1729 FX_WORD unicode = 0; |
(...skipping 14 matching lines...) Expand all Loading... |
1744 CFX_WideString Document::GetObjWordStr(CPDF_TextObject* pTextObj, int nWordIndex
) | 1744 CFX_WideString Document::GetObjWordStr(CPDF_TextObject* pTextObj, int nWordIndex
) |
1745 { | 1745 { |
1746 ASSERT(pTextObj != NULL); | 1746 ASSERT(pTextObj != NULL); |
1747 | 1747 |
1748 CFX_WideString swRet; | 1748 CFX_WideString swRet; |
1749 | 1749 |
1750 CPDF_Font* pFont = pTextObj->GetFont(); | 1750 CPDF_Font* pFont = pTextObj->GetFont(); |
1751 if (!pFont) return L""; | 1751 if (!pFont) return L""; |
1752 | 1752 |
1753 int nWords = 0; | 1753 int nWords = 0; |
1754 » FX_BOOL bIsLatin = FALSE; | 1754 » bool bIsLatin = false; |
1755 | 1755 |
1756 for (int i=0, sz=pTextObj->CountChars(); i<sz; i++) | 1756 for (int i=0, sz=pTextObj->CountChars(); i<sz; i++) |
1757 { | 1757 { |
1758 FX_DWORD charcode = -1; | 1758 FX_DWORD charcode = -1; |
1759 FX_FLOAT kerning; | 1759 FX_FLOAT kerning; |
1760 | 1760 |
1761 pTextObj->GetCharInfo(i, charcode, kerning); | 1761 pTextObj->GetCharInfo(i, charcode, kerning); |
1762 CFX_WideString swUnicode = pFont->UnicodeFromCharCode(charcode); | 1762 CFX_WideString swUnicode = pFont->UnicodeFromCharCode(charcode); |
1763 | 1763 |
1764 FX_WORD unicode = 0; | 1764 FX_WORD unicode = 0; |
(...skipping 10 matching lines...) Expand all Loading... |
1775 nWords++; | 1775 nWords++; |
1776 } | 1776 } |
1777 | 1777 |
1778 if (nWords-1 == nWordIndex) | 1778 if (nWords-1 == nWordIndex) |
1779 swRet += unicode; | 1779 swRet += unicode; |
1780 } | 1780 } |
1781 | 1781 |
1782 return swRet; | 1782 return swRet; |
1783 } | 1783 } |
1784 | 1784 |
1785 FX_BOOL Document::zoom(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sEr
ror) | 1785 bool Document::zoom(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError
) |
1786 { | 1786 { |
1787 | 1787 |
1788 » return TRUE; | 1788 » return true; |
1789 } | 1789 } |
1790 | 1790 |
1791 /** | 1791 /** |
1792 (none, NoVary) | 1792 (none, NoVary) |
1793 (fitP, FitPage) | 1793 (fitP, FitPage) |
1794 (fitW, FitWidth) | 1794 (fitW, FitWidth) |
1795 (fitH, FitHeight) | 1795 (fitH, FitHeight) |
1796 (fitV, FitVisibleWidth) | 1796 (fitV, FitVisibleWidth) |
1797 (pref, Preferred) | 1797 (pref, Preferred) |
1798 (refW, ReflowWidth) | 1798 (refW, ReflowWidth) |
1799 */ | 1799 */ |
1800 | 1800 |
1801 FX_BOOL Document::zoomType(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString&
sError) | 1801 bool Document::zoomType(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sE
rror) |
1802 { | 1802 { |
1803 » return TRUE; | 1803 » return true; |
1804 } | 1804 } |
1805 | 1805 |
1806 FX_BOOL Document::deletePages(IFXJS_Context* cc, const CJS_Parameters& params, C
JS_Value& vRet, CFX_WideString& sError) | 1806 bool Document::deletePages(IFXJS_Context* cc, const CJS_Parameters& params, CJS_
Value& vRet, CFX_WideString& sError) |
1807 { | 1807 { |
1808 // Unsafe, no supported. | 1808 // Unsafe, no supported. |
1809 return TRUE; | 1809 return true; |
1810 } | 1810 } |
1811 | 1811 |
1812 FX_BOOL Document::extractPages(IFXJS_Context* cc, const CJS_Parameters& params,
CJS_Value& vRet, CFX_WideString& sError) | 1812 bool Document::extractPages(IFXJS_Context* cc, const CJS_Parameters& params, CJS
_Value& vRet, CFX_WideString& sError) |
1813 { | 1813 { |
1814 // Unsafe, not supported. | 1814 // Unsafe, not supported. |
1815 return TRUE; | 1815 return true; |
1816 } | 1816 } |
1817 | 1817 |
1818 FX_BOOL Document::insertPages(IFXJS_Context* cc, const CJS_Parameters& params, C
JS_Value& vRet, CFX_WideString& sError) | 1818 bool Document::insertPages(IFXJS_Context* cc, const CJS_Parameters& params, CJS_
Value& vRet, CFX_WideString& sError) |
1819 { | 1819 { |
1820 // Unsafe, not supported. | 1820 // Unsafe, not supported. |
1821 return TRUE; | 1821 return true; |
1822 } | 1822 } |
1823 | 1823 |
1824 FX_BOOL Document::replacePages(IFXJS_Context* cc, const CJS_Parameters& params,
CJS_Value& vRet, CFX_WideString& sError) | 1824 bool Document::replacePages(IFXJS_Context* cc, const CJS_Parameters& params, CJS
_Value& vRet, CFX_WideString& sError) |
1825 { | 1825 { |
1826 // Unsafe, not supported. | 1826 // Unsafe, not supported. |
1827 return TRUE; | 1827 return true; |
1828 } | 1828 } |
1829 | 1829 |
1830 FX_BOOL Document::getURL(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Va
lue& vRet, CFX_WideString& sError) | 1830 bool Document::getURL(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value
& vRet, CFX_WideString& sError) |
1831 { | 1831 { |
1832 // Unsafe, not supported. | 1832 // Unsafe, not supported. |
1833 return TRUE; | 1833 return true; |
1834 } | 1834 } |
1835 | 1835 |
1836 void Document::AddDelayData(CJS_DelayData* pData) | 1836 void Document::AddDelayData(CJS_DelayData* pData) |
1837 { | 1837 { |
1838 m_DelayData.Add(pData); | 1838 m_DelayData.Add(pData); |
1839 } | 1839 } |
1840 | 1840 |
1841 void Document::DoFieldDelay(const CFX_WideString& sFieldName, int nControlIndex) | 1841 void Document::DoFieldDelay(const CFX_WideString& sFieldName, int nControlIndex) |
1842 { | 1842 { |
1843 CFX_DWordArray DelArray; | 1843 CFX_DWordArray DelArray; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1883 { | 1883 { |
1884 m_DelayData.RemoveAt(DelArray[j]); | 1884 m_DelayData.RemoveAt(DelArray[j]); |
1885 } | 1885 } |
1886 } | 1886 } |
1887 | 1887 |
1888 CJS_Document* Document::GetCJSDoc() const | 1888 CJS_Document* Document::GetCJSDoc() const |
1889 { | 1889 { |
1890 return static_cast<CJS_Document*>(m_pJSObject); | 1890 return static_cast<CJS_Document*>(m_pJSObject); |
1891 } | 1891 } |
1892 | 1892 |
OLD | NEW |