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 "xfa/fde/xml/fde_xml_imp.h" | 7 #include "xfa/fde/xml/fde_xml_imp.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 } | 70 } |
71 } | 71 } |
72 return FALSE; | 72 return FALSE; |
73 } | 73 } |
74 | 74 |
75 CFDE_XMLNode::CFDE_XMLNode() | 75 CFDE_XMLNode::CFDE_XMLNode() |
76 : m_pParent(NULL), m_pChild(NULL), m_pPrior(NULL), m_pNext(NULL) {} | 76 : m_pParent(NULL), m_pChild(NULL), m_pPrior(NULL), m_pNext(NULL) {} |
77 CFDE_XMLNode::~CFDE_XMLNode() { | 77 CFDE_XMLNode::~CFDE_XMLNode() { |
78 DeleteChildren(); | 78 DeleteChildren(); |
79 } | 79 } |
| 80 |
80 void CFDE_XMLNode::DeleteChildren() { | 81 void CFDE_XMLNode::DeleteChildren() { |
81 CFDE_XMLNode *pChild = m_pChild, *pTemp; | 82 CFDE_XMLNode* pChild = m_pChild; |
82 while (pChild != NULL) { | 83 while (pChild) { |
83 pTemp = pChild->m_pNext; | 84 CFDE_XMLNode* pNext = pChild->m_pNext; |
84 pChild->Release(); | 85 delete pChild; |
85 pChild = pTemp; | 86 pChild = pNext; |
86 } | 87 } |
87 m_pChild = NULL; | 88 m_pChild = nullptr; |
88 } | 89 } |
| 90 |
89 int32_t CFDE_XMLNode::CountChildNodes() const { | 91 int32_t CFDE_XMLNode::CountChildNodes() const { |
90 int32_t iCount = 0; | 92 int32_t iCount = 0; |
91 CFDE_XMLNode* pChild = m_pChild; | 93 CFDE_XMLNode* pChild = m_pChild; |
92 while (pChild != NULL) { | 94 while (pChild != NULL) { |
93 iCount++; | 95 iCount++; |
94 pChild = pChild->m_pNext; | 96 pChild = pChild->m_pNext; |
95 } | 97 } |
96 return iCount; | 98 return iCount; |
97 } | 99 } |
98 CFDE_XMLNode* CFDE_XMLNode::GetChildNode(int32_t index) const { | 100 CFDE_XMLNode* CFDE_XMLNode::GetChildNode(int32_t index) const { |
(...skipping 754 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
853 void CFDE_XMLDoc::Reset(FX_BOOL bInitRoot) { | 855 void CFDE_XMLDoc::Reset(FX_BOOL bInitRoot) { |
854 m_iStatus = 0; | 856 m_iStatus = 0; |
855 m_pStream = NULL; | 857 m_pStream = NULL; |
856 if (bInitRoot) { | 858 if (bInitRoot) { |
857 if (m_pRoot == NULL) { | 859 if (m_pRoot == NULL) { |
858 m_pRoot = new CFDE_XMLNode; | 860 m_pRoot = new CFDE_XMLNode; |
859 } else { | 861 } else { |
860 m_pRoot->DeleteChildren(); | 862 m_pRoot->DeleteChildren(); |
861 } | 863 } |
862 } else { | 864 } else { |
863 if (m_pRoot != NULL) { | 865 delete m_pRoot; |
864 m_pRoot->Release(); | 866 m_pRoot = nullptr; |
865 m_pRoot = NULL; | |
866 } | |
867 } | 867 } |
868 ReleaseParser(); | 868 ReleaseParser(); |
869 } | 869 } |
| 870 |
870 void CFDE_XMLDoc::ReleaseParser() { | 871 void CFDE_XMLDoc::ReleaseParser() { |
871 if (m_pXMLParser != NULL) { | 872 delete m_pXMLParser; |
872 m_pXMLParser->Release(); | 873 m_pXMLParser = nullptr; |
873 m_pXMLParser = NULL; | 874 delete m_pSyntaxParser; |
874 } | 875 m_pSyntaxParser = nullptr; |
875 if (m_pSyntaxParser != NULL) { | |
876 m_pSyntaxParser->Release(); | |
877 m_pSyntaxParser = NULL; | |
878 } | |
879 } | 876 } |
| 877 |
880 FX_BOOL CFDE_XMLDoc::LoadXML(IFX_Stream* pXMLStream, | 878 FX_BOOL CFDE_XMLDoc::LoadXML(IFX_Stream* pXMLStream, |
881 int32_t iXMLPlaneSize, | 879 int32_t iXMLPlaneSize, |
882 int32_t iTextDataSize, | 880 int32_t iTextDataSize, |
883 FDE_XMLREADERHANDLER* pHandler) { | 881 FDE_XMLREADERHANDLER* pHandler) { |
884 if (pXMLStream == NULL) { | 882 if (pXMLStream == NULL) { |
885 return FALSE; | 883 return FALSE; |
886 } | 884 } |
887 Reset(TRUE); | 885 Reset(TRUE); |
888 iXMLPlaneSize = iXMLPlaneSize / 1024; | 886 iXMLPlaneSize = iXMLPlaneSize / 1024; |
889 if (iXMLPlaneSize < 1) { | 887 if (iXMLPlaneSize < 1) { |
(...skipping 1183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2073 m_BlockBuffer.DeleteTextChars(m_iDataLength - m_iEntityStart, FALSE); | 2071 m_BlockBuffer.DeleteTextChars(m_iDataLength - m_iEntityStart, FALSE); |
2074 m_pCurrentBlock = m_BlockBuffer.GetAvailableBlock(m_iIndexInBlock); | 2072 m_pCurrentBlock = m_BlockBuffer.GetAvailableBlock(m_iIndexInBlock); |
2075 m_iEntityStart = -1; | 2073 m_iEntityStart = -1; |
2076 } else { | 2074 } else { |
2077 if (m_iEntityStart < 0 && ch == L'&') { | 2075 if (m_iEntityStart < 0 && ch == L'&') { |
2078 m_iEntityStart = m_iDataLength - 1; | 2076 m_iEntityStart = m_iDataLength - 1; |
2079 } | 2077 } |
2080 } | 2078 } |
2081 m_pStart++; | 2079 m_pStart++; |
2082 } | 2080 } |
OLD | NEW |