Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(285)

Side by Side Diff: fpdfsdk/src/javascript/Document.cpp

Issue 1437863005: Merge to XFA: Replace CJS_Parameters with std::vector<CJS_Value>. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « fpdfsdk/src/javascript/Document.h ('k') | fpdfsdk/src/javascript/Field.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "Document.h" 7 #include "Document.h"
8 8
9 #include "../../include/fsdk_mgr.h" // For CPDFDoc_Environment. 9 #include "../../include/fsdk_mgr.h" // For CPDFDoc_Environment.
10 #include "../../include/javascript/IJavaScript.h" 10 #include "../../include/javascript/IJavaScript.h"
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 pEnv->JS_docgotoPage(iPageCount - 1); 249 pEnv->JS_docgotoPage(iPageCount - 1);
250 } else if (iPageNum < 0) { 250 } else if (iPageNum < 0) {
251 pEnv->JS_docgotoPage(0); 251 pEnv->JS_docgotoPage(0);
252 } 252 }
253 } 253 }
254 254
255 return TRUE; 255 return TRUE;
256 } 256 }
257 257
258 FX_BOOL Document::addAnnot(IJS_Context* cc, 258 FX_BOOL Document::addAnnot(IJS_Context* cc,
259 const CJS_Parameters& params, 259 const std::vector<CJS_Value>& params,
260 CJS_Value& vRet, 260 CJS_Value& vRet,
261 CFX_WideString& sError) { 261 CFX_WideString& sError) {
262 // Not supported. 262 // Not supported.
263 return TRUE; 263 return TRUE;
264 } 264 }
265 265
266 FX_BOOL Document::addField(IJS_Context* cc, 266 FX_BOOL Document::addField(IJS_Context* cc,
267 const CJS_Parameters& params, 267 const std::vector<CJS_Value>& params,
268 CJS_Value& vRet, 268 CJS_Value& vRet,
269 CFX_WideString& sError) { 269 CFX_WideString& sError) {
270 // Not supported. 270 // Not supported.
271 return TRUE; 271 return TRUE;
272 } 272 }
273 273
274 FX_BOOL Document::exportAsText(IJS_Context* cc, 274 FX_BOOL Document::exportAsText(IJS_Context* cc,
275 const CJS_Parameters& params, 275 const std::vector<CJS_Value>& params,
276 CJS_Value& vRet, 276 CJS_Value& vRet,
277 CFX_WideString& sError) { 277 CFX_WideString& sError) {
278 // Unsafe, not supported. 278 // Unsafe, not supported.
279 return TRUE; 279 return TRUE;
280 } 280 }
281 281
282 FX_BOOL Document::exportAsFDF(IJS_Context* cc, 282 FX_BOOL Document::exportAsFDF(IJS_Context* cc,
283 const CJS_Parameters& params, 283 const std::vector<CJS_Value>& params,
284 CJS_Value& vRet, 284 CJS_Value& vRet,
285 CFX_WideString& sError) { 285 CFX_WideString& sError) {
286 // Unsafe, not supported. 286 // Unsafe, not supported.
287 return TRUE; 287 return TRUE;
288 } 288 }
289 289
290 FX_BOOL Document::exportAsXFDF(IJS_Context* cc, 290 FX_BOOL Document::exportAsXFDF(IJS_Context* cc,
291 const CJS_Parameters& params, 291 const std::vector<CJS_Value>& params,
292 CJS_Value& vRet, 292 CJS_Value& vRet,
293 CFX_WideString& sError) { 293 CFX_WideString& sError) {
294 // Unsafe, not supported. 294 // Unsafe, not supported.
295 return TRUE; 295 return TRUE;
296 } 296 }
297 297
298 // Maps a field object in PDF document to a JavaScript variable 298 // Maps a field object in PDF document to a JavaScript variable
299 // comment: 299 // comment:
300 // note: the paremter cName, this is clue how to treat if the cName is not a 300 // note: the paremter cName, this is clue how to treat if the cName is not a
301 // valiable filed name in this document 301 // valiable filed name in this document
302 302
303 FX_BOOL Document::getField(IJS_Context* cc, 303 FX_BOOL Document::getField(IJS_Context* cc,
304 const CJS_Parameters& params, 304 const std::vector<CJS_Value>& params,
305 CJS_Value& vRet, 305 CJS_Value& vRet,
306 CFX_WideString& sError) { 306 CFX_WideString& sError) {
307 CJS_Context* pContext = (CJS_Context*)cc; 307 CJS_Context* pContext = (CJS_Context*)cc;
308 if (params.size() < 1) { 308 if (params.size() < 1) {
309 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); 309 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
310 return FALSE; 310 return FALSE;
311 } 311 }
312 312
313 CFX_WideString wideName = params[0].ToCFXWideString(); 313 CFX_WideString wideName = params[0].ToCFXWideString();
314 314
(...skipping 12 matching lines...) Expand all
327 CJS_Field* pJSField = (CJS_Field*)FXJS_GetPrivate(isolate, pFieldObj); 327 CJS_Field* pJSField = (CJS_Field*)FXJS_GetPrivate(isolate, pFieldObj);
328 Field* pField = (Field*)pJSField->GetEmbedObject(); 328 Field* pField = (Field*)pJSField->GetEmbedObject();
329 pField->AttachField(this, wideName); 329 pField->AttachField(this, wideName);
330 330
331 vRet = pJSField; 331 vRet = pJSField;
332 return TRUE; 332 return TRUE;
333 } 333 }
334 334
335 // Gets the name of the nth field in the document 335 // Gets the name of the nth field in the document
336 FX_BOOL Document::getNthFieldName(IJS_Context* cc, 336 FX_BOOL Document::getNthFieldName(IJS_Context* cc,
337 const CJS_Parameters& params, 337 const std::vector<CJS_Value>& params,
338 CJS_Value& vRet, 338 CJS_Value& vRet,
339 CFX_WideString& sError) { 339 CFX_WideString& sError) {
340 CJS_Context* pContext = (CJS_Context*)cc; 340 CJS_Context* pContext = (CJS_Context*)cc;
341 if (params.size() != 1) { 341 if (params.size() != 1) {
342 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); 342 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
343 return FALSE; 343 return FALSE;
344 } 344 }
345 345
346 int nIndex = params[0].ToInt(); 346 int nIndex = params[0].ToInt();
347 if (nIndex < 0) { 347 if (nIndex < 0) {
348 sError = JSGetStringFromID(pContext, IDS_STRING_JSVALUEERROR); 348 sError = JSGetStringFromID(pContext, IDS_STRING_JSVALUEERROR);
349 return FALSE; 349 return FALSE;
350 } 350 }
351 351
352 CPDFSDK_InterForm* pInterForm = m_pDocument->GetInterForm(); 352 CPDFSDK_InterForm* pInterForm = m_pDocument->GetInterForm();
353 CPDF_InterForm* pPDFForm = pInterForm->GetInterForm(); 353 CPDF_InterForm* pPDFForm = pInterForm->GetInterForm();
354 CPDF_FormField* pField = pPDFForm->GetField(nIndex); 354 CPDF_FormField* pField = pPDFForm->GetField(nIndex);
355 if (!pField) 355 if (!pField)
356 return FALSE; 356 return FALSE;
357 357
358 vRet = pField->GetFullName().c_str(); 358 vRet = pField->GetFullName().c_str();
359 return TRUE; 359 return TRUE;
360 } 360 }
361 361
362 FX_BOOL Document::importAnFDF(IJS_Context* cc, 362 FX_BOOL Document::importAnFDF(IJS_Context* cc,
363 const CJS_Parameters& params, 363 const std::vector<CJS_Value>& params,
364 CJS_Value& vRet, 364 CJS_Value& vRet,
365 CFX_WideString& sError) { 365 CFX_WideString& sError) {
366 // Unsafe, not supported. 366 // Unsafe, not supported.
367 return TRUE; 367 return TRUE;
368 } 368 }
369 369
370 FX_BOOL Document::importAnXFDF(IJS_Context* cc, 370 FX_BOOL Document::importAnXFDF(IJS_Context* cc,
371 const CJS_Parameters& params, 371 const std::vector<CJS_Value>& params,
372 CJS_Value& vRet, 372 CJS_Value& vRet,
373 CFX_WideString& sError) { 373 CFX_WideString& sError) {
374 // Unsafe, not supported. 374 // Unsafe, not supported.
375 return TRUE; 375 return TRUE;
376 } 376 }
377 377
378 FX_BOOL Document::importTextData(IJS_Context* cc, 378 FX_BOOL Document::importTextData(IJS_Context* cc,
379 const CJS_Parameters& params, 379 const std::vector<CJS_Value>& params,
380 CJS_Value& vRet, 380 CJS_Value& vRet,
381 CFX_WideString& sError) { 381 CFX_WideString& sError) {
382 // Unsafe, not supported. 382 // Unsafe, not supported.
383 return TRUE; 383 return TRUE;
384 } 384 }
385 385
386 // exports the form data and mails the resulting fdf file as an attachment to 386 // exports the form data and mails the resulting fdf file as an attachment to
387 // all recipients. 387 // all recipients.
388 // comment: need reader supports 388 // comment: need reader supports
389 // note: 389 // note:
390 // int CPDFSDK_Document::mailForm(FX_BOOL bUI,String cto,string ccc,string 390 // int CPDFSDK_Document::mailForm(FX_BOOL bUI,String cto,string ccc,string
391 // cbcc,string cSubject,string cms); 391 // cbcc,string cSubject,string cms);
392 392
393 FX_BOOL Document::mailForm(IJS_Context* cc, 393 FX_BOOL Document::mailForm(IJS_Context* cc,
394 const CJS_Parameters& params, 394 const std::vector<CJS_Value>& params,
395 CJS_Value& vRet, 395 CJS_Value& vRet,
396 CFX_WideString& sError) { 396 CFX_WideString& sError) {
397 ASSERT(m_pDocument != NULL); 397 ASSERT(m_pDocument != NULL);
398 398
399 if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) 399 if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS))
400 return FALSE; 400 return FALSE;
401 401
402 int iLength = params.size(); 402 int iLength = params.size();
403 403
404 FX_BOOL bUI = iLength > 0 ? params[0].ToBool() : TRUE; 404 FX_BOOL bUI = iLength > 0 ? params[0].ToBool() : TRUE;
(...skipping 20 matching lines...) Expand all
425 425
426 pRuntime->BeginBlock(); 426 pRuntime->BeginBlock();
427 pEnv->JS_docmailForm(textBuf.GetBuffer(), textBuf.GetLength(), bUI, 427 pEnv->JS_docmailForm(textBuf.GetBuffer(), textBuf.GetLength(), bUI,
428 cTo.c_str(), cSubject.c_str(), cCc.c_str(), cBcc.c_str(), 428 cTo.c_str(), cSubject.c_str(), cCc.c_str(), cBcc.c_str(),
429 cMsg.c_str()); 429 cMsg.c_str());
430 pRuntime->EndBlock(); 430 pRuntime->EndBlock();
431 return TRUE; 431 return TRUE;
432 } 432 }
433 433
434 FX_BOOL Document::print(IJS_Context* cc, 434 FX_BOOL Document::print(IJS_Context* cc,
435 const CJS_Parameters& params, 435 const std::vector<CJS_Value>& params,
436 CJS_Value& vRet, 436 CJS_Value& vRet,
437 CFX_WideString& sError) { 437 CFX_WideString& sError) {
438 FX_BOOL bUI = TRUE; 438 FX_BOOL bUI = TRUE;
439 int nStart = 0; 439 int nStart = 0;
440 int nEnd = 0; 440 int nEnd = 0;
441 FX_BOOL bSilent = FALSE; 441 FX_BOOL bSilent = FALSE;
442 FX_BOOL bShrinkToFit = FALSE; 442 FX_BOOL bShrinkToFit = FALSE;
443 FX_BOOL bPrintAsImage = FALSE; 443 FX_BOOL bPrintAsImage = FALSE;
444 FX_BOOL bReverse = FALSE; 444 FX_BOOL bReverse = FALSE;
445 FX_BOOL bAnnotations = FALSE; 445 FX_BOOL bAnnotations = FALSE;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 return TRUE; 493 return TRUE;
494 } 494 }
495 return FALSE; 495 return FALSE;
496 } 496 }
497 497
498 // removes the specified field from the document. 498 // removes the specified field from the document.
499 // comment: 499 // comment:
500 // note: if the filed name is not retional, adobe is dumb for it. 500 // note: if the filed name is not retional, adobe is dumb for it.
501 501
502 FX_BOOL Document::removeField(IJS_Context* cc, 502 FX_BOOL Document::removeField(IJS_Context* cc,
503 const CJS_Parameters& params, 503 const std::vector<CJS_Value>& params,
504 CJS_Value& vRet, 504 CJS_Value& vRet,
505 CFX_WideString& sError) { 505 CFX_WideString& sError) {
506 ASSERT(m_pDocument != NULL); 506 ASSERT(m_pDocument != NULL);
507 507
508 if (!(m_pDocument->GetPermissions(FPDFPERM_MODIFY) || 508 if (!(m_pDocument->GetPermissions(FPDFPERM_MODIFY) ||
509 m_pDocument->GetPermissions(FPDFPERM_ANNOT_FORM))) 509 m_pDocument->GetPermissions(FPDFPERM_ANNOT_FORM)))
510 return FALSE; 510 return FALSE;
511 511
512 CJS_Context* pContext = (CJS_Context*)cc; 512 CJS_Context* pContext = (CJS_Context*)cc;
513 if (params.size() != 1) { 513 if (params.size() != 1) {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 m_pDocument->SetChangeMark(); 546 m_pDocument->SetChangeMark();
547 547
548 return TRUE; 548 return TRUE;
549 } 549 }
550 550
551 // reset filed values within a document. 551 // reset filed values within a document.
552 // comment: 552 // comment:
553 // note: if the fields names r not rational, aodbe is dumb for it. 553 // note: if the fields names r not rational, aodbe is dumb for it.
554 554
555 FX_BOOL Document::resetForm(IJS_Context* cc, 555 FX_BOOL Document::resetForm(IJS_Context* cc,
556 const CJS_Parameters& params, 556 const std::vector<CJS_Value>& params,
557 CJS_Value& vRet, 557 CJS_Value& vRet,
558 CFX_WideString& sError) { 558 CFX_WideString& sError) {
559 if (!(m_pDocument->GetPermissions(FPDFPERM_MODIFY) || 559 if (!(m_pDocument->GetPermissions(FPDFPERM_MODIFY) ||
560 m_pDocument->GetPermissions(FPDFPERM_ANNOT_FORM) || 560 m_pDocument->GetPermissions(FPDFPERM_ANNOT_FORM) ||
561 m_pDocument->GetPermissions(FPDFPERM_FILL_FORM))) 561 m_pDocument->GetPermissions(FPDFPERM_FILL_FORM)))
562 return FALSE; 562 return FALSE;
563 563
564 CPDFSDK_InterForm* pInterForm = 564 CPDFSDK_InterForm* pInterForm =
565 (CPDFSDK_InterForm*)m_pDocument->GetInterForm(); 565 (CPDFSDK_InterForm*)m_pDocument->GetInterForm();
566 CPDF_InterForm* pPDFForm = pInterForm->GetInterForm(); 566 CPDF_InterForm* pPDFForm = pInterForm->GetInterForm();
(...skipping 26 matching lines...) Expand all
593 593
594 if (!aFields.empty()) { 594 if (!aFields.empty()) {
595 pPDFForm->ResetForm(aFields, TRUE, TRUE); 595 pPDFForm->ResetForm(aFields, TRUE, TRUE);
596 m_pDocument->SetChangeMark(); 596 m_pDocument->SetChangeMark();
597 } 597 }
598 598
599 return TRUE; 599 return TRUE;
600 } 600 }
601 601
602 FX_BOOL Document::saveAs(IJS_Context* cc, 602 FX_BOOL Document::saveAs(IJS_Context* cc,
603 const CJS_Parameters& params, 603 const std::vector<CJS_Value>& params,
604 CJS_Value& vRet, 604 CJS_Value& vRet,
605 CFX_WideString& sError) { 605 CFX_WideString& sError) {
606 // Unsafe, not supported. 606 // Unsafe, not supported.
607 return TRUE; 607 return TRUE;
608 } 608 }
609 609
610 FX_BOOL Document::submitForm(IJS_Context* cc, 610 FX_BOOL Document::submitForm(IJS_Context* cc,
611 const CJS_Parameters& params, 611 const std::vector<CJS_Value>& params,
612 CJS_Value& vRet, 612 CJS_Value& vRet,
613 CFX_WideString& sError) { 613 CFX_WideString& sError) {
614 CJS_Context* pContext = (CJS_Context*)cc; 614 CJS_Context* pContext = (CJS_Context*)cc;
615 int nSize = params.size(); 615 int nSize = params.size();
616 if (nSize < 1) { 616 if (nSize < 1) {
617 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); 617 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
618 return FALSE; 618 return FALSE;
619 } 619 }
620 620
621 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); 621 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
709 return FALSE; 709 return FALSE;
710 } 710 }
711 711
712 FX_BOOL Document::bookmarkRoot(IJS_Context* cc, 712 FX_BOOL Document::bookmarkRoot(IJS_Context* cc,
713 CJS_PropValue& vp, 713 CJS_PropValue& vp,
714 CFX_WideString& sError) { 714 CFX_WideString& sError) {
715 return TRUE; 715 return TRUE;
716 } 716 }
717 717
718 FX_BOOL Document::mailDoc(IJS_Context* cc, 718 FX_BOOL Document::mailDoc(IJS_Context* cc,
719 const CJS_Parameters& params, 719 const std::vector<CJS_Value>& params,
720 CJS_Value& vRet, 720 CJS_Value& vRet,
721 CFX_WideString& sError) { 721 CFX_WideString& sError) {
722 FX_BOOL bUI = TRUE; 722 FX_BOOL bUI = TRUE;
723 CFX_WideString cTo = L""; 723 CFX_WideString cTo = L"";
724 CFX_WideString cCc = L""; 724 CFX_WideString cCc = L"";
725 CFX_WideString cBcc = L""; 725 CFX_WideString cBcc = L"";
726 CFX_WideString cSubject = L""; 726 CFX_WideString cSubject = L"";
727 CFX_WideString cMsg = L""; 727 CFX_WideString cMsg = L"";
728 728
729 if (params.size() >= 1) 729 if (params.size() >= 1)
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after
1216 return TRUE; 1216 return TRUE;
1217 } 1217 }
1218 1218
1219 FX_BOOL Document::layout(IJS_Context* cc, 1219 FX_BOOL Document::layout(IJS_Context* cc,
1220 CJS_PropValue& vp, 1220 CJS_PropValue& vp,
1221 CFX_WideString& sError) { 1221 CFX_WideString& sError) {
1222 return TRUE; 1222 return TRUE;
1223 } 1223 }
1224 1224
1225 FX_BOOL Document::addLink(IJS_Context* cc, 1225 FX_BOOL Document::addLink(IJS_Context* cc,
1226 const CJS_Parameters& params, 1226 const std::vector<CJS_Value>& params,
1227 CJS_Value& vRet, 1227 CJS_Value& vRet,
1228 CFX_WideString& sError) { 1228 CFX_WideString& sError) {
1229 return TRUE; 1229 return TRUE;
1230 } 1230 }
1231 1231
1232 FX_BOOL Document::closeDoc(IJS_Context* cc, 1232 FX_BOOL Document::closeDoc(IJS_Context* cc,
1233 const CJS_Parameters& params, 1233 const std::vector<CJS_Value>& params,
1234 CJS_Value& vRet, 1234 CJS_Value& vRet,
1235 CFX_WideString& sError) { 1235 CFX_WideString& sError) {
1236 ASSERT(m_pDocument != NULL); 1236 ASSERT(m_pDocument != NULL);
1237 return TRUE; 1237 return TRUE;
1238 } 1238 }
1239 1239
1240 FX_BOOL Document::getPageBox(IJS_Context* cc, 1240 FX_BOOL Document::getPageBox(IJS_Context* cc,
1241 const CJS_Parameters& params, 1241 const std::vector<CJS_Value>& params,
1242 CJS_Value& vRet, 1242 CJS_Value& vRet,
1243 CFX_WideString& sError) { 1243 CFX_WideString& sError) {
1244 return TRUE; 1244 return TRUE;
1245 } 1245 }
1246 1246
1247 FX_BOOL Document::getAnnot(IJS_Context* cc, 1247 FX_BOOL Document::getAnnot(IJS_Context* cc,
1248 const CJS_Parameters& params, 1248 const std::vector<CJS_Value>& params,
1249 CJS_Value& vRet, 1249 CJS_Value& vRet,
1250 CFX_WideString& sError) { 1250 CFX_WideString& sError) {
1251 return TRUE; 1251 return TRUE;
1252 } 1252 }
1253 1253
1254 FX_BOOL Document::getAnnots(IJS_Context* cc, 1254 FX_BOOL Document::getAnnots(IJS_Context* cc,
1255 const CJS_Parameters& params, 1255 const std::vector<CJS_Value>& params,
1256 CJS_Value& vRet, 1256 CJS_Value& vRet,
1257 CFX_WideString& sError) { 1257 CFX_WideString& sError) {
1258 vRet.SetNull(); 1258 vRet.SetNull();
1259 return TRUE; 1259 return TRUE;
1260 } 1260 }
1261 1261
1262 FX_BOOL Document::getAnnot3D(IJS_Context* cc, 1262 FX_BOOL Document::getAnnot3D(IJS_Context* cc,
1263 const CJS_Parameters& params, 1263 const std::vector<CJS_Value>& params,
1264 CJS_Value& vRet, 1264 CJS_Value& vRet,
1265 CFX_WideString& sError) { 1265 CFX_WideString& sError) {
1266 vRet.SetNull(); 1266 vRet.SetNull();
1267 return TRUE; 1267 return TRUE;
1268 } 1268 }
1269 1269
1270 FX_BOOL Document::getAnnots3D(IJS_Context* cc, 1270 FX_BOOL Document::getAnnots3D(IJS_Context* cc,
1271 const CJS_Parameters& params, 1271 const std::vector<CJS_Value>& params,
1272 CJS_Value& vRet, 1272 CJS_Value& vRet,
1273 CFX_WideString& sError) { 1273 CFX_WideString& sError) {
1274 vRet = CJS_Value::VT_undefined; 1274 vRet = CJS_Value::VT_undefined;
1275 return TRUE; 1275 return TRUE;
1276 } 1276 }
1277 1277
1278 FX_BOOL Document::getOCGs(IJS_Context* cc, 1278 FX_BOOL Document::getOCGs(IJS_Context* cc,
1279 const CJS_Parameters& params, 1279 const std::vector<CJS_Value>& params,
1280 CJS_Value& vRet, 1280 CJS_Value& vRet,
1281 CFX_WideString& sError) { 1281 CFX_WideString& sError) {
1282 return TRUE; 1282 return TRUE;
1283 } 1283 }
1284 1284
1285 FX_BOOL Document::getLinks(IJS_Context* cc, 1285 FX_BOOL Document::getLinks(IJS_Context* cc,
1286 const CJS_Parameters& params, 1286 const std::vector<CJS_Value>& params,
1287 CJS_Value& vRet, 1287 CJS_Value& vRet,
1288 CFX_WideString& sError) { 1288 CFX_WideString& sError) {
1289 return TRUE; 1289 return TRUE;
1290 } 1290 }
1291 1291
1292 bool Document::IsEnclosedInRect(CFX_FloatRect rect, CFX_FloatRect LinkRect) { 1292 bool Document::IsEnclosedInRect(CFX_FloatRect rect, CFX_FloatRect LinkRect) {
1293 return (rect.left <= LinkRect.left && rect.top <= LinkRect.top && 1293 return (rect.left <= LinkRect.left && rect.top <= LinkRect.top &&
1294 rect.right >= LinkRect.right && rect.bottom >= LinkRect.bottom); 1294 rect.right >= LinkRect.right && rect.bottom >= LinkRect.bottom);
1295 } 1295 }
1296 1296
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1333 IconElement* pTemp = m_pHead; 1333 IconElement* pTemp = m_pHead;
1334 for (int i = 0; i < iIndex; i++) { 1334 for (int i = 0; i < iIndex; i++) {
1335 pTemp = pTemp->NextIcon; 1335 pTemp = pTemp->NextIcon;
1336 } 1336 }
1337 return pTemp; 1337 return pTemp;
1338 } 1338 }
1339 return NULL; 1339 return NULL;
1340 } 1340 }
1341 1341
1342 FX_BOOL Document::addIcon(IJS_Context* cc, 1342 FX_BOOL Document::addIcon(IJS_Context* cc,
1343 const CJS_Parameters& params, 1343 const std::vector<CJS_Value>& params,
1344 CJS_Value& vRet, 1344 CJS_Value& vRet,
1345 CFX_WideString& sError) { 1345 CFX_WideString& sError) {
1346 CJS_Context* pContext = (CJS_Context*)cc; 1346 CJS_Context* pContext = (CJS_Context*)cc;
1347 if (params.size() != 2) { 1347 if (params.size() != 2) {
1348 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); 1348 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
1349 return FALSE; 1349 return FALSE;
1350 } 1350 }
1351 CFX_WideString swIconName = params[0].ToCFXWideString(); 1351 CFX_WideString swIconName = params[0].ToCFXWideString();
1352 1352
1353 if (params[1].GetType() != CJS_Value::VT_object) { 1353 if (params[1].GetType() != CJS_Value::VT_object) {
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
1416 pIcon->SetStream(pIconElement->IconStream->GetStream()); 1416 pIcon->SetStream(pIconElement->IconStream->GetStream());
1417 pIcon->SetIconName(pIconElement->IconName); 1417 pIcon->SetIconName(pIconElement->IconName);
1418 Icons.SetElement(i, CJS_Value(pRuntime, pJS_Icon)); 1418 Icons.SetElement(i, CJS_Value(pRuntime, pJS_Icon));
1419 } 1419 }
1420 1420
1421 vp << Icons; 1421 vp << Icons;
1422 return TRUE; 1422 return TRUE;
1423 } 1423 }
1424 1424
1425 FX_BOOL Document::getIcon(IJS_Context* cc, 1425 FX_BOOL Document::getIcon(IJS_Context* cc,
1426 const CJS_Parameters& params, 1426 const std::vector<CJS_Value>& params,
1427 CJS_Value& vRet, 1427 CJS_Value& vRet,
1428 CFX_WideString& sError) { 1428 CFX_WideString& sError) {
1429 CJS_Context* pContext = (CJS_Context*)cc; 1429 CJS_Context* pContext = (CJS_Context*)cc;
1430 if (params.size() != 1) { 1430 if (params.size() != 1) {
1431 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); 1431 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
1432 return FALSE; 1432 return FALSE;
1433 } 1433 }
1434 1434
1435 if (!m_pIconTree) 1435 if (!m_pIconTree)
1436 return FALSE; 1436 return FALSE;
(...skipping 23 matching lines...) Expand all
1460 pIcon->SetStream(pRetIcon->GetStream()); 1460 pIcon->SetStream(pRetIcon->GetStream());
1461 vRet = pJS_Icon; 1461 vRet = pJS_Icon;
1462 return TRUE; 1462 return TRUE;
1463 } 1463 }
1464 } 1464 }
1465 1465
1466 return FALSE; 1466 return FALSE;
1467 } 1467 }
1468 1468
1469 FX_BOOL Document::removeIcon(IJS_Context* cc, 1469 FX_BOOL Document::removeIcon(IJS_Context* cc,
1470 const CJS_Parameters& params, 1470 const std::vector<CJS_Value>& params,
1471 CJS_Value& vRet, 1471 CJS_Value& vRet,
1472 CFX_WideString& sError) { 1472 CFX_WideString& sError) {
1473 // Unsafe, no supported. 1473 // Unsafe, no supported.
1474 return TRUE; 1474 return TRUE;
1475 } 1475 }
1476 1476
1477 FX_BOOL Document::createDataObject(IJS_Context* cc, 1477 FX_BOOL Document::createDataObject(IJS_Context* cc,
1478 const CJS_Parameters& params, 1478 const std::vector<CJS_Value>& params,
1479 CJS_Value& vRet, 1479 CJS_Value& vRet,
1480 CFX_WideString& sError) { 1480 CFX_WideString& sError) {
1481 // Unsafe, not implemented. 1481 // Unsafe, not implemented.
1482 return TRUE; 1482 return TRUE;
1483 } 1483 }
1484 1484
1485 FX_BOOL Document::media(IJS_Context* cc, 1485 FX_BOOL Document::media(IJS_Context* cc,
1486 CJS_PropValue& vp, 1486 CJS_PropValue& vp,
1487 CFX_WideString& sError) { 1487 CFX_WideString& sError) {
1488 return TRUE; 1488 return TRUE;
1489 } 1489 }
1490 1490
1491 FX_BOOL Document::calculateNow(IJS_Context* cc, 1491 FX_BOOL Document::calculateNow(IJS_Context* cc,
1492 const CJS_Parameters& params, 1492 const std::vector<CJS_Value>& params,
1493 CJS_Value& vRet, 1493 CJS_Value& vRet,
1494 CFX_WideString& sError) { 1494 CFX_WideString& sError) {
1495 ASSERT(m_pDocument != NULL); 1495 ASSERT(m_pDocument != NULL);
1496 1496
1497 if (!(m_pDocument->GetPermissions(FPDFPERM_MODIFY) || 1497 if (!(m_pDocument->GetPermissions(FPDFPERM_MODIFY) ||
1498 m_pDocument->GetPermissions(FPDFPERM_ANNOT_FORM) || 1498 m_pDocument->GetPermissions(FPDFPERM_ANNOT_FORM) ||
1499 m_pDocument->GetPermissions(FPDFPERM_FILL_FORM))) 1499 m_pDocument->GetPermissions(FPDFPERM_FILL_FORM)))
1500 return FALSE; 1500 return FALSE;
1501 1501
1502 CPDFSDK_InterForm* pInterForm = 1502 CPDFSDK_InterForm* pInterForm =
1503 (CPDFSDK_InterForm*)m_pDocument->GetInterForm(); 1503 (CPDFSDK_InterForm*)m_pDocument->GetInterForm();
1504 ASSERT(pInterForm != NULL); 1504 ASSERT(pInterForm != NULL);
1505 pInterForm->OnCalculate(); 1505 pInterForm->OnCalculate();
1506 return TRUE; 1506 return TRUE;
1507 } 1507 }
1508 1508
1509 FX_BOOL Document::Collab(IJS_Context* cc, 1509 FX_BOOL Document::Collab(IJS_Context* cc,
1510 CJS_PropValue& vp, 1510 CJS_PropValue& vp,
1511 CFX_WideString& sError) { 1511 CFX_WideString& sError) {
1512 return TRUE; 1512 return TRUE;
1513 } 1513 }
1514 1514
1515 FX_BOOL Document::getPageNthWord(IJS_Context* cc, 1515 FX_BOOL Document::getPageNthWord(IJS_Context* cc,
1516 const CJS_Parameters& params, 1516 const std::vector<CJS_Value>& params,
1517 CJS_Value& vRet, 1517 CJS_Value& vRet,
1518 CFX_WideString& sError) { 1518 CFX_WideString& sError) {
1519 ASSERT(m_pDocument != NULL); 1519 ASSERT(m_pDocument != NULL);
1520 1520
1521 if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) 1521 if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS))
1522 return FALSE; 1522 return FALSE;
1523 1523
1524 int nPageNo = params.size() > 0 ? params[0].ToInt() : 0; 1524 int nPageNo = params.size() > 0 ? params[0].ToInt() : 0;
1525 int nWordNo = params.size() > 1 ? params[1].ToInt() : 0; 1525 int nWordNo = params.size() > 1 ? params[1].ToInt() : 0;
1526 bool bStrip = params.size() > 2 ? params[2].ToBool() : true; 1526 bool bStrip = params.size() > 2 ? params[2].ToBool() : true;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1568 if (bStrip) { 1568 if (bStrip) {
1569 swRet.TrimLeft(); 1569 swRet.TrimLeft();
1570 swRet.TrimRight(); 1570 swRet.TrimRight();
1571 } 1571 }
1572 1572
1573 vRet = swRet.c_str(); 1573 vRet = swRet.c_str();
1574 return TRUE; 1574 return TRUE;
1575 } 1575 }
1576 1576
1577 FX_BOOL Document::getPageNthWordQuads(IJS_Context* cc, 1577 FX_BOOL Document::getPageNthWordQuads(IJS_Context* cc,
1578 const CJS_Parameters& params, 1578 const std::vector<CJS_Value>& params,
1579 CJS_Value& vRet, 1579 CJS_Value& vRet,
1580 CFX_WideString& sError) { 1580 CFX_WideString& sError) {
1581 ASSERT(m_pDocument != NULL); 1581 ASSERT(m_pDocument != NULL);
1582 1582
1583 if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) 1583 if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS))
1584 return FALSE; 1584 return FALSE;
1585 1585
1586 return FALSE; 1586 return FALSE;
1587 } 1587 }
1588 1588
1589 FX_BOOL Document::getPageNumWords(IJS_Context* cc, 1589 FX_BOOL Document::getPageNumWords(IJS_Context* cc,
1590 const CJS_Parameters& params, 1590 const std::vector<CJS_Value>& params,
1591 CJS_Value& vRet, 1591 CJS_Value& vRet,
1592 CFX_WideString& sError) { 1592 CFX_WideString& sError) {
1593 ASSERT(m_pDocument != NULL); 1593 ASSERT(m_pDocument != NULL);
1594 1594
1595 if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) 1595 if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS))
1596 return FALSE; 1596 return FALSE;
1597 1597
1598 int nPageNo = params.size() > 0 ? params[0].ToInt() : 0; 1598 int nPageNo = params.size() > 0 ? params[0].ToInt() : 0;
1599 1599
1600 CPDF_Document* pDocument = m_pDocument->GetDocument()->GetPDFDoc(); 1600 CPDF_Document* pDocument = m_pDocument->GetDocument()->GetPDFDoc();
(...skipping 26 matching lines...) Expand all
1627 } 1627 }
1628 } 1628 }
1629 } 1629 }
1630 1630
1631 vRet = nWords; 1631 vRet = nWords;
1632 1632
1633 return TRUE; 1633 return TRUE;
1634 } 1634 }
1635 1635
1636 FX_BOOL Document::getPrintParams(IJS_Context* cc, 1636 FX_BOOL Document::getPrintParams(IJS_Context* cc,
1637 const CJS_Parameters& params, 1637 const std::vector<CJS_Value>& params,
1638 CJS_Value& vRet, 1638 CJS_Value& vRet,
1639 CFX_WideString& sError) { 1639 CFX_WideString& sError) {
1640 CJS_Context* pContext = (CJS_Context*)cc; 1640 CJS_Context* pContext = (CJS_Context*)cc;
1641 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); 1641 CJS_Runtime* pRuntime = pContext->GetJSRuntime();
1642 v8::Local<v8::Object> pRetObj = FXJS_NewFxDynamicObj( 1642 v8::Local<v8::Object> pRetObj = FXJS_NewFxDynamicObj(
1643 pRuntime->GetIsolate(), pRuntime, CJS_PrintParamsObj::g_nObjDefnID); 1643 pRuntime->GetIsolate(), pRuntime, CJS_PrintParamsObj::g_nObjDefnID);
1644 1644
1645 // Not implemented yet. 1645 // Not implemented yet.
1646 1646
1647 vRet = pRetObj; 1647 vRet = pRetObj;
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
1738 (refW, ReflowWidth) 1738 (refW, ReflowWidth)
1739 */ 1739 */
1740 1740
1741 FX_BOOL Document::zoomType(IJS_Context* cc, 1741 FX_BOOL Document::zoomType(IJS_Context* cc,
1742 CJS_PropValue& vp, 1742 CJS_PropValue& vp,
1743 CFX_WideString& sError) { 1743 CFX_WideString& sError) {
1744 return TRUE; 1744 return TRUE;
1745 } 1745 }
1746 1746
1747 FX_BOOL Document::deletePages(IJS_Context* cc, 1747 FX_BOOL Document::deletePages(IJS_Context* cc,
1748 const CJS_Parameters& params, 1748 const std::vector<CJS_Value>& params,
1749 CJS_Value& vRet, 1749 CJS_Value& vRet,
1750 CFX_WideString& sError) { 1750 CFX_WideString& sError) {
1751 // Unsafe, no supported. 1751 // Unsafe, no supported.
1752 return TRUE; 1752 return TRUE;
1753 } 1753 }
1754 1754
1755 FX_BOOL Document::extractPages(IJS_Context* cc, 1755 FX_BOOL Document::extractPages(IJS_Context* cc,
1756 const CJS_Parameters& params, 1756 const std::vector<CJS_Value>& params,
1757 CJS_Value& vRet, 1757 CJS_Value& vRet,
1758 CFX_WideString& sError) { 1758 CFX_WideString& sError) {
1759 // Unsafe, not supported. 1759 // Unsafe, not supported.
1760 return TRUE; 1760 return TRUE;
1761 } 1761 }
1762 1762
1763 FX_BOOL Document::insertPages(IJS_Context* cc, 1763 FX_BOOL Document::insertPages(IJS_Context* cc,
1764 const CJS_Parameters& params, 1764 const std::vector<CJS_Value>& params,
1765 CJS_Value& vRet, 1765 CJS_Value& vRet,
1766 CFX_WideString& sError) { 1766 CFX_WideString& sError) {
1767 // Unsafe, not supported. 1767 // Unsafe, not supported.
1768 return TRUE; 1768 return TRUE;
1769 } 1769 }
1770 1770
1771 FX_BOOL Document::replacePages(IJS_Context* cc, 1771 FX_BOOL Document::replacePages(IJS_Context* cc,
1772 const CJS_Parameters& params, 1772 const std::vector<CJS_Value>& params,
1773 CJS_Value& vRet, 1773 CJS_Value& vRet,
1774 CFX_WideString& sError) { 1774 CFX_WideString& sError) {
1775 // Unsafe, not supported. 1775 // Unsafe, not supported.
1776 return TRUE; 1776 return TRUE;
1777 } 1777 }
1778 1778
1779 FX_BOOL Document::getURL(IJS_Context* cc, 1779 FX_BOOL Document::getURL(IJS_Context* cc,
1780 const CJS_Parameters& params, 1780 const std::vector<CJS_Value>& params,
1781 CJS_Value& vRet, 1781 CJS_Value& vRet,
1782 CFX_WideString& sError) { 1782 CFX_WideString& sError) {
1783 // Unsafe, not supported. 1783 // Unsafe, not supported.
1784 return TRUE; 1784 return TRUE;
1785 } 1785 }
1786 1786
1787 void Document::AddDelayData(CJS_DelayData* pData) { 1787 void Document::AddDelayData(CJS_DelayData* pData) {
1788 m_DelayData.Add(pData); 1788 m_DelayData.Add(pData);
1789 } 1789 }
1790 1790
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1825 CFX_DWordArray DelArray; 1825 CFX_DWordArray DelArray;
1826 1826
1827 for (int j = DelArray.GetSize() - 1; j >= 0; j--) { 1827 for (int j = DelArray.GetSize() - 1; j >= 0; j--) {
1828 m_DelayData.RemoveAt(DelArray[j]); 1828 m_DelayData.RemoveAt(DelArray[j]);
1829 } 1829 }
1830 } 1830 }
1831 1831
1832 CJS_Document* Document::GetCJSDoc() const { 1832 CJS_Document* Document::GetCJSDoc() const {
1833 return static_cast<CJS_Document*>(m_pJSObject); 1833 return static_cast<CJS_Document*>(m_pJSObject);
1834 } 1834 }
OLDNEW
« no previous file with comments | « fpdfsdk/src/javascript/Document.h ('k') | fpdfsdk/src/javascript/Field.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698