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

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

Issue 1437713003: Replace CJS_Parameters with std::vector<CJS_Value>. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@todo
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 473 matching lines...) Expand 10 before | Expand all | Expand 10 after
1203 return TRUE; 1203 return TRUE;
1204 } 1204 }
1205 1205
1206 FX_BOOL Document::layout(IJS_Context* cc, 1206 FX_BOOL Document::layout(IJS_Context* cc,
1207 CJS_PropValue& vp, 1207 CJS_PropValue& vp,
1208 CFX_WideString& sError) { 1208 CFX_WideString& sError) {
1209 return TRUE; 1209 return TRUE;
1210 } 1210 }
1211 1211
1212 FX_BOOL Document::addLink(IJS_Context* cc, 1212 FX_BOOL Document::addLink(IJS_Context* cc,
1213 const CJS_Parameters& params, 1213 const std::vector<CJS_Value>& params,
1214 CJS_Value& vRet, 1214 CJS_Value& vRet,
1215 CFX_WideString& sError) { 1215 CFX_WideString& sError) {
1216 return TRUE; 1216 return TRUE;
1217 } 1217 }
1218 1218
1219 FX_BOOL Document::closeDoc(IJS_Context* cc, 1219 FX_BOOL Document::closeDoc(IJS_Context* cc,
1220 const CJS_Parameters& params, 1220 const std::vector<CJS_Value>& params,
1221 CJS_Value& vRet, 1221 CJS_Value& vRet,
1222 CFX_WideString& sError) { 1222 CFX_WideString& sError) {
1223 ASSERT(m_pDocument != NULL); 1223 ASSERT(m_pDocument != NULL);
1224 return TRUE; 1224 return TRUE;
1225 } 1225 }
1226 1226
1227 FX_BOOL Document::getPageBox(IJS_Context* cc, 1227 FX_BOOL Document::getPageBox(IJS_Context* cc,
1228 const CJS_Parameters& params, 1228 const std::vector<CJS_Value>& params,
1229 CJS_Value& vRet, 1229 CJS_Value& vRet,
1230 CFX_WideString& sError) { 1230 CFX_WideString& sError) {
1231 return TRUE; 1231 return TRUE;
1232 } 1232 }
1233 1233
1234 FX_BOOL Document::getAnnot(IJS_Context* cc, 1234 FX_BOOL Document::getAnnot(IJS_Context* cc,
1235 const CJS_Parameters& params, 1235 const std::vector<CJS_Value>& params,
1236 CJS_Value& vRet, 1236 CJS_Value& vRet,
1237 CFX_WideString& sError) { 1237 CFX_WideString& sError) {
1238 return TRUE; 1238 return TRUE;
1239 } 1239 }
1240 1240
1241 FX_BOOL Document::getAnnots(IJS_Context* cc, 1241 FX_BOOL Document::getAnnots(IJS_Context* cc,
1242 const CJS_Parameters& params, 1242 const std::vector<CJS_Value>& params,
1243 CJS_Value& vRet, 1243 CJS_Value& vRet,
1244 CFX_WideString& sError) { 1244 CFX_WideString& sError) {
1245 vRet.SetNull(); 1245 vRet.SetNull();
1246 return TRUE; 1246 return TRUE;
1247 } 1247 }
1248 1248
1249 FX_BOOL Document::getAnnot3D(IJS_Context* cc, 1249 FX_BOOL Document::getAnnot3D(IJS_Context* cc,
1250 const CJS_Parameters& params, 1250 const std::vector<CJS_Value>& params,
1251 CJS_Value& vRet, 1251 CJS_Value& vRet,
1252 CFX_WideString& sError) { 1252 CFX_WideString& sError) {
1253 vRet.SetNull(); 1253 vRet.SetNull();
1254 return TRUE; 1254 return TRUE;
1255 } 1255 }
1256 1256
1257 FX_BOOL Document::getAnnots3D(IJS_Context* cc, 1257 FX_BOOL Document::getAnnots3D(IJS_Context* cc,
1258 const CJS_Parameters& params, 1258 const std::vector<CJS_Value>& params,
1259 CJS_Value& vRet, 1259 CJS_Value& vRet,
1260 CFX_WideString& sError) { 1260 CFX_WideString& sError) {
1261 vRet = CJS_Value::VT_undefined; 1261 vRet = CJS_Value::VT_undefined;
1262 return TRUE; 1262 return TRUE;
1263 } 1263 }
1264 1264
1265 FX_BOOL Document::getOCGs(IJS_Context* cc, 1265 FX_BOOL Document::getOCGs(IJS_Context* cc,
1266 const CJS_Parameters& params, 1266 const std::vector<CJS_Value>& params,
1267 CJS_Value& vRet, 1267 CJS_Value& vRet,
1268 CFX_WideString& sError) { 1268 CFX_WideString& sError) {
1269 return TRUE; 1269 return TRUE;
1270 } 1270 }
1271 1271
1272 FX_BOOL Document::getLinks(IJS_Context* cc, 1272 FX_BOOL Document::getLinks(IJS_Context* cc,
1273 const CJS_Parameters& params, 1273 const std::vector<CJS_Value>& params,
1274 CJS_Value& vRet, 1274 CJS_Value& vRet,
1275 CFX_WideString& sError) { 1275 CFX_WideString& sError) {
1276 return TRUE; 1276 return TRUE;
1277 } 1277 }
1278 1278
1279 bool Document::IsEnclosedInRect(CFX_FloatRect rect, CFX_FloatRect LinkRect) { 1279 bool Document::IsEnclosedInRect(CFX_FloatRect rect, CFX_FloatRect LinkRect) {
1280 return (rect.left <= LinkRect.left && rect.top <= LinkRect.top && 1280 return (rect.left <= LinkRect.left && rect.top <= LinkRect.top &&
1281 rect.right >= LinkRect.right && rect.bottom >= LinkRect.bottom); 1281 rect.right >= LinkRect.right && rect.bottom >= LinkRect.bottom);
1282 } 1282 }
1283 1283
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1320 IconElement* pTemp = m_pHead; 1320 IconElement* pTemp = m_pHead;
1321 for (int i = 0; i < iIndex; i++) { 1321 for (int i = 0; i < iIndex; i++) {
1322 pTemp = pTemp->NextIcon; 1322 pTemp = pTemp->NextIcon;
1323 } 1323 }
1324 return pTemp; 1324 return pTemp;
1325 } 1325 }
1326 return NULL; 1326 return NULL;
1327 } 1327 }
1328 1328
1329 FX_BOOL Document::addIcon(IJS_Context* cc, 1329 FX_BOOL Document::addIcon(IJS_Context* cc,
1330 const CJS_Parameters& params, 1330 const std::vector<CJS_Value>& params,
1331 CJS_Value& vRet, 1331 CJS_Value& vRet,
1332 CFX_WideString& sError) { 1332 CFX_WideString& sError) {
1333 CJS_Context* pContext = (CJS_Context*)cc; 1333 CJS_Context* pContext = (CJS_Context*)cc;
1334 if (params.size() != 2) { 1334 if (params.size() != 2) {
1335 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); 1335 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
1336 return FALSE; 1336 return FALSE;
1337 } 1337 }
1338 CFX_WideString swIconName = params[0].ToCFXWideString(); 1338 CFX_WideString swIconName = params[0].ToCFXWideString();
1339 1339
1340 if (params[1].GetType() != CJS_Value::VT_object) { 1340 if (params[1].GetType() != CJS_Value::VT_object) {
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
1403 pIcon->SetStream(pIconElement->IconStream->GetStream()); 1403 pIcon->SetStream(pIconElement->IconStream->GetStream());
1404 pIcon->SetIconName(pIconElement->IconName); 1404 pIcon->SetIconName(pIconElement->IconName);
1405 Icons.SetElement(i, CJS_Value(pRuntime, pJS_Icon)); 1405 Icons.SetElement(i, CJS_Value(pRuntime, pJS_Icon));
1406 } 1406 }
1407 1407
1408 vp << Icons; 1408 vp << Icons;
1409 return TRUE; 1409 return TRUE;
1410 } 1410 }
1411 1411
1412 FX_BOOL Document::getIcon(IJS_Context* cc, 1412 FX_BOOL Document::getIcon(IJS_Context* cc,
1413 const CJS_Parameters& params, 1413 const std::vector<CJS_Value>& params,
1414 CJS_Value& vRet, 1414 CJS_Value& vRet,
1415 CFX_WideString& sError) { 1415 CFX_WideString& sError) {
1416 CJS_Context* pContext = (CJS_Context*)cc; 1416 CJS_Context* pContext = (CJS_Context*)cc;
1417 if (params.size() != 1) { 1417 if (params.size() != 1) {
1418 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); 1418 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
1419 return FALSE; 1419 return FALSE;
1420 } 1420 }
1421 1421
1422 if (!m_pIconTree) 1422 if (!m_pIconTree)
1423 return FALSE; 1423 return FALSE;
(...skipping 23 matching lines...) Expand all
1447 pIcon->SetStream(pRetIcon->GetStream()); 1447 pIcon->SetStream(pRetIcon->GetStream());
1448 vRet = pJS_Icon; 1448 vRet = pJS_Icon;
1449 return TRUE; 1449 return TRUE;
1450 } 1450 }
1451 } 1451 }
1452 1452
1453 return FALSE; 1453 return FALSE;
1454 } 1454 }
1455 1455
1456 FX_BOOL Document::removeIcon(IJS_Context* cc, 1456 FX_BOOL Document::removeIcon(IJS_Context* cc,
1457 const CJS_Parameters& params, 1457 const std::vector<CJS_Value>& params,
1458 CJS_Value& vRet, 1458 CJS_Value& vRet,
1459 CFX_WideString& sError) { 1459 CFX_WideString& sError) {
1460 // Unsafe, no supported. 1460 // Unsafe, no supported.
1461 return TRUE; 1461 return TRUE;
1462 } 1462 }
1463 1463
1464 FX_BOOL Document::createDataObject(IJS_Context* cc, 1464 FX_BOOL Document::createDataObject(IJS_Context* cc,
1465 const CJS_Parameters& params, 1465 const std::vector<CJS_Value>& params,
1466 CJS_Value& vRet, 1466 CJS_Value& vRet,
1467 CFX_WideString& sError) { 1467 CFX_WideString& sError) {
1468 // Unsafe, not implemented. 1468 // Unsafe, not implemented.
1469 return TRUE; 1469 return TRUE;
1470 } 1470 }
1471 1471
1472 FX_BOOL Document::media(IJS_Context* cc, 1472 FX_BOOL Document::media(IJS_Context* cc,
1473 CJS_PropValue& vp, 1473 CJS_PropValue& vp,
1474 CFX_WideString& sError) { 1474 CFX_WideString& sError) {
1475 return TRUE; 1475 return TRUE;
1476 } 1476 }
1477 1477
1478 FX_BOOL Document::calculateNow(IJS_Context* cc, 1478 FX_BOOL Document::calculateNow(IJS_Context* cc,
1479 const CJS_Parameters& params, 1479 const std::vector<CJS_Value>& params,
1480 CJS_Value& vRet, 1480 CJS_Value& vRet,
1481 CFX_WideString& sError) { 1481 CFX_WideString& sError) {
1482 ASSERT(m_pDocument != NULL); 1482 ASSERT(m_pDocument != NULL);
1483 1483
1484 if (!(m_pDocument->GetPermissions(FPDFPERM_MODIFY) || 1484 if (!(m_pDocument->GetPermissions(FPDFPERM_MODIFY) ||
1485 m_pDocument->GetPermissions(FPDFPERM_ANNOT_FORM) || 1485 m_pDocument->GetPermissions(FPDFPERM_ANNOT_FORM) ||
1486 m_pDocument->GetPermissions(FPDFPERM_FILL_FORM))) 1486 m_pDocument->GetPermissions(FPDFPERM_FILL_FORM)))
1487 return FALSE; 1487 return FALSE;
1488 1488
1489 CPDFSDK_InterForm* pInterForm = 1489 CPDFSDK_InterForm* pInterForm =
1490 (CPDFSDK_InterForm*)m_pDocument->GetInterForm(); 1490 (CPDFSDK_InterForm*)m_pDocument->GetInterForm();
1491 ASSERT(pInterForm != NULL); 1491 ASSERT(pInterForm != NULL);
1492 pInterForm->OnCalculate(); 1492 pInterForm->OnCalculate();
1493 return TRUE; 1493 return TRUE;
1494 } 1494 }
1495 1495
1496 FX_BOOL Document::Collab(IJS_Context* cc, 1496 FX_BOOL Document::Collab(IJS_Context* cc,
1497 CJS_PropValue& vp, 1497 CJS_PropValue& vp,
1498 CFX_WideString& sError) { 1498 CFX_WideString& sError) {
1499 return TRUE; 1499 return TRUE;
1500 } 1500 }
1501 1501
1502 FX_BOOL Document::getPageNthWord(IJS_Context* cc, 1502 FX_BOOL Document::getPageNthWord(IJS_Context* cc,
1503 const CJS_Parameters& params, 1503 const std::vector<CJS_Value>& params,
1504 CJS_Value& vRet, 1504 CJS_Value& vRet,
1505 CFX_WideString& sError) { 1505 CFX_WideString& sError) {
1506 ASSERT(m_pDocument != NULL); 1506 ASSERT(m_pDocument != NULL);
1507 1507
1508 if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) 1508 if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS))
1509 return FALSE; 1509 return FALSE;
1510 1510
1511 int nPageNo = params.size() > 0 ? params[0].ToInt() : 0; 1511 int nPageNo = params.size() > 0 ? params[0].ToInt() : 0;
1512 int nWordNo = params.size() > 1 ? params[1].ToInt() : 0; 1512 int nWordNo = params.size() > 1 ? params[1].ToInt() : 0;
1513 bool bStrip = params.size() > 2 ? params[2].ToBool() : true; 1513 bool bStrip = params.size() > 2 ? params[2].ToBool() : true;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1555 if (bStrip) { 1555 if (bStrip) {
1556 swRet.TrimLeft(); 1556 swRet.TrimLeft();
1557 swRet.TrimRight(); 1557 swRet.TrimRight();
1558 } 1558 }
1559 1559
1560 vRet = swRet.c_str(); 1560 vRet = swRet.c_str();
1561 return TRUE; 1561 return TRUE;
1562 } 1562 }
1563 1563
1564 FX_BOOL Document::getPageNthWordQuads(IJS_Context* cc, 1564 FX_BOOL Document::getPageNthWordQuads(IJS_Context* cc,
1565 const CJS_Parameters& params, 1565 const std::vector<CJS_Value>& params,
1566 CJS_Value& vRet, 1566 CJS_Value& vRet,
1567 CFX_WideString& sError) { 1567 CFX_WideString& sError) {
1568 ASSERT(m_pDocument != NULL); 1568 ASSERT(m_pDocument != NULL);
1569 1569
1570 if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) 1570 if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS))
1571 return FALSE; 1571 return FALSE;
1572 1572
1573 return FALSE; 1573 return FALSE;
1574 } 1574 }
1575 1575
1576 FX_BOOL Document::getPageNumWords(IJS_Context* cc, 1576 FX_BOOL Document::getPageNumWords(IJS_Context* cc,
1577 const CJS_Parameters& params, 1577 const std::vector<CJS_Value>& params,
1578 CJS_Value& vRet, 1578 CJS_Value& vRet,
1579 CFX_WideString& sError) { 1579 CFX_WideString& sError) {
1580 ASSERT(m_pDocument != NULL); 1580 ASSERT(m_pDocument != NULL);
1581 1581
1582 if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) 1582 if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS))
1583 return FALSE; 1583 return FALSE;
1584 1584
1585 int nPageNo = params.size() > 0 ? params[0].ToInt() : 0; 1585 int nPageNo = params.size() > 0 ? params[0].ToInt() : 0;
1586 1586
1587 CPDF_Document* pDocument = m_pDocument->GetPDFDocument(); 1587 CPDF_Document* pDocument = m_pDocument->GetPDFDocument();
(...skipping 26 matching lines...) Expand all
1614 } 1614 }
1615 } 1615 }
1616 } 1616 }
1617 1617
1618 vRet = nWords; 1618 vRet = nWords;
1619 1619
1620 return TRUE; 1620 return TRUE;
1621 } 1621 }
1622 1622
1623 FX_BOOL Document::getPrintParams(IJS_Context* cc, 1623 FX_BOOL Document::getPrintParams(IJS_Context* cc,
1624 const CJS_Parameters& params, 1624 const std::vector<CJS_Value>& params,
1625 CJS_Value& vRet, 1625 CJS_Value& vRet,
1626 CFX_WideString& sError) { 1626 CFX_WideString& sError) {
1627 CJS_Context* pContext = (CJS_Context*)cc; 1627 CJS_Context* pContext = (CJS_Context*)cc;
1628 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); 1628 CJS_Runtime* pRuntime = pContext->GetJSRuntime();
1629 v8::Local<v8::Object> pRetObj = FXJS_NewFxDynamicObj( 1629 v8::Local<v8::Object> pRetObj = FXJS_NewFxDynamicObj(
1630 pRuntime->GetIsolate(), pRuntime, CJS_PrintParamsObj::g_nObjDefnID); 1630 pRuntime->GetIsolate(), pRuntime, CJS_PrintParamsObj::g_nObjDefnID);
1631 1631
1632 // Not implemented yet. 1632 // Not implemented yet.
1633 1633
1634 vRet = pRetObj; 1634 vRet = pRetObj;
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
1725 (refW, ReflowWidth) 1725 (refW, ReflowWidth)
1726 */ 1726 */
1727 1727
1728 FX_BOOL Document::zoomType(IJS_Context* cc, 1728 FX_BOOL Document::zoomType(IJS_Context* cc,
1729 CJS_PropValue& vp, 1729 CJS_PropValue& vp,
1730 CFX_WideString& sError) { 1730 CFX_WideString& sError) {
1731 return TRUE; 1731 return TRUE;
1732 } 1732 }
1733 1733
1734 FX_BOOL Document::deletePages(IJS_Context* cc, 1734 FX_BOOL Document::deletePages(IJS_Context* cc,
1735 const CJS_Parameters& params, 1735 const std::vector<CJS_Value>& params,
1736 CJS_Value& vRet, 1736 CJS_Value& vRet,
1737 CFX_WideString& sError) { 1737 CFX_WideString& sError) {
1738 // Unsafe, no supported. 1738 // Unsafe, no supported.
1739 return TRUE; 1739 return TRUE;
1740 } 1740 }
1741 1741
1742 FX_BOOL Document::extractPages(IJS_Context* cc, 1742 FX_BOOL Document::extractPages(IJS_Context* cc,
1743 const CJS_Parameters& params, 1743 const std::vector<CJS_Value>& params,
1744 CJS_Value& vRet, 1744 CJS_Value& vRet,
1745 CFX_WideString& sError) { 1745 CFX_WideString& sError) {
1746 // Unsafe, not supported. 1746 // Unsafe, not supported.
1747 return TRUE; 1747 return TRUE;
1748 } 1748 }
1749 1749
1750 FX_BOOL Document::insertPages(IJS_Context* cc, 1750 FX_BOOL Document::insertPages(IJS_Context* cc,
1751 const CJS_Parameters& params, 1751 const std::vector<CJS_Value>& params,
1752 CJS_Value& vRet, 1752 CJS_Value& vRet,
1753 CFX_WideString& sError) { 1753 CFX_WideString& sError) {
1754 // Unsafe, not supported. 1754 // Unsafe, not supported.
1755 return TRUE; 1755 return TRUE;
1756 } 1756 }
1757 1757
1758 FX_BOOL Document::replacePages(IJS_Context* cc, 1758 FX_BOOL Document::replacePages(IJS_Context* cc,
1759 const CJS_Parameters& params, 1759 const std::vector<CJS_Value>& params,
1760 CJS_Value& vRet, 1760 CJS_Value& vRet,
1761 CFX_WideString& sError) { 1761 CFX_WideString& sError) {
1762 // Unsafe, not supported. 1762 // Unsafe, not supported.
1763 return TRUE; 1763 return TRUE;
1764 } 1764 }
1765 1765
1766 FX_BOOL Document::getURL(IJS_Context* cc, 1766 FX_BOOL Document::getURL(IJS_Context* cc,
1767 const CJS_Parameters& params, 1767 const std::vector<CJS_Value>& params,
1768 CJS_Value& vRet, 1768 CJS_Value& vRet,
1769 CFX_WideString& sError) { 1769 CFX_WideString& sError) {
1770 // Unsafe, not supported. 1770 // Unsafe, not supported.
1771 return TRUE; 1771 return TRUE;
1772 } 1772 }
1773 1773
1774 void Document::AddDelayData(CJS_DelayData* pData) { 1774 void Document::AddDelayData(CJS_DelayData* pData) {
1775 m_DelayData.Add(pData); 1775 m_DelayData.Add(pData);
1776 } 1776 }
1777 1777
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1812 CFX_DWordArray DelArray; 1812 CFX_DWordArray DelArray;
1813 1813
1814 for (int j = DelArray.GetSize() - 1; j >= 0; j--) { 1814 for (int j = DelArray.GetSize() - 1; j >= 0; j--) {
1815 m_DelayData.RemoveAt(DelArray[j]); 1815 m_DelayData.RemoveAt(DelArray[j]);
1816 } 1816 }
1817 } 1817 }
1818 1818
1819 CJS_Document* Document::GetCJSDoc() const { 1819 CJS_Document* Document::GetCJSDoc() const {
1820 return static_cast<CJS_Document*>(m_pJSObject); 1820 return static_cast<CJS_Document*>(m_pJSObject);
1821 } 1821 }
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