diff options
Diffstat (limited to 'xfa/fxfa/parser')
-rw-r--r-- | xfa/fxfa/parser/cxfa_dataexporter.cpp | 7 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_document.cpp | 16 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_document.h | 10 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_document_parser.cpp | 6 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_document_parser.h | 1 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_node_unittest.cpp | 17 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_simple_parser.cpp | 4 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_simple_parser.h | 1 |
8 files changed, 12 insertions, 50 deletions
diff --git a/xfa/fxfa/parser/cxfa_dataexporter.cpp b/xfa/fxfa/parser/cxfa_dataexporter.cpp index 23fc17883a..b254ce6cad 100644 --- a/xfa/fxfa/parser/cxfa_dataexporter.cpp +++ b/xfa/fxfa/parser/cxfa_dataexporter.cpp @@ -44,7 +44,6 @@ bool CXFA_DataExporter::Export( CXFA_Node* pNode, uint32_t dwFlag, const char* pChecksum) { - CFX_XMLDoc* pXMLDoc = m_pDocument->GetXMLDoc(); if (pNode->IsModelNode()) { switch (pNode->GetPacketType()) { case XFA_PacketType::Xdp: { @@ -66,7 +65,7 @@ bool CXFA_DataExporter::Export( CXFA_Node* pDataNode = pNode->GetFirstChild(); ASSERT(pDataNode); XFA_DataExporter_DealWithDataGroupNode(pDataNode); - pXMLDoc->SaveXMLNode(pStream, pElement); + pElement->SaveXMLNode(pStream); break; } case XFA_PacketType::Form: { @@ -80,7 +79,7 @@ bool CXFA_DataExporter::Export( if (!pElement || pElement->GetType() != FX_XMLNODE_Element) return false; - pXMLDoc->SaveXMLNode(pStream, pElement); + pElement->SaveXMLNode(pStream); break; } } @@ -103,7 +102,7 @@ bool CXFA_DataExporter::Export( XFA_DataExporter_DealWithDataGroupNode(pExportNode); pElement->SetString(L"xmlns:xfa", L"http://www.xfa.org/schema/xfa-data/1.0/"); - pXMLDoc->SaveXMLNode(pStream, pElement); + pElement->SaveXMLNode(pStream); pElement->RemoveAttribute(L"xmlns:xfa"); return true; diff --git a/xfa/fxfa/parser/cxfa_document.cpp b/xfa/fxfa/parser/cxfa_document.cpp index a21d3f974c..2a9d80e0cd 100644 --- a/xfa/fxfa/parser/cxfa_document.cpp +++ b/xfa/fxfa/parser/cxfa_document.cpp @@ -88,14 +88,12 @@ void MergeNode(CXFA_Document* pDocument, } // namespace -CXFA_Document::CXFA_Document(CXFA_DocumentParser* pParser) +CXFA_Document::CXFA_Document(CXFA_FFNotify* notify) : CXFA_NodeOwner(), - m_pParser(pParser), + notify_(notify), m_pRootNode(nullptr), m_eCurVersionMode(XFA_VERSION_DEFAULT), - m_dwDocFlags(0) { - ASSERT(m_pParser); -} + m_dwDocFlags(0) {} CXFA_Document::~CXFA_Document() { // Remove all the bindings before freeing the node as the ownership is wonky. @@ -125,14 +123,6 @@ void CXFA_Document::ClearLayoutData() { m_pScriptSignature.reset(); } -CFX_XMLDoc* CXFA_Document::GetXMLDoc() const { - return m_pParser->GetXMLDoc(); -} - -CXFA_FFNotify* CXFA_Document::GetNotify() const { - return m_pParser->GetNotify(); -} - CXFA_Object* CXFA_Document::GetXFAObject(XFA_HashCode dwNodeNameHash) { switch (dwNodeNameHash) { case XFA_HASHCODE_Data: { diff --git a/xfa/fxfa/parser/cxfa_document.h b/xfa/fxfa/parser/cxfa_document.h index 4d1c417c5b..9dc8e52ab6 100644 --- a/xfa/fxfa/parser/cxfa_document.h +++ b/xfa/fxfa/parser/cxfa_document.h @@ -50,7 +50,6 @@ class CScript_LayoutPseudoModel; class CScript_LogPseudoModel; class CScript_SignaturePseudoModel; class CXFA_ContainerLayoutItem; -class CXFA_DocumentParser; class CXFA_FFNotify; class CXFA_LayoutItem; class CXFA_LayoutProcessor; @@ -59,16 +58,13 @@ class CXFA_Object; class CXFA_Document : public CXFA_NodeOwner { public: - explicit CXFA_Document(CXFA_DocumentParser* pParser); + explicit CXFA_Document(CXFA_FFNotify* notify); ~CXFA_Document() override; - virtual CXFA_FFNotify* GetNotify() const; - CFXJSE_Engine* InitScriptContext(CFXJS_Engine* fxjs_engine); CXFA_Node* GetRoot() const { return m_pRootNode; } - CFX_XMLDoc* GetXMLDoc() const; - + CXFA_FFNotify* GetNotify() const { return notify_.Get(); } CXFA_LocaleMgr* GetLocalMgr(); CXFA_Object* GetXFAObject(XFA_HashCode wsNodeNameHash); CXFA_Node* GetNodeByID(CXFA_Node* pRoot, const WideStringView& wsID); @@ -105,7 +101,7 @@ class CXFA_Document : public CXFA_NodeOwner { std::vector<CXFA_Node*> m_pPendingPageSet; private: - CXFA_DocumentParser* m_pParser; + UnownedPtr<CXFA_FFNotify> notify_; CXFA_Node* m_pRootNode; std::unique_ptr<CFXJSE_Engine> m_pScriptContext; std::unique_ptr<CXFA_LayoutProcessor> m_pLayoutProcessor; diff --git a/xfa/fxfa/parser/cxfa_document_parser.cpp b/xfa/fxfa/parser/cxfa_document_parser.cpp index 6446ea31ce..652694e214 100644 --- a/xfa/fxfa/parser/cxfa_document_parser.cpp +++ b/xfa/fxfa/parser/cxfa_document_parser.cpp @@ -25,7 +25,7 @@ int32_t CXFA_DocumentParser::StartParse( int32_t nRetStatus = m_nodeParser.StartParse(pStream, ePacketID); if (nRetStatus == XFA_PARSESTATUS_Ready) { - m_pDocument = pdfium::MakeUnique<CXFA_Document>(this); + m_pDocument = pdfium::MakeUnique<CXFA_Document>(GetNotify()); m_nodeParser.SetFactory(m_pDocument.get()); } return nRetStatus; @@ -40,10 +40,6 @@ int32_t CXFA_DocumentParser::DoParse() { return nRetStatus; } -CFX_XMLDoc* CXFA_DocumentParser::GetXMLDoc() const { - return m_nodeParser.GetXMLDoc(); -} - CXFA_FFNotify* CXFA_DocumentParser::GetNotify() const { return m_pNotify.Get(); } diff --git a/xfa/fxfa/parser/cxfa_document_parser.h b/xfa/fxfa/parser/cxfa_document_parser.h index 35d71603cb..c245843c0f 100644 --- a/xfa/fxfa/parser/cxfa_document_parser.h +++ b/xfa/fxfa/parser/cxfa_document_parser.h @@ -26,7 +26,6 @@ class CXFA_DocumentParser { XFA_PacketType ePacketID); int32_t DoParse(); - CFX_XMLDoc* GetXMLDoc() const; CXFA_FFNotify* GetNotify() const; CXFA_Document* GetDocument() const; diff --git a/xfa/fxfa/parser/cxfa_node_unittest.cpp b/xfa/fxfa/parser/cxfa_node_unittest.cpp index 7c35e5d989..81e21890df 100644 --- a/xfa/fxfa/parser/cxfa_node_unittest.cpp +++ b/xfa/fxfa/parser/cxfa_node_unittest.cpp @@ -7,19 +7,9 @@ #include "testing/test_support.h" #include "third_party/base/ptr_util.h" #include "xfa/fxfa/parser/cxfa_document.h" -#include "xfa/fxfa/parser/cxfa_document_parser.h" namespace { -class CXFA_DocumentMock : public CXFA_Document { - public: - explicit CXFA_DocumentMock(CXFA_DocumentParser* parser) - : CXFA_Document(parser) {} - ~CXFA_DocumentMock() override = default; - - CXFA_FFNotify* GetNotify() const override { return nullptr; } -}; - class TestNode : public CXFA_Node { public: explicit TestNode(CXFA_Document* doc) @@ -40,23 +30,20 @@ class TestNode : public CXFA_Node { class CXFANodeTest : public testing::Test { public: void SetUp() override { - doc_parser_ = pdfium::MakeUnique<CXFA_DocumentParser>(nullptr); - doc_ = pdfium::MakeUnique<CXFA_DocumentMock>(doc_parser_.get()); + doc_ = pdfium::MakeUnique<CXFA_Document>(nullptr); node_ = pdfium::MakeUnique<TestNode>(doc_.get()); } void TearDown() override { node_ = nullptr; doc_ = nullptr; - doc_parser_ = nullptr; } CXFA_Document* GetDoc() const { return doc_.get(); } CXFA_Node* GetNode() const { return node_.get(); } private: - std::unique_ptr<CXFA_DocumentParser> doc_parser_; - std::unique_ptr<CXFA_DocumentMock> doc_; + std::unique_ptr<CXFA_Document> doc_; std::unique_ptr<TestNode> node_; }; diff --git a/xfa/fxfa/parser/cxfa_simple_parser.cpp b/xfa/fxfa/parser/cxfa_simple_parser.cpp index 0bce147223..f21506d557 100644 --- a/xfa/fxfa/parser/cxfa_simple_parser.cpp +++ b/xfa/fxfa/parser/cxfa_simple_parser.cpp @@ -468,10 +468,6 @@ CXFA_Node* CXFA_SimpleParser::GetRootNode() const { return m_pRootNode; } -CFX_XMLDoc* CXFA_SimpleParser::GetXMLDoc() const { - return m_pXMLDoc.get(); -} - CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket(CFX_XMLNode* pXMLDocumentNode, XFA_PacketType ePacketID) { switch (ePacketID) { diff --git a/xfa/fxfa/parser/cxfa_simple_parser.h b/xfa/fxfa/parser/cxfa_simple_parser.h index 7a20de384a..c1015469c9 100644 --- a/xfa/fxfa/parser/cxfa_simple_parser.h +++ b/xfa/fxfa/parser/cxfa_simple_parser.h @@ -32,7 +32,6 @@ class CXFA_SimpleParser { CFX_XMLNode* ParseXMLData(const ByteString& wsXML); void ConstructXFANode(CXFA_Node* pXFANode, CFX_XMLNode* pXMLNode); CXFA_Node* GetRootNode() const; - CFX_XMLDoc* GetXMLDoc() const; void CloseParser(); // Called later for the ctor with no parameters. |