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> |
(...skipping 783 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
794 CFX_WideString cwProducer = pDictionary->GetUnicodeTextFor("Producer"); | 794 CFX_WideString cwProducer = pDictionary->GetUnicodeTextFor("Producer"); |
795 CFX_WideString cwCreationDate = | 795 CFX_WideString cwCreationDate = |
796 pDictionary->GetUnicodeTextFor("CreationDate"); | 796 pDictionary->GetUnicodeTextFor("CreationDate"); |
797 CFX_WideString cwModDate = pDictionary->GetUnicodeTextFor("ModDate"); | 797 CFX_WideString cwModDate = pDictionary->GetUnicodeTextFor("ModDate"); |
798 CFX_WideString cwTrapped = pDictionary->GetUnicodeTextFor("Trapped"); | 798 CFX_WideString cwTrapped = pDictionary->GetUnicodeTextFor("Trapped"); |
799 | 799 |
800 CJS_Context* pContext = (CJS_Context*)cc; | 800 CJS_Context* pContext = (CJS_Context*)cc; |
801 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 801 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
802 | 802 |
803 v8::Local<v8::Object> pObj = pRuntime->NewFxDynamicObj(-1); | 803 v8::Local<v8::Object> pObj = pRuntime->NewFxDynamicObj(-1); |
804 pRuntime->PutObjectString(pObj, L"Author", cwAuthor); | 804 pRuntime->PutObjectProperty(pObj, L"Author", pRuntime->NewString(cwAuthor)); |
805 pRuntime->PutObjectString(pObj, L"Title", cwTitle); | 805 pRuntime->PutObjectProperty(pObj, L"Title", pRuntime->NewString(cwTitle)); |
806 pRuntime->PutObjectString(pObj, L"Subject", cwSubject); | 806 pRuntime->PutObjectProperty(pObj, L"Subject", pRuntime->NewString(cwSubject)); |
807 pRuntime->PutObjectString(pObj, L"Keywords", cwKeywords); | 807 pRuntime->PutObjectProperty(pObj, L"Keywords", |
808 pRuntime->PutObjectString(pObj, L"Creator", cwCreator); | 808 pRuntime->NewString(cwKeywords)); |
809 pRuntime->PutObjectString(pObj, L"Producer", cwProducer); | 809 pRuntime->PutObjectProperty(pObj, L"Creator", pRuntime->NewString(cwCreator)); |
810 pRuntime->PutObjectString(pObj, L"CreationDate", cwCreationDate); | 810 pRuntime->PutObjectProperty(pObj, L"Producer", |
811 pRuntime->PutObjectString(pObj, L"ModDate", cwModDate); | 811 pRuntime->NewString(cwProducer)); |
812 pRuntime->PutObjectString(pObj, L"Trapped", cwTrapped); | 812 pRuntime->PutObjectProperty(pObj, L"CreationDate", |
| 813 pRuntime->NewString(cwCreationDate)); |
| 814 pRuntime->PutObjectProperty(pObj, L"ModDate", pRuntime->NewString(cwModDate)); |
| 815 pRuntime->PutObjectProperty(pObj, L"Trapped", pRuntime->NewString(cwTrapped)); |
813 | 816 |
814 // It's to be compatible to non-standard info dictionary. | 817 // It's to be compatible to non-standard info dictionary. |
815 for (const auto& it : *pDictionary) { | 818 for (const auto& it : *pDictionary) { |
816 const CFX_ByteString& bsKey = it.first; | 819 const CFX_ByteString& bsKey = it.first; |
817 CPDF_Object* pValueObj = it.second.get(); | 820 CPDF_Object* pValueObj = it.second.get(); |
818 CFX_WideString wsKey = CFX_WideString::FromUTF8(bsKey.AsStringC()); | 821 CFX_WideString wsKey = CFX_WideString::FromUTF8(bsKey.AsStringC()); |
819 if (pValueObj->IsString() || pValueObj->IsName()) { | 822 if (pValueObj->IsString() || pValueObj->IsName()) { |
820 pRuntime->PutObjectString(pObj, wsKey, pValueObj->GetUnicodeText()); | 823 pRuntime->PutObjectProperty( |
| 824 pObj, wsKey, pRuntime->NewString(pValueObj->GetUnicodeText())); |
821 } else if (pValueObj->IsNumber()) { | 825 } else if (pValueObj->IsNumber()) { |
822 pRuntime->PutObjectNumber(pObj, wsKey, (float)pValueObj->GetNumber()); | 826 pRuntime->PutObjectProperty(pObj, wsKey, |
| 827 pRuntime->NewNumber(pValueObj->GetNumber())); |
823 } else if (pValueObj->IsBoolean()) { | 828 } else if (pValueObj->IsBoolean()) { |
824 pRuntime->PutObjectBoolean(pObj, wsKey, !!pValueObj->GetInteger()); | 829 pRuntime->PutObjectProperty( |
| 830 pObj, wsKey, pRuntime->NewBoolean(!!pValueObj->GetInteger())); |
825 } | 831 } |
826 } | 832 } |
827 vp << pObj; | 833 vp << pObj; |
828 return true; | 834 return true; |
829 } | 835 } |
830 | 836 |
831 bool Document::getPropertyInternal(IJS_Context* cc, | 837 bool Document::getPropertyInternal(IJS_Context* cc, |
832 CJS_PropValue& vp, | 838 CJS_PropValue& vp, |
833 const CFX_ByteString& propName, | 839 const CFX_ByteString& propName, |
834 CFX_WideString& sError) { | 840 CFX_WideString& sError) { |
(...skipping 882 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1717 } | 1723 } |
1718 } | 1724 } |
1719 | 1725 |
1720 for (const auto& pData : DelayDataForFieldAndControlIndex) | 1726 for (const auto& pData : DelayDataForFieldAndControlIndex) |
1721 Field::DoDelay(m_pFormFillEnv.Get(), pData.get()); | 1727 Field::DoDelay(m_pFormFillEnv.Get(), pData.get()); |
1722 } | 1728 } |
1723 | 1729 |
1724 CJS_Document* Document::GetCJSDoc() const { | 1730 CJS_Document* Document::GetCJSDoc() const { |
1725 return static_cast<CJS_Document*>(m_pJSObject); | 1731 return static_cast<CJS_Document*>(m_pJSObject); |
1726 } | 1732 } |
OLD | NEW |