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 <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "core/fpdfapi/font/cpdf_font.h" | 12 #include "core/fpdfapi/font/cpdf_font.h" |
13 #include "core/fpdfapi/page/cpdf_page.h" | 13 #include "core/fpdfapi/page/cpdf_page.h" |
14 #include "core/fpdfapi/parser/cpdf_array.h" | 14 #include "core/fpdfapi/parser/cpdf_array.h" |
15 #include "core/fpdfapi/parser/cpdf_document.h" | 15 #include "core/fpdfapi/parser/cpdf_document.h" |
| 16 #include "core/fpdfapi/parser/cpdf_string.h" |
16 #include "core/fpdfapi/parser/fpdf_parser_decode.h" | 17 #include "core/fpdfapi/parser/fpdf_parser_decode.h" |
17 #include "core/fpdfdoc/cpdf_interform.h" | 18 #include "core/fpdfdoc/cpdf_interform.h" |
18 #include "core/fpdfdoc/cpdf_nametree.h" | 19 #include "core/fpdfdoc/cpdf_nametree.h" |
19 #include "fpdfsdk/cpdfsdk_annotiterator.h" | 20 #include "fpdfsdk/cpdfsdk_annotiterator.h" |
20 #include "fpdfsdk/cpdfsdk_formfillenvironment.h" | 21 #include "fpdfsdk/cpdfsdk_formfillenvironment.h" |
21 #include "fpdfsdk/cpdfsdk_interform.h" | 22 #include "fpdfsdk/cpdfsdk_interform.h" |
22 #include "fpdfsdk/cpdfsdk_pageview.h" | 23 #include "fpdfsdk/cpdfsdk_pageview.h" |
23 #include "fpdfsdk/cpdfsdk_widget.h" | 24 #include "fpdfsdk/cpdfsdk_widget.h" |
24 #include "fpdfsdk/javascript/Annot.h" | 25 #include "fpdfsdk/javascript/Annot.h" |
25 #include "fpdfsdk/javascript/Field.h" | 26 #include "fpdfsdk/javascript/Field.h" |
(...skipping 776 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
802 pRuntime->PutObjectString(pObj, L"Keywords", cwKeywords); | 803 pRuntime->PutObjectString(pObj, L"Keywords", cwKeywords); |
803 pRuntime->PutObjectString(pObj, L"Creator", cwCreator); | 804 pRuntime->PutObjectString(pObj, L"Creator", cwCreator); |
804 pRuntime->PutObjectString(pObj, L"Producer", cwProducer); | 805 pRuntime->PutObjectString(pObj, L"Producer", cwProducer); |
805 pRuntime->PutObjectString(pObj, L"CreationDate", cwCreationDate); | 806 pRuntime->PutObjectString(pObj, L"CreationDate", cwCreationDate); |
806 pRuntime->PutObjectString(pObj, L"ModDate", cwModDate); | 807 pRuntime->PutObjectString(pObj, L"ModDate", cwModDate); |
807 pRuntime->PutObjectString(pObj, L"Trapped", cwTrapped); | 808 pRuntime->PutObjectString(pObj, L"Trapped", cwTrapped); |
808 | 809 |
809 // It's to be compatible to non-standard info dictionary. | 810 // It's to be compatible to non-standard info dictionary. |
810 for (const auto& it : *pDictionary) { | 811 for (const auto& it : *pDictionary) { |
811 const CFX_ByteString& bsKey = it.first; | 812 const CFX_ByteString& bsKey = it.first; |
812 CPDF_Object* pValueObj = it.second; | 813 CPDF_Object* pValueObj = it.second.get(); |
813 CFX_WideString wsKey = CFX_WideString::FromUTF8(bsKey.AsStringC()); | 814 CFX_WideString wsKey = CFX_WideString::FromUTF8(bsKey.AsStringC()); |
814 if (pValueObj->IsString() || pValueObj->IsName()) { | 815 if (pValueObj->IsString() || pValueObj->IsName()) { |
815 pRuntime->PutObjectString(pObj, wsKey, pValueObj->GetUnicodeText()); | 816 pRuntime->PutObjectString(pObj, wsKey, pValueObj->GetUnicodeText()); |
816 } else if (pValueObj->IsNumber()) { | 817 } else if (pValueObj->IsNumber()) { |
817 pRuntime->PutObjectNumber(pObj, wsKey, (float)pValueObj->GetNumber()); | 818 pRuntime->PutObjectNumber(pObj, wsKey, (float)pValueObj->GetNumber()); |
818 } else if (pValueObj->IsBoolean()) { | 819 } else if (pValueObj->IsBoolean()) { |
819 pRuntime->PutObjectBoolean(pObj, wsKey, !!pValueObj->GetInteger()); | 820 pRuntime->PutObjectBoolean(pObj, wsKey, !!pValueObj->GetInteger()); |
820 } | 821 } |
821 } | 822 } |
822 vp << pObj; | 823 vp << pObj; |
(...skipping 14 matching lines...) Expand all Loading... |
837 | 838 |
838 if (vp.IsGetting()) { | 839 if (vp.IsGetting()) { |
839 vp << pDictionary->GetUnicodeTextFor(propName); | 840 vp << pDictionary->GetUnicodeTextFor(propName); |
840 } else { | 841 } else { |
841 if (!m_pFormFillEnv->GetPermissions(FPDFPERM_MODIFY)) { | 842 if (!m_pFormFillEnv->GetPermissions(FPDFPERM_MODIFY)) { |
842 sError = JSGetStringFromID(IDS_STRING_JSNOPERMISSION); | 843 sError = JSGetStringFromID(IDS_STRING_JSNOPERMISSION); |
843 return false; | 844 return false; |
844 } | 845 } |
845 CFX_WideString csProperty; | 846 CFX_WideString csProperty; |
846 vp >> csProperty; | 847 vp >> csProperty; |
847 pDictionary->SetStringFor(propName, PDF_EncodeText(csProperty)); | 848 pDictionary->SetNewFor<CPDF_String>(propName, PDF_EncodeText(csProperty), |
| 849 false); |
848 m_pFormFillEnv->SetChangeMark(); | 850 m_pFormFillEnv->SetChangeMark(); |
849 } | 851 } |
850 return true; | 852 return true; |
851 } | 853 } |
852 | 854 |
853 bool Document::creationDate(IJS_Context* cc, | 855 bool Document::creationDate(IJS_Context* cc, |
854 CJS_PropValue& vp, | 856 CJS_PropValue& vp, |
855 CFX_WideString& sError) { | 857 CFX_WideString& sError) { |
856 return getPropertyInternal(cc, vp, "CreationDate", sError); | 858 return getPropertyInternal(cc, vp, "CreationDate", sError); |
857 } | 859 } |
(...skipping 856 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1714 } | 1716 } |
1715 } | 1717 } |
1716 | 1718 |
1717 for (const auto& pData : DelayDataForFieldAndControlIndex) | 1719 for (const auto& pData : DelayDataForFieldAndControlIndex) |
1718 Field::DoDelay(m_pFormFillEnv.Get(), pData.get()); | 1720 Field::DoDelay(m_pFormFillEnv.Get(), pData.get()); |
1719 } | 1721 } |
1720 | 1722 |
1721 CJS_Document* Document::GetCJSDoc() const { | 1723 CJS_Document* Document::GetCJSDoc() const { |
1722 return static_cast<CJS_Document*>(m_pJSObject); | 1724 return static_cast<CJS_Document*>(m_pJSObject); |
1723 } | 1725 } |
OLD | NEW |