From ae95f763dfb5e4fab3a9ff026b2f844c202625d7 Mon Sep 17 00:00:00 2001 From: dsinclair Date: Tue, 29 Mar 2016 16:58:29 -0700 Subject: Remove IFDE_XML* classes. The CFDE_XML* classes did not inhert from the IFDE_XML variants but we casted to them anyway. This CL removes the IFDE_XML* variants and we just use the CPDF_XML* classes directly. BUG=pdfium:357 Review URL: https://codereview.chromium.org/1836353002 --- testing/libfuzzer/pdf_xml_fuzzer.cc | 27 +-- xfa/fde/xml/fde_xml.h | 162 ------------- xfa/fde/xml/fde_xml_imp.cpp | 80 +++---- xfa/fde/xml/fde_xml_imp.h | 87 ++++--- xfa/fxfa/app/xfa_ffdoc.cpp | 33 +-- xfa/fxfa/app/xfa_ffdoc.h | 2 +- xfa/fxfa/app/xfa_ffdochandler.cpp | 2 +- xfa/fxfa/app/xfa_ffdochandler.h | 61 ++--- xfa/fxfa/app/xfa_ffwidgetacc.cpp | 16 +- xfa/fxfa/app/xfa_textlayout.cpp | 79 +++---- xfa/fxfa/app/xfa_textlayout.h | 24 +- xfa/fxfa/parser/xfa_document_datamerger_imp.cpp | 31 +-- xfa/fxfa/parser/xfa_document_serialize.cpp | 33 +-- xfa/fxfa/parser/xfa_object.h | 8 +- xfa/fxfa/parser/xfa_object_imp.cpp | 101 +++++---- xfa/fxfa/parser/xfa_parser.h | 8 +- xfa/fxfa/parser/xfa_parser_imp.cpp | 287 ++++++++++++------------ xfa/fxfa/parser/xfa_parser_imp.h | 60 ++--- xfa/fxfa/parser/xfa_utils.h | 8 +- xfa/fxfa/parser/xfa_utils_imp.cpp | 15 +- 20 files changed, 489 insertions(+), 635 deletions(-) diff --git a/testing/libfuzzer/pdf_xml_fuzzer.cc b/testing/libfuzzer/pdf_xml_fuzzer.cc index 592bf0f066..998e2ec650 100644 --- a/testing/libfuzzer/pdf_xml_fuzzer.cc +++ b/testing/libfuzzer/pdf_xml_fuzzer.cc @@ -14,22 +14,22 @@ namespace { -IFDE_XMLNode* XFA_FDEExtension_GetDocumentNode( - IFDE_XMLDoc* pXMLDoc, +CFDE_XMLNode* XFA_FDEExtension_GetDocumentNode( + CFDE_XMLDoc* pXMLDoc, FX_BOOL bVerifyWellFormness = FALSE) { if (!pXMLDoc) { return nullptr; } - IFDE_XMLNode* pXMLFakeRoot = pXMLDoc->GetRoot(); - for (IFDE_XMLNode* pXMLNode = - pXMLFakeRoot->GetNodeItem(IFDE_XMLNode::FirstChild); - pXMLNode; pXMLNode = pXMLNode->GetNodeItem(IFDE_XMLNode::NextSibling)) { + CFDE_XMLNode* pXMLFakeRoot = pXMLDoc->GetRoot(); + for (CFDE_XMLNode* pXMLNode = + pXMLFakeRoot->GetNodeItem(CFDE_XMLNode::FirstChild); + pXMLNode; pXMLNode = pXMLNode->GetNodeItem(CFDE_XMLNode::NextSibling)) { if (pXMLNode->GetType() == FDE_XMLNODE_Element) { if (bVerifyWellFormness) { - for (IFDE_XMLNode* pNextNode = - pXMLNode->GetNodeItem(IFDE_XMLNode::NextSibling); + for (CFDE_XMLNode* pNextNode = + pXMLNode->GetNodeItem(CFDE_XMLNode::NextSibling); pNextNode; - pNextNode = pNextNode->GetNodeItem(IFDE_XMLNode::NextSibling)) { + pNextNode = pNextNode->GetNodeItem(CFDE_XMLNode::NextSibling)) { if (pNextNode->GetType() == FDE_XMLNODE_Element) { return FALSE; } @@ -54,14 +54,9 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { if (!stream) return 0; - std::unique_ptr doc(IFDE_XMLDoc::Create()); - if (!doc) - return 0; - - std::unique_ptr> parser( + std::unique_ptr doc(new CFDE_XMLDoc); + std::unique_ptr> parser( new CXFA_XMLParser(doc->GetRoot(), stream.get())); - if (!parser) - return 0; if (!doc->LoadXML(parser.release())) return 0; 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(pChild)); pChild = pChild->m_pNext; } ws = L"m_pChild; while (pNode != NULL) { - SaveXMLNode(pXMLStream, (IFDE_XMLNode*)pNode); + SaveXMLNode(pXMLStream, static_cast(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_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_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); } diff --git a/xfa/fxfa/app/xfa_ffdoc.cpp b/xfa/fxfa/app/xfa_ffdoc.cpp index 0dcf730f2e..01d40ee8cc 100644 --- a/xfa/fxfa/app/xfa_ffdoc.cpp +++ b/xfa/fxfa/app/xfa_ffdoc.cpp @@ -10,6 +10,7 @@ #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" #include "core/fxcrt/include/fx_ext.h" #include "core/include/fpdfdoc/fpdf_doc.h" +#include "xfa/fde/xml/fde_xml_imp.h" #include "xfa/fgas/crt/fgas_algorithm.h" #include "xfa/fwl/core/ifwl_notedriver.h" #include "xfa/fxfa/app/xfa_ffapp.h" @@ -42,16 +43,16 @@ int32_t CXFA_FFDoc::StartLoad() { m_pDocument = pDocParser->GetDocument(); return iStatus; } -FX_BOOL XFA_GetPDFContentsFromPDFXML(IFDE_XMLNode* pPDFElement, +FX_BOOL XFA_GetPDFContentsFromPDFXML(CFDE_XMLNode* pPDFElement, uint8_t*& pByteBuffer, int32_t& iBufferSize) { - IFDE_XMLElement* pDocumentElement = NULL; - for (IFDE_XMLNode* pXMLNode = - pPDFElement->GetNodeItem(IFDE_XMLNode::FirstChild); - pXMLNode; pXMLNode = pXMLNode->GetNodeItem(IFDE_XMLNode::NextSibling)) { + CFDE_XMLElement* pDocumentElement = NULL; + for (CFDE_XMLNode* pXMLNode = + pPDFElement->GetNodeItem(CFDE_XMLNode::FirstChild); + pXMLNode; pXMLNode = pXMLNode->GetNodeItem(CFDE_XMLNode::NextSibling)) { if (pXMLNode->GetType() == FDE_XMLNODE_Element) { CFX_WideString wsTagName; - IFDE_XMLElement* pXMLElement = (IFDE_XMLElement*)pXMLNode; + CFDE_XMLElement* pXMLElement = static_cast(pXMLNode); pXMLElement->GetTagName(wsTagName); if (wsTagName.Equal(FX_WSTRC(L"document"))) { pDocumentElement = pXMLElement; @@ -62,13 +63,13 @@ FX_BOOL XFA_GetPDFContentsFromPDFXML(IFDE_XMLNode* pPDFElement, if (!pDocumentElement) { return FALSE; } - IFDE_XMLElement* pChunkElement = NULL; - for (IFDE_XMLNode* pXMLNode = - pDocumentElement->GetNodeItem(IFDE_XMLNode::FirstChild); - pXMLNode; pXMLNode = pXMLNode->GetNodeItem(IFDE_XMLNode::NextSibling)) { + CFDE_XMLElement* pChunkElement = NULL; + for (CFDE_XMLNode* pXMLNode = + pDocumentElement->GetNodeItem(CFDE_XMLNode::FirstChild); + pXMLNode; pXMLNode = pXMLNode->GetNodeItem(CFDE_XMLNode::NextSibling)) { if (pXMLNode->GetType() == FDE_XMLNODE_Element) { CFX_WideString wsTagName; - IFDE_XMLElement* pXMLElement = (IFDE_XMLElement*)pXMLNode; + CFDE_XMLElement* pXMLElement = static_cast(pXMLNode); pXMLElement->GetTagName(wsTagName); if (wsTagName.Equal(FX_WSTRC(L"chunk"))) { pChunkElement = pXMLElement; @@ -111,7 +112,7 @@ int32_t CXFA_FFDoc::DoLoad(IFX_Pause* pPause) { if (!pPDFNode) { return XFA_PARSESTATUS_SyntaxErr; } - IFDE_XMLNode* pPDFXML = pPDFNode->GetXMLMappingNode(); + CFDE_XMLNode* pPDFXML = pPDFNode->GetXMLMappingNode(); if (pPDFXML->GetType() != FDE_XMLNODE_Element) { return XFA_PARSESTATUS_SyntaxErr; } @@ -122,7 +123,7 @@ int32_t CXFA_FFDoc::DoLoad(IFX_Pause* pPause) { pXFAReader = FX_CreateMemoryStream(pByteBuffer, iBufferSize, TRUE); } else { CFX_WideString wsHref; - ((IFDE_XMLElement*)pPDFXML)->GetString(L"href", wsHref); + static_cast(pPDFXML)->GetString(L"href", wsHref); if (!wsHref.IsEmpty()) { pXFAReader = GetDocProvider()->OpenLinkedFile(this, wsHref); } @@ -378,16 +379,16 @@ CFX_DIBitmap* CXFA_FFDoc::GetPDFNamedImage(const CFX_WideStringC& wsName, return (CFX_DIBitmap*)imageDIBDpi->pDibSource; } -IFDE_XMLElement* CXFA_FFDoc::GetPackageData(const CFX_WideStringC& wsPackage) { +CFDE_XMLElement* CXFA_FFDoc::GetPackageData(const CFX_WideStringC& wsPackage) { uint32_t packetHash = FX_HashCode_String_GetW(wsPackage.GetPtr(), wsPackage.GetLength()); CXFA_Node* pNode = ToNode(m_pDocument->GetXFAObject(packetHash)); if (!pNode) { return NULL; } - IFDE_XMLNode* pXMLNode = pNode->GetXMLMappingNode(); + CFDE_XMLNode* pXMLNode = pNode->GetXMLMappingNode(); return (pXMLNode && pXMLNode->GetType() == FDE_XMLNODE_Element) - ? (IFDE_XMLElement*)pXMLNode + ? static_cast(pXMLNode) : NULL; } FX_BOOL CXFA_FFDoc::SavePackage(const CFX_WideStringC& wsPackage, diff --git a/xfa/fxfa/app/xfa_ffdoc.h b/xfa/fxfa/app/xfa_ffdoc.h index 8b61bd228f..31d5d0fc41 100644 --- a/xfa/fxfa/app/xfa_ffdoc.h +++ b/xfa/fxfa/app/xfa_ffdoc.h @@ -42,7 +42,7 @@ class CXFA_FFDoc : public IXFA_Doc { CFX_DIBitmap* GetPDFNamedImage(const CFX_WideStringC& wsName, int32_t& iImageXDpi, int32_t& iImageYDpi); - IFDE_XMLElement* GetPackageData(const CFX_WideStringC& wsPackage); + CFDE_XMLElement* GetPackageData(const CFX_WideStringC& wsPackage); FX_BOOL SavePackage(const CFX_WideStringC& wsPackage, IFX_FileWrite* pFile, IXFA_ChecksumContext* pCSContext = NULL); diff --git a/xfa/fxfa/app/xfa_ffdochandler.cpp b/xfa/fxfa/app/xfa_ffdochandler.cpp index 2019bb24df..036fc67ebd 100644 --- a/xfa/fxfa/app/xfa_ffdochandler.cpp +++ b/xfa/fxfa/app/xfa_ffdochandler.cpp @@ -40,7 +40,7 @@ int32_t CXFA_FFDocHandler::CountPackages(IXFA_Doc* hDoc) { void CXFA_FFDocHandler::GetPackageName(IXFA_Doc* hDoc, int32_t iPackage, CFX_WideStringC& wsPackage) {} -IFDE_XMLElement* CXFA_FFDocHandler::GetPackageData( +CFDE_XMLElement* CXFA_FFDocHandler::GetPackageData( IXFA_Doc* hDoc, const CFX_WideStringC& wsPackage) { return static_cast(hDoc)->GetPackageData(wsPackage); diff --git a/xfa/fxfa/app/xfa_ffdochandler.h b/xfa/fxfa/app/xfa_ffdochandler.h index ff2491509a..695f6a819d 100644 --- a/xfa/fxfa/app/xfa_ffdochandler.h +++ b/xfa/fxfa/app/xfa_ffdochandler.h @@ -13,36 +13,37 @@ class CXFA_FFDocHandler : public IXFA_DocHandler { public: CXFA_FFDocHandler(); ~CXFA_FFDocHandler(); - virtual void ReleaseDoc(IXFA_Doc* hDoc); - virtual IXFA_DocProvider* GetDocProvider(IXFA_Doc* hDoc); - virtual uint32_t GetDocType(IXFA_Doc* hDoc); - virtual int32_t StartLoad(IXFA_Doc* hDoc); - virtual int32_t DoLoad(IXFA_Doc* hDoc, IFX_Pause* pPause = NULL); - virtual void StopLoad(IXFA_Doc* hDoc); - - virtual IXFA_DocView* CreateDocView(IXFA_Doc* hDoc, uint32_t dwView = 0); - virtual int32_t CountPackages(IXFA_Doc* hDoc); - virtual void GetPackageName(IXFA_Doc* hDoc, - int32_t iPackage, - CFX_WideStringC& wsPackage); - virtual IFDE_XMLElement* GetPackageData(IXFA_Doc* hDoc, - const CFX_WideStringC& wsPackage); - virtual FX_BOOL SavePackage(IXFA_Doc* hDoc, - const CFX_WideStringC& wsPackage, - IFX_FileWrite* pFile, - IXFA_ChecksumContext* pCSContext = NULL); - virtual FX_BOOL CloseDoc(IXFA_Doc* hDoc); - virtual FX_BOOL ImportData(IXFA_Doc* hDoc, - IFX_FileRead* pStream, - FX_BOOL bXDP = TRUE); - virtual void SetJSERuntime(IXFA_Doc* hDoc, FXJSE_HRUNTIME hRuntime); - virtual FXJSE_HVALUE GetXFAScriptObject(IXFA_Doc* hDoc); - virtual XFA_ATTRIBUTEENUM GetRestoreState(IXFA_Doc* hDoc); - virtual FX_BOOL RunDocScript(IXFA_Doc* hDoc, - XFA_SCRIPTTYPE eScriptType, - const CFX_WideStringC& wsScript, - FXJSE_HVALUE hRetValue, - FXJSE_HVALUE hThisObject); + + void ReleaseDoc(IXFA_Doc* hDoc) override; + IXFA_DocProvider* GetDocProvider(IXFA_Doc* hDoc) override; + uint32_t GetDocType(IXFA_Doc* hDoc) override; + int32_t StartLoad(IXFA_Doc* hDoc) override; + int32_t DoLoad(IXFA_Doc* hDoc, IFX_Pause* pPause = NULL) override; + void StopLoad(IXFA_Doc* hDoc) override; + + IXFA_DocView* CreateDocView(IXFA_Doc* hDoc, uint32_t dwView = 0) override; + int32_t CountPackages(IXFA_Doc* hDoc) override; + void GetPackageName(IXFA_Doc* hDoc, + int32_t iPackage, + CFX_WideStringC& wsPackage) override; + CFDE_XMLElement* GetPackageData(IXFA_Doc* hDoc, + const CFX_WideStringC& wsPackage); + FX_BOOL SavePackage(IXFA_Doc* hDoc, + const CFX_WideStringC& wsPackage, + IFX_FileWrite* pFile, + IXFA_ChecksumContext* pCSContext = NULL) override; + FX_BOOL CloseDoc(IXFA_Doc* hDoc) override; + FX_BOOL ImportData(IXFA_Doc* hDoc, + IFX_FileRead* pStream, + FX_BOOL bXDP = TRUE) override; + void SetJSERuntime(IXFA_Doc* hDoc, FXJSE_HRUNTIME hRuntime) override; + FXJSE_HVALUE GetXFAScriptObject(IXFA_Doc* hDoc) override; + XFA_ATTRIBUTEENUM GetRestoreState(IXFA_Doc* hDoc) override; + FX_BOOL RunDocScript(IXFA_Doc* hDoc, + XFA_SCRIPTTYPE eScriptType, + const CFX_WideStringC& wsScript, + FXJSE_HVALUE hRetValue, + FXJSE_HVALUE hThisObject) override; protected: }; diff --git a/xfa/fxfa/app/xfa_ffwidgetacc.cpp b/xfa/fxfa/app/xfa_ffwidgetacc.cpp index e4e574b969..c50786a3dc 100644 --- a/xfa/fxfa/app/xfa_ffwidgetacc.cpp +++ b/xfa/fxfa/app/xfa_ffwidgetacc.cpp @@ -9,6 +9,7 @@ #include #include "xfa/fde/tto/fde_textout.h" +#include "xfa/fde/xml/fde_xml_imp.h" #include "xfa/fxfa/app/xfa_ffapp.h" #include "xfa/fxfa/app/xfa_ffcheckbutton.h" #include "xfa/fxfa/app/xfa_ffchoicelist.h" @@ -288,9 +289,10 @@ void CXFA_WidgetAcc::SetImageEdit(const CFX_WideStringC& wsContentType, if (pHrefNode) { pHrefNode->SetCData(XFA_ATTRIBUTE_Value, wsHref); } else { - IFDE_XMLNode* pXMLNode = pBind->GetXMLMappingNode(); + CFDE_XMLNode* pXMLNode = pBind->GetXMLMappingNode(); FXSYS_assert(pXMLNode && pXMLNode->GetType() == FDE_XMLNODE_Element); - ((IFDE_XMLElement*)pXMLNode)->SetString(FX_WSTRC(L"href"), wsHref); + static_cast(pXMLNode) + ->SetString(FX_WSTRC(L"href"), wsHref); } } @@ -1602,14 +1604,14 @@ CXFA_Node* CXFA_TextProvider::GetTextNode(FX_BOOL& bRichText) { return pChildNode; } else if (m_eType == XFA_TEXTPROVIDERTYPE_Datasets) { CXFA_Node* pBind = m_pWidgetAcc->GetDatasets(); - IFDE_XMLNode* pXMLNode = pBind->GetXMLMappingNode(); + CFDE_XMLNode* pXMLNode = pBind->GetXMLMappingNode(); FXSYS_assert(pXMLNode); - for (IFDE_XMLNode* pXMLChild = - pXMLNode->GetNodeItem(IFDE_XMLNode::FirstChild); + for (CFDE_XMLNode* pXMLChild = + pXMLNode->GetNodeItem(CFDE_XMLNode::FirstChild); pXMLChild; - pXMLChild = pXMLChild->GetNodeItem(IFDE_XMLNode::NextSibling)) { + pXMLChild = pXMLChild->GetNodeItem(CFDE_XMLNode::NextSibling)) { if (pXMLChild->GetType() == FDE_XMLNODE_Element) { - IFDE_XMLElement* pElement = (IFDE_XMLElement*)pXMLChild; + CFDE_XMLElement* pElement = static_cast(pXMLChild); if (XFA_RecognizeRichText(pElement)) { bRichText = TRUE; } diff --git a/xfa/fxfa/app/xfa_textlayout.cpp b/xfa/fxfa/app/xfa_textlayout.cpp index ddd9809f91..ced7acbb32 100644 --- a/xfa/fxfa/app/xfa_textlayout.cpp +++ b/xfa/fxfa/app/xfa_textlayout.cpp @@ -10,6 +10,7 @@ #include "core/fxcrt/include/fx_ext.h" #include "xfa/fde/fde_pen.h" +#include "xfa/fde/xml/fde_xml_imp.h" #include "xfa/fgas/crt/fgas_algorithm.h" #include "xfa/fgas/crt/fgas_codepage.h" #include "xfa/fxfa/app/xfa_ffapp.h" @@ -64,7 +65,7 @@ CXFA_TextParser::~CXFA_TextParser() { m_pAllocator->Release(); FX_POSITION ps = m_mapXMLNodeToParseContext.GetStartPosition(); while (ps) { - IFDE_XMLNode* pXMLNode; + CFDE_XMLNode* pXMLNode; CXFA_TextParseContext* pParseContext; m_mapXMLNodeToParseContext.GetNextAssoc(ps, pXMLNode, pParseContext); if (pParseContext) @@ -75,7 +76,7 @@ CXFA_TextParser::~CXFA_TextParser() { void CXFA_TextParser::Reset() { FX_POSITION ps = m_mapXMLNodeToParseContext.GetStartPosition(); while (ps) { - IFDE_XMLNode* pXMLNode; + CFDE_XMLNode* pXMLNode; CXFA_TextParseContext* pParseContext; m_mapXMLNodeToParseContext.GetNextAssoc(ps, pXMLNode, pParseContext); if (pParseContext) @@ -210,7 +211,7 @@ IFDE_CSSComputedStyle* CXFA_TextParser::CreateStyle( return pNewStyle; } IFDE_CSSComputedStyle* CXFA_TextParser::ComputeStyle( - IFDE_XMLNode* pXMLNode, + CFDE_XMLNode* pXMLNode, IFDE_CSSComputedStyle* pParentStyle) { CXFA_TextParseContext* pContext = static_cast( m_mapXMLNodeToParseContext.GetValueAt(pXMLNode)); @@ -230,7 +231,7 @@ IFDE_CSSComputedStyle* CXFA_TextParser::ComputeStyle( pCSSAccel->OnLeaveTag(&tagProvider); return pStyle; } -void CXFA_TextParser::DoParse(IFDE_XMLNode* pXMLContainer, +void CXFA_TextParser::DoParse(CFDE_XMLNode* pXMLContainer, IXFA_TextProvider* pTextProvider) { if (pXMLContainer == NULL || pTextProvider == NULL || m_pAllocator) { return; @@ -242,7 +243,7 @@ void CXFA_TextParser::DoParse(IFDE_XMLNode* pXMLContainer, ParseRichText(pXMLContainer, pRootStyle); pRootStyle->Release(); } -void CXFA_TextParser::ParseRichText(IFDE_XMLNode* pXMLNode, +void CXFA_TextParser::ParseRichText(CFDE_XMLNode* pXMLNode, IFDE_CSSComputedStyle* pParentStyle) { if (pXMLNode == NULL) { return; @@ -278,16 +279,16 @@ void CXFA_TextParser::ParseRichText(IFDE_XMLNode* pXMLNode, pTextContext->SetDisplay(eDisplay); m_mapXMLNodeToParseContext.SetAt(pXMLNode, pTextContext); } - for (IFDE_XMLNode* pXMLChild = - pXMLNode->GetNodeItem(IFDE_XMLNode::FirstChild); + for (CFDE_XMLNode* pXMLChild = + pXMLNode->GetNodeItem(CFDE_XMLNode::FirstChild); pXMLChild; - pXMLChild = pXMLChild->GetNodeItem(IFDE_XMLNode::NextSibling)) { + pXMLChild = pXMLChild->GetNodeItem(CFDE_XMLNode::NextSibling)) { ParseRichText(pXMLChild, pNewStyle); } if (pNewStyle) pNewStyle->Release(); } -void CXFA_TextParser::ParseTagInfo(IFDE_XMLNode* pXMLNode, +void CXFA_TextParser::ParseTagInfo(CFDE_XMLNode* pXMLNode, CXFA_CSSTagProvider& tagProvider) { static const uint32_t s_XFATagName[] = { 0x61, 0x62, 0x69, 0x70, 0x0001f714, @@ -296,7 +297,7 @@ void CXFA_TextParser::ParseTagInfo(IFDE_XMLNode* pXMLNode, }; CFX_WideString wsName; if (pXMLNode->GetType() == FDE_XMLNODE_Element) { - IFDE_XMLElement* pXMLElement = (IFDE_XMLElement*)pXMLNode; + CFDE_XMLElement* pXMLElement = static_cast(pXMLNode); pXMLElement->GetLocalTagName(wsName); tagProvider.SetTagNameObj(wsName); uint32_t dwHashCode = @@ -391,7 +392,7 @@ FX_FLOAT CXFA_TextParser::GetFontSize(IXFA_TextProvider* pTextProvider, } int32_t CXFA_TextParser::GetHorScale(IXFA_TextProvider* pTextProvider, IFDE_CSSComputedStyle* pStyle, - IFDE_XMLNode* pXMLNode) const { + CFDE_XMLNode* pXMLNode) const { if (pStyle) { CFX_WideString wsValue; if (pStyle->GetCustomStyle(FX_WSTRC(L"xfa-font-horizontal-scale"), @@ -406,7 +407,7 @@ int32_t CXFA_TextParser::GetHorScale(IXFA_TextProvider* pTextProvider, FX_WSTRC(L"xfa-font-horizontal-scale"), wsValue)) { return wsValue.GetInteger(); } - pXMLNode = pXMLNode->GetNodeItem(IFDE_XMLNode::Parent); + pXMLNode = pXMLNode->GetNodeItem(CFDE_XMLNode::Parent); } } if (CXFA_Font font = pTextProvider->GetFontNode()) { @@ -515,7 +516,7 @@ FX_FLOAT CXFA_TextParser::GetLineHeight(IXFA_TextProvider* pTextProvider, return fLineHeight; } FX_BOOL CXFA_TextParser::GetEmbbedObj(IXFA_TextProvider* pTextProvider, - IFDE_XMLNode* pXMLNode, + CFDE_XMLNode* pXMLNode, CFX_WideString& wsValue) { wsValue.Empty(); if (pXMLNode == NULL) { @@ -523,7 +524,7 @@ FX_BOOL CXFA_TextParser::GetEmbbedObj(IXFA_TextProvider* pTextProvider, } FX_BOOL bRet = FALSE; if (pXMLNode->GetType() == FDE_XMLNODE_Element) { - IFDE_XMLElement* pElement = (IFDE_XMLElement*)pXMLNode; + CFDE_XMLElement* pElement = static_cast(pXMLNode); CFX_WideString wsAttr; pElement->GetString(FX_WSTRC(L"xfa:embed").GetPtr(), wsAttr); if (wsAttr.IsEmpty()) { @@ -559,7 +560,7 @@ FX_BOOL CXFA_TextParser::GetEmbbedObj(IXFA_TextProvider* pTextProvider, return bRet; } CXFA_TextParseContext* CXFA_TextParser::GetParseContextFromMap( - IFDE_XMLNode* pXMLNode) { + CFDE_XMLNode* pXMLNode) { return (CXFA_TextParseContext*)m_mapXMLNodeToParseContext.GetValueAt( pXMLNode); } @@ -712,19 +713,19 @@ void CXFA_TextLayout::GetTextDataNode() { } m_pTextDataNode = pNode; } -IFDE_XMLNode* CXFA_TextLayout::GetXMLContainerNode() { - IFDE_XMLNode* pXMLContainer = NULL; +CFDE_XMLNode* CXFA_TextLayout::GetXMLContainerNode() { + CFDE_XMLNode* pXMLContainer = NULL; if (m_bRichText) { - IFDE_XMLNode* pXMLRoot = m_pTextDataNode->GetXMLMappingNode(); + CFDE_XMLNode* pXMLRoot = m_pTextDataNode->GetXMLMappingNode(); if (!pXMLRoot) { return pXMLContainer; } - for (IFDE_XMLNode* pXMLChild = - pXMLRoot->GetNodeItem(IFDE_XMLNode::FirstChild); + for (CFDE_XMLNode* pXMLChild = + pXMLRoot->GetNodeItem(CFDE_XMLNode::FirstChild); pXMLChild; - pXMLChild = pXMLChild->GetNodeItem(IFDE_XMLNode::NextSibling)) { + pXMLChild = pXMLChild->GetNodeItem(CFDE_XMLNode::NextSibling)) { if (pXMLChild->GetType() == FDE_XMLNODE_Element) { - IFDE_XMLElement* pXMLElement = (IFDE_XMLElement*)pXMLChild; + CFDE_XMLElement* pXMLElement = static_cast(pXMLChild); CFX_WideString wsTag; pXMLElement->GetLocalTagName(wsTag); if (wsTag.Equal(FX_WSTRC(L"body")) || wsTag.Equal(FX_WSTRC(L"html"))) { @@ -803,7 +804,7 @@ void CXFA_TextLayout::InitBreak(FX_FLOAT fLineWidth) { void CXFA_TextLayout::InitBreak(IFDE_CSSComputedStyle* pStyle, FDE_CSSDISPLAY eDisplay, FX_FLOAT fLineWidth, - IFDE_XMLNode* pXMLNode, + CFDE_XMLNode* pXMLNode, IFDE_CSSComputedStyle* pParentStyle) { if (pStyle == NULL) { InitBreak(fLineWidth); @@ -1113,17 +1114,17 @@ FX_BOOL CXFA_TextLayout::Layout(int32_t iBlock) { } m_pBreak->Reset(); if (m_bRichText) { - IFDE_XMLNode* pContainerNode = GetXMLContainerNode(); + CFDE_XMLNode* pContainerNode = GetXMLContainerNode(); if (!pContainerNode) { return TRUE; } - IFDE_XMLNode* pXMLNode = m_pLoader->m_pXMLNode; + CFDE_XMLNode* pXMLNode = m_pLoader->m_pXMLNode; if (pXMLNode == NULL) { return TRUE; } - IFDE_XMLNode* pSaveXMLNode = m_pLoader->m_pXMLNode; + CFDE_XMLNode* pSaveXMLNode = m_pLoader->m_pXMLNode; for (; pXMLNode; - pXMLNode = pXMLNode->GetNodeItem(IFDE_XMLNode::NextSibling)) { + pXMLNode = pXMLNode->GetNodeItem(CFDE_XMLNode::NextSibling)) { FX_BOOL bFlag = LoadRichText(pXMLNode, szText, fLinePos, m_pLoader->m_pParentStyle, TRUE); if (!bFlag) { @@ -1131,7 +1132,7 @@ FX_BOOL CXFA_TextLayout::Layout(int32_t iBlock) { } } while (pXMLNode == NULL) { - pXMLNode = pSaveXMLNode->GetNodeItem(IFDE_XMLNode::Parent); + pXMLNode = pSaveXMLNode->GetNodeItem(CFDE_XMLNode::Parent); if (pXMLNode == pContainerNode) { break; } @@ -1142,12 +1143,12 @@ FX_BOOL CXFA_TextLayout::Layout(int32_t iBlock) { break; } pSaveXMLNode = pXMLNode; - pXMLNode = pXMLNode->GetNodeItem(IFDE_XMLNode::NextSibling); + pXMLNode = pXMLNode->GetNodeItem(CFDE_XMLNode::NextSibling); if (!pXMLNode) { continue; } for (; pXMLNode; - pXMLNode = pXMLNode->GetNodeItem(IFDE_XMLNode::NextSibling)) { + pXMLNode = pXMLNode->GetNodeItem(CFDE_XMLNode::NextSibling)) { FX_BOOL bFlag = LoadRichText(pXMLNode, szText, fLinePos, m_pLoader->m_pParentStyle, TRUE); if (!bFlag) { @@ -1313,7 +1314,7 @@ FX_BOOL CXFA_TextLayout::Loader(const CFX_SizeF& szText, return TRUE; } if (m_bRichText) { - IFDE_XMLNode* pXMLContainer = GetXMLContainerNode(); + CFDE_XMLNode* pXMLContainer = GetXMLContainerNode(); if (pXMLContainer) { if (!m_textParser.IsParsed()) { m_textParser.DoParse(pXMLContainer, m_pTextProvider); @@ -1359,7 +1360,7 @@ void CXFA_TextLayout::LoadText(CXFA_Node* pNode, EndBreak(FX_RTFBREAK_ParagraphBreak, fLinePos, bSavePieces); } } -FX_BOOL CXFA_TextLayout::LoadRichText(IFDE_XMLNode* pXMLNode, +FX_BOOL CXFA_TextLayout::LoadRichText(CFDE_XMLNode* pXMLNode, const CFX_SizeF& szText, FX_FLOAT& fLinePos, IFDE_CSSComputedStyle* pParentStyle, @@ -1381,7 +1382,7 @@ FX_BOOL CXFA_TextLayout::LoadRichText(IFDE_XMLNode* pXMLNode, if (bEndBreak) { FX_BOOL bCurOl = FALSE; FX_BOOL bCurLi = FALSE; - IFDE_XMLElement* pElement = NULL; + CFDE_XMLElement* pElement = NULL; if (pContext) { if (m_bBlockContinue || (m_pLoader && pXMLNode == m_pLoader->m_pXMLNode)) { @@ -1390,7 +1391,7 @@ FX_BOOL CXFA_TextLayout::LoadRichText(IFDE_XMLNode* pXMLNode, if (pXMLNode->GetType() == FDE_XMLNODE_Text) { bContentNode = TRUE; } else if (pXMLNode->GetType() == FDE_XMLNODE_Element) { - pElement = (IFDE_XMLElement*)pXMLNode; + pElement = static_cast(pXMLNode); pElement->GetLocalTagName(wsName); } if (wsName == FX_WSTRC(L"ol")) { @@ -1437,7 +1438,7 @@ FX_BOOL CXFA_TextLayout::LoadRichText(IFDE_XMLNode* pXMLNode, m_textParser.IsSpaceRun(bContentNode ? pParentStyle : pStyle); CFX_WideString wsText; if (bContentNode && iTabCount == 0) { - ((IFDE_XMLText*)pXMLNode)->GetText(wsText); + static_cast(pXMLNode)->GetText(wsText); } else if (wsName == FX_WSTRC(L"br")) { wsText = L'\n'; } else if (wsName == FX_WSTRC(L"li")) { @@ -1506,10 +1507,10 @@ FX_BOOL CXFA_TextLayout::LoadRichText(IFDE_XMLNode* pXMLNode, } } FX_BOOL ret = TRUE; - for (IFDE_XMLNode* pChildNode = - pXMLNode->GetNodeItem(IFDE_XMLNode::FirstChild); + for (CFDE_XMLNode* pChildNode = + pXMLNode->GetNodeItem(CFDE_XMLNode::FirstChild); pChildNode; - pChildNode = pChildNode->GetNodeItem(IFDE_XMLNode::NextSibling)) { + pChildNode = pChildNode->GetNodeItem(CFDE_XMLNode::NextSibling)) { if (bCurOl) { iLiCount++; } @@ -1557,7 +1558,7 @@ FX_BOOL CXFA_TextLayout::LoadRichText(IFDE_XMLNode* pXMLNode, } if (m_pLoader && m_pLoader->m_iTotalLines > -1) { m_pLoader->m_pXMLNode = - pXMLNode->GetNodeItem(IFDE_XMLNode::NextSibling); + pXMLNode->GetNodeItem(CFDE_XMLNode::NextSibling); m_pLoader->m_pParentStyle = pParentStyle; } return FALSE; diff --git a/xfa/fxfa/app/xfa_textlayout.h b/xfa/fxfa/app/xfa_textlayout.h index f6c3262536..1d2db21652 100644 --- a/xfa/fxfa/app/xfa_textlayout.h +++ b/xfa/fxfa/app/xfa_textlayout.h @@ -88,9 +88,9 @@ class CXFA_TextParser { CXFA_TextParser() : m_pAllocator(NULL), m_pSelector(NULL), m_pUASheet(NULL) {} virtual ~CXFA_TextParser(); void Reset(); - void DoParse(IFDE_XMLNode* pXMLContainer, IXFA_TextProvider* pTextProvider); + void DoParse(CFDE_XMLNode* pXMLContainer, IXFA_TextProvider* pTextProvider); IFDE_CSSComputedStyle* CreateRootStyle(IXFA_TextProvider* pTextProvider); - IFDE_CSSComputedStyle* ComputeStyle(IFDE_XMLNode* pXMLNode, + IFDE_CSSComputedStyle* ComputeStyle(CFDE_XMLNode* pXMLNode, IFDE_CSSComputedStyle* pParentStyle); FX_BOOL IsParsed() const { return m_pAllocator != NULL; } @@ -106,7 +106,7 @@ class CXFA_TextParser { IFDE_CSSComputedStyle* pStyle) const; int32_t GetHorScale(IXFA_TextProvider* pTextProvider, IFDE_CSSComputedStyle* pStyle, - IFDE_XMLNode* pXMLNode) const; + CFDE_XMLNode* pXMLNode) const; int32_t GetVerScale(IXFA_TextProvider* pTextProvider, IFDE_CSSComputedStyle* pStyle) const; void GetUnderline(IXFA_TextProvider* pTextProvider, @@ -125,21 +125,21 @@ class CXFA_TextParser { FX_BOOL bFirst, FX_FLOAT fVerScale) const; FX_BOOL GetEmbbedObj(IXFA_TextProvider* pTextProvider, - IFDE_XMLNode* pXMLNode, + CFDE_XMLNode* pXMLNode, CFX_WideString& wsValue); - CXFA_TextParseContext* GetParseContextFromMap(IFDE_XMLNode* pXMLNode); + CXFA_TextParseContext* GetParseContextFromMap(CFDE_XMLNode* pXMLNode); private: void InitCSSData(IXFA_TextProvider* pTextProvider); - void ParseRichText(IFDE_XMLNode* pXMLNode, + void ParseRichText(CFDE_XMLNode* pXMLNode, IFDE_CSSComputedStyle* pParentStyle); - void ParseTagInfo(IFDE_XMLNode* pXMLNode, CXFA_CSSTagProvider& tagProvider); + void ParseTagInfo(CFDE_XMLNode* pXMLNode, CXFA_CSSTagProvider& tagProvider); IFDE_CSSStyleSheet* LoadDefaultSheetStyle(); IFDE_CSSComputedStyle* CreateStyle(IFDE_CSSComputedStyle* pParentStyle); IFX_MEMAllocator* m_pAllocator; IFDE_CSSStyleSelector* m_pSelector; IFDE_CSSStyleSheet* m_pUASheet; - CFX_MapPtrTemplate + CFX_MapPtrTemplate m_mapXMLNodeToParseContext; }; @@ -165,7 +165,7 @@ class CXFA_LoaderContext { int32_t m_iChar; int32_t m_iLines; int32_t m_iTotalLines; - IFDE_XMLNode* m_pXMLNode; + CFDE_XMLNode* m_pXMLNode; CXFA_Node* m_pNode; IFDE_CSSComputedStyle* m_pParentStyle; CFX_ArrayTemplate m_lineHeights; @@ -352,13 +352,13 @@ class CXFA_TextLayout { private: void GetTextDataNode(); - IFDE_XMLNode* GetXMLContainerNode(); + CFDE_XMLNode* GetXMLContainerNode(); IFX_RTFBreak* CreateBreak(FX_BOOL bDefault); void InitBreak(FX_FLOAT fLineWidth); void InitBreak(IFDE_CSSComputedStyle* pStyle, FDE_CSSDISPLAY eDisplay, FX_FLOAT fLineWidth, - IFDE_XMLNode* pXMLNode, + CFDE_XMLNode* pXMLNode, IFDE_CSSComputedStyle* pParentStyle = NULL); FX_BOOL Loader(const CFX_SizeF& szText, FX_FLOAT& fLinePos, @@ -367,7 +367,7 @@ class CXFA_TextLayout { const CFX_SizeF& szText, FX_FLOAT& fLinePos, FX_BOOL bSavePieces); - FX_BOOL LoadRichText(IFDE_XMLNode* pXMLNode, + FX_BOOL LoadRichText(CFDE_XMLNode* pXMLNode, const CFX_SizeF& szText, FX_FLOAT& fLinePos, IFDE_CSSComputedStyle* pParentStyle, diff --git a/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp b/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp index 8872400bb5..476dde4104 100644 --- a/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp +++ b/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp @@ -7,6 +7,7 @@ #include "xfa/fxfa/parser/xfa_document_datamerger_imp.h" #include "core/fxcrt/include/fx_ext.h" +#include "xfa/fde/xml/fde_xml_imp.h" #include "xfa/fxfa/fm2js/xfa_fm2jsapi.h" #include "xfa/fxfa/parser/xfa_basic_imp.h" #include "xfa/fxfa/parser/xfa_docdata.h" @@ -125,8 +126,8 @@ static void XFA_DataMerge_CreateDataBinding(CXFA_Node* pFormNode, image.GetContentType(wsContentType); image.GetHref(wsHref); } - IFDE_XMLElement* pXMLDataElement = - (IFDE_XMLElement*)(pDataNode->GetXMLMappingNode()); + CFDE_XMLElement* pXMLDataElement = + static_cast(pDataNode->GetXMLMappingNode()); FXSYS_assert(pXMLDataElement); pWidgetData->GetFormatDataValue(wsValue, wsFormatedValue); pDataNode->SetAttributeValue(wsValue, wsFormatedValue); @@ -151,9 +152,9 @@ static void XFA_DataMerge_CreateDataBinding(CXFA_Node* pFormNode, pValue->SetCData(XFA_ATTRIBUTE_Value, wsSelTextArray[i]); } } else { - IFDE_XMLNode* pXMLNode = pDataNode->GetXMLMappingNode(); + CFDE_XMLNode* pXMLNode = pDataNode->GetXMLMappingNode(); FXSYS_assert(pXMLNode->GetType() == FDE_XMLNODE_Element); - ((IFDE_XMLElement*)pXMLNode) + static_cast(pXMLNode) ->SetString(FX_WSTRC(L"xfa:dataNode"), FX_WSTRC(L"dataGroup")); } } else if (!wsValue.IsEmpty()) { @@ -263,8 +264,8 @@ static void XFA_DataMerge_CreateDataBinding(CXFA_Node* pFormNode, defValue.GetNode(), wsNormailizeValue, XFA_ELEMENT_Image); CXFA_Image image = defValue.GetImage(); if (image) { - IFDE_XMLElement* pXMLDataElement = - (IFDE_XMLElement*)(pDataNode->GetXMLMappingNode()); + CFDE_XMLElement* pXMLDataElement = + static_cast(pDataNode->GetXMLMappingNode()); FXSYS_assert(pXMLDataElement); CFX_WideString wsContentType; CFX_WideString wsHref; @@ -1261,9 +1262,9 @@ CXFA_Node* CXFA_Document::GetNotBindNode(CXFA_ObjArray& arrayNodes) { void CXFA_Document::DoDataMerge() { CXFA_Node* pDatasetsRoot = ToNode(GetXFAObject(XFA_HASHCODE_Datasets)); if (!pDatasetsRoot) { - IFDE_XMLElement* pDatasetsXMLNode = - IFDE_XMLElement::Create(FX_WSTRC(L"xfa:datasets")); - FXSYS_assert(pDatasetsXMLNode); + CFDE_XMLElement* pDatasetsXMLNode = + new CFDE_XMLElement(FX_WSTRC(L"xfa:datasets")); + pDatasetsXMLNode->SetString( FX_WSTRC(L"xmlns:xfa"), FX_WSTRC(L"http://www.xfa.org/schema/xfa-data/1.0/")); @@ -1305,9 +1306,9 @@ void CXFA_Document::DoDataMerge() { } } if (!pDataRoot) { - IFDE_XMLElement* pDataRootXMLNode = - IFDE_XMLElement::Create(FX_WSTRC(L"xfa:data")); - FXSYS_assert(pDataRootXMLNode); + CFDE_XMLElement* pDataRootXMLNode = + new CFDE_XMLElement(FX_WSTRC(L"xfa:data")); + pDataRoot = CreateNode(XFA_XDPPACKET_Datasets, XFA_ELEMENT_DataGroup); pDataRoot->SetCData(XFA_ATTRIBUTE_Name, FX_WSTRC(L"data")); pDataRoot->SetXMLMappingNode(pDataRootXMLNode); @@ -1353,9 +1354,9 @@ void CXFA_Document::DoDataMerge() { CFX_WideStringC wsFormName = pSubformSetNode->GetCData(XFA_ATTRIBUTE_Name); CFX_WideString wsDataTopLevelName = wsFormName.IsEmpty() ? FX_WSTRC(L"form") : wsFormName; - IFDE_XMLElement* pDataTopLevelXMLNode = - IFDE_XMLElement::Create(wsDataTopLevelName); - FXSYS_assert(pDataTopLevelXMLNode); + CFDE_XMLElement* pDataTopLevelXMLNode = + new CFDE_XMLElement(wsDataTopLevelName); + pDataTopLevel = CreateNode(XFA_XDPPACKET_Datasets, XFA_ELEMENT_DataGroup); pDataTopLevel->SetCData(XFA_ATTRIBUTE_Name, wsDataTopLevelName); pDataTopLevel->SetXMLMappingNode(pDataTopLevelXMLNode); diff --git a/xfa/fxfa/parser/xfa_document_serialize.cpp b/xfa/fxfa/parser/xfa_document_serialize.cpp index 3df82e38f1..289581ecae 100644 --- a/xfa/fxfa/parser/xfa_document_serialize.cpp +++ b/xfa/fxfa/parser/xfa_document_serialize.cpp @@ -6,6 +6,7 @@ #include "xfa/fxfa/parser/xfa_document_serialize.h" +#include "xfa/fde/xml/fde_xml_imp.h" #include "xfa/fgas/crt/fgas_codepage.h" #include "xfa/fxfa/fm2js/xfa_fm2jsapi.h" #include "xfa/fxfa/parser/xfa_docdata.h" @@ -60,8 +61,8 @@ FX_BOOL CXFA_DataImporter::ImportData(IFX_FileRead* pDataDocument) { pDataModel->InsertChild(pChildNode); } } else { - IFDE_XMLNode* pXMLNode = pImportDataRoot->GetXMLMappingNode(); - IFDE_XMLNode* pParentXMLNode = pXMLNode->GetNodeItem(IFDE_XMLNode::Parent); + CFDE_XMLNode* pXMLNode = pImportDataRoot->GetXMLMappingNode(); + CFDE_XMLNode* pParentXMLNode = pXMLNode->GetNodeItem(CFDE_XMLNode::Parent); if (pParentXMLNode) { pParentXMLNode->RemoveChildNode(pXMLNode); } @@ -244,12 +245,12 @@ static void XFA_DataExporter_RegenerateFormFile_Changed( pNode->GetAttribute(XFA_ATTRIBUTE_ContentType, wsContentType, FALSE); if (pRawValueNode->GetClassID() == XFA_ELEMENT_SharpxHTML && wsContentType.Equal(FX_WSTRC(L"text/html"))) { - IFDE_XMLNode* pExDataXML = pNode->GetXMLMappingNode(); + CFDE_XMLNode* pExDataXML = pNode->GetXMLMappingNode(); if (!pExDataXML) { break; } - IFDE_XMLNode* pRichTextXML = - pExDataXML->GetNodeItem(IFDE_XMLNode::FirstChild); + CFDE_XMLNode* pRichTextXML = + pExDataXML->GetNodeItem(CFDE_XMLNode::FirstChild); if (!pRichTextXML) { break; } @@ -498,7 +499,7 @@ FX_BOOL CXFA_DataExporter::Export(IFX_Stream* pStream, CXFA_Node* pNode, uint32_t dwFlag, const FX_CHAR* pChecksum) { - IFDE_XMLDoc* pXMLDoc = m_pDocument->GetParser()->GetXMLDoc(); + CFDE_XMLDoc* pXMLDoc = m_pDocument->GetParser()->GetXMLDoc(); if (pNode->GetObjectType() == XFA_OBJECTTYPE_ModelNode) { switch (pNode->GetPacketID()) { case XFA_XDPPACKET_XDP: { @@ -513,8 +514,8 @@ FX_BOOL CXFA_DataExporter::Export(IFX_Stream* pStream, pStream->WriteString(s_pwsPostamble, FXSYS_wcslen(s_pwsPostamble)); } break; case XFA_XDPPACKET_Datasets: { - IFDE_XMLElement* pElement = - (IFDE_XMLElement*)pNode->GetXMLMappingNode(); + CFDE_XMLElement* pElement = + static_cast(pNode->GetXMLMappingNode()); if (!pElement || pElement->GetType() != FDE_XMLNODE_Element) { return FALSE; } @@ -528,8 +529,8 @@ FX_BOOL CXFA_DataExporter::Export(IFX_Stream* pStream, } break; case XFA_XDPPACKET_Template: default: { - IFDE_XMLElement* pElement = - (IFDE_XMLElement*)pNode->GetXMLMappingNode(); + CFDE_XMLElement* pElement = + static_cast(pNode->GetXMLMappingNode()); if (!pElement || pElement->GetType() != FDE_XMLNODE_Element) { return FALSE; } @@ -548,8 +549,8 @@ FX_BOOL CXFA_DataExporter::Export(IFX_Stream* pStream, break; } } - IFDE_XMLElement* pElement = - (IFDE_XMLElement*)pExportNode->GetXMLMappingNode(); + CFDE_XMLElement* pElement = + static_cast(pExportNode->GetXMLMappingNode()); if (!pElement || pElement->GetType() != FDE_XMLNODE_Element) { return FALSE; } @@ -574,16 +575,16 @@ void XFA_DataExporter_DealWithDataGroupNode(CXFA_Node* pDataNode) { } if (pDataNode->GetClassID() == XFA_ELEMENT_DataGroup) { if (iChildNum > 0) { - IFDE_XMLNode* pXMLNode = pDataNode->GetXMLMappingNode(); + CFDE_XMLNode* pXMLNode = pDataNode->GetXMLMappingNode(); FXSYS_assert(pXMLNode->GetType() == FDE_XMLNODE_Element); - IFDE_XMLElement* pXMLElement = (IFDE_XMLElement*)pXMLNode; + CFDE_XMLElement* pXMLElement = static_cast(pXMLNode); if (pXMLElement->HasAttribute(L"xfa:dataNode")) { pXMLElement->RemoveAttribute(L"xfa:dataNode"); } } else { - IFDE_XMLNode* pXMLNode = pDataNode->GetXMLMappingNode(); + CFDE_XMLNode* pXMLNode = pDataNode->GetXMLMappingNode(); FXSYS_assert(pXMLNode->GetType() == FDE_XMLNODE_Element); - ((IFDE_XMLElement*)pXMLNode) + static_cast(pXMLNode) ->SetString(FX_WSTRC(L"xfa:dataNode"), FX_WSTRC(L"dataGroup")); } } diff --git a/xfa/fxfa/parser/xfa_object.h b/xfa/fxfa/parser/xfa_object.h index a41cf4af2a..3279941a4a 100644 --- a/xfa/fxfa/parser/xfa_object.h +++ b/xfa/fxfa/parser/xfa_object.h @@ -138,9 +138,9 @@ class CXFA_Node : public CXFA_Object { FX_BOOL IsFormContainer() { return m_ePacket == XFA_XDPPACKET_Form && IsContainerNode(); } - void SetXMLMappingNode(IFDE_XMLNode* pXMLNode) { m_pXMLNode = pXMLNode; } - IFDE_XMLNode* GetXMLMappingNode() const { return m_pXMLNode; } - IFDE_XMLNode* CreateXMLMappingNode(); + void SetXMLMappingNode(CFDE_XMLNode* pXMLNode) { m_pXMLNode = pXMLNode; } + CFDE_XMLNode* GetXMLMappingNode() const { return m_pXMLNode; } + CFDE_XMLNode* CreateXMLMappingNode(); FX_BOOL IsNeedSavingXMLNode(); uint32_t GetNameHash() const { return m_dwNameHash; } bool IsUnnamed() const { return m_dwNameHash == 0; } @@ -638,7 +638,7 @@ class CXFA_Node : public CXFA_Object { CXFA_Node* m_pChild; CXFA_Node* m_pLastChild; CXFA_Node* m_pParent; - IFDE_XMLNode* m_pXMLNode; + CFDE_XMLNode* m_pXMLNode; XFA_ELEMENT m_eNodeClass; uint16_t m_ePacket; uint32_t m_dwNameHash; diff --git a/xfa/fxfa/parser/xfa_object_imp.cpp b/xfa/fxfa/parser/xfa_object_imp.cpp index fad2b26d4e..eed5323ab8 100644 --- a/xfa/fxfa/parser/xfa_object_imp.cpp +++ b/xfa/fxfa/parser/xfa_object_imp.cpp @@ -7,6 +7,7 @@ #include "xfa/fxfa/parser/xfa_object.h" #include "core/fxcrt/include/fx_ext.h" +#include "xfa/fde/xml/fde_xml_imp.h" #include "xfa/fgas/crt/fgas_codepage.h" #include "xfa/fgas/crt/fgas_system.h" #include "xfa/fxfa/fm2js/xfa_fm2jsapi.h" @@ -124,11 +125,11 @@ CXFA_Node* CXFA_Node::Clone(FX_BOOL bRecursive) { MergeAllData(pClone); pClone->UpdateNameHash(); if (IsNeedSavingXMLNode()) { - IFDE_XMLNode* pCloneXML = NULL; + CFDE_XMLNode* pCloneXML = NULL; if (IsAttributeInXML()) { CFX_WideString wsName; GetAttribute(XFA_ATTRIBUTE_Name, wsName, FALSE); - IFDE_XMLElement* pCloneXMLElement = IFDE_XMLElement::Create(wsName); + CFDE_XMLElement* pCloneXMLElement = new CFDE_XMLElement(wsName); CFX_WideStringC wsValue = GetCData(XFA_ATTRIBUTE_Value); if (!wsValue.IsEmpty()) { pCloneXMLElement->SetTextData(wsValue); @@ -962,15 +963,16 @@ void CXFA_Node::Script_NodeClass_LoadXML(CFXJSE_Arguments* pArguments) { if (!pParser) { return; } - IFDE_XMLNode* pXMLNode = NULL; + CFDE_XMLNode* pXMLNode = NULL; int32_t iParserStatus = pParser->ParseXMLData(wsExpression, pXMLNode, NULL); if (iParserStatus != XFA_PARSESTATUS_Done || !pXMLNode) { pParser->Release(); pParser = NULL; return; } - if (bIgnoreRoot && (pXMLNode->GetType() != FDE_XMLNODE_Element || - XFA_RecognizeRichText((IFDE_XMLElement*)pXMLNode))) { + if (bIgnoreRoot && + (pXMLNode->GetType() != FDE_XMLNODE_Element || + XFA_RecognizeRichText(static_cast(pXMLNode)))) { bIgnoreRoot = FALSE; } CXFA_Node* pFakeRoot = Clone(FALSE); @@ -978,27 +980,27 @@ void CXFA_Node::Script_NodeClass_LoadXML(CFXJSE_Arguments* pArguments) { if (!wsContentType.IsEmpty()) { pFakeRoot->SetCData(XFA_ATTRIBUTE_ContentType, wsContentType); } - IFDE_XMLNode* pFakeXMLRoot = pFakeRoot->GetXMLMappingNode(); + CFDE_XMLNode* pFakeXMLRoot = pFakeRoot->GetXMLMappingNode(); if (!pFakeXMLRoot) { - IFDE_XMLNode* pThisXMLRoot = GetXMLMappingNode(); + CFDE_XMLNode* pThisXMLRoot = GetXMLMappingNode(); pFakeXMLRoot = pThisXMLRoot ? pThisXMLRoot->Clone(FALSE) : NULL; } if (!pFakeXMLRoot) { CFX_WideStringC wsClassName; GetClassName(wsClassName); - pFakeXMLRoot = IFDE_XMLElement::Create(wsClassName); + pFakeXMLRoot = new CFDE_XMLElement(wsClassName); } if (bIgnoreRoot) { - IFDE_XMLNode* pXMLChild = pXMLNode->GetNodeItem(IFDE_XMLNode::FirstChild); + CFDE_XMLNode* pXMLChild = pXMLNode->GetNodeItem(CFDE_XMLNode::FirstChild); while (pXMLChild) { - IFDE_XMLNode* pXMLSibling = - pXMLChild->GetNodeItem(IFDE_XMLNode::NextSibling); + CFDE_XMLNode* pXMLSibling = + pXMLChild->GetNodeItem(CFDE_XMLNode::NextSibling); pXMLNode->RemoveChildNode(pXMLChild); pFakeXMLRoot->InsertChildNode(pXMLChild); pXMLChild = pXMLSibling; } } else { - IFDE_XMLNode* pXMLParent = pXMLNode->GetNodeItem(IFDE_XMLNode::Parent); + CFDE_XMLNode* pXMLParent = pXMLNode->GetNodeItem(CFDE_XMLNode::Parent); if (pXMLParent) { pXMLParent->RemoveChildNode(pXMLNode); } @@ -1026,11 +1028,11 @@ void CXFA_Node::Script_NodeClass_LoadXML(CFXJSE_Arguments* pArguments) { } if (GetPacketID() == XFA_XDPPACKET_Form && GetClassID() == XFA_ELEMENT_ExData) { - IFDE_XMLNode* pTempXMLNode = GetXMLMappingNode(); + CFDE_XMLNode* pTempXMLNode = GetXMLMappingNode(); SetXMLMappingNode(pFakeXMLRoot); SetFlag(XFA_NODEFLAG_OwnXMLNode, TRUE, FALSE); if (pTempXMLNode && - pTempXMLNode->GetNodeItem(IFDE_XMLNode::Parent) == NULL) { + pTempXMLNode->GetNodeItem(CFDE_XMLNode::Parent) == NULL) { pFakeXMLRoot = pTempXMLNode; } else { pFakeXMLRoot = NULL; @@ -1106,7 +1108,7 @@ void CXFA_Node::Script_NodeClass_SaveXML(CFXJSE_Arguments* pArguments) { return; } if (GetPacketID() == XFA_XDPPACKET_Datasets) { - IFDE_XMLNode* pElement = GetXMLMappingNode(); + CFDE_XMLNode* pElement = GetXMLMappingNode(); if (!pElement || pElement->GetType() != FDE_XMLNODE_Element) { FXJSE_Value_SetUTF8String(pArguments->GetReturnValue(), bsXMLHeader); return; @@ -3500,9 +3502,9 @@ void CXFA_Node::Script_Packet_GetAttribute(CFXJSE_Arguments* pArguments) { if (argc == 1) { CFX_ByteString bsAttributeName = pArguments->GetUTF8String(0); CFX_WideString wsAttributeValue; - IFDE_XMLNode* pXMLNode = GetXMLMappingNode(); + CFDE_XMLNode* pXMLNode = GetXMLMappingNode(); if (pXMLNode && pXMLNode->GetType() == FDE_XMLNODE_Element) { - ((IFDE_XMLElement*)pXMLNode) + static_cast(pXMLNode) ->GetString(CFX_WideString::FromUTF8(bsAttributeName, bsAttributeName.GetLength()), wsAttributeValue); @@ -3520,9 +3522,9 @@ void CXFA_Node::Script_Packet_SetAttribute(CFXJSE_Arguments* pArguments) { if (argc == 2) { CFX_ByteString bsValue = pArguments->GetUTF8String(0); CFX_ByteString bsName = pArguments->GetUTF8String(1); - IFDE_XMLNode* pXMLNode = GetXMLMappingNode(); + CFDE_XMLNode* pXMLNode = GetXMLMappingNode(); if (pXMLNode && pXMLNode->GetType() == FDE_XMLNODE_Element) { - ((IFDE_XMLElement*)pXMLNode) + static_cast(pXMLNode) ->SetString(CFX_WideString::FromUTF8(bsName, bsName.GetLength()), CFX_WideString::FromUTF8(bsValue, bsValue.GetLength())); } @@ -3538,9 +3540,9 @@ void CXFA_Node::Script_Packet_RemoveAttribute(CFXJSE_Arguments* pArguments) { CFX_ByteString bsName = pArguments->GetUTF8String(0); CFX_WideString wsName = CFX_WideString::FromUTF8(bsName, bsName.GetLength()); - IFDE_XMLNode* pXMLNode = GetXMLMappingNode(); + CFDE_XMLNode* pXMLNode = GetXMLMappingNode(); if (pXMLNode && pXMLNode->GetType() == FDE_XMLNODE_Element) { - IFDE_XMLElement* pXMLElement = (IFDE_XMLElement*)pXMLNode; + CFDE_XMLElement* pXMLElement = static_cast(pXMLNode); if (pXMLElement->HasAttribute(wsName)) { pXMLElement->RemoveAttribute(wsName); } @@ -3557,17 +3559,17 @@ void CXFA_Node::Script_Packet_Content(FXJSE_HVALUE hValue, if (bSetting) { CFX_ByteString bsNewContent; FXJSE_Value_ToUTF8String(hValue, bsNewContent); - IFDE_XMLNode* pXMLNode = GetXMLMappingNode(); + CFDE_XMLNode* pXMLNode = GetXMLMappingNode(); if (pXMLNode && pXMLNode->GetType() == FDE_XMLNODE_Element) { - IFDE_XMLElement* pXMLElement = (IFDE_XMLElement*)pXMLNode; + CFDE_XMLElement* pXMLElement = static_cast(pXMLNode); pXMLElement->SetTextData( CFX_WideString::FromUTF8(bsNewContent, bsNewContent.GetLength())); } } else { CFX_WideString wsTextData; - IFDE_XMLNode* pXMLNode = GetXMLMappingNode(); + CFDE_XMLNode* pXMLNode = GetXMLMappingNode(); if (pXMLNode && pXMLNode->GetType() == FDE_XMLNODE_Element) { - IFDE_XMLElement* pXMLElement = (IFDE_XMLElement*)pXMLNode; + CFDE_XMLElement* pXMLElement = static_cast(pXMLNode); pXMLElement->GetTextData(wsTextData); } FXJSE_Value_SetUTF8String( @@ -3960,7 +3962,7 @@ FX_BOOL CXFA_Node::SetCData(XFA_ATTRIBUTE eAttr, switch (eXMLType) { case FDE_XMLNODE_Element: if (IsAttributeInXML()) { - ((IFDE_XMLElement*)m_pXMLNode) + static_cast(m_pXMLNode) ->SetString(GetCData(XFA_ATTRIBUTE_QualifiedName), wsValue); } else { FX_BOOL bDeleteChildren = TRUE; @@ -3977,13 +3979,13 @@ FX_BOOL CXFA_Node::SetCData(XFA_ATTRIBUTE eAttr, } } if (bDeleteChildren) { - ((IFDE_XMLElement*)m_pXMLNode)->DeleteChildren(); + static_cast(m_pXMLNode)->DeleteChildren(); } - ((IFDE_XMLElement*)m_pXMLNode)->SetTextData(wsValue); + static_cast(m_pXMLNode)->SetTextData(wsValue); } break; case FDE_XMLNODE_Text: - ((IFDE_XMLText*)m_pXMLNode)->SetText(wsValue); + static_cast(m_pXMLNode)->SetText(wsValue); break; default: FXSYS_assert(0); @@ -3997,7 +3999,7 @@ FX_BOOL CXFA_Node::SetCData(XFA_ATTRIBUTE eAttr, if (pInfo->eName == XFA_ATTRIBUTE_ContentType) { wsAttrName = FX_WSTRC(L"xfa:") + wsAttrName; } - ((IFDE_XMLElement*)m_pXMLNode)->SetString(wsAttrName, wsValue); + static_cast(m_pXMLNode)->SetString(wsAttrName, wsValue); } } return TRUE; @@ -4017,7 +4019,7 @@ FX_BOOL CXFA_Node::SetAttributeValue(const CFX_WideString& wsValue, switch (eXMLType) { case FDE_XMLNODE_Element: if (IsAttributeInXML()) { - ((IFDE_XMLElement*)m_pXMLNode) + static_cast(m_pXMLNode) ->SetString(GetCData(XFA_ATTRIBUTE_QualifiedName), wsXMLValue); } else { FX_BOOL bDeleteChildren = TRUE; @@ -4034,13 +4036,13 @@ FX_BOOL CXFA_Node::SetAttributeValue(const CFX_WideString& wsValue, } } if (bDeleteChildren) { - ((IFDE_XMLElement*)m_pXMLNode)->DeleteChildren(); + static_cast(m_pXMLNode)->DeleteChildren(); } - ((IFDE_XMLElement*)m_pXMLNode)->SetTextData(wsXMLValue); + static_cast(m_pXMLNode)->SetTextData(wsXMLValue); } break; case FDE_XMLNODE_Text: - ((IFDE_XMLText*)m_pXMLNode)->SetText(wsXMLValue); + static_cast(m_pXMLNode)->SetText(wsXMLValue); break; default: FXSYS_assert(0); @@ -4129,19 +4131,19 @@ FX_BOOL CXFA_Node::SetValue(XFA_ATTRIBUTE eAttr, if (pInfo) { switch (eType) { case XFA_ATTRIBUTETYPE_Enum: - ((IFDE_XMLElement*)m_pXMLNode) + static_cast(m_pXMLNode) ->SetString( pInfo->pName, XFA_GetAttributeEnumByID((XFA_ATTRIBUTEENUM)(uintptr_t)pValue) ->pName); break; case XFA_ATTRIBUTETYPE_Boolean: - ((IFDE_XMLElement*)m_pXMLNode) + static_cast(m_pXMLNode) ->SetString(pInfo->pName, pValue ? FX_WSTRC(L"1") : FX_WSTRC(L"0")); break; case XFA_ATTRIBUTETYPE_Integer: - ((IFDE_XMLElement*)m_pXMLNode) + static_cast(m_pXMLNode) ->SetInteger(pInfo->pName, (int32_t)(uintptr_t)pValue); break; default: @@ -4464,14 +4466,14 @@ FX_BOOL CXFA_Node::TryNamespace(CFX_WideString& wsNamespace) { wsNamespace.Empty(); if (GetObjectType() == XFA_OBJECTTYPE_ModelNode || GetClassID() == XFA_ELEMENT_Packet) { - IFDE_XMLNode* pXMLNode = GetXMLMappingNode(); + CFDE_XMLNode* pXMLNode = GetXMLMappingNode(); if (!pXMLNode || pXMLNode->GetType() != FDE_XMLNODE_Element) { return FALSE; } - ((IFDE_XMLElement*)pXMLNode)->GetNamespaceURI(wsNamespace); + static_cast(pXMLNode)->GetNamespaceURI(wsNamespace); return TRUE; } else if (GetPacketID() == XFA_XDPPACKET_Datasets) { - IFDE_XMLNode* pXMLNode = GetXMLMappingNode(); + CFDE_XMLNode* pXMLNode = GetXMLMappingNode(); if (!pXMLNode) { return FALSE; } @@ -4481,10 +4483,10 @@ FX_BOOL CXFA_Node::TryNamespace(CFX_WideString& wsNamespace) { if (GetClassID() == XFA_ELEMENT_DataValue && GetEnum(XFA_ATTRIBUTE_Contains) == XFA_ATTRIBUTEENUM_MetaData) { return XFA_FDEExtension_ResolveNamespaceQualifier( - (IFDE_XMLElement*)pXMLNode, GetCData(XFA_ATTRIBUTE_QualifiedName), - wsNamespace); + static_cast(pXMLNode), + GetCData(XFA_ATTRIBUTE_QualifiedName), wsNamespace); } - ((IFDE_XMLElement*)pXMLNode)->GetNamespaceURI(wsNamespace); + static_cast(pXMLNode)->GetNamespaceURI(wsNamespace); return TRUE; } else { CXFA_Node* pModelNode = GetModelNode(); @@ -4617,7 +4619,7 @@ int32_t CXFA_Node::InsertChild(int32_t index, CXFA_Node* pNode) { pNotify->OnNodeEvent(this, XFA_NODEEVENT_ChildAdded, pNode); } if (IsNeedSavingXMLNode() && pNode->m_pXMLNode) { - FXSYS_assert(pNode->m_pXMLNode->GetNodeItem(IFDE_XMLNode::Parent) == NULL); + FXSYS_assert(pNode->m_pXMLNode->GetNodeItem(CFDE_XMLNode::Parent) == NULL); m_pXMLNode->InsertChildNode(pNode->m_pXMLNode, index); pNode->SetFlag(XFA_NODEFLAG_OwnXMLNode, FALSE, FALSE); } @@ -4663,7 +4665,7 @@ FX_BOOL CXFA_Node::InsertChild(CXFA_Node* pNode, CXFA_Node* pBeforeNode) { pNotify->OnNodeEvent(this, XFA_NODEEVENT_ChildAdded, pNode); } if (IsNeedSavingXMLNode() && pNode->m_pXMLNode) { - FXSYS_assert(pNode->m_pXMLNode->GetNodeItem(IFDE_XMLNode::Parent) == NULL); + FXSYS_assert(pNode->m_pXMLNode->GetNodeItem(CFDE_XMLNode::Parent) == NULL); m_pXMLNode->InsertChildNode(pNode->m_pXMLNode, nIndex); pNode->SetFlag(XFA_NODEFLAG_OwnXMLNode, FALSE, FALSE); } @@ -4711,14 +4713,15 @@ FX_BOOL CXFA_Node::RemoveChild(CXFA_Node* pNode, FX_BOOL bNotify) { FXSYS_assert(pNode->m_pXMLNode == m_pXMLNode && m_pXMLNode->GetType() == FDE_XMLNODE_Element); if (pNode->m_pXMLNode->GetType() == FDE_XMLNODE_Element) { - IFDE_XMLElement* pXMLElement = (IFDE_XMLElement*)(pNode->m_pXMLNode); + CFDE_XMLElement* pXMLElement = + static_cast(pNode->m_pXMLNode); CFX_WideStringC wsAttributeName = pNode->GetCData(XFA_ATTRIBUTE_QualifiedName); pXMLElement->RemoveAttribute(wsAttributeName.GetPtr()); } CFX_WideString wsName; pNode->GetAttribute(XFA_ATTRIBUTE_Name, wsName, FALSE); - IFDE_XMLElement* pNewXMLElement = IFDE_XMLElement::Create(wsName); + CFDE_XMLElement* pNewXMLElement = new CFDE_XMLElement(wsName); CFX_WideStringC wsValue = GetCData(XFA_ATTRIBUTE_Value); if (!wsValue.IsEmpty()) { pNewXMLElement->SetTextData(wsValue); @@ -4971,10 +4974,10 @@ void CXFA_Node::UpdateNameHash() { wsName.GetLength()); } } -IFDE_XMLNode* CXFA_Node::CreateXMLMappingNode() { +CFDE_XMLNode* CXFA_Node::CreateXMLMappingNode() { if (!m_pXMLNode) { CFX_WideStringC wsTag = GetCData(XFA_ATTRIBUTE_Name); - m_pXMLNode = IFDE_XMLElement::Create(wsTag); + m_pXMLNode = new CFDE_XMLElement(wsTag); SetFlag(XFA_NODEFLAG_OwnXMLNode, TRUE, FALSE); } return m_pXMLNode; diff --git a/xfa/fxfa/parser/xfa_parser.h b/xfa/fxfa/parser/xfa_parser.h index 2d45e5f9c8..86a0d9d94f 100644 --- a/xfa/fxfa/parser/xfa_parser.h +++ b/xfa/fxfa/parser/xfa_parser.h @@ -9,6 +9,8 @@ #include "xfa/fxfa/parser/xfa_document.h" +class CFDE_XMLDoc; + class IXFA_Parser { public: static IXFA_Parser* Create(IXFA_ObjFactory* pFactory, @@ -19,13 +21,13 @@ class IXFA_Parser { XFA_XDPPACKET ePacketID = XFA_XDPPACKET_XDP) = 0; virtual int32_t DoParse(IFX_Pause* pPause = NULL) = 0; virtual int32_t ParseXMLData(const CFX_WideString& wsXML, - IFDE_XMLNode*& pXMLNode, + CFDE_XMLNode*& pXMLNode, IFX_Pause* pPause = NULL) = 0; virtual void ConstructXFANode(CXFA_Node* pXFANode, - IFDE_XMLNode* pXMLNode) = 0; + CFDE_XMLNode* pXMLNode) = 0; virtual IXFA_ObjFactory* GetFactory() const = 0; virtual CXFA_Node* GetRootNode() const = 0; - virtual IFDE_XMLDoc* GetXMLDoc() const = 0; + virtual CFDE_XMLDoc* GetXMLDoc() const = 0; virtual void CloseParser() = 0; }; class IXFA_DocParser : public IXFA_Parser { diff --git a/xfa/fxfa/parser/xfa_parser_imp.cpp b/xfa/fxfa/parser/xfa_parser_imp.cpp index efddc427a6..75198dc443 100644 --- a/xfa/fxfa/parser/xfa_parser_imp.cpp +++ b/xfa/fxfa/parser/xfa_parser_imp.cpp @@ -6,6 +6,7 @@ #include "xfa/fxfa/parser/xfa_parser_imp.h" +#include "xfa/fde/xml/fde_xml_imp.h" #include "xfa/fgas/crt/fgas_codepage.h" #include "xfa/fxfa/fm2js/xfa_fm2jsapi.h" #include "xfa/fxfa/parser/xfa_basic_imp.h" @@ -38,22 +39,22 @@ CXFA_SimpleParser::~CXFA_SimpleParser() { void CXFA_SimpleParser::SetFactory(IXFA_ObjFactory* pFactory) { m_pFactory = pFactory; } -static IFDE_XMLNode* XFA_FDEExtension_GetDocumentNode( - IFDE_XMLDoc* pXMLDoc, +static CFDE_XMLNode* XFA_FDEExtension_GetDocumentNode( + CFDE_XMLDoc* pXMLDoc, FX_BOOL bVerifyWellFormness = FALSE) { if (!pXMLDoc) { return NULL; } - IFDE_XMLNode* pXMLFakeRoot = pXMLDoc->GetRoot(); - for (IFDE_XMLNode* pXMLNode = - pXMLFakeRoot->GetNodeItem(IFDE_XMLNode::FirstChild); - pXMLNode; pXMLNode = pXMLNode->GetNodeItem(IFDE_XMLNode::NextSibling)) { + CFDE_XMLNode* pXMLFakeRoot = pXMLDoc->GetRoot(); + for (CFDE_XMLNode* pXMLNode = + pXMLFakeRoot->GetNodeItem(CFDE_XMLNode::FirstChild); + pXMLNode; pXMLNode = pXMLNode->GetNodeItem(CFDE_XMLNode::NextSibling)) { if (pXMLNode->GetType() == FDE_XMLNODE_Element) { if (bVerifyWellFormness) { - for (IFDE_XMLNode* pNextNode = - pXMLNode->GetNodeItem(IFDE_XMLNode::NextSibling); + for (CFDE_XMLNode* pNextNode = + pXMLNode->GetNodeItem(CFDE_XMLNode::NextSibling); pNextNode; - pNextNode = pNextNode->GetNodeItem(IFDE_XMLNode::NextSibling)) { + pNextNode = pNextNode->GetNodeItem(CFDE_XMLNode::NextSibling)) { if (pNextNode->GetType() == FDE_XMLNODE_Element) { return FALSE; } @@ -78,14 +79,8 @@ int32_t CXFA_SimpleParser::StartParse(IFX_FileRead* pStream, wCodePage != FX_CODEPAGE_UTF8) { m_pStream->SetCodePage(FX_CODEPAGE_UTF8); } - m_pXMLDoc = IFDE_XMLDoc::Create(); - if (m_pXMLDoc == NULL) { - return XFA_PARSESTATUS_StatusErr; - } + m_pXMLDoc = new CFDE_XMLDoc; m_pXMLParser = new CXFA_XMLParser(m_pXMLDoc->GetRoot(), m_pStream); - if (m_pXMLParser == NULL) { - return XFA_PARSESTATUS_StatusErr; - } if (!m_pXMLDoc->LoadXML(m_pXMLParser)) { return XFA_PARSESTATUS_StatusErr; } @@ -116,7 +111,7 @@ int32_t CXFA_SimpleParser::DoParse(IFX_Pause* pPause) { return XFA_PARSESTATUS_Done; } int32_t CXFA_SimpleParser::ParseXMLData(const CFX_WideString& wsXML, - IFDE_XMLNode*& pXMLNode, + CFDE_XMLNode*& pXMLNode, IFX_Pause* pPause) { CloseParser(); pXMLNode = NULL; @@ -125,15 +120,8 @@ int32_t CXFA_SimpleParser::ParseXMLData(const CFX_WideString& wsXML, return XFA_PARSESTATUS_StreamErr; } m_pStream = pStream; - m_pXMLDoc = IFDE_XMLDoc::Create(); - if (m_pXMLDoc == NULL) { - return XFA_PARSESTATUS_StatusErr; - } + m_pXMLDoc = new CFDE_XMLDoc; CXFA_XMLParser* pParser = new CXFA_XMLParser(m_pXMLDoc->GetRoot(), m_pStream); - if (pParser == NULL) { - return XFA_PARSESTATUS_StatusErr; - } - pParser->m_dwCheckStatus = 0x03; if (!m_pXMLDoc->LoadXML(pParser)) { return XFA_PARSESTATUS_StatusErr; @@ -157,14 +145,14 @@ int32_t CXFA_SimpleParser::ParseXMLData(const CFX_WideString& wsXML, } void CXFA_SimpleParser::ConstructXFANode(CXFA_Node* pXFANode, - IFDE_XMLNode* pXMLNode) { + CFDE_XMLNode* pXMLNode) { XFA_XDPPACKET ePacketID = (XFA_XDPPACKET)pXFANode->GetPacketID(); if (ePacketID == XFA_XDPPACKET_Datasets) { if (pXFANode->GetClassID() == XFA_ELEMENT_DataValue) { - for (IFDE_XMLNode* pXMLChild = - pXMLNode->GetNodeItem(IFDE_XMLNode::FirstChild); + for (CFDE_XMLNode* pXMLChild = + pXMLNode->GetNodeItem(CFDE_XMLNode::FirstChild); pXMLChild; - pXMLChild = pXMLChild->GetNodeItem(IFDE_XMLNode::NextSibling)) { + pXMLChild = pXMLChild->GetNodeItem(CFDE_XMLNode::NextSibling)) { FDE_XMLNODETYPE eNodeType = pXMLChild->GetType(); if (eNodeType == FDE_XMLNODE_Instruction) continue; @@ -176,11 +164,11 @@ void CXFA_SimpleParser::ConstructXFANode(CXFA_Node* pXFANode, return; CFX_WideString wsNodeStr; - ((IFDE_XMLElement*)pXMLChild)->GetLocalTagName(wsNodeStr); + CFDE_XMLElement* child = static_cast(pXMLChild); + child->GetLocalTagName(wsNodeStr); pXFAChild->SetCData(XFA_ATTRIBUTE_Name, wsNodeStr); CFX_WideString wsChildValue; - XFA_GetPlainTextFromRichText((IFDE_XMLElement*)pXMLChild, - wsChildValue); + XFA_GetPlainTextFromRichText(child, wsChildValue); if (!wsChildValue.IsEmpty()) pXFAChild->SetCData(XFA_ATTRIBUTE_Value, wsChildValue); @@ -203,13 +191,13 @@ void CXFA_SimpleParser::ConstructXFANode(CXFA_Node* pXFANode, } FX_BOOL XFA_FDEExtension_ResolveNamespaceQualifier( - IFDE_XMLElement* pNode, + CFDE_XMLElement* pNode, const CFX_WideStringC& wsQualifier, CFX_WideString& wsNamespaceURI) { if (!pNode) { return FALSE; } - IFDE_XMLNode* pFakeRoot = pNode->GetNodeItem(IFDE_XMLNode::Root); + CFDE_XMLNode* pFakeRoot = pNode->GetNodeItem(CFDE_XMLNode::Root); CFX_WideString wsNSAttribute; FX_BOOL bRet = FALSE; if (wsQualifier.IsEmpty()) { @@ -218,8 +206,8 @@ FX_BOOL XFA_FDEExtension_ResolveNamespaceQualifier( } else { wsNSAttribute = FX_WSTRC(L"xmlns:") + wsQualifier; } - for (; pNode != pFakeRoot; - pNode = (IFDE_XMLElement*)pNode->GetNodeItem(IFDE_XMLNode::Parent)) { + for (; pNode != pFakeRoot; pNode = static_cast( + pNode->GetNodeItem(CFDE_XMLNode::Parent))) { if (pNode->GetType() != FDE_XMLNODE_Element) { continue; } @@ -232,7 +220,7 @@ FX_BOOL XFA_FDEExtension_ResolveNamespaceQualifier( return bRet; } static inline void XFA_FDEExtension_GetElementTagNamespaceURI( - IFDE_XMLElement* pElement, + CFDE_XMLElement* pElement, CFX_WideString& wsNamespaceURI) { CFX_WideString wsNodeStr; pElement->GetNamespacePrefix(wsNodeStr); @@ -242,14 +230,14 @@ static inline void XFA_FDEExtension_GetElementTagNamespaceURI( } } static FX_BOOL XFA_FDEExtension_MatchNodeName( - IFDE_XMLNode* pNode, + CFDE_XMLNode* pNode, const CFX_WideStringC& wsLocalTagName, const CFX_WideStringC& wsNamespaceURIPrefix, uint32_t eMatchFlags = XFA_XDPPACKET_FLAGS_NOMATCH) { if (!pNode || pNode->GetType() != FDE_XMLNODE_Element) { return FALSE; } - IFDE_XMLElement* pElement = reinterpret_cast(pNode); + CFDE_XMLElement* pElement = reinterpret_cast(pNode); CFX_WideString wsNodeStr; pElement->GetLocalTagName(wsNodeStr); if (wsNodeStr != wsLocalTagName) { @@ -279,7 +267,7 @@ static FX_BOOL XFA_FDEExtension_GetAttributeLocalName( } } static FX_BOOL XFA_FDEExtension_ResolveAttribute( - IFDE_XMLElement* pElement, + CFDE_XMLElement* pElement, const CFX_WideStringC& wsAttributeName, CFX_WideString& wsLocalAttrName, CFX_WideString& wsNamespaceURI) { @@ -302,7 +290,7 @@ static FX_BOOL XFA_FDEExtension_ResolveAttribute( return TRUE; } static FX_BOOL XFA_FDEExtension_FindAttributeWithNS( - IFDE_XMLElement* pElement, + CFDE_XMLElement* pElement, const CFX_WideStringC& wsLocalAttributeName, const CFX_WideStringC& wsNamespaceURIPrefix, CFX_WideString& wsValue, @@ -348,7 +336,7 @@ static FX_BOOL XFA_FDEExtension_FindAttributeWithNS( } return FALSE; } -CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket(IFDE_XMLNode* pXMLDocumentNode, +CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket(CFDE_XMLNode* pXMLDocumentNode, XFA_XDPPACKET ePacketID) { switch (ePacketID) { case XFA_XDPPACKET_UNKNOWN: @@ -375,7 +363,7 @@ CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket(IFDE_XMLNode* pXMLDocumentNode, return NULL; } CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_XDP( - IFDE_XMLNode* pXMLDocumentNode, + CFDE_XMLNode* pXMLDocumentNode, XFA_XDPPACKET ePacketID) { if (!XFA_FDEExtension_MatchNodeName( pXMLDocumentNode, XFA_GetPacketByIndex(XFA_PACKET_XDP)->pName, @@ -391,7 +379,7 @@ CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_XDP( m_pRootNode = pXFARootNode; pXFARootNode->SetCData(XFA_ATTRIBUTE_Name, FX_WSTRC(L"xfa")); { - IFDE_XMLElement* pElement = (IFDE_XMLElement*)pXMLDocumentNode; + CFDE_XMLElement* pElement = static_cast(pXMLDocumentNode); int32_t iAttributeCount = pElement->CountAttributes(); for (int32_t i = 0; i < iAttributeCount; i++) { CFX_WideString wsAttriName, wsAttriValue; @@ -403,13 +391,13 @@ CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_XDP( } } } - IFDE_XMLNode* pXMLConfigDOMRoot = nullptr; + CFDE_XMLNode* pXMLConfigDOMRoot = nullptr; CXFA_Node* pXFAConfigDOMRoot = nullptr; { - for (IFDE_XMLNode* pChildItem = - pXMLDocumentNode->GetNodeItem(IFDE_XMLNode::FirstChild); + for (CFDE_XMLNode* pChildItem = + pXMLDocumentNode->GetNodeItem(CFDE_XMLNode::FirstChild); pChildItem; - pChildItem = pChildItem->GetNodeItem(IFDE_XMLNode::NextSibling)) { + pChildItem = pChildItem->GetNodeItem(CFDE_XMLNode::NextSibling)) { const XFA_PACKETINFO* pPacketInfo = XFA_GetPacketByIndex(XFA_PACKET_Config); if (!XFA_FDEExtension_MatchNodeName(pChildItem, pPacketInfo->pName, @@ -426,22 +414,22 @@ CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_XDP( pXFARootNode->InsertChild(pXFAConfigDOMRoot, NULL); } } - IFDE_XMLNode* pXMLDatasetsDOMRoot = nullptr; - IFDE_XMLNode* pXMLFormDOMRoot = nullptr; - IFDE_XMLNode* pXMLTemplateDOMRoot = nullptr; + CFDE_XMLNode* pXMLDatasetsDOMRoot = nullptr; + CFDE_XMLNode* pXMLFormDOMRoot = nullptr; + CFDE_XMLNode* pXMLTemplateDOMRoot = nullptr; { - for (IFDE_XMLNode* pChildItem = - pXMLDocumentNode->GetNodeItem(IFDE_XMLNode::FirstChild); + for (CFDE_XMLNode* pChildItem = + pXMLDocumentNode->GetNodeItem(CFDE_XMLNode::FirstChild); pChildItem; - pChildItem = pChildItem->GetNodeItem(IFDE_XMLNode::NextSibling)) { + pChildItem = pChildItem->GetNodeItem(CFDE_XMLNode::NextSibling)) { if (!pChildItem || pChildItem->GetType() != FDE_XMLNODE_Element) { continue; } if (pChildItem == pXMLConfigDOMRoot) { continue; } - IFDE_XMLElement* pElement = - reinterpret_cast(pChildItem); + CFDE_XMLElement* pElement = + reinterpret_cast(pChildItem); CFX_WideString wsPacketName; pElement->GetLocalTagName(wsPacketName); const XFA_PACKETINFO* pPacketInfo = XFA_GetPacketByName(wsPacketName); @@ -512,7 +500,7 @@ CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_XDP( return pXFARootNode; } CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_Config( - IFDE_XMLNode* pXMLDocumentNode, + CFDE_XMLNode* pXMLDocumentNode, XFA_XDPPACKET ePacketID) { if (!XFA_FDEExtension_MatchNodeName( pXMLDocumentNode, XFA_GetPacketByIndex(XFA_PACKET_Config)->pName, @@ -534,7 +522,7 @@ CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_Config( return pNode; } CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_TemplateForm( - IFDE_XMLNode* pXMLDocumentNode, + CFDE_XMLNode* pXMLDocumentNode, XFA_XDPPACKET ePacketID) { CXFA_Node* pNode = NULL; if (ePacketID == XFA_XDPPACKET_Template) { @@ -551,8 +539,8 @@ CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_TemplateForm( XFA_GetPacketByIndex(XFA_PACKET_Template)->pName); if (m_bDocumentParser) { CFX_WideString wsNamespaceURI; - IFDE_XMLElement* pXMLDocumentElement = - (IFDE_XMLElement*)pXMLDocumentNode; + CFDE_XMLElement* pXMLDocumentElement = + static_cast(pXMLDocumentNode); pXMLDocumentElement->GetNamespaceURI(wsNamespaceURI); if (wsNamespaceURI.IsEmpty()) { pXMLDocumentElement->GetString(L"xmlns:xfa", wsNamespaceURI); @@ -568,7 +556,8 @@ CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_TemplateForm( pXMLDocumentNode, XFA_GetPacketByIndex(XFA_PACKET_Form)->pName, XFA_GetPacketByIndex(XFA_PACKET_Form)->pURI, XFA_GetPacketByIndex(XFA_PACKET_Form)->eFlags)) { - IFDE_XMLElement* pXMLDocumentElement = (IFDE_XMLElement*)pXMLDocumentNode; + CFDE_XMLElement* pXMLDocumentElement = + static_cast(pXMLDocumentNode); CFX_WideString wsChecksum; pXMLDocumentElement->GetString(L"checksum", wsChecksum); if (wsChecksum.GetLength() != 28 || @@ -618,7 +607,7 @@ CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_TemplateForm( } return pNode; } -static IFDE_XMLNode* XFA_GetDataSetsFromXDP(IFDE_XMLNode* pXMLDocumentNode) { +static CFDE_XMLNode* XFA_GetDataSetsFromXDP(CFDE_XMLNode* pXMLDocumentNode) { if (XFA_FDEExtension_MatchNodeName( pXMLDocumentNode, XFA_GetPacketByIndex(XFA_PACKET_Datasets)->pName, XFA_GetPacketByIndex(XFA_PACKET_Datasets)->pURI, @@ -631,10 +620,10 @@ static IFDE_XMLNode* XFA_GetDataSetsFromXDP(IFDE_XMLNode* pXMLDocumentNode) { XFA_GetPacketByIndex(XFA_PACKET_XDP)->eFlags)) { return NULL; } - for (IFDE_XMLNode* pDatasetsNode = - pXMLDocumentNode->GetNodeItem(IFDE_XMLNode::FirstChild); + for (CFDE_XMLNode* pDatasetsNode = + pXMLDocumentNode->GetNodeItem(CFDE_XMLNode::FirstChild); pDatasetsNode; - pDatasetsNode = pDatasetsNode->GetNodeItem(IFDE_XMLNode::NextSibling)) { + pDatasetsNode = pDatasetsNode->GetNodeItem(CFDE_XMLNode::NextSibling)) { if (!XFA_FDEExtension_MatchNodeName( pDatasetsNode, XFA_GetPacketByIndex(XFA_PACKET_Datasets)->pName, XFA_GetPacketByIndex(XFA_PACKET_Datasets)->pURI, @@ -646,9 +635,9 @@ static IFDE_XMLNode* XFA_GetDataSetsFromXDP(IFDE_XMLNode* pXMLDocumentNode) { return NULL; } CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_Data( - IFDE_XMLNode* pXMLDocumentNode, + CFDE_XMLNode* pXMLDocumentNode, XFA_XDPPACKET ePacketID) { - IFDE_XMLNode* pDatasetsXMLNode = XFA_GetDataSetsFromXDP(pXMLDocumentNode); + CFDE_XMLNode* pDatasetsXMLNode = XFA_GetDataSetsFromXDP(pXMLDocumentNode); if (pDatasetsXMLNode) { CXFA_Node* pNode = m_pFactory->CreateNode(XFA_XDPPACKET_Datasets, XFA_ELEMENT_DataModel); @@ -663,24 +652,25 @@ CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_Data( pNode->SetXMLMappingNode(pDatasetsXMLNode); return pNode; } - IFDE_XMLNode* pDataXMLNode = NULL; + CFDE_XMLNode* pDataXMLNode = NULL; if (XFA_FDEExtension_MatchNodeName( pXMLDocumentNode, FX_WSTRC(L"data"), XFA_GetPacketByIndex(XFA_PACKET_Datasets)->pURI, XFA_GetPacketByIndex(XFA_PACKET_Datasets)->eFlags)) { - ((IFDE_XMLElement*)pXMLDocumentNode)->RemoveAttribute(L"xmlns:xfa"); + static_cast(pXMLDocumentNode) + ->RemoveAttribute(L"xmlns:xfa"); pDataXMLNode = pXMLDocumentNode; } else { - IFDE_XMLElement* pDataElement = - IFDE_XMLElement::Create(FX_WSTRC(L"xfa:data")); - IFDE_XMLNode* pParentXMLNode = - pXMLDocumentNode->GetNodeItem(IFDE_XMLNode::Parent); + CFDE_XMLElement* pDataElement = new CFDE_XMLElement(FX_WSTRC(L"xfa:data")); + CFDE_XMLNode* pParentXMLNode = + pXMLDocumentNode->GetNodeItem(CFDE_XMLNode::Parent); if (pParentXMLNode) { pParentXMLNode->RemoveChildNode(pXMLDocumentNode); } FXSYS_assert(pXMLDocumentNode->GetType() == FDE_XMLNODE_Element); if (pXMLDocumentNode->GetType() == FDE_XMLNODE_Element) { - ((IFDE_XMLElement*)pXMLDocumentNode)->RemoveAttribute(L"xmlns:xfa"); + static_cast(pXMLDocumentNode) + ->RemoveAttribute(L"xmlns:xfa"); } pDataElement->InsertChildNode(pXMLDocumentNode); pDataXMLNode = pDataElement; @@ -695,7 +685,7 @@ CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_Data( return NULL; } CFX_WideString wsLocalName; - ((IFDE_XMLElement*)pDataXMLNode)->GetLocalTagName(wsLocalName); + static_cast(pDataXMLNode)->GetLocalTagName(wsLocalName); pNode->SetCData(XFA_ATTRIBUTE_Name, wsLocalName); if (!DataLoader(pNode, pDataXMLNode, TRUE)) { return NULL; @@ -709,7 +699,7 @@ CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_Data( return NULL; } CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_LocaleConnectionSourceSet( - IFDE_XMLNode* pXMLDocumentNode, + CFDE_XMLNode* pXMLDocumentNode, XFA_XDPPACKET ePacketID) { CXFA_Node* pNode = NULL; if (ePacketID == XFA_XDPPACKET_LocaleSet) { @@ -768,7 +758,7 @@ CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_LocaleConnectionSourceSet( return pNode; } CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_Xdc( - IFDE_XMLNode* pXMLDocumentNode, + CFDE_XMLNode* pXMLDocumentNode, XFA_XDPPACKET ePacketID) { if (XFA_FDEExtension_MatchNodeName( pXMLDocumentNode, XFA_GetPacketByIndex(XFA_PACKET_Xdc)->pName, @@ -787,7 +777,7 @@ CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_Xdc( return NULL; } CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_User( - IFDE_XMLNode* pXMLDocumentNode, + CFDE_XMLNode* pXMLDocumentNode, XFA_XDPPACKET ePacketID) { CXFA_Node* pNode = m_pFactory->CreateNode(XFA_XDPPACKET_XDP, XFA_ELEMENT_Packet); @@ -795,7 +785,7 @@ CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_User( return NULL; } CFX_WideString wsName; - ((IFDE_XMLElement*)pXMLDocumentNode)->GetLocalTagName(wsName); + static_cast(pXMLDocumentNode)->GetLocalTagName(wsName); pNode->SetCData(XFA_ATTRIBUTE_Name, wsName); if (!UserPacketLoader(pNode, pXMLDocumentNode)) { return NULL; @@ -804,7 +794,7 @@ CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_User( return pNode; } CXFA_Node* CXFA_SimpleParser::UserPacketLoader(CXFA_Node* pXFANode, - IFDE_XMLNode* pXMLDoc) { + CFDE_XMLNode* pXMLDoc) { return pXFANode; } static FX_BOOL XFA_FDEExtension_IsStringAllWhitespace(CFX_WideString wsText) { @@ -812,22 +802,22 @@ static FX_BOOL XFA_FDEExtension_IsStringAllWhitespace(CFX_WideString wsText) { return wsText.IsEmpty(); } CXFA_Node* CXFA_SimpleParser::DataLoader(CXFA_Node* pXFANode, - IFDE_XMLNode* pXMLDoc, + CFDE_XMLNode* pXMLDoc, FX_BOOL bDoTransform) { ParseDataGroup(pXFANode, pXMLDoc, XFA_XDPPACKET_Datasets); return pXFANode; } CXFA_Node* CXFA_SimpleParser::NormalLoader(CXFA_Node* pXFANode, - IFDE_XMLNode* pXMLDoc, + CFDE_XMLNode* pXMLDoc, XFA_XDPPACKET ePacketID, FX_BOOL bUseAttribute) { FX_BOOL bOneOfPropertyFound = FALSE; - for (IFDE_XMLNode* pXMLChild = pXMLDoc->GetNodeItem(IFDE_XMLNode::FirstChild); + for (CFDE_XMLNode* pXMLChild = pXMLDoc->GetNodeItem(CFDE_XMLNode::FirstChild); pXMLChild; - pXMLChild = pXMLChild->GetNodeItem(IFDE_XMLNode::NextSibling)) { + pXMLChild = pXMLChild->GetNodeItem(CFDE_XMLNode::NextSibling)) { switch (pXMLChild->GetType()) { case FDE_XMLNODE_Element: { - IFDE_XMLElement* pXMLElement = (IFDE_XMLElement*)pXMLChild; + CFDE_XMLElement* pXMLElement = static_cast(pXMLChild); CFX_WideString wsTagName; pXMLElement->GetLocalTagName(wsTagName); const XFA_ELEMENTINFO* pElemInfo = XFA_GetElementByName(wsTagName); @@ -901,7 +891,8 @@ CXFA_Node* CXFA_SimpleParser::NormalLoader(CXFA_Node* pXFANode, } } break; case FDE_XMLNODE_Instruction: - ParseInstruction(pXFANode, (IFDE_XMLInstruction*)pXMLChild, ePacketID); + ParseInstruction(pXFANode, static_cast(pXMLChild), + ePacketID); break; default: break; @@ -909,7 +900,7 @@ CXFA_Node* CXFA_SimpleParser::NormalLoader(CXFA_Node* pXFANode, } return pXFANode; } -FX_BOOL XFA_RecognizeRichText(IFDE_XMLElement* pRichTextXMLNode) { +FX_BOOL XFA_RecognizeRichText(CFDE_XMLElement* pRichTextXMLNode) { if (pRichTextXMLNode) { CFX_WideString wsNamespaceURI; XFA_FDEExtension_GetElementTagNamespaceURI(pRichTextXMLNode, @@ -922,33 +913,33 @@ FX_BOOL XFA_RecognizeRichText(IFDE_XMLElement* pRichTextXMLNode) { } class RichTextNodeVisitor { public: - static inline IFDE_XMLNode* GetFirstChild(IFDE_XMLNode* pNode) { - return pNode->GetNodeItem(IFDE_XMLNode::FirstChild); + static inline CFDE_XMLNode* GetFirstChild(CFDE_XMLNode* pNode) { + return pNode->GetNodeItem(CFDE_XMLNode::FirstChild); } - static inline IFDE_XMLNode* GetNextSibling(IFDE_XMLNode* pNode) { - return pNode->GetNodeItem(IFDE_XMLNode::NextSibling); + static inline CFDE_XMLNode* GetNextSibling(CFDE_XMLNode* pNode) { + return pNode->GetNodeItem(CFDE_XMLNode::NextSibling); } - static inline IFDE_XMLNode* GetParent(IFDE_XMLNode* pNode) { - return pNode->GetNodeItem(IFDE_XMLNode::Parent); + static inline CFDE_XMLNode* GetParent(CFDE_XMLNode* pNode) { + return pNode->GetNodeItem(CFDE_XMLNode::Parent); } }; -void XFA_ConvertXMLToPlainText(IFDE_XMLElement* pRootXMLNode, +void XFA_ConvertXMLToPlainText(CFDE_XMLElement* pRootXMLNode, CFX_WideString& wsOutput) { - for (IFDE_XMLNode* pXMLChild = - pRootXMLNode->GetNodeItem(IFDE_XMLNode::FirstChild); + for (CFDE_XMLNode* pXMLChild = + pRootXMLNode->GetNodeItem(CFDE_XMLNode::FirstChild); pXMLChild; - pXMLChild = pXMLChild->GetNodeItem(IFDE_XMLNode::NextSibling)) { + pXMLChild = pXMLChild->GetNodeItem(CFDE_XMLNode::NextSibling)) { switch (pXMLChild->GetType()) { case FDE_XMLNODE_Element: { CFX_WideString wsTextData; - ((IFDE_XMLElement*)pXMLChild)->GetTextData(wsTextData); + static_cast(pXMLChild)->GetTextData(wsTextData); wsTextData += FX_WSTRC(L"\n"); wsOutput += wsTextData; } break; case FDE_XMLNODE_Text: { CFX_WideString wsText; - ((IFDE_XMLText*)pXMLChild)->GetText(wsText); + static_cast(pXMLChild)->GetText(wsText); if (XFA_FDEExtension_IsStringAllWhitespace(wsText)) { continue; } else { @@ -957,7 +948,7 @@ void XFA_ConvertXMLToPlainText(IFDE_XMLElement* pRootXMLNode, } break; case FDE_XMLNODE_CharData: { CFX_WideString wsCharData; - ((IFDE_XMLCharData*)pXMLChild)->GetCharData(wsCharData); + static_cast(pXMLChild)->GetCharData(wsCharData); if (XFA_FDEExtension_IsStringAllWhitespace(wsCharData)) { continue; } else { @@ -972,7 +963,7 @@ void XFA_ConvertXMLToPlainText(IFDE_XMLElement* pRootXMLNode, } void CXFA_SimpleParser::ParseContentNode(CXFA_Node* pXFANode, - IFDE_XMLNode* pXMLNode, + CFDE_XMLNode* pXMLNode, XFA_XDPPACKET ePacketID) { XFA_ELEMENT element = XFA_ELEMENT_Sharptext; if (pXFANode->GetClassID() == XFA_ELEMENT_ExData) { @@ -987,10 +978,10 @@ void CXFA_SimpleParser::ParseContentNode(CXFA_Node* pXFANode, pXFANode->SetXMLMappingNode(pXMLNode); CFX_WideString wsValue; - for (IFDE_XMLNode* pXMLChild = - pXMLNode->GetNodeItem(IFDE_XMLNode::FirstChild); + for (CFDE_XMLNode* pXMLChild = + pXMLNode->GetNodeItem(CFDE_XMLNode::FirstChild); pXMLChild; - pXMLChild = pXMLChild->GetNodeItem(IFDE_XMLNode::NextSibling)) { + pXMLChild = pXMLChild->GetNodeItem(CFDE_XMLNode::NextSibling)) { FDE_XMLNODETYPE eNodeType = pXMLChild->GetType(); if (eNodeType == FDE_XMLNODE_Instruction) continue; @@ -999,19 +990,21 @@ void CXFA_SimpleParser::ParseContentNode(CXFA_Node* pXFANode, if (eNodeType != FDE_XMLNODE_Element) break; - if (XFA_RecognizeRichText((IFDE_XMLElement*)pXMLChild)) - XFA_GetPlainTextFromRichText((IFDE_XMLElement*)pXMLChild, wsValue); + if (XFA_RecognizeRichText(static_cast(pXMLChild))) + XFA_GetPlainTextFromRichText(static_cast(pXMLChild), + wsValue); } else if (element == XFA_ELEMENT_Sharpxml) { if (eNodeType != FDE_XMLNODE_Element) break; - XFA_ConvertXMLToPlainText((IFDE_XMLElement*)pXMLChild, wsValue); + XFA_ConvertXMLToPlainText(static_cast(pXMLChild), + wsValue); } else { if (eNodeType == FDE_XMLNODE_Element) break; if (eNodeType == FDE_XMLNODE_Text) - ((IFDE_XMLText*)pXMLChild)->GetText(wsValue); + static_cast(pXMLChild)->GetText(wsValue); else if (eNodeType == FDE_XMLNODE_CharData) - ((IFDE_XMLCharData*)pXMLChild)->GetCharData(wsValue); + static_cast(pXMLChild)->GetCharData(wsValue); } break; } @@ -1029,15 +1022,15 @@ void CXFA_SimpleParser::ParseContentNode(CXFA_Node* pXFANode, } void CXFA_SimpleParser::ParseDataGroup(CXFA_Node* pXFANode, - IFDE_XMLNode* pXMLNode, + CFDE_XMLNode* pXMLNode, XFA_XDPPACKET ePacketID) { - for (IFDE_XMLNode* pXMLChild = - pXMLNode->GetNodeItem(IFDE_XMLNode::FirstChild); + for (CFDE_XMLNode* pXMLChild = + pXMLNode->GetNodeItem(CFDE_XMLNode::FirstChild); pXMLChild; - pXMLChild = pXMLChild->GetNodeItem(IFDE_XMLNode::NextSibling)) { + pXMLChild = pXMLChild->GetNodeItem(CFDE_XMLNode::NextSibling)) { switch (pXMLChild->GetType()) { case FDE_XMLNODE_Element: { - IFDE_XMLElement* pXMLElement = (IFDE_XMLElement*)pXMLChild; + CFDE_XMLElement* pXMLElement = static_cast(pXMLChild); { CFX_WideString wsNamespaceURI; XFA_FDEExtension_GetElementTagNamespaceURI(pXMLElement, @@ -1080,12 +1073,13 @@ void CXFA_SimpleParser::ParseDataGroup(CXFA_Node* pXFANode, } } if (eNodeType == XFA_ELEMENT_DataModel) { - for (IFDE_XMLNode* pXMLDataChild = - pXMLElement->GetNodeItem(IFDE_XMLNode::FirstChild); + for (CFDE_XMLNode* pXMLDataChild = + pXMLElement->GetNodeItem(CFDE_XMLNode::FirstChild); pXMLDataChild; pXMLDataChild = pXMLDataChild->GetNodeItem( - IFDE_XMLNode::NextSibling)) { + CFDE_XMLNode::NextSibling)) { if (pXMLDataChild->GetType() == FDE_XMLNODE_Element) { - if (!XFA_RecognizeRichText((IFDE_XMLElement*)pXMLDataChild)) { + if (!XFA_RecognizeRichText( + static_cast(pXMLDataChild))) { eNodeType = XFA_ELEMENT_DataGroup; break; } @@ -1168,7 +1162,8 @@ void CXFA_SimpleParser::ParseDataGroup(CXFA_Node* pXFANode, } continue; case FDE_XMLNODE_CharData: { - IFDE_XMLCharData* pXMLCharData = (IFDE_XMLCharData*)pXMLChild; + CFDE_XMLCharData* pXMLCharData = + static_cast(pXMLChild); CFX_WideString wsCharData; pXMLCharData->GetCharData(wsCharData); if (XFA_FDEExtension_IsStringAllWhitespace(wsCharData)) { @@ -1186,7 +1181,7 @@ void CXFA_SimpleParser::ParseDataGroup(CXFA_Node* pXFANode, } continue; case FDE_XMLNODE_Text: { - IFDE_XMLText* pXMLText = (IFDE_XMLText*)pXMLChild; + CFDE_XMLText* pXMLText = static_cast(pXMLChild); CFX_WideString wsText; pXMLText->GetText(wsText); if (XFA_FDEExtension_IsStringAllWhitespace(wsText)) { @@ -1212,35 +1207,37 @@ void CXFA_SimpleParser::ParseDataGroup(CXFA_Node* pXFANode, } void CXFA_SimpleParser::ParseDataValue(CXFA_Node* pXFANode, - IFDE_XMLNode* pXMLNode, + CFDE_XMLNode* pXMLNode, XFA_XDPPACKET ePacketID) { CFX_WideTextBuf wsValueTextBuf; CFX_WideTextBuf wsCurValueTextBuf; FX_BOOL bMarkAsCompound = FALSE; - IFDE_XMLNode* pXMLCurValueNode = nullptr; - for (IFDE_XMLNode* pXMLChild = - pXMLNode->GetNodeItem(IFDE_XMLNode::FirstChild); + CFDE_XMLNode* pXMLCurValueNode = nullptr; + for (CFDE_XMLNode* pXMLChild = + pXMLNode->GetNodeItem(CFDE_XMLNode::FirstChild); pXMLChild; - pXMLChild = pXMLChild->GetNodeItem(IFDE_XMLNode::NextSibling)) { + pXMLChild = pXMLChild->GetNodeItem(CFDE_XMLNode::NextSibling)) { FDE_XMLNODETYPE eNodeType = pXMLChild->GetType(); if (eNodeType == FDE_XMLNODE_Instruction) continue; CFX_WideString wsText; if (eNodeType == FDE_XMLNODE_Text) { - ((IFDE_XMLText*)pXMLChild)->GetText(wsText); + static_cast(pXMLChild)->GetText(wsText); if (!pXMLCurValueNode) pXMLCurValueNode = pXMLChild; wsCurValueTextBuf << wsText; } else if (eNodeType == FDE_XMLNODE_CharData) { - ((IFDE_XMLCharData*)pXMLChild)->GetCharData(wsText); + static_cast(pXMLChild)->GetCharData(wsText); if (!pXMLCurValueNode) pXMLCurValueNode = pXMLChild; wsCurValueTextBuf << wsText; - } else if (XFA_RecognizeRichText((IFDE_XMLElement*)pXMLChild)) { - XFA_GetPlainTextFromRichText((IFDE_XMLElement*)pXMLChild, wsText); + } else if (XFA_RecognizeRichText( + static_cast(pXMLChild))) { + XFA_GetPlainTextFromRichText(static_cast(pXMLChild), + wsText); if (!pXMLCurValueNode) pXMLCurValueNode = pXMLChild; @@ -1271,7 +1268,7 @@ void CXFA_SimpleParser::ParseDataValue(CXFA_Node* pXFANode, return; CFX_WideString wsNodeStr; - ((IFDE_XMLElement*)pXMLChild)->GetLocalTagName(wsNodeStr); + static_cast(pXMLChild)->GetLocalTagName(wsNodeStr); pXFAChild->SetCData(XFA_ATTRIBUTE_Name, wsNodeStr); ParseDataValue(pXFAChild, pXMLChild, ePacketID); pXFANode->InsertChild(pXFAChild); @@ -1306,7 +1303,7 @@ void CXFA_SimpleParser::ParseDataValue(CXFA_Node* pXFANode, } void CXFA_SimpleParser::ParseInstruction(CXFA_Node* pXFANode, - IFDE_XMLInstruction* pXMLInstruction, + CFDE_XMLInstruction* pXMLInstruction, XFA_XDPPACKET ePacketID) { if (!m_bDocumentParser) { return; @@ -1372,7 +1369,7 @@ int32_t CXFA_DocumentParser::DoParse(IFX_Pause* pPause) { return nRetStatus; } int32_t CXFA_DocumentParser::ParseXMLData(const CFX_WideString& wsXML, - IFDE_XMLNode*& pXMLNode, + CFDE_XMLNode*& pXMLNode, IFX_Pause* pPause) { CloseParser(); int32_t nRetStatus = m_nodeParser.ParseXMLData(wsXML, pXMLNode, NULL); @@ -1383,7 +1380,7 @@ int32_t CXFA_DocumentParser::ParseXMLData(const CFX_WideString& wsXML, return nRetStatus; } void CXFA_DocumentParser::ConstructXFANode(CXFA_Node* pXFANode, - IFDE_XMLNode* pXMLNode) { + CFDE_XMLNode* pXMLNode) { if (!pXFANode || !pXMLNode) { return; } @@ -1400,7 +1397,7 @@ void CXFA_DocumentParser::CloseParser() { } m_nodeParser.CloseParser(); } -CXFA_XMLParser::CXFA_XMLParser(IFDE_XMLNode* pRoot, IFX_Stream* pStream) +CXFA_XMLParser::CXFA_XMLParser(CFDE_XMLNode* pRoot, IFX_Stream* pStream) : m_nElementStart(0), m_dwCheckStatus(0), m_dwCurrentCheckStatus(0), @@ -1413,7 +1410,7 @@ CXFA_XMLParser::CXFA_XMLParser(IFDE_XMLNode* pRoot, IFX_Stream* pStream) m_dwStatus(FDE_XMLSYNTAXSTATUS_None) { ASSERT(m_pParent && m_pStream); m_NodeStack.Push(m_pParent); - m_pParser = IFDE_XMLSyntaxParser::Create(); + m_pParser = new CFDE_XMLSyntaxParser; m_pParser->Init(m_pStream, 32 * 1024, 1024 * 1024); } CXFA_XMLParser::~CXFA_XMLParser() { @@ -1459,7 +1456,7 @@ int32_t CXFA_XMLParser::DoParser(IFX_Pause* pPause) { break; } m_pParser->GetTagName(m_ws1); - ((IFDE_XMLElement*)m_pChild)->GetTagName(m_ws2); + static_cast(m_pChild)->GetTagName(m_ws2); if (m_ws1.GetLength() > 0 && !m_ws1.Equal(m_ws2)) { m_dwStatus = FDE_XMLSYNTAXSTATUS_Error; break; @@ -1475,7 +1472,7 @@ int32_t CXFA_XMLParser::DoParser(IFX_Pause* pPause) { m_dwCurrentCheckStatus = 0; } - m_pParent = (IFDE_XMLNode*)*m_NodeStack.GetTopElement(); + m_pParent = static_cast(*m_NodeStack.GetTopElement()); m_pChild = m_pParent; iCount++; break; @@ -1483,7 +1480,7 @@ int32_t CXFA_XMLParser::DoParser(IFX_Pause* pPause) { m_pParser->GetTargetName(m_ws1); if (m_ws1 == FX_WSTRC(L"originalXFAVersion") || m_ws1 == FX_WSTRC(L"acrobat")) { - m_pChild = IFDE_XMLInstruction::Create(m_ws1); + m_pChild = new CFDE_XMLInstruction(m_ws1); m_pParent->InsertChildNode(m_pChild); } else { m_pChild = NULL; @@ -1492,14 +1489,14 @@ int32_t CXFA_XMLParser::DoParser(IFX_Pause* pPause) { break; case FDE_XMLSYNTAXSTATUS_TagName: m_pParser->GetTagName(m_ws1); - m_pChild = IFDE_XMLElement::Create(m_ws1); + m_pChild = new CFDE_XMLElement(m_ws1); m_pParent->InsertChildNode(m_pChild); m_NodeStack.Push(m_pChild); m_pParent = m_pChild; if (m_dwCheckStatus != 0x03 && m_NodeStack.GetSize() == 3) { CFX_WideString wsTag; - ((IFDE_XMLElement*)m_pChild)->GetLocalTagName(wsTag); + static_cast(m_pChild)->GetLocalTagName(wsTag); if (wsTag == FX_WSTRC(L"template")) { m_dwCheckStatus |= 0x01; m_dwCurrentCheckStatus = 0x01; @@ -1520,20 +1517,20 @@ int32_t CXFA_XMLParser::DoParser(IFX_Pause* pPause) { if (m_pChild) { m_pParser->GetAttributeName(m_ws2); if (m_pChild->GetType() == FDE_XMLNODE_Element) { - ((IFDE_XMLElement*)m_pChild)->SetString(m_ws1, m_ws2); + static_cast(m_pChild)->SetString(m_ws1, m_ws2); } } m_ws1.Empty(); break; case FDE_XMLSYNTAXSTATUS_Text: m_pParser->GetTextData(m_ws1); - m_pChild = IFDE_XMLText::Create(m_ws1); + m_pChild = new CFDE_XMLText(m_ws1); m_pParent->InsertChildNode(m_pChild); m_pChild = m_pParent; break; case FDE_XMLSYNTAXSTATUS_CData: m_pParser->GetTextData(m_ws1); - m_pChild = IFDE_XMLCharData::Create(m_ws1); + m_pChild = new CFDE_XMLCharData(m_ws1); m_pParent->InsertChildNode(m_pChild); m_pChild = m_pParent; break; @@ -1544,10 +1541,10 @@ int32_t CXFA_XMLParser::DoParser(IFX_Pause* pPause) { break; } if (!m_ws1.IsEmpty()) { - ((IFDE_XMLInstruction*)m_pChild)->AppendData(m_ws1); + static_cast(m_pChild)->AppendData(m_ws1); } m_pParser->GetTargetData(m_ws1); - ((IFDE_XMLInstruction*)m_pChild)->AppendData(m_ws1); + static_cast(m_pChild)->AppendData(m_ws1); } m_ws1.Empty(); break; diff --git a/xfa/fxfa/parser/xfa_parser_imp.h b/xfa/fxfa/parser/xfa_parser_imp.h index 6ef890857a..308de7e587 100644 --- a/xfa/fxfa/parser/xfa_parser_imp.h +++ b/xfa/fxfa/parser/xfa_parser_imp.h @@ -7,6 +7,7 @@ #ifndef XFA_FXFA_PARSER_XFA_PARSER_IMP_H_ #define XFA_FXFA_PARSER_XFA_PARSER_IMP_H_ +#include "xfa/fde/xml/fde_xml_imp.h" #include "xfa/fxfa/parser/xfa_parser.h" class CXFA_XMLParser; @@ -21,56 +22,56 @@ class CXFA_SimpleParser : public IXFA_Parser { XFA_XDPPACKET ePacketID = XFA_XDPPACKET_XDP); virtual int32_t DoParse(IFX_Pause* pPause = NULL); virtual int32_t ParseXMLData(const CFX_WideString& wsXML, - IFDE_XMLNode*& pXMLNode, + CFDE_XMLNode*& pXMLNode, IFX_Pause* pPause = NULL); - virtual void ConstructXFANode(CXFA_Node* pXFANode, IFDE_XMLNode* pXMLNode); + virtual void ConstructXFANode(CXFA_Node* pXFANode, CFDE_XMLNode* pXMLNode); virtual IXFA_ObjFactory* GetFactory() const { return m_pFactory; } virtual CXFA_Node* GetRootNode() const { return m_pRootNode; } - virtual IFDE_XMLDoc* GetXMLDoc() const { return m_pXMLDoc; } + virtual CFDE_XMLDoc* GetXMLDoc() const { return m_pXMLDoc; } virtual void CloseParser(); protected: - CXFA_Node* ParseAsXDPPacket(IFDE_XMLNode* pXMLDocumentNode, + CXFA_Node* ParseAsXDPPacket(CFDE_XMLNode* pXMLDocumentNode, XFA_XDPPACKET ePacketID); - CXFA_Node* ParseAsXDPPacket_XDP(IFDE_XMLNode* pXMLDocumentNode, + CXFA_Node* ParseAsXDPPacket_XDP(CFDE_XMLNode* pXMLDocumentNode, XFA_XDPPACKET ePacketID); - CXFA_Node* ParseAsXDPPacket_Config(IFDE_XMLNode* pXMLDocumentNode, + CXFA_Node* ParseAsXDPPacket_Config(CFDE_XMLNode* pXMLDocumentNode, XFA_XDPPACKET ePacketID); - CXFA_Node* ParseAsXDPPacket_TemplateForm(IFDE_XMLNode* pXMLDocumentNode, + CXFA_Node* ParseAsXDPPacket_TemplateForm(CFDE_XMLNode* pXMLDocumentNode, XFA_XDPPACKET ePacketID); - CXFA_Node* ParseAsXDPPacket_Data(IFDE_XMLNode* pXMLDocumentNode, + CXFA_Node* ParseAsXDPPacket_Data(CFDE_XMLNode* pXMLDocumentNode, XFA_XDPPACKET ePacketID); CXFA_Node* ParseAsXDPPacket_LocaleConnectionSourceSet( - IFDE_XMLNode* pXMLDocumentNode, + CFDE_XMLNode* pXMLDocumentNode, XFA_XDPPACKET ePacketID); - CXFA_Node* ParseAsXDPPacket_Xdc(IFDE_XMLNode* pXMLDocumentNode, + CXFA_Node* ParseAsXDPPacket_Xdc(CFDE_XMLNode* pXMLDocumentNode, XFA_XDPPACKET ePacketID); - CXFA_Node* ParseAsXDPPacket_User(IFDE_XMLNode* pXMLDocumentNode, + CXFA_Node* ParseAsXDPPacket_User(CFDE_XMLNode* pXMLDocumentNode, XFA_XDPPACKET ePacketID); CXFA_Node* NormalLoader(CXFA_Node* pXFANode, - IFDE_XMLNode* pXMLDoc, + CFDE_XMLNode* pXMLDoc, XFA_XDPPACKET ePacketID, FX_BOOL bUseAttribute = TRUE); CXFA_Node* DataLoader(CXFA_Node* pXFANode, - IFDE_XMLNode* pXMLDoc, + CFDE_XMLNode* pXMLDoc, FX_BOOL bDoTransform); - CXFA_Node* UserPacketLoader(CXFA_Node* pXFANode, IFDE_XMLNode* pXMLDoc); + CXFA_Node* UserPacketLoader(CXFA_Node* pXFANode, CFDE_XMLNode* pXMLDoc); void ParseContentNode(CXFA_Node* pXFANode, - IFDE_XMLNode* pXMLNode, + CFDE_XMLNode* pXMLNode, XFA_XDPPACKET ePacketID); void ParseDataValue(CXFA_Node* pXFANode, - IFDE_XMLNode* pXMLNode, + CFDE_XMLNode* pXMLNode, XFA_XDPPACKET ePacketID); void ParseDataGroup(CXFA_Node* pXFANode, - IFDE_XMLNode* pXMLNode, + CFDE_XMLNode* pXMLNode, XFA_XDPPACKET ePacketID); void ParseInstruction(CXFA_Node* pXFANode, - IFDE_XMLInstruction* pXMLInstruction, + CFDE_XMLInstruction* pXMLInstruction, XFA_XDPPACKET ePacketID); void SetFactory(IXFA_ObjFactory* pFactory); CXFA_XMLParser* m_pXMLParser; - IFDE_XMLDoc* m_pXMLDoc; + CFDE_XMLDoc* m_pXMLDoc; IFX_Stream* m_pStream; IFX_FileRead* m_pFileRead; IXFA_ObjFactory* m_pFactory; @@ -89,14 +90,14 @@ class CXFA_DocumentParser : public IXFA_DocParser { XFA_XDPPACKET ePacketID = XFA_XDPPACKET_XDP); virtual int32_t DoParse(IFX_Pause* pPause = NULL); virtual int32_t ParseXMLData(const CFX_WideString& wsXML, - IFDE_XMLNode*& pXMLNode, + CFDE_XMLNode*& pXMLNode, IFX_Pause* pPause = NULL); - virtual void ConstructXFANode(CXFA_Node* pXFANode, IFDE_XMLNode* pXMLNode); + virtual void ConstructXFANode(CXFA_Node* pXFANode, CFDE_XMLNode* pXMLNode); virtual IXFA_ObjFactory* GetFactory() const { return m_nodeParser.GetFactory(); } virtual CXFA_Node* GetRootNode() const { return m_nodeParser.GetRootNode(); } - virtual IFDE_XMLDoc* GetXMLDoc() const { return m_nodeParser.GetXMLDoc(); } + virtual CFDE_XMLDoc* GetXMLDoc() const { return m_nodeParser.GetXMLDoc(); } virtual IXFA_Notify* GetNotify() const { return m_pNotify; } virtual CXFA_Document* GetDocument() const { return m_pDocument; } virtual void CloseParser(); @@ -106,11 +107,11 @@ class CXFA_DocumentParser : public IXFA_DocParser { IXFA_Notify* m_pNotify; CXFA_Document* m_pDocument; }; -typedef CFX_StackTemplate CXFA_XMLNodeStack; +typedef CFX_StackTemplate CXFA_XMLNodeStack; -class CXFA_XMLParser : public IFDE_XMLParser { +class CXFA_XMLParser : public CFDE_XMLParser { public: - CXFA_XMLParser(IFDE_XMLNode* pRoot, IFX_Stream* pStream); + CXFA_XMLParser(CFDE_XMLNode* pRoot, IFX_Stream* pStream); ~CXFA_XMLParser(); virtual void Release() { delete this; } @@ -123,12 +124,11 @@ class CXFA_XMLParser : public IFDE_XMLParser { uint16_t m_dwCurrentCheckStatus; protected: - IFDE_XMLNode* m_pRoot; + CFDE_XMLNode* m_pRoot; IFX_Stream* m_pStream; - IFDE_XMLSyntaxParser* m_pParser; - - IFDE_XMLNode* m_pParent; - IFDE_XMLNode* m_pChild; + CFDE_XMLSyntaxParser* m_pParser; + CFDE_XMLNode* m_pParent; + CFDE_XMLNode* m_pChild; CXFA_XMLNodeStack m_NodeStack; CFX_WideString m_ws1; CFX_WideString m_ws2; diff --git a/xfa/fxfa/parser/xfa_utils.h b/xfa/fxfa/parser/xfa_utils.h index 6cc17d97c0..9070b97e0e 100644 --- a/xfa/fxfa/parser/xfa_utils.h +++ b/xfa/fxfa/parser/xfa_utils.h @@ -10,10 +10,12 @@ #include "xfa/fde/xml/fde_xml.h" #include "xfa/include/fxfa/fxfa_basic.h" +class CFDE_XMLElement; +class CFDE_XMLNode; class CXFA_LocaleValue; FX_BOOL XFA_FDEExtension_ResolveNamespaceQualifier( - IFDE_XMLElement* pNode, + CFDE_XMLElement* pNode, const CFX_WideStringC& wsQualifier, CFX_WideString& wsNamespaceURI); template @@ -200,8 +202,8 @@ FX_DOUBLE XFA_WideStringToDouble(const CFX_WideString& wsStringVal); FX_DOUBLE XFA_ByteStringToDouble(const CFX_ByteStringC& szStringVal); int32_t XFA_MapRotation(int32_t nRotation); -FX_BOOL XFA_RecognizeRichText(IFDE_XMLElement* pRichTextXMLNode); -void XFA_GetPlainTextFromRichText(IFDE_XMLNode* pXMLNode, +FX_BOOL XFA_RecognizeRichText(CFDE_XMLElement* pRichTextXMLNode); +void XFA_GetPlainTextFromRichText(CFDE_XMLNode* pXMLNode, CFX_WideString& wsPlainText); FX_BOOL XFA_FieldIsMultiListBox(CXFA_Node* pFieldNode); IFX_Stream* XFA_CreateWideTextRead(const CFX_WideString& wsBuffer); diff --git a/xfa/fxfa/parser/xfa_utils_imp.cpp b/xfa/fxfa/parser/xfa_utils_imp.cpp index 5e8881e192..6630d060d4 100644 --- a/xfa/fxfa/parser/xfa_utils_imp.cpp +++ b/xfa/fxfa/parser/xfa_utils_imp.cpp @@ -7,6 +7,7 @@ #include "xfa/fxfa/parser/xfa_utils.h" #include "core/fxcrt/include/fx_ext.h" +#include "xfa/fde/xml/fde_xml_imp.h" #include "xfa/fxfa/fm2js/xfa_fm2jsapi.h" #include "xfa/fxfa/parser/xfa_docdata.h" #include "xfa/fxfa/parser/xfa_doclayout.h" @@ -186,14 +187,14 @@ CXFA_LocaleValue XFA_GetLocaleValue(CXFA_WidgetData* pWidgetData) { return CXFA_LocaleValue(iVTType, pWidgetData->GetRawValue(), pWidgetData->GetNode()->GetDocument()->GetLocalMgr()); } -void XFA_GetPlainTextFromRichText(IFDE_XMLNode* pXMLNode, +void XFA_GetPlainTextFromRichText(CFDE_XMLNode* pXMLNode, CFX_WideString& wsPlainText) { if (pXMLNode == NULL) { return; } switch (pXMLNode->GetType()) { case FDE_XMLNODE_Element: { - IFDE_XMLElement* pXMLElement = (IFDE_XMLElement*)pXMLNode; + CFDE_XMLElement* pXMLElement = static_cast(pXMLNode); CFX_WideString wsTag; pXMLElement->GetLocalTagName(wsTag); uint32_t uTag = FX_HashCode_String_GetW(wsTag, wsTag.GetLength(), TRUE); @@ -212,21 +213,21 @@ void XFA_GetPlainTextFromRichText(IFDE_XMLNode* pXMLNode, } break; case FDE_XMLNODE_Text: { CFX_WideString wsContent; - ((IFDE_XMLText*)pXMLNode)->GetText(wsContent); + static_cast(pXMLNode)->GetText(wsContent); wsPlainText += wsContent; } break; case FDE_XMLNODE_CharData: { CFX_WideString wsCharData; - ((IFDE_XMLCharData*)pXMLNode)->GetCharData(wsCharData); + static_cast(pXMLNode)->GetCharData(wsCharData); wsPlainText += wsCharData; } break; default: break; } - for (IFDE_XMLNode* pChildXML = - pXMLNode->GetNodeItem(IFDE_XMLNode::FirstChild); + for (CFDE_XMLNode* pChildXML = + pXMLNode->GetNodeItem(CFDE_XMLNode::FirstChild); pChildXML; - pChildXML = pChildXML->GetNodeItem(IFDE_XMLNode::NextSibling)) { + pChildXML = pChildXML->GetNodeItem(CFDE_XMLNode::NextSibling)) { XFA_GetPlainTextFromRichText(pChildXML, wsPlainText); } } -- cgit v1.2.3