diff options
Diffstat (limited to 'xfa')
-rw-r--r-- | xfa/fde/xml/cfde_xml_parser.cpp (renamed from xfa/fxfa/parser/cxfa_xml_parser.cpp) | 8 | ||||
-rw-r--r-- | xfa/fde/xml/cfde_xml_parser.h (renamed from xfa/fxfa/parser/cxfa_xml_parser.h) | 15 | ||||
-rw-r--r-- | xfa/fde/xml/fde_xml_imp.cpp | 31 | ||||
-rw-r--r-- | xfa/fde/xml/fde_xml_imp.h | 13 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_simple_parser.cpp | 6 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_simple_parser.h | 4 |
6 files changed, 21 insertions, 56 deletions
diff --git a/xfa/fxfa/parser/cxfa_xml_parser.cpp b/xfa/fde/xml/cfde_xml_parser.cpp index 72564d9fe5..840c34a5c4 100644 --- a/xfa/fxfa/parser/cxfa_xml_parser.cpp +++ b/xfa/fde/xml/cfde_xml_parser.cpp @@ -4,11 +4,11 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#include "xfa/fxfa/parser/cxfa_xml_parser.h" +#include "xfa/fde/xml/cfde_xml_parser.h" #include "third_party/base/ptr_util.h" -CXFA_XMLParser::CXFA_XMLParser(CFDE_XMLNode* pParent, +CFDE_XMLParser::CFDE_XMLParser(CFDE_XMLNode* pParent, const CFX_RetainPtr<IFGAS_Stream>& pStream) : m_nElementStart(0), m_dwCheckStatus(0), @@ -23,9 +23,9 @@ CXFA_XMLParser::CXFA_XMLParser(CFDE_XMLNode* pParent, m_pParser->Init(m_pStream, 32 * 1024, 1024 * 1024); } -CXFA_XMLParser::~CXFA_XMLParser() {} +CFDE_XMLParser::~CFDE_XMLParser() {} -int32_t CXFA_XMLParser::DoParser(IFX_Pause* pPause) { +int32_t CFDE_XMLParser::DoParser(IFX_Pause* pPause) { if (m_syntaxParserResult == FDE_XmlSyntaxResult::Error) return -1; if (m_syntaxParserResult == FDE_XmlSyntaxResult::EndOfString) diff --git a/xfa/fxfa/parser/cxfa_xml_parser.h b/xfa/fde/xml/cfde_xml_parser.h index a631df02dc..cd8ccbe389 100644 --- a/xfa/fxfa/parser/cxfa_xml_parser.h +++ b/xfa/fde/xml/cfde_xml_parser.h @@ -4,8 +4,8 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#ifndef XFA_FXFA_PARSER_CXFA_XML_PARSER_H_ -#define XFA_FXFA_PARSER_CXFA_XML_PARSER_H_ +#ifndef XFA_FDE_XML_CFDE_XML_PARSER_H_ +#define XFA_FDE_XML_CFDE_XML_PARSER_H_ #include <memory> #include <stack> @@ -15,14 +15,13 @@ class IFGAS_Stream; class IFX_Pause; -class CXFA_XMLParser : public IFDE_XMLParser { +class CFDE_XMLParser { public: - CXFA_XMLParser(CFDE_XMLNode* pParent, + CFDE_XMLParser(CFDE_XMLNode* pParent, const CFX_RetainPtr<IFGAS_Stream>& pStream); - ~CXFA_XMLParser() override; + ~CFDE_XMLParser(); - // IFDE_XMLParser - int32_t DoParser(IFX_Pause* pPause) override; + int32_t DoParser(IFX_Pause* pPause); FX_FILESIZE m_nStart[2]; size_t m_nSize[2]; @@ -41,4 +40,4 @@ class CXFA_XMLParser : public IFDE_XMLParser { FDE_XmlSyntaxResult m_syntaxParserResult; }; -#endif // XFA_FXFA_PARSER_CXFA_XML_PARSER_H_ +#endif // XFA_FDE_XML_CFDE_XML_PARSER_H_ diff --git a/xfa/fde/xml/fde_xml_imp.cpp b/xfa/fde/xml/fde_xml_imp.cpp index ade8fc0557..68a4978209 100644 --- a/xfa/fde/xml/fde_xml_imp.cpp +++ b/xfa/fde/xml/fde_xml_imp.cpp @@ -13,6 +13,7 @@ #include "core/fxcrt/fx_safe_types.h" #include "third_party/base/ptr_util.h" #include "third_party/base/stl_util.h" +#include "xfa/fde/xml/cfde_xml_parser.h" #include "xfa/fgas/crt/fgas_codepage.h" namespace { @@ -917,7 +918,7 @@ CFDE_XMLDoc::CFDE_XMLDoc() CFDE_XMLDoc::~CFDE_XMLDoc() {} -bool CFDE_XMLDoc::LoadXML(std::unique_ptr<IFDE_XMLParser> pXMLParser) { +bool CFDE_XMLDoc::LoadXML(std::unique_ptr<CFDE_XMLParser> pXMLParser) { if (!pXMLParser) return false; @@ -1052,34 +1053,6 @@ void CFDE_XMLDoc::SaveXMLNode(const CFX_RetainPtr<IFGAS_Stream>& pXMLStream, } } -void CFDE_XMLDoc::SaveXML(CFX_RetainPtr<IFGAS_Stream>& pXMLStream, - bool bSaveBOM) { - if (!pXMLStream || pXMLStream == m_pStream) { - m_pStream->Seek(FX_STREAMSEEK_Begin, 0); - pXMLStream = m_pStream; - } - ASSERT((pXMLStream->GetAccessModes() & FX_STREAMACCESS_Text) != 0); - ASSERT((pXMLStream->GetAccessModes() & FX_STREAMACCESS_Write) != 0); - uint16_t wCodePage = pXMLStream->GetCodePage(); - if (wCodePage != FX_CODEPAGE_UTF16LE && wCodePage != FX_CODEPAGE_UTF16BE && - wCodePage != FX_CODEPAGE_UTF8) { - wCodePage = FX_CODEPAGE_UTF8; - pXMLStream->SetCodePage(wCodePage); - } - if (bSaveBOM) { - pXMLStream->WriteString(L"\xFEFF", 1); - } - CFDE_XMLNode* pNode = m_pRoot->m_pChild; - while (pNode) { - SaveXMLNode(pXMLStream, static_cast<CFDE_XMLNode*>(pNode)); - pNode = pNode->m_pNext; - } - if (pXMLStream == m_pStream) { - int32_t iPos = pXMLStream->GetPosition(); - pXMLStream->SetLength(iPos); - } -} - CFDE_BlockBuffer::CFDE_BlockBuffer(int32_t iAllocStep) : m_iDataLength(0), m_iBufferSize(0), diff --git a/xfa/fde/xml/fde_xml_imp.h b/xfa/fde/xml/fde_xml_imp.h index 09cdcbacdf..bd88da06cc 100644 --- a/xfa/fde/xml/fde_xml_imp.h +++ b/xfa/fde/xml/fde_xml_imp.h @@ -22,8 +22,8 @@ class CFDE_XMLElement; class CFDE_XMLText; class CFDE_XMLDoc; class CFDE_XMLDOMParser; +class CFDE_XMLParser; class CFDE_XMLSyntaxParser; -class IFDE_XMLParser; class CFDE_XMLNode { public: @@ -191,27 +191,20 @@ class CFDE_XMLDoc { CFDE_XMLDoc(); ~CFDE_XMLDoc(); - bool LoadXML(std::unique_ptr<IFDE_XMLParser> pXMLParser); + bool LoadXML(std::unique_ptr<CFDE_XMLParser> pXMLParser); int32_t DoLoad(IFX_Pause* pPause = nullptr); void CloseXML(); CFDE_XMLNode* GetRoot() const { return m_pRoot.get(); } - void SaveXML(CFX_RetainPtr<IFGAS_Stream>& pXMLStream, bool bSaveBOM = true); void SaveXMLNode(const CFX_RetainPtr<IFGAS_Stream>& pXMLStream, CFDE_XMLNode* pNode); private: int32_t m_iStatus; std::unique_ptr<CFDE_XMLNode> m_pRoot; - std::unique_ptr<IFDE_XMLParser> m_pXMLParser; + std::unique_ptr<CFDE_XMLParser> m_pXMLParser; CFX_RetainPtr<IFGAS_Stream> m_pStream; }; -class IFDE_XMLParser { - public: - virtual ~IFDE_XMLParser() {} - virtual int32_t DoParser(IFX_Pause* pPause) = 0; -}; - class CFDE_BlockBuffer { public: explicit CFDE_BlockBuffer(int32_t iAllocStep = 1024 * 1024); diff --git a/xfa/fxfa/parser/cxfa_simple_parser.cpp b/xfa/fxfa/parser/cxfa_simple_parser.cpp index 574ef3a458..9204660388 100644 --- a/xfa/fxfa/parser/cxfa_simple_parser.cpp +++ b/xfa/fxfa/parser/cxfa_simple_parser.cpp @@ -11,12 +11,12 @@ #include "core/fxcrt/cfx_checksumcontext.h" #include "core/fxcrt/fx_ext.h" #include "third_party/base/ptr_util.h" +#include "xfa/fde/xml/cfde_xml_parser.h" #include "xfa/fgas/crt/fgas_codepage.h" #include "xfa/fxfa/fxfa.h" #include "xfa/fxfa/parser/cxfa_document.h" #include "xfa/fxfa/parser/cxfa_node.h" #include "xfa/fxfa/parser/cxfa_widetextread.h" -#include "xfa/fxfa/parser/cxfa_xml_parser.h" #include "xfa/fxfa/parser/xfa_basic_data.h" #include "xfa/fxfa/parser/xfa_utils.h" @@ -298,7 +298,7 @@ int32_t CXFA_SimpleParser::StartParse( } m_pXMLDoc = pdfium::MakeUnique<CFDE_XMLDoc>(); auto pNewParser = - pdfium::MakeUnique<CXFA_XMLParser>(m_pXMLDoc->GetRoot(), m_pStream); + pdfium::MakeUnique<CFDE_XMLParser>(m_pXMLDoc->GetRoot(), m_pStream); m_pXMLParser = pNewParser.get(); if (!m_pXMLDoc->LoadXML(std::move(pNewParser))) return XFA_PARSESTATUS_StatusErr; @@ -334,7 +334,7 @@ int32_t CXFA_SimpleParser::ParseXMLData(const CFX_WideString& wsXML, m_pXMLDoc = pdfium::MakeUnique<CFDE_XMLDoc>(); auto pStream = pdfium::MakeRetain<CXFA_WideTextRead>(wsXML); auto pParser = - pdfium::MakeUnique<CXFA_XMLParser>(m_pXMLDoc->GetRoot(), pStream); + pdfium::MakeUnique<CFDE_XMLParser>(m_pXMLDoc->GetRoot(), pStream); pParser->m_dwCheckStatus = 0x03; if (!m_pXMLDoc->LoadXML(std::move(pParser))) return XFA_PARSESTATUS_StatusErr; diff --git a/xfa/fxfa/parser/cxfa_simple_parser.h b/xfa/fxfa/parser/cxfa_simple_parser.h index 5f61ad7d28..350104161c 100644 --- a/xfa/fxfa/parser/cxfa_simple_parser.h +++ b/xfa/fxfa/parser/cxfa_simple_parser.h @@ -14,7 +14,7 @@ class CXFA_Document; class CXFA_Node; -class CXFA_XMLParser; +class CFDE_XMLParser; class IFX_SeekableReadStream; class IFX_Pause; class IFGAS_Stream; @@ -76,7 +76,7 @@ class CXFA_SimpleParser { CFDE_XMLInstruction* pXMLInstruction, XFA_XDPPACKET ePacketID); - CXFA_XMLParser* m_pXMLParser; + CFDE_XMLParser* m_pXMLParser; std::unique_ptr<CFDE_XMLDoc> m_pXMLDoc; CFX_RetainPtr<IFGAS_Stream> m_pStream; CFX_RetainPtr<IFX_SeekableReadStream> m_pFileRead; |