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 "../../include/fpdfdoc/fpdf_doc.h" | 7 #include "../../include/fpdfdoc/fpdf_doc.h" |
8 #include "../../include/fxcrt/fx_xml.h" | 8 #include "../../include/fxcrt/fx_xml.h" |
9 typedef struct _PDFDOC_METADATA { | 9 typedef struct _PDFDOC_METADATA { |
10 CPDF_Document *m_pDoc; | 10 CPDF_Document *m_pDoc; |
(...skipping 10 matching lines...) Expand all Loading... |
21 "Producer", "Producer", | 21 "Producer", "Producer", |
22 "Creator", "CreatorTool", | 22 "Creator", "CreatorTool", |
23 "CreationDate", "CreateDate", | 23 "CreationDate", "CreateDate", |
24 "ModDate", "ModifyDate", | 24 "ModDate", "ModifyDate", |
25 "MetadataDate", "MetadataDate" | 25 "MetadataDate", "MetadataDate" |
26 }; | 26 }; |
27 CPDF_Metadata::CPDF_Metadata() | 27 CPDF_Metadata::CPDF_Metadata() |
28 { | 28 { |
29 m_pData = FX_Alloc(PDFDOC_METADATA, 1); | 29 m_pData = FX_Alloc(PDFDOC_METADATA, 1); |
30 CFX_CMapByteStringToPtr *&pStringMap = ((PDFDOC_LPMETADATA)m_pData)->m_pStri
ngMap; | 30 CFX_CMapByteStringToPtr *&pStringMap = ((PDFDOC_LPMETADATA)m_pData)->m_pStri
ngMap; |
31 pStringMap = FX_NEW(CFX_CMapByteStringToPtr); | 31 pStringMap = FX_NEW CFX_CMapByteStringToPtr; |
32 if (pStringMap != NULL) { | 32 if (pStringMap != NULL) { |
33 CFX_ByteString bstr; | 33 CFX_ByteString bstr; |
34 for (int i = 0; i < 18; i += 2) { | 34 for (int i = 0; i < 18; i += 2) { |
35 bstr = gs_FPDFDOC_Metadata_Titles[i]; | 35 bstr = gs_FPDFDOC_Metadata_Titles[i]; |
36 pStringMap->AddValue(bstr, (void*)gs_FPDFDOC_Metadata_Titles[i + 1])
; | 36 pStringMap->AddValue(bstr, (void*)gs_FPDFDOC_Metadata_Titles[i + 1])
; |
37 } | 37 } |
38 } | 38 } |
39 } | 39 } |
40 CPDF_Metadata::~CPDF_Metadata() | 40 CPDF_Metadata::~CPDF_Metadata() |
41 { | 41 { |
42 FXSYS_assert(m_pData != NULL); | 42 FXSYS_assert(m_pData != NULL); |
43 CXML_Element *&p = ((PDFDOC_LPMETADATA)m_pData)->m_pXmlElmnt; | 43 CXML_Element *&p = ((PDFDOC_LPMETADATA)m_pData)->m_pXmlElmnt; |
44 if (p) { | 44 delete p; |
45 delete p; | |
46 } | |
47 CFX_CMapByteStringToPtr *pStringMap = ((PDFDOC_LPMETADATA)m_pData)->m_pStrin
gMap; | 45 CFX_CMapByteStringToPtr *pStringMap = ((PDFDOC_LPMETADATA)m_pData)->m_pStrin
gMap; |
48 if (pStringMap) { | 46 if (pStringMap) { |
49 pStringMap->RemoveAll(); | 47 pStringMap->RemoveAll(); |
50 FX_Free(pStringMap); | 48 delete pStringMap; |
51 } | 49 } |
52 FX_Free(m_pData); | 50 FX_Free(m_pData); |
53 } | 51 } |
54 void CPDF_Metadata::LoadDoc(CPDF_Document *pDoc) | 52 void CPDF_Metadata::LoadDoc(CPDF_Document *pDoc) |
55 { | 53 { |
56 FXSYS_assert(pDoc != NULL); | 54 FXSYS_assert(pDoc != NULL); |
57 ((PDFDOC_LPMETADATA)m_pData)->m_pDoc = pDoc; | 55 ((PDFDOC_LPMETADATA)m_pData)->m_pDoc = pDoc; |
58 CPDF_Dictionary *pRoot = pDoc->GetRoot(); | 56 CPDF_Dictionary *pRoot = pDoc->GetRoot(); |
59 CPDF_Stream *pStream = pRoot->GetStream(FX_BSTRC("Metadata")); | 57 CPDF_Stream *pStream = pRoot->GetStream(FX_BSTRC("Metadata")); |
60 if (!pStream) { | 58 if (!pStream) { |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 return -1; | 140 return -1; |
143 } | 141 } |
144 CXML_Element* CPDF_Metadata::GetRoot() const | 142 CXML_Element* CPDF_Metadata::GetRoot() const |
145 { | 143 { |
146 return ((PDFDOC_LPMETADATA)m_pData)->m_pXmlElmnt; | 144 return ((PDFDOC_LPMETADATA)m_pData)->m_pXmlElmnt; |
147 } | 145 } |
148 CXML_Element* CPDF_Metadata::GetRDF() const | 146 CXML_Element* CPDF_Metadata::GetRDF() const |
149 { | 147 { |
150 return ((PDFDOC_LPMETADATA)m_pData)->m_pElmntRdf; | 148 return ((PDFDOC_LPMETADATA)m_pData)->m_pElmntRdf; |
151 } | 149 } |
OLD | NEW |