| 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 FX_LPCBYTE pBuf = acc.GetData(); | 63 FX_LPCBYTE pBuf = acc.GetData(); |
| 64 CXML_Element *&pXmlElmnt = ((PDFDOC_LPMETADATA)m_pData)->m_pXmlElmnt; | 64 CXML_Element *&pXmlElmnt = ((PDFDOC_LPMETADATA)m_pData)->m_pXmlElmnt; |
| 65 pXmlElmnt = CXML_Element::Parse(pBuf, size); | 65 pXmlElmnt = CXML_Element::Parse(pBuf, size); |
| 66 if (!pXmlElmnt) { | 66 if (!pXmlElmnt) { |
| 67 return; | 67 return; |
| 68 } | 68 } |
| 69 CXML_Element *&pElmntRdf = ((PDFDOC_LPMETADATA)m_pData)->m_pElmntRdf; | 69 CXML_Element *&pElmntRdf = ((PDFDOC_LPMETADATA)m_pData)->m_pElmntRdf; |
| 70 if (pXmlElmnt->GetTagName() == FX_BSTRC("RDF")) { | 70 if (pXmlElmnt->GetTagName() == FX_BSTRC("RDF")) { |
| 71 pElmntRdf = pXmlElmnt; | 71 pElmntRdf = pXmlElmnt; |
| 72 } else { | 72 } else { |
| 73 pElmntRdf = pXmlElmnt->GetElement(NULL, FX_BSTRC("RDF")); | 73 pElmntRdf = pXmlElmnt->GetElement(CFX_ByteStringC(), FX_BSTRC("RDF")); |
| 74 } | 74 } |
| 75 } | 75 } |
| 76 FX_INT32 CPDF_Metadata::GetString(FX_BSTR bsItem, CFX_WideString &wsStr) | 76 FX_INT32 CPDF_Metadata::GetString(FX_BSTR bsItem, CFX_WideString &wsStr) |
| 77 { | 77 { |
| 78 if (!((PDFDOC_LPMETADATA)m_pData)->m_pXmlElmnt) { | 78 if (!((PDFDOC_LPMETADATA)m_pData)->m_pXmlElmnt) { |
| 79 return -1; | 79 return -1; |
| 80 } | 80 } |
| 81 if (!((PDFDOC_LPMETADATA)m_pData)->m_pStringMap) { | 81 if (!((PDFDOC_LPMETADATA)m_pData)->m_pStringMap) { |
| 82 return -1; | 82 return -1; |
| 83 } | 83 } |
| 84 void *szTag; | 84 void *szTag; |
| 85 if (!((PDFDOC_LPMETADATA)m_pData)->m_pStringMap->Lookup(bsItem, szTag)) { | 85 if (!((PDFDOC_LPMETADATA)m_pData)->m_pStringMap->Lookup(bsItem, szTag)) { |
| 86 return -1; | 86 return -1; |
| 87 } | 87 } |
| 88 CFX_ByteString bsTag = (FX_LPCSTR)szTag; | 88 CFX_ByteString bsTag = (FX_LPCSTR)szTag; |
| 89 wsStr = L""; | 89 wsStr = L""; |
| 90 CXML_Element *pElmntRdf = ((PDFDOC_LPMETADATA)m_pData)->m_pElmntRdf; | 90 CXML_Element *pElmntRdf = ((PDFDOC_LPMETADATA)m_pData)->m_pElmntRdf; |
| 91 if (!pElmntRdf) { | 91 if (!pElmntRdf) { |
| 92 return -1; | 92 return -1; |
| 93 } | 93 } |
| 94 int nChild = pElmntRdf->CountChildren(); | 94 int nChild = pElmntRdf->CountChildren(); |
| 95 for (int i = 0; i < nChild; i++) { | 95 for (int i = 0; i < nChild; i++) { |
| 96 CXML_Element *pTag = pElmntRdf->GetElement(NULL, FX_BSTRC("Description")
, i); | 96 CXML_Element *pTag = pElmntRdf->GetElement(CFX_ByteStringC(), "Descripti
on", i); |
| 97 if (!pTag) { | 97 if (!pTag) { |
| 98 continue; | 98 continue; |
| 99 } | 99 } |
| 100 if (bsItem == FX_BSTRC("Title") || bsItem == FX_BSTRC("Subject")) { | 100 if (bsItem == FX_BSTRC("Title") || bsItem == FX_BSTRC("Subject")) { |
| 101 CXML_Element *pElmnt = pTag->GetElement(NULL, bsTag); | 101 CXML_Element *pElmnt = pTag->GetElement(CFX_ByteString(), bsTag); |
| 102 if (!pElmnt) { | 102 if (!pElmnt) { |
| 103 continue; | 103 continue; |
| 104 } | 104 } |
| 105 pElmnt = pElmnt->GetElement(NULL, FX_BSTRC("Alt")); | 105 pElmnt = pElmnt->GetElement(CFX_ByteString(), FX_BSTRC("Alt")); |
| 106 if (!pElmnt) { | 106 if (!pElmnt) { |
| 107 continue; | 107 continue; |
| 108 } | 108 } |
| 109 pElmnt = pElmnt->GetElement(NULL, FX_BSTRC("li")); | 109 pElmnt = pElmnt->GetElement(CFX_ByteString(), FX_BSTRC("li")); |
| 110 if (!pElmnt) { | 110 if (!pElmnt) { |
| 111 continue; | 111 continue; |
| 112 } | 112 } |
| 113 wsStr = pElmnt->GetContent(0); | 113 wsStr = pElmnt->GetContent(0); |
| 114 return wsStr.GetLength(); | 114 return wsStr.GetLength(); |
| 115 } else if (bsItem == FX_BSTRC("Author")) { | 115 } else if (bsItem == FX_BSTRC("Author")) { |
| 116 CXML_Element *pElmnt = pTag->GetElement(NULL, bsTag); | 116 CXML_Element *pElmnt = pTag->GetElement(CFX_ByteString(), bsTag); |
| 117 if (!pElmnt) { | 117 if (!pElmnt) { |
| 118 continue; | 118 continue; |
| 119 } | 119 } |
| 120 pElmnt = pElmnt->GetElement(NULL, FX_BSTRC("Seq")); | 120 pElmnt = pElmnt->GetElement(CFX_ByteString(), FX_BSTRC("Seq")); |
| 121 if (!pElmnt) { | 121 if (!pElmnt) { |
| 122 continue; | 122 continue; |
| 123 } | 123 } |
| 124 pElmnt = pElmnt->GetElement(NULL, FX_BSTRC("li")); | 124 pElmnt = pElmnt->GetElement(CFX_ByteString(), FX_BSTRC("li")); |
| 125 if (!pElmnt) { | 125 if (!pElmnt) { |
| 126 continue; | 126 continue; |
| 127 } | 127 } |
| 128 wsStr = pElmnt->GetContent(0); | 128 wsStr = pElmnt->GetContent(0); |
| 129 return wsStr.GetLength(); | 129 return wsStr.GetLength(); |
| 130 } else { | 130 } else { |
| 131 CXML_Element *pElmnt = pTag->GetElement(NULL, bsTag); | 131 CXML_Element *pElmnt = pTag->GetElement(CFX_ByteString(), bsTag); |
| 132 if (!pElmnt) { | 132 if (!pElmnt) { |
| 133 continue; | 133 continue; |
| 134 } | 134 } |
| 135 wsStr = pElmnt->GetContent(0); | 135 wsStr = pElmnt->GetContent(0); |
| 136 return wsStr.GetLength(); | 136 return wsStr.GetLength(); |
| 137 } | 137 } |
| 138 } | 138 } |
| 139 return -1; | 139 return -1; |
| 140 } | 140 } |
| 141 CXML_Element* CPDF_Metadata::GetRoot() const | 141 CXML_Element* CPDF_Metadata::GetRoot() const |
| 142 { | 142 { |
| 143 return ((PDFDOC_LPMETADATA)m_pData)->m_pXmlElmnt; | 143 return ((PDFDOC_LPMETADATA)m_pData)->m_pXmlElmnt; |
| 144 } | 144 } |
| 145 CXML_Element* CPDF_Metadata::GetRDF() const | 145 CXML_Element* CPDF_Metadata::GetRDF() const |
| 146 { | 146 { |
| 147 return ((PDFDOC_LPMETADATA)m_pData)->m_pElmntRdf; | 147 return ((PDFDOC_LPMETADATA)m_pData)->m_pElmntRdf; |
| 148 } | 148 } |
| OLD | NEW |