From 8b0cf76f00c6e89e8bb7bf4bcf2189b27baac31c Mon Sep 17 00:00:00 2001 From: dan sinclair Date: Mon, 16 Apr 2018 21:24:57 +0000 Subject: Merge CFX_XMLElement and CFX_XMLAttributeNode CFX_XMLElement is the only subclass of CFX_XMLAttributeNode. This CL merges the two classes together. The {Set|Get}String method has been renamed to {Set|Get}Attribute to make it clearer what you're retrieving. Change-Id: I158c961d4d8c5f563d937a3e7a35321a33622562 Reviewed-on: https://pdfium-review.googlesource.com/30710 Commit-Queue: dsinclair Reviewed-by: Henrique Nakashima --- BUILD.gn | 2 - core/fpdfdoc/cpdf_metadata.cpp | 8 +-- core/fxcrt/xml/cfx_xmlattributenode.cpp | 34 ------------- core/fxcrt/xml/cfx_xmlattributenode.h | 44 ----------------- core/fxcrt/xml/cfx_xmlelement.cpp | 85 +++++++++++++++++++++----------- core/fxcrt/xml/cfx_xmlelement.h | 22 ++++++++- core/fxcrt/xml/cfx_xmlinstruction.h | 2 +- core/fxcrt/xml/cfx_xmlnode.cpp | 10 ---- core/fxcrt/xml/cfx_xmlnode.h | 1 - core/fxcrt/xml/cfx_xmlparser.cpp | 4 +- fxjs/xfa/cjx_object.cpp | 12 ++--- fxjs/xfa/cjx_packet.cpp | 4 +- xfa/fxfa/cxfa_textlayout.cpp | 2 +- xfa/fxfa/cxfa_textparser.cpp | 8 +-- xfa/fxfa/parser/cxfa_dataexporter.cpp | 3 +- xfa/fxfa/parser/cxfa_document.cpp | 14 +++--- xfa/fxfa/parser/cxfa_document_parser.cpp | 2 +- xfa/fxfa/parser/cxfa_node.cpp | 6 +-- xfa/fxfa/parser/cxfa_xmllocale.cpp | 6 +-- xfa/fxfa/parser/xfa_utils.cpp | 6 +-- 20 files changed, 113 insertions(+), 162 deletions(-) delete mode 100644 core/fxcrt/xml/cfx_xmlattributenode.cpp delete mode 100644 core/fxcrt/xml/cfx_xmlattributenode.h diff --git a/BUILD.gn b/BUILD.gn index 9f93d7232f..5d69b8d5bd 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -875,8 +875,6 @@ jumbo_static_library("fxcrt") { "core/fxcrt/weak_ptr.h", "core/fxcrt/widestring.cpp", "core/fxcrt/widestring.h", - "core/fxcrt/xml/cfx_xmlattributenode.cpp", - "core/fxcrt/xml/cfx_xmlattributenode.h", "core/fxcrt/xml/cfx_xmlchardata.cpp", "core/fxcrt/xml/cfx_xmlchardata.h", "core/fxcrt/xml/cfx_xmlelement.cpp", diff --git a/core/fpdfdoc/cpdf_metadata.cpp b/core/fpdfdoc/cpdf_metadata.cpp index 972569a25d..56f8c64c0e 100644 --- a/core/fpdfdoc/cpdf_metadata.cpp +++ b/core/fpdfdoc/cpdf_metadata.cpp @@ -16,12 +16,8 @@ namespace { void CheckForSharedFormInternal(CFX_XMLElement* element, std::vector* unsupported) { - for (const auto& pair : element->GetAttributes()) { - if (pair.first != L"xmlns:adhocwf" || - pair.second != L"http://ns.adobe.com/AcrobatAdhocWorkflow/1.0/") { - continue; - } - + WideString attr = element->GetAttribute(L"xmlns:adhocwf"); + if (attr == L"http://ns.adobe.com/AcrobatAdhocWorkflow/1.0/") { for (const auto* child = element->GetFirstChild(); child; child = child->GetNextSibling()) { if (child->GetType() != FX_XMLNODE_Element) diff --git a/core/fxcrt/xml/cfx_xmlattributenode.cpp b/core/fxcrt/xml/cfx_xmlattributenode.cpp deleted file mode 100644 index 6104747793..0000000000 --- a/core/fxcrt/xml/cfx_xmlattributenode.cpp +++ /dev/null @@ -1,34 +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 "core/fxcrt/xml/cfx_xmlattributenode.h" - -#include "core/fxcrt/fx_extension.h" - -CFX_XMLAttributeNode::CFX_XMLAttributeNode(const WideString& name) - : CFX_XMLNode(), name_(name) { - ASSERT(name_.GetLength() > 0); -} - -CFX_XMLAttributeNode::~CFX_XMLAttributeNode() {} - -bool CFX_XMLAttributeNode::HasAttribute(const WideString& name) const { - return attrs_.find(name) != attrs_.end(); -} - -WideString CFX_XMLAttributeNode::GetString(const WideString& name) const { - auto it = attrs_.find(name); - return it != attrs_.end() ? it->second : WideString(); -} - -void CFX_XMLAttributeNode::SetString(const WideString& name, - const WideString& value) { - attrs_[name] = value; -} - -void CFX_XMLAttributeNode::RemoveAttribute(const WideString& name) { - attrs_.erase(name); -} diff --git a/core/fxcrt/xml/cfx_xmlattributenode.h b/core/fxcrt/xml/cfx_xmlattributenode.h deleted file mode 100644 index 1ac9b84db2..0000000000 --- a/core/fxcrt/xml/cfx_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 CORE_FXCRT_XML_CFX_XMLATTRIBUTENODE_H_ -#define CORE_FXCRT_XML_CFX_XMLATTRIBUTENODE_H_ - -#include -#include - -#include "core/fxcrt/fx_string.h" -#include "core/fxcrt/xml/cfx_xmlnode.h" - -class CFX_XMLAttributeNode : public CFX_XMLNode { - public: - explicit CFX_XMLAttributeNode(const WideString& name); - ~CFX_XMLAttributeNode() override; - - // CFX_XMLNode - FX_XMLNODETYPE GetType() const override = 0; - std::unique_ptr Clone() override = 0; - - WideString GetName() const { return name_; } - const std::map& GetAttributes() const { - return attrs_; - } - void SetAttributes(const std::map& attrs) { - attrs_ = attrs; - } - bool HasAttribute(const WideString& name) const; - - void SetString(const WideString& name, const WideString& value); - WideString GetString(const WideString& name) const; - - void RemoveAttribute(const WideString& name); - - private: - WideString name_; - std::map attrs_; -}; - -#endif // CORE_FXCRT_XML_CFX_XMLATTRIBUTENODE_H_ diff --git a/core/fxcrt/xml/cfx_xmlelement.cpp b/core/fxcrt/xml/cfx_xmlelement.cpp index 27d136305b..42588c6393 100644 --- a/core/fxcrt/xml/cfx_xmlelement.cpp +++ b/core/fxcrt/xml/cfx_xmlelement.cpp @@ -16,17 +16,19 @@ #include "third_party/base/stl_util.h" CFX_XMLElement::CFX_XMLElement(const WideString& wsTag) - : CFX_XMLAttributeNode(wsTag) {} + : CFX_XMLNode(), name_(wsTag) { + ASSERT(!name_.IsEmpty()); +} -CFX_XMLElement::~CFX_XMLElement() {} +CFX_XMLElement::~CFX_XMLElement() = default; FX_XMLNODETYPE CFX_XMLElement::GetType() const { return FX_XMLNODE_Element; } std::unique_ptr CFX_XMLElement::Clone() { - auto pClone = pdfium::MakeUnique(GetName()); - pClone->SetAttributes(GetAttributes()); + auto pClone = pdfium::MakeUnique(name_); + pClone->attrs_ = attrs_; WideString wsText; for (CFX_XMLNode* pChild = GetFirstChild(); pChild; @@ -39,15 +41,14 @@ std::unique_ptr CFX_XMLElement::Clone() { } WideString CFX_XMLElement::GetLocalTagName() const { - auto pos = GetName().Find(L':'); - return pos.has_value() - ? GetName().Right(GetName().GetLength() - pos.value() - 1) - : GetName(); + auto pos = name_.Find(L':'); + return pos.has_value() ? name_.Right(name_.GetLength() - pos.value() - 1) + : name_; } WideString CFX_XMLElement::GetNamespacePrefix() const { - auto pos = GetName().Find(L':'); - return pos.has_value() ? GetName().Left(pos.value()) : WideString(); + auto pos = name_.Find(L':'); + return pos.has_value() ? name_.Left(pos.value()) : WideString(); } WideString CFX_XMLElement::GetNamespaceURI() const { @@ -68,7 +69,7 @@ WideString CFX_XMLElement::GetNamespaceURI() const { pNode = pNode->GetParent(); continue; } - return pElement->GetString(wsAttri); + return pElement->GetAttribute(wsAttri); } return WideString(); } @@ -94,30 +95,28 @@ void CFX_XMLElement::SetTextData(const WideString& wsText) { void CFX_XMLElement::Save( const RetainPtr& pXMLStream) { - WideString ws(L"<"); - ws += GetName(); - pXMLStream->WriteString(ws.AsStringView()); + pXMLStream->WriteString(L"<"); + pXMLStream->WriteString(name_.AsStringView()); - for (auto it : GetAttributes()) { + for (auto it : attrs_) { pXMLStream->WriteString( AttributeToString(it.first, it.second).AsStringView()); } - if (GetFirstChild()) { - ws = L"\n>"; - pXMLStream->WriteString(ws.AsStringView()); + if (!GetFirstChild()) { + pXMLStream->WriteString(L" />"); + return; + } - for (CFX_XMLNode* pChild = GetFirstChild(); pChild; - pChild = pChild->GetNextSibling()) { - pChild->Save(pXMLStream); - } - ws = L""; - } else { - ws = L"\n/>"; + pXMLStream->WriteString(L">"); + + for (CFX_XMLNode* pChild = GetFirstChild(); pChild; + pChild = pChild->GetNextSibling()) { + pChild->Save(pXMLStream); } - pXMLStream->WriteString(ws.AsStringView()); + pXMLStream->WriteString(L"WriteString(name_.AsStringView()); + pXMLStream->WriteString(L"\n>"); } CFX_XMLElement* CFX_XMLElement::GetFirstChildNamed( @@ -132,7 +131,7 @@ CFX_XMLElement* CFX_XMLElement::GetNthChildNamed(const WideStringView& name, continue; CFX_XMLElement* elem = static_cast(child); - if (elem->GetName() != name) + if (elem->name_ != name) continue; if (idx == 0) return elem; @@ -141,3 +140,31 @@ CFX_XMLElement* CFX_XMLElement::GetNthChildNamed(const WideStringView& name, } return nullptr; } + +bool CFX_XMLElement::HasAttribute(const WideString& name) const { + return attrs_.find(name) != attrs_.end(); +} + +WideString CFX_XMLElement::GetAttribute(const WideString& name) const { + auto it = attrs_.find(name); + return it != attrs_.end() ? it->second : L""; +} + +void CFX_XMLElement::SetAttribute(const WideString& name, + const WideString& value) { + attrs_[name] = value; +} + +void CFX_XMLElement::RemoveAttribute(const WideString& name) { + attrs_.erase(name); +} + +WideString CFX_XMLElement::AttributeToString(const WideString& name, + const WideString& value) { + WideString ret = L" "; + ret += name; + ret += L"=\""; + ret += EncodeEntities(value); + ret += L"\""; + return ret; +} diff --git a/core/fxcrt/xml/cfx_xmlelement.h b/core/fxcrt/xml/cfx_xmlelement.h index f713114eb7..f8533a1445 100644 --- a/core/fxcrt/xml/cfx_xmlelement.h +++ b/core/fxcrt/xml/cfx_xmlelement.h @@ -7,13 +7,14 @@ #ifndef CORE_FXCRT_XML_CFX_XMLELEMENT_H_ #define CORE_FXCRT_XML_CFX_XMLELEMENT_H_ +#include #include #include #include "core/fxcrt/fx_string.h" -#include "core/fxcrt/xml/cfx_xmlattributenode.h" +#include "core/fxcrt/xml/cfx_xmlnode.h" -class CFX_XMLElement : public CFX_XMLAttributeNode { +class CFX_XMLElement : public CFX_XMLNode { public: explicit CFX_XMLElement(const WideString& wsTag); ~CFX_XMLElement() override; @@ -23,6 +24,17 @@ class CFX_XMLElement : public CFX_XMLAttributeNode { std::unique_ptr Clone() override; void Save(const RetainPtr& pXMLStream) override; + WideString GetName() const { return name_; } + + const std::map& GetAttributes() const { + return attrs_; + } + bool HasAttribute(const WideString& name) const; + void SetAttribute(const WideString& name, const WideString& value); + WideString GetAttribute(const WideString& name) const; + + void RemoveAttribute(const WideString& name); + CFX_XMLElement* GetFirstChildNamed(const WideStringView& name) const; CFX_XMLElement* GetNthChildNamed(const WideStringView& name, size_t idx) const; @@ -33,6 +45,12 @@ class CFX_XMLElement : public CFX_XMLAttributeNode { WideString GetTextData() const; void SetTextData(const WideString& wsText); + + private: + WideString AttributeToString(const WideString& name, const WideString& value); + + WideString name_; + std::map attrs_; }; #endif // CORE_FXCRT_XML_CFX_XMLELEMENT_H_ diff --git a/core/fxcrt/xml/cfx_xmlinstruction.h b/core/fxcrt/xml/cfx_xmlinstruction.h index cbdf9e2538..7cee1d4fc0 100644 --- a/core/fxcrt/xml/cfx_xmlinstruction.h +++ b/core/fxcrt/xml/cfx_xmlinstruction.h @@ -11,7 +11,7 @@ #include #include "core/fxcrt/fx_string.h" -#include "core/fxcrt/xml/cfx_xmlattributenode.h" +#include "core/fxcrt/xml/cfx_xmlnode.h" class CFX_XMLInstruction : public CFX_XMLNode { public: diff --git a/core/fxcrt/xml/cfx_xmlnode.cpp b/core/fxcrt/xml/cfx_xmlnode.cpp index 5e787ed2b9..540b20e721 100644 --- a/core/fxcrt/xml/cfx_xmlnode.cpp +++ b/core/fxcrt/xml/cfx_xmlnode.cpp @@ -119,13 +119,3 @@ WideString CFX_XMLNode::EncodeEntities(const WideString& value) { ret.Replace(L"\"", L"""); return ret; } - -WideString CFX_XMLNode::AttributeToString(const WideString& name, - const WideString& value) { - WideString ret = L" "; - ret += name; - ret += L"=\""; - ret += EncodeEntities(value); - ret += L"\""; - return ret; -} diff --git a/core/fxcrt/xml/cfx_xmlnode.h b/core/fxcrt/xml/cfx_xmlnode.h index 76625e3ca2..7278d2b4ca 100644 --- a/core/fxcrt/xml/cfx_xmlnode.h +++ b/core/fxcrt/xml/cfx_xmlnode.h @@ -45,7 +45,6 @@ class CFX_XMLNode { void DeleteChildren(); protected: - WideString AttributeToString(const WideString& name, const WideString& value); WideString EncodeEntities(const WideString& value); private: diff --git a/core/fxcrt/xml/cfx_xmlparser.cpp b/core/fxcrt/xml/cfx_xmlparser.cpp index da287cf9cc..8292b33206 100644 --- a/core/fxcrt/xml/cfx_xmlparser.cpp +++ b/core/fxcrt/xml/cfx_xmlparser.cpp @@ -189,8 +189,8 @@ bool CFX_XMLParser::Parse() { break; case FX_XmlSyntaxResult::AttriValue: if (m_pChild && m_pChild->GetType() == FX_XMLNODE_Element) { - static_cast(m_pChild)->SetString(m_ws1, - GetAttributeName()); + static_cast(m_pChild)->SetAttribute( + m_ws1, GetAttributeName()); } m_ws1.clear(); break; diff --git a/fxjs/xfa/cjx_object.cpp b/fxjs/xfa/cjx_object.cpp index ab22e8b7e7..2ea69d43c8 100644 --- a/fxjs/xfa/cjx_object.cpp +++ b/fxjs/xfa/cjx_object.cpp @@ -343,7 +343,7 @@ bool CJX_Object::SetBoolean(XFA_Attribute eAttr, bool bValue, bool bNotify) { CFX_XMLElement* elem = SetValue(eAttr, XFA_AttributeType::Boolean, (void*)(uintptr_t)bValue, bNotify); if (elem) - elem->SetString(CXFA_Node::AttributeToName(eAttr), bValue ? L"1" : L"0"); + elem->SetAttribute(CXFA_Node::AttributeToName(eAttr), bValue ? L"1" : L"0"); return true; } @@ -355,8 +355,8 @@ bool CJX_Object::SetInteger(XFA_Attribute eAttr, int32_t iValue, bool bNotify) { CFX_XMLElement* elem = SetValue(eAttr, XFA_AttributeType::Integer, (void*)(uintptr_t)iValue, bNotify); if (elem) { - elem->SetString(CXFA_Node::AttributeToName(eAttr), - WideString::Format(L"%d", iValue)); + elem->SetAttribute(CXFA_Node::AttributeToName(eAttr), + WideString::Format(L"%d", iValue)); } return true; } @@ -397,8 +397,8 @@ bool CJX_Object::SetEnum(XFA_Attribute eAttr, CFX_XMLElement* elem = SetValue(eAttr, XFA_AttributeType::Enum, (void*)(uintptr_t)eValue, bNotify); if (elem) { - elem->SetString(CXFA_Node::AttributeToName(eAttr), - CXFA_Node::AttributeEnumToName(eValue)); + elem->SetAttribute(CXFA_Node::AttributeToName(eAttr), + CXFA_Node::AttributeEnumToName(eValue)); } return true; } @@ -487,7 +487,7 @@ bool CJX_Object::SetCData(XFA_Attribute eAttr, if (eAttr == XFA_Attribute::ContentType) wsAttrName = L"xfa:" + wsAttrName; - elem->SetString(wsAttrName, wsValue); + elem->SetAttribute(wsAttrName, wsValue); return true; } diff --git a/fxjs/xfa/cjx_packet.cpp b/fxjs/xfa/cjx_packet.cpp index 80b391c87b..bd39ec0538 100644 --- a/fxjs/xfa/cjx_packet.cpp +++ b/fxjs/xfa/cjx_packet.cpp @@ -32,7 +32,7 @@ CJS_Return CJX_Packet::getAttribute( WideString attributeValue; CFX_XMLNode* pXMLNode = GetXFANode()->GetXMLMappingNode(); if (pXMLNode && pXMLNode->GetType() == FX_XMLNODE_Element) { - attributeValue = static_cast(pXMLNode)->GetString( + attributeValue = static_cast(pXMLNode)->GetAttribute( runtime->ToWideString(params[0]).c_str()); } return CJS_Return( @@ -47,7 +47,7 @@ CJS_Return CJX_Packet::setAttribute( CFX_XMLNode* pXMLNode = GetXFANode()->GetXMLMappingNode(); if (pXMLNode && pXMLNode->GetType() == FX_XMLNODE_Element) { - static_cast(pXMLNode)->SetString( + static_cast(pXMLNode)->SetAttribute( runtime->ToWideString(params[1]), runtime->ToWideString(params[0])); } return CJS_Return(runtime->NewNull()); diff --git a/xfa/fxfa/cxfa_textlayout.cpp b/xfa/fxfa/cxfa_textlayout.cpp index e360c16dde..e066380f77 100644 --- a/xfa/fxfa/cxfa_textlayout.cpp +++ b/xfa/fxfa/cxfa_textlayout.cpp @@ -744,7 +744,7 @@ bool CXFA_TextLayout::LoadRichText( if (wsName == L"a") { ASSERT(pElement); - WideString wsLinkContent = pElement->GetString(L"href"); + WideString wsLinkContent = pElement->GetAttribute(L"href"); if (!wsLinkContent.IsEmpty()) { pLinkData = pdfium::MakeRetain(wsLinkContent.c_str()); diff --git a/xfa/fxfa/cxfa_textparser.cpp b/xfa/fxfa/cxfa_textparser.cpp index a957147762..f0a6dd2af1 100644 --- a/xfa/fxfa/cxfa_textparser.cpp +++ b/xfa/fxfa/cxfa_textparser.cpp @@ -284,7 +284,7 @@ std::unique_ptr CXFA_TextParser::ParseTagInfo( tagProvider->SetTagName(wsName); tagProvider->m_bTagAvailable = TagValidate(wsName); - WideString wsValue = pXMLElement->GetString(L"style"); + WideString wsValue = pXMLElement->GetAttribute(L"style"); if (!wsValue.IsEmpty()) tagProvider->SetAttribute(L"style", wsValue); } else if (pXMLNode->GetType() == FX_XMLNODE_Text) { @@ -505,13 +505,13 @@ bool CXFA_TextParser::GetEmbbedObj(CXFA_TextProvider* pTextProvider, bool bRet = false; if (pXMLNode->GetType() == FX_XMLNODE_Element) { CFX_XMLElement* pElement = static_cast(pXMLNode); - WideString wsAttr = pElement->GetString(L"xfa:embed"); + WideString wsAttr = pElement->GetAttribute(L"xfa:embed"); if (wsAttr.IsEmpty()) return false; if (wsAttr[0] == L'#') wsAttr.Delete(0); - WideString ws = pElement->GetString(L"xfa:embedType"); + WideString ws = pElement->GetAttribute(L"xfa:embedType"); if (ws.IsEmpty()) ws = L"som"; else @@ -521,7 +521,7 @@ bool CXFA_TextParser::GetEmbbedObj(CXFA_TextProvider* pTextProvider, if (!bURI && ws != L"som") return false; - ws = pElement->GetString(L"xfa:embedMode"); + ws = pElement->GetAttribute(L"xfa:embedMode"); if (ws.IsEmpty()) ws = L"formatted"; else diff --git a/xfa/fxfa/parser/cxfa_dataexporter.cpp b/xfa/fxfa/parser/cxfa_dataexporter.cpp index 1418d030b5..389b9dbacb 100644 --- a/xfa/fxfa/parser/cxfa_dataexporter.cpp +++ b/xfa/fxfa/parser/cxfa_dataexporter.cpp @@ -89,7 +89,8 @@ bool CXFA_DataExporter::Export( return false; XFA_DataExporter_DealWithDataGroupNode(pExportNode); - pElement->SetString(L"xmlns:xfa", L"http://www.xfa.org/schema/xfa-data/1.0/"); + pElement->SetAttribute(L"xmlns:xfa", + L"http://www.xfa.org/schema/xfa-data/1.0/"); pElement->Save(pStream); pElement->RemoveAttribute(L"xmlns:xfa"); diff --git a/xfa/fxfa/parser/cxfa_document.cpp b/xfa/fxfa/parser/cxfa_document.cpp index cdfb7b45a6..713e15c4fa 100644 --- a/xfa/fxfa/parser/cxfa_document.cpp +++ b/xfa/fxfa/parser/cxfa_document.cpp @@ -514,7 +514,7 @@ void CreateDataBinding(CXFA_Node* pFormNode, pDataNode->JSObject()->SetCData(XFA_Attribute::ContentType, wsContentType, false, false); if (!wsHref.IsEmpty()) - pXMLDataElement->SetString(L"href", wsHref); + pXMLDataElement->SetAttribute(L"href", wsHref); break; } @@ -537,8 +537,8 @@ void CreateDataBinding(CXFA_Node* pFormNode, } else { CFX_XMLNode* pXMLNode = pDataNode->GetXMLMappingNode(); ASSERT(pXMLNode->GetType() == FX_XMLNODE_Element); - static_cast(pXMLNode)->SetString(L"xfa:dataNode", - L"dataGroup"); + static_cast(pXMLNode)->SetAttribute( + L"xfa:dataNode", L"dataGroup"); } } else if (!wsValue.IsEmpty()) { pDataNode->JSObject()->SetAttributeValue( @@ -657,14 +657,14 @@ void CreateDataBinding(CXFA_Node* pFormNode, ASSERT(pXMLDataElement); WideString wsContentType = - pXMLDataElement->GetString(L"xfa:contentType"); + pXMLDataElement->GetAttribute(L"xfa:contentType"); if (!wsContentType.IsEmpty()) { pDataNode->JSObject()->SetCData(XFA_Attribute::ContentType, wsContentType, false, false); image->SetContentType(wsContentType); } - WideString wsHref = pXMLDataElement->GetString(L"href"); + WideString wsHref = pXMLDataElement->GetAttribute(L"href"); if (!wsHref.IsEmpty()) image->SetHref(wsHref); } @@ -1625,8 +1625,8 @@ void CXFA_Document::DoDataMerge() { if (!pDatasetsRoot) { // Ownership will be passed in the AppendChild below to the XML tree. auto pDatasetsXMLNode = pdfium::MakeUnique(L"xfa:datasets"); - pDatasetsXMLNode->SetString(L"xmlns:xfa", - L"http://www.xfa.org/schema/xfa-data/1.0/"); + pDatasetsXMLNode->SetAttribute(L"xmlns:xfa", + L"http://www.xfa.org/schema/xfa-data/1.0/"); pDatasetsRoot = CreateNode(XFA_PacketType::Datasets, XFA_Element::DataModel); pDatasetsRoot->JSObject()->SetCData(XFA_Attribute::Name, L"datasets", false, diff --git a/xfa/fxfa/parser/cxfa_document_parser.cpp b/xfa/fxfa/parser/cxfa_document_parser.cpp index 98ac38065d..32bcba0609 100644 --- a/xfa/fxfa/parser/cxfa_document_parser.cpp +++ b/xfa/fxfa/parser/cxfa_document_parser.cpp @@ -602,7 +602,7 @@ CXFA_Node* CXFA_DocumentParser::ParseAsXDPPacket_Template( static_cast(pXMLDocumentNode); WideString wsNamespaceURI = pXMLDocumentElement->GetNamespaceURI(); if (wsNamespaceURI.IsEmpty()) - wsNamespaceURI = pXMLDocumentElement->GetString(L"xmlns:xfa"); + wsNamespaceURI = pXMLDocumentElement->GetAttribute(L"xmlns:xfa"); pNode->GetDocument()->RecognizeXFAVersionNumber(wsNamespaceURI); diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp index 10f0a40017..7da4ed551d 100644 --- a/xfa/fxfa/parser/cxfa_node.cpp +++ b/xfa/fxfa/parser/cxfa_node.cpp @@ -2662,7 +2662,7 @@ void CXFA_Node::SetImageEdit(const WideString& wsContentType, } else { CFX_XMLNode* pXMLNode = pBind->GetXMLMappingNode(); ASSERT(pXMLNode && pXMLNode->GetType() == FX_XMLNODE_Element); - static_cast(pXMLNode)->SetString(L"href", wsHref); + static_cast(pXMLNode)->SetAttribute(L"href", wsHref); } } @@ -4662,8 +4662,8 @@ void CXFA_Node::SetToXML(const WideString& value) { switch (eXMLType) { case FX_XMLNODE_Element: { if (IsAttributeInXML()) { - elem->SetString(JSObject()->GetCData(XFA_Attribute::QualifiedName), - value); + elem->SetAttribute(JSObject()->GetCData(XFA_Attribute::QualifiedName), + value); return; } diff --git a/xfa/fxfa/parser/cxfa_xmllocale.cpp b/xfa/fxfa/parser/cxfa_xmllocale.cpp index 6720d56cba..4354ed98de 100644 --- a/xfa/fxfa/parser/cxfa_xmllocale.cpp +++ b/xfa/fxfa/parser/cxfa_xmllocale.cpp @@ -65,7 +65,7 @@ CXFA_XMLLocale::CXFA_XMLLocale(std::unique_ptr root, CXFA_XMLLocale::~CXFA_XMLLocale() {} WideString CXFA_XMLLocale::GetName() const { - return locale_->GetString(L"name"); + return locale_->GetAttribute(L"name"); } WideString CXFA_XMLLocale::GetDecimalSymbol() const { @@ -136,7 +136,7 @@ WideString CXFA_XMLLocale::GetCalendarSymbol(const WideStringView& symbol, if (elem->GetName() != pstrSymbolNames) continue; - WideString abbr = elem->GetString(L"abbr"); + WideString abbr = elem->GetAttribute(L"abbr"); bool abbr_value = false; if (!abbr.IsEmpty()) abbr_value = abbr == L"1"; @@ -219,7 +219,7 @@ WideString CXFA_XMLLocale::GetPattern(CFX_XMLElement* patterns, CFX_XMLElement* pattern = static_cast(child); if (pattern->GetName() != bsTag) continue; - if (pattern->GetString(L"name") != wsName) + if (pattern->GetAttribute(L"name") != wsName) continue; return pattern->GetTextData(); diff --git a/xfa/fxfa/parser/xfa_utils.cpp b/xfa/fxfa/parser/xfa_utils.cpp index 7b4e4b1989..ebe087aa64 100644 --- a/xfa/fxfa/parser/xfa_utils.cpp +++ b/xfa/fxfa/parser/xfa_utils.cpp @@ -479,7 +479,7 @@ bool XFA_FDEExtension_ResolveNamespaceQualifier(CFX_XMLElement* pNode, auto* pElement = static_cast(pParent); if (pElement->HasAttribute(wsNSAttribute.c_str())) { - *wsNamespaceURI = pElement->GetString(wsNSAttribute.c_str()); + *wsNamespaceURI = pElement->GetAttribute(wsNSAttribute.c_str()); return true; } } @@ -513,8 +513,8 @@ void XFA_DataExporter_DealWithDataGroupNode(CXFA_Node* pDataNode) { CFX_XMLNode* pXMLNode = pDataNode->GetXMLMappingNode(); ASSERT(pXMLNode->GetType() == FX_XMLNODE_Element); - static_cast(pXMLNode)->SetString(L"xfa:dataNode", - L"dataGroup"); + static_cast(pXMLNode)->SetAttribute(L"xfa:dataNode", + L"dataGroup"); } void XFA_DataExporter_RegenerateFormFile( -- cgit v1.2.3