summaryrefslogtreecommitdiff
path: root/xfa/fxfa/parser/cxfa_node.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'xfa/fxfa/parser/cxfa_node.cpp')
-rw-r--r--xfa/fxfa/parser/cxfa_node.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp
index b2535aee8c..3823d2eae0 100644
--- a/xfa/fxfa/parser/cxfa_node.cpp
+++ b/xfa/fxfa/parser/cxfa_node.cpp
@@ -4656,3 +4656,38 @@ bool CXFA_Node::PresenceRequiresSpace() const {
return ePresence == XFA_AttributeEnum::Visible ||
ePresence == XFA_AttributeEnum::Invisible;
}
+
+void CXFA_Node::SetToXML(const WideString& value) {
+ auto* elem = static_cast<CFX_XMLElement*>(GetXMLMappingNode());
+ FX_XMLNODETYPE eXMLType = elem->GetType();
+ switch (eXMLType) {
+ case FX_XMLNODE_Element: {
+ if (IsAttributeInXML()) {
+ elem->SetString(JSObject()->GetCData(XFA_Attribute::QualifiedName),
+ value);
+ return;
+ }
+
+ bool bDeleteChildren = true;
+ if (GetPacketType() == XFA_PacketType::Datasets) {
+ for (CXFA_Node* pChildDataNode = GetFirstChild(); pChildDataNode;
+ pChildDataNode = pChildDataNode->GetNextSibling()) {
+ if (!pChildDataNode->GetBindItems()->empty()) {
+ bDeleteChildren = false;
+ break;
+ }
+ }
+ }
+ if (bDeleteChildren)
+ elem->DeleteChildren();
+
+ elem->SetTextData(value);
+ break;
+ }
+ case FX_XMLNODE_Text:
+ static_cast<CFX_XMLText*>(GetXMLMappingNode())->SetText(value);
+ break;
+ default:
+ NOTREACHED();
+ }
+}