| 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 751 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 762 CFX_WideString cwCreationDate = pDictionary->GetUnicodeTextBy("CreationDate"); | 762 CFX_WideString cwCreationDate = pDictionary->GetUnicodeTextBy("CreationDate"); |
| 763 CFX_WideString cwModDate = pDictionary->GetUnicodeTextBy("ModDate"); | 763 CFX_WideString cwModDate = pDictionary->GetUnicodeTextBy("ModDate"); |
| 764 CFX_WideString cwTrapped = pDictionary->GetUnicodeTextBy("Trapped"); | 764 CFX_WideString cwTrapped = pDictionary->GetUnicodeTextBy("Trapped"); |
| 765 | 765 |
| 766 v8::Isolate* isolate = GetIsolate(cc); | 766 v8::Isolate* isolate = GetIsolate(cc); |
| 767 if (vp.IsGetting()) { | 767 if (vp.IsGetting()) { |
| 768 CJS_Context* pContext = (CJS_Context*)cc; | 768 CJS_Context* pContext = (CJS_Context*)cc; |
| 769 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 769 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
| 770 v8::Local<v8::Object> pObj = | 770 v8::Local<v8::Object> pObj = |
| 771 FXJS_NewFxDynamicObj(pRuntime->GetIsolate(), pRuntime, -1); | 771 FXJS_NewFxDynamicObj(pRuntime->GetIsolate(), pRuntime, -1); |
| 772 FXJS_PutObjectString(isolate, pObj, L"Author", cwAuthor.c_str()); | 772 FXJS_PutObjectString(isolate, pObj, L"Author", cwAuthor); |
| 773 FXJS_PutObjectString(isolate, pObj, L"Title", cwTitle.c_str()); | 773 FXJS_PutObjectString(isolate, pObj, L"Title", cwTitle); |
| 774 FXJS_PutObjectString(isolate, pObj, L"Subject", cwSubject.c_str()); | 774 FXJS_PutObjectString(isolate, pObj, L"Subject", cwSubject); |
| 775 FXJS_PutObjectString(isolate, pObj, L"Keywords", cwKeywords.c_str()); | 775 FXJS_PutObjectString(isolate, pObj, L"Keywords", cwKeywords); |
| 776 FXJS_PutObjectString(isolate, pObj, L"Creator", cwCreator.c_str()); | 776 FXJS_PutObjectString(isolate, pObj, L"Creator", cwCreator); |
| 777 FXJS_PutObjectString(isolate, pObj, L"Producer", cwProducer.c_str()); | 777 FXJS_PutObjectString(isolate, pObj, L"Producer", cwProducer); |
| 778 FXJS_PutObjectString(isolate, pObj, L"CreationDate", | 778 FXJS_PutObjectString(isolate, pObj, L"CreationDate", cwCreationDate); |
| 779 cwCreationDate.c_str()); | 779 FXJS_PutObjectString(isolate, pObj, L"ModDate", cwModDate); |
| 780 FXJS_PutObjectString(isolate, pObj, L"ModDate", cwModDate.c_str()); | 780 FXJS_PutObjectString(isolate, pObj, L"Trapped", cwTrapped); |
| 781 FXJS_PutObjectString(isolate, pObj, L"Trapped", cwTrapped.c_str()); | |
| 782 | 781 |
| 783 // It's to be compatible to non-standard info dictionary. | 782 // It's to be compatible to non-standard info dictionary. |
| 784 for (const auto& it : *pDictionary) { | 783 for (const auto& it : *pDictionary) { |
| 785 const CFX_ByteString& bsKey = it.first; | 784 const CFX_ByteString& bsKey = it.first; |
| 786 CPDF_Object* pValueObj = it.second; | 785 CPDF_Object* pValueObj = it.second; |
| 787 CFX_WideString wsKey = CFX_WideString::FromUTF8(bsKey.AsStringC()); | 786 CFX_WideString wsKey = CFX_WideString::FromUTF8(bsKey.AsStringC()); |
| 788 if (pValueObj->IsString() || pValueObj->IsName()) { | 787 if (pValueObj->IsString() || pValueObj->IsName()) { |
| 789 FXJS_PutObjectString(isolate, pObj, wsKey.c_str(), | 788 FXJS_PutObjectString(isolate, pObj, wsKey, pValueObj->GetUnicodeText()); |
| 790 pValueObj->GetUnicodeText().c_str()); | |
| 791 } else if (pValueObj->IsNumber()) { | 789 } else if (pValueObj->IsNumber()) { |
| 792 FXJS_PutObjectNumber(isolate, pObj, wsKey.c_str(), | 790 FXJS_PutObjectNumber(isolate, pObj, wsKey, |
| 793 (float)pValueObj->GetNumber()); | 791 (float)pValueObj->GetNumber()); |
| 794 } else if (pValueObj->IsBoolean()) { | 792 } else if (pValueObj->IsBoolean()) { |
| 795 FXJS_PutObjectBoolean(isolate, pObj, wsKey.c_str(), | 793 FXJS_PutObjectBoolean(isolate, pObj, wsKey, !!pValueObj->GetInteger()); |
| 796 !!pValueObj->GetInteger()); | |
| 797 } | 794 } |
| 798 } | 795 } |
| 799 vp << pObj; | 796 vp << pObj; |
| 800 } | 797 } |
| 801 return TRUE; | 798 return TRUE; |
| 802 } | 799 } |
| 803 | 800 |
| 804 FX_BOOL Document::creationDate(IJS_Context* cc, | 801 FX_BOOL Document::creationDate(IJS_Context* cc, |
| 805 CJS_PropValue& vp, | 802 CJS_PropValue& vp, |
| 806 CFX_WideString& sError) { | 803 CFX_WideString& sError) { |
| (...skipping 782 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1589 } | 1586 } |
| 1590 } | 1587 } |
| 1591 | 1588 |
| 1592 for (const auto& pData : DelayDataForFieldAndControlIndex) | 1589 for (const auto& pData : DelayDataForFieldAndControlIndex) |
| 1593 Field::DoDelay(m_pDocument, pData.get()); | 1590 Field::DoDelay(m_pDocument, pData.get()); |
| 1594 } | 1591 } |
| 1595 | 1592 |
| 1596 CJS_Document* Document::GetCJSDoc() const { | 1593 CJS_Document* Document::GetCJSDoc() const { |
| 1597 return static_cast<CJS_Document*>(m_pJSObject); | 1594 return static_cast<CJS_Document*>(m_pJSObject); |
| 1598 } | 1595 } |
| OLD | NEW |