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 "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 Loading... |
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 920 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1502 | 1501 |
1503 FX_BOOL Document::getPageNthWord(IJS_Context* cc, | 1502 FX_BOOL Document::getPageNthWord(IJS_Context* cc, |
1504 const CJS_Parameters& params, | 1503 const CJS_Parameters& params, |
1505 CJS_Value& vRet, | 1504 CJS_Value& vRet, |
1506 CFX_WideString& sError) { | 1505 CFX_WideString& sError) { |
1507 ASSERT(m_pDocument != NULL); | 1506 ASSERT(m_pDocument != NULL); |
1508 | 1507 |
1509 if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) | 1508 if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) |
1510 return FALSE; | 1509 return FALSE; |
1511 | 1510 |
1512 int nPageNo = params.GetSize() > 0 ? params[0].ToInt() : 0; | 1511 int nPageNo = params.size() > 0 ? params[0].ToInt() : 0; |
1513 int nWordNo = params.GetSize() > 1 ? params[1].ToInt() : 0; | 1512 int nWordNo = params.size() > 1 ? params[1].ToInt() : 0; |
1514 bool bStrip = params.GetSize() > 2 ? params[2].ToBool() : true; | 1513 bool bStrip = params.size() > 2 ? params[2].ToBool() : true; |
1515 | 1514 |
1516 CPDF_Document* pDocument = m_pDocument->GetPDFDocument(); | 1515 CPDF_Document* pDocument = m_pDocument->GetPDFDocument(); |
1517 if (!pDocument) | 1516 if (!pDocument) |
1518 return FALSE; | 1517 return FALSE; |
1519 | 1518 |
1520 CJS_Context* pContext = static_cast<CJS_Context*>(cc); | 1519 CJS_Context* pContext = static_cast<CJS_Context*>(cc); |
1521 if (nPageNo < 0 || nPageNo >= pDocument->GetPageCount()) { | 1520 if (nPageNo < 0 || nPageNo >= pDocument->GetPageCount()) { |
1522 sError = JSGetStringFromID(pContext, IDS_STRING_JSVALUEERROR); | 1521 sError = JSGetStringFromID(pContext, IDS_STRING_JSVALUEERROR); |
1523 return FALSE; | 1522 return FALSE; |
1524 } | 1523 } |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1576 | 1575 |
1577 FX_BOOL Document::getPageNumWords(IJS_Context* cc, | 1576 FX_BOOL Document::getPageNumWords(IJS_Context* cc, |
1578 const CJS_Parameters& params, | 1577 const CJS_Parameters& params, |
1579 CJS_Value& vRet, | 1578 CJS_Value& vRet, |
1580 CFX_WideString& sError) { | 1579 CFX_WideString& sError) { |
1581 ASSERT(m_pDocument != NULL); | 1580 ASSERT(m_pDocument != NULL); |
1582 | 1581 |
1583 if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) | 1582 if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) |
1584 return FALSE; | 1583 return FALSE; |
1585 | 1584 |
1586 int nPageNo = params.GetSize() > 0 ? params[0].ToInt() : 0; | 1585 int nPageNo = params.size() > 0 ? params[0].ToInt() : 0; |
1587 | 1586 |
1588 CPDF_Document* pDocument = m_pDocument->GetPDFDocument(); | 1587 CPDF_Document* pDocument = m_pDocument->GetPDFDocument(); |
1589 ASSERT(pDocument != NULL); | 1588 ASSERT(pDocument != NULL); |
1590 | 1589 |
1591 CJS_Context* pContext = static_cast<CJS_Context*>(cc); | 1590 CJS_Context* pContext = static_cast<CJS_Context*>(cc); |
1592 if (nPageNo < 0 || nPageNo >= pDocument->GetPageCount()) { | 1591 if (nPageNo < 0 || nPageNo >= pDocument->GetPageCount()) { |
1593 sError = JSGetStringFromID(pContext, IDS_STRING_JSVALUEERROR); | 1592 sError = JSGetStringFromID(pContext, IDS_STRING_JSVALUEERROR); |
1594 return FALSE; | 1593 return FALSE; |
1595 } | 1594 } |
1596 | 1595 |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1813 CFX_DWordArray DelArray; | 1812 CFX_DWordArray DelArray; |
1814 | 1813 |
1815 for (int j = DelArray.GetSize() - 1; j >= 0; j--) { | 1814 for (int j = DelArray.GetSize() - 1; j >= 0; j--) { |
1816 m_DelayData.RemoveAt(DelArray[j]); | 1815 m_DelayData.RemoveAt(DelArray[j]); |
1817 } | 1816 } |
1818 } | 1817 } |
1819 | 1818 |
1820 CJS_Document* Document::GetCJSDoc() const { | 1819 CJS_Document* Document::GetCJSDoc() const { |
1821 return static_cast<CJS_Document*>(m_pJSObject); | 1820 return static_cast<CJS_Document*>(m_pJSObject); |
1822 } | 1821 } |
OLD | NEW |