Add CXFA_Node::GetXMLDocument() helper.
Change-Id: Id33c4f83fd517b76612ded26cf998e7600d6ff11
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/55195
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp
index 3e4d831..a0a1e53 100644
--- a/xfa/fxfa/parser/cxfa_node.cpp
+++ b/xfa/fxfa/parser/cxfa_node.cpp
@@ -976,19 +976,12 @@
WideString wsName = JSObject()
->TryAttribute(XFA_Attribute::Name, false)
.value_or(WideString());
- auto* pCloneXMLElement = GetDocument()
- ->GetNotify()
- ->GetHDOC()
- ->GetXMLDocument()
- ->CreateNode<CFX_XMLElement>(wsName);
+ auto* pCloneXMLElement =
+ GetXMLDocument()->CreateNode<CFX_XMLElement>(wsName);
WideString wsValue = JSObject()->GetCData(XFA_Attribute::Value);
if (!wsValue.IsEmpty()) {
- auto* text = GetDocument()
- ->GetNotify()
- ->GetHDOC()
- ->GetXMLDocument()
- ->CreateNode<CFX_XMLText>(wsValue);
+ auto* text = GetXMLDocument()->CreateNode<CFX_XMLText>(wsValue);
pCloneXMLElement->AppendLastChild(text);
}
@@ -996,8 +989,7 @@
pClone->JSObject()->SetEnum(XFA_Attribute::Contains,
XFA_AttributeValue::Unknown, false);
} else {
- pCloneXML = xml_node_->Clone(
- GetDocument()->GetNotify()->GetHDOC()->GetXMLDocument());
+ pCloneXML = xml_node_->Clone(GetXMLDocument());
}
pClone->SetXMLMappingNode(pCloneXML);
}
@@ -1554,18 +1546,10 @@
->TryAttribute(XFA_Attribute::Name, false)
.value_or(WideString());
- auto* pNewXMLElement = GetDocument()
- ->GetNotify()
- ->GetHDOC()
- ->GetXMLDocument()
- ->CreateNode<CFX_XMLElement>(wsName);
+ auto* pNewXMLElement = GetXMLDocument()->CreateNode<CFX_XMLElement>(wsName);
WideString wsValue = JSObject()->GetCData(XFA_Attribute::Value);
if (!wsValue.IsEmpty()) {
- auto* text = GetDocument()
- ->GetNotify()
- ->GetHDOC()
- ->GetXMLDocument()
- ->CreateNode<CFX_XMLText>(wsValue);
+ auto* text = GetXMLDocument()->CreateNode<CFX_XMLText>(wsValue);
pNewXMLElement->AppendLastChild(text);
}
pNode->xml_node_ = pNewXMLElement;
@@ -1756,12 +1740,8 @@
CFX_XMLNode* CXFA_Node::CreateXMLMappingNode() {
if (!xml_node_) {
- xml_node_ = GetDocument()
- ->GetNotify()
- ->GetHDOC()
- ->GetXMLDocument()
- ->CreateNode<CFX_XMLElement>(
- JSObject()->GetCData(XFA_Attribute::Name));
+ xml_node_ = GetXMLDocument()->CreateNode<CFX_XMLElement>(
+ JSObject()->GetCData(XFA_Attribute::Name));
}
return xml_node_.Get();
}
@@ -5053,11 +5033,7 @@
if (bDeleteChildren)
elem->RemoveAllChildren();
- auto* text = GetDocument()
- ->GetNotify()
- ->GetHDOC()
- ->GetXMLDocument()
- ->CreateNode<CFX_XMLText>(value);
+ auto* text = GetXMLDocument()->CreateNode<CFX_XMLText>(value);
elem->AppendLastChild(text);
break;
}
@@ -5082,6 +5058,10 @@
return nullptr;
}
+CFX_XMLDocument* CXFA_Node::GetXMLDocument() const {
+ return GetDocument()->GetNotify()->GetHDOC()->GetXMLDocument();
+}
+
// static
std::unique_ptr<CXFA_Node> CXFA_Node::Create(CXFA_Document* doc,
XFA_Element element,
diff --git a/xfa/fxfa/parser/cxfa_node.h b/xfa/fxfa/parser/cxfa_node.h
index 4639e16..1f70d60 100644
--- a/xfa/fxfa/parser/cxfa_node.h
+++ b/xfa/fxfa/parser/cxfa_node.h
@@ -21,6 +21,7 @@
class CFGAS_GEFont;
class CFX_DIBitmap;
+class CFX_XMLDocument;
class CFX_XMLNode;
class CXFA_Bind;
class CXFA_Border;
@@ -479,6 +480,8 @@
CXFA_Event* event,
CXFA_EventParam* pEventParam);
+ CFX_XMLDocument* GetXMLDocument() const;
+
pdfium::span<const PropertyData> const m_Properties;
pdfium::span<const AttributeData> const m_Attributes;
const uint32_t m_ValidPackets;