From 0d86ecb08e1b2c204333b1f1f6b0b014e5b2971c Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Wed, 19 Apr 2017 09:19:57 -0400 Subject: Move fde XML parser to core MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This CL moves the XML parser from FDE into FXCRT and renames to CFX_ from CFDE_. Change-Id: I21a9590bf74daf5517df630d7e7a5de89da99ea4 Reviewed-on: https://pdfium-review.googlesource.com/4312 Commit-Queue: dsinclair Reviewed-by: Tom Sepez Reviewed-by: Nicolás Peña --- xfa/fde/xml/cfde_xmlattributenode.cpp | 35 -- xfa/fde/xml/cfde_xmlattributenode.h | 44 -- xfa/fde/xml/cfde_xmlchardata.cpp | 22 - xfa/fde/xml/cfde_xmlchardata.h | 24 - xfa/fde/xml/cfde_xmldoc.cpp | 160 ------ xfa/fde/xml/cfde_xmldoc.h | 37 -- xfa/fde/xml/cfde_xmlelement.cpp | 102 ---- xfa/fde/xml/cfde_xmlelement.h | 33 -- xfa/fde/xml/cfde_xmlinstruction.cpp | 36 -- xfa/fde/xml/cfde_xmlinstruction.h | 35 -- xfa/fde/xml/cfde_xmlnode.cpp | 441 --------------- xfa/fde/xml/cfde_xmlnode.h | 75 --- xfa/fde/xml/cfde_xmlparser.cpp | 171 ------ xfa/fde/xml/cfde_xmlparser.h | 47 -- xfa/fde/xml/cfde_xmlsyntaxparser.cpp | 698 ------------------------ xfa/fde/xml/cfde_xmlsyntaxparser.h | 128 ----- xfa/fde/xml/cfde_xmlsyntaxparser_unittest.cpp | 527 ------------------ xfa/fde/xml/cfde_xmltext.cpp | 22 - xfa/fde/xml/cfde_xmltext.h | 31 -- xfa/fxfa/app/cxfa_loadercontext.h | 4 +- xfa/fxfa/app/cxfa_textlayout.cpp | 59 +- xfa/fxfa/app/cxfa_textlayout.h | 8 +- xfa/fxfa/app/cxfa_textparser.cpp | 35 +- xfa/fxfa/app/cxfa_textparser.h | 18 +- xfa/fxfa/app/xfa_ffwidgetacc.cpp | 16 +- xfa/fxfa/cxfa_ffdoc.cpp | 30 +- xfa/fxfa/cxfa_widgetacc.cpp | 10 +- xfa/fxfa/parser/cxfa_dataexporter.cpp | 46 +- xfa/fxfa/parser/cxfa_dataimporter.cpp | 6 +- xfa/fxfa/parser/cxfa_document.cpp | 2 +- xfa/fxfa/parser/cxfa_document.h | 4 +- xfa/fxfa/parser/cxfa_document_parser.cpp | 4 +- xfa/fxfa/parser/cxfa_document_parser.h | 4 +- xfa/fxfa/parser/cxfa_node.cpp | 140 ++--- xfa/fxfa/parser/cxfa_node.h | 10 +- xfa/fxfa/parser/cxfa_simple_parser.cpp | 287 +++++----- xfa/fxfa/parser/cxfa_simple_parser.h | 48 +- xfa/fxfa/parser/xfa_document_datamerger_imp.cpp | 28 +- xfa/fxfa/parser/xfa_utils.cpp | 26 +- xfa/fxfa/parser/xfa_utils.h | 10 +- 40 files changed, 393 insertions(+), 3070 deletions(-) delete mode 100644 xfa/fde/xml/cfde_xmlattributenode.cpp delete mode 100644 xfa/fde/xml/cfde_xmlattributenode.h delete mode 100644 xfa/fde/xml/cfde_xmlchardata.cpp delete mode 100644 xfa/fde/xml/cfde_xmlchardata.h delete mode 100644 xfa/fde/xml/cfde_xmldoc.cpp delete mode 100644 xfa/fde/xml/cfde_xmldoc.h delete mode 100644 xfa/fde/xml/cfde_xmlelement.cpp delete mode 100644 xfa/fde/xml/cfde_xmlelement.h delete mode 100644 xfa/fde/xml/cfde_xmlinstruction.cpp delete mode 100644 xfa/fde/xml/cfde_xmlinstruction.h delete mode 100644 xfa/fde/xml/cfde_xmlnode.cpp delete mode 100644 xfa/fde/xml/cfde_xmlnode.h delete mode 100644 xfa/fde/xml/cfde_xmlparser.cpp delete mode 100644 xfa/fde/xml/cfde_xmlparser.h delete mode 100644 xfa/fde/xml/cfde_xmlsyntaxparser.cpp delete mode 100644 xfa/fde/xml/cfde_xmlsyntaxparser.h delete mode 100644 xfa/fde/xml/cfde_xmlsyntaxparser_unittest.cpp delete mode 100644 xfa/fde/xml/cfde_xmltext.cpp delete mode 100644 xfa/fde/xml/cfde_xmltext.h (limited to 'xfa') diff --git a/xfa/fde/xml/cfde_xmlattributenode.cpp b/xfa/fde/xml/cfde_xmlattributenode.cpp deleted file mode 100644 index 0bfa949b12..0000000000 --- a/xfa/fde/xml/cfde_xmlattributenode.cpp +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2017 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#include "xfa/fde/xml/cfde_xmlattributenode.h" - -#include "core/fxcrt/fx_ext.h" - -CFDE_XMLAttributeNode::CFDE_XMLAttributeNode(const CFX_WideString& name) - : CFDE_XMLNode(), name_(name) { - ASSERT(name_.GetLength() > 0); -} - -CFDE_XMLAttributeNode::~CFDE_XMLAttributeNode() {} - -bool CFDE_XMLAttributeNode::HasAttribute(const CFX_WideString& name) const { - return attrs_.find(name) != attrs_.end(); -} - -CFX_WideString CFDE_XMLAttributeNode::GetString( - const CFX_WideString& name) const { - auto it = attrs_.find(name); - return it != attrs_.end() ? it->second : CFX_WideString(); -} - -void CFDE_XMLAttributeNode::SetString(const CFX_WideString& name, - const CFX_WideString& value) { - attrs_[name] = value; -} - -void CFDE_XMLAttributeNode::RemoveAttribute(const CFX_WideString& name) { - attrs_.erase(name); -} diff --git a/xfa/fde/xml/cfde_xmlattributenode.h b/xfa/fde/xml/cfde_xmlattributenode.h deleted file mode 100644 index 07a1ef1610..0000000000 --- a/xfa/fde/xml/cfde_xmlattributenode.h +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright 2017 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef XFA_FDE_XML_CFDE_XMLATTRIBUTENODE_H_ -#define XFA_FDE_XML_CFDE_XMLATTRIBUTENODE_H_ - -#include -#include - -#include "core/fxcrt/fx_string.h" -#include "xfa/fde/xml/cfde_xmlnode.h" - -class CFDE_XMLAttributeNode : public CFDE_XMLNode { - public: - explicit CFDE_XMLAttributeNode(const CFX_WideString& name); - ~CFDE_XMLAttributeNode() override; - - // CFDE_XMLNode - FDE_XMLNODETYPE GetType() const override = 0; - std::unique_ptr Clone() override = 0; - - CFX_WideString GetName() const { return name_; } - const std::map& GetAttributes() const { - return attrs_; - } - void SetAttributes(const std::map& attrs) { - attrs_ = attrs; - } - bool HasAttribute(const CFX_WideString& name) const; - - void SetString(const CFX_WideString& name, const CFX_WideString& value); - CFX_WideString GetString(const CFX_WideString& name) const; - - void RemoveAttribute(const CFX_WideString& name); - - private: - CFX_WideString name_; - std::map attrs_; -}; - -#endif // XFA_FDE_XML_CFDE_XMLATTRIBUTENODE_H_ diff --git a/xfa/fde/xml/cfde_xmlchardata.cpp b/xfa/fde/xml/cfde_xmlchardata.cpp deleted file mode 100644 index bb2991937b..0000000000 --- a/xfa/fde/xml/cfde_xmlchardata.cpp +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2017 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#include "xfa/fde/xml/cfde_xmlchardata.h" - -#include "third_party/base/ptr_util.h" - -CFDE_XMLCharData::CFDE_XMLCharData(const CFX_WideString& wsCData) - : CFDE_XMLText(wsCData) {} - -CFDE_XMLCharData::~CFDE_XMLCharData() {} - -FDE_XMLNODETYPE CFDE_XMLCharData::GetType() const { - return FDE_XMLNODE_CharData; -} - -std::unique_ptr CFDE_XMLCharData::Clone() { - return pdfium::MakeUnique(GetText()); -} diff --git a/xfa/fde/xml/cfde_xmlchardata.h b/xfa/fde/xml/cfde_xmlchardata.h deleted file mode 100644 index 56babbc8b4..0000000000 --- a/xfa/fde/xml/cfde_xmlchardata.h +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2017 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef XFA_FDE_XML_CFDE_XMLCHARDATA_H_ -#define XFA_FDE_XML_CFDE_XMLCHARDATA_H_ - -#include - -#include "core/fxcrt/fx_string.h" -#include "xfa/fde/xml/cfde_xmltext.h" - -class CFDE_XMLCharData : public CFDE_XMLText { - public: - explicit CFDE_XMLCharData(const CFX_WideString& wsCData); - ~CFDE_XMLCharData() override; - - FDE_XMLNODETYPE GetType() const override; - std::unique_ptr Clone() override; -}; - -#endif // XFA_FDE_XML_CFDE_XMLCHARDATA_H_ diff --git a/xfa/fde/xml/cfde_xmldoc.cpp b/xfa/fde/xml/cfde_xmldoc.cpp deleted file mode 100644 index fa44472098..0000000000 --- a/xfa/fde/xml/cfde_xmldoc.cpp +++ /dev/null @@ -1,160 +0,0 @@ -// Copyright 2017 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#include "xfa/fde/xml/cfde_xmldoc.h" - -#include -#include - -#include "core/fxcrt/fx_codepage.h" -#include "third_party/base/ptr_util.h" -#include "third_party/base/stl_util.h" -#include "xfa/fde/xml/cfde_xmlchardata.h" -#include "xfa/fde/xml/cfde_xmlelement.h" -#include "xfa/fde/xml/cfde_xmlinstruction.h" -#include "xfa/fde/xml/cfde_xmlnode.h" -#include "xfa/fde/xml/cfde_xmltext.h" - -CFDE_XMLDoc::CFDE_XMLDoc() - : m_iStatus(0), m_pRoot(pdfium::MakeUnique()) { - m_pRoot->InsertChildNode(new CFDE_XMLInstruction(L"xml")); -} - -CFDE_XMLDoc::~CFDE_XMLDoc() {} - -bool CFDE_XMLDoc::LoadXML(std::unique_ptr pXMLParser) { - if (!pXMLParser) - return false; - - m_iStatus = 0; - m_pStream.Reset(); - m_pRoot->DeleteChildren(); - m_pXMLParser = std::move(pXMLParser); - return true; -} - -int32_t CFDE_XMLDoc::DoLoad(IFX_Pause* pPause) { - if (m_iStatus < 100) - m_iStatus = m_pXMLParser->DoParser(pPause); - - return m_iStatus; -} - -void CFDE_XMLDoc::CloseXML() { - m_pXMLParser.reset(); -} - -void CFDE_XMLDoc::SaveXMLNode( - const CFX_RetainPtr& pXMLStream, - CFDE_XMLNode* pINode) { - CFDE_XMLNode* pNode = (CFDE_XMLNode*)pINode; - switch (pNode->GetType()) { - case FDE_XMLNODE_Instruction: { - CFX_WideString ws; - CFDE_XMLInstruction* pInstruction = (CFDE_XMLInstruction*)pNode; - if (pInstruction->GetName().CompareNoCase(L"xml") == 0) { - ws = L"GetCodePage(); - if (wCodePage == FX_CODEPAGE_UTF16LE) { - ws += L"UTF-16"; - } else if (wCodePage == FX_CODEPAGE_UTF16BE) { - ws += L"UTF-16be"; - } else { - ws += L"UTF-8"; - } - ws += L"\"?>"; - pXMLStream->WriteString(ws.AsStringC()); - } else { - ws.Format(L"GetName().c_str()); - pXMLStream->WriteString(ws.AsStringC()); - - for (auto it : pInstruction->GetAttributes()) { - CFX_WideString wsValue = it.second; - wsValue.Replace(L"&", L"&"); - wsValue.Replace(L"<", L"<"); - wsValue.Replace(L">", L">"); - wsValue.Replace(L"\'", L"'"); - wsValue.Replace(L"\"", L"""); - - ws = L" "; - ws += it.first; - ws += L"=\""; - ws += wsValue; - ws += L"\""; - pXMLStream->WriteString(ws.AsStringC()); - } - - for (auto target : pInstruction->GetTargetData()) { - ws = L" \""; - ws += target; - ws += L"\""; - pXMLStream->WriteString(ws.AsStringC()); - } - ws = L"?>"; - pXMLStream->WriteString(ws.AsStringC()); - } - break; - } - case FDE_XMLNODE_Element: { - CFX_WideString ws; - ws = L"<"; - ws += static_cast(pNode)->GetName(); - pXMLStream->WriteString(ws.AsStringC()); - - for (auto it : static_cast(pNode)->GetAttributes()) { - CFX_WideString wsValue = it.second; - wsValue.Replace(L"&", L"&"); - wsValue.Replace(L"<", L"<"); - wsValue.Replace(L">", L">"); - wsValue.Replace(L"\'", L"'"); - wsValue.Replace(L"\"", L"""); - - ws = L" "; - ws += it.first; - ws += L"=\""; - ws += wsValue; - ws += L"\""; - pXMLStream->WriteString(ws.AsStringC()); - } - if (pNode->m_pChild) { - ws = L"\n>"; - pXMLStream->WriteString(ws.AsStringC()); - CFDE_XMLNode* pChild = pNode->m_pChild; - while (pChild) { - SaveXMLNode(pXMLStream, static_cast(pChild)); - pChild = pChild->m_pNext; - } - ws = L"(pNode)->GetName(); - ws += L"\n>"; - } else { - ws = L"\n/>"; - } - pXMLStream->WriteString(ws.AsStringC()); - break; - } - case FDE_XMLNODE_Text: { - CFX_WideString ws = static_cast(pNode)->GetText(); - ws.Replace(L"&", L"&"); - ws.Replace(L"<", L"<"); - ws.Replace(L">", L">"); - ws.Replace(L"\'", L"'"); - ws.Replace(L"\"", L"""); - pXMLStream->WriteString(ws.AsStringC()); - break; - } - case FDE_XMLNODE_CharData: { - CFX_WideString ws = L"(pNode)->GetText(); - ws += L"]]>"; - pXMLStream->WriteString(ws.AsStringC()); - break; - } - case FDE_XMLNODE_Unknown: - default: - break; - } -} diff --git a/xfa/fde/xml/cfde_xmldoc.h b/xfa/fde/xml/cfde_xmldoc.h deleted file mode 100644 index c9c7db41b7..0000000000 --- a/xfa/fde/xml/cfde_xmldoc.h +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2017 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef XFA_FDE_XML_CFDE_XMLDOC_H_ -#define XFA_FDE_XML_CFDE_XMLDOC_H_ - -#include - -#include "core/fxcrt/cfx_retain_ptr.h" -#include "core/fxcrt/cfx_seekablestreamproxy.h" -#include "xfa/fde/xml/cfde_xmlnode.h" -#include "xfa/fde/xml/cfde_xmlparser.h" - -class CFDE_XMLDoc { - public: - CFDE_XMLDoc(); - ~CFDE_XMLDoc(); - - bool LoadXML(std::unique_ptr pXMLParser); - int32_t DoLoad(IFX_Pause* pPause); - void CloseXML(); - - CFDE_XMLNode* GetRoot() const { return m_pRoot.get(); } - void SaveXMLNode(const CFX_RetainPtr& pXMLStream, - CFDE_XMLNode* pNode); - - private: - int32_t m_iStatus; - std::unique_ptr m_pRoot; - std::unique_ptr m_pXMLParser; - CFX_RetainPtr m_pStream; -}; - -#endif // XFA_FDE_XML_CFDE_XMLDOC_H_ diff --git a/xfa/fde/xml/cfde_xmlelement.cpp b/xfa/fde/xml/cfde_xmlelement.cpp deleted file mode 100644 index 560cf89280..0000000000 --- a/xfa/fde/xml/cfde_xmlelement.cpp +++ /dev/null @@ -1,102 +0,0 @@ -// Copyright 2017 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#include "xfa/fde/xml/cfde_xmlelement.h" - -#include "core/fxcrt/fx_ext.h" -#include "third_party/base/ptr_util.h" -#include "third_party/base/stl_util.h" -#include "xfa/fde/xml/cfde_xmlchardata.h" -#include "xfa/fde/xml/cfde_xmltext.h" - -CFDE_XMLElement::CFDE_XMLElement(const CFX_WideString& wsTag) - : CFDE_XMLAttributeNode(wsTag) {} - -CFDE_XMLElement::~CFDE_XMLElement() {} - -FDE_XMLNODETYPE CFDE_XMLElement::GetType() const { - return FDE_XMLNODE_Element; -} - -std::unique_ptr CFDE_XMLElement::Clone() { - auto pClone = pdfium::MakeUnique(GetName()); - pClone->SetAttributes(GetAttributes()); - - CFX_WideString wsText; - CFDE_XMLNode* pChild = m_pChild; - while (pChild) { - switch (pChild->GetType()) { - case FDE_XMLNODE_Text: - wsText += static_cast(pChild)->GetText(); - break; - default: - break; - } - pChild = pChild->m_pNext; - } - pClone->SetTextData(wsText); - return pClone; -} - -CFX_WideString CFDE_XMLElement::GetLocalTagName() const { - FX_STRSIZE iFind = GetName().Find(L':', 0); - if (iFind < 0) - return GetName(); - return GetName().Right(GetName().GetLength() - iFind - 1); -} - -CFX_WideString CFDE_XMLElement::GetNamespacePrefix() const { - FX_STRSIZE iFind = GetName().Find(L':', 0); - if (iFind < 0) - return CFX_WideString(); - return GetName().Left(iFind); -} - -CFX_WideString CFDE_XMLElement::GetNamespaceURI() const { - CFX_WideString wsAttri(L"xmlns"); - CFX_WideString wsPrefix = GetNamespacePrefix(); - if (wsPrefix.GetLength() > 0) { - wsAttri += L":"; - wsAttri += wsPrefix; - } - - auto* pNode = static_cast(this); - while (pNode) { - if (pNode->GetType() != FDE_XMLNODE_Element) - break; - - auto* pElement = static_cast(pNode); - if (!pElement->HasAttribute(wsAttri)) { - pNode = pNode->GetNodeItem(CFDE_XMLNode::Parent); - continue; - } - return pElement->GetString(wsAttri); - } - return CFX_WideString(); -} - -CFX_WideString CFDE_XMLElement::GetTextData() const { - CFX_WideTextBuf buffer; - CFDE_XMLNode* pChild = m_pChild; - while (pChild) { - switch (pChild->GetType()) { - case FDE_XMLNODE_Text: - case FDE_XMLNODE_CharData: - buffer << static_cast(pChild)->GetText(); - break; - default: - break; - } - pChild = pChild->m_pNext; - } - return buffer.MakeString(); -} - -void CFDE_XMLElement::SetTextData(const CFX_WideString& wsText) { - if (wsText.GetLength() < 1) - return; - InsertChildNode(new CFDE_XMLText(wsText)); -} diff --git a/xfa/fde/xml/cfde_xmlelement.h b/xfa/fde/xml/cfde_xmlelement.h deleted file mode 100644 index a891ce8928..0000000000 --- a/xfa/fde/xml/cfde_xmlelement.h +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2017 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef XFA_FDE_XML_CFDE_XMLELEMENT_H_ -#define XFA_FDE_XML_CFDE_XMLELEMENT_H_ - -#include -#include - -#include "core/fxcrt/fx_string.h" -#include "xfa/fde/xml/cfde_xmlattributenode.h" - -class CFDE_XMLElement : public CFDE_XMLAttributeNode { - public: - explicit CFDE_XMLElement(const CFX_WideString& wsTag); - ~CFDE_XMLElement() override; - - // CFDE_XMLNode - FDE_XMLNODETYPE GetType() const override; - std::unique_ptr Clone() override; - - CFX_WideString GetLocalTagName() const; - CFX_WideString GetNamespacePrefix() const; - CFX_WideString GetNamespaceURI() const; - - CFX_WideString GetTextData() const; - void SetTextData(const CFX_WideString& wsText); -}; - -#endif // XFA_FDE_XML_CFDE_XMLELEMENT_H_ diff --git a/xfa/fde/xml/cfde_xmlinstruction.cpp b/xfa/fde/xml/cfde_xmlinstruction.cpp deleted file mode 100644 index d289d9e88a..0000000000 --- a/xfa/fde/xml/cfde_xmlinstruction.cpp +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2017 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#include "xfa/fde/xml/cfde_xmlinstruction.h" - -#include "core/fxcrt/fx_ext.h" -#include "third_party/base/ptr_util.h" -#include "third_party/base/stl_util.h" - -CFDE_XMLInstruction::CFDE_XMLInstruction(const CFX_WideString& wsTarget) - : CFDE_XMLAttributeNode(wsTarget) {} - -CFDE_XMLInstruction::~CFDE_XMLInstruction() {} - -FDE_XMLNODETYPE CFDE_XMLInstruction::GetType() const { - return FDE_XMLNODE_Instruction; -} - -std::unique_ptr CFDE_XMLInstruction::Clone() { - auto pClone = pdfium::MakeUnique(GetName()); - pClone->SetAttributes(GetAttributes()); - pClone->m_TargetData = m_TargetData; - return pClone; -} - -void CFDE_XMLInstruction::AppendData(const CFX_WideString& wsData) { - m_TargetData.push_back(wsData); -} - -void CFDE_XMLInstruction::RemoveData(int32_t index) { - if (pdfium::IndexInBounds(m_TargetData, index)) - m_TargetData.erase(m_TargetData.begin() + index); -} diff --git a/xfa/fde/xml/cfde_xmlinstruction.h b/xfa/fde/xml/cfde_xmlinstruction.h deleted file mode 100644 index e9c4ad3dfe..0000000000 --- a/xfa/fde/xml/cfde_xmlinstruction.h +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2017 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef XFA_FDE_XML_CFDE_XMLINSTRUCTION_H_ -#define XFA_FDE_XML_CFDE_XMLINSTRUCTION_H_ - -#include -#include - -#include "core/fxcrt/fx_string.h" -#include "xfa/fde/xml/cfde_xmlattributenode.h" - -class CFDE_XMLInstruction : public CFDE_XMLAttributeNode { - public: - explicit CFDE_XMLInstruction(const CFX_WideString& wsTarget); - ~CFDE_XMLInstruction() override; - - // CFDE_XMLNode - FDE_XMLNODETYPE GetType() const override; - std::unique_ptr Clone() override; - - const std::vector& GetTargetData() const { - return m_TargetData; - } - void AppendData(const CFX_WideString& wsData); - void RemoveData(int32_t index); - - private: - std::vector m_TargetData; -}; - -#endif // XFA_FDE_XML_CFDE_XMLINSTRUCTION_H_ diff --git a/xfa/fde/xml/cfde_xmlnode.cpp b/xfa/fde/xml/cfde_xmlnode.cpp deleted file mode 100644 index c81de7623a..0000000000 --- a/xfa/fde/xml/cfde_xmlnode.cpp +++ /dev/null @@ -1,441 +0,0 @@ -// Copyright 2017 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#include "xfa/fde/xml/cfde_xmlnode.h" - -#include - -#include "core/fxcrt/fx_codepage.h" -#include "third_party/base/stl_util.h" -#include "xfa/fde/xml/cfde_xmlchardata.h" -#include "xfa/fde/xml/cfde_xmlelement.h" -#include "xfa/fde/xml/cfde_xmlinstruction.h" -#include "xfa/fde/xml/cfde_xmltext.h" - -CFDE_XMLNode::CFDE_XMLNode() - : m_pParent(nullptr), - m_pChild(nullptr), - m_pPrior(nullptr), - m_pNext(nullptr) {} - -FDE_XMLNODETYPE CFDE_XMLNode::GetType() const { - return FDE_XMLNODE_Unknown; -} - -CFDE_XMLNode::~CFDE_XMLNode() { - DeleteChildren(); -} - -void CFDE_XMLNode::DeleteChildren() { - CFDE_XMLNode* pChild = m_pChild; - while (pChild) { - CFDE_XMLNode* pNext = pChild->m_pNext; - delete pChild; - pChild = pNext; - } - m_pChild = nullptr; -} - -int32_t CFDE_XMLNode::CountChildNodes() const { - int32_t iCount = 0; - CFDE_XMLNode* pChild = m_pChild; - while (pChild) { - iCount++; - pChild = pChild->m_pNext; - } - return iCount; -} - -CFDE_XMLNode* CFDE_XMLNode::GetChildNode(int32_t index) const { - CFDE_XMLNode* pChild = m_pChild; - while (pChild) { - if (index == 0) { - return pChild; - } - index--; - pChild = pChild->m_pNext; - } - return nullptr; -} - -int32_t CFDE_XMLNode::GetChildNodeIndex(CFDE_XMLNode* pNode) const { - int32_t index = 0; - CFDE_XMLNode* pChild = m_pChild; - while (pChild) { - if (pChild == pNode) { - return index; - } - index++; - pChild = pChild->m_pNext; - } - return -1; -} - -CFDE_XMLNode* CFDE_XMLNode::GetPath(const wchar_t* pPath, - int32_t iLength, - bool bQualifiedName) const { - ASSERT(pPath); - if (iLength < 0) { - iLength = FXSYS_wcslen(pPath); - } - if (iLength == 0) { - return nullptr; - } - CFX_WideString csPath; - const wchar_t* pStart = pPath; - const wchar_t* pEnd = pPath + iLength; - wchar_t ch; - while (pStart < pEnd) { - ch = *pStart++; - if (ch == L'/') { - break; - } else { - csPath += ch; - } - } - iLength -= pStart - pPath; - CFDE_XMLNode* pFind = nullptr; - if (csPath.GetLength() < 1) { - pFind = GetNodeItem(CFDE_XMLNode::Root); - } else if (csPath.Compare(L"..") == 0) { - pFind = m_pParent; - } else if (csPath.Compare(L".") == 0) { - pFind = (CFDE_XMLNode*)this; - } else { - CFX_WideString wsTag; - CFDE_XMLNode* pNode = m_pChild; - while (pNode) { - if (pNode->GetType() == FDE_XMLNODE_Element) { - if (bQualifiedName) - wsTag = static_cast(pNode)->GetName(); - else - wsTag = static_cast(pNode)->GetLocalTagName(); - - if (wsTag.Compare(csPath) == 0) { - if (iLength < 1) - pFind = pNode; - else - pFind = pNode->GetPath(pStart, iLength, bQualifiedName); - - if (pFind) - return pFind; - } - } - pNode = pNode->m_pNext; - } - } - if (!pFind || iLength < 1) - return pFind; - return pFind->GetPath(pStart, iLength, bQualifiedName); -} - -int32_t CFDE_XMLNode::InsertChildNode(CFDE_XMLNode* pNode, int32_t index) { - pNode->m_pParent = this; - if (!m_pChild) { - m_pChild = pNode; - pNode->m_pPrior = nullptr; - pNode->m_pNext = nullptr; - return 0; - } - if (index == 0) { - pNode->m_pNext = m_pChild; - pNode->m_pPrior = nullptr; - m_pChild->m_pPrior = pNode; - m_pChild = pNode; - return 0; - } - int32_t iCount = 0; - CFDE_XMLNode* pFind = m_pChild; - while (++iCount != index && pFind->m_pNext) { - pFind = pFind->m_pNext; - } - pNode->m_pPrior = pFind; - pNode->m_pNext = pFind->m_pNext; - if (pFind->m_pNext) - pFind->m_pNext->m_pPrior = pNode; - pFind->m_pNext = pNode; - return iCount; -} - -void CFDE_XMLNode::RemoveChildNode(CFDE_XMLNode* pNode) { - ASSERT(m_pChild && pNode); - if (m_pChild == pNode) { - m_pChild = pNode->m_pNext; - } else { - pNode->m_pPrior->m_pNext = pNode->m_pNext; - } - if (pNode->m_pNext) - pNode->m_pNext->m_pPrior = pNode->m_pPrior; - pNode->m_pParent = nullptr; - pNode->m_pNext = nullptr; - pNode->m_pPrior = nullptr; -} - -CFDE_XMLNode* CFDE_XMLNode::GetNodeItem(CFDE_XMLNode::NodeItem eItem) const { - switch (eItem) { - case CFDE_XMLNode::Root: { - CFDE_XMLNode* pParent = (CFDE_XMLNode*)this; - while (pParent->m_pParent) { - pParent = pParent->m_pParent; - } - return pParent; - } - case CFDE_XMLNode::Parent: - return m_pParent; - case CFDE_XMLNode::FirstSibling: { - CFDE_XMLNode* pItem = (CFDE_XMLNode*)this; - while (pItem->m_pPrior) { - pItem = pItem->m_pPrior; - } - return pItem == (CFDE_XMLNode*)this ? nullptr : pItem; - } - case CFDE_XMLNode::PriorSibling: - return m_pPrior; - case CFDE_XMLNode::NextSibling: - return m_pNext; - case CFDE_XMLNode::LastSibling: { - CFDE_XMLNode* pItem = (CFDE_XMLNode*)this; - while (pItem->m_pNext) - pItem = pItem->m_pNext; - return pItem == (CFDE_XMLNode*)this ? nullptr : pItem; - } - case CFDE_XMLNode::FirstNeighbor: { - CFDE_XMLNode* pParent = (CFDE_XMLNode*)this; - while (pParent->m_pParent) - pParent = pParent->m_pParent; - return pParent == (CFDE_XMLNode*)this ? nullptr : pParent; - } - case CFDE_XMLNode::PriorNeighbor: { - if (!m_pPrior) - return m_pParent; - - CFDE_XMLNode* pItem = m_pPrior; - while (pItem->m_pChild) { - pItem = pItem->m_pChild; - while (pItem->m_pNext) - pItem = pItem->m_pNext; - } - return pItem; - } - case CFDE_XMLNode::NextNeighbor: { - if (m_pChild) - return m_pChild; - if (m_pNext) - return m_pNext; - CFDE_XMLNode* pItem = m_pParent; - while (pItem) { - if (pItem->m_pNext) - return pItem->m_pNext; - pItem = pItem->m_pParent; - } - return nullptr; - } - case CFDE_XMLNode::LastNeighbor: { - CFDE_XMLNode* pItem = (CFDE_XMLNode*)this; - while (pItem->m_pParent) { - pItem = pItem->m_pParent; - } - while (true) { - while (pItem->m_pNext) - pItem = pItem->m_pNext; - if (!pItem->m_pChild) - break; - pItem = pItem->m_pChild; - } - return pItem == (CFDE_XMLNode*)this ? nullptr : pItem; - } - case CFDE_XMLNode::FirstChild: - return m_pChild; - case CFDE_XMLNode::LastChild: { - if (!m_pChild) - return nullptr; - - CFDE_XMLNode* pChild = m_pChild; - while (pChild->m_pNext) - pChild = pChild->m_pNext; - return pChild; - } - default: - break; - } - return nullptr; -} - -int32_t CFDE_XMLNode::GetNodeLevel() const { - int32_t iLevel = 0; - const CFDE_XMLNode* pItem = m_pParent; - while (pItem) { - iLevel++; - pItem = pItem->m_pParent; - } - return iLevel; -} - -bool CFDE_XMLNode::InsertNodeItem(CFDE_XMLNode::NodeItem eItem, - CFDE_XMLNode* pNode) { - switch (eItem) { - case CFDE_XMLNode::NextSibling: { - pNode->m_pParent = m_pParent; - pNode->m_pNext = m_pNext; - pNode->m_pPrior = this; - if (m_pNext) { - m_pNext->m_pPrior = pNode; - } - m_pNext = pNode; - return true; - } - case CFDE_XMLNode::PriorSibling: { - pNode->m_pParent = m_pParent; - pNode->m_pNext = this; - pNode->m_pPrior = m_pPrior; - if (m_pPrior) { - m_pPrior->m_pNext = pNode; - } else if (m_pParent) { - m_pParent->m_pChild = pNode; - } - m_pPrior = pNode; - return true; - } - default: - return false; - } -} - -CFDE_XMLNode* CFDE_XMLNode::RemoveNodeItem(CFDE_XMLNode::NodeItem eItem) { - CFDE_XMLNode* pNode = nullptr; - switch (eItem) { - case CFDE_XMLNode::NextSibling: - if (m_pNext) { - pNode = m_pNext; - m_pNext = pNode->m_pNext; - if (m_pNext) { - m_pNext->m_pPrior = this; - } - pNode->m_pParent = nullptr; - pNode->m_pNext = nullptr; - pNode->m_pPrior = nullptr; - } - break; - default: - break; - } - return pNode; -} - -std::unique_ptr CFDE_XMLNode::Clone() { - return nullptr; -} - -void CFDE_XMLNode::SaveXMLNode( - const CFX_RetainPtr& pXMLStream) { - CFDE_XMLNode* pNode = (CFDE_XMLNode*)this; - switch (pNode->GetType()) { - case FDE_XMLNODE_Instruction: { - CFX_WideString ws; - CFDE_XMLInstruction* pInstruction = (CFDE_XMLInstruction*)pNode; - if (pInstruction->GetName().CompareNoCase(L"xml") == 0) { - ws = L"GetCodePage(); - if (wCodePage == FX_CODEPAGE_UTF16LE) { - ws += L"UTF-16"; - } else if (wCodePage == FX_CODEPAGE_UTF16BE) { - ws += L"UTF-16be"; - } else { - ws += L"UTF-8"; - } - ws += L"\"?>"; - pXMLStream->WriteString(ws.AsStringC()); - } else { - ws.Format(L"GetName().c_str()); - pXMLStream->WriteString(ws.AsStringC()); - - for (auto it : pInstruction->GetAttributes()) { - CFX_WideString wsValue = it.second; - wsValue.Replace(L"&", L"&"); - wsValue.Replace(L"<", L"<"); - wsValue.Replace(L">", L">"); - wsValue.Replace(L"\'", L"'"); - wsValue.Replace(L"\"", L"""); - - ws = L" "; - ws += it.first; - ws += L"=\""; - ws += wsValue; - ws += L"\""; - pXMLStream->WriteString(ws.AsStringC()); - } - - for (auto target : pInstruction->GetTargetData()) { - ws = L" \""; - ws += target; - ws += L"\""; - pXMLStream->WriteString(ws.AsStringC()); - } - ws = L"?>"; - pXMLStream->WriteString(ws.AsStringC()); - } - break; - } - case FDE_XMLNODE_Element: { - CFX_WideString ws; - ws = L"<"; - ws += static_cast(pNode)->GetName(); - pXMLStream->WriteString(ws.AsStringC()); - - for (auto it : static_cast(pNode)->GetAttributes()) { - CFX_WideString wsValue = it.second; - wsValue.Replace(L"&", L"&"); - wsValue.Replace(L"<", L"<"); - wsValue.Replace(L">", L">"); - wsValue.Replace(L"\'", L"'"); - wsValue.Replace(L"\"", L"""); - - ws = L" "; - ws += it.first; - ws += L"=\""; - ws += wsValue; - ws += L"\""; - pXMLStream->WriteString(ws.AsStringC()); - } - if (pNode->m_pChild) { - ws = L"\n>"; - pXMLStream->WriteString(ws.AsStringC()); - CFDE_XMLNode* pChild = pNode->m_pChild; - while (pChild) { - pChild->SaveXMLNode(pXMLStream); - pChild = pChild->m_pNext; - } - ws = L"(pNode)->GetName(); - ws += L"\n>"; - } else { - ws = L"\n/>"; - } - pXMLStream->WriteString(ws.AsStringC()); - break; - } - case FDE_XMLNODE_Text: { - CFX_WideString ws = static_cast(pNode)->GetText(); - ws.Replace(L"&", L"&"); - ws.Replace(L"<", L"<"); - ws.Replace(L">", L">"); - ws.Replace(L"\'", L"'"); - ws.Replace(L"\"", L"""); - pXMLStream->WriteString(ws.AsStringC()); - break; - } - case FDE_XMLNODE_CharData: { - CFX_WideString ws = L"(pNode)->GetText(); - ws += L"]]>"; - pXMLStream->WriteString(ws.AsStringC()); - break; - } - case FDE_XMLNODE_Unknown: - default: - break; - } -} diff --git a/xfa/fde/xml/cfde_xmlnode.h b/xfa/fde/xml/cfde_xmlnode.h deleted file mode 100644 index 71e1a712e0..0000000000 --- a/xfa/fde/xml/cfde_xmlnode.h +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright 2017 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef XFA_FDE_XML_CFDE_XMLNODE_H_ -#define XFA_FDE_XML_CFDE_XMLNODE_H_ - -#include - -#include "core/fxcrt/cfx_retain_ptr.h" -#include "core/fxcrt/cfx_seekablestreamproxy.h" - -enum FDE_XMLNODETYPE { - FDE_XMLNODE_Unknown = 0, - FDE_XMLNODE_Instruction, - FDE_XMLNODE_Element, - FDE_XMLNODE_Text, - FDE_XMLNODE_CharData, -}; - -struct FDE_XMLNODE { - int32_t iNodeNum; - FDE_XMLNODETYPE eNodeType; -}; - -class CFDE_XMLNode { - public: - enum NodeItem { - Root = 0, - Parent, - FirstSibling, - PriorSibling, - NextSibling, - LastSibling, - FirstNeighbor, - PriorNeighbor, - NextNeighbor, - LastNeighbor, - FirstChild, - LastChild - }; - - CFDE_XMLNode(); - virtual ~CFDE_XMLNode(); - - virtual FDE_XMLNODETYPE GetType() const; - virtual std::unique_ptr Clone(); - - int32_t CountChildNodes() const; - CFDE_XMLNode* GetChildNode(int32_t index) const; - int32_t GetChildNodeIndex(CFDE_XMLNode* pNode) const; - int32_t InsertChildNode(CFDE_XMLNode* pNode, int32_t index = -1); - void RemoveChildNode(CFDE_XMLNode* pNode); - void DeleteChildren(); - - CFDE_XMLNode* GetPath(const wchar_t* pPath, - int32_t iLength = -1, - bool bQualifiedName = true) const; - - int32_t GetNodeLevel() const; - CFDE_XMLNode* GetNodeItem(CFDE_XMLNode::NodeItem eItem) const; - bool InsertNodeItem(CFDE_XMLNode::NodeItem eItem, CFDE_XMLNode* pNode); - CFDE_XMLNode* RemoveNodeItem(CFDE_XMLNode::NodeItem eItem); - - void SaveXMLNode(const CFX_RetainPtr& pXMLStream); - - CFDE_XMLNode* m_pParent; - CFDE_XMLNode* m_pChild; - CFDE_XMLNode* m_pPrior; - CFDE_XMLNode* m_pNext; -}; - -#endif // XFA_FDE_XML_CFDE_XMLNODE_H_ diff --git a/xfa/fde/xml/cfde_xmlparser.cpp b/xfa/fde/xml/cfde_xmlparser.cpp deleted file mode 100644 index c8b300f81d..0000000000 --- a/xfa/fde/xml/cfde_xmlparser.cpp +++ /dev/null @@ -1,171 +0,0 @@ -// Copyright 2016 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#include "xfa/fde/xml/cfde_xmlparser.h" - -#include "core/fxcrt/fx_basic.h" -#include "third_party/base/ptr_util.h" -#include "xfa/fde/xml/cfde_xmlchardata.h" -#include "xfa/fde/xml/cfde_xmlelement.h" -#include "xfa/fde/xml/cfde_xmlinstruction.h" -#include "xfa/fde/xml/cfde_xmlnode.h" -#include "xfa/fde/xml/cfde_xmltext.h" - -CFDE_XMLParser::CFDE_XMLParser( - CFDE_XMLNode* pParent, - const CFX_RetainPtr& pStream) - : m_nElementStart(0), - m_dwCheckStatus(0), - m_dwCurrentCheckStatus(0), - m_pStream(pStream), - m_pParser(pdfium::MakeUnique(m_pStream)), - m_pParent(pParent), - m_pChild(nullptr), - m_syntaxParserResult(FDE_XmlSyntaxResult::None) { - ASSERT(m_pParent && m_pStream); - m_NodeStack.push(m_pParent); -} - -CFDE_XMLParser::~CFDE_XMLParser() {} - -int32_t CFDE_XMLParser::DoParser(IFX_Pause* pPause) { - if (m_syntaxParserResult == FDE_XmlSyntaxResult::Error) - return -1; - if (m_syntaxParserResult == FDE_XmlSyntaxResult::EndOfString) - return 100; - - int32_t iCount = 0; - while (true) { - m_syntaxParserResult = m_pParser->DoSyntaxParse(); - switch (m_syntaxParserResult) { - case FDE_XmlSyntaxResult::InstructionOpen: - break; - case FDE_XmlSyntaxResult::InstructionClose: - if (m_pChild) { - if (m_pChild->GetType() != FDE_XMLNODE_Instruction) { - m_syntaxParserResult = FDE_XmlSyntaxResult::Error; - break; - } - } - m_pChild = m_pParent; - break; - case FDE_XmlSyntaxResult::ElementOpen: - if (m_dwCheckStatus != 0x03 && m_NodeStack.size() == 2) - m_nElementStart = m_pParser->GetCurrentPos() - 1; - break; - case FDE_XmlSyntaxResult::ElementBreak: - break; - case FDE_XmlSyntaxResult::ElementClose: - if (m_pChild->GetType() != FDE_XMLNODE_Element) { - m_syntaxParserResult = FDE_XmlSyntaxResult::Error; - break; - } - m_ws1 = m_pParser->GetTagName(); - m_ws2 = static_cast(m_pChild)->GetName(); - if (m_ws1.GetLength() > 0 && m_ws1 != m_ws2) { - m_syntaxParserResult = FDE_XmlSyntaxResult::Error; - break; - } - if (!m_NodeStack.empty()) - m_NodeStack.pop(); - if (m_NodeStack.empty()) { - m_syntaxParserResult = FDE_XmlSyntaxResult::Error; - break; - } else if (m_dwCurrentCheckStatus != 0 && m_NodeStack.size() == 2) { - m_nSize[m_dwCurrentCheckStatus - 1] = - m_pParser->GetCurrentBinaryPos() - - m_nStart[m_dwCurrentCheckStatus - 1]; - m_dwCurrentCheckStatus = 0; - } - m_pParent = m_NodeStack.top(); - m_pChild = m_pParent; - iCount++; - break; - case FDE_XmlSyntaxResult::TargetName: - m_ws1 = m_pParser->GetTargetName(); - if (m_ws1 == L"originalXFAVersion" || m_ws1 == L"acrobat") { - m_pChild = new CFDE_XMLInstruction(m_ws1); - m_pParent->InsertChildNode(m_pChild); - } else { - m_pChild = nullptr; - } - m_ws1.clear(); - break; - case FDE_XmlSyntaxResult::TagName: - m_ws1 = m_pParser->GetTagName(); - 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.size() == 3) { - CFX_WideString wsTag = - static_cast(m_pChild)->GetLocalTagName(); - if (wsTag == L"template") { - m_dwCheckStatus |= 0x01; - m_dwCurrentCheckStatus = 0x01; - m_nStart[0] = m_pParser->GetCurrentBinaryPos() - - (m_pParser->GetCurrentPos() - m_nElementStart); - } else if (wsTag == L"datasets") { - m_dwCheckStatus |= 0x02; - m_dwCurrentCheckStatus = 0x02; - m_nStart[1] = m_pParser->GetCurrentBinaryPos() - - (m_pParser->GetCurrentPos() - m_nElementStart); - } - } - break; - case FDE_XmlSyntaxResult::AttriName: - m_ws1 = m_pParser->GetAttributeName(); - break; - case FDE_XmlSyntaxResult::AttriValue: - if (m_pChild) { - m_ws2 = m_pParser->GetAttributeName(); - if (m_pChild->GetType() == FDE_XMLNODE_Element) - static_cast(m_pChild)->SetString(m_ws1, m_ws2); - } - m_ws1.clear(); - break; - case FDE_XmlSyntaxResult::Text: - m_ws1 = m_pParser->GetTextData(); - m_pChild = new CFDE_XMLText(m_ws1); - m_pParent->InsertChildNode(m_pChild); - m_pChild = m_pParent; - break; - case FDE_XmlSyntaxResult::CData: - m_ws1 = m_pParser->GetTextData(); - m_pChild = new CFDE_XMLCharData(m_ws1); - m_pParent->InsertChildNode(m_pChild); - m_pChild = m_pParent; - break; - case FDE_XmlSyntaxResult::TargetData: - if (m_pChild) { - if (m_pChild->GetType() != FDE_XMLNODE_Instruction) { - m_syntaxParserResult = FDE_XmlSyntaxResult::Error; - break; - } - auto* instruction = static_cast(m_pChild); - if (!m_ws1.IsEmpty()) - instruction->AppendData(m_ws1); - instruction->AppendData(m_pParser->GetTargetData()); - } - m_ws1.clear(); - break; - default: - break; - } - if (m_syntaxParserResult == FDE_XmlSyntaxResult::Error || - m_syntaxParserResult == FDE_XmlSyntaxResult::EndOfString) { - break; - } - if (pPause && iCount > 500 && pPause->NeedToPauseNow()) { - break; - } - } - return (m_syntaxParserResult == FDE_XmlSyntaxResult::Error || - m_NodeStack.size() != 1) - ? -1 - : m_pParser->GetStatus(); -} diff --git a/xfa/fde/xml/cfde_xmlparser.h b/xfa/fde/xml/cfde_xmlparser.h deleted file mode 100644 index 14b2127068..0000000000 --- a/xfa/fde/xml/cfde_xmlparser.h +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright 2016 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef XFA_FDE_XML_CFDE_XMLPARSER_H_ -#define XFA_FDE_XML_CFDE_XMLPARSER_H_ - -#include -#include - -#include "core/fxcrt/cfx_retain_ptr.h" -#include "core/fxcrt/fx_string.h" -#include "xfa/fde/xml/cfde_xmlsyntaxparser.h" - -class CFDE_XMLElement; -class CFDE_XMLNode; -class CFX_SeekableStreamProxy; -class IFX_Pause; - -class CFDE_XMLParser { - public: - CFDE_XMLParser(CFDE_XMLNode* pParent, - const CFX_RetainPtr& pStream); - ~CFDE_XMLParser(); - - int32_t DoParser(IFX_Pause* pPause); - - FX_FILESIZE m_nStart[2]; - size_t m_nSize[2]; - FX_FILESIZE m_nElementStart; - uint16_t m_dwCheckStatus; - uint16_t m_dwCurrentCheckStatus; - - private: - CFX_RetainPtr m_pStream; - std::unique_ptr m_pParser; - CFDE_XMLNode* m_pParent; - CFDE_XMLNode* m_pChild; - std::stack m_NodeStack; - CFX_WideString m_ws1; - CFX_WideString m_ws2; - FDE_XmlSyntaxResult m_syntaxParserResult; -}; - -#endif // XFA_FDE_XML_CFDE_XMLPARSER_H_ diff --git a/xfa/fde/xml/cfde_xmlsyntaxparser.cpp b/xfa/fde/xml/cfde_xmlsyntaxparser.cpp deleted file mode 100644 index 5d671bb39a..0000000000 --- a/xfa/fde/xml/cfde_xmlsyntaxparser.cpp +++ /dev/null @@ -1,698 +0,0 @@ -// Copyright 2017 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#include "xfa/fde/xml/cfde_xmlsyntaxparser.h" - -#include - -#include "core/fxcrt/fx_ext.h" -#include "core/fxcrt/fx_safe_types.h" - -namespace { - -const uint32_t kMaxCharRange = 0x10ffff; - -bool IsXMLWhiteSpace(wchar_t ch) { - return ch == L' ' || ch == 0x0A || ch == 0x0D || ch == 0x09; -} - -struct FDE_XMLNAMECHAR { - uint16_t wStart; - uint16_t wEnd; - bool bStartChar; -}; - -const FDE_XMLNAMECHAR g_XMLNameChars[] = { - {L'-', L'.', false}, {L'0', L'9', false}, {L':', L':', false}, - {L'A', L'Z', true}, {L'_', L'_', true}, {L'a', L'z', true}, - {0xB7, 0xB7, false}, {0xC0, 0xD6, true}, {0xD8, 0xF6, true}, - {0xF8, 0x02FF, true}, {0x0300, 0x036F, false}, {0x0370, 0x037D, true}, - {0x037F, 0x1FFF, true}, {0x200C, 0x200D, true}, {0x203F, 0x2040, false}, - {0x2070, 0x218F, true}, {0x2C00, 0x2FEF, true}, {0x3001, 0xD7FF, true}, - {0xF900, 0xFDCF, true}, {0xFDF0, 0xFFFD, true}, -}; - -bool IsXMLNameChar(wchar_t ch, bool bFirstChar) { - int32_t iStart = 0; - int32_t iEnd = FX_ArraySize(g_XMLNameChars) - 1; - while (iStart <= iEnd) { - int32_t iMid = (iStart + iEnd) / 2; - if (ch < g_XMLNameChars[iMid].wStart) { - iEnd = iMid - 1; - } else if (ch > g_XMLNameChars[iMid].wEnd) { - iStart = iMid + 1; - } else { - return bFirstChar ? g_XMLNameChars[iMid].bStartChar : true; - } - } - return false; -} - -int32_t GetUTF8EncodeLength(const std::vector& src, - FX_FILESIZE iSrcLen) { - uint32_t unicode = 0; - int32_t iDstNum = 0; - const wchar_t* pSrc = src.data(); - while (iSrcLen-- > 0) { - unicode = *pSrc++; - int nbytes = 0; - if ((uint32_t)unicode < 0x80) { - nbytes = 1; - } else if ((uint32_t)unicode < 0x800) { - nbytes = 2; - } else if ((uint32_t)unicode < 0x10000) { - nbytes = 3; - } else if ((uint32_t)unicode < 0x200000) { - nbytes = 4; - } else if ((uint32_t)unicode < 0x4000000) { - nbytes = 5; - } else { - nbytes = 6; - } - iDstNum += nbytes; - } - return iDstNum; -} - -} // namespace - -CFDE_XMLSyntaxParser::CFDE_XMLSyntaxParser( - const CFX_RetainPtr& pStream) - : m_pStream(pStream), - m_iXMLPlaneSize(32 * 1024), - m_iCurrentPos(0), - m_iCurrentNodeNum(-1), - m_iLastNodeNum(-1), - m_iParsedBytes(0), - m_ParsedChars(0), - m_iBufferChars(0), - m_bEOS(false), - m_Start(0), - m_End(0), - m_iAllocStep(m_BlockBuffer.GetAllocStep()), - m_pCurrentBlock(nullptr), - m_iIndexInBlock(0), - m_iTextDataLength(0), - m_syntaxParserResult(FDE_XmlSyntaxResult::None), - m_syntaxParserState(FDE_XmlSyntaxState::Text), - m_wQuotationMark(0), - m_iEntityStart(-1) { - ASSERT(pStream); - - m_CurNode.iNodeNum = -1; - m_CurNode.eNodeType = FDE_XMLNODE_Unknown; - - m_iXMLPlaneSize = - std::min(m_iXMLPlaneSize, - pdfium::base::checked_cast(m_pStream->GetLength())); - m_iCurrentPos = m_pStream->GetBOMLength(); - - FX_SAFE_STRSIZE alloc_size_safe = m_iXMLPlaneSize; - alloc_size_safe += 1; // For NUL. - if (!alloc_size_safe.IsValid() || alloc_size_safe.ValueOrDie() <= 0) { - m_syntaxParserResult = FDE_XmlSyntaxResult::Error; - return; - } - - m_Buffer.resize(pdfium::base::ValueOrDieForType(alloc_size_safe)); - - m_BlockBuffer.InitBuffer(); - std::tie(m_pCurrentBlock, m_iIndexInBlock) = - m_BlockBuffer.GetAvailableBlock(); -} - -CFDE_XMLSyntaxParser::~CFDE_XMLSyntaxParser() {} - -FDE_XmlSyntaxResult CFDE_XMLSyntaxParser::DoSyntaxParse() { - if (m_syntaxParserResult == FDE_XmlSyntaxResult::Error || - m_syntaxParserResult == FDE_XmlSyntaxResult::EndOfString) { - return m_syntaxParserResult; - } - - int32_t iStreamLength = m_pStream->GetLength(); - int32_t iPos; - - FDE_XmlSyntaxResult syntaxParserResult = FDE_XmlSyntaxResult::None; - while (true) { - if (m_Start >= m_End) { - if (m_bEOS || m_iCurrentPos >= iStreamLength) { - m_syntaxParserResult = FDE_XmlSyntaxResult::EndOfString; - return m_syntaxParserResult; - } - m_ParsedChars += m_End; - m_iParsedBytes = m_iCurrentPos; - if (m_pStream->GetPosition() != m_iCurrentPos) - m_pStream->Seek(CFX_SeekableStreamProxy::Pos::Begin, m_iCurrentPos); - - m_iBufferChars = - m_pStream->ReadString(m_Buffer.data(), m_iXMLPlaneSize, &m_bEOS); - iPos = m_pStream->GetPosition(); - if (m_iBufferChars < 1) { - m_iCurrentPos = iStreamLength; - m_syntaxParserResult = FDE_XmlSyntaxResult::EndOfString; - return m_syntaxParserResult; - } - m_iCurrentPos = iPos; - m_Start = 0; - m_End = m_iBufferChars; - } - - while (m_Start < m_End) { - wchar_t ch = m_Buffer[m_Start]; - switch (m_syntaxParserState) { - case FDE_XmlSyntaxState::Text: - if (ch == L'<') { - if (!m_BlockBuffer.IsEmpty()) { - m_iTextDataLength = m_BlockBuffer.GetDataLength(); - m_BlockBuffer.Reset(true); - std::tie(m_pCurrentBlock, m_iIndexInBlock) = - m_BlockBuffer.GetAvailableBlock(); - m_iEntityStart = -1; - syntaxParserResult = FDE_XmlSyntaxResult::Text; - } else { - m_Start++; - m_syntaxParserState = FDE_XmlSyntaxState::Node; - } - } else { - ParseTextChar(ch); - } - break; - case FDE_XmlSyntaxState::Node: - if (ch == L'!') { - m_Start++; - m_syntaxParserState = FDE_XmlSyntaxState::SkipCommentOrDecl; - } else if (ch == L'/') { - m_Start++; - m_syntaxParserState = FDE_XmlSyntaxState::CloseElement; - } else if (ch == L'?') { - m_iLastNodeNum++; - m_iCurrentNodeNum = m_iLastNodeNum; - m_CurNode.iNodeNum = m_iLastNodeNum; - m_CurNode.eNodeType = FDE_XMLNODE_Instruction; - m_XMLNodeStack.push(m_CurNode); - m_Start++; - m_syntaxParserState = FDE_XmlSyntaxState::Target; - syntaxParserResult = FDE_XmlSyntaxResult::InstructionOpen; - } else { - m_iLastNodeNum++; - m_iCurrentNodeNum = m_iLastNodeNum; - m_CurNode.iNodeNum = m_iLastNodeNum; - m_CurNode.eNodeType = FDE_XMLNODE_Element; - m_XMLNodeStack.push(m_CurNode); - m_syntaxParserState = FDE_XmlSyntaxState::Tag; - syntaxParserResult = FDE_XmlSyntaxResult::ElementOpen; - } - break; - case FDE_XmlSyntaxState::Target: - case FDE_XmlSyntaxState::Tag: - if (!IsXMLNameChar(ch, m_BlockBuffer.IsEmpty())) { - if (m_BlockBuffer.IsEmpty()) { - m_syntaxParserResult = FDE_XmlSyntaxResult::Error; - return m_syntaxParserResult; - } - - m_iTextDataLength = m_BlockBuffer.GetDataLength(); - m_BlockBuffer.Reset(true); - std::tie(m_pCurrentBlock, m_iIndexInBlock) = - m_BlockBuffer.GetAvailableBlock(); - if (m_syntaxParserState != FDE_XmlSyntaxState::Target) - syntaxParserResult = FDE_XmlSyntaxResult::TagName; - else - syntaxParserResult = FDE_XmlSyntaxResult::TargetName; - - m_syntaxParserState = FDE_XmlSyntaxState::AttriName; - } else { - if (m_iIndexInBlock == m_iAllocStep) { - std::tie(m_pCurrentBlock, m_iIndexInBlock) = - m_BlockBuffer.GetAvailableBlock(); - if (!m_pCurrentBlock) { - return FDE_XmlSyntaxResult::Error; - } - } - m_pCurrentBlock[m_iIndexInBlock++] = ch; - m_BlockBuffer.IncrementDataLength(); - m_Start++; - } - break; - case FDE_XmlSyntaxState::AttriName: - if (m_BlockBuffer.IsEmpty() && IsXMLWhiteSpace(ch)) { - m_Start++; - break; - } - if (!IsXMLNameChar(ch, m_BlockBuffer.IsEmpty())) { - if (m_BlockBuffer.IsEmpty()) { - if (m_CurNode.eNodeType == FDE_XMLNODE_Element) { - if (ch == L'>' || ch == L'/') { - m_syntaxParserState = FDE_XmlSyntaxState::BreakElement; - break; - } - } else if (m_CurNode.eNodeType == FDE_XMLNODE_Instruction) { - if (ch == L'?') { - m_syntaxParserState = FDE_XmlSyntaxState::CloseInstruction; - m_Start++; - } else { - m_syntaxParserState = FDE_XmlSyntaxState::TargetData; - } - break; - } - m_syntaxParserResult = FDE_XmlSyntaxResult::Error; - return m_syntaxParserResult; - } else { - if (m_CurNode.eNodeType == FDE_XMLNODE_Instruction) { - if (ch != '=' && !IsXMLWhiteSpace(ch)) { - m_syntaxParserState = FDE_XmlSyntaxState::TargetData; - break; - } - } - m_iTextDataLength = m_BlockBuffer.GetDataLength(); - m_BlockBuffer.Reset(true); - std::tie(m_pCurrentBlock, m_iIndexInBlock) = - m_BlockBuffer.GetAvailableBlock(); - m_syntaxParserState = FDE_XmlSyntaxState::AttriEqualSign; - syntaxParserResult = FDE_XmlSyntaxResult::AttriName; - } - } else { - if (m_iIndexInBlock == m_iAllocStep) { - std::tie(m_pCurrentBlock, m_iIndexInBlock) = - m_BlockBuffer.GetAvailableBlock(); - if (!m_pCurrentBlock) { - return FDE_XmlSyntaxResult::Error; - } - } - m_pCurrentBlock[m_iIndexInBlock++] = ch; - m_BlockBuffer.IncrementDataLength(); - m_Start++; - } - break; - case FDE_XmlSyntaxState::AttriEqualSign: - if (IsXMLWhiteSpace(ch)) { - m_Start++; - break; - } - if (ch != L'=') { - if (m_CurNode.eNodeType == FDE_XMLNODE_Instruction) { - m_syntaxParserState = FDE_XmlSyntaxState::TargetData; - break; - } - m_syntaxParserResult = FDE_XmlSyntaxResult::Error; - return m_syntaxParserResult; - } else { - m_syntaxParserState = FDE_XmlSyntaxState::AttriQuotation; - m_Start++; - } - break; - case FDE_XmlSyntaxState::AttriQuotation: - if (IsXMLWhiteSpace(ch)) { - m_Start++; - break; - } - if (ch != L'\"' && ch != L'\'') { - m_syntaxParserResult = FDE_XmlSyntaxResult::Error; - return m_syntaxParserResult; - } else { - m_wQuotationMark = ch; - m_syntaxParserState = FDE_XmlSyntaxState::AttriValue; - m_Start++; - } - break; - case FDE_XmlSyntaxState::AttriValue: - if (ch == m_wQuotationMark) { - if (m_iEntityStart > -1) { - m_syntaxParserResult = FDE_XmlSyntaxResult::Error; - return m_syntaxParserResult; - } - m_iTextDataLength = m_BlockBuffer.GetDataLength(); - m_wQuotationMark = 0; - m_BlockBuffer.Reset(true); - std::tie(m_pCurrentBlock, m_iIndexInBlock) = - m_BlockBuffer.GetAvailableBlock(); - m_Start++; - m_syntaxParserState = FDE_XmlSyntaxState::AttriName; - syntaxParserResult = FDE_XmlSyntaxResult::AttriValue; - } else { - ParseTextChar(ch); - } - break; - case FDE_XmlSyntaxState::CloseInstruction: - if (ch != L'>') { - if (m_iIndexInBlock == m_iAllocStep) { - std::tie(m_pCurrentBlock, m_iIndexInBlock) = - m_BlockBuffer.GetAvailableBlock(); - if (!m_pCurrentBlock) { - return FDE_XmlSyntaxResult::Error; - } - } - m_pCurrentBlock[m_iIndexInBlock++] = ch; - m_BlockBuffer.IncrementDataLength(); - m_syntaxParserState = FDE_XmlSyntaxState::TargetData; - } else if (!m_BlockBuffer.IsEmpty()) { - m_iTextDataLength = m_BlockBuffer.GetDataLength(); - m_BlockBuffer.Reset(true); - std::tie(m_pCurrentBlock, m_iIndexInBlock) = - m_BlockBuffer.GetAvailableBlock(); - syntaxParserResult = FDE_XmlSyntaxResult::TargetData; - } else { - m_Start++; - if (m_XMLNodeStack.empty()) { - m_syntaxParserResult = FDE_XmlSyntaxResult::Error; - return m_syntaxParserResult; - } - m_XMLNodeStack.pop(); - if (!m_XMLNodeStack.empty()) { - m_CurNode = m_XMLNodeStack.top(); - } else { - m_CurNode.iNodeNum = -1; - m_CurNode.eNodeType = FDE_XMLNODE_Unknown; - } - m_iCurrentNodeNum = m_CurNode.iNodeNum; - m_BlockBuffer.Reset(true); - std::tie(m_pCurrentBlock, m_iIndexInBlock) = - m_BlockBuffer.GetAvailableBlock(); - m_syntaxParserState = FDE_XmlSyntaxState::Text; - syntaxParserResult = FDE_XmlSyntaxResult::InstructionClose; - } - break; - case FDE_XmlSyntaxState::BreakElement: - if (ch == L'>') { - m_syntaxParserState = FDE_XmlSyntaxState::Text; - syntaxParserResult = FDE_XmlSyntaxResult::ElementBreak; - } else if (ch == L'/') { - m_syntaxParserState = FDE_XmlSyntaxState::CloseElement; - } else { - m_syntaxParserResult = FDE_XmlSyntaxResult::Error; - return m_syntaxParserResult; - } - m_Start++; - break; - case FDE_XmlSyntaxState::CloseElement: - if (!IsXMLNameChar(ch, m_BlockBuffer.IsEmpty())) { - if (ch == L'>') { - if (m_XMLNodeStack.empty()) { - m_syntaxParserResult = FDE_XmlSyntaxResult::Error; - return m_syntaxParserResult; - } - m_XMLNodeStack.pop(); - if (!m_XMLNodeStack.empty()) { - m_CurNode = m_XMLNodeStack.top(); - } else { - m_CurNode.iNodeNum = -1; - m_CurNode.eNodeType = FDE_XMLNODE_Unknown; - } - m_iCurrentNodeNum = m_CurNode.iNodeNum; - m_iTextDataLength = m_BlockBuffer.GetDataLength(); - m_BlockBuffer.Reset(true); - std::tie(m_pCurrentBlock, m_iIndexInBlock) = - m_BlockBuffer.GetAvailableBlock(); - m_syntaxParserState = FDE_XmlSyntaxState::Text; - syntaxParserResult = FDE_XmlSyntaxResult::ElementClose; - } else if (!IsXMLWhiteSpace(ch)) { - m_syntaxParserResult = FDE_XmlSyntaxResult::Error; - return m_syntaxParserResult; - } - } else { - if (m_iIndexInBlock == m_iAllocStep) { - std::tie(m_pCurrentBlock, m_iIndexInBlock) = - m_BlockBuffer.GetAvailableBlock(); - if (!m_pCurrentBlock) { - return FDE_XmlSyntaxResult::Error; - } - } - m_pCurrentBlock[m_iIndexInBlock++] = ch; - m_BlockBuffer.IncrementDataLength(); - } - m_Start++; - break; - case FDE_XmlSyntaxState::SkipCommentOrDecl: - if (FXSYS_wcsnicmp(m_Buffer.data() + m_Start, L"--", 2) == 0) { - m_Start += 2; - m_syntaxParserState = FDE_XmlSyntaxState::SkipComment; - } else if (FXSYS_wcsnicmp(m_Buffer.data() + m_Start, L"[CDATA[", 7) == - 0) { - m_Start += 7; - m_syntaxParserState = FDE_XmlSyntaxState::SkipCData; - } else { - m_syntaxParserState = FDE_XmlSyntaxState::SkipDeclNode; - m_SkipChar = L'>'; - m_SkipStack.push(L'>'); - } - break; - case FDE_XmlSyntaxState::SkipCData: { - if (FXSYS_wcsnicmp(m_Buffer.data() + m_Start, L"]]>", 3) == 0) { - m_Start += 3; - syntaxParserResult = FDE_XmlSyntaxResult::CData; - m_iTextDataLength = m_BlockBuffer.GetDataLength(); - m_BlockBuffer.Reset(true); - std::tie(m_pCurrentBlock, m_iIndexInBlock) = - m_BlockBuffer.GetAvailableBlock(); - m_syntaxParserState = FDE_XmlSyntaxState::Text; - } else { - if (m_iIndexInBlock == m_iAllocStep) { - std::tie(m_pCurrentBlock, m_iIndexInBlock) = - m_BlockBuffer.GetAvailableBlock(); - if (!m_pCurrentBlock) - return FDE_XmlSyntaxResult::Error; - } - m_pCurrentBlock[m_iIndexInBlock++] = ch; - m_BlockBuffer.IncrementDataLength(); - m_Start++; - } - break; - } - case FDE_XmlSyntaxState::SkipDeclNode: - if (m_SkipChar == L'\'' || m_SkipChar == L'\"') { - m_Start++; - if (ch != m_SkipChar) - break; - - m_SkipStack.pop(); - if (m_SkipStack.empty()) - m_syntaxParserState = FDE_XmlSyntaxState::Text; - else - m_SkipChar = m_SkipStack.top(); - } else { - switch (ch) { - case L'<': - m_SkipChar = L'>'; - m_SkipStack.push(L'>'); - break; - case L'[': - m_SkipChar = L']'; - m_SkipStack.push(L']'); - break; - case L'(': - m_SkipChar = L')'; - m_SkipStack.push(L')'); - break; - case L'\'': - m_SkipChar = L'\''; - m_SkipStack.push(L'\''); - break; - case L'\"': - m_SkipChar = L'\"'; - m_SkipStack.push(L'\"'); - break; - default: - if (ch == m_SkipChar) { - m_SkipStack.pop(); - if (m_SkipStack.empty()) { - if (m_BlockBuffer.GetDataLength() >= 9) - (void)m_BlockBuffer.GetTextData(0, 7); - - m_iTextDataLength = m_BlockBuffer.GetDataLength(); - m_BlockBuffer.Reset(true); - std::tie(m_pCurrentBlock, m_iIndexInBlock) = - m_BlockBuffer.GetAvailableBlock(); - m_syntaxParserState = FDE_XmlSyntaxState::Text; - } else { - m_SkipChar = m_SkipStack.top(); - } - } - break; - } - if (!m_SkipStack.empty()) { - if (m_iIndexInBlock == m_iAllocStep) { - std::tie(m_pCurrentBlock, m_iIndexInBlock) = - m_BlockBuffer.GetAvailableBlock(); - if (!m_pCurrentBlock) { - return FDE_XmlSyntaxResult::Error; - } - } - m_pCurrentBlock[m_iIndexInBlock++] = ch; - m_BlockBuffer.IncrementDataLength(); - } - m_Start++; - } - break; - case FDE_XmlSyntaxState::SkipComment: - if (FXSYS_wcsnicmp(m_Buffer.data() + m_Start, L"-->", 3) == 0) { - m_Start += 2; - m_syntaxParserState = FDE_XmlSyntaxState::Text; - } - - m_Start++; - break; - case FDE_XmlSyntaxState::TargetData: - if (IsXMLWhiteSpace(ch)) { - if (m_BlockBuffer.IsEmpty()) { - m_Start++; - break; - } else if (m_wQuotationMark == 0) { - m_iTextDataLength = m_BlockBuffer.GetDataLength(); - m_wQuotationMark = 0; - m_BlockBuffer.Reset(true); - std::tie(m_pCurrentBlock, m_iIndexInBlock) = - m_BlockBuffer.GetAvailableBlock(); - m_Start++; - syntaxParserResult = FDE_XmlSyntaxResult::TargetData; - break; - } - } - if (ch == '?') { - m_syntaxParserState = FDE_XmlSyntaxState::CloseInstruction; - m_Start++; - } else if (ch == '\"') { - if (m_wQuotationMark == 0) { - m_wQuotationMark = ch; - m_Start++; - } else if (ch == m_wQuotationMark) { - m_iTextDataLength = m_BlockBuffer.GetDataLength(); - m_wQuotationMark = 0; - m_BlockBuffer.Reset(true); - std::tie(m_pCurrentBlock, m_iIndexInBlock) = - m_BlockBuffer.GetAvailableBlock(); - m_Start++; - syntaxParserResult = FDE_XmlSyntaxResult::TargetData; - } else { - m_syntaxParserResult = FDE_XmlSyntaxResult::Error; - return m_syntaxParserResult; - } - } else { - if (m_iIndexInBlock == m_iAllocStep) { - std::tie(m_pCurrentBlock, m_iIndexInBlock) = - m_BlockBuffer.GetAvailableBlock(); - if (!m_pCurrentBlock) { - return FDE_XmlSyntaxResult::Error; - } - } - m_pCurrentBlock[m_iIndexInBlock++] = ch; - m_BlockBuffer.IncrementDataLength(); - m_Start++; - } - break; - default: - break; - } - if (syntaxParserResult != FDE_XmlSyntaxResult::None) - return syntaxParserResult; - } - } - return FDE_XmlSyntaxResult::Text; -} - -int32_t CFDE_XMLSyntaxParser::GetStatus() const { - if (!m_pStream) - return -1; - - int32_t iStreamLength = m_pStream->GetLength(); - if (iStreamLength < 1) - return 100; - - if (m_syntaxParserResult == FDE_XmlSyntaxResult::Error) - return -1; - - if (m_syntaxParserResult == FDE_XmlSyntaxResult::EndOfString) - return 100; - return m_iParsedBytes * 100 / iStreamLength; -} - -FX_FILESIZE CFDE_XMLSyntaxParser::GetCurrentBinaryPos() const { - if (!m_pStream) - return 0; - - int32_t nDstLen = GetUTF8EncodeLength(m_Buffer, m_Start); - return m_iParsedBytes + nDstLen; -} - -void CFDE_XMLSyntaxParser::ParseTextChar(wchar_t character) { - if (m_iIndexInBlock == m_iAllocStep) { - std::tie(m_pCurrentBlock, m_iIndexInBlock) = - m_BlockBuffer.GetAvailableBlock(); - if (!m_pCurrentBlock) - return; - } - - m_pCurrentBlock[m_iIndexInBlock++] = character; - m_BlockBuffer.IncrementDataLength(); - if (m_iEntityStart > -1 && character == L';') { - CFX_WideString csEntity = m_BlockBuffer.GetTextData( - m_iEntityStart + 1, - m_BlockBuffer.GetDataLength() - 1 - m_iEntityStart - 1); - int32_t iLen = csEntity.GetLength(); - if (iLen > 0) { - if (csEntity[0] == L'#') { - uint32_t ch = 0; - wchar_t w; - if (iLen > 1 && csEntity[1] == L'x') { - for (int32_t i = 2; i < iLen; i++) { - w = csEntity[i]; - if (w >= L'0' && w <= L'9') { - ch = (ch << 4) + w - L'0'; - } else if (w >= L'A' && w <= L'F') { - ch = (ch << 4) + w - 55; - } else if (w >= L'a' && w <= L'f') { - ch = (ch << 4) + w - 87; - } else { - break; - } - } - } else { - for (int32_t i = 1; i < iLen; i++) { - w = csEntity[i]; - if (w < L'0' || w > L'9') - break; - ch = ch * 10 + w - L'0'; - } - } - if (ch > kMaxCharRange) - ch = ' '; - - character = static_cast(ch); - if (character != 0) { - m_BlockBuffer.SetTextChar(m_iEntityStart, character); - m_iEntityStart++; - } - } else { - if (csEntity.Compare(L"amp") == 0) { - m_BlockBuffer.SetTextChar(m_iEntityStart, L'&'); - m_iEntityStart++; - } else if (csEntity.Compare(L"lt") == 0) { - m_BlockBuffer.SetTextChar(m_iEntityStart, L'<'); - m_iEntityStart++; - } else if (csEntity.Compare(L"gt") == 0) { - m_BlockBuffer.SetTextChar(m_iEntityStart, L'>'); - m_iEntityStart++; - } else if (csEntity.Compare(L"apos") == 0) { - m_BlockBuffer.SetTextChar(m_iEntityStart, L'\''); - m_iEntityStart++; - } else if (csEntity.Compare(L"quot") == 0) { - m_BlockBuffer.SetTextChar(m_iEntityStart, L'\"'); - m_iEntityStart++; - } - } - } - if (m_iEntityStart >= 0 && - m_BlockBuffer.GetDataLength() > static_cast(m_iEntityStart)) { - m_BlockBuffer.DeleteTextChars(m_BlockBuffer.GetDataLength() - - m_iEntityStart); - } - std::tie(m_pCurrentBlock, m_iIndexInBlock) = - m_BlockBuffer.GetAvailableBlock(); - m_iEntityStart = -1; - } else if (m_iEntityStart < 0 && character == L'&') { - m_iEntityStart = m_BlockBuffer.GetDataLength() - 1; - } - m_Start++; -} diff --git a/xfa/fde/xml/cfde_xmlsyntaxparser.h b/xfa/fde/xml/cfde_xmlsyntaxparser.h deleted file mode 100644 index 8b6c9ac8b5..0000000000 --- a/xfa/fde/xml/cfde_xmlsyntaxparser.h +++ /dev/null @@ -1,128 +0,0 @@ -// Copyright 2017 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef XFA_FDE_XML_CFDE_XMLSYNTAXPARSER_H_ -#define XFA_FDE_XML_CFDE_XMLSYNTAXPARSER_H_ - -#include -#include - -#include "core/fxcrt/cfx_blockbuffer.h" -#include "core/fxcrt/cfx_retain_ptr.h" -#include "core/fxcrt/cfx_seekablestreamproxy.h" -#include "core/fxcrt/fx_string.h" -#include "xfa/fde/xml/cfde_xmlnode.h" - -enum class FDE_XmlSyntaxResult { - None, - InstructionOpen, - InstructionClose, - ElementOpen, - ElementBreak, - ElementClose, - TargetName, - TagName, - AttriName, - AttriValue, - Text, - CData, - TargetData, - Error, - EndOfString -}; - -class CFDE_XMLSyntaxParser { - public: - explicit CFDE_XMLSyntaxParser( - const CFX_RetainPtr& pStream); - ~CFDE_XMLSyntaxParser(); - - FDE_XmlSyntaxResult DoSyntaxParse(); - - int32_t GetStatus() const; - FX_FILESIZE GetCurrentPos() const { return m_ParsedChars + m_Start; } - FX_FILESIZE GetCurrentBinaryPos() const; - int32_t GetCurrentNodeNumber() const { return m_iCurrentNodeNum; } - int32_t GetLastNodeNumber() const { return m_iLastNodeNum; } - - CFX_WideString GetTargetName() const { - return m_BlockBuffer.GetTextData(0, m_iTextDataLength); - } - - CFX_WideString GetTagName() const { - return m_BlockBuffer.GetTextData(0, m_iTextDataLength); - } - - CFX_WideString GetAttributeName() const { - return m_BlockBuffer.GetTextData(0, m_iTextDataLength); - } - - CFX_WideString GetAttributeValue() const { - return m_BlockBuffer.GetTextData(0, m_iTextDataLength); - } - - CFX_WideString GetTextData() const { - return m_BlockBuffer.GetTextData(0, m_iTextDataLength); - } - - CFX_WideString GetTargetData() const { - return m_BlockBuffer.GetTextData(0, m_iTextDataLength); - } - - protected: - enum class FDE_XmlSyntaxState { - Text, - Node, - Target, - Tag, - AttriName, - AttriEqualSign, - AttriQuotation, - AttriValue, - Entity, - EntityDecimal, - EntityHex, - CloseInstruction, - BreakElement, - CloseElement, - SkipDeclNode, - DeclCharData, - SkipComment, - SkipCommentOrDecl, - SkipCData, - TargetData - }; - - void ParseTextChar(wchar_t ch); - - CFX_RetainPtr m_pStream; - FX_STRSIZE m_iXMLPlaneSize; - int32_t m_iCurrentPos; - int32_t m_iCurrentNodeNum; - int32_t m_iLastNodeNum; - int32_t m_iParsedBytes; - FX_FILESIZE m_ParsedChars; - std::vector m_Buffer; - int32_t m_iBufferChars; - bool m_bEOS; - FX_FILESIZE m_Start; // Start position in m_Buffer - FX_FILESIZE m_End; // End position in m_Buffer - FDE_XMLNODE m_CurNode; - std::stack m_XMLNodeStack; - CFX_BlockBuffer m_BlockBuffer; - int32_t m_iAllocStep; - wchar_t* m_pCurrentBlock; // Pointer into CFX_BlockBuffer - int32_t m_iIndexInBlock; - int32_t m_iTextDataLength; - FDE_XmlSyntaxResult m_syntaxParserResult; - FDE_XmlSyntaxState m_syntaxParserState; - wchar_t m_wQuotationMark; - int32_t m_iEntityStart; - std::stack m_SkipStack; - wchar_t m_SkipChar; -}; - -#endif // XFA_FDE_XML_CFDE_XMLSYNTAXPARSER_H_ diff --git a/xfa/fde/xml/cfde_xmlsyntaxparser_unittest.cpp b/xfa/fde/xml/cfde_xmlsyntaxparser_unittest.cpp deleted file mode 100644 index 45ad3bb2f0..0000000000 --- a/xfa/fde/xml/cfde_xmlsyntaxparser_unittest.cpp +++ /dev/null @@ -1,527 +0,0 @@ -// Copyright 2016 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "xfa/fde/xml/cfde_xmlsyntaxparser.h" - -#include - -#include "core/fxcrt/cfx_seekablestreamproxy.h" -#include "core/fxcrt/fx_codepage.h" -#include "testing/gtest/include/gtest/gtest.h" -#include "testing/test_support.h" - -class CFDE_XMLSyntaxParserTest : public pdfium::FPDF_Test {}; - -TEST_F(CFDE_XMLSyntaxParserTest, CData) { - const char* input = - ""; - - const wchar_t* cdata = - L"\n" - L" if (a[1] < 3)\n" - L" app.alert(\"Tclams\");\n" - L" "; - - CFX_RetainPtr stream = - pdfium::MakeRetain( - reinterpret_cast(const_cast(input)), strlen(input)); - stream->SetCodePage(FX_CODEPAGE_UTF8); - - CFDE_XMLSyntaxParser parser(stream); - ASSERT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); - ASSERT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse()); - ASSERT_EQ(L"script", parser.GetTagName()); - - ASSERT_EQ(FDE_XmlSyntaxResult::AttriName, parser.DoSyntaxParse()); - ASSERT_EQ(L"contentType", parser.GetAttributeName()); - ASSERT_EQ(FDE_XmlSyntaxResult::AttriValue, parser.DoSyntaxParse()); - ASSERT_EQ(L"application/x-javascript", parser.GetAttributeValue()); - - ASSERT_EQ(FDE_XmlSyntaxResult::ElementBreak, parser.DoSyntaxParse()); - ASSERT_EQ(FDE_XmlSyntaxResult::Text, parser.DoSyntaxParse()); - ASSERT_EQ(L"\n ", parser.GetTextData()); - - ASSERT_EQ(FDE_XmlSyntaxResult::CData, parser.DoSyntaxParse()); - ASSERT_EQ(cdata, parser.GetTextData()); - - ASSERT_EQ(FDE_XmlSyntaxResult::Text, parser.DoSyntaxParse()); - ASSERT_EQ(L"\n", parser.GetTextData()); - - ASSERT_EQ(FDE_XmlSyntaxResult::ElementClose, parser.DoSyntaxParse()); - ASSERT_EQ(L"script", parser.GetTagName()); - - ASSERT_EQ(FDE_XmlSyntaxResult::EndOfString, parser.DoSyntaxParse()); -} - -TEST_F(CFDE_XMLSyntaxParserTest, CDataWithInnerScript) { - const char* input = - "\n" - " ]]>\n" - ""; - - const wchar_t* cdata = - L"\n" - L" if (a[1] < 3)\n" - L" app.alert(\"Tclams\");\n" - L" \n" - L" "; - - CFX_RetainPtr stream = - pdfium::MakeRetain( - reinterpret_cast(const_cast(input)), strlen(input)); - stream->SetCodePage(FX_CODEPAGE_UTF8); - - CFDE_XMLSyntaxParser parser(stream); - ASSERT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); - ASSERT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse()); - ASSERT_EQ(L"script", parser.GetTagName()); - - ASSERT_EQ(FDE_XmlSyntaxResult::AttriName, parser.DoSyntaxParse()); - ASSERT_EQ(L"contentType", parser.GetAttributeName()); - ASSERT_EQ(FDE_XmlSyntaxResult::AttriValue, parser.DoSyntaxParse()); - ASSERT_EQ(L"application/x-javascript", parser.GetAttributeValue()); - - ASSERT_EQ(FDE_XmlSyntaxResult::ElementBreak, parser.DoSyntaxParse()); - ASSERT_EQ(FDE_XmlSyntaxResult::Text, parser.DoSyntaxParse()); - ASSERT_EQ(L"\n ", parser.GetTextData()); - - ASSERT_EQ(FDE_XmlSyntaxResult::CData, parser.DoSyntaxParse()); - ASSERT_EQ(cdata, parser.GetTextData()); - - ASSERT_EQ(FDE_XmlSyntaxResult::Text, parser.DoSyntaxParse()); - ASSERT_EQ(L"\n", parser.GetTextData()); - - ASSERT_EQ(FDE_XmlSyntaxResult::ElementClose, parser.DoSyntaxParse()); - ASSERT_EQ(L"script", parser.GetTagName()); - - ASSERT_EQ(FDE_XmlSyntaxResult::EndOfString, parser.DoSyntaxParse()); -} - -TEST_F(CFDE_XMLSyntaxParserTest, ArrowBangArrow) { - const char* input = - ""; - - CFX_RetainPtr stream = - pdfium::MakeRetain( - reinterpret_cast(const_cast(input)), strlen(input)); - stream->SetCodePage(FX_CODEPAGE_UTF8); - - CFDE_XMLSyntaxParser parser(stream); - ASSERT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); - ASSERT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse()); - - ASSERT_EQ(L"script", parser.GetTagName()); - - ASSERT_EQ(FDE_XmlSyntaxResult::AttriName, parser.DoSyntaxParse()); - ASSERT_EQ(L"contentType", parser.GetAttributeName()); - ASSERT_EQ(FDE_XmlSyntaxResult::AttriValue, parser.DoSyntaxParse()); - ASSERT_EQ(L"application/x-javascript", parser.GetAttributeValue()); - - ASSERT_EQ(FDE_XmlSyntaxResult::ElementBreak, parser.DoSyntaxParse()); - ASSERT_EQ(FDE_XmlSyntaxResult::Text, parser.DoSyntaxParse()); - ASSERT_EQ(L"\n ", parser.GetTextData()); - - ASSERT_EQ(FDE_XmlSyntaxResult::Text, parser.DoSyntaxParse()); - ASSERT_EQ(L"\n", parser.GetTextData()); - - ASSERT_EQ(FDE_XmlSyntaxResult::ElementClose, parser.DoSyntaxParse()); - ASSERT_EQ(L"script", parser.GetTagName()); - - ASSERT_EQ(FDE_XmlSyntaxResult::EndOfString, parser.DoSyntaxParse()); -} - -TEST_F(CFDE_XMLSyntaxParserTest, ArrowBangBracketArrow) { - const char* input = - ""; - - CFX_RetainPtr stream = - pdfium::MakeRetain( - reinterpret_cast(const_cast(input)), strlen(input)); - stream->SetCodePage(FX_CODEPAGE_UTF8); - - CFDE_XMLSyntaxParser parser(stream); - ASSERT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); - ASSERT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse()); - ASSERT_EQ(L"script", parser.GetTagName()); - - ASSERT_EQ(FDE_XmlSyntaxResult::AttriName, parser.DoSyntaxParse()); - ASSERT_EQ(L"contentType", parser.GetAttributeName()); - ASSERT_EQ(FDE_XmlSyntaxResult::AttriValue, parser.DoSyntaxParse()); - ASSERT_EQ(L"application/x-javascript", parser.GetAttributeValue()); - - ASSERT_EQ(FDE_XmlSyntaxResult::ElementBreak, parser.DoSyntaxParse()); - ASSERT_EQ(FDE_XmlSyntaxResult::Text, parser.DoSyntaxParse()); - ASSERT_EQ(L"\n ", parser.GetTextData()); - - // Parser walks to end of input. - - ASSERT_EQ(FDE_XmlSyntaxResult::EndOfString, parser.DoSyntaxParse()); -} - -TEST_F(CFDE_XMLSyntaxParserTest, IncompleteCData) { - const char* input = - ""; - - CFX_RetainPtr stream = - pdfium::MakeRetain( - reinterpret_cast(const_cast(input)), strlen(input)); - stream->SetCodePage(FX_CODEPAGE_UTF8); - - CFDE_XMLSyntaxParser parser(stream); - ASSERT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); - ASSERT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse()); - ASSERT_EQ(L"script", parser.GetTagName()); - - ASSERT_EQ(FDE_XmlSyntaxResult::AttriName, parser.DoSyntaxParse()); - ASSERT_EQ(L"contentType", parser.GetAttributeName()); - ASSERT_EQ(FDE_XmlSyntaxResult::AttriValue, parser.DoSyntaxParse()); - ASSERT_EQ(L"application/x-javascript", parser.GetAttributeValue()); - - ASSERT_EQ(FDE_XmlSyntaxResult::ElementBreak, parser.DoSyntaxParse()); - ASSERT_EQ(FDE_XmlSyntaxResult::Text, parser.DoSyntaxParse()); - ASSERT_EQ(L"\n ", parser.GetTextData()); - - // Parser walks to end of input. - - ASSERT_EQ(FDE_XmlSyntaxResult::EndOfString, parser.DoSyntaxParse()); -} - -TEST_F(CFDE_XMLSyntaxParserTest, UnClosedCData) { - const char* input = - ""; - - CFX_RetainPtr stream = - pdfium::MakeRetain( - reinterpret_cast(const_cast(input)), strlen(input)); - stream->SetCodePage(FX_CODEPAGE_UTF8); - - CFDE_XMLSyntaxParser parser(stream); - ASSERT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); - ASSERT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse()); - ASSERT_EQ(L"script", parser.GetTagName()); - - ASSERT_EQ(FDE_XmlSyntaxResult::AttriName, parser.DoSyntaxParse()); - ASSERT_EQ(L"contentType", parser.GetAttributeName()); - ASSERT_EQ(FDE_XmlSyntaxResult::AttriValue, parser.DoSyntaxParse()); - ASSERT_EQ(L"application/x-javascript", parser.GetAttributeValue()); - - ASSERT_EQ(FDE_XmlSyntaxResult::ElementBreak, parser.DoSyntaxParse()); - ASSERT_EQ(FDE_XmlSyntaxResult::Text, parser.DoSyntaxParse()); - ASSERT_EQ(L"\n ", parser.GetTextData()); - - // Parser walks to end of input. - - ASSERT_EQ(FDE_XmlSyntaxResult::EndOfString, parser.DoSyntaxParse()); -} - -TEST_F(CFDE_XMLSyntaxParserTest, EmptyCData) { - const char* input = - ""; - - CFX_RetainPtr stream = - pdfium::MakeRetain( - reinterpret_cast(const_cast(input)), strlen(input)); - stream->SetCodePage(FX_CODEPAGE_UTF8); - - CFDE_XMLSyntaxParser parser(stream); - ASSERT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); - ASSERT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse()); - ASSERT_EQ(L"script", parser.GetTagName()); - - ASSERT_EQ(FDE_XmlSyntaxResult::AttriName, parser.DoSyntaxParse()); - ASSERT_EQ(L"contentType", parser.GetAttributeName()); - ASSERT_EQ(FDE_XmlSyntaxResult::AttriValue, parser.DoSyntaxParse()); - ASSERT_EQ(L"application/x-javascript", parser.GetAttributeValue()); - - ASSERT_EQ(FDE_XmlSyntaxResult::ElementBreak, parser.DoSyntaxParse()); - ASSERT_EQ(FDE_XmlSyntaxResult::Text, parser.DoSyntaxParse()); - ASSERT_EQ(L"\n ", parser.GetTextData()); - - ASSERT_EQ(FDE_XmlSyntaxResult::CData, parser.DoSyntaxParse()); - ASSERT_EQ(L"", parser.GetTextData()); - - ASSERT_EQ(FDE_XmlSyntaxResult::Text, parser.DoSyntaxParse()); - ASSERT_EQ(L"\n", parser.GetTextData()); - - ASSERT_EQ(FDE_XmlSyntaxResult::ElementClose, parser.DoSyntaxParse()); - ASSERT_EQ(L"script", parser.GetTagName()); - - ASSERT_EQ(FDE_XmlSyntaxResult::EndOfString, parser.DoSyntaxParse()); -} - -TEST_F(CFDE_XMLSyntaxParserTest, Comment) { - const char* input = - ""; - - CFX_RetainPtr stream = - pdfium::MakeRetain( - reinterpret_cast(const_cast(input)), strlen(input)); - stream->SetCodePage(FX_CODEPAGE_UTF8); - - CFDE_XMLSyntaxParser parser(stream); - ASSERT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); - ASSERT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse()); - ASSERT_EQ(L"script", parser.GetTagName()); - - ASSERT_EQ(FDE_XmlSyntaxResult::AttriName, parser.DoSyntaxParse()); - ASSERT_EQ(L"contentType", parser.GetAttributeName()); - ASSERT_EQ(FDE_XmlSyntaxResult::AttriValue, parser.DoSyntaxParse()); - ASSERT_EQ(L"application/x-javascript", parser.GetAttributeValue()); - - ASSERT_EQ(FDE_XmlSyntaxResult::ElementBreak, parser.DoSyntaxParse()); - ASSERT_EQ(FDE_XmlSyntaxResult::Text, parser.DoSyntaxParse()); - ASSERT_EQ(L"\n ", parser.GetTextData()); - - ASSERT_EQ(FDE_XmlSyntaxResult::Text, parser.DoSyntaxParse()); - ASSERT_EQ(L"\n", parser.GetTextData()); - - ASSERT_EQ(FDE_XmlSyntaxResult::ElementClose, parser.DoSyntaxParse()); - ASSERT_EQ(L"script", parser.GetTagName()); - - ASSERT_EQ(FDE_XmlSyntaxResult::EndOfString, parser.DoSyntaxParse()); -} - -TEST_F(CFDE_XMLSyntaxParserTest, IncorrectCommentStart) { - const char* input = - ""; - - CFX_RetainPtr stream = - pdfium::MakeRetain( - reinterpret_cast(const_cast(input)), strlen(input)); - stream->SetCodePage(FX_CODEPAGE_UTF8); - - CFDE_XMLSyntaxParser parser(stream); - ASSERT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); - ASSERT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse()); - ASSERT_EQ(L"script", parser.GetTagName()); - - ASSERT_EQ(FDE_XmlSyntaxResult::AttriName, parser.DoSyntaxParse()); - ASSERT_EQ(L"contentType", parser.GetAttributeName()); - ASSERT_EQ(FDE_XmlSyntaxResult::AttriValue, parser.DoSyntaxParse()); - ASSERT_EQ(L"application/x-javascript", parser.GetAttributeValue()); - - ASSERT_EQ(FDE_XmlSyntaxResult::ElementBreak, parser.DoSyntaxParse()); - ASSERT_EQ(FDE_XmlSyntaxResult::Text, parser.DoSyntaxParse()); - ASSERT_EQ(L"\n ", parser.GetTextData()); - - ASSERT_EQ(FDE_XmlSyntaxResult::Text, parser.DoSyntaxParse()); - ASSERT_EQ(L"\n", parser.GetTextData()); - - ASSERT_EQ(FDE_XmlSyntaxResult::ElementClose, parser.DoSyntaxParse()); - ASSERT_EQ(L"script", parser.GetTagName()); - - ASSERT_EQ(FDE_XmlSyntaxResult::EndOfString, parser.DoSyntaxParse()); -} - -TEST_F(CFDE_XMLSyntaxParserTest, CommentEmpty) { - const char* input = - ""; - - CFX_RetainPtr stream = - pdfium::MakeRetain( - reinterpret_cast(const_cast(input)), strlen(input)); - stream->SetCodePage(FX_CODEPAGE_UTF8); - - CFDE_XMLSyntaxParser parser(stream); - ASSERT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); - ASSERT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse()); - ASSERT_EQ(L"script", parser.GetTagName()); - - ASSERT_EQ(FDE_XmlSyntaxResult::AttriName, parser.DoSyntaxParse()); - ASSERT_EQ(L"contentType", parser.GetAttributeName()); - ASSERT_EQ(FDE_XmlSyntaxResult::AttriValue, parser.DoSyntaxParse()); - ASSERT_EQ(L"application/x-javascript", parser.GetAttributeValue()); - - ASSERT_EQ(FDE_XmlSyntaxResult::ElementBreak, parser.DoSyntaxParse()); - ASSERT_EQ(FDE_XmlSyntaxResult::Text, parser.DoSyntaxParse()); - ASSERT_EQ(L"\n ", parser.GetTextData()); - - ASSERT_EQ(FDE_XmlSyntaxResult::Text, parser.DoSyntaxParse()); - ASSERT_EQ(L"\n", parser.GetTextData()); - - ASSERT_EQ(FDE_XmlSyntaxResult::ElementClose, parser.DoSyntaxParse()); - ASSERT_EQ(L"script", parser.GetTagName()); - - ASSERT_EQ(FDE_XmlSyntaxResult::EndOfString, parser.DoSyntaxParse()); -} - -TEST_F(CFDE_XMLSyntaxParserTest, CommentThreeDash) { - const char* input = - ""; - - CFX_RetainPtr stream = - pdfium::MakeRetain( - reinterpret_cast(const_cast(input)), strlen(input)); - stream->SetCodePage(FX_CODEPAGE_UTF8); - - CFDE_XMLSyntaxParser parser(stream); - ASSERT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); - ASSERT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse()); - ASSERT_EQ(L"script", parser.GetTagName()); - - ASSERT_EQ(FDE_XmlSyntaxResult::AttriName, parser.DoSyntaxParse()); - ASSERT_EQ(L"contentType", parser.GetAttributeName()); - ASSERT_EQ(FDE_XmlSyntaxResult::AttriValue, parser.DoSyntaxParse()); - ASSERT_EQ(L"application/x-javascript", parser.GetAttributeValue()); - - ASSERT_EQ(FDE_XmlSyntaxResult::ElementBreak, parser.DoSyntaxParse()); - ASSERT_EQ(FDE_XmlSyntaxResult::Text, parser.DoSyntaxParse()); - ASSERT_EQ(L"\n ", parser.GetTextData()); - - ASSERT_EQ(FDE_XmlSyntaxResult::EndOfString, parser.DoSyntaxParse()); -} - -TEST_F(CFDE_XMLSyntaxParserTest, CommentTwoDash) { - const char* input = - ""; - - CFX_RetainPtr stream = - pdfium::MakeRetain( - reinterpret_cast(const_cast(input)), strlen(input)); - stream->SetCodePage(FX_CODEPAGE_UTF8); - - CFDE_XMLSyntaxParser parser(stream); - ASSERT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); - ASSERT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse()); - ASSERT_EQ(L"script", parser.GetTagName()); - - ASSERT_EQ(FDE_XmlSyntaxResult::AttriName, parser.DoSyntaxParse()); - ASSERT_EQ(L"contentType", parser.GetAttributeName()); - ASSERT_EQ(FDE_XmlSyntaxResult::AttriValue, parser.DoSyntaxParse()); - ASSERT_EQ(L"application/x-javascript", parser.GetAttributeValue()); - - ASSERT_EQ(FDE_XmlSyntaxResult::ElementBreak, parser.DoSyntaxParse()); - ASSERT_EQ(FDE_XmlSyntaxResult::Text, parser.DoSyntaxParse()); - ASSERT_EQ(L"\n ", parser.GetTextData()); - - ASSERT_EQ(FDE_XmlSyntaxResult::EndOfString, parser.DoSyntaxParse()); -} - -TEST_F(CFDE_XMLSyntaxParserTest, Entities) { - const char* input = - ""; - - CFX_RetainPtr stream = - pdfium::MakeRetain( - reinterpret_cast(const_cast(input)), strlen(input)); - stream->SetCodePage(FX_CODEPAGE_UTF8); - - CFDE_XMLSyntaxParser parser(stream); - ASSERT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); - ASSERT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse()); - ASSERT_EQ(L"script", parser.GetTagName()); - - ASSERT_EQ(FDE_XmlSyntaxResult::AttriName, parser.DoSyntaxParse()); - ASSERT_EQ(L"contentType", parser.GetAttributeName()); - ASSERT_EQ(FDE_XmlSyntaxResult::AttriValue, parser.DoSyntaxParse()); - ASSERT_EQ(L"application/x-javascript", parser.GetAttributeValue()); - - ASSERT_EQ(FDE_XmlSyntaxResult::ElementBreak, parser.DoSyntaxParse()); - ASSERT_EQ(FDE_XmlSyntaxResult::Text, parser.DoSyntaxParse()); - ASSERT_EQ(L"BTH\xab48", parser.GetTextData()); - - ASSERT_EQ(FDE_XmlSyntaxResult::ElementClose, parser.DoSyntaxParse()); - ASSERT_EQ(L"script", parser.GetTagName()); - - ASSERT_EQ(FDE_XmlSyntaxResult::EndOfString, parser.DoSyntaxParse()); -} - -TEST_F(CFDE_XMLSyntaxParserTest, EntityOverflowHex) { - const char* input = - ""; - - CFX_RetainPtr stream = - pdfium::MakeRetain( - reinterpret_cast(const_cast(input)), strlen(input)); - stream->SetCodePage(FX_CODEPAGE_UTF8); - - CFDE_XMLSyntaxParser parser(stream); - ASSERT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); - ASSERT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse()); - ASSERT_EQ(L"script", parser.GetTagName()); - - ASSERT_EQ(FDE_XmlSyntaxResult::AttriName, parser.DoSyntaxParse()); - ASSERT_EQ(L"contentType", parser.GetAttributeName()); - ASSERT_EQ(FDE_XmlSyntaxResult::AttriValue, parser.DoSyntaxParse()); - ASSERT_EQ(L"application/x-javascript", parser.GetAttributeValue()); - - ASSERT_EQ(FDE_XmlSyntaxResult::ElementBreak, parser.DoSyntaxParse()); - ASSERT_EQ(FDE_XmlSyntaxResult::Text, parser.DoSyntaxParse()); - ASSERT_EQ(L" ", parser.GetTextData()); - - ASSERT_EQ(FDE_XmlSyntaxResult::ElementClose, parser.DoSyntaxParse()); - ASSERT_EQ(L"script", parser.GetTagName()); - - ASSERT_EQ(FDE_XmlSyntaxResult::EndOfString, parser.DoSyntaxParse()); -} - -TEST_F(CFDE_XMLSyntaxParserTest, EntityOverflowDecimal) { - const char* input = - ""; - - CFX_RetainPtr stream = - pdfium::MakeRetain( - reinterpret_cast(const_cast(input)), strlen(input)); - stream->SetCodePage(FX_CODEPAGE_UTF8); - - CFDE_XMLSyntaxParser parser(stream); - ASSERT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); - ASSERT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse()); - ASSERT_EQ(L"script", parser.GetTagName()); - - ASSERT_EQ(FDE_XmlSyntaxResult::AttriName, parser.DoSyntaxParse()); - ASSERT_EQ(L"contentType", parser.GetAttributeName()); - ASSERT_EQ(FDE_XmlSyntaxResult::AttriValue, parser.DoSyntaxParse()); - ASSERT_EQ(L"application/x-javascript", parser.GetAttributeValue()); - - ASSERT_EQ(FDE_XmlSyntaxResult::ElementBreak, parser.DoSyntaxParse()); - ASSERT_EQ(FDE_XmlSyntaxResult::Text, parser.DoSyntaxParse()); - ASSERT_EQ(L" ", parser.GetTextData()); - - ASSERT_EQ(FDE_XmlSyntaxResult::ElementClose, parser.DoSyntaxParse()); - ASSERT_EQ(L"script", parser.GetTagName()); - - ASSERT_EQ(FDE_XmlSyntaxResult::EndOfString, parser.DoSyntaxParse()); -} diff --git a/xfa/fde/xml/cfde_xmltext.cpp b/xfa/fde/xml/cfde_xmltext.cpp deleted file mode 100644 index 2af66ac70c..0000000000 --- a/xfa/fde/xml/cfde_xmltext.cpp +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2017 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#include "xfa/fde/xml/cfde_xmltext.h" - -#include "third_party/base/ptr_util.h" - -CFDE_XMLText::CFDE_XMLText(const CFX_WideString& wsText) - : CFDE_XMLNode(), m_wsText(wsText) {} - -CFDE_XMLText::~CFDE_XMLText() {} - -FDE_XMLNODETYPE CFDE_XMLText::GetType() const { - return FDE_XMLNODE_Text; -} - -std::unique_ptr CFDE_XMLText::Clone() { - return pdfium::MakeUnique(m_wsText); -} diff --git a/xfa/fde/xml/cfde_xmltext.h b/xfa/fde/xml/cfde_xmltext.h deleted file mode 100644 index 6987c49980..0000000000 --- a/xfa/fde/xml/cfde_xmltext.h +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2017 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef XFA_FDE_XML_CFDE_XMLTEXT_H_ -#define XFA_FDE_XML_CFDE_XMLTEXT_H_ - -#include - -#include "core/fxcrt/fx_string.h" -#include "xfa/fde/xml/cfde_xmlnode.h" - -class CFDE_XMLText : public CFDE_XMLNode { - public: - explicit CFDE_XMLText(const CFX_WideString& wsText); - ~CFDE_XMLText() override; - - // CFDE_XMLNode - FDE_XMLNODETYPE GetType() const override; - std::unique_ptr Clone() override; - - CFX_WideString GetText() const { return m_wsText; } - void SetText(const CFX_WideString& wsText) { m_wsText = wsText; } - - private: - CFX_WideString m_wsText; -}; - -#endif // XFA_FDE_XML_CFDE_XMLTEXT_H_ diff --git a/xfa/fxfa/app/cxfa_loadercontext.h b/xfa/fxfa/app/cxfa_loadercontext.h index 16d9608bac..553252e200 100644 --- a/xfa/fxfa/app/cxfa_loadercontext.h +++ b/xfa/fxfa/app/cxfa_loadercontext.h @@ -13,7 +13,7 @@ #include "core/fxcrt/fx_system.h" #include "xfa/fde/css/cfde_csscomputedstyle.h" -class CFDE_XMLNode; +class CFX_XMLNode; class CXFA_Node; class CXFA_LoaderContext { @@ -30,7 +30,7 @@ class CXFA_LoaderContext { int32_t m_iLines; int32_t m_iTotalLines; uint32_t m_dwFlags; - CFDE_XMLNode* m_pXMLNode; + CFX_XMLNode* m_pXMLNode; CXFA_Node* m_pNode; CFX_RetainPtr m_pParentStyle; std::vector m_lineHeights; diff --git a/xfa/fxfa/app/cxfa_textlayout.cpp b/xfa/fxfa/app/cxfa_textlayout.cpp index 880bdf4585..69f5f53db3 100644 --- a/xfa/fxfa/app/cxfa_textlayout.cpp +++ b/xfa/fxfa/app/cxfa_textlayout.cpp @@ -9,6 +9,9 @@ #include #include +#include "core/fxcrt/xml/cfx_xmlelement.h" +#include "core/fxcrt/xml/cfx_xmlnode.h" +#include "core/fxcrt/xml/cfx_xmltext.h" #include "third_party/base/ptr_util.h" #include "third_party/base/stl_util.h" #include "xfa/fde/cfde_brush.h" @@ -17,9 +20,6 @@ #include "xfa/fde/cfde_renderdevice.h" #include "xfa/fde/css/cfde_csscomputedstyle.h" #include "xfa/fde/css/cfde_cssstyleselector.h" -#include "xfa/fde/xml/cfde_xmlelement.h" -#include "xfa/fde/xml/cfde_xmlnode.h" -#include "xfa/fde/xml/cfde_xmltext.h" #include "xfa/fxfa/app/cxfa_linkuserdata.h" #include "xfa/fxfa/app/cxfa_loadercontext.h" #include "xfa/fxfa/app/cxfa_pieceline.h" @@ -66,21 +66,20 @@ void CXFA_TextLayout::GetTextDataNode() { m_pTextDataNode = pNode; } -CFDE_XMLNode* CXFA_TextLayout::GetXMLContainerNode() { +CFX_XMLNode* CXFA_TextLayout::GetXMLContainerNode() { if (!m_bRichText) return nullptr; - CFDE_XMLNode* pXMLRoot = m_pTextDataNode->GetXMLMappingNode(); + CFX_XMLNode* pXMLRoot = m_pTextDataNode->GetXMLMappingNode(); if (!pXMLRoot) return nullptr; - CFDE_XMLNode* pXMLContainer = nullptr; - for (CFDE_XMLNode* pXMLChild = - pXMLRoot->GetNodeItem(CFDE_XMLNode::FirstChild); + CFX_XMLNode* pXMLContainer = nullptr; + for (CFX_XMLNode* pXMLChild = pXMLRoot->GetNodeItem(CFX_XMLNode::FirstChild); pXMLChild; - pXMLChild = pXMLChild->GetNodeItem(CFDE_XMLNode::NextSibling)) { - if (pXMLChild->GetType() == FDE_XMLNODE_Element) { - CFDE_XMLElement* pXMLElement = static_cast(pXMLChild); + pXMLChild = pXMLChild->GetNodeItem(CFX_XMLNode::NextSibling)) { + if (pXMLChild->GetType() == FX_XMLNODE_Element) { + CFX_XMLElement* pXMLElement = static_cast(pXMLChild); CFX_WideString wsTag = pXMLElement->GetLocalTagName(); if (wsTag == L"body" || wsTag == L"html") { pXMLContainer = pXMLChild; @@ -159,7 +158,7 @@ void CXFA_TextLayout::InitBreak(float fLineWidth) { void CXFA_TextLayout::InitBreak(CFDE_CSSComputedStyle* pStyle, FDE_CSSDisplay eDisplay, float fLineWidth, - CFDE_XMLNode* pXMLNode, + CFX_XMLNode* pXMLNode, CFDE_CSSComputedStyle* pParentStyle) { if (!pStyle) { InitBreak(fLineWidth); @@ -460,24 +459,24 @@ bool CXFA_TextLayout::Layout(int32_t iBlock) { m_pBreak->Reset(); if (m_bRichText) { - CFDE_XMLNode* pContainerNode = GetXMLContainerNode(); + CFX_XMLNode* pContainerNode = GetXMLContainerNode(); if (!pContainerNode) return true; - CFDE_XMLNode* pXMLNode = m_pLoader->m_pXMLNode; + CFX_XMLNode* pXMLNode = m_pLoader->m_pXMLNode; if (!pXMLNode) return true; - CFDE_XMLNode* pSaveXMLNode = m_pLoader->m_pXMLNode; + CFX_XMLNode* pSaveXMLNode = m_pLoader->m_pXMLNode; for (; pXMLNode; - pXMLNode = pXMLNode->GetNodeItem(CFDE_XMLNode::NextSibling)) { + pXMLNode = pXMLNode->GetNodeItem(CFX_XMLNode::NextSibling)) { if (!LoadRichText(pXMLNode, szText, fLinePos, m_pLoader->m_pParentStyle, true, nullptr)) { break; } } while (!pXMLNode) { - pXMLNode = pSaveXMLNode->GetNodeItem(CFDE_XMLNode::Parent); + pXMLNode = pSaveXMLNode->GetNodeItem(CFX_XMLNode::Parent); if (pXMLNode == pContainerNode) break; if (!LoadRichText(pXMLNode, szText, fLinePos, m_pLoader->m_pParentStyle, @@ -485,11 +484,11 @@ bool CXFA_TextLayout::Layout(int32_t iBlock) { break; } pSaveXMLNode = pXMLNode; - pXMLNode = pXMLNode->GetNodeItem(CFDE_XMLNode::NextSibling); + pXMLNode = pXMLNode->GetNodeItem(CFX_XMLNode::NextSibling); if (!pXMLNode) continue; for (; pXMLNode; - pXMLNode = pXMLNode->GetNodeItem(CFDE_XMLNode::NextSibling)) { + pXMLNode = pXMLNode->GetNodeItem(CFX_XMLNode::NextSibling)) { if (!LoadRichText(pXMLNode, szText, fLinePos, m_pLoader->m_pParentStyle, true, nullptr)) { break; @@ -645,7 +644,7 @@ bool CXFA_TextLayout::Loader(const CFX_SizeF& szText, return true; if (m_bRichText) { - CFDE_XMLNode* pXMLContainer = GetXMLContainerNode(); + CFX_XMLNode* pXMLContainer = GetXMLContainerNode(); if (pXMLContainer) { if (!m_textParser.IsParsed()) m_textParser.DoParse(pXMLContainer, m_pTextProvider); @@ -694,7 +693,7 @@ void CXFA_TextLayout::LoadText(CXFA_Node* pNode, } bool CXFA_TextLayout::LoadRichText( - CFDE_XMLNode* pXMLNode, + CFX_XMLNode* pXMLNode, const CFX_SizeF& szText, float& fLinePos, const CFX_RetainPtr& pParentStyle, @@ -716,16 +715,16 @@ bool CXFA_TextLayout::LoadRichText( if (bEndBreak) { bool bCurOl = false; bool bCurLi = false; - CFDE_XMLElement* pElement = nullptr; + CFX_XMLElement* pElement = nullptr; if (pContext) { if (m_bBlockContinue || (m_pLoader && pXMLNode == m_pLoader->m_pXMLNode)) { m_bBlockContinue = true; } - if (pXMLNode->GetType() == FDE_XMLNODE_Text) { + if (pXMLNode->GetType() == FX_XMLNODE_Text) { bContentNode = true; - } else if (pXMLNode->GetType() == FDE_XMLNODE_Element) { - pElement = static_cast(pXMLNode); + } else if (pXMLNode->GetType() == FX_XMLNODE_Element) { + pElement = static_cast(pXMLNode); wsName = pElement->GetLocalTagName(); } if (wsName == L"ol") { @@ -771,7 +770,7 @@ bool CXFA_TextLayout::LoadRichText( bContentNode ? pParentStyle.Get() : pStyle.Get()); CFX_WideString wsText; if (bContentNode && iTabCount == 0) { - wsText = static_cast(pXMLNode)->GetText(); + wsText = static_cast(pXMLNode)->GetText(); } else if (wsName == L"br") { wsText = L'\n'; } else if (wsName == L"li") { @@ -834,10 +833,10 @@ bool CXFA_TextLayout::LoadRichText( } } - for (CFDE_XMLNode* pChildNode = - pXMLNode->GetNodeItem(CFDE_XMLNode::FirstChild); + for (CFX_XMLNode* pChildNode = + pXMLNode->GetNodeItem(CFX_XMLNode::FirstChild); pChildNode; - pChildNode = pChildNode->GetNodeItem(CFDE_XMLNode::NextSibling)) { + pChildNode = pChildNode->GetNodeItem(CFX_XMLNode::NextSibling)) { if (bCurOl) iLiCount++; @@ -872,7 +871,7 @@ bool CXFA_TextLayout::LoadRichText( if (IsEnd(bSavePieces)) { if (m_pLoader && m_pLoader->m_iTotalLines > -1) { m_pLoader->m_pXMLNode = - pXMLNode->GetNodeItem(CFDE_XMLNode::NextSibling); + pXMLNode->GetNodeItem(CFX_XMLNode::NextSibling); m_pLoader->m_pParentStyle = pParentStyle; } return false; diff --git a/xfa/fxfa/app/cxfa_textlayout.h b/xfa/fxfa/app/cxfa_textlayout.h index 5bce1c9ab2..75c2d56324 100644 --- a/xfa/fxfa/app/cxfa_textlayout.h +++ b/xfa/fxfa/app/cxfa_textlayout.h @@ -21,7 +21,7 @@ class CFDE_Brush; class CFDE_CSSComputedStyle; class CFDE_Pen; class CFDE_RenderDevice; -class CFDE_XMLNode; +class CFX_XMLNode; class CFX_RTFBreak; class CXFA_LoaderContext; class CXFA_LinkUserData; @@ -64,13 +64,13 @@ class CXFA_TextLayout { private: void GetTextDataNode(); - CFDE_XMLNode* GetXMLContainerNode(); + CFX_XMLNode* GetXMLContainerNode(); std::unique_ptr CreateBreak(bool bDefault); void InitBreak(float fLineWidth); void InitBreak(CFDE_CSSComputedStyle* pStyle, FDE_CSSDisplay eDisplay, float fLineWidth, - CFDE_XMLNode* pXMLNode, + CFX_XMLNode* pXMLNode, CFDE_CSSComputedStyle* pParentStyle = nullptr); bool Loader(const CFX_SizeF& szText, float& fLinePos, @@ -79,7 +79,7 @@ class CXFA_TextLayout { const CFX_SizeF& szText, float& fLinePos, bool bSavePieces); - bool LoadRichText(CFDE_XMLNode* pXMLNode, + bool LoadRichText(CFX_XMLNode* pXMLNode, const CFX_SizeF& szText, float& fLinePos, const CFX_RetainPtr& pParentStyle, diff --git a/xfa/fxfa/app/cxfa_textparser.cpp b/xfa/fxfa/app/cxfa_textparser.cpp index 1243f5b7ea..33bd2b9deb 100644 --- a/xfa/fxfa/app/cxfa_textparser.cpp +++ b/xfa/fxfa/app/cxfa_textparser.cpp @@ -11,13 +11,13 @@ #include #include "core/fxcrt/fx_codepage.h" +#include "core/fxcrt/xml/cfx_xmlelement.h" +#include "core/fxcrt/xml/cfx_xmlnode.h" #include "third_party/base/ptr_util.h" #include "xfa/fde/css/cfde_csscomputedstyle.h" #include "xfa/fde/css/cfde_cssstyleselector.h" #include "xfa/fde/css/cfde_cssstylesheet.h" #include "xfa/fde/css/fde_css.h" -#include "xfa/fde/xml/cfde_xmlelement.h" -#include "xfa/fde/xml/cfde_xmlnode.h" #include "xfa/fgas/font/cfgas_fontmgr.h" #include "xfa/fxfa/app/cxfa_csstagprovider.h" #include "xfa/fxfa/app/cxfa_textparsecontext.h" @@ -175,7 +175,7 @@ CFX_RetainPtr CXFA_TextParser::CreateStyle( } CFX_RetainPtr CXFA_TextParser::ComputeStyle( - CFDE_XMLNode* pXMLNode, + CFX_XMLNode* pXMLNode, CFDE_CSSComputedStyle* pParentStyle) { auto it = m_mapXMLNodeToParseContext.find(pXMLNode); if (it == m_mapXMLNodeToParseContext.end()) @@ -198,7 +198,7 @@ CFX_RetainPtr CXFA_TextParser::ComputeStyle( return pStyle; } -void CXFA_TextParser::DoParse(CFDE_XMLNode* pXMLContainer, +void CXFA_TextParser::DoParse(CFX_XMLNode* pXMLContainer, CXFA_TextProvider* pTextProvider) { if (!pXMLContainer || !pTextProvider || m_bParsed) return; @@ -209,7 +209,7 @@ void CXFA_TextParser::DoParse(CFDE_XMLNode* pXMLContainer, ParseRichText(pXMLContainer, pRootStyle.Get()); } -void CXFA_TextParser::ParseRichText(CFDE_XMLNode* pXMLNode, +void CXFA_TextParser::ParseRichText(CFX_XMLNode* pXMLNode, CFDE_CSSComputedStyle* pParentStyle) { if (!pXMLNode) return; @@ -240,10 +240,9 @@ void CXFA_TextParser::ParseRichText(CFDE_XMLNode* pXMLNode, m_mapXMLNodeToParseContext[pXMLNode] = std::move(pTextContext); } - for (CFDE_XMLNode* pXMLChild = - pXMLNode->GetNodeItem(CFDE_XMLNode::FirstChild); + for (CFX_XMLNode* pXMLChild = pXMLNode->GetNodeItem(CFX_XMLNode::FirstChild); pXMLChild; - pXMLChild = pXMLChild->GetNodeItem(CFDE_XMLNode::NextSibling)) { + pXMLChild = pXMLChild->GetNodeItem(CFX_XMLNode::NextSibling)) { ParseRichText(pXMLChild, pNewStyle.Get()); } } @@ -271,12 +270,12 @@ bool CXFA_TextParser::TagValidate(const CFX_WideString& wsName) const { } std::unique_ptr CXFA_TextParser::ParseTagInfo( - CFDE_XMLNode* pXMLNode) { + CFX_XMLNode* pXMLNode) { auto tagProvider = pdfium::MakeUnique(); CFX_WideString wsName; - if (pXMLNode->GetType() == FDE_XMLNODE_Element) { - CFDE_XMLElement* pXMLElement = static_cast(pXMLNode); + if (pXMLNode->GetType() == FX_XMLNODE_Element) { + CFX_XMLElement* pXMLElement = static_cast(pXMLNode); wsName = pXMLElement->GetLocalTagName(); tagProvider->SetTagName(wsName); tagProvider->m_bTagAvailable = TagValidate(wsName); @@ -284,7 +283,7 @@ std::unique_ptr CXFA_TextParser::ParseTagInfo( CFX_WideString wsValue = pXMLElement->GetString(L"style"); if (!wsValue.IsEmpty()) tagProvider->SetAttribute(L"style", wsValue); - } else if (pXMLNode->GetType() == FDE_XMLNODE_Text) { + } else if (pXMLNode->GetType() == FX_XMLNODE_Text) { tagProvider->m_bTagAvailable = true; tagProvider->m_bContent = true; } @@ -363,7 +362,7 @@ float CXFA_TextParser::GetFontSize(CXFA_TextProvider* pTextProvider, int32_t CXFA_TextParser::GetHorScale(CXFA_TextProvider* pTextProvider, CFDE_CSSComputedStyle* pStyle, - CFDE_XMLNode* pXMLNode) const { + CFX_XMLNode* pXMLNode) const { if (pStyle) { CFX_WideString wsValue; if (pStyle->GetCustomStyle(L"xfa-font-horizontal-scale", wsValue)) @@ -379,7 +378,7 @@ int32_t CXFA_TextParser::GetHorScale(CXFA_TextProvider* pTextProvider, return wsValue.GetInteger(); } } - pXMLNode = pXMLNode->GetNodeItem(CFDE_XMLNode::Parent); + pXMLNode = pXMLNode->GetNodeItem(CFX_XMLNode::Parent); } } @@ -490,15 +489,15 @@ float CXFA_TextParser::GetLineHeight(CXFA_TextProvider* pTextProvider, } bool CXFA_TextParser::GetEmbbedObj(CXFA_TextProvider* pTextProvider, - CFDE_XMLNode* pXMLNode, + CFX_XMLNode* pXMLNode, CFX_WideString& wsValue) { wsValue.clear(); if (!pXMLNode) return false; bool bRet = false; - if (pXMLNode->GetType() == FDE_XMLNODE_Element) { - CFDE_XMLElement* pElement = static_cast(pXMLNode); + if (pXMLNode->GetType() == FX_XMLNODE_Element) { + CFX_XMLElement* pElement = static_cast(pXMLNode); CFX_WideString wsAttr = pElement->GetString(L"xfa:embed"); if (wsAttr.IsEmpty()) return false; @@ -531,7 +530,7 @@ bool CXFA_TextParser::GetEmbbedObj(CXFA_TextProvider* pTextProvider, } CXFA_TextParseContext* CXFA_TextParser::GetParseContextFromMap( - CFDE_XMLNode* pXMLNode) { + CFX_XMLNode* pXMLNode) { auto it = m_mapXMLNodeToParseContext.find(pXMLNode); return it != m_mapXMLNodeToParseContext.end() ? it->second.get() : nullptr; } diff --git a/xfa/fxfa/app/cxfa_textparser.h b/xfa/fxfa/app/cxfa_textparser.h index 29f03a8dea..04bd51fafe 100644 --- a/xfa/fxfa/app/cxfa_textparser.h +++ b/xfa/fxfa/app/cxfa_textparser.h @@ -19,7 +19,7 @@ class CFDE_CSSComputedStyle; class CFDE_CSSStyleSelector; class CFDE_CSSStyleSheet; -class CFDE_XMLNode; +class CFX_XMLNode; class CXFA_CSSTagProvider; class CXFA_TextParseContext; class CXFA_TextProvider; @@ -31,12 +31,12 @@ class CXFA_TextParser { virtual ~CXFA_TextParser(); void Reset(); - void DoParse(CFDE_XMLNode* pXMLContainer, CXFA_TextProvider* pTextProvider); + void DoParse(CFX_XMLNode* pXMLContainer, CXFA_TextProvider* pTextProvider); CFX_RetainPtr CreateRootStyle( CXFA_TextProvider* pTextProvider); CFX_RetainPtr ComputeStyle( - CFDE_XMLNode* pXMLNode, + CFX_XMLNode* pXMLNode, CFDE_CSSComputedStyle* pParentStyle); bool IsParsed() const { return m_bParsed; } @@ -57,7 +57,7 @@ class CXFA_TextParser { int32_t GetHorScale(CXFA_TextProvider* pTextProvider, CFDE_CSSComputedStyle* pStyle, - CFDE_XMLNode* pXMLNode) const; + CFX_XMLNode* pXMLNode) const; int32_t GetVerScale(CXFA_TextProvider* pTextProvider, CFDE_CSSComputedStyle* pStyle) const; @@ -78,18 +78,18 @@ class CXFA_TextParser { float fVerScale) const; bool GetEmbbedObj(CXFA_TextProvider* pTextProvider, - CFDE_XMLNode* pXMLNode, + CFX_XMLNode* pXMLNode, CFX_WideString& wsValue); - CXFA_TextParseContext* GetParseContextFromMap(CFDE_XMLNode* pXMLNode); + CXFA_TextParseContext* GetParseContextFromMap(CFX_XMLNode* pXMLNode); protected: bool TagValidate(const CFX_WideString& str) const; private: void InitCSSData(CXFA_TextProvider* pTextProvider); - void ParseRichText(CFDE_XMLNode* pXMLNode, + void ParseRichText(CFX_XMLNode* pXMLNode, CFDE_CSSComputedStyle* pParentStyle); - std::unique_ptr ParseTagInfo(CFDE_XMLNode* pXMLNode); + std::unique_ptr ParseTagInfo(CFX_XMLNode* pXMLNode); std::unique_ptr LoadDefaultSheetStyle(); CFX_RetainPtr CreateStyle( CFDE_CSSComputedStyle* pParentStyle); @@ -97,7 +97,7 @@ class CXFA_TextParser { bool m_bParsed; bool m_cssInitialized; std::unique_ptr m_pSelector; - std::map> + std::map> m_mapXMLNodeToParseContext; }; diff --git a/xfa/fxfa/app/xfa_ffwidgetacc.cpp b/xfa/fxfa/app/xfa_ffwidgetacc.cpp index 760def2759..7f53027e5c 100644 --- a/xfa/fxfa/app/xfa_ffwidgetacc.cpp +++ b/xfa/fxfa/app/xfa_ffwidgetacc.cpp @@ -10,12 +10,12 @@ #include #include +#include "core/fxcrt/xml/cfx_xmlelement.h" +#include "core/fxcrt/xml/cfx_xmlnode.h" #include "fxjs/cfxjse_value.h" #include "third_party/base/ptr_util.h" #include "third_party/base/stl_util.h" #include "xfa/fde/cfde_textout.h" -#include "xfa/fde/xml/cfde_xmlelement.h" -#include "xfa/fde/xml/cfde_xmlnode.h" #include "xfa/fxfa/app/xfa_ffcheckbutton.h" #include "xfa/fxfa/app/xfa_ffchoicelist.h" #include "xfa/fxfa/app/xfa_fffield.h" @@ -63,14 +63,14 @@ CXFA_Node* CXFA_TextProvider::GetTextNode(bool& bRichText) { return pChildNode; } else if (m_eType == XFA_TEXTPROVIDERTYPE_Datasets) { CXFA_Node* pBind = m_pWidgetAcc->GetDatasets(); - CFDE_XMLNode* pXMLNode = pBind->GetXMLMappingNode(); + CFX_XMLNode* pXMLNode = pBind->GetXMLMappingNode(); ASSERT(pXMLNode); - for (CFDE_XMLNode* pXMLChild = - pXMLNode->GetNodeItem(CFDE_XMLNode::FirstChild); + for (CFX_XMLNode* pXMLChild = + pXMLNode->GetNodeItem(CFX_XMLNode::FirstChild); pXMLChild; - pXMLChild = pXMLChild->GetNodeItem(CFDE_XMLNode::NextSibling)) { - if (pXMLChild->GetType() == FDE_XMLNODE_Element) { - CFDE_XMLElement* pElement = static_cast(pXMLChild); + pXMLChild = pXMLChild->GetNodeItem(CFX_XMLNode::NextSibling)) { + if (pXMLChild->GetType() == FX_XMLNODE_Element) { + CFX_XMLElement* pElement = static_cast(pXMLChild); if (XFA_RecognizeRichText(pElement)) { bRichText = true; } diff --git a/xfa/fxfa/cxfa_ffdoc.cpp b/xfa/fxfa/cxfa_ffdoc.cpp index 3565370bde..04741f9082 100644 --- a/xfa/fxfa/cxfa_ffdoc.cpp +++ b/xfa/fxfa/cxfa_ffdoc.cpp @@ -17,9 +17,9 @@ #include "core/fxcrt/cfx_checksumcontext.h" #include "core/fxcrt/fx_ext.h" #include "core/fxcrt/fx_memory.h" +#include "core/fxcrt/xml/cfx_xmlelement.h" +#include "core/fxcrt/xml/cfx_xmlnode.h" #include "third_party/base/ptr_util.h" -#include "xfa/fde/xml/cfde_xmlelement.h" -#include "xfa/fde/xml/cfde_xmlnode.h" #include "xfa/fwl/cfwl_notedriver.h" #include "xfa/fxfa/app/xfa_ffnotify.h" #include "xfa/fxfa/cxfa_ffapp.h" @@ -171,15 +171,15 @@ int32_t CXFA_FFDoc::StartLoad() { return m_pDocumentParser->StartParse(m_pStream, XFA_XDPPACKET_XDP); } -bool XFA_GetPDFContentsFromPDFXML(CFDE_XMLNode* pPDFElement, +bool XFA_GetPDFContentsFromPDFXML(CFX_XMLNode* pPDFElement, uint8_t*& pByteBuffer, int32_t& iBufferSize) { - CFDE_XMLElement* pDocumentElement = nullptr; - for (CFDE_XMLNode* pXMLNode = - pPDFElement->GetNodeItem(CFDE_XMLNode::FirstChild); - pXMLNode; pXMLNode = pXMLNode->GetNodeItem(CFDE_XMLNode::NextSibling)) { - if (pXMLNode->GetType() == FDE_XMLNODE_Element) { - CFDE_XMLElement* pXMLElement = static_cast(pXMLNode); + CFX_XMLElement* pDocumentElement = nullptr; + for (CFX_XMLNode* pXMLNode = + pPDFElement->GetNodeItem(CFX_XMLNode::FirstChild); + pXMLNode; pXMLNode = pXMLNode->GetNodeItem(CFX_XMLNode::NextSibling)) { + if (pXMLNode->GetType() == FX_XMLNODE_Element) { + CFX_XMLElement* pXMLElement = static_cast(pXMLNode); CFX_WideString wsTagName = pXMLElement->GetName(); if (wsTagName == L"document") { pDocumentElement = pXMLElement; @@ -190,12 +190,12 @@ bool XFA_GetPDFContentsFromPDFXML(CFDE_XMLNode* pPDFElement, if (!pDocumentElement) { return false; } - CFDE_XMLElement* pChunkElement = nullptr; - for (CFDE_XMLNode* pXMLNode = - pDocumentElement->GetNodeItem(CFDE_XMLNode::FirstChild); - pXMLNode; pXMLNode = pXMLNode->GetNodeItem(CFDE_XMLNode::NextSibling)) { - if (pXMLNode->GetType() == FDE_XMLNODE_Element) { - CFDE_XMLElement* pXMLElement = static_cast(pXMLNode); + CFX_XMLElement* pChunkElement = nullptr; + for (CFX_XMLNode* pXMLNode = + pDocumentElement->GetNodeItem(CFX_XMLNode::FirstChild); + pXMLNode; pXMLNode = pXMLNode->GetNodeItem(CFX_XMLNode::NextSibling)) { + if (pXMLNode->GetType() == FX_XMLNODE_Element) { + CFX_XMLElement* pXMLElement = static_cast(pXMLNode); CFX_WideString wsTagName = pXMLElement->GetName(); if (wsTagName == L"chunk") { pChunkElement = pXMLElement; diff --git a/xfa/fxfa/cxfa_widgetacc.cpp b/xfa/fxfa/cxfa_widgetacc.cpp index be7556ee24..ad8f4bf5fa 100644 --- a/xfa/fxfa/cxfa_widgetacc.cpp +++ b/xfa/fxfa/cxfa_widgetacc.cpp @@ -9,10 +9,10 @@ #include #include +#include "core/fxcrt/xml/cfx_xmlelement.h" +#include "core/fxcrt/xml/cfx_xmlnode.h" #include "third_party/base/stl_util.h" #include "xfa/fde/cfde_textout.h" -#include "xfa/fde/xml/cfde_xmlelement.h" -#include "xfa/fde/xml/cfde_xmlnode.h" #include "xfa/fxfa/app/cxfa_textlayout.h" #include "xfa/fxfa/app/xfa_ffwidgetacc.h" #include "xfa/fxfa/cxfa_ffapp.h" @@ -265,9 +265,9 @@ void CXFA_WidgetAcc::SetImageEdit(const CFX_WideString& wsContentType, if (pHrefNode) { pHrefNode->SetCData(XFA_ATTRIBUTE_Value, wsHref); } else { - CFDE_XMLNode* pXMLNode = pBind->GetXMLMappingNode(); - ASSERT(pXMLNode && pXMLNode->GetType() == FDE_XMLNODE_Element); - static_cast(pXMLNode)->SetString(L"href", wsHref); + CFX_XMLNode* pXMLNode = pBind->GetXMLMappingNode(); + ASSERT(pXMLNode && pXMLNode->GetType() == FX_XMLNODE_Element); + static_cast(pXMLNode)->SetString(L"href", wsHref); } } diff --git a/xfa/fxfa/parser/cxfa_dataexporter.cpp b/xfa/fxfa/parser/cxfa_dataexporter.cpp index c1eda8d9e6..0c702fe53c 100644 --- a/xfa/fxfa/parser/cxfa_dataexporter.cpp +++ b/xfa/fxfa/parser/cxfa_dataexporter.cpp @@ -10,10 +10,10 @@ #include "core/fxcrt/fx_basic.h" #include "core/fxcrt/fx_codepage.h" +#include "core/fxcrt/xml/cfx_xmldoc.h" +#include "core/fxcrt/xml/cfx_xmlelement.h" +#include "core/fxcrt/xml/cfx_xmlnode.h" #include "third_party/base/stl_util.h" -#include "xfa/fde/xml/cfde_xmldoc.h" -#include "xfa/fde/xml/cfde_xmlelement.h" -#include "xfa/fde/xml/cfde_xmlnode.h" #include "xfa/fxfa/parser/cxfa_document.h" #include "xfa/fxfa/parser/cxfa_node.h" #include "xfa/fxfa/parser/cxfa_widgetdata.h" @@ -215,12 +215,12 @@ void RegenerateFormFile_Changed(CXFA_Node* pNode, pNode->GetAttribute(XFA_ATTRIBUTE_ContentType, wsContentType, false); if (pRawValueNode->GetElementType() == XFA_Element::SharpxHTML && wsContentType == L"text/html") { - CFDE_XMLNode* pExDataXML = pNode->GetXMLMappingNode(); + CFX_XMLNode* pExDataXML = pNode->GetXMLMappingNode(); if (!pExDataXML) break; - CFDE_XMLNode* pRichTextXML = - pExDataXML->GetNodeItem(CFDE_XMLNode::FirstChild); + CFX_XMLNode* pRichTextXML = + pExDataXML->GetNodeItem(CFX_XMLNode::FirstChild); if (!pRichTextXML) break; @@ -454,19 +454,19 @@ void XFA_DataExporter_DealWithDataGroupNode(CXFA_Node* pDataNode) { return; if (iChildNum > 0) { - CFDE_XMLNode* pXMLNode = pDataNode->GetXMLMappingNode(); - ASSERT(pXMLNode->GetType() == FDE_XMLNODE_Element); - CFDE_XMLElement* pXMLElement = static_cast(pXMLNode); + CFX_XMLNode* pXMLNode = pDataNode->GetXMLMappingNode(); + ASSERT(pXMLNode->GetType() == FX_XMLNODE_Element); + CFX_XMLElement* pXMLElement = static_cast(pXMLNode); if (pXMLElement->HasAttribute(L"xfa:dataNode")) pXMLElement->RemoveAttribute(L"xfa:dataNode"); return; } - CFDE_XMLNode* pXMLNode = pDataNode->GetXMLMappingNode(); - ASSERT(pXMLNode->GetType() == FDE_XMLNODE_Element); - static_cast(pXMLNode)->SetString(L"xfa:dataNode", - L"dataGroup"); + CFX_XMLNode* pXMLNode = pDataNode->GetXMLMappingNode(); + ASSERT(pXMLNode->GetType() == FX_XMLNODE_Element); + static_cast(pXMLNode)->SetString(L"xfa:dataNode", + L"dataGroup"); } CXFA_DataExporter::CXFA_DataExporter(CXFA_Document* pDocument) @@ -497,7 +497,7 @@ bool CXFA_DataExporter::Export( CXFA_Node* pNode, uint32_t dwFlag, const char* pChecksum) { - CFDE_XMLDoc* pXMLDoc = m_pDocument->GetXMLDoc(); + CFX_XMLDoc* pXMLDoc = m_pDocument->GetXMLDoc(); if (pNode->IsModelNode()) { switch (pNode->GetPacketID()) { case XFA_XDPPACKET_XDP: { @@ -511,9 +511,9 @@ bool CXFA_DataExporter::Export( break; } case XFA_XDPPACKET_Datasets: { - CFDE_XMLElement* pElement = - static_cast(pNode->GetXMLMappingNode()); - if (!pElement || pElement->GetType() != FDE_XMLNODE_Element) + CFX_XMLElement* pElement = + static_cast(pNode->GetXMLMappingNode()); + if (!pElement || pElement->GetType() != FX_XMLNODE_Element) return false; CXFA_Node* pDataNode = pNode->GetNodeItem(XFA_NODEITEM_FirstChild); @@ -528,9 +528,9 @@ bool CXFA_DataExporter::Export( } case XFA_XDPPACKET_Template: default: { - CFDE_XMLElement* pElement = - static_cast(pNode->GetXMLMappingNode()); - if (!pElement || pElement->GetType() != FDE_XMLNODE_Element) + CFX_XMLElement* pElement = + static_cast(pNode->GetXMLMappingNode()); + if (!pElement || pElement->GetType() != FX_XMLNODE_Element) return false; pXMLDoc->SaveXMLNode(pStream, pElement); @@ -550,9 +550,9 @@ bool CXFA_DataExporter::Export( break; } } - CFDE_XMLElement* pElement = - static_cast(pExportNode->GetXMLMappingNode()); - if (!pElement || pElement->GetType() != FDE_XMLNODE_Element) + CFX_XMLElement* pElement = + static_cast(pExportNode->GetXMLMappingNode()); + if (!pElement || pElement->GetType() != FX_XMLNODE_Element) return false; XFA_DataExporter_DealWithDataGroupNode(pExportNode); diff --git a/xfa/fxfa/parser/cxfa_dataimporter.cpp b/xfa/fxfa/parser/cxfa_dataimporter.cpp index d87d0914e4..cb5a42c428 100644 --- a/xfa/fxfa/parser/cxfa_dataimporter.cpp +++ b/xfa/fxfa/parser/cxfa_dataimporter.cpp @@ -9,8 +9,8 @@ #include #include "core/fxcrt/fx_stream.h" +#include "core/fxcrt/xml/cfx_xmlnode.h" #include "third_party/base/ptr_util.h" -#include "xfa/fde/xml/cfde_xmlnode.h" #include "xfa/fxfa/fxfa.h" #include "xfa/fxfa/fxfa_basic.h" #include "xfa/fxfa/parser/cxfa_document.h" @@ -53,8 +53,8 @@ bool CXFA_DataImporter::ImportData( pDataModel->InsertChild(pChildNode); } } else { - CFDE_XMLNode* pXMLNode = pImportDataRoot->GetXMLMappingNode(); - CFDE_XMLNode* pParentXMLNode = pXMLNode->GetNodeItem(CFDE_XMLNode::Parent); + CFX_XMLNode* pXMLNode = pImportDataRoot->GetXMLMappingNode(); + CFX_XMLNode* pParentXMLNode = pXMLNode->GetNodeItem(CFX_XMLNode::Parent); if (pParentXMLNode) pParentXMLNode->RemoveChildNode(pXMLNode); pDataModel->InsertChild(pImportDataRoot); diff --git a/xfa/fxfa/parser/cxfa_document.cpp b/xfa/fxfa/parser/cxfa_document.cpp index 7c979fec22..8e39dafa84 100644 --- a/xfa/fxfa/parser/cxfa_document.cpp +++ b/xfa/fxfa/parser/cxfa_document.cpp @@ -127,7 +127,7 @@ void CXFA_Document::SetRoot(CXFA_Node* pNewRoot) { RemovePurgeNode(pNewRoot); } -CFDE_XMLDoc* CXFA_Document::GetXMLDoc() const { +CFX_XMLDoc* CXFA_Document::GetXMLDoc() const { return m_pParser->GetXMLDoc(); } diff --git a/xfa/fxfa/parser/cxfa_document.h b/xfa/fxfa/parser/cxfa_document.h index 101b23332e..03586b6591 100644 --- a/xfa/fxfa/parser/cxfa_document.h +++ b/xfa/fxfa/parser/cxfa_document.h @@ -40,7 +40,7 @@ enum XFA_DocFlag { XFA_DOCFLAG_Scripting = 0x0008 }; -class CFDE_XMLDoc; +class CFX_XMLDoc; class CScript_DataWindow; class CScript_EventPseudoModel; class CScript_HostPseudoModel; @@ -66,7 +66,7 @@ class CXFA_Document { CXFA_Node* GetRoot() const { return m_pRootNode; } - CFDE_XMLDoc* GetXMLDoc() const; + CFX_XMLDoc* GetXMLDoc() const; CXFA_FFNotify* GetNotify() const; CXFA_LocaleMgr* GetLocalMgr(); CXFA_Object* GetXFAObject(XFA_HashCode wsNodeNameHash); diff --git a/xfa/fxfa/parser/cxfa_document_parser.cpp b/xfa/fxfa/parser/cxfa_document_parser.cpp index a6860d6b52..eb7cadc01c 100644 --- a/xfa/fxfa/parser/cxfa_document_parser.cpp +++ b/xfa/fxfa/parser/cxfa_document_parser.cpp @@ -6,8 +6,8 @@ #include "xfa/fxfa/parser/cxfa_document_parser.h" +#include "core/fxcrt/xml/cfx_xmldoc.h" #include "third_party/base/ptr_util.h" -#include "xfa/fde/xml/cfde_xmldoc.h" #include "xfa/fxfa/fxfa.h" #include "xfa/fxfa/parser/cxfa_document.h" @@ -40,7 +40,7 @@ int32_t CXFA_DocumentParser::DoParse(IFX_Pause* pPause) { return nRetStatus; } -CFDE_XMLDoc* CXFA_DocumentParser::GetXMLDoc() const { +CFX_XMLDoc* CXFA_DocumentParser::GetXMLDoc() const { return m_nodeParser.GetXMLDoc(); } diff --git a/xfa/fxfa/parser/cxfa_document_parser.h b/xfa/fxfa/parser/cxfa_document_parser.h index 90bd47f829..d876244e35 100644 --- a/xfa/fxfa/parser/cxfa_document_parser.h +++ b/xfa/fxfa/parser/cxfa_document_parser.h @@ -11,7 +11,7 @@ #include "xfa/fxfa/parser/cxfa_simple_parser.h" -class CFDE_XMLDoc; +class CFX_XMLDoc; class CXFA_Document; class CXFA_FFNotify; class CXFA_Notify; @@ -27,7 +27,7 @@ class CXFA_DocumentParser { XFA_XDPPACKET ePacketID); int32_t DoParse(IFX_Pause* pPause); - CFDE_XMLDoc* GetXMLDoc() const; + CFX_XMLDoc* GetXMLDoc() const; CXFA_FFNotify* GetNotify() const; CXFA_Document* GetDocument() const; diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp index 83c05d1269..ce45ae10db 100644 --- a/xfa/fxfa/parser/cxfa_node.cpp +++ b/xfa/fxfa/parser/cxfa_node.cpp @@ -15,12 +15,12 @@ #include "core/fxcrt/cfx_decimal.h" #include "core/fxcrt/fx_codepage.h" #include "core/fxcrt/fx_ext.h" +#include "core/fxcrt/xml/cfx_xmlelement.h" +#include "core/fxcrt/xml/cfx_xmlnode.h" +#include "core/fxcrt/xml/cfx_xmltext.h" #include "fxjs/cfxjse_value.h" #include "third_party/base/ptr_util.h" #include "third_party/base/stl_util.h" -#include "xfa/fde/xml/cfde_xmlelement.h" -#include "xfa/fde/xml/cfde_xmlnode.h" -#include "xfa/fde/xml/cfde_xmltext.h" #include "xfa/fxfa/app/xfa_ffnotify.h" #include "xfa/fxfa/cxfa_eventparam.h" #include "xfa/fxfa/cxfa_ffwidget.h" @@ -517,11 +517,11 @@ CXFA_Node* CXFA_Node::Clone(bool bRecursive) { MergeAllData(pClone); pClone->UpdateNameHash(); if (IsNeedSavingXMLNode()) { - std::unique_ptr pCloneXML; + std::unique_ptr pCloneXML; if (IsAttributeInXML()) { CFX_WideString wsName; GetAttribute(XFA_ATTRIBUTE_Name, wsName, false); - auto pCloneXMLElement = pdfium::MakeUnique(wsName); + auto pCloneXMLElement = pdfium::MakeUnique(wsName); CFX_WideStringC wsValue = GetCData(XFA_ATTRIBUTE_Value); if (!wsValue.IsEmpty()) { pCloneXMLElement->SetTextData(CFX_WideString(wsValue)); @@ -1284,12 +1284,12 @@ void CXFA_Node::Script_NodeClass_LoadXML(CFXJSE_Arguments* pArguments) { auto pParser = pdfium::MakeUnique(m_pDocument, false); if (!pParser) return; - CFDE_XMLNode* pXMLNode = pParser->ParseXMLData(wsExpression, nullptr); + CFX_XMLNode* pXMLNode = pParser->ParseXMLData(wsExpression, nullptr); if (!pXMLNode) return; if (bIgnoreRoot && - (pXMLNode->GetType() != FDE_XMLNODE_Element || - XFA_RecognizeRichText(static_cast(pXMLNode)))) { + (pXMLNode->GetType() != FX_XMLNODE_Element || + XFA_RecognizeRichText(static_cast(pXMLNode)))) { bIgnoreRoot = false; } CXFA_Node* pFakeRoot = Clone(false); @@ -1299,27 +1299,27 @@ void CXFA_Node::Script_NodeClass_LoadXML(CFXJSE_Arguments* pArguments) { CFX_WideString(wsContentType)); } - std::unique_ptr pFakeXMLRoot(pFakeRoot->GetXMLMappingNode()); + std::unique_ptr pFakeXMLRoot(pFakeRoot->GetXMLMappingNode()); if (!pFakeXMLRoot) { - CFDE_XMLNode* pThisXMLRoot = GetXMLMappingNode(); + CFX_XMLNode* pThisXMLRoot = GetXMLMappingNode(); pFakeXMLRoot = pThisXMLRoot ? pThisXMLRoot->Clone() : nullptr; } if (!pFakeXMLRoot) { pFakeXMLRoot = - pdfium::MakeUnique(CFX_WideString(GetClassName())); + pdfium::MakeUnique(CFX_WideString(GetClassName())); } if (bIgnoreRoot) { - CFDE_XMLNode* pXMLChild = pXMLNode->GetNodeItem(CFDE_XMLNode::FirstChild); + CFX_XMLNode* pXMLChild = pXMLNode->GetNodeItem(CFX_XMLNode::FirstChild); while (pXMLChild) { - CFDE_XMLNode* pXMLSibling = - pXMLChild->GetNodeItem(CFDE_XMLNode::NextSibling); + CFX_XMLNode* pXMLSibling = + pXMLChild->GetNodeItem(CFX_XMLNode::NextSibling); pXMLNode->RemoveChildNode(pXMLChild); pFakeXMLRoot->InsertChildNode(pXMLChild); pXMLChild = pXMLSibling; } } else { - CFDE_XMLNode* pXMLParent = pXMLNode->GetNodeItem(CFDE_XMLNode::Parent); + CFX_XMLNode* pXMLParent = pXMLNode->GetNodeItem(CFX_XMLNode::Parent); if (pXMLParent) { pXMLParent->RemoveChildNode(pXMLNode); } @@ -1349,10 +1349,10 @@ void CXFA_Node::Script_NodeClass_LoadXML(CFXJSE_Arguments* pArguments) { } if (GetPacketID() == XFA_XDPPACKET_Form && GetElementType() == XFA_Element::ExData) { - CFDE_XMLNode* pTempXMLNode = GetXMLMappingNode(); + CFX_XMLNode* pTempXMLNode = GetXMLMappingNode(); SetXMLMappingNode(pFakeXMLRoot.release()); SetFlag(XFA_NodeFlag_OwnXMLNode, false); - if (pTempXMLNode && !pTempXMLNode->GetNodeItem(CFDE_XMLNode::Parent)) + if (pTempXMLNode && !pTempXMLNode->GetNodeItem(CFX_XMLNode::Parent)) pFakeXMLRoot.reset(pTempXMLNode); else pFakeXMLRoot = nullptr; @@ -1396,10 +1396,10 @@ void CXFA_Node::Script_NodeClass_SaveXML(CFXJSE_Arguments* pArguments) { CFX_WideString bsXMLHeader = L"\n"; if (GetPacketID() == XFA_XDPPACKET_Form || GetPacketID() == XFA_XDPPACKET_Datasets) { - CFDE_XMLNode* pElement = nullptr; + CFX_XMLNode* pElement = nullptr; if (GetPacketID() == XFA_XDPPACKET_Datasets) { pElement = GetXMLMappingNode(); - if (!pElement || pElement->GetType() != FDE_XMLNODE_Element) { + if (!pElement || pElement->GetType() != FX_XMLNODE_Element) { pArguments->GetReturnValue()->SetString( bsXMLHeader.UTF8Encode().AsStringC()); return; @@ -3366,9 +3366,9 @@ void CXFA_Node::Script_Packet_GetAttribute(CFXJSE_Arguments* pArguments) { } CFX_ByteString bsAttributeName = pArguments->GetUTF8String(0); CFX_WideString wsAttributeValue; - CFDE_XMLNode* pXMLNode = GetXMLMappingNode(); - if (pXMLNode && pXMLNode->GetType() == FDE_XMLNODE_Element) { - wsAttributeValue = static_cast(pXMLNode)->GetString( + CFX_XMLNode* pXMLNode = GetXMLMappingNode(); + if (pXMLNode && pXMLNode->GetType() == FX_XMLNODE_Element) { + wsAttributeValue = static_cast(pXMLNode)->GetString( CFX_WideString::FromUTF8(bsAttributeName.AsStringC()).c_str()); } pArguments->GetReturnValue()->SetString( @@ -3382,9 +3382,9 @@ void CXFA_Node::Script_Packet_SetAttribute(CFXJSE_Arguments* pArguments) { } CFX_ByteString bsValue = pArguments->GetUTF8String(0); CFX_ByteString bsName = pArguments->GetUTF8String(1); - CFDE_XMLNode* pXMLNode = GetXMLMappingNode(); - if (pXMLNode && pXMLNode->GetType() == FDE_XMLNODE_Element) { - static_cast(pXMLNode)->SetString( + CFX_XMLNode* pXMLNode = GetXMLMappingNode(); + if (pXMLNode && pXMLNode->GetType() == FX_XMLNODE_Element) { + static_cast(pXMLNode)->SetString( CFX_WideString::FromUTF8(bsName.AsStringC()), CFX_WideString::FromUTF8(bsValue.AsStringC())); } @@ -3399,9 +3399,9 @@ void CXFA_Node::Script_Packet_RemoveAttribute(CFXJSE_Arguments* pArguments) { CFX_ByteString bsName = pArguments->GetUTF8String(0); CFX_WideString wsName = CFX_WideString::FromUTF8(bsName.AsStringC()); - CFDE_XMLNode* pXMLNode = GetXMLMappingNode(); - if (pXMLNode && pXMLNode->GetType() == FDE_XMLNODE_Element) { - CFDE_XMLElement* pXMLElement = static_cast(pXMLNode); + CFX_XMLNode* pXMLNode = GetXMLMappingNode(); + if (pXMLNode && pXMLNode->GetType() == FX_XMLNODE_Element) { + CFX_XMLElement* pXMLElement = static_cast(pXMLNode); if (pXMLElement->HasAttribute(wsName.c_str())) { pXMLElement->RemoveAttribute(wsName.c_str()); } @@ -3413,16 +3413,16 @@ void CXFA_Node::Script_Packet_Content(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { if (bSetting) { - CFDE_XMLNode* pXMLNode = GetXMLMappingNode(); - if (pXMLNode && pXMLNode->GetType() == FDE_XMLNODE_Element) { - CFDE_XMLElement* pXMLElement = static_cast(pXMLNode); + CFX_XMLNode* pXMLNode = GetXMLMappingNode(); + if (pXMLNode && pXMLNode->GetType() == FX_XMLNODE_Element) { + CFX_XMLElement* pXMLElement = static_cast(pXMLNode); pXMLElement->SetTextData(pValue->ToWideString()); } } else { CFX_WideString wsTextData; - CFDE_XMLNode* pXMLNode = GetXMLMappingNode(); - if (pXMLNode && pXMLNode->GetType() == FDE_XMLNODE_Element) { - CFDE_XMLElement* pXMLElement = static_cast(pXMLNode); + CFX_XMLNode* pXMLNode = GetXMLMappingNode(); + if (pXMLNode && pXMLNode->GetType() == FX_XMLNODE_Element) { + CFX_XMLElement* pXMLElement = static_cast(pXMLNode); wsTextData = pXMLElement->GetTextData(); } pValue->SetString(wsTextData.UTF8Encode().AsStringC()); @@ -3782,11 +3782,11 @@ bool CXFA_Node::SetCData(XFA_ATTRIBUTE eAttr, } if (eAttr == XFA_ATTRIBUTE_Value) { - FDE_XMLNODETYPE eXMLType = m_pXMLNode->GetType(); + FX_XMLNODETYPE eXMLType = m_pXMLNode->GetType(); switch (eXMLType) { - case FDE_XMLNODE_Element: + case FX_XMLNODE_Element: if (IsAttributeInXML()) { - static_cast(m_pXMLNode) + static_cast(m_pXMLNode) ->SetString(CFX_WideString(GetCData(XFA_ATTRIBUTE_QualifiedName)), wsValue); } else { @@ -3803,13 +3803,13 @@ bool CXFA_Node::SetCData(XFA_ATTRIBUTE eAttr, } } if (bDeleteChildren) { - static_cast(m_pXMLNode)->DeleteChildren(); + static_cast(m_pXMLNode)->DeleteChildren(); } - static_cast(m_pXMLNode)->SetTextData(wsValue); + static_cast(m_pXMLNode)->SetTextData(wsValue); } break; - case FDE_XMLNODE_Text: - static_cast(m_pXMLNode)->SetText(wsValue); + case FX_XMLNODE_Text: + static_cast(m_pXMLNode)->SetText(wsValue); break; default: ASSERT(0); @@ -3819,12 +3819,12 @@ bool CXFA_Node::SetCData(XFA_ATTRIBUTE eAttr, const XFA_ATTRIBUTEINFO* pInfo = XFA_GetAttributeByID(eAttr); if (pInfo) { - ASSERT(m_pXMLNode->GetType() == FDE_XMLNODE_Element); + ASSERT(m_pXMLNode->GetType() == FX_XMLNODE_Element); CFX_WideString wsAttrName = pInfo->pName; if (pInfo->eName == XFA_ATTRIBUTE_ContentType) { wsAttrName = L"xfa:" + wsAttrName; } - static_cast(m_pXMLNode)->SetString(wsAttrName, wsValue); + static_cast(m_pXMLNode)->SetString(wsAttrName, wsValue); } return true; } @@ -3839,11 +3839,11 @@ bool CXFA_Node::SetAttributeValue(const CFX_WideString& wsValue, SetUserData(pKey, pClone, &deleteWideStringCallBack); OnChanged(XFA_ATTRIBUTE_Value, bNotify, bScriptModify); if (IsNeedSavingXMLNode()) { - FDE_XMLNODETYPE eXMLType = m_pXMLNode->GetType(); + FX_XMLNODETYPE eXMLType = m_pXMLNode->GetType(); switch (eXMLType) { - case FDE_XMLNODE_Element: + case FX_XMLNODE_Element: if (IsAttributeInXML()) { - static_cast(m_pXMLNode) + static_cast(m_pXMLNode) ->SetString(CFX_WideString(GetCData(XFA_ATTRIBUTE_QualifiedName)), wsXMLValue); } else { @@ -3860,13 +3860,13 @@ bool CXFA_Node::SetAttributeValue(const CFX_WideString& wsValue, } } if (bDeleteChildren) { - static_cast(m_pXMLNode)->DeleteChildren(); + static_cast(m_pXMLNode)->DeleteChildren(); } - static_cast(m_pXMLNode)->SetTextData(wsXMLValue); + static_cast(m_pXMLNode)->SetTextData(wsXMLValue); } break; - case FDE_XMLNODE_Text: - static_cast(m_pXMLNode)->SetText(wsXMLValue); + case FX_XMLNODE_Text: + static_cast(m_pXMLNode)->SetText(wsXMLValue); break; default: ASSERT(0); @@ -3955,26 +3955,26 @@ bool CXFA_Node::SetValue(XFA_ATTRIBUTE eAttr, SetMapModuleValue(pKey, pValue); OnChanged(eAttr, bNotify, false); if (IsNeedSavingXMLNode()) { - ASSERT(m_pXMLNode->GetType() == FDE_XMLNODE_Element); + ASSERT(m_pXMLNode->GetType() == FX_XMLNODE_Element); const XFA_ATTRIBUTEINFO* pInfo = XFA_GetAttributeByID(eAttr); if (pInfo) { switch (eType) { case XFA_ATTRIBUTETYPE_Enum: - static_cast(m_pXMLNode) + static_cast(m_pXMLNode) ->SetString( pInfo->pName, GetAttributeEnumByID((XFA_ATTRIBUTEENUM)(uintptr_t)pValue) ->pName); break; case XFA_ATTRIBUTETYPE_Boolean: - static_cast(m_pXMLNode) + static_cast(m_pXMLNode) ->SetString(pInfo->pName, pValue ? L"1" : L"0"); break; case XFA_ATTRIBUTETYPE_Integer: { CFX_WideString wsValue; wsValue.Format( L"%d", static_cast(reinterpret_cast(pValue))); - static_cast(m_pXMLNode) + static_cast(m_pXMLNode) ->SetString(pInfo->pName, wsValue); break; } @@ -4293,27 +4293,27 @@ CXFA_Node* CXFA_Node::GetModelNode() { bool CXFA_Node::TryNamespace(CFX_WideString& wsNamespace) { wsNamespace.clear(); if (IsModelNode() || GetElementType() == XFA_Element::Packet) { - CFDE_XMLNode* pXMLNode = GetXMLMappingNode(); - if (!pXMLNode || pXMLNode->GetType() != FDE_XMLNODE_Element) { + CFX_XMLNode* pXMLNode = GetXMLMappingNode(); + if (!pXMLNode || pXMLNode->GetType() != FX_XMLNODE_Element) { return false; } - wsNamespace = static_cast(pXMLNode)->GetNamespaceURI(); + wsNamespace = static_cast(pXMLNode)->GetNamespaceURI(); return true; } else if (GetPacketID() == XFA_XDPPACKET_Datasets) { - CFDE_XMLNode* pXMLNode = GetXMLMappingNode(); + CFX_XMLNode* pXMLNode = GetXMLMappingNode(); if (!pXMLNode) { return false; } - if (pXMLNode->GetType() != FDE_XMLNODE_Element) { + if (pXMLNode->GetType() != FX_XMLNODE_Element) { return true; } if (GetElementType() == XFA_Element::DataValue && GetEnum(XFA_ATTRIBUTE_Contains) == XFA_ATTRIBUTEENUM_MetaData) { return XFA_FDEExtension_ResolveNamespaceQualifier( - static_cast(pXMLNode), + static_cast(pXMLNode), GetCData(XFA_ATTRIBUTE_QualifiedName), &wsNamespace); } - wsNamespace = static_cast(pXMLNode)->GetNamespaceURI(); + wsNamespace = static_cast(pXMLNode)->GetNamespaceURI(); return true; } else { CXFA_Node* pModelNode = GetModelNode(); @@ -4448,7 +4448,7 @@ int32_t CXFA_Node::InsertChild(int32_t index, CXFA_Node* pNode) { pNotify->OnChildAdded(this); if (IsNeedSavingXMLNode() && pNode->m_pXMLNode) { - ASSERT(!pNode->m_pXMLNode->GetNodeItem(CFDE_XMLNode::Parent)); + ASSERT(!pNode->m_pXMLNode->GetNodeItem(CFX_XMLNode::Parent)); m_pXMLNode->InsertChildNode(pNode->m_pXMLNode, index); pNode->ClearFlag(XFA_NodeFlag_OwnXMLNode); } @@ -4495,7 +4495,7 @@ bool CXFA_Node::InsertChild(CXFA_Node* pNode, CXFA_Node* pBeforeNode) { pNotify->OnChildAdded(this); if (IsNeedSavingXMLNode() && pNode->m_pXMLNode) { - ASSERT(!pNode->m_pXMLNode->GetNodeItem(CFDE_XMLNode::Parent)); + ASSERT(!pNode->m_pXMLNode->GetNodeItem(CFX_XMLNode::Parent)); m_pXMLNode->InsertChildNode(pNode->m_pXMLNode, nIndex); pNode->ClearFlag(XFA_NodeFlag_OwnXMLNode); } @@ -4543,17 +4543,17 @@ bool CXFA_Node::RemoveChild(CXFA_Node* pNode, bool bNotify) { if (IsNeedSavingXMLNode() && pNode->m_pXMLNode) { if (pNode->IsAttributeInXML()) { ASSERT(pNode->m_pXMLNode == m_pXMLNode && - m_pXMLNode->GetType() == FDE_XMLNODE_Element); - if (pNode->m_pXMLNode->GetType() == FDE_XMLNODE_Element) { - CFDE_XMLElement* pXMLElement = - static_cast(pNode->m_pXMLNode); + m_pXMLNode->GetType() == FX_XMLNODE_Element); + if (pNode->m_pXMLNode->GetType() == FX_XMLNODE_Element) { + CFX_XMLElement* pXMLElement = + static_cast(pNode->m_pXMLNode); CFX_WideStringC wsAttributeName = pNode->GetCData(XFA_ATTRIBUTE_QualifiedName); pXMLElement->RemoveAttribute(wsAttributeName.c_str()); } CFX_WideString wsName; pNode->GetAttribute(XFA_ATTRIBUTE_Name, wsName, false); - CFDE_XMLElement* pNewXMLElement = new CFDE_XMLElement(wsName); + CFX_XMLElement* pNewXMLElement = new CFX_XMLElement(wsName); CFX_WideStringC wsValue = GetCData(XFA_ATTRIBUTE_Value); if (!wsValue.IsEmpty()) { pNewXMLElement->SetTextData(CFX_WideString(wsValue)); @@ -4799,10 +4799,10 @@ void CXFA_Node::UpdateNameHash() { } } -CFDE_XMLNode* CXFA_Node::CreateXMLMappingNode() { +CFX_XMLNode* CXFA_Node::CreateXMLMappingNode() { if (!m_pXMLNode) { CFX_WideString wsTag(GetCData(XFA_ATTRIBUTE_Name)); - m_pXMLNode = new CFDE_XMLElement(wsTag); + m_pXMLNode = new CFX_XMLElement(wsTag); SetFlag(XFA_NodeFlag_OwnXMLNode, false); } return m_pXMLNode; diff --git a/xfa/fxfa/parser/cxfa_node.h b/xfa/fxfa/parser/cxfa_node.h index 970d267ff3..db4b2ce553 100644 --- a/xfa/fxfa/parser/cxfa_node.h +++ b/xfa/fxfa/parser/cxfa_node.h @@ -13,7 +13,7 @@ #include "core/fxcrt/fx_string.h" #include "xfa/fxfa/parser/cxfa_object.h" -class CFDE_XMLNode; +class CFX_XMLNode; class CFXJSE_Argument; class CXFA_WidgetData; @@ -95,9 +95,9 @@ class CXFA_Node : public CXFA_Object { bool IsFormContainer() const { return m_ePacket == XFA_XDPPACKET_Form && IsContainerNode(); } - void SetXMLMappingNode(CFDE_XMLNode* pXMLNode) { m_pXMLNode = pXMLNode; } - CFDE_XMLNode* GetXMLMappingNode() const { return m_pXMLNode; } - CFDE_XMLNode* CreateXMLMappingNode(); + void SetXMLMappingNode(CFX_XMLNode* pXMLNode) { m_pXMLNode = pXMLNode; } + CFX_XMLNode* GetXMLMappingNode() const { return m_pXMLNode; } + CFX_XMLNode* CreateXMLMappingNode(); bool IsNeedSavingXMLNode(); uint32_t GetNameHash() const { return m_dwNameHash; } bool IsUnnamed() const { return m_dwNameHash == 0; } @@ -592,7 +592,7 @@ class CXFA_Node : public CXFA_Object { CXFA_Node* m_pChild; CXFA_Node* m_pLastChild; CXFA_Node* m_pParent; - CFDE_XMLNode* m_pXMLNode; + CFX_XMLNode* m_pXMLNode; uint16_t m_ePacket; uint16_t m_uNodeFlags; uint32_t m_dwNameHash; diff --git a/xfa/fxfa/parser/cxfa_simple_parser.cpp b/xfa/fxfa/parser/cxfa_simple_parser.cpp index 642b7641bd..9fd684c0a9 100644 --- a/xfa/fxfa/parser/cxfa_simple_parser.cpp +++ b/xfa/fxfa/parser/cxfa_simple_parser.cpp @@ -13,14 +13,14 @@ #include "core/fxcrt/cfx_seekablestreamproxy.h" #include "core/fxcrt/fx_codepage.h" #include "core/fxcrt/fx_ext.h" +#include "core/fxcrt/xml/cfx_xmlchardata.h" +#include "core/fxcrt/xml/cfx_xmldoc.h" +#include "core/fxcrt/xml/cfx_xmlelement.h" +#include "core/fxcrt/xml/cfx_xmlinstruction.h" +#include "core/fxcrt/xml/cfx_xmlnode.h" +#include "core/fxcrt/xml/cfx_xmlparser.h" +#include "core/fxcrt/xml/cfx_xmltext.h" #include "third_party/base/ptr_util.h" -#include "xfa/fde/xml/cfde_xmlchardata.h" -#include "xfa/fde/xml/cfde_xmldoc.h" -#include "xfa/fde/xml/cfde_xmlelement.h" -#include "xfa/fde/xml/cfde_xmlinstruction.h" -#include "xfa/fde/xml/cfde_xmlnode.h" -#include "xfa/fde/xml/cfde_xmlparser.h" -#include "xfa/fde/xml/cfde_xmltext.h" #include "xfa/fxfa/fxfa.h" #include "xfa/fxfa/parser/cxfa_document.h" #include "xfa/fxfa/parser/cxfa_node.h" @@ -29,25 +29,25 @@ namespace { -CFDE_XMLNode* GetDocumentNode(CFDE_XMLDoc* pXMLDoc, - bool bVerifyWellFormness = false) { +CFX_XMLNode* GetDocumentNode(CFX_XMLDoc* pXMLDoc, + bool bVerifyWellFormness = false) { if (!pXMLDoc) return nullptr; - for (CFDE_XMLNode* pXMLNode = - pXMLDoc->GetRoot()->GetNodeItem(CFDE_XMLNode::FirstChild); - pXMLNode; pXMLNode = pXMLNode->GetNodeItem(CFDE_XMLNode::NextSibling)) { - if (pXMLNode->GetType() != FDE_XMLNODE_Element) + for (CFX_XMLNode* pXMLNode = + pXMLDoc->GetRoot()->GetNodeItem(CFX_XMLNode::FirstChild); + pXMLNode; pXMLNode = pXMLNode->GetNodeItem(CFX_XMLNode::NextSibling)) { + if (pXMLNode->GetType() != FX_XMLNODE_Element) continue; if (!bVerifyWellFormness) return pXMLNode; - for (CFDE_XMLNode* pNextNode = - pXMLNode->GetNodeItem(CFDE_XMLNode::NextSibling); + for (CFX_XMLNode* pNextNode = + pXMLNode->GetNodeItem(CFX_XMLNode::NextSibling); pNextNode; - pNextNode = pNextNode->GetNodeItem(CFDE_XMLNode::NextSibling)) { - if (pNextNode->GetType() == FDE_XMLNODE_Element) + pNextNode = pNextNode->GetNodeItem(CFX_XMLNode::NextSibling)) { + if (pNextNode->GetType() == FX_XMLNODE_Element) return nullptr; } return pXMLNode; @@ -55,7 +55,7 @@ CFDE_XMLNode* GetDocumentNode(CFDE_XMLDoc* pXMLDoc, return nullptr; } -CFX_WideString GetElementTagNamespaceURI(CFDE_XMLElement* pElement) { +CFX_WideString GetElementTagNamespaceURI(CFX_XMLElement* pElement) { CFX_WideString wsNodeStr = pElement->GetNamespacePrefix(); CFX_WideString wsNamespaceURI; if (!XFA_FDEExtension_ResolveNamespaceQualifier( @@ -65,14 +65,14 @@ CFX_WideString GetElementTagNamespaceURI(CFDE_XMLElement* pElement) { return wsNamespaceURI; } -bool MatchNodeName(CFDE_XMLNode* pNode, +bool MatchNodeName(CFX_XMLNode* pNode, const CFX_WideStringC& wsLocalTagName, const CFX_WideStringC& wsNamespaceURIPrefix, uint32_t eMatchFlags = XFA_XDPPACKET_FLAGS_NOMATCH) { - if (!pNode || pNode->GetType() != FDE_XMLNODE_Element) + if (!pNode || pNode->GetType() != FX_XMLNODE_Element) return false; - CFDE_XMLElement* pElement = reinterpret_cast(pNode); + CFX_XMLElement* pElement = reinterpret_cast(pNode); CFX_WideString wsNodeStr = pElement->GetLocalTagName(); if (wsNodeStr != wsLocalTagName) return false; @@ -100,7 +100,7 @@ bool GetAttributeLocalName(const CFX_WideStringC& wsAttributeName, return true; } -bool ResolveAttribute(CFDE_XMLElement* pElement, +bool ResolveAttribute(CFX_XMLElement* pElement, const CFX_WideStringC& wsAttributeName, CFX_WideString& wsLocalAttrName, CFX_WideString& wsNamespaceURI) { @@ -122,7 +122,7 @@ bool ResolveAttribute(CFDE_XMLElement* pElement, return true; } -bool FindAttributeWithNS(CFDE_XMLElement* pElement, +bool FindAttributeWithNS(CFX_XMLElement* pElement, const CFX_WideStringC& wsLocalAttributeName, const CFX_WideStringC& wsNamespaceURIPrefix, CFX_WideString& wsValue, @@ -164,7 +164,7 @@ bool FindAttributeWithNS(CFDE_XMLElement* pElement, return false; } -CFDE_XMLNode* GetDataSetsFromXDP(CFDE_XMLNode* pXMLDocumentNode) { +CFX_XMLNode* GetDataSetsFromXDP(CFX_XMLNode* pXMLDocumentNode) { if (MatchNodeName(pXMLDocumentNode, XFA_GetPacketByIndex(XFA_PACKET_Datasets)->pName, XFA_GetPacketByIndex(XFA_PACKET_Datasets)->pURI, @@ -177,10 +177,10 @@ CFDE_XMLNode* GetDataSetsFromXDP(CFDE_XMLNode* pXMLDocumentNode) { XFA_GetPacketByIndex(XFA_PACKET_XDP)->eFlags)) { return nullptr; } - for (CFDE_XMLNode* pDatasetsNode = - pXMLDocumentNode->GetNodeItem(CFDE_XMLNode::FirstChild); + for (CFX_XMLNode* pDatasetsNode = + pXMLDocumentNode->GetNodeItem(CFX_XMLNode::FirstChild); pDatasetsNode; - pDatasetsNode = pDatasetsNode->GetNodeItem(CFDE_XMLNode::NextSibling)) { + pDatasetsNode = pDatasetsNode->GetNodeItem(CFX_XMLNode::NextSibling)) { if (!MatchNodeName(pDatasetsNode, XFA_GetPacketByIndex(XFA_PACKET_Datasets)->pName, XFA_GetPacketByIndex(XFA_PACKET_Datasets)->pURI, @@ -197,24 +197,23 @@ bool IsStringAllWhitespace(CFX_WideString wsText) { return wsText.IsEmpty(); } -void ConvertXMLToPlainText(CFDE_XMLElement* pRootXMLNode, +void ConvertXMLToPlainText(CFX_XMLElement* pRootXMLNode, CFX_WideString& wsOutput) { - for (CFDE_XMLNode* pXMLChild = - pRootXMLNode->GetNodeItem(CFDE_XMLNode::FirstChild); + for (CFX_XMLNode* pXMLChild = + pRootXMLNode->GetNodeItem(CFX_XMLNode::FirstChild); pXMLChild; - pXMLChild = pXMLChild->GetNodeItem(CFDE_XMLNode::NextSibling)) { + pXMLChild = pXMLChild->GetNodeItem(CFX_XMLNode::NextSibling)) { switch (pXMLChild->GetType()) { - case FDE_XMLNODE_Element: { + case FX_XMLNODE_Element: { CFX_WideString wsTextData = - static_cast(pXMLChild)->GetTextData(); + static_cast(pXMLChild)->GetTextData(); wsTextData += L"\n"; wsOutput += wsTextData; break; } - case FDE_XMLNODE_Text: - case FDE_XMLNODE_CharData: { - CFX_WideString wsText = - static_cast(pXMLChild)->GetText(); + case FX_XMLNODE_Text: + case FX_XMLNODE_CharData: { + CFX_WideString wsText = static_cast(pXMLChild)->GetText(); if (IsStringAllWhitespace(wsText)) continue; @@ -250,7 +249,7 @@ const XFA_PACKETINFO* GetPacketByName(const CFX_WideStringC& wsName) { } // namespace -bool XFA_RecognizeRichText(CFDE_XMLElement* pRichTextXMLNode) { +bool XFA_RecognizeRichText(CFX_XMLElement* pRichTextXMLNode) { return pRichTextXMLNode && GetElementTagNamespaceURI(pRichTextXMLNode) == L"http://www.w3.org/1999/xhtml"; } @@ -283,9 +282,9 @@ int32_t CXFA_SimpleParser::StartParse( wCodePage != FX_CODEPAGE_UTF8) { m_pStream->SetCodePage(FX_CODEPAGE_UTF8); } - m_pXMLDoc = pdfium::MakeUnique(); + m_pXMLDoc = pdfium::MakeUnique(); auto pNewParser = - pdfium::MakeUnique(m_pXMLDoc->GetRoot(), m_pStream); + pdfium::MakeUnique(m_pXMLDoc->GetRoot(), m_pStream); m_pXMLParser = pNewParser.get(); if (!m_pXMLDoc->LoadXML(std::move(pNewParser))) return XFA_PARSESTATUS_StatusErr; @@ -314,15 +313,15 @@ int32_t CXFA_SimpleParser::DoParse(IFX_Pause* pPause) { return XFA_PARSESTATUS_Done; } -CFDE_XMLNode* CXFA_SimpleParser::ParseXMLData(const CFX_ByteString& wsXML, - IFX_Pause* pPause) { +CFX_XMLNode* CXFA_SimpleParser::ParseXMLData(const CFX_ByteString& wsXML, + IFX_Pause* pPause) { CloseParser(); - m_pXMLDoc = pdfium::MakeUnique(); + m_pXMLDoc = pdfium::MakeUnique(); auto pStream = pdfium::MakeRetain( const_cast(wsXML.raw_str()), wsXML.GetLength()); auto pParser = - pdfium::MakeUnique(m_pXMLDoc->GetRoot(), pStream); + pdfium::MakeUnique(m_pXMLDoc->GetRoot(), pStream); pParser->m_dwCheckStatus = 0x03; if (!m_pXMLDoc->LoadXML(std::move(pParser))) return nullptr; @@ -334,25 +333,25 @@ CFDE_XMLNode* CXFA_SimpleParser::ParseXMLData(const CFX_ByteString& wsXML, } void CXFA_SimpleParser::ConstructXFANode(CXFA_Node* pXFANode, - CFDE_XMLNode* pXMLNode) { + CFX_XMLNode* pXMLNode) { XFA_XDPPACKET ePacketID = (XFA_XDPPACKET)pXFANode->GetPacketID(); if (ePacketID == XFA_XDPPACKET_Datasets) { if (pXFANode->GetElementType() == XFA_Element::DataValue) { - for (CFDE_XMLNode* pXMLChild = - pXMLNode->GetNodeItem(CFDE_XMLNode::FirstChild); + for (CFX_XMLNode* pXMLChild = + pXMLNode->GetNodeItem(CFX_XMLNode::FirstChild); pXMLChild; - pXMLChild = pXMLChild->GetNodeItem(CFDE_XMLNode::NextSibling)) { - FDE_XMLNODETYPE eNodeType = pXMLChild->GetType(); - if (eNodeType == FDE_XMLNODE_Instruction) + pXMLChild = pXMLChild->GetNodeItem(CFX_XMLNode::NextSibling)) { + FX_XMLNODETYPE eNodeType = pXMLChild->GetType(); + if (eNodeType == FX_XMLNODE_Instruction) continue; - if (eNodeType == FDE_XMLNODE_Element) { + if (eNodeType == FX_XMLNODE_Element) { CXFA_Node* pXFAChild = m_pFactory->CreateNode(XFA_XDPPACKET_Datasets, XFA_Element::DataValue); if (!pXFAChild) return; - CFDE_XMLElement* child = static_cast(pXMLChild); + CFX_XMLElement* child = static_cast(pXMLChild); CFX_WideString wsNodeStr = child->GetLocalTagName(); pXFAChild->SetCData(XFA_ATTRIBUTE_Name, wsNodeStr); CFX_WideString wsChildValue; @@ -382,18 +381,18 @@ CXFA_Node* CXFA_SimpleParser::GetRootNode() const { return m_pRootNode; } -CFDE_XMLDoc* CXFA_SimpleParser::GetXMLDoc() const { +CFX_XMLDoc* CXFA_SimpleParser::GetXMLDoc() const { return m_pXMLDoc.get(); } bool XFA_FDEExtension_ResolveNamespaceQualifier( - CFDE_XMLElement* pNode, + CFX_XMLElement* pNode, const CFX_WideStringC& wsQualifier, CFX_WideString* wsNamespaceURI) { if (!pNode) return false; - CFDE_XMLNode* pFakeRoot = pNode->GetNodeItem(CFDE_XMLNode::Root); + CFX_XMLNode* pFakeRoot = pNode->GetNodeItem(CFX_XMLNode::Root); CFX_WideString wsNSAttribute; bool bRet = false; if (wsQualifier.IsEmpty()) { @@ -402,12 +401,12 @@ bool XFA_FDEExtension_ResolveNamespaceQualifier( } else { wsNSAttribute = L"xmlns:" + wsQualifier; } - for (CFDE_XMLNode* pParent = pNode; pParent != pFakeRoot; - pParent = pParent->GetNodeItem(CFDE_XMLNode::Parent)) { - if (pParent->GetType() != FDE_XMLNODE_Element) + for (CFX_XMLNode* pParent = pNode; pParent != pFakeRoot; + pParent = pParent->GetNodeItem(CFX_XMLNode::Parent)) { + if (pParent->GetType() != FX_XMLNODE_Element) continue; - auto* pElement = static_cast(pParent); + auto* pElement = static_cast(pParent); if (pElement->HasAttribute(wsNSAttribute.c_str())) { *wsNamespaceURI = pElement->GetString(wsNSAttribute.c_str()); return true; @@ -417,7 +416,7 @@ bool XFA_FDEExtension_ResolveNamespaceQualifier( return bRet; } -CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket(CFDE_XMLNode* pXMLDocumentNode, +CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket(CFX_XMLNode* pXMLDocumentNode, XFA_XDPPACKET ePacketID) { switch (ePacketID) { case XFA_XDPPACKET_UNKNOWN: @@ -444,7 +443,7 @@ CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket(CFDE_XMLNode* pXMLDocumentNode, } CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_XDP( - CFDE_XMLNode* pXMLDocumentNode, + CFX_XMLNode* pXMLDocumentNode, XFA_XDPPACKET ePacketID) { if (!MatchNodeName(pXMLDocumentNode, XFA_GetPacketByIndex(XFA_PACKET_XDP)->pName, @@ -461,7 +460,7 @@ CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_XDP( m_pRootNode = pXFARootNode; pXFARootNode->SetCData(XFA_ATTRIBUTE_Name, L"xfa"); - CFDE_XMLElement* pElement = static_cast(pXMLDocumentNode); + CFX_XMLElement* pElement = static_cast(pXMLDocumentNode); for (auto it : pElement->GetAttributes()) { if (it.first == L"uuid") pXFARootNode->SetCData(XFA_ATTRIBUTE_Uuid, it.second); @@ -469,12 +468,12 @@ CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_XDP( pXFARootNode->SetCData(XFA_ATTRIBUTE_TimeStamp, it.second); } - CFDE_XMLNode* pXMLConfigDOMRoot = nullptr; + CFX_XMLNode* pXMLConfigDOMRoot = nullptr; CXFA_Node* pXFAConfigDOMRoot = nullptr; - for (CFDE_XMLNode* pChildItem = - pXMLDocumentNode->GetNodeItem(CFDE_XMLNode::FirstChild); + for (CFX_XMLNode* pChildItem = + pXMLDocumentNode->GetNodeItem(CFX_XMLNode::FirstChild); pChildItem; - pChildItem = pChildItem->GetNodeItem(CFDE_XMLNode::NextSibling)) { + pChildItem = pChildItem->GetNodeItem(CFX_XMLNode::NextSibling)) { const XFA_PACKETINFO* pPacketInfo = XFA_GetPacketByIndex(XFA_PACKET_Config); if (!MatchNodeName(pChildItem, pPacketInfo->pName, pPacketInfo->pURI, pPacketInfo->eFlags)) { @@ -489,19 +488,19 @@ CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_XDP( pXFARootNode->InsertChild(pXFAConfigDOMRoot, nullptr); } - CFDE_XMLNode* pXMLDatasetsDOMRoot = nullptr; - CFDE_XMLNode* pXMLFormDOMRoot = nullptr; - CFDE_XMLNode* pXMLTemplateDOMRoot = nullptr; - for (CFDE_XMLNode* pChildItem = - pXMLDocumentNode->GetNodeItem(CFDE_XMLNode::FirstChild); + CFX_XMLNode* pXMLDatasetsDOMRoot = nullptr; + CFX_XMLNode* pXMLFormDOMRoot = nullptr; + CFX_XMLNode* pXMLTemplateDOMRoot = nullptr; + for (CFX_XMLNode* pChildItem = + pXMLDocumentNode->GetNodeItem(CFX_XMLNode::FirstChild); pChildItem; - pChildItem = pChildItem->GetNodeItem(CFDE_XMLNode::NextSibling)) { - if (!pChildItem || pChildItem->GetType() != FDE_XMLNODE_Element) + pChildItem = pChildItem->GetNodeItem(CFX_XMLNode::NextSibling)) { + if (!pChildItem || pChildItem->GetType() != FX_XMLNODE_Element) continue; if (pChildItem == pXMLConfigDOMRoot) continue; - CFDE_XMLElement* pElement = reinterpret_cast(pChildItem); + CFX_XMLElement* pElement = reinterpret_cast(pChildItem); CFX_WideString wsPacketName = pElement->GetLocalTagName(); const XFA_PACKETINFO* pPacketInfo = GetPacketByName(wsPacketName.AsStringC()); @@ -570,7 +569,7 @@ CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_XDP( } CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_Config( - CFDE_XMLNode* pXMLDocumentNode, + CFX_XMLNode* pXMLDocumentNode, XFA_XDPPACKET ePacketID) { if (!MatchNodeName(pXMLDocumentNode, XFA_GetPacketByIndex(XFA_PACKET_Config)->pName, @@ -593,7 +592,7 @@ CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_Config( } CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_TemplateForm( - CFDE_XMLNode* pXMLDocumentNode, + CFX_XMLNode* pXMLDocumentNode, XFA_XDPPACKET ePacketID) { CXFA_Node* pNode = nullptr; if (ePacketID == XFA_XDPPACKET_Template) { @@ -609,8 +608,8 @@ CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_TemplateForm( pNode->SetCData(XFA_ATTRIBUTE_Name, XFA_GetPacketByIndex(XFA_PACKET_Template)->pName); if (m_bDocumentParser) { - CFDE_XMLElement* pXMLDocumentElement = - static_cast(pXMLDocumentNode); + CFX_XMLElement* pXMLDocumentElement = + static_cast(pXMLDocumentNode); CFX_WideString wsNamespaceURI = pXMLDocumentElement->GetNamespaceURI(); if (wsNamespaceURI.IsEmpty()) wsNamespaceURI = pXMLDocumentElement->GetString(L"xmlns:xfa"); @@ -625,8 +624,8 @@ CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_TemplateForm( XFA_GetPacketByIndex(XFA_PACKET_Form)->pName, XFA_GetPacketByIndex(XFA_PACKET_Form)->pURI, XFA_GetPacketByIndex(XFA_PACKET_Form)->eFlags)) { - CFDE_XMLElement* pXMLDocumentElement = - static_cast(pXMLDocumentNode); + CFX_XMLElement* pXMLDocumentElement = + static_cast(pXMLDocumentNode); CFX_WideString wsChecksum = pXMLDocumentElement->GetString(L"checksum"); if (wsChecksum.GetLength() != 28 || m_pXMLParser->m_dwCheckStatus != 0x03) { @@ -674,9 +673,9 @@ CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_TemplateForm( } CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_Data( - CFDE_XMLNode* pXMLDocumentNode, + CFX_XMLNode* pXMLDocumentNode, XFA_XDPPACKET ePacketID) { - CFDE_XMLNode* pDatasetsXMLNode = GetDataSetsFromXDP(pXMLDocumentNode); + CFX_XMLNode* pDatasetsXMLNode = GetDataSetsFromXDP(pXMLDocumentNode); if (pDatasetsXMLNode) { CXFA_Node* pNode = m_pFactory->CreateNode(XFA_XDPPACKET_Datasets, XFA_Element::DataModel); @@ -692,23 +691,23 @@ CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_Data( return pNode; } - CFDE_XMLNode* pDataXMLNode = nullptr; + CFX_XMLNode* pDataXMLNode = nullptr; if (MatchNodeName(pXMLDocumentNode, L"data", XFA_GetPacketByIndex(XFA_PACKET_Datasets)->pURI, XFA_GetPacketByIndex(XFA_PACKET_Datasets)->eFlags)) { - static_cast(pXMLDocumentNode) + static_cast(pXMLDocumentNode) ->RemoveAttribute(L"xmlns:xfa"); pDataXMLNode = pXMLDocumentNode; } else { - CFDE_XMLElement* pDataElement = new CFDE_XMLElement(L"xfa:data"); - CFDE_XMLNode* pParentXMLNode = - pXMLDocumentNode->GetNodeItem(CFDE_XMLNode::Parent); + CFX_XMLElement* pDataElement = new CFX_XMLElement(L"xfa:data"); + CFX_XMLNode* pParentXMLNode = + pXMLDocumentNode->GetNodeItem(CFX_XMLNode::Parent); if (pParentXMLNode) pParentXMLNode->RemoveChildNode(pXMLDocumentNode); - ASSERT(pXMLDocumentNode->GetType() == FDE_XMLNODE_Element); - if (pXMLDocumentNode->GetType() == FDE_XMLNODE_Element) { - static_cast(pXMLDocumentNode) + ASSERT(pXMLDocumentNode->GetType() == FX_XMLNODE_Element); + if (pXMLDocumentNode->GetType() == FX_XMLNODE_Element) { + static_cast(pXMLDocumentNode) ->RemoveAttribute(L"xmlns:xfa"); } pDataElement->InsertChildNode(pXMLDocumentNode); @@ -724,7 +723,7 @@ CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_Data( return nullptr; } CFX_WideString wsLocalName = - static_cast(pDataXMLNode)->GetLocalTagName(); + static_cast(pDataXMLNode)->GetLocalTagName(); pNode->SetCData(XFA_ATTRIBUTE_Name, wsLocalName); if (!DataLoader(pNode, pDataXMLNode, true)) return nullptr; @@ -738,7 +737,7 @@ CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_Data( } CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_LocaleConnectionSourceSet( - CFDE_XMLNode* pXMLDocumentNode, + CFX_XMLNode* pXMLDocumentNode, XFA_XDPPACKET ePacketID) { CXFA_Node* pNode = nullptr; if (ePacketID == XFA_XDPPACKET_LocaleSet) { @@ -793,7 +792,7 @@ CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_LocaleConnectionSourceSet( } CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_Xdc( - CFDE_XMLNode* pXMLDocumentNode, + CFX_XMLNode* pXMLDocumentNode, XFA_XDPPACKET ePacketID) { if (!MatchNodeName(pXMLDocumentNode, XFA_GetPacketByIndex(XFA_PACKET_Xdc)->pName, @@ -813,7 +812,7 @@ CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_Xdc( } CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_User( - CFDE_XMLNode* pXMLDocumentNode, + CFX_XMLNode* pXMLDocumentNode, XFA_XDPPACKET ePacketID) { CXFA_Node* pNode = m_pFactory->CreateNode(XFA_XDPPACKET_XDP, XFA_Element::Packet); @@ -821,7 +820,7 @@ CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_User( return nullptr; CFX_WideString wsName = - static_cast(pXMLDocumentNode)->GetLocalTagName(); + static_cast(pXMLDocumentNode)->GetLocalTagName(); pNode->SetCData(XFA_ATTRIBUTE_Name, wsName); if (!UserPacketLoader(pNode, pXMLDocumentNode)) return nullptr; @@ -831,28 +830,28 @@ CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_User( } CXFA_Node* CXFA_SimpleParser::UserPacketLoader(CXFA_Node* pXFANode, - CFDE_XMLNode* pXMLDoc) { + CFX_XMLNode* pXMLDoc) { return pXFANode; } CXFA_Node* CXFA_SimpleParser::DataLoader(CXFA_Node* pXFANode, - CFDE_XMLNode* pXMLDoc, + CFX_XMLNode* pXMLDoc, bool bDoTransform) { ParseDataGroup(pXFANode, pXMLDoc, XFA_XDPPACKET_Datasets); return pXFANode; } CXFA_Node* CXFA_SimpleParser::NormalLoader(CXFA_Node* pXFANode, - CFDE_XMLNode* pXMLDoc, + CFX_XMLNode* pXMLDoc, XFA_XDPPACKET ePacketID, bool bUseAttribute) { bool bOneOfPropertyFound = false; - for (CFDE_XMLNode* pXMLChild = pXMLDoc->GetNodeItem(CFDE_XMLNode::FirstChild); + for (CFX_XMLNode* pXMLChild = pXMLDoc->GetNodeItem(CFX_XMLNode::FirstChild); pXMLChild; - pXMLChild = pXMLChild->GetNodeItem(CFDE_XMLNode::NextSibling)) { + pXMLChild = pXMLChild->GetNodeItem(CFX_XMLNode::NextSibling)) { switch (pXMLChild->GetType()) { - case FDE_XMLNODE_Element: { - CFDE_XMLElement* pXMLElement = static_cast(pXMLChild); + case FX_XMLNODE_Element: { + CFX_XMLElement* pXMLElement = static_cast(pXMLChild); CFX_WideString wsTagName = pXMLElement->GetLocalTagName(); XFA_Element eType = XFA_GetElementTypeForName(wsTagName.AsStringC()); if (eType == XFA_Element::Unknown) @@ -914,8 +913,8 @@ CXFA_Node* CXFA_SimpleParser::NormalLoader(CXFA_Node* pXFANode, break; } } break; - case FDE_XMLNODE_Instruction: - ParseInstruction(pXFANode, static_cast(pXMLChild), + case FX_XMLNODE_Instruction: + ParseInstruction(pXFANode, static_cast(pXMLChild), ePacketID); break; default: @@ -926,7 +925,7 @@ CXFA_Node* CXFA_SimpleParser::NormalLoader(CXFA_Node* pXFANode, } void CXFA_SimpleParser::ParseContentNode(CXFA_Node* pXFANode, - CFDE_XMLNode* pXMLNode, + CFX_XMLNode* pXMLNode, XFA_XDPPACKET ePacketID) { XFA_Element element = XFA_Element::Sharptext; if (pXFANode->GetElementType() == XFA_Element::ExData) { @@ -941,31 +940,30 @@ void CXFA_SimpleParser::ParseContentNode(CXFA_Node* pXFANode, pXFANode->SetXMLMappingNode(pXMLNode); CFX_WideString wsValue; - for (CFDE_XMLNode* pXMLChild = - pXMLNode->GetNodeItem(CFDE_XMLNode::FirstChild); + for (CFX_XMLNode* pXMLChild = pXMLNode->GetNodeItem(CFX_XMLNode::FirstChild); pXMLChild; - pXMLChild = pXMLChild->GetNodeItem(CFDE_XMLNode::NextSibling)) { - FDE_XMLNODETYPE eNodeType = pXMLChild->GetType(); - if (eNodeType == FDE_XMLNODE_Instruction) + pXMLChild = pXMLChild->GetNodeItem(CFX_XMLNode::NextSibling)) { + FX_XMLNODETYPE eNodeType = pXMLChild->GetType(); + if (eNodeType == FX_XMLNODE_Instruction) continue; if (element == XFA_Element::SharpxHTML) { - if (eNodeType != FDE_XMLNODE_Element) + if (eNodeType != FX_XMLNODE_Element) break; - if (XFA_RecognizeRichText(static_cast(pXMLChild))) - XFA_GetPlainTextFromRichText(static_cast(pXMLChild), + if (XFA_RecognizeRichText(static_cast(pXMLChild))) + XFA_GetPlainTextFromRichText(static_cast(pXMLChild), wsValue); } else if (element == XFA_Element::Sharpxml) { - if (eNodeType != FDE_XMLNODE_Element) + if (eNodeType != FX_XMLNODE_Element) break; - ConvertXMLToPlainText(static_cast(pXMLChild), wsValue); + ConvertXMLToPlainText(static_cast(pXMLChild), wsValue); } else { - if (eNodeType == FDE_XMLNODE_Element) + if (eNodeType == FX_XMLNODE_Element) break; - if (eNodeType == FDE_XMLNODE_Text || eNodeType == FDE_XMLNODE_CharData) - wsValue = static_cast(pXMLChild)->GetText(); + if (eNodeType == FX_XMLNODE_Text || eNodeType == FX_XMLNODE_CharData) + wsValue = static_cast(pXMLChild)->GetText(); } break; } @@ -983,15 +981,14 @@ void CXFA_SimpleParser::ParseContentNode(CXFA_Node* pXFANode, } void CXFA_SimpleParser::ParseDataGroup(CXFA_Node* pXFANode, - CFDE_XMLNode* pXMLNode, + CFX_XMLNode* pXMLNode, XFA_XDPPACKET ePacketID) { - for (CFDE_XMLNode* pXMLChild = - pXMLNode->GetNodeItem(CFDE_XMLNode::FirstChild); + for (CFX_XMLNode* pXMLChild = pXMLNode->GetNodeItem(CFX_XMLNode::FirstChild); pXMLChild; - pXMLChild = pXMLChild->GetNodeItem(CFDE_XMLNode::NextSibling)) { + pXMLChild = pXMLChild->GetNodeItem(CFX_XMLNode::NextSibling)) { switch (pXMLChild->GetType()) { - case FDE_XMLNODE_Element: { - CFDE_XMLElement* pXMLElement = static_cast(pXMLChild); + case FX_XMLNODE_Element: { + CFX_XMLElement* pXMLElement = static_cast(pXMLChild); { CFX_WideString wsNamespaceURI = GetElementTagNamespaceURI(pXMLElement); @@ -1024,13 +1021,13 @@ void CXFA_SimpleParser::ParseDataGroup(CXFA_Node* pXFANode, } } if (eNodeType == XFA_Element::DataModel) { - for (CFDE_XMLNode* pXMLDataChild = - pXMLElement->GetNodeItem(CFDE_XMLNode::FirstChild); + for (CFX_XMLNode* pXMLDataChild = + pXMLElement->GetNodeItem(CFX_XMLNode::FirstChild); pXMLDataChild; pXMLDataChild = pXMLDataChild->GetNodeItem( - CFDE_XMLNode::NextSibling)) { - if (pXMLDataChild->GetType() == FDE_XMLNODE_Element) { + CFX_XMLNode::NextSibling)) { + if (pXMLDataChild->GetType() == FX_XMLNODE_Element) { if (!XFA_RecognizeRichText( - static_cast(pXMLDataChild))) { + static_cast(pXMLDataChild))) { eNodeType = XFA_Element::DataGroup; break; } @@ -1094,9 +1091,9 @@ void CXFA_SimpleParser::ParseDataGroup(CXFA_Node* pXFANode, pXFAChild->SetFlag(XFA_NodeFlag_Initialized, false); continue; } - case FDE_XMLNODE_CharData: - case FDE_XMLNODE_Text: { - CFDE_XMLText* pXMLText = static_cast(pXMLChild); + case FX_XMLNODE_CharData: + case FX_XMLNODE_Text: { + CFX_XMLText* pXMLText = static_cast(pXMLChild); CFX_WideString wsText = pXMLText->GetText(); if (IsStringAllWhitespace(wsText)) continue; @@ -1119,30 +1116,28 @@ void CXFA_SimpleParser::ParseDataGroup(CXFA_Node* pXFANode, } void CXFA_SimpleParser::ParseDataValue(CXFA_Node* pXFANode, - CFDE_XMLNode* pXMLNode, + CFX_XMLNode* pXMLNode, XFA_XDPPACKET ePacketID) { CFX_WideTextBuf wsValueTextBuf; CFX_WideTextBuf wsCurValueTextBuf; bool bMarkAsCompound = false; - CFDE_XMLNode* pXMLCurValueNode = nullptr; - for (CFDE_XMLNode* pXMLChild = - pXMLNode->GetNodeItem(CFDE_XMLNode::FirstChild); + CFX_XMLNode* pXMLCurValueNode = nullptr; + for (CFX_XMLNode* pXMLChild = pXMLNode->GetNodeItem(CFX_XMLNode::FirstChild); pXMLChild; - pXMLChild = pXMLChild->GetNodeItem(CFDE_XMLNode::NextSibling)) { - FDE_XMLNODETYPE eNodeType = pXMLChild->GetType(); - if (eNodeType == FDE_XMLNODE_Instruction) + pXMLChild = pXMLChild->GetNodeItem(CFX_XMLNode::NextSibling)) { + FX_XMLNODETYPE eNodeType = pXMLChild->GetType(); + if (eNodeType == FX_XMLNODE_Instruction) continue; CFX_WideString wsText; - if (eNodeType == FDE_XMLNODE_Text || eNodeType == FDE_XMLNODE_CharData) { - wsText = static_cast(pXMLChild)->GetText(); + if (eNodeType == FX_XMLNODE_Text || eNodeType == FX_XMLNODE_CharData) { + wsText = static_cast(pXMLChild)->GetText(); if (!pXMLCurValueNode) pXMLCurValueNode = pXMLChild; wsCurValueTextBuf << wsText; - } else if (XFA_RecognizeRichText( - static_cast(pXMLChild))) { - XFA_GetPlainTextFromRichText(static_cast(pXMLChild), + } else if (XFA_RecognizeRichText(static_cast(pXMLChild))) { + XFA_GetPlainTextFromRichText(static_cast(pXMLChild), wsText); if (!pXMLCurValueNode) pXMLCurValueNode = pXMLChild; @@ -1174,7 +1169,7 @@ void CXFA_SimpleParser::ParseDataValue(CXFA_Node* pXFANode, return; CFX_WideString wsNodeStr = - static_cast(pXMLChild)->GetLocalTagName(); + static_cast(pXMLChild)->GetLocalTagName(); pXFAChild->SetCData(XFA_ATTRIBUTE_Name, wsNodeStr); ParseDataValue(pXFAChild, pXMLChild, ePacketID); pXFANode->InsertChild(pXFAChild); @@ -1209,7 +1204,7 @@ void CXFA_SimpleParser::ParseDataValue(CXFA_Node* pXFANode, } void CXFA_SimpleParser::ParseInstruction(CXFA_Node* pXFANode, - CFDE_XMLInstruction* pXMLInstruction, + CFX_XMLInstruction* pXMLInstruction, XFA_XDPPACKET ePacketID) { if (!m_bDocumentParser) return; diff --git a/xfa/fxfa/parser/cxfa_simple_parser.h b/xfa/fxfa/parser/cxfa_simple_parser.h index 88a7679e74..cb1efcc1d5 100644 --- a/xfa/fxfa/parser/cxfa_simple_parser.h +++ b/xfa/fxfa/parser/cxfa_simple_parser.h @@ -13,10 +13,10 @@ class CXFA_Document; class CXFA_Node; -class CFDE_XMLDoc; -class CFDE_XMLInstruction; -class CFDE_XMLNode; -class CFDE_XMLParser; +class CFX_XMLDoc; +class CFX_XMLInstruction; +class CFX_XMLNode; +class CFX_XMLParser; class IFX_SeekableStream; class IFX_Pause; class CFX_SeekableStreamProxy; @@ -29,55 +29,55 @@ class CXFA_SimpleParser { int32_t StartParse(const CFX_RetainPtr& pStream, XFA_XDPPACKET ePacketID); int32_t DoParse(IFX_Pause* pPause); - CFDE_XMLNode* ParseXMLData(const CFX_ByteString& wsXML, IFX_Pause* pPause); - void ConstructXFANode(CXFA_Node* pXFANode, CFDE_XMLNode* pXMLNode); + CFX_XMLNode* ParseXMLData(const CFX_ByteString& wsXML, IFX_Pause* pPause); + void ConstructXFANode(CXFA_Node* pXFANode, CFX_XMLNode* pXMLNode); CXFA_Node* GetRootNode() const; - CFDE_XMLDoc* GetXMLDoc() const; + CFX_XMLDoc* GetXMLDoc() const; void CloseParser(); void SetFactory(CXFA_Document* pFactory); private: - CXFA_Node* ParseAsXDPPacket(CFDE_XMLNode* pXMLDocumentNode, + CXFA_Node* ParseAsXDPPacket(CFX_XMLNode* pXMLDocumentNode, XFA_XDPPACKET ePacketID); - CXFA_Node* ParseAsXDPPacket_XDP(CFDE_XMLNode* pXMLDocumentNode, + CXFA_Node* ParseAsXDPPacket_XDP(CFX_XMLNode* pXMLDocumentNode, XFA_XDPPACKET ePacketID); - CXFA_Node* ParseAsXDPPacket_Config(CFDE_XMLNode* pXMLDocumentNode, + CXFA_Node* ParseAsXDPPacket_Config(CFX_XMLNode* pXMLDocumentNode, XFA_XDPPACKET ePacketID); - CXFA_Node* ParseAsXDPPacket_TemplateForm(CFDE_XMLNode* pXMLDocumentNode, + CXFA_Node* ParseAsXDPPacket_TemplateForm(CFX_XMLNode* pXMLDocumentNode, XFA_XDPPACKET ePacketID); - CXFA_Node* ParseAsXDPPacket_Data(CFDE_XMLNode* pXMLDocumentNode, + CXFA_Node* ParseAsXDPPacket_Data(CFX_XMLNode* pXMLDocumentNode, XFA_XDPPACKET ePacketID); CXFA_Node* ParseAsXDPPacket_LocaleConnectionSourceSet( - CFDE_XMLNode* pXMLDocumentNode, + CFX_XMLNode* pXMLDocumentNode, XFA_XDPPACKET ePacketID); - CXFA_Node* ParseAsXDPPacket_Xdc(CFDE_XMLNode* pXMLDocumentNode, + CXFA_Node* ParseAsXDPPacket_Xdc(CFX_XMLNode* pXMLDocumentNode, XFA_XDPPACKET ePacketID); - CXFA_Node* ParseAsXDPPacket_User(CFDE_XMLNode* pXMLDocumentNode, + CXFA_Node* ParseAsXDPPacket_User(CFX_XMLNode* pXMLDocumentNode, XFA_XDPPACKET ePacketID); CXFA_Node* NormalLoader(CXFA_Node* pXFANode, - CFDE_XMLNode* pXMLDoc, + CFX_XMLNode* pXMLDoc, XFA_XDPPACKET ePacketID, bool bUseAttribute); CXFA_Node* DataLoader(CXFA_Node* pXFANode, - CFDE_XMLNode* pXMLDoc, + CFX_XMLNode* pXMLDoc, bool bDoTransform); - CXFA_Node* UserPacketLoader(CXFA_Node* pXFANode, CFDE_XMLNode* pXMLDoc); + CXFA_Node* UserPacketLoader(CXFA_Node* pXFANode, CFX_XMLNode* pXMLDoc); void ParseContentNode(CXFA_Node* pXFANode, - CFDE_XMLNode* pXMLNode, + CFX_XMLNode* pXMLNode, XFA_XDPPACKET ePacketID); void ParseDataValue(CXFA_Node* pXFANode, - CFDE_XMLNode* pXMLNode, + CFX_XMLNode* pXMLNode, XFA_XDPPACKET ePacketID); void ParseDataGroup(CXFA_Node* pXFANode, - CFDE_XMLNode* pXMLNode, + CFX_XMLNode* pXMLNode, XFA_XDPPACKET ePacketID); void ParseInstruction(CXFA_Node* pXFANode, - CFDE_XMLInstruction* pXMLInstruction, + CFX_XMLInstruction* pXMLInstruction, XFA_XDPPACKET ePacketID); - CFDE_XMLParser* m_pXMLParser; - std::unique_ptr m_pXMLDoc; + CFX_XMLParser* m_pXMLParser; + std::unique_ptr m_pXMLDoc; CFX_RetainPtr m_pStream; CFX_RetainPtr m_pFileRead; CXFA_Document* m_pFactory; diff --git a/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp b/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp index 82aec1f00d..f338595605 100644 --- a/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp +++ b/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp @@ -10,9 +10,9 @@ #include #include "core/fxcrt/fx_ext.h" +#include "core/fxcrt/xml/cfx_xmlelement.h" +#include "core/fxcrt/xml/cfx_xmlnode.h" #include "third_party/base/stl_util.h" -#include "xfa/fde/xml/cfde_xmlelement.h" -#include "xfa/fde/xml/cfde_xmlnode.h" #include "xfa/fxfa/parser/cxfa_document.h" #include "xfa/fxfa/parser/cxfa_layoutprocessor.h" #include "xfa/fxfa/parser/cxfa_localemgr.h" @@ -142,8 +142,8 @@ void CreateDataBinding(CXFA_Node* pFormNode, image.GetContentType(wsContentType); image.GetHref(wsHref); } - CFDE_XMLElement* pXMLDataElement = - static_cast(pDataNode->GetXMLMappingNode()); + CFX_XMLElement* pXMLDataElement = + static_cast(pDataNode->GetXMLMappingNode()); ASSERT(pXMLDataElement); pWidgetData->GetFormatDataValue(wsValue, wsFormattedValue); pDataNode->SetAttributeValue(wsValue, wsFormattedValue); @@ -168,10 +168,10 @@ void CreateDataBinding(CXFA_Node* pFormNode, pValue->SetCData(XFA_ATTRIBUTE_Value, text); } } else { - CFDE_XMLNode* pXMLNode = pDataNode->GetXMLMappingNode(); - ASSERT(pXMLNode->GetType() == FDE_XMLNODE_Element); - static_cast(pXMLNode)->SetString(L"xfa:dataNode", - L"dataGroup"); + CFX_XMLNode* pXMLNode = pDataNode->GetXMLMappingNode(); + ASSERT(pXMLNode->GetType() == FX_XMLNODE_Element); + static_cast(pXMLNode)->SetString(L"xfa:dataNode", + L"dataGroup"); } } else if (!wsValue.IsEmpty()) { pWidgetData->GetFormatDataValue(wsValue, wsFormattedValue); @@ -281,8 +281,8 @@ void CreateDataBinding(CXFA_Node* pFormNode, XFA_Element::Image); CXFA_Image image = defValue.GetImage(); if (image) { - CFDE_XMLElement* pXMLDataElement = - static_cast(pDataNode->GetXMLMappingNode()); + CFX_XMLElement* pXMLDataElement = + static_cast(pDataNode->GetXMLMappingNode()); ASSERT(pXMLDataElement); CFX_WideString wsContentType = @@ -1356,7 +1356,7 @@ CXFA_Node* CXFA_Document::GetNotBindNode( void CXFA_Document::DoDataMerge() { CXFA_Node* pDatasetsRoot = ToNode(GetXFAObject(XFA_HASHCODE_Datasets)); if (!pDatasetsRoot) { - CFDE_XMLElement* pDatasetsXMLNode = new CFDE_XMLElement(L"xfa:datasets"); + CFX_XMLElement* pDatasetsXMLNode = new CFX_XMLElement(L"xfa:datasets"); pDatasetsXMLNode->SetString(L"xmlns:xfa", L"http://www.xfa.org/schema/xfa-data/1.0/"); pDatasetsRoot = CreateNode(XFA_XDPPACKET_Datasets, XFA_Element::DataModel); @@ -1392,7 +1392,7 @@ void CXFA_Document::DoDataMerge() { } if (!pDataRoot) { - CFDE_XMLElement* pDataRootXMLNode = new CFDE_XMLElement(L"xfa:data"); + CFX_XMLElement* pDataRootXMLNode = new CFX_XMLElement(L"xfa:data"); pDataRoot = CreateNode(XFA_XDPPACKET_Datasets, XFA_Element::DataGroup); pDataRoot->SetCData(XFA_ATTRIBUTE_Name, L"data"); pDataRoot->SetXMLMappingNode(pDataRootXMLNode); @@ -1441,8 +1441,8 @@ void CXFA_Document::DoDataMerge() { CFX_WideStringC wsFormName = pSubformSetNode->GetCData(XFA_ATTRIBUTE_Name); CFX_WideString wsDataTopLevelName(wsFormName.IsEmpty() ? L"form" : wsFormName); - CFDE_XMLElement* pDataTopLevelXMLNode = - new CFDE_XMLElement(wsDataTopLevelName); + CFX_XMLElement* pDataTopLevelXMLNode = + new CFX_XMLElement(wsDataTopLevelName); pDataTopLevel = CreateNode(XFA_XDPPACKET_Datasets, XFA_Element::DataGroup); pDataTopLevel->SetCData(XFA_ATTRIBUTE_Name, wsDataTopLevelName); diff --git a/xfa/fxfa/parser/xfa_utils.cpp b/xfa/fxfa/parser/xfa_utils.cpp index 2ffba9b2e6..1c5adc75c9 100644 --- a/xfa/fxfa/parser/xfa_utils.cpp +++ b/xfa/fxfa/parser/xfa_utils.cpp @@ -9,10 +9,10 @@ #include #include "core/fxcrt/fx_ext.h" -#include "xfa/fde/xml/cfde_xmlchardata.h" -#include "xfa/fde/xml/cfde_xmlelement.h" -#include "xfa/fde/xml/cfde_xmlnode.h" -#include "xfa/fde/xml/cfde_xmltext.h" +#include "core/fxcrt/xml/cfx_xmlchardata.h" +#include "core/fxcrt/xml/cfx_xmlelement.h" +#include "core/fxcrt/xml/cfx_xmlnode.h" +#include "core/fxcrt/xml/cfx_xmltext.h" #include "xfa/fxfa/parser/cxfa_document.h" #include "xfa/fxfa/parser/cxfa_localemgr.h" #include "xfa/fxfa/parser/cxfa_localevalue.h" @@ -171,14 +171,14 @@ CXFA_LocaleValue XFA_GetLocaleValue(CXFA_WidgetData* pWidgetData) { return CXFA_LocaleValue(iVTType, pWidgetData->GetRawValue(), pWidgetData->GetNode()->GetDocument()->GetLocalMgr()); } -void XFA_GetPlainTextFromRichText(CFDE_XMLNode* pXMLNode, +void XFA_GetPlainTextFromRichText(CFX_XMLNode* pXMLNode, CFX_WideString& wsPlainText) { if (!pXMLNode) { return; } switch (pXMLNode->GetType()) { - case FDE_XMLNODE_Element: { - CFDE_XMLElement* pXMLElement = static_cast(pXMLNode); + case FX_XMLNODE_Element: { + CFX_XMLElement* pXMLElement = static_cast(pXMLNode); CFX_WideString wsTag = pXMLElement->GetLocalTagName(); uint32_t uTag = FX_HashCode_GetW(wsTag.AsStringC(), true); if (uTag == 0x0001f714) { @@ -195,20 +195,18 @@ void XFA_GetPlainTextFromRichText(CFDE_XMLNode* pXMLNode, } break; } - case FDE_XMLNODE_Text: - case FDE_XMLNODE_CharData: { - CFX_WideString wsContent = - static_cast(pXMLNode)->GetText(); + case FX_XMLNODE_Text: + case FX_XMLNODE_CharData: { + CFX_WideString wsContent = static_cast(pXMLNode)->GetText(); wsPlainText += wsContent; break; } default: break; } - for (CFDE_XMLNode* pChildXML = - pXMLNode->GetNodeItem(CFDE_XMLNode::FirstChild); + for (CFX_XMLNode* pChildXML = pXMLNode->GetNodeItem(CFX_XMLNode::FirstChild); pChildXML; - pChildXML = pChildXML->GetNodeItem(CFDE_XMLNode::NextSibling)) { + pChildXML = pChildXML->GetNodeItem(CFX_XMLNode::NextSibling)) { XFA_GetPlainTextFromRichText(pChildXML, wsPlainText); } } diff --git a/xfa/fxfa/parser/xfa_utils.h b/xfa/fxfa/parser/xfa_utils.h index 80f6d096ed..bc05381fc3 100644 --- a/xfa/fxfa/parser/xfa_utils.h +++ b/xfa/fxfa/parser/xfa_utils.h @@ -10,8 +10,8 @@ #include "core/fxcrt/cfx_seekablestreamproxy.h" #include "xfa/fxfa/fxfa_basic.h" -class CFDE_XMLElement; -class CFDE_XMLNode; +class CFX_XMLElement; +class CFX_XMLNode; class CXFA_LocaleValue; class CXFA_Node; class CXFA_WidgetData; @@ -20,7 +20,7 @@ double XFA_GetFractionalScale(uint32_t idx); int XFA_GetMaxFractionalScale(); bool XFA_FDEExtension_ResolveNamespaceQualifier( - CFDE_XMLElement* pNode, + CFX_XMLElement* pNode, const CFX_WideStringC& wsQualifier, CFX_WideString* wsNamespaceURI); @@ -147,8 +147,8 @@ CXFA_LocaleValue XFA_GetLocaleValue(CXFA_WidgetData* pWidgetData); double XFA_ByteStringToDouble(const CFX_ByteStringC& szStringVal); int32_t XFA_MapRotation(int32_t nRotation); -bool XFA_RecognizeRichText(CFDE_XMLElement* pRichTextXMLNode); -void XFA_GetPlainTextFromRichText(CFDE_XMLNode* pXMLNode, +bool XFA_RecognizeRichText(CFX_XMLElement* pRichTextXMLNode); +void XFA_GetPlainTextFromRichText(CFX_XMLNode* pXMLNode, CFX_WideString& wsPlainText); bool XFA_FieldIsMultiListBox(CXFA_Node* pFieldNode); -- cgit v1.2.3