summaryrefslogtreecommitdiff
path: root/xfa/fde/xml
diff options
context:
space:
mode:
Diffstat (limited to 'xfa/fde/xml')
-rw-r--r--xfa/fde/xml/fde_xml_imp.cpp56
-rw-r--r--xfa/fde/xml/fde_xml_imp.h89
2 files changed, 78 insertions, 67 deletions
diff --git a/xfa/fde/xml/fde_xml_imp.cpp b/xfa/fde/xml/fde_xml_imp.cpp
index 446db86950..f630a8995e 100644
--- a/xfa/fde/xml/fde_xml_imp.cpp
+++ b/xfa/fde/xml/fde_xml_imp.cpp
@@ -77,15 +77,17 @@ CFDE_XMLNode::CFDE_XMLNode()
CFDE_XMLNode::~CFDE_XMLNode() {
DeleteChildren();
}
+
void CFDE_XMLNode::DeleteChildren() {
- CFDE_XMLNode *pChild = m_pChild, *pTemp;
- while (pChild != NULL) {
- pTemp = pChild->m_pNext;
- pChild->Release();
- pChild = pTemp;
+ CFDE_XMLNode* pChild = m_pChild;
+ while (pChild) {
+ CFDE_XMLNode* pNext = pChild->m_pNext;
+ delete pChild;
+ pChild = pNext;
}
- m_pChild = NULL;
+ m_pChild = nullptr;
}
+
int32_t CFDE_XMLNode::CountChildNodes() const {
int32_t iCount = 0;
CFDE_XMLNode* pChild = m_pChild;
@@ -510,6 +512,9 @@ CFDE_XMLInstruction::CFDE_XMLInstruction(const CFX_WideString& wsTarget)
: m_wsTarget(wsTarget) {
ASSERT(m_wsTarget.GetLength() > 0);
}
+
+CFDE_XMLInstruction::~CFDE_XMLInstruction() {}
+
CFDE_XMLNode* CFDE_XMLInstruction::Clone(FX_BOOL bRecursive) {
CFDE_XMLInstruction* pClone = new CFDE_XMLInstruction(m_wsTarget);
if (!pClone) {
@@ -827,8 +832,12 @@ void CFDE_XMLElement::SetTextData(const CFX_WideString& wsText) {
}
InsertChildNode(new CFDE_XMLText(wsText));
}
+
CFDE_XMLText::CFDE_XMLText(const CFX_WideString& wsText)
: CFDE_XMLNode(), m_wsText(wsText) {}
+
+CFDE_XMLText::~CFDE_XMLText() {}
+
CFDE_XMLNode* CFDE_XMLText::Clone(FX_BOOL bRecursive) {
CFDE_XMLText* pClone = new CFDE_XMLText(m_wsText);
return pClone;
@@ -836,6 +845,9 @@ CFDE_XMLNode* CFDE_XMLText::Clone(FX_BOOL bRecursive) {
CFDE_XMLCharData::CFDE_XMLCharData(const CFX_WideString& wsCData)
: CFDE_XMLDeclaration(), m_wsCharData(wsCData) {}
+
+CFDE_XMLCharData::~CFDE_XMLCharData() {}
+
CFDE_XMLNode* CFDE_XMLCharData::Clone(FX_BOOL bRecursive) {
CFDE_XMLCharData* pClone = new CFDE_XMLCharData(m_wsCharData);
return pClone;
@@ -860,23 +872,19 @@ void CFDE_XMLDoc::Reset(FX_BOOL bInitRoot) {
m_pRoot->DeleteChildren();
}
} else {
- if (m_pRoot != NULL) {
- m_pRoot->Release();
- m_pRoot = NULL;
- }
+ delete m_pRoot;
+ m_pRoot = nullptr;
}
ReleaseParser();
}
+
void CFDE_XMLDoc::ReleaseParser() {
- if (m_pXMLParser != NULL) {
- m_pXMLParser->Release();
- m_pXMLParser = NULL;
- }
- if (m_pSyntaxParser != NULL) {
- m_pSyntaxParser->Release();
- m_pSyntaxParser = NULL;
- }
+ delete m_pXMLParser;
+ m_pXMLParser = nullptr;
+ delete m_pSyntaxParser;
+ m_pSyntaxParser = nullptr;
}
+
FX_BOOL CFDE_XMLDoc::LoadXML(IFX_Stream* pXMLStream,
int32_t iXMLPlaneSize,
int32_t iTextDataSize,
@@ -919,21 +927,23 @@ FX_BOOL CFDE_XMLDoc::LoadXML(IFX_Stream* pXMLStream,
}
return TRUE;
}
-FX_BOOL CFDE_XMLDoc::LoadXML(CFDE_XMLParser* pXMLParser) {
- if (pXMLParser == NULL) {
+
+FX_BOOL CFDE_XMLDoc::LoadXML(IFDE_XMLParser* pXMLParser) {
+ if (!pXMLParser)
return FALSE;
- }
+
Reset(TRUE);
m_pXMLParser = pXMLParser;
- return m_pXMLParser != NULL;
+ return TRUE;
}
+
int32_t CFDE_XMLDoc::DoLoad(IFX_Pause* pPause) {
if (m_iStatus >= 100) {
return m_iStatus;
}
- ASSERT(m_pXMLParser != NULL);
return m_iStatus = m_pXMLParser->DoParser(pPause);
}
+
void CFDE_XMLDoc::CloseXML() {
ReleaseParser();
}
diff --git a/xfa/fde/xml/fde_xml_imp.h b/xfa/fde/xml/fde_xml_imp.h
index bad970e5be..78e39b6f22 100644
--- a/xfa/fde/xml/fde_xml_imp.h
+++ b/xfa/fde/xml/fde_xml_imp.h
@@ -18,9 +18,9 @@ class CFDE_XMLElement;
class CFDE_XMLText;
class CFDE_XMLDoc;
class CFDE_XMLDOMParser;
-class CFDE_XMLParser;
class CFDE_XMLSAXParser;
class CFDE_XMLSyntaxParser;
+class IFDE_XMLParser;
class CFDE_XMLNode : public CFX_Target {
public:
@@ -40,8 +40,8 @@ class CFDE_XMLNode : public CFX_Target {
};
CFDE_XMLNode();
+ ~CFDE_XMLNode() override;
- virtual void Release() { delete this; }
virtual FDE_XMLNODETYPE GetType() const { return FDE_XMLNODE_Unknown; }
virtual int32_t CountChildNodes() const;
virtual CFDE_XMLNode* GetChildNode(int32_t index) const;
@@ -60,20 +60,22 @@ class CFDE_XMLNode : public CFX_Target {
virtual CFDE_XMLNode* Clone(FX_BOOL bRecursive);
virtual void SaveXMLNode(IFX_Stream* pXMLStream);
- public:
- ~CFDE_XMLNode();
void CloneChildren(CFDE_XMLNode* pClone);
+
CFDE_XMLNode* m_pParent;
CFDE_XMLNode* m_pChild;
CFDE_XMLNode* m_pPrior;
CFDE_XMLNode* m_pNext;
};
+
class CFDE_XMLInstruction : public CFDE_XMLNode {
public:
CFDE_XMLInstruction(const CFX_WideString& wsTarget);
- virtual void Release() { delete this; }
- virtual FDE_XMLNODETYPE GetType() const { return FDE_XMLNODE_Instruction; }
- virtual CFDE_XMLNode* Clone(FX_BOOL bRecursive);
+ ~CFDE_XMLInstruction() override;
+
+ FDE_XMLNODETYPE GetType() const override { return FDE_XMLNODE_Instruction; }
+ CFDE_XMLNode* Clone(FX_BOOL bRecursive) override;
+
virtual void GetTargetName(CFX_WideString& wsTarget) const {
wsTarget = m_wsTarget;
}
@@ -99,18 +101,19 @@ class CFDE_XMLInstruction : public CFDE_XMLNode {
virtual void AppendData(const CFX_WideString& wsData);
virtual void RemoveData(int32_t index);
- public:
- ~CFDE_XMLInstruction() {}
CFX_WideString m_wsTarget;
CFX_WideStringArray m_Attributes;
CFX_WideStringArray m_TargetData;
};
+
class CFDE_XMLElement : public CFDE_XMLNode {
public:
CFDE_XMLElement(const CFX_WideString& wsTag);
- virtual void Release() { delete this; }
- virtual FDE_XMLNODETYPE GetType() const { return FDE_XMLNODE_Element; }
- virtual CFDE_XMLNode* Clone(FX_BOOL bRecursive);
+ ~CFDE_XMLElement() override;
+
+ FDE_XMLNODETYPE GetType() const override { return FDE_XMLNODE_Element; }
+ CFDE_XMLNode* Clone(FX_BOOL bRecursive) override;
+
virtual void GetTagName(CFX_WideString& wsTag) const;
virtual void GetLocalTagName(CFX_WideString& wsTag) const;
virtual void GetNamespacePrefix(CFX_WideString& wsPrefix) const;
@@ -135,35 +138,37 @@ class CFDE_XMLElement : public CFDE_XMLNode {
virtual void GetTextData(CFX_WideString& wsText) const;
virtual void SetTextData(const CFX_WideString& wsText);
- public:
- ~CFDE_XMLElement();
CFX_WideString m_wsTag;
CFX_WideStringArray m_Attributes;
};
+
class CFDE_XMLText : public CFDE_XMLNode {
public:
CFDE_XMLText(const CFX_WideString& wsText);
- virtual void Release() { delete this; }
- virtual FDE_XMLNODETYPE GetType() const { return FDE_XMLNODE_Text; }
- virtual CFDE_XMLNode* Clone(FX_BOOL bRecursive);
+ ~CFDE_XMLText() override;
+
+ FDE_XMLNODETYPE GetType() const override { return FDE_XMLNODE_Text; }
+ CFDE_XMLNode* Clone(FX_BOOL bRecursive) override;
+
virtual void GetText(CFX_WideString& wsText) const { wsText = m_wsText; }
virtual void SetText(const CFX_WideString& wsText) { m_wsText = wsText; }
- public:
- ~CFDE_XMLText() {}
CFX_WideString m_wsText;
};
+
class CFDE_XMLDeclaration : public CFDE_XMLNode {
public:
CFDE_XMLDeclaration() : CFDE_XMLNode() {}
};
+
class CFDE_XMLCharData : public CFDE_XMLDeclaration {
public:
CFDE_XMLCharData(const CFX_WideString& wsCData);
+ ~CFDE_XMLCharData() override;
+
+ FDE_XMLNODETYPE GetType() const override { return FDE_XMLNODE_CharData; }
+ CFDE_XMLNode* Clone(FX_BOOL bRecursive) override;
- virtual void Release() { delete this; }
- virtual FDE_XMLNODETYPE GetType() const { return FDE_XMLNODE_CharData; }
- virtual CFDE_XMLNode* Clone(FX_BOOL bRecursive);
virtual void GetCharData(CFX_WideString& wsCharData) const {
wsCharData = m_wsCharData;
}
@@ -171,21 +176,19 @@ class CFDE_XMLCharData : public CFDE_XMLDeclaration {
m_wsCharData = wsCData;
}
- public:
- ~CFDE_XMLCharData() {}
-
CFX_WideString m_wsCharData;
};
+
class CFDE_XMLDoc : public CFX_Target {
public:
CFDE_XMLDoc();
- ~CFDE_XMLDoc();
- virtual void Release() { delete this; }
+ ~CFDE_XMLDoc() override;
+
virtual FX_BOOL LoadXML(IFX_Stream* pXMLStream,
int32_t iXMLPlaneSize = 8192,
int32_t iTextDataSize = 256,
FDE_XMLREADERHANDLER* pHandler = NULL);
- virtual FX_BOOL LoadXML(CFDE_XMLParser* pXMLParser);
+ virtual FX_BOOL LoadXML(IFDE_XMLParser* pXMLParser);
virtual int32_t DoLoad(IFX_Pause* pPause = NULL);
virtual void CloseXML();
virtual CFDE_XMLNode* GetRoot() const { return m_pRoot; }
@@ -197,27 +200,25 @@ class CFDE_XMLDoc : public CFX_Target {
int32_t m_iStatus;
CFDE_XMLNode* m_pRoot;
CFDE_XMLSyntaxParser* m_pSyntaxParser;
- CFDE_XMLParser* m_pXMLParser;
+ IFDE_XMLParser* m_pXMLParser;
void Reset(FX_BOOL bInitRoot);
void ReleaseParser();
};
typedef CFX_StackTemplate<CFDE_XMLNode*> CFDE_XMLDOMNodeStack;
-class CFDE_XMLParser {
+class IFDE_XMLParser {
public:
- virtual ~CFDE_XMLParser() {}
+ virtual ~IFDE_XMLParser() {}
- virtual void Release() = 0;
virtual int32_t DoParser(IFX_Pause* pPause) = 0;
};
-class CFDE_XMLDOMParser : public CFDE_XMLParser, public CFX_Target {
+class CFDE_XMLDOMParser : public IFDE_XMLParser, public CFX_Target {
public:
CFDE_XMLDOMParser(CFDE_XMLNode* pRoot, CFDE_XMLSyntaxParser* pParser);
- ~CFDE_XMLDOMParser();
+ ~CFDE_XMLDOMParser() override;
- virtual void Release() { delete this; }
- virtual int32_t DoParser(IFX_Pause* pPause);
+ int32_t DoParser(IFX_Pause* pPause) override;
private:
CFDE_XMLSyntaxParser* m_pParser;
@@ -236,14 +237,14 @@ class CFDE_XMLTAG : public CFX_Target {
FDE_XMLNODETYPE eType;
};
typedef CFX_ObjectStackTemplate<CFDE_XMLTAG> CFDE_XMLTagStack;
-class CFDE_XMLSAXParser : public CFDE_XMLParser, public CFX_Target {
+
+class CFDE_XMLSAXParser : public IFDE_XMLParser, public CFX_Target {
public:
CFDE_XMLSAXParser(FDE_XMLREADERHANDLER* pHandler,
CFDE_XMLSyntaxParser* pParser);
- ~CFDE_XMLSAXParser();
+ ~CFDE_XMLSAXParser() override;
- virtual void Release() { delete this; }
- virtual int32_t DoParser(IFX_Pause* pPause);
+ int32_t DoParser(IFX_Pause* pPause) override;
private:
void Push(const CFDE_XMLTAG& xmlTag);
@@ -259,11 +260,11 @@ class CFDE_XMLSAXParser : public CFDE_XMLParser, public CFX_Target {
class CFDE_BlockBuffer : public CFX_Target {
public:
CFDE_BlockBuffer(int32_t iAllocStep = 1024 * 1024);
- ~CFDE_BlockBuffer();
+ ~CFDE_BlockBuffer() override;
FX_BOOL InitBuffer(int32_t iBufferSize = 1024 * 1024);
FX_BOOL IsInitialized() { return m_iBufferSize / m_iAllocStep >= 1; }
- void ReleaseBuffer() { delete this; }
+
FX_WCHAR* GetAvailableBlock(int32_t& iIndexInBlock);
inline int32_t GetAllocStep() const { return m_iAllocStep; }
inline int32_t& GetDataLengthRef() { return m_iDataLength; }
@@ -294,8 +295,8 @@ class CFDE_BlockBuffer : public CFX_Target {
class CFDE_XMLSyntaxParser : public CFX_Target {
public:
CFDE_XMLSyntaxParser();
- ~CFDE_XMLSyntaxParser();
- void Release() { delete this; }
+ ~CFDE_XMLSyntaxParser() override;
+
void Init(IFX_Stream* pStream,
int32_t iXMLPlaneSize,
int32_t iTextDataSize = 256);