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

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

Issue 1436843003: Merge to XFA: Cleanup CPDF_ApSettings and CJS_Parameters. (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 | « core/src/fpdfdoc/doc_formcontrol.cpp ('k') | fpdfsdk/src/javascript/JS_Value.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 549 matching lines...) Expand 10 before | Expand all | Expand 10 after
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();
567 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); 567 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
568 CJS_Array aName(pRuntime); 568 CJS_Array aName(pRuntime);
569 569
570 // TODO(thestig) Convert CJS_Parameters to a std::vector and use .empty(). 570 if (params.empty()) {
571 if (params.size() <= 0) {
572 pPDFForm->ResetForm(TRUE); 571 pPDFForm->ResetForm(TRUE);
573 m_pDocument->SetChangeMark(); 572 m_pDocument->SetChangeMark();
574 return TRUE; 573 return TRUE;
575 } 574 }
576 575
577 switch (params[0].GetType()) { 576 switch (params[0].GetType()) {
578 default: 577 default:
579 aName.Attach(params[0].ToV8Array()); 578 aName.Attach(params[0].ToV8Array());
580 break; 579 break;
581 case CJS_Value::VT_string: 580 case CJS_Value::VT_string:
(...skipping 933 matching lines...) Expand 10 before | Expand all | Expand 10 after
1515 1514
1516 FX_BOOL Document::getPageNthWord(IJS_Context* cc, 1515 FX_BOOL Document::getPageNthWord(IJS_Context* cc,
1517 const CJS_Parameters& params, 1516 const CJS_Parameters& params,
1518 CJS_Value& vRet, 1517 CJS_Value& vRet,
1519 CFX_WideString& sError) { 1518 CFX_WideString& sError) {
1520 ASSERT(m_pDocument != NULL); 1519 ASSERT(m_pDocument != NULL);
1521 1520
1522 if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) 1521 if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS))
1523 return FALSE; 1522 return FALSE;
1524 1523
1525 int nPageNo = params.GetSize() > 0 ? params[0].ToInt() : 0; 1524 int nPageNo = params.size() > 0 ? params[0].ToInt() : 0;
1526 int nWordNo = params.GetSize() > 1 ? params[1].ToInt() : 0; 1525 int nWordNo = params.size() > 1 ? params[1].ToInt() : 0;
1527 bool bStrip = params.GetSize() > 2 ? params[2].ToBool() : true; 1526 bool bStrip = params.size() > 2 ? params[2].ToBool() : true;
1528 1527
1529 CPDF_Document* pDocument = m_pDocument->GetDocument()->GetPDFDoc(); 1528 CPDF_Document* pDocument = m_pDocument->GetDocument()->GetPDFDoc();
1530 if (!pDocument) 1529 if (!pDocument)
1531 return FALSE; 1530 return FALSE;
1532 1531
1533 CJS_Context* pContext = static_cast<CJS_Context*>(cc); 1532 CJS_Context* pContext = static_cast<CJS_Context*>(cc);
1534 if (nPageNo < 0 || nPageNo >= pDocument->GetPageCount()) { 1533 if (nPageNo < 0 || nPageNo >= pDocument->GetPageCount()) {
1535 sError = JSGetStringFromID(pContext, IDS_STRING_JSVALUEERROR); 1534 sError = JSGetStringFromID(pContext, IDS_STRING_JSVALUEERROR);
1536 return FALSE; 1535 return FALSE;
1537 } 1536 }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1589 1588
1590 FX_BOOL Document::getPageNumWords(IJS_Context* cc, 1589 FX_BOOL Document::getPageNumWords(IJS_Context* cc,
1591 const CJS_Parameters& params, 1590 const CJS_Parameters& params,
1592 CJS_Value& vRet, 1591 CJS_Value& vRet,
1593 CFX_WideString& sError) { 1592 CFX_WideString& sError) {
1594 ASSERT(m_pDocument != NULL); 1593 ASSERT(m_pDocument != NULL);
1595 1594
1596 if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) 1595 if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS))
1597 return FALSE; 1596 return FALSE;
1598 1597
1599 int nPageNo = params.GetSize() > 0 ? params[0].ToInt() : 0; 1598 int nPageNo = params.size() > 0 ? params[0].ToInt() : 0;
1600 1599
1601 CPDF_Document* pDocument = m_pDocument->GetDocument()->GetPDFDoc(); 1600 CPDF_Document* pDocument = m_pDocument->GetDocument()->GetPDFDoc();
1602 ASSERT(pDocument != NULL); 1601 ASSERT(pDocument != NULL);
1603 1602
1604 CJS_Context* pContext = static_cast<CJS_Context*>(cc); 1603 CJS_Context* pContext = static_cast<CJS_Context*>(cc);
1605 if (nPageNo < 0 || nPageNo >= pDocument->GetPageCount()) { 1604 if (nPageNo < 0 || nPageNo >= pDocument->GetPageCount()) {
1606 sError = JSGetStringFromID(pContext, IDS_STRING_JSVALUEERROR); 1605 sError = JSGetStringFromID(pContext, IDS_STRING_JSVALUEERROR);
1607 return FALSE; 1606 return FALSE;
1608 } 1607 }
1609 1608
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
1826 CFX_DWordArray DelArray; 1825 CFX_DWordArray DelArray;
1827 1826
1828 for (int j = DelArray.GetSize() - 1; j >= 0; j--) { 1827 for (int j = DelArray.GetSize() - 1; j >= 0; j--) {
1829 m_DelayData.RemoveAt(DelArray[j]); 1828 m_DelayData.RemoveAt(DelArray[j]);
1830 } 1829 }
1831 } 1830 }
1832 1831
1833 CJS_Document* Document::GetCJSDoc() const { 1832 CJS_Document* Document::GetCJSDoc() const {
1834 return static_cast<CJS_Document*>(m_pJSObject); 1833 return static_cast<CJS_Document*>(m_pJSObject);
1835 } 1834 }
OLDNEW
« no previous file with comments | « core/src/fpdfdoc/doc_formcontrol.cpp ('k') | fpdfsdk/src/javascript/JS_Value.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698