summaryrefslogtreecommitdiff
path: root/xfa/fde
diff options
context:
space:
mode:
Diffstat (limited to 'xfa/fde')
-rw-r--r--xfa/fde/xml/fde_xml.h162
-rw-r--r--xfa/fde/xml/fde_xml_imp.cpp80
-rw-r--r--xfa/fde/xml/fde_xml_imp.h87
3 files changed, 88 insertions, 241 deletions
diff --git a/xfa/fde/xml/fde_xml.h b/xfa/fde/xml/fde_xml.h
index cb76ac3b8a..9d0a869524 100644
--- a/xfa/fde/xml/fde_xml.h
+++ b/xfa/fde/xml/fde_xml.h
@@ -10,15 +10,6 @@
#include "xfa/fgas/crt/fgas_stream.h"
#include "xfa/fgas/crt/fgas_utils.h"
-class IFDE_XMLNode;
-class IFDE_XMLInstruction;
-class IFDE_XMLDeclaration;
-class IFDE_XMLElement;
-class IFDE_XMLText;
-class IFDE_XMLDoc;
-class IFDE_XMLParser;
-class IFDE_XMLSyntaxParser;
-
enum FDE_XMLNODETYPE {
FDE_XMLNODE_Unknown = 0,
FDE_XMLNODE_Instruction,
@@ -37,115 +28,6 @@ FX_BOOL FDE_IsXMLValidChar(FX_WCHAR ch);
FX_BOOL FDE_IsXMLWhiteSpace(FX_WCHAR ch);
FX_BOOL FDE_IsXMLNameChar(FX_WCHAR ch, FX_BOOL bFirstChar);
-class IFDE_XMLNode {
- public:
- virtual ~IFDE_XMLNode() {}
- virtual void Release() = 0;
- virtual FDE_XMLNODETYPE GetType() const = 0;
- virtual int32_t CountChildNodes() const = 0;
- virtual IFDE_XMLNode* GetChildNode(int32_t index) const = 0;
- virtual int32_t GetChildNodeIndex(IFDE_XMLNode* pNode) const = 0;
- virtual IFDE_XMLNode* GetPath(const FX_WCHAR* pPath,
- int32_t iLength = -1,
- FX_BOOL bQualifiedName = TRUE) const = 0;
- virtual int32_t InsertChildNode(IFDE_XMLNode* pNode, int32_t index = -1) = 0;
- virtual void RemoveChildNode(IFDE_XMLNode* pNode) = 0;
- virtual void DeleteChildren() = 0;
- enum NodeItem {
- Root = 0,
- Parent,
- FirstSibling,
- PriorSibling,
- NextSibling,
- LastSibling,
- FirstNeighbor,
- PriorNeighbor,
- NextNeighbor,
- LastNeighbor,
- FirstChild,
- LastChild
- };
- virtual IFDE_XMLNode* GetNodeItem(NodeItem eItem) const = 0;
- virtual int32_t GetNodeLevel() const = 0;
- virtual FX_BOOL InsertNodeItem(IFDE_XMLNode::NodeItem eItem,
- IFDE_XMLNode* pNode) = 0;
- virtual IFDE_XMLNode* RemoveNodeItem(IFDE_XMLNode::NodeItem eItem) = 0;
- virtual IFDE_XMLNode* Clone(FX_BOOL bRecursive) = 0;
- virtual void SaveXMLNode(IFX_Stream* pXMLStream) = 0;
-};
-class IFDE_XMLInstruction : public IFDE_XMLNode {
- public:
- static IFDE_XMLInstruction* Create(const CFX_WideString& wsTarget);
- virtual void GetTargetName(CFX_WideString& wsTarget) const = 0;
- virtual int32_t CountAttributes() const = 0;
- virtual FX_BOOL GetAttribute(int32_t index,
- CFX_WideString& wsAttriName,
- CFX_WideString& wsAttriValue) const = 0;
- virtual FX_BOOL HasAttribute(const FX_WCHAR* pwsAttriName) const = 0;
- virtual void GetString(const FX_WCHAR* pwsAttriName,
- CFX_WideString& wsAttriValue,
- const FX_WCHAR* pwsDefValue = NULL) const = 0;
- virtual void SetString(const CFX_WideString& wsAttriName,
- const CFX_WideString& wsAttriValue) = 0;
- virtual int32_t GetInteger(const FX_WCHAR* pwsAttriName,
- int32_t iDefValue = 0) const = 0;
- virtual void SetInteger(const FX_WCHAR* pwsAttriName,
- int32_t iAttriValue) = 0;
- virtual FX_FLOAT GetFloat(const FX_WCHAR* pwsAttriName,
- FX_FLOAT fDefValue = 0) const = 0;
- virtual void SetFloat(const FX_WCHAR* pwsAttriName, FX_FLOAT fAttriValue) = 0;
- virtual void RemoveAttribute(const FX_WCHAR* pwsAttriName) = 0;
- virtual int32_t CountData() const = 0;
- virtual FX_BOOL GetData(int32_t index, CFX_WideString& wsData) const = 0;
- virtual void AppendData(const CFX_WideString& wsData) = 0;
- virtual void RemoveData(int32_t index) = 0;
-};
-class IFDE_XMLElement : public IFDE_XMLNode {
- public:
- static IFDE_XMLElement* Create(const CFX_WideString& wsTag);
- virtual void GetTagName(CFX_WideString& wsTag) const = 0;
- virtual void GetLocalTagName(CFX_WideString& wsTag) const = 0;
- virtual void GetNamespacePrefix(CFX_WideString& wsPrefix) const = 0;
- virtual void GetNamespaceURI(CFX_WideString& wsNamespace) const = 0;
- virtual int32_t CountAttributes() const = 0;
- virtual FX_BOOL GetAttribute(int32_t index,
- CFX_WideString& wsAttriName,
- CFX_WideString& wsAttriValue) const = 0;
- virtual FX_BOOL HasAttribute(const FX_WCHAR* pwsAttriName) const = 0;
- virtual void GetString(const FX_WCHAR* pwsAttriName,
- CFX_WideString& wsAttriValue,
- const FX_WCHAR* pwsDefValue = NULL) const = 0;
- virtual void SetString(const CFX_WideString& wsAttriName,
- const CFX_WideString& wsAttriValue) = 0;
- virtual int32_t GetInteger(const FX_WCHAR* pwsAttriName,
- int32_t iDefValue = 0) const = 0;
- virtual void SetInteger(const FX_WCHAR* pwsAttriName,
- int32_t iAttriValue) = 0;
- virtual FX_FLOAT GetFloat(const FX_WCHAR* pwsAttriName,
- FX_FLOAT fDefValue = 0) const = 0;
- virtual void SetFloat(const FX_WCHAR* pwsAttriName, FX_FLOAT fAttriValue) = 0;
- virtual void RemoveAttribute(const FX_WCHAR* pwsAttriName) = 0;
- virtual void GetTextData(CFX_WideString& wsText) const = 0;
- virtual void SetTextData(const CFX_WideString& wsText) = 0;
-};
-class IFDE_XMLText : public IFDE_XMLNode {
- public:
- static IFDE_XMLText* Create(const CFX_WideString& wsText);
- virtual void GetText(CFX_WideString& wsText) const = 0;
- virtual void SetText(const CFX_WideString& wsText) = 0;
-};
-class IFDE_XMLDeclaration : public IFDE_XMLNode {
- public:
-};
-class IFDE_XMLCharData : public IFDE_XMLDeclaration {
- public:
- static IFDE_XMLCharData* Create(const CFX_WideString& wsCData);
- virtual ~IFDE_XMLCharData() {}
-
- virtual void GetCharData(CFX_WideString& wsCData) const = 0;
- virtual void SetCharData(const CFX_WideString& wsCData) = 0;
-};
-
struct FDE_XMLREADERHANDLER {
void* pData;
void (*OnTagEnter)(FDE_XMLREADERHANDLER* pThis,
@@ -163,29 +45,6 @@ struct FDE_XMLREADERHANDLER {
const CFX_WideString& wsValue);
};
-class IFDE_XMLDoc {
- public:
- static IFDE_XMLDoc* Create();
- virtual ~IFDE_XMLDoc() {}
- virtual void Release() = 0;
- virtual FX_BOOL LoadXML(IFX_Stream* pXMLStream,
- int32_t iXMLPlaneSize = 8192,
- int32_t iTextDataSize = 256,
- FDE_XMLREADERHANDLER* pHandler = NULL) = 0;
- virtual FX_BOOL LoadXML(IFDE_XMLParser* pXMLParser) = 0;
- virtual int32_t DoLoad(IFX_Pause* pPause = NULL) = 0;
- virtual void CloseXML() = 0;
- virtual IFDE_XMLNode* GetRoot() const = 0;
- virtual void SaveXML(IFX_Stream* pXMLStream = NULL,
- FX_BOOL bSaveBOM = TRUE) = 0;
- virtual void SaveXMLNode(IFX_Stream* pXMLStream, IFDE_XMLNode* pNode) = 0;
-};
-class IFDE_XMLParser {
- public:
- virtual ~IFDE_XMLParser() {}
- virtual void Release() = 0;
- virtual int32_t DoParser(IFX_Pause* pPause) = 0;
-};
#define FDE_XMLSYNTAXSTATUS_None 0x00
#define FDE_XMLSYNTAXSTATUS_InstructionOpen 0x01
#define FDE_XMLSYNTAXSTATUS_InstructionClose 0x02
@@ -201,26 +60,5 @@ class IFDE_XMLParser {
#define FDE_XMLSYNTAXSTATUS_TargetData 0x0C
#define FDE_XMLSYNTAXSTATUS_Error 0xFE
#define FDE_XMLSYNTAXSTATUS_EOS 0xFF
-class IFDE_XMLSyntaxParser {
- public:
- static IFDE_XMLSyntaxParser* Create();
- virtual ~IFDE_XMLSyntaxParser() {}
- virtual void Release() = 0;
- virtual void Init(IFX_Stream* pStream,
- int32_t iXMLPlaneSize,
- int32_t iTextDataSize = 256) = 0;
- virtual uint32_t DoSyntaxParse() = 0;
- virtual int32_t GetStatus() const = 0;
- virtual int32_t GetCurrentPos() const = 0;
- virtual FX_FILESIZE GetCurrentBinaryPos() const = 0;
- virtual int32_t GetCurrentNodeNumber() const = 0;
- virtual int32_t GetLastNodeNumber() const = 0;
- virtual void GetTargetName(CFX_WideString& wsTarget) const = 0;
- virtual void GetTagName(CFX_WideString& wsTag) const = 0;
- virtual void GetAttributeName(CFX_WideString& wsAttriName) const = 0;
- virtual void GetAttributeValue(CFX_WideString& wsAttriValue) const = 0;
- virtual void GetTextData(CFX_WideString& wsText) const = 0;
- virtual void GetTargetData(CFX_WideString& wsData) const = 0;
-};
#endif // XFA_FDE_XML_FDE_XML_H_
diff --git a/xfa/fde/xml/fde_xml_imp.cpp b/xfa/fde/xml/fde_xml_imp.cpp
index fef11a9080..ef5a7e4ee3 100644
--- a/xfa/fde/xml/fde_xml_imp.cpp
+++ b/xfa/fde/xml/fde_xml_imp.cpp
@@ -143,7 +143,7 @@ CFDE_XMLNode* CFDE_XMLNode::GetPath(const FX_WCHAR* pPath,
iLength -= pStart - pPath;
CFDE_XMLNode* pFind = NULL;
if (csPath.GetLength() < 1) {
- pFind = GetNodeItem(IFDE_XMLNode::Root);
+ pFind = GetNodeItem(CFDE_XMLNode::Root);
} else if (csPath.Compare(L"..") == 0) {
pFind = m_pParent;
} else if (csPath.Compare(L".") == 0) {
@@ -219,43 +219,43 @@ void CFDE_XMLNode::RemoveChildNode(CFDE_XMLNode* pNode) {
pNode->m_pNext = NULL;
pNode->m_pPrior = NULL;
}
-CFDE_XMLNode* CFDE_XMLNode::GetNodeItem(IFDE_XMLNode::NodeItem eItem) const {
+CFDE_XMLNode* CFDE_XMLNode::GetNodeItem(CFDE_XMLNode::NodeItem eItem) const {
switch (eItem) {
- case IFDE_XMLNode::Root: {
+ case CFDE_XMLNode::Root: {
CFDE_XMLNode* pParent = (CFDE_XMLNode*)this;
while (pParent->m_pParent != NULL) {
pParent = pParent->m_pParent;
}
return pParent;
}
- case IFDE_XMLNode::Parent:
+ case CFDE_XMLNode::Parent:
return m_pParent;
- case IFDE_XMLNode::FirstSibling: {
+ case CFDE_XMLNode::FirstSibling: {
CFDE_XMLNode* pItem = (CFDE_XMLNode*)this;
while (pItem->m_pPrior != NULL) {
pItem = pItem->m_pPrior;
}
return pItem == (CFDE_XMLNode*)this ? NULL : pItem;
}
- case IFDE_XMLNode::PriorSibling:
+ case CFDE_XMLNode::PriorSibling:
return m_pPrior;
- case IFDE_XMLNode::NextSibling:
+ case CFDE_XMLNode::NextSibling:
return m_pNext;
- case IFDE_XMLNode::LastSibling: {
+ case CFDE_XMLNode::LastSibling: {
CFDE_XMLNode* pItem = (CFDE_XMLNode*)this;
while (pItem->m_pNext != NULL) {
pItem = pItem->m_pNext;
}
return pItem == (CFDE_XMLNode*)this ? NULL : pItem;
}
- case IFDE_XMLNode::FirstNeighbor: {
+ case CFDE_XMLNode::FirstNeighbor: {
CFDE_XMLNode* pParent = (CFDE_XMLNode*)this;
while (pParent->m_pParent != NULL) {
pParent = pParent->m_pParent;
}
return pParent == (CFDE_XMLNode*)this ? NULL : pParent;
}
- case IFDE_XMLNode::PriorNeighbor: {
+ case CFDE_XMLNode::PriorNeighbor: {
if (m_pPrior == NULL) {
return m_pParent;
}
@@ -268,7 +268,7 @@ CFDE_XMLNode* CFDE_XMLNode::GetNodeItem(IFDE_XMLNode::NodeItem eItem) const {
}
return pItem;
}
- case IFDE_XMLNode::NextNeighbor: {
+ case CFDE_XMLNode::NextNeighbor: {
if (m_pChild != NULL) {
return m_pChild;
}
@@ -284,7 +284,7 @@ CFDE_XMLNode* CFDE_XMLNode::GetNodeItem(IFDE_XMLNode::NodeItem eItem) const {
}
return NULL;
}
- case IFDE_XMLNode::LastNeighbor: {
+ case CFDE_XMLNode::LastNeighbor: {
CFDE_XMLNode* pItem = (CFDE_XMLNode*)this;
while (pItem->m_pParent != NULL) {
pItem = pItem->m_pParent;
@@ -300,9 +300,9 @@ CFDE_XMLNode* CFDE_XMLNode::GetNodeItem(IFDE_XMLNode::NodeItem eItem) const {
}
return pItem == (CFDE_XMLNode*)this ? NULL : pItem;
}
- case IFDE_XMLNode::FirstChild:
+ case CFDE_XMLNode::FirstChild:
return m_pChild;
- case IFDE_XMLNode::LastChild: {
+ case CFDE_XMLNode::LastChild: {
if (m_pChild == NULL) {
return NULL;
}
@@ -325,11 +325,11 @@ int32_t CFDE_XMLNode::GetNodeLevel() const {
}
return iLevel;
}
-FX_BOOL CFDE_XMLNode::InsertNodeItem(IFDE_XMLNode::NodeItem eItem,
+FX_BOOL CFDE_XMLNode::InsertNodeItem(CFDE_XMLNode::NodeItem eItem,
CFDE_XMLNode* pNode) {
FXSYS_assert(pNode != NULL);
switch (eItem) {
- case IFDE_XMLNode::NextSibling: {
+ case CFDE_XMLNode::NextSibling: {
pNode->m_pParent = m_pParent;
pNode->m_pNext = m_pNext;
pNode->m_pPrior = this;
@@ -339,7 +339,7 @@ FX_BOOL CFDE_XMLNode::InsertNodeItem(IFDE_XMLNode::NodeItem eItem,
m_pNext = pNode;
return TRUE;
}
- case IFDE_XMLNode::PriorSibling: {
+ case CFDE_XMLNode::PriorSibling: {
pNode->m_pParent = m_pParent;
pNode->m_pNext = this;
pNode->m_pPrior = m_pPrior;
@@ -356,10 +356,10 @@ FX_BOOL CFDE_XMLNode::InsertNodeItem(IFDE_XMLNode::NodeItem eItem,
}
return FALSE;
}
-CFDE_XMLNode* CFDE_XMLNode::RemoveNodeItem(IFDE_XMLNode::NodeItem eItem) {
+CFDE_XMLNode* CFDE_XMLNode::RemoveNodeItem(CFDE_XMLNode::NodeItem eItem) {
CFDE_XMLNode* pNode = NULL;
switch (eItem) {
- case IFDE_XMLNode::NextSibling:
+ case CFDE_XMLNode::NextSibling:
if (m_pNext) {
pNode = m_pNext;
m_pNext = pNode->m_pNext;
@@ -500,15 +500,12 @@ void CFDE_XMLNode::CloneChildren(CFDE_XMLNode* pClone) {
pNext = pNext->m_pNext;
while (pNext) {
CFDE_XMLNode* pChild = pNext->Clone(TRUE);
- pCloneNext->InsertNodeItem(IFDE_XMLNode::NextSibling, pChild);
+ pCloneNext->InsertNodeItem(CFDE_XMLNode::NextSibling, pChild);
pCloneNext = pChild;
pNext = pNext->m_pNext;
}
}
-IFDE_XMLInstruction* IFDE_XMLInstruction::Create(
- const CFX_WideString& wsTarget) {
- return (IFDE_XMLInstruction*)new CFDE_XMLInstruction(wsTarget);
-}
+
CFDE_XMLInstruction::CFDE_XMLInstruction(const CFX_WideString& wsTarget)
: m_wsTarget(wsTarget) {
FXSYS_assert(m_wsTarget.GetLength() > 0);
@@ -637,9 +634,7 @@ void CFDE_XMLInstruction::AppendData(const CFX_WideString& wsData) {
void CFDE_XMLInstruction::RemoveData(int32_t index) {
m_TargetData.RemoveAt(index);
}
-IFDE_XMLElement* IFDE_XMLElement::Create(const CFX_WideString& wsTag) {
- return (IFDE_XMLElement*)new CFDE_XMLElement(wsTag);
-}
+
CFDE_XMLElement::CFDE_XMLElement(const CFX_WideString& wsTag)
: CFDE_XMLNode(), m_wsTag(wsTag), m_Attributes() {
FXSYS_assert(m_wsTag.GetLength() > 0);
@@ -706,7 +701,7 @@ void CFDE_XMLElement::GetNamespaceURI(CFX_WideString& wsNamespace) const {
}
CFDE_XMLElement* pElement = (CFDE_XMLElement*)pNode;
if (!pElement->HasAttribute(wsAttri)) {
- pNode = pNode->GetNodeItem(IFDE_XMLNode::Parent);
+ pNode = pNode->GetNodeItem(CFDE_XMLNode::Parent);
continue;
}
pElement->GetString(wsAttri, wsNamespace);
@@ -832,27 +827,20 @@ void CFDE_XMLElement::SetTextData(const CFX_WideString& wsText) {
}
InsertChildNode(new CFDE_XMLText(wsText));
}
-IFDE_XMLText* IFDE_XMLText::Create(const CFX_WideString& wsText) {
- return (IFDE_XMLText*)new CFDE_XMLText(wsText);
-}
CFDE_XMLText::CFDE_XMLText(const CFX_WideString& wsText)
: CFDE_XMLNode(), m_wsText(wsText) {}
CFDE_XMLNode* CFDE_XMLText::Clone(FX_BOOL bRecursive) {
CFDE_XMLText* pClone = new CFDE_XMLText(m_wsText);
return pClone;
}
-IFDE_XMLCharData* IFDE_XMLCharData::Create(const CFX_WideString& wsCData) {
- return (IFDE_XMLCharData*)new CFDE_XMLCharData(wsCData);
-}
+
CFDE_XMLCharData::CFDE_XMLCharData(const CFX_WideString& wsCData)
: CFDE_XMLDeclaration(), m_wsCharData(wsCData) {}
CFDE_XMLNode* CFDE_XMLCharData::Clone(FX_BOOL bRecursive) {
CFDE_XMLCharData* pClone = new CFDE_XMLCharData(m_wsCharData);
return pClone;
}
-IFDE_XMLDoc* IFDE_XMLDoc::Create() {
- return (IFDE_XMLDoc*)new CFDE_XMLDoc;
-}
+
CFDE_XMLDoc::CFDE_XMLDoc()
: m_pRoot(NULL), m_pSyntaxParser(NULL), m_pXMLParser(NULL) {
Reset(TRUE);
@@ -919,7 +907,7 @@ FX_BOOL CFDE_XMLDoc::LoadXML(IFX_Stream* pXMLStream,
wCodePage != FX_CODEPAGE_UTF8) {
m_pStream->SetCodePage(FX_CODEPAGE_UTF8);
}
- m_pSyntaxParser = IFDE_XMLSyntaxParser::Create();
+ m_pSyntaxParser = new CFDE_XMLSyntaxParser;
if (m_pSyntaxParser == NULL) {
return FALSE;
}
@@ -931,7 +919,7 @@ FX_BOOL CFDE_XMLDoc::LoadXML(IFX_Stream* pXMLStream,
}
return TRUE;
}
-FX_BOOL CFDE_XMLDoc::LoadXML(IFDE_XMLParser* pXMLParser) {
+FX_BOOL CFDE_XMLDoc::LoadXML(CFDE_XMLParser* pXMLParser) {
if (pXMLParser == NULL) {
return FALSE;
}
@@ -949,7 +937,7 @@ int32_t CFDE_XMLDoc::DoLoad(IFX_Pause* pPause) {
void CFDE_XMLDoc::CloseXML() {
ReleaseParser();
}
-void CFDE_XMLDoc::SaveXMLNode(IFX_Stream* pXMLStream, IFDE_XMLNode* pINode) {
+void CFDE_XMLDoc::SaveXMLNode(IFX_Stream* pXMLStream, CFDE_XMLNode* pINode) {
CFDE_XMLNode* pNode = (CFDE_XMLNode*)pINode;
FXSYS_assert(pXMLStream != NULL && pNode != NULL);
switch (pNode->GetType()) {
@@ -1030,7 +1018,7 @@ void CFDE_XMLDoc::SaveXMLNode(IFX_Stream* pXMLStream, IFDE_XMLNode* pINode) {
pXMLStream->WriteString(ws, ws.GetLength());
CFDE_XMLNode* pChild = pNode->m_pChild;
while (pChild != NULL) {
- SaveXMLNode(pXMLStream, (IFDE_XMLNode*)pChild);
+ SaveXMLNode(pXMLStream, static_cast<CFDE_XMLNode*>(pChild));
pChild = pChild->m_pNext;
}
ws = L"</";
@@ -1078,7 +1066,7 @@ void CFDE_XMLDoc::SaveXML(IFX_Stream* pXMLStream, FX_BOOL bSaveBOM) {
}
CFDE_XMLNode* pNode = m_pRoot->m_pChild;
while (pNode != NULL) {
- SaveXMLNode(pXMLStream, (IFDE_XMLNode*)pNode);
+ SaveXMLNode(pXMLStream, static_cast<CFDE_XMLNode*>(pNode));
pNode = pNode->m_pNext;
}
if (pXMLStream == m_pStream) {
@@ -1087,7 +1075,7 @@ void CFDE_XMLDoc::SaveXML(IFX_Stream* pXMLStream, FX_BOOL bSaveBOM) {
}
}
CFDE_XMLDOMParser::CFDE_XMLDOMParser(CFDE_XMLNode* pRoot,
- IFDE_XMLSyntaxParser* pParser)
+ CFDE_XMLSyntaxParser* pParser)
: m_pParser(pParser),
m_pParent(pRoot),
m_pChild(NULL),
@@ -1207,7 +1195,7 @@ int32_t CFDE_XMLDOMParser::DoParser(IFX_Pause* pPause) {
return m_pParser->GetStatus();
}
CFDE_XMLSAXParser::CFDE_XMLSAXParser(FDE_XMLREADERHANDLER* pHandler,
- IFDE_XMLSyntaxParser* pParser)
+ CFDE_XMLSyntaxParser* pParser)
: m_pHandler(pHandler),
m_pParser(pParser),
m_TagStack(16),
@@ -1448,10 +1436,6 @@ void CFDE_BlockBuffer::ClearBuffer() {
m_BlockArray.RemoveAll();
}
-IFDE_XMLSyntaxParser* IFDE_XMLSyntaxParser::Create() {
- return new CFDE_XMLSyntaxParser;
-}
-
CFDE_XMLSyntaxParser::CFDE_XMLSyntaxParser()
: m_pStream(nullptr),
m_iXMLPlaneSize(-1),
diff --git a/xfa/fde/xml/fde_xml_imp.h b/xfa/fde/xml/fde_xml_imp.h
index 7d74ff62bf..a4361bdfea 100644
--- a/xfa/fde/xml/fde_xml_imp.h
+++ b/xfa/fde/xml/fde_xml_imp.h
@@ -17,14 +17,30 @@ class CFDE_XMLInstruction;
class CFDE_XMLElement;
class CFDE_XMLText;
class CFDE_XMLDoc;
-class IFDE_XMLParser;
class CFDE_XMLDOMParser;
+class CFDE_XMLParser;
class CFDE_XMLSAXParser;
class CFDE_XMLSyntaxParser;
class CFDE_XMLNode : public CFX_Target {
public:
+ enum NodeItem {
+ Root = 0,
+ Parent,
+ FirstSibling,
+ PriorSibling,
+ NextSibling,
+ LastSibling,
+ FirstNeighbor,
+ PriorNeighbor,
+ NextNeighbor,
+ LastNeighbor,
+ FirstChild,
+ LastChild
+ };
+
CFDE_XMLNode();
+
virtual void Release() { delete this; }
virtual FDE_XMLNODETYPE GetType() const { return FDE_XMLNODE_Unknown; }
virtual int32_t CountChildNodes() const;
@@ -36,11 +52,11 @@ class CFDE_XMLNode : public CFX_Target {
virtual int32_t InsertChildNode(CFDE_XMLNode* pNode, int32_t index = -1);
virtual void RemoveChildNode(CFDE_XMLNode* pNode);
virtual void DeleteChildren();
- virtual CFDE_XMLNode* GetNodeItem(IFDE_XMLNode::NodeItem eItem) const;
+ virtual CFDE_XMLNode* GetNodeItem(CFDE_XMLNode::NodeItem eItem) const;
virtual int32_t GetNodeLevel() const;
- virtual FX_BOOL InsertNodeItem(IFDE_XMLNode::NodeItem eItem,
+ virtual FX_BOOL InsertNodeItem(CFDE_XMLNode::NodeItem eItem,
CFDE_XMLNode* pNode);
- virtual CFDE_XMLNode* RemoveNodeItem(IFDE_XMLNode::NodeItem eItem);
+ virtual CFDE_XMLNode* RemoveNodeItem(CFDE_XMLNode::NodeItem eItem);
virtual CFDE_XMLNode* Clone(FX_BOOL bRecursive);
virtual void SaveXMLNode(IFX_Stream* pXMLStream);
@@ -169,33 +185,42 @@ class CFDE_XMLDoc : public CFX_Target {
int32_t iXMLPlaneSize = 8192,
int32_t iTextDataSize = 256,
FDE_XMLREADERHANDLER* pHandler = NULL);
- virtual FX_BOOL LoadXML(IFDE_XMLParser* pXMLParser);
+ virtual FX_BOOL LoadXML(CFDE_XMLParser* pXMLParser);
virtual int32_t DoLoad(IFX_Pause* pPause = NULL);
virtual void CloseXML();
virtual CFDE_XMLNode* GetRoot() const { return m_pRoot; }
virtual void SaveXML(IFX_Stream* pXMLStream = NULL, FX_BOOL bSaveBOM = TRUE);
- virtual void SaveXMLNode(IFX_Stream* pXMLStream, IFDE_XMLNode* pNode);
+ virtual void SaveXMLNode(IFX_Stream* pXMLStream, CFDE_XMLNode* pNode);
protected:
IFX_Stream* m_pStream;
int32_t m_iStatus;
CFDE_XMLNode* m_pRoot;
- IFDE_XMLSyntaxParser* m_pSyntaxParser;
- IFDE_XMLParser* m_pXMLParser;
+ CFDE_XMLSyntaxParser* m_pSyntaxParser;
+ CFDE_XMLParser* m_pXMLParser;
void Reset(FX_BOOL bInitRoot);
void ReleaseParser();
};
typedef CFX_StackTemplate<CFDE_XMLNode*> CFDE_XMLDOMNodeStack;
-class CFDE_XMLDOMParser : public IFDE_XMLParser, public CFX_Target {
+
+class CFDE_XMLParser {
public:
- CFDE_XMLDOMParser(CFDE_XMLNode* pRoot, IFDE_XMLSyntaxParser* pParser);
+ virtual ~CFDE_XMLParser() {}
+
+ virtual void Release() = 0;
+ virtual int32_t DoParser(IFX_Pause* pPause) = 0;
+};
+
+class CFDE_XMLDOMParser : public CFDE_XMLParser, public CFX_Target {
+ public:
+ CFDE_XMLDOMParser(CFDE_XMLNode* pRoot, CFDE_XMLSyntaxParser* pParser);
~CFDE_XMLDOMParser();
virtual void Release() { delete this; }
virtual int32_t DoParser(IFX_Pause* pPause);
private:
- IFDE_XMLSyntaxParser* m_pParser;
+ CFDE_XMLSyntaxParser* m_pParser;
CFDE_XMLNode* m_pParent;
CFDE_XMLNode* m_pChild;
CFDE_XMLDOMNodeStack m_NodeStack;
@@ -211,10 +236,10 @@ class CFDE_XMLTAG : public CFX_Target {
FDE_XMLNODETYPE eType;
};
typedef CFX_ObjectStackTemplate<CFDE_XMLTAG> CFDE_XMLTagStack;
-class CFDE_XMLSAXParser : public IFDE_XMLParser, public CFX_Target {
+class CFDE_XMLSAXParser : public CFDE_XMLParser, public CFX_Target {
public:
CFDE_XMLSAXParser(FDE_XMLREADERHANDLER* pHandler,
- IFDE_XMLSyntaxParser* pParser);
+ CFDE_XMLSyntaxParser* pParser);
~CFDE_XMLSAXParser();
virtual void Release() { delete this; }
@@ -224,7 +249,7 @@ class CFDE_XMLSAXParser : public IFDE_XMLParser, public CFX_Target {
void Push(const CFDE_XMLTAG& xmlTag);
void Pop();
FDE_XMLREADERHANDLER* m_pHandler;
- IFDE_XMLSyntaxParser* m_pParser;
+ CFDE_XMLSyntaxParser* m_pParser;
CFDE_XMLTagStack m_TagStack;
CFDE_XMLTAG* m_pTagTop;
CFX_WideString m_ws1;
@@ -285,39 +310,39 @@ class CFDE_BlockBuffer : public CFX_Target {
#define FDE_XMLSYNTAXMODE_SkipComment 16
#define FDE_XMLSYNTAXMODE_SkipCommentOrDecl 17
#define FDE_XMLSYNTAXMODE_TargetData 18
-class CFDE_XMLSyntaxParser : public IFDE_XMLSyntaxParser, public CFX_Target {
+class CFDE_XMLSyntaxParser : public CFX_Target {
public:
CFDE_XMLSyntaxParser();
~CFDE_XMLSyntaxParser();
- virtual void Release() { delete this; }
- virtual void Init(IFX_Stream* pStream,
- int32_t iXMLPlaneSize,
- int32_t iTextDataSize = 256);
- virtual uint32_t DoSyntaxParse();
- virtual int32_t GetStatus() const;
- virtual int32_t GetCurrentPos() const {
+ void Release() { delete this; }
+ void Init(IFX_Stream* pStream,
+ int32_t iXMLPlaneSize,
+ int32_t iTextDataSize = 256);
+ uint32_t DoSyntaxParse();
+ int32_t GetStatus() const;
+ int32_t GetCurrentPos() const {
return m_iParsedChars + (m_pStart - m_pBuffer);
}
- virtual FX_FILESIZE GetCurrentBinaryPos() const;
- virtual int32_t GetCurrentNodeNumber() const { return m_iCurrentNodeNum; }
- virtual int32_t GetLastNodeNumber() const { return m_iLastNodeNum; }
+ FX_FILESIZE GetCurrentBinaryPos() const;
+ int32_t GetCurrentNodeNumber() const { return m_iCurrentNodeNum; }
+ int32_t GetLastNodeNumber() const { return m_iLastNodeNum; }
- virtual void GetTargetName(CFX_WideString& wsTarget) const {
+ void GetTargetName(CFX_WideString& wsTarget) const {
m_BlockBuffer.GetTextData(wsTarget, 0, m_iTextDataLength);
}
- virtual void GetTagName(CFX_WideString& wsTag) const {
+ void GetTagName(CFX_WideString& wsTag) const {
m_BlockBuffer.GetTextData(wsTag, 0, m_iTextDataLength);
}
- virtual void GetAttributeName(CFX_WideString& wsAttriName) const {
+ void GetAttributeName(CFX_WideString& wsAttriName) const {
m_BlockBuffer.GetTextData(wsAttriName, 0, m_iTextDataLength);
}
- virtual void GetAttributeValue(CFX_WideString& wsAttriValue) const {
+ void GetAttributeValue(CFX_WideString& wsAttriValue) const {
m_BlockBuffer.GetTextData(wsAttriValue, 0, m_iTextDataLength);
}
- virtual void GetTextData(CFX_WideString& wsText) const {
+ void GetTextData(CFX_WideString& wsText) const {
m_BlockBuffer.GetTextData(wsText, 0, m_iTextDataLength);
}
- virtual void GetTargetData(CFX_WideString& wsData) const {
+ void GetTargetData(CFX_WideString& wsData) const {
m_BlockBuffer.GetTextData(wsData, 0, m_iTextDataLength);
}