| 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 "fpdfsdk/javascript/Document.h" | 7 #include "fpdfsdk/javascript/Document.h" |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 766 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 777 return FALSE; | 777 return FALSE; |
| 778 } | 778 } |
| 779 if (!m_pDocument) { | 779 if (!m_pDocument) { |
| 780 sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT); | 780 sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT); |
| 781 return FALSE; | 781 return FALSE; |
| 782 } | 782 } |
| 783 CPDF_Dictionary* pDictionary = m_pDocument->GetPDFDocument()->GetInfo(); | 783 CPDF_Dictionary* pDictionary = m_pDocument->GetPDFDocument()->GetInfo(); |
| 784 if (!pDictionary) | 784 if (!pDictionary) |
| 785 return FALSE; | 785 return FALSE; |
| 786 | 786 |
| 787 CFX_WideString cwAuthor = pDictionary->GetUnicodeTextBy("Author"); | 787 CFX_WideString cwAuthor = pDictionary->GetUnicodeTextFor("Author"); |
| 788 CFX_WideString cwTitle = pDictionary->GetUnicodeTextBy("Title"); | 788 CFX_WideString cwTitle = pDictionary->GetUnicodeTextFor("Title"); |
| 789 CFX_WideString cwSubject = pDictionary->GetUnicodeTextBy("Subject"); | 789 CFX_WideString cwSubject = pDictionary->GetUnicodeTextFor("Subject"); |
| 790 CFX_WideString cwKeywords = pDictionary->GetUnicodeTextBy("Keywords"); | 790 CFX_WideString cwKeywords = pDictionary->GetUnicodeTextFor("Keywords"); |
| 791 CFX_WideString cwCreator = pDictionary->GetUnicodeTextBy("Creator"); | 791 CFX_WideString cwCreator = pDictionary->GetUnicodeTextFor("Creator"); |
| 792 CFX_WideString cwProducer = pDictionary->GetUnicodeTextBy("Producer"); | 792 CFX_WideString cwProducer = pDictionary->GetUnicodeTextFor("Producer"); |
| 793 CFX_WideString cwCreationDate = pDictionary->GetUnicodeTextBy("CreationDate"); | 793 CFX_WideString cwCreationDate = |
| 794 CFX_WideString cwModDate = pDictionary->GetUnicodeTextBy("ModDate"); | 794 pDictionary->GetUnicodeTextFor("CreationDate"); |
| 795 CFX_WideString cwTrapped = pDictionary->GetUnicodeTextBy("Trapped"); | 795 CFX_WideString cwModDate = pDictionary->GetUnicodeTextFor("ModDate"); |
| 796 CFX_WideString cwTrapped = pDictionary->GetUnicodeTextFor("Trapped"); |
| 796 | 797 |
| 797 CJS_Context* pContext = (CJS_Context*)cc; | 798 CJS_Context* pContext = (CJS_Context*)cc; |
| 798 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 799 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
| 799 | 800 |
| 800 v8::Local<v8::Object> pObj = pRuntime->NewFxDynamicObj(-1); | 801 v8::Local<v8::Object> pObj = pRuntime->NewFxDynamicObj(-1); |
| 801 pRuntime->PutObjectString(pObj, L"Author", cwAuthor); | 802 pRuntime->PutObjectString(pObj, L"Author", cwAuthor); |
| 802 pRuntime->PutObjectString(pObj, L"Title", cwTitle); | 803 pRuntime->PutObjectString(pObj, L"Title", cwTitle); |
| 803 pRuntime->PutObjectString(pObj, L"Subject", cwSubject); | 804 pRuntime->PutObjectString(pObj, L"Subject", cwSubject); |
| 804 pRuntime->PutObjectString(pObj, L"Keywords", cwKeywords); | 805 pRuntime->PutObjectString(pObj, L"Keywords", cwKeywords); |
| 805 pRuntime->PutObjectString(pObj, L"Creator", cwCreator); | 806 pRuntime->PutObjectString(pObj, L"Creator", cwCreator); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 831 CFX_WideString& sError) { | 832 CFX_WideString& sError) { |
| 832 if (!m_pDocument) { | 833 if (!m_pDocument) { |
| 833 sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT); | 834 sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT); |
| 834 return FALSE; | 835 return FALSE; |
| 835 } | 836 } |
| 836 CPDF_Dictionary* pDictionary = m_pDocument->GetPDFDocument()->GetInfo(); | 837 CPDF_Dictionary* pDictionary = m_pDocument->GetPDFDocument()->GetInfo(); |
| 837 if (!pDictionary) | 838 if (!pDictionary) |
| 838 return FALSE; | 839 return FALSE; |
| 839 | 840 |
| 840 if (vp.IsGetting()) { | 841 if (vp.IsGetting()) { |
| 841 vp << pDictionary->GetUnicodeTextBy(propName); | 842 vp << pDictionary->GetUnicodeTextFor(propName); |
| 842 } else { | 843 } else { |
| 843 if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) { | 844 if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) { |
| 844 sError = JSGetStringFromID(IDS_STRING_JSNOPERMISSION); | 845 sError = JSGetStringFromID(IDS_STRING_JSNOPERMISSION); |
| 845 return FALSE; | 846 return FALSE; |
| 846 } | 847 } |
| 847 CFX_WideString csProperty; | 848 CFX_WideString csProperty; |
| 848 vp >> csProperty; | 849 vp >> csProperty; |
| 849 pDictionary->SetAtString(propName, PDF_EncodeText(csProperty)); | 850 pDictionary->SetStringFor(propName, PDF_EncodeText(csProperty)); |
| 850 m_pDocument->SetChangeMark(); | 851 m_pDocument->SetChangeMark(); |
| 851 } | 852 } |
| 852 return TRUE; | 853 return TRUE; |
| 853 } | 854 } |
| 854 | 855 |
| 855 FX_BOOL Document::creationDate(IJS_Context* cc, | 856 FX_BOOL Document::creationDate(IJS_Context* cc, |
| 856 CJS_PropValue& vp, | 857 CJS_PropValue& vp, |
| 857 CFX_WideString& sError) { | 858 CFX_WideString& sError) { |
| 858 return getPropertyInternal(cc, vp, "CreationDate", sError); | 859 return getPropertyInternal(cc, vp, "CreationDate", sError); |
| 859 } | 860 } |
| (...skipping 859 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1719 } | 1720 } |
| 1720 } | 1721 } |
| 1721 | 1722 |
| 1722 for (const auto& pData : DelayDataForFieldAndControlIndex) | 1723 for (const auto& pData : DelayDataForFieldAndControlIndex) |
| 1723 Field::DoDelay(m_pDocument.Get(), pData.get()); | 1724 Field::DoDelay(m_pDocument.Get(), pData.get()); |
| 1724 } | 1725 } |
| 1725 | 1726 |
| 1726 CJS_Document* Document::GetCJSDoc() const { | 1727 CJS_Document* Document::GetCJSDoc() const { |
| 1727 return static_cast<CJS_Document*>(m_pJSObject); | 1728 return static_cast<CJS_Document*>(m_pJSObject); |
| 1728 } | 1729 } |
| OLD | NEW |