summaryrefslogtreecommitdiff
path: root/xfa
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-04-05 11:48:21 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-04-05 16:10:44 +0000
commit5fa4e981ed6c431d86c51a74eba19ea4b816f541 (patch)
tree4bfa4afc2b89e1a423ec4838937042780eaa6191 /xfa
parentddcb6e7f47e2769fb4565bd4430ecb465a1f5417 (diff)
downloadpdfium-5fa4e981ed6c431d86c51a74eba19ea4b816f541.tar.xz
Move XML attribute handling to a base class.
This CL moves the attribute handling out of CFDE_XMLElement and CFDE_XMLInstruction into a common CFDE_XMLAttributeNode. The handling is also converted to a std::map from either a) a vector storing name,value,name,value or b) two vectors one for names and the other for values. The unused Get/Set methods for interger and float are removed and the iteration is converted to use iterators. Change-Id: Icda00ae898a595d58b06af0ced337f55f47c317c Reviewed-on: https://pdfium-review.googlesource.com/3753 Reviewed-by: Nicolás Peña <npm@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa')
-rw-r--r--xfa/fde/xml/cfde_xmlattributenode.cpp35
-rw-r--r--xfa/fde/xml/cfde_xmlattributenode.h44
-rw-r--r--xfa/fde/xml/cfde_xmldoc.cpp47
-rw-r--r--xfa/fde/xml/cfde_xmlelement.cpp168
-rw-r--r--xfa/fde/xml/cfde_xmlelement.h36
-rw-r--r--xfa/fde/xml/cfde_xmlinstruction.cpp125
-rw-r--r--xfa/fde/xml/cfde_xmlinstruction.h28
-rw-r--r--xfa/fde/xml/cfde_xmlnode.cpp63
-rw-r--r--xfa/fde/xml/cfde_xmlparser.cpp6
-rw-r--r--xfa/fxfa/app/cxfa_textlayout.cpp8
-rw-r--r--xfa/fxfa/app/cxfa_textparser.cpp14
-rw-r--r--xfa/fxfa/cxfa_ffdoc.cpp9
-rw-r--r--xfa/fxfa/parser/cxfa_document.cpp2
-rw-r--r--xfa/fxfa/parser/cxfa_document.h2
-rw-r--r--xfa/fxfa/parser/cxfa_node.cpp21
-rw-r--r--xfa/fxfa/parser/cxfa_simple_parser.cpp306
-rw-r--r--xfa/fxfa/parser/xfa_document_datamerger_imp.cpp9
-rw-r--r--xfa/fxfa/parser/xfa_utils.cpp3
-rw-r--r--xfa/fxfa/parser/xfa_utils.h2
19 files changed, 343 insertions, 585 deletions
diff --git a/xfa/fde/xml/cfde_xmlattributenode.cpp b/xfa/fde/xml/cfde_xmlattributenode.cpp
new file mode 100644
index 0000000000..0bfa949b12
--- /dev/null
+++ b/xfa/fde/xml/cfde_xmlattributenode.cpp
@@ -0,0 +1,35 @@
+// 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 "xfa/fde/xml/cfde_xmlattributenode.h"
+
+#include "core/fxcrt/fx_ext.h"
+
+CFDE_XMLAttributeNode::CFDE_XMLAttributeNode(const CFX_WideString& name)
+ : CFDE_XMLNode(), name_(name) {
+ ASSERT(name_.GetLength() > 0);
+}
+
+CFDE_XMLAttributeNode::~CFDE_XMLAttributeNode() {}
+
+bool CFDE_XMLAttributeNode::HasAttribute(const CFX_WideString& name) const {
+ return attrs_.find(name) != attrs_.end();
+}
+
+CFX_WideString CFDE_XMLAttributeNode::GetString(
+ const CFX_WideString& name) const {
+ auto it = attrs_.find(name);
+ return it != attrs_.end() ? it->second : CFX_WideString();
+}
+
+void CFDE_XMLAttributeNode::SetString(const CFX_WideString& name,
+ const CFX_WideString& value) {
+ attrs_[name] = value;
+}
+
+void CFDE_XMLAttributeNode::RemoveAttribute(const CFX_WideString& name) {
+ attrs_.erase(name);
+}
diff --git a/xfa/fde/xml/cfde_xmlattributenode.h b/xfa/fde/xml/cfde_xmlattributenode.h
new file mode 100644
index 0000000000..07a1ef1610
--- /dev/null
+++ b/xfa/fde/xml/cfde_xmlattributenode.h
@@ -0,0 +1,44 @@
+// 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 XFA_FDE_XML_CFDE_XMLATTRIBUTENODE_H_
+#define XFA_FDE_XML_CFDE_XMLATTRIBUTENODE_H_
+
+#include <map>
+#include <memory>
+
+#include "core/fxcrt/fx_string.h"
+#include "xfa/fde/xml/cfde_xmlnode.h"
+
+class CFDE_XMLAttributeNode : public CFDE_XMLNode {
+ public:
+ explicit CFDE_XMLAttributeNode(const CFX_WideString& name);
+ ~CFDE_XMLAttributeNode() override;
+
+ // CFDE_XMLNode
+ FDE_XMLNODETYPE GetType() const override = 0;
+ std::unique_ptr<CFDE_XMLNode> Clone() override = 0;
+
+ CFX_WideString GetName() const { return name_; }
+ const std::map<CFX_WideString, CFX_WideString>& GetAttributes() const {
+ return attrs_;
+ }
+ void SetAttributes(const std::map<CFX_WideString, CFX_WideString>& attrs) {
+ attrs_ = attrs;
+ }
+ bool HasAttribute(const CFX_WideString& name) const;
+
+ void SetString(const CFX_WideString& name, const CFX_WideString& value);
+ CFX_WideString GetString(const CFX_WideString& name) const;
+
+ void RemoveAttribute(const CFX_WideString& name);
+
+ private:
+ CFX_WideString name_;
+ std::map<CFX_WideString, CFX_WideString> attrs_;
+};
+
+#endif // XFA_FDE_XML_CFDE_XMLATTRIBUTENODE_H_
diff --git a/xfa/fde/xml/cfde_xmldoc.cpp b/xfa/fde/xml/cfde_xmldoc.cpp
index 5d427fb06e..7032700578 100644
--- a/xfa/fde/xml/cfde_xmldoc.cpp
+++ b/xfa/fde/xml/cfde_xmldoc.cpp
@@ -54,7 +54,7 @@ void CFDE_XMLDoc::SaveXMLNode(const CFX_RetainPtr<IFGAS_Stream>& pXMLStream,
case FDE_XMLNODE_Instruction: {
CFX_WideString ws;
CFDE_XMLInstruction* pInstruction = (CFDE_XMLInstruction*)pNode;
- if (pInstruction->m_wsTarget.CompareNoCase(L"xml") == 0) {
+ if (pInstruction->GetName().CompareNoCase(L"xml") == 0) {
ws = L"<?xml version=\"1.0\" encoding=\"";
uint16_t wCodePage = pXMLStream->GetCodePage();
if (wCodePage == FX_CODEPAGE_UTF16LE) {
@@ -67,31 +67,28 @@ void CFDE_XMLDoc::SaveXMLNode(const CFX_RetainPtr<IFGAS_Stream>& pXMLStream,
ws += L"\"?>";
pXMLStream->WriteString(ws.c_str(), ws.GetLength());
} else {
- ws.Format(L"<?%s", pInstruction->m_wsTarget.c_str());
+ ws.Format(L"<?%s", pInstruction->GetName().c_str());
pXMLStream->WriteString(ws.c_str(), ws.GetLength());
- std::vector<CFX_WideString>& attributes = pInstruction->m_Attributes;
- int32_t i;
- int32_t iCount = pdfium::CollectionSize<int32_t>(attributes);
- CFX_WideString wsValue;
- for (i = 0; i < iCount; i += 2) {
- ws = L" ";
- ws += attributes[i];
- ws += L"=\"";
- wsValue = attributes[i + 1];
+
+ for (auto it : pInstruction->GetAttributes()) {
+ CFX_WideString wsValue = it.second;
wsValue.Replace(L"&", L"&amp;");
wsValue.Replace(L"<", L"&lt;");
wsValue.Replace(L">", L"&gt;");
wsValue.Replace(L"\'", L"&apos;");
wsValue.Replace(L"\"", L"&quot;");
+
+ ws = L" ";
+ ws += it.first;
+ ws += L"=\"";
ws += wsValue;
ws += L"\"";
pXMLStream->WriteString(ws.c_str(), ws.GetLength());
}
- std::vector<CFX_WideString>& targetdata = pInstruction->m_TargetData;
- iCount = pdfium::CollectionSize<int32_t>(targetdata);
- for (i = 0; i < iCount; i++) {
+
+ for (auto target : pInstruction->GetTargetData()) {
ws = L" \"";
- ws += targetdata[i];
+ ws += target;
ws += L"\"";
pXMLStream->WriteString(ws.c_str(), ws.GetLength());
}
@@ -103,22 +100,20 @@ void CFDE_XMLDoc::SaveXMLNode(const CFX_RetainPtr<IFGAS_Stream>& pXMLStream,
case FDE_XMLNODE_Element: {
CFX_WideString ws;
ws = L"<";
- ws += ((CFDE_XMLElement*)pNode)->m_wsTag;
+ ws += static_cast<CFDE_XMLElement*>(pNode)->GetName();
pXMLStream->WriteString(ws.c_str(), ws.GetLength());
- std::vector<CFX_WideString>& attributes =
- static_cast<CFDE_XMLElement*>(pNode)->m_Attributes;
- int32_t iCount = pdfium::CollectionSize<int32_t>(attributes);
- CFX_WideString wsValue;
- for (int32_t i = 0; i < iCount; i += 2) {
- ws = L" ";
- ws += attributes[i];
- ws += L"=\"";
- wsValue = attributes[i + 1];
+
+ for (auto it : static_cast<CFDE_XMLElement*>(pNode)->GetAttributes()) {
+ CFX_WideString wsValue = it.second;
wsValue.Replace(L"&", L"&amp;");
wsValue.Replace(L"<", L"&lt;");
wsValue.Replace(L">", L"&gt;");
wsValue.Replace(L"\'", L"&apos;");
wsValue.Replace(L"\"", L"&quot;");
+
+ ws = L" ";
+ ws += it.first;
+ ws += L"=\"";
ws += wsValue;
ws += L"\"";
pXMLStream->WriteString(ws.c_str(), ws.GetLength());
@@ -132,7 +127,7 @@ void CFDE_XMLDoc::SaveXMLNode(const CFX_RetainPtr<IFGAS_Stream>& pXMLStream,
pChild = pChild->m_pNext;
}
ws = L"</";
- ws += ((CFDE_XMLElement*)pNode)->m_wsTag;
+ ws += static_cast<CFDE_XMLElement*>(pNode)->GetName();
ws += L"\n>";
} else {
ws = L"\n/>";
diff --git a/xfa/fde/xml/cfde_xmlelement.cpp b/xfa/fde/xml/cfde_xmlelement.cpp
index 646eea2ee2..560cf89280 100644
--- a/xfa/fde/xml/cfde_xmlelement.cpp
+++ b/xfa/fde/xml/cfde_xmlelement.cpp
@@ -13,9 +13,7 @@
#include "xfa/fde/xml/cfde_xmltext.h"
CFDE_XMLElement::CFDE_XMLElement(const CFX_WideString& wsTag)
- : CFDE_XMLNode(), m_wsTag(wsTag), m_Attributes() {
- ASSERT(m_wsTag.GetLength() > 0);
-}
+ : CFDE_XMLAttributeNode(wsTag) {}
CFDE_XMLElement::~CFDE_XMLElement() {}
@@ -24,8 +22,8 @@ FDE_XMLNODETYPE CFDE_XMLElement::GetType() const {
}
std::unique_ptr<CFDE_XMLNode> CFDE_XMLElement::Clone() {
- auto pClone = pdfium::MakeUnique<CFDE_XMLElement>(m_wsTag);
- pClone->m_Attributes = m_Attributes;
+ auto pClone = pdfium::MakeUnique<CFDE_XMLElement>(GetName());
+ pClone->SetAttributes(GetAttributes());
CFX_WideString wsText;
CFDE_XMLNode* pChild = m_pChild;
@@ -43,155 +41,44 @@ std::unique_ptr<CFDE_XMLNode> CFDE_XMLElement::Clone() {
return pClone;
}
-void CFDE_XMLElement::GetTagName(CFX_WideString& wsTag) const {
- wsTag = m_wsTag;
-}
-
-void CFDE_XMLElement::GetLocalTagName(CFX_WideString& wsTag) const {
- FX_STRSIZE iFind = m_wsTag.Find(L':', 0);
- if (iFind < 0) {
- wsTag = m_wsTag;
- } else {
- wsTag = m_wsTag.Right(m_wsTag.GetLength() - iFind - 1);
- }
+CFX_WideString CFDE_XMLElement::GetLocalTagName() const {
+ FX_STRSIZE iFind = GetName().Find(L':', 0);
+ if (iFind < 0)
+ return GetName();
+ return GetName().Right(GetName().GetLength() - iFind - 1);
}
-void CFDE_XMLElement::GetNamespacePrefix(CFX_WideString& wsPrefix) const {
- FX_STRSIZE iFind = m_wsTag.Find(L':', 0);
- if (iFind < 0) {
- wsPrefix.clear();
- } else {
- wsPrefix = m_wsTag.Left(iFind);
- }
+CFX_WideString CFDE_XMLElement::GetNamespacePrefix() const {
+ FX_STRSIZE iFind = GetName().Find(L':', 0);
+ if (iFind < 0)
+ return CFX_WideString();
+ return GetName().Left(iFind);
}
-void CFDE_XMLElement::GetNamespaceURI(CFX_WideString& wsNamespace) const {
- CFX_WideString wsAttri(L"xmlns"), wsPrefix;
- GetNamespacePrefix(wsPrefix);
+CFX_WideString CFDE_XMLElement::GetNamespaceURI() const {
+ CFX_WideString wsAttri(L"xmlns");
+ CFX_WideString wsPrefix = GetNamespacePrefix();
if (wsPrefix.GetLength() > 0) {
wsAttri += L":";
wsAttri += wsPrefix;
}
- wsNamespace.clear();
- CFDE_XMLNode* pNode = (CFDE_XMLNode*)this;
+
+ auto* pNode = static_cast<const CFDE_XMLNode*>(this);
while (pNode) {
- if (pNode->GetType() != FDE_XMLNODE_Element) {
+ if (pNode->GetType() != FDE_XMLNODE_Element)
break;
- }
- CFDE_XMLElement* pElement = (CFDE_XMLElement*)pNode;
- if (!pElement->HasAttribute(wsAttri.c_str())) {
+
+ auto* pElement = static_cast<const CFDE_XMLElement*>(pNode);
+ if (!pElement->HasAttribute(wsAttri)) {
pNode = pNode->GetNodeItem(CFDE_XMLNode::Parent);
continue;
}
- pElement->GetString(wsAttri.c_str(), wsNamespace);
- break;
- }
-}
-
-int32_t CFDE_XMLElement::CountAttributes() const {
- return pdfium::CollectionSize<int32_t>(m_Attributes) / 2;
-}
-
-bool CFDE_XMLElement::GetAttribute(int32_t index,
- CFX_WideString& wsAttriName,
- CFX_WideString& wsAttriValue) const {
- int32_t iCount = pdfium::CollectionSize<int32_t>(m_Attributes);
- ASSERT(index > -1 && index < iCount / 2);
- for (int32_t i = 0; i < iCount; i += 2) {
- if (index == 0) {
- wsAttriName = m_Attributes[i];
- wsAttriValue = m_Attributes[i + 1];
- return true;
- }
- index--;
- }
- return false;
-}
-
-bool CFDE_XMLElement::HasAttribute(const wchar_t* pwsAttriName) const {
- int32_t iCount = pdfium::CollectionSize<int32_t>(m_Attributes);
- for (int32_t i = 0; i < iCount; i += 2) {
- if (m_Attributes[i].Compare(pwsAttriName) == 0)
- return true;
- }
- return false;
-}
-
-void CFDE_XMLElement::GetString(const wchar_t* pwsAttriName,
- CFX_WideString& wsAttriValue,
- const wchar_t* pwsDefValue) const {
- int32_t iCount = pdfium::CollectionSize<int32_t>(m_Attributes);
- for (int32_t i = 0; i < iCount; i += 2) {
- if (m_Attributes[i].Compare(pwsAttriName) == 0) {
- wsAttriValue = m_Attributes[i + 1];
- return;
- }
+ return pElement->GetString(wsAttri);
}
- wsAttriValue = pwsDefValue;
+ return CFX_WideString();
}
-void CFDE_XMLElement::SetString(const CFX_WideString& wsAttriName,
- const CFX_WideString& wsAttriValue) {
- ASSERT(wsAttriName.GetLength() > 0);
- int32_t iCount = pdfium::CollectionSize<int32_t>(m_Attributes);
- for (int32_t i = 0; i < iCount; i += 2) {
- if (m_Attributes[i].Compare(wsAttriName) == 0) {
- m_Attributes[i] = wsAttriName;
- m_Attributes[i + 1] = wsAttriValue;
- return;
- }
- }
- m_Attributes.push_back(wsAttriName);
- m_Attributes.push_back(wsAttriValue);
-}
-
-int32_t CFDE_XMLElement::GetInteger(const wchar_t* pwsAttriName,
- int32_t iDefValue) const {
- int32_t iCount = pdfium::CollectionSize<int32_t>(m_Attributes);
- for (int32_t i = 0; i < iCount; i += 2) {
- if (m_Attributes[i].Compare(pwsAttriName) == 0) {
- return FXSYS_wtoi(m_Attributes[i + 1].c_str());
- }
- }
- return iDefValue;
-}
-
-void CFDE_XMLElement::SetInteger(const wchar_t* pwsAttriName,
- int32_t iAttriValue) {
- CFX_WideString wsValue;
- wsValue.Format(L"%d", iAttriValue);
- SetString(pwsAttriName, wsValue);
-}
-
-float CFDE_XMLElement::GetFloat(const wchar_t* pwsAttriName,
- float fDefValue) const {
- int32_t iCount = pdfium::CollectionSize<int32_t>(m_Attributes);
- for (int32_t i = 0; i < iCount; i += 2) {
- if (m_Attributes[i].Compare(pwsAttriName) == 0) {
- return FXSYS_wcstof(m_Attributes[i + 1].c_str(), -1, nullptr);
- }
- }
- return fDefValue;
-}
-
-void CFDE_XMLElement::SetFloat(const wchar_t* pwsAttriName, float fAttriValue) {
- CFX_WideString wsValue;
- wsValue.Format(L"%f", fAttriValue);
- SetString(pwsAttriName, wsValue);
-}
-
-void CFDE_XMLElement::RemoveAttribute(const wchar_t* pwsAttriName) {
- int32_t iCount = pdfium::CollectionSize<int32_t>(m_Attributes);
- for (int32_t i = 0; i < iCount; i += 2) {
- if (m_Attributes[i].Compare(pwsAttriName) == 0) {
- m_Attributes.erase(m_Attributes.begin() + i,
- m_Attributes.begin() + i + 2);
- return;
- }
- }
-}
-
-void CFDE_XMLElement::GetTextData(CFX_WideString& wsText) const {
+CFX_WideString CFDE_XMLElement::GetTextData() const {
CFX_WideTextBuf buffer;
CFDE_XMLNode* pChild = m_pChild;
while (pChild) {
@@ -205,12 +92,11 @@ void CFDE_XMLElement::GetTextData(CFX_WideString& wsText) const {
}
pChild = pChild->m_pNext;
}
- wsText = buffer.AsStringC();
+ return buffer.MakeString();
}
void CFDE_XMLElement::SetTextData(const CFX_WideString& wsText) {
- if (wsText.GetLength() < 1) {
+ if (wsText.GetLength() < 1)
return;
- }
InsertChildNode(new CFDE_XMLText(wsText));
}
diff --git a/xfa/fde/xml/cfde_xmlelement.h b/xfa/fde/xml/cfde_xmlelement.h
index c4c522e8a5..a891ce8928 100644
--- a/xfa/fde/xml/cfde_xmlelement.h
+++ b/xfa/fde/xml/cfde_xmlelement.h
@@ -11,9 +11,9 @@
#include <vector>
#include "core/fxcrt/fx_string.h"
-#include "xfa/fde/xml/cfde_xmlnode.h"
+#include "xfa/fde/xml/cfde_xmlattributenode.h"
-class CFDE_XMLElement : public CFDE_XMLNode {
+class CFDE_XMLElement : public CFDE_XMLAttributeNode {
public:
explicit CFDE_XMLElement(const CFX_WideString& wsTag);
~CFDE_XMLElement() override;
@@ -22,36 +22,12 @@ class CFDE_XMLElement : public CFDE_XMLNode {
FDE_XMLNODETYPE GetType() const override;
std::unique_ptr<CFDE_XMLNode> Clone() override;
- void GetTagName(CFX_WideString& wsTag) const;
- void GetLocalTagName(CFX_WideString& wsTag) const;
+ CFX_WideString GetLocalTagName() const;
+ CFX_WideString GetNamespacePrefix() const;
+ CFX_WideString GetNamespaceURI() const;
- void GetNamespacePrefix(CFX_WideString& wsPrefix) const;
- void GetNamespaceURI(CFX_WideString& wsNamespace) const;
-
- int32_t CountAttributes() const;
- bool GetAttribute(int32_t index,
- CFX_WideString& wsAttriName,
- CFX_WideString& wsAttriValue) const;
- bool HasAttribute(const wchar_t* pwsAttriName) const;
- void RemoveAttribute(const wchar_t* pwsAttriName);
-
- void GetString(const wchar_t* pwsAttriName,
- CFX_WideString& wsAttriValue,
- const wchar_t* pwsDefValue = nullptr) const;
- void SetString(const CFX_WideString& wsAttriName,
- const CFX_WideString& wsAttriValue);
-
- int32_t GetInteger(const wchar_t* pwsAttriName, int32_t iDefValue = 0) const;
- void SetInteger(const wchar_t* pwsAttriName, int32_t iAttriValue);
-
- float GetFloat(const wchar_t* pwsAttriName, float fDefValue = 0) const;
- void SetFloat(const wchar_t* pwsAttriName, float fAttriValue);
-
- void GetTextData(CFX_WideString& wsText) const;
+ CFX_WideString GetTextData() const;
void SetTextData(const CFX_WideString& wsText);
-
- CFX_WideString m_wsTag;
- std::vector<CFX_WideString> m_Attributes;
};
#endif // XFA_FDE_XML_CFDE_XMLELEMENT_H_
diff --git a/xfa/fde/xml/cfde_xmlinstruction.cpp b/xfa/fde/xml/cfde_xmlinstruction.cpp
index 2229b4768a..d289d9e88a 100644
--- a/xfa/fde/xml/cfde_xmlinstruction.cpp
+++ b/xfa/fde/xml/cfde_xmlinstruction.cpp
@@ -11,9 +11,7 @@
#include "third_party/base/stl_util.h"
CFDE_XMLInstruction::CFDE_XMLInstruction(const CFX_WideString& wsTarget)
- : m_wsTarget(wsTarget) {
- ASSERT(m_wsTarget.GetLength() > 0);
-}
+ : CFDE_XMLAttributeNode(wsTarget) {}
CFDE_XMLInstruction::~CFDE_XMLInstruction() {}
@@ -22,129 +20,12 @@ FDE_XMLNODETYPE CFDE_XMLInstruction::GetType() const {
}
std::unique_ptr<CFDE_XMLNode> CFDE_XMLInstruction::Clone() {
- auto pClone = pdfium::MakeUnique<CFDE_XMLInstruction>(m_wsTarget);
- pClone->m_Attributes = m_Attributes;
+ auto pClone = pdfium::MakeUnique<CFDE_XMLInstruction>(GetName());
+ pClone->SetAttributes(GetAttributes());
pClone->m_TargetData = m_TargetData;
return pClone;
}
-int32_t CFDE_XMLInstruction::CountAttributes() const {
- return pdfium::CollectionSize<int32_t>(m_Attributes) / 2;
-}
-
-bool CFDE_XMLInstruction::GetAttribute(int32_t index,
- CFX_WideString& wsAttriName,
- CFX_WideString& wsAttriValue) const {
- int32_t iCount = pdfium::CollectionSize<int32_t>(m_Attributes);
- ASSERT(index > -1 && index < iCount / 2);
- for (int32_t i = 0; i < iCount; i += 2) {
- if (index == 0) {
- wsAttriName = m_Attributes[i];
- wsAttriValue = m_Attributes[i + 1];
- return true;
- }
- index--;
- }
- return false;
-}
-
-bool CFDE_XMLInstruction::HasAttribute(const wchar_t* pwsAttriName) const {
- int32_t iCount = pdfium::CollectionSize<int32_t>(m_Attributes);
- for (int32_t i = 0; i < iCount; i += 2) {
- if (m_Attributes[i].Compare(pwsAttriName) == 0) {
- return true;
- }
- }
- return false;
-}
-
-void CFDE_XMLInstruction::GetString(const wchar_t* pwsAttriName,
- CFX_WideString& wsAttriValue,
- const wchar_t* pwsDefValue) const {
- int32_t iCount = pdfium::CollectionSize<int32_t>(m_Attributes);
- for (int32_t i = 0; i < iCount; i += 2) {
- if (m_Attributes[i].Compare(pwsAttriName) == 0) {
- wsAttriValue = m_Attributes[i + 1];
- return;
- }
- }
- wsAttriValue = pwsDefValue;
-}
-
-void CFDE_XMLInstruction::SetString(const CFX_WideString& wsAttriName,
- const CFX_WideString& wsAttriValue) {
- ASSERT(wsAttriName.GetLength() > 0);
- int32_t iCount = pdfium::CollectionSize<int32_t>(m_Attributes);
- for (int32_t i = 0; i < iCount; i += 2) {
- if (m_Attributes[i].Compare(wsAttriName) == 0) {
- m_Attributes[i] = wsAttriName;
- m_Attributes[i + 1] = wsAttriValue;
- return;
- }
- }
- m_Attributes.push_back(wsAttriName);
- m_Attributes.push_back(wsAttriValue);
-}
-
-int32_t CFDE_XMLInstruction::GetInteger(const wchar_t* pwsAttriName,
- int32_t iDefValue) const {
- int32_t iCount = pdfium::CollectionSize<int32_t>(m_Attributes);
- for (int32_t i = 0; i < iCount; i += 2) {
- if (m_Attributes[i].Compare(pwsAttriName) == 0) {
- return FXSYS_wtoi(m_Attributes[i + 1].c_str());
- }
- }
- return iDefValue;
-}
-
-void CFDE_XMLInstruction::SetInteger(const wchar_t* pwsAttriName,
- int32_t iAttriValue) {
- CFX_WideString wsValue;
- wsValue.Format(L"%d", iAttriValue);
- SetString(pwsAttriName, wsValue);
-}
-
-float CFDE_XMLInstruction::GetFloat(const wchar_t* pwsAttriName,
- float fDefValue) const {
- int32_t iCount = pdfium::CollectionSize<int32_t>(m_Attributes);
- for (int32_t i = 0; i < iCount; i += 2) {
- if (m_Attributes[i].Compare(pwsAttriName) == 0) {
- return FXSYS_wcstof(m_Attributes[i + 1].c_str(), -1, nullptr);
- }
- }
- return fDefValue;
-}
-
-void CFDE_XMLInstruction::SetFloat(const wchar_t* pwsAttriName,
- float fAttriValue) {
- CFX_WideString wsValue;
- wsValue.Format(L"%f", fAttriValue);
- SetString(pwsAttriName, wsValue);
-}
-
-void CFDE_XMLInstruction::RemoveAttribute(const wchar_t* pwsAttriName) {
- int32_t iCount = pdfium::CollectionSize<int32_t>(m_Attributes);
- for (int32_t i = 0; i < iCount; i += 2) {
- if (m_Attributes[i].Compare(pwsAttriName) == 0) {
- m_Attributes.erase(m_Attributes.begin() + i,
- m_Attributes.begin() + i + 2);
- return;
- }
- }
-}
-
-int32_t CFDE_XMLInstruction::CountData() const {
- return pdfium::CollectionSize<int32_t>(m_TargetData);
-}
-
-bool CFDE_XMLInstruction::GetData(int32_t index, CFX_WideString& wsData) const {
- if (!pdfium::IndexInBounds(m_TargetData, index))
- return false;
-
- wsData = m_TargetData[index];
- return true;
-}
-
void CFDE_XMLInstruction::AppendData(const CFX_WideString& wsData) {
m_TargetData.push_back(wsData);
}
diff --git a/xfa/fde/xml/cfde_xmlinstruction.h b/xfa/fde/xml/cfde_xmlinstruction.h
index 4e891e1fac..e9c4ad3dfe 100644
--- a/xfa/fde/xml/cfde_xmlinstruction.h
+++ b/xfa/fde/xml/cfde_xmlinstruction.h
@@ -11,9 +11,9 @@
#include <vector>
#include "core/fxcrt/fx_string.h"
-#include "xfa/fde/xml/cfde_xmlnode.h"
+#include "xfa/fde/xml/cfde_xmlattributenode.h"
-class CFDE_XMLInstruction : public CFDE_XMLNode {
+class CFDE_XMLInstruction : public CFDE_XMLAttributeNode {
public:
explicit CFDE_XMLInstruction(const CFX_WideString& wsTarget);
~CFDE_XMLInstruction() override;
@@ -22,29 +22,13 @@ class CFDE_XMLInstruction : public CFDE_XMLNode {
FDE_XMLNODETYPE GetType() const override;
std::unique_ptr<CFDE_XMLNode> Clone() override;
- void GetTargetName(CFX_WideString& wsTarget) const { wsTarget = m_wsTarget; }
- int32_t CountAttributes() const;
- bool GetAttribute(int32_t index,
- CFX_WideString& wsAttriName,
- CFX_WideString& wsAttriValue) const;
- bool HasAttribute(const wchar_t* pwsAttriName) const;
- void GetString(const wchar_t* pwsAttriName,
- CFX_WideString& wsAttriValue,
- const wchar_t* pwsDefValue = nullptr) const;
- void SetString(const CFX_WideString& wsAttriName,
- const CFX_WideString& wsAttriValue);
- int32_t GetInteger(const wchar_t* pwsAttriName, int32_t iDefValue = 0) const;
- void SetInteger(const wchar_t* pwsAttriName, int32_t iAttriValue);
- float GetFloat(const wchar_t* pwsAttriName, float fDefValue = 0) const;
- void SetFloat(const wchar_t* pwsAttriName, float fAttriValue);
- void RemoveAttribute(const wchar_t* pwsAttriName);
- int32_t CountData() const;
- bool GetData(int32_t index, CFX_WideString& wsData) const;
+ const std::vector<CFX_WideString>& GetTargetData() const {
+ return m_TargetData;
+ }
void AppendData(const CFX_WideString& wsData);
void RemoveData(int32_t index);
- CFX_WideString m_wsTarget;
- std::vector<CFX_WideString> m_Attributes;
+ private:
std::vector<CFX_WideString> m_TargetData;
};
diff --git a/xfa/fde/xml/cfde_xmlnode.cpp b/xfa/fde/xml/cfde_xmlnode.cpp
index 22bd262bf2..82db939a23 100644
--- a/xfa/fde/xml/cfde_xmlnode.cpp
+++ b/xfa/fde/xml/cfde_xmlnode.cpp
@@ -109,17 +109,17 @@ CFDE_XMLNode* CFDE_XMLNode::GetPath(const wchar_t* pPath,
CFDE_XMLNode* pNode = m_pChild;
while (pNode) {
if (pNode->GetType() == FDE_XMLNODE_Element) {
- if (bQualifiedName) {
- ((CFDE_XMLElement*)pNode)->GetTagName(wsTag);
- } else {
- ((CFDE_XMLElement*)pNode)->GetLocalTagName(wsTag);
- }
+ if (bQualifiedName)
+ wsTag = static_cast<CFDE_XMLElement*>(pNode)->GetName();
+ else
+ wsTag = static_cast<CFDE_XMLElement*>(pNode)->GetLocalTagName();
+
if (wsTag.Compare(csPath) == 0) {
- if (iLength < 1) {
+ if (iLength < 1)
pFind = pNode;
- } else {
+ else
pFind = pNode->GetPath(pStart, iLength, bQualifiedName);
- }
+
if (pFind)
return pFind;
}
@@ -335,7 +335,7 @@ void CFDE_XMLNode::SaveXMLNode(const CFX_RetainPtr<IFGAS_Stream>& pXMLStream) {
case FDE_XMLNODE_Instruction: {
CFX_WideString ws;
CFDE_XMLInstruction* pInstruction = (CFDE_XMLInstruction*)pNode;
- if (pInstruction->m_wsTarget.CompareNoCase(L"xml") == 0) {
+ if (pInstruction->GetName().CompareNoCase(L"xml") == 0) {
ws = L"<?xml version=\"1.0\" encoding=\"";
uint16_t wCodePage = pXMLStream->GetCodePage();
if (wCodePage == FX_CODEPAGE_UTF16LE) {
@@ -348,31 +348,28 @@ void CFDE_XMLNode::SaveXMLNode(const CFX_RetainPtr<IFGAS_Stream>& pXMLStream) {
ws += L"\"?>";
pXMLStream->WriteString(ws.c_str(), ws.GetLength());
} else {
- ws.Format(L"<?%s", pInstruction->m_wsTarget.c_str());
+ ws.Format(L"<?%s", pInstruction->GetName().c_str());
pXMLStream->WriteString(ws.c_str(), ws.GetLength());
- std::vector<CFX_WideString>& attributes = pInstruction->m_Attributes;
- int32_t i;
- int32_t iCount = pdfium::CollectionSize<int32_t>(attributes);
- CFX_WideString wsValue;
- for (i = 0; i < iCount; i += 2) {
- ws = L" ";
- ws += attributes[i];
- ws += L"=\"";
- wsValue = attributes[i + 1];
+
+ for (auto it : pInstruction->GetAttributes()) {
+ CFX_WideString wsValue = it.second;
wsValue.Replace(L"&", L"&amp;");
wsValue.Replace(L"<", L"&lt;");
wsValue.Replace(L">", L"&gt;");
wsValue.Replace(L"\'", L"&apos;");
wsValue.Replace(L"\"", L"&quot;");
+
+ ws = L" ";
+ ws += it.first;
+ ws += L"=\"";
ws += wsValue;
ws += L"\"";
pXMLStream->WriteString(ws.c_str(), ws.GetLength());
}
- std::vector<CFX_WideString>& targetdata = pInstruction->m_TargetData;
- iCount = pdfium::CollectionSize<int32_t>(targetdata);
- for (i = 0; i < iCount; i++) {
+
+ for (auto target : pInstruction->GetTargetData()) {
ws = L" \"";
- ws += targetdata[i];
+ ws += target;
ws += L"\"";
pXMLStream->WriteString(ws.c_str(), ws.GetLength());
}
@@ -384,22 +381,20 @@ void CFDE_XMLNode::SaveXMLNode(const CFX_RetainPtr<IFGAS_Stream>& pXMLStream) {
case FDE_XMLNODE_Element: {
CFX_WideString ws;
ws = L"<";
- ws += ((CFDE_XMLElement*)pNode)->m_wsTag;
+ ws += static_cast<CFDE_XMLElement*>(pNode)->GetName();
pXMLStream->WriteString(ws.c_str(), ws.GetLength());
- std::vector<CFX_WideString>& attributes =
- static_cast<CFDE_XMLElement*>(pNode)->m_Attributes;
- int32_t iCount = pdfium::CollectionSize<int32_t>(attributes);
- CFX_WideString wsValue;
- for (int32_t i = 0; i < iCount; i += 2) {
- ws = L" ";
- ws += attributes[i];
- ws += L"=\"";
- wsValue = attributes[i + 1];
+
+ for (auto it : static_cast<CFDE_XMLElement*>(pNode)->GetAttributes()) {
+ CFX_WideString wsValue = it.second;
wsValue.Replace(L"&", L"&amp;");
wsValue.Replace(L"<", L"&lt;");
wsValue.Replace(L">", L"&gt;");
wsValue.Replace(L"\'", L"&apos;");
wsValue.Replace(L"\"", L"&quot;");
+
+ ws = L" ";
+ ws += it.first;
+ ws += L"=\"";
ws += wsValue;
ws += L"\"";
pXMLStream->WriteString(ws.c_str(), ws.GetLength());
@@ -413,7 +408,7 @@ void CFDE_XMLNode::SaveXMLNode(const CFX_RetainPtr<IFGAS_Stream>& pXMLStream) {
pChild = pChild->m_pNext;
}
ws = L"</";
- ws += ((CFDE_XMLElement*)pNode)->m_wsTag;
+ ws += static_cast<CFDE_XMLElement*>(pNode)->GetName();
ws += L"\n>";
} else {
ws = L"\n/>";
diff --git a/xfa/fde/xml/cfde_xmlparser.cpp b/xfa/fde/xml/cfde_xmlparser.cpp
index db85021693..ad7b9e1a6f 100644
--- a/xfa/fde/xml/cfde_xmlparser.cpp
+++ b/xfa/fde/xml/cfde_xmlparser.cpp
@@ -64,7 +64,7 @@ int32_t CFDE_XMLParser::DoParser(IFX_Pause* pPause) {
break;
}
m_pParser->GetTagName(m_ws1);
- static_cast<CFDE_XMLElement*>(m_pChild)->GetTagName(m_ws2);
+ m_ws2 = static_cast<CFDE_XMLElement*>(m_pChild)->GetName();
if (m_ws1.GetLength() > 0 && m_ws1 != m_ws2) {
m_syntaxParserResult = FDE_XmlSyntaxResult::Error;
break;
@@ -102,8 +102,8 @@ int32_t CFDE_XMLParser::DoParser(IFX_Pause* pPause) {
m_pParent = m_pChild;
if (m_dwCheckStatus != 0x03 && m_NodeStack.size() == 3) {
- CFX_WideString wsTag;
- static_cast<CFDE_XMLElement*>(m_pChild)->GetLocalTagName(wsTag);
+ CFX_WideString wsTag =
+ static_cast<CFDE_XMLElement*>(m_pChild)->GetLocalTagName();
if (wsTag == L"template") {
m_dwCheckStatus |= 0x01;
m_dwCurrentCheckStatus = 0x01;
diff --git a/xfa/fxfa/app/cxfa_textlayout.cpp b/xfa/fxfa/app/cxfa_textlayout.cpp
index c32717b523..880bdf4585 100644
--- a/xfa/fxfa/app/cxfa_textlayout.cpp
+++ b/xfa/fxfa/app/cxfa_textlayout.cpp
@@ -81,8 +81,7 @@ CFDE_XMLNode* CXFA_TextLayout::GetXMLContainerNode() {
pXMLChild = pXMLChild->GetNodeItem(CFDE_XMLNode::NextSibling)) {
if (pXMLChild->GetType() == FDE_XMLNODE_Element) {
CFDE_XMLElement* pXMLElement = static_cast<CFDE_XMLElement*>(pXMLChild);
- CFX_WideString wsTag;
- pXMLElement->GetLocalTagName(wsTag);
+ CFX_WideString wsTag = pXMLElement->GetLocalTagName();
if (wsTag == L"body" || wsTag == L"html") {
pXMLContainer = pXMLChild;
break;
@@ -727,7 +726,7 @@ bool CXFA_TextLayout::LoadRichText(
bContentNode = true;
} else if (pXMLNode->GetType() == FDE_XMLNODE_Element) {
pElement = static_cast<CFDE_XMLElement*>(pXMLNode);
- pElement->GetLocalTagName(wsName);
+ wsName = pElement->GetLocalTagName();
}
if (wsName == L"ol") {
bIsOl = true;
@@ -757,9 +756,8 @@ bool CXFA_TextLayout::LoadRichText(
}
if (wsName == L"a") {
- CFX_WideString wsLinkContent;
ASSERT(pElement);
- pElement->GetString(L"href", wsLinkContent);
+ CFX_WideString wsLinkContent = pElement->GetString(L"href");
if (!wsLinkContent.IsEmpty()) {
pLinkData = pdfium::MakeRetain<CXFA_LinkUserData>(
wsLinkContent.GetBuffer(wsLinkContent.GetLength()));
diff --git a/xfa/fxfa/app/cxfa_textparser.cpp b/xfa/fxfa/app/cxfa_textparser.cpp
index b4032fa5c7..6f394dd5e2 100644
--- a/xfa/fxfa/app/cxfa_textparser.cpp
+++ b/xfa/fxfa/app/cxfa_textparser.cpp
@@ -277,12 +277,11 @@ std::unique_ptr<CXFA_CSSTagProvider> CXFA_TextParser::ParseTagInfo(
CFX_WideString wsName;
if (pXMLNode->GetType() == FDE_XMLNODE_Element) {
CFDE_XMLElement* pXMLElement = static_cast<CFDE_XMLElement*>(pXMLNode);
- pXMLElement->GetLocalTagName(wsName);
+ wsName = pXMLElement->GetLocalTagName();
tagProvider->SetTagName(wsName);
tagProvider->m_bTagAvailable = TagValidate(wsName);
- CFX_WideString wsValue;
- pXMLElement->GetString(L"style", wsValue);
+ CFX_WideString wsValue = pXMLElement->GetString(L"style");
if (!wsValue.IsEmpty())
tagProvider->SetAttribute(L"style", wsValue);
} else if (pXMLNode->GetType() == FDE_XMLNODE_Text) {
@@ -500,15 +499,13 @@ bool CXFA_TextParser::GetEmbbedObj(CXFA_TextProvider* pTextProvider,
bool bRet = false;
if (pXMLNode->GetType() == FDE_XMLNODE_Element) {
CFDE_XMLElement* pElement = static_cast<CFDE_XMLElement*>(pXMLNode);
- CFX_WideString wsAttr;
- pElement->GetString(L"xfa:embed", wsAttr);
+ CFX_WideString wsAttr = pElement->GetString(L"xfa:embed");
if (wsAttr.IsEmpty())
return false;
if (wsAttr.GetAt(0) == L'#')
wsAttr.Delete(0);
- CFX_WideString ws;
- pElement->GetString(L"xfa:embedType", ws);
+ CFX_WideString ws = pElement->GetString(L"xfa:embedType");
if (ws.IsEmpty())
ws = L"som";
else
@@ -518,8 +515,7 @@ bool CXFA_TextParser::GetEmbbedObj(CXFA_TextProvider* pTextProvider,
if (!bURI && ws != L"som")
return false;
- ws.clear();
- pElement->GetString(L"xfa:embedMode", ws);
+ ws = pElement->GetString(L"xfa:embedMode");
if (ws.IsEmpty())
ws = L"formatted";
else
diff --git a/xfa/fxfa/cxfa_ffdoc.cpp b/xfa/fxfa/cxfa_ffdoc.cpp
index 993f5bc664..47f089eee0 100644
--- a/xfa/fxfa/cxfa_ffdoc.cpp
+++ b/xfa/fxfa/cxfa_ffdoc.cpp
@@ -178,9 +178,8 @@ bool XFA_GetPDFContentsFromPDFXML(CFDE_XMLNode* pPDFElement,
pPDFElement->GetNodeItem(CFDE_XMLNode::FirstChild);
pXMLNode; pXMLNode = pXMLNode->GetNodeItem(CFDE_XMLNode::NextSibling)) {
if (pXMLNode->GetType() == FDE_XMLNODE_Element) {
- CFX_WideString wsTagName;
CFDE_XMLElement* pXMLElement = static_cast<CFDE_XMLElement*>(pXMLNode);
- pXMLElement->GetTagName(wsTagName);
+ CFX_WideString wsTagName = pXMLElement->GetName();
if (wsTagName == L"document") {
pDocumentElement = pXMLElement;
break;
@@ -195,9 +194,8 @@ bool XFA_GetPDFContentsFromPDFXML(CFDE_XMLNode* pPDFElement,
pDocumentElement->GetNodeItem(CFDE_XMLNode::FirstChild);
pXMLNode; pXMLNode = pXMLNode->GetNodeItem(CFDE_XMLNode::NextSibling)) {
if (pXMLNode->GetType() == FDE_XMLNODE_Element) {
- CFX_WideString wsTagName;
CFDE_XMLElement* pXMLElement = static_cast<CFDE_XMLElement*>(pXMLNode);
- pXMLElement->GetTagName(wsTagName);
+ CFX_WideString wsTagName = pXMLElement->GetName();
if (wsTagName == L"chunk") {
pChunkElement = pXMLElement;
break;
@@ -207,8 +205,7 @@ bool XFA_GetPDFContentsFromPDFXML(CFDE_XMLNode* pPDFElement,
if (!pChunkElement) {
return false;
}
- CFX_WideString wsPDFContent;
- pChunkElement->GetTextData(wsPDFContent);
+ CFX_WideString wsPDFContent = pChunkElement->GetTextData();
iBufferSize =
Base64DecodeW(wsPDFContent.c_str(), wsPDFContent.GetLength(), nullptr);
pByteBuffer = FX_Alloc(uint8_t, iBufferSize + 1);
diff --git a/xfa/fxfa/parser/cxfa_document.cpp b/xfa/fxfa/parser/cxfa_document.cpp
index 165c0a3ee5..7c979fec22 100644
--- a/xfa/fxfa/parser/cxfa_document.cpp
+++ b/xfa/fxfa/parser/cxfa_document.cpp
@@ -296,7 +296,7 @@ CXFA_ScriptContext* CXFA_Document::GetScriptContext() {
}
XFA_VERSION CXFA_Document::RecognizeXFAVersionNumber(
- CFX_WideString& wsTemplateNS) {
+ const CFX_WideString& wsTemplateNS) {
CFX_WideStringC wsTemplateURIPrefix =
XFA_GetPacketByIndex(XFA_PACKET_Template)->pURI;
FX_STRSIZE nPrefixLength = wsTemplateURIPrefix.GetLength();
diff --git a/xfa/fxfa/parser/cxfa_document.h b/xfa/fxfa/parser/cxfa_document.h
index 5d9ec1b430..101b23332e 100644
--- a/xfa/fxfa/parser/cxfa_document.h
+++ b/xfa/fxfa/parser/cxfa_document.h
@@ -87,7 +87,7 @@ class CXFA_Document {
bool IsInteractive();
XFA_VERSION GetCurVersionMode() { return m_eCurVersionMode; }
- XFA_VERSION RecognizeXFAVersionNumber(CFX_WideString& wsTemplateNS);
+ XFA_VERSION RecognizeXFAVersionNumber(const CFX_WideString& wsTemplateNS);
CXFA_Node* CreateNode(uint32_t dwPacket, XFA_Element eElement);
CXFA_Node* CreateNode(const XFA_PACKETINFO* pPacket, XFA_Element eElement);
diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp
index 2079127dc9..5ed013c259 100644
--- a/xfa/fxfa/parser/cxfa_node.cpp
+++ b/xfa/fxfa/parser/cxfa_node.cpp
@@ -3378,9 +3378,8 @@ void CXFA_Node::Script_Packet_GetAttribute(CFXJSE_Arguments* pArguments) {
CFX_WideString wsAttributeValue;
CFDE_XMLNode* pXMLNode = GetXMLMappingNode();
if (pXMLNode && pXMLNode->GetType() == FDE_XMLNODE_Element) {
- static_cast<CFDE_XMLElement*>(pXMLNode)->GetString(
- CFX_WideString::FromUTF8(bsAttributeName.AsStringC()).c_str(),
- wsAttributeValue);
+ wsAttributeValue = static_cast<CFDE_XMLElement*>(pXMLNode)->GetString(
+ CFX_WideString::FromUTF8(bsAttributeName.AsStringC()).c_str());
}
pArguments->GetReturnValue()->SetString(
wsAttributeValue.UTF8Encode().AsStringC());
@@ -3434,7 +3433,7 @@ void CXFA_Node::Script_Packet_Content(CFXJSE_Value* pValue,
CFDE_XMLNode* pXMLNode = GetXMLMappingNode();
if (pXMLNode && pXMLNode->GetType() == FDE_XMLNODE_Element) {
CFDE_XMLElement* pXMLElement = static_cast<CFDE_XMLElement*>(pXMLNode);
- pXMLElement->GetTextData(wsTextData);
+ wsTextData = pXMLElement->GetTextData();
}
pValue->SetString(wsTextData.UTF8Encode().AsStringC());
}
@@ -3981,10 +3980,14 @@ bool CXFA_Node::SetValue(XFA_ATTRIBUTE eAttr,
static_cast<CFDE_XMLElement*>(m_pXMLNode)
->SetString(pInfo->pName, pValue ? L"1" : L"0");
break;
- case XFA_ATTRIBUTETYPE_Integer:
+ case XFA_ATTRIBUTETYPE_Integer: {
+ CFX_WideString wsValue;
+ wsValue.Format(
+ L"%d", static_cast<int32_t>(reinterpret_cast<uintptr_t>(pValue)));
static_cast<CFDE_XMLElement*>(m_pXMLNode)
- ->SetInteger(pInfo->pName, (int32_t)(uintptr_t)pValue);
+ ->SetString(pInfo->pName, wsValue);
break;
+ }
default:
ASSERT(0);
}
@@ -4304,7 +4307,7 @@ bool CXFA_Node::TryNamespace(CFX_WideString& wsNamespace) {
if (!pXMLNode || pXMLNode->GetType() != FDE_XMLNODE_Element) {
return false;
}
- static_cast<CFDE_XMLElement*>(pXMLNode)->GetNamespaceURI(wsNamespace);
+ wsNamespace = static_cast<CFDE_XMLElement*>(pXMLNode)->GetNamespaceURI();
return true;
} else if (GetPacketID() == XFA_XDPPACKET_Datasets) {
CFDE_XMLNode* pXMLNode = GetXMLMappingNode();
@@ -4318,9 +4321,9 @@ bool CXFA_Node::TryNamespace(CFX_WideString& wsNamespace) {
GetEnum(XFA_ATTRIBUTE_Contains) == XFA_ATTRIBUTEENUM_MetaData) {
return XFA_FDEExtension_ResolveNamespaceQualifier(
static_cast<CFDE_XMLElement*>(pXMLNode),
- GetCData(XFA_ATTRIBUTE_QualifiedName), wsNamespace);
+ GetCData(XFA_ATTRIBUTE_QualifiedName), &wsNamespace);
}
- static_cast<CFDE_XMLElement*>(pXMLNode)->GetNamespaceURI(wsNamespace);
+ wsNamespace = static_cast<CFDE_XMLElement*>(pXMLNode)->GetNamespaceURI();
return true;
} else {
CXFA_Node* pModelNode = GetModelNode();
diff --git a/xfa/fxfa/parser/cxfa_simple_parser.cpp b/xfa/fxfa/parser/cxfa_simple_parser.cpp
index cb6a90d2a5..b3f1302eae 100644
--- a/xfa/fxfa/parser/cxfa_simple_parser.cpp
+++ b/xfa/fxfa/parser/cxfa_simple_parser.cpp
@@ -7,6 +7,7 @@
#include "xfa/fxfa/parser/cxfa_simple_parser.h"
#include <utility>
+#include <vector>
#include "core/fxcrt/cfx_checksumcontext.h"
#include "core/fxcrt/fx_ext.h"
@@ -54,14 +55,14 @@ CFDE_XMLNode* GetDocumentNode(CFDE_XMLDoc* pXMLDoc,
return nullptr;
}
-void GetElementTagNamespaceURI(CFDE_XMLElement* pElement,
- CFX_WideString& wsNamespaceURI) {
- CFX_WideString wsNodeStr;
- pElement->GetNamespacePrefix(wsNodeStr);
+CFX_WideString GetElementTagNamespaceURI(CFDE_XMLElement* pElement) {
+ CFX_WideString wsNodeStr = pElement->GetNamespacePrefix();
+ CFX_WideString wsNamespaceURI;
if (!XFA_FDEExtension_ResolveNamespaceQualifier(
- pElement, wsNodeStr.AsStringC(), wsNamespaceURI)) {
- wsNamespaceURI.clear();
+ pElement, wsNodeStr.AsStringC(), &wsNamespaceURI)) {
+ return CFX_WideString();
}
+ return wsNamespaceURI;
}
bool MatchNodeName(CFDE_XMLNode* pNode,
@@ -72,18 +73,18 @@ bool MatchNodeName(CFDE_XMLNode* pNode,
return false;
CFDE_XMLElement* pElement = reinterpret_cast<CFDE_XMLElement*>(pNode);
- CFX_WideString wsNodeStr;
- pElement->GetLocalTagName(wsNodeStr);
+ CFX_WideString wsNodeStr = pElement->GetLocalTagName();
if (wsNodeStr != wsLocalTagName)
return false;
- GetElementTagNamespaceURI(pElement, wsNodeStr);
+ wsNodeStr = GetElementTagNamespaceURI(pElement);
if (eMatchFlags & XFA_XDPPACKET_FLAGS_NOMATCH)
return true;
if (eMatchFlags & XFA_XDPPACKET_FLAGS_PREFIXMATCH) {
return wsNodeStr.Left(wsNamespaceURIPrefix.GetLength()) ==
wsNamespaceURIPrefix;
}
+
return wsNodeStr == wsNamespaceURIPrefix;
}
@@ -114,7 +115,7 @@ bool ResolveAttribute(CFDE_XMLElement* pElement,
return false;
}
if (!XFA_FDEExtension_ResolveNamespaceQualifier(
- pElement, wsNSPrefix.AsStringC(), wsNamespaceURI)) {
+ pElement, wsNSPrefix.AsStringC(), &wsNamespaceURI)) {
wsNamespaceURI.clear();
return false;
}
@@ -129,26 +130,23 @@ bool FindAttributeWithNS(CFDE_XMLElement* pElement,
if (!pElement)
return false;
- CFX_WideString wsAttrName;
- CFX_WideString wsAttrValue;
CFX_WideString wsAttrNS;
- for (int32_t iAttrCount = pElement->CountAttributes(), i = 0; i < iAttrCount;
- i++) {
- pElement->GetAttribute(i, wsAttrName, wsAttrValue);
- FX_STRSIZE iFind = wsAttrName.Find(L':', 0);
+ for (auto it : pElement->GetAttributes()) {
+ FX_STRSIZE iFind = it.first.Find(L':', 0);
CFX_WideString wsNSPrefix;
if (iFind < 0) {
- if (wsLocalAttributeName != wsAttrName)
+ if (wsLocalAttributeName != it.first)
continue;
} else {
if (wsLocalAttributeName !=
- wsAttrName.Right(wsAttrName.GetLength() - iFind - 1)) {
+ it.first.Right(it.first.GetLength() - iFind - 1)) {
continue;
}
- wsNSPrefix = wsAttrName.Left(iFind);
+ wsNSPrefix = it.first.Left(iFind);
}
+
if (!XFA_FDEExtension_ResolveNamespaceQualifier(
- pElement, wsNSPrefix.AsStringC(), wsAttrNS)) {
+ pElement, wsNSPrefix.AsStringC(), &wsAttrNS)) {
continue;
}
if (bMatchNSAsPrefix) {
@@ -160,7 +158,7 @@ bool FindAttributeWithNS(CFDE_XMLElement* pElement,
if (wsAttrNS != wsNamespaceURIPrefix)
continue;
}
- wsValue = wsAttrValue;
+ wsValue = it.second;
return true;
}
return false;
@@ -207,8 +205,8 @@ void ConvertXMLToPlainText(CFDE_XMLElement* pRootXMLNode,
pXMLChild = pXMLChild->GetNodeItem(CFDE_XMLNode::NextSibling)) {
switch (pXMLChild->GetType()) {
case FDE_XMLNODE_Element: {
- CFX_WideString wsTextData;
- static_cast<CFDE_XMLElement*>(pXMLChild)->GetTextData(wsTextData);
+ CFX_WideString wsTextData =
+ static_cast<CFDE_XMLElement*>(pXMLChild)->GetTextData();
wsTextData += L"\n";
wsOutput += wsTextData;
break;
@@ -253,13 +251,8 @@ const XFA_PACKETINFO* GetPacketByName(const CFX_WideStringC& wsName) {
} // namespace
bool XFA_RecognizeRichText(CFDE_XMLElement* pRichTextXMLNode) {
- if (pRichTextXMLNode) {
- CFX_WideString wsNamespaceURI;
- GetElementTagNamespaceURI(pRichTextXMLNode, wsNamespaceURI);
- if (wsNamespaceURI == L"http://www.w3.org/1999/xhtml")
- return true;
- }
- return false;
+ return pRichTextXMLNode && GetElementTagNamespaceURI(pRichTextXMLNode) ==
+ L"http://www.w3.org/1999/xhtml";
}
CXFA_SimpleParser::CXFA_SimpleParser(CXFA_Document* pFactory,
@@ -318,6 +311,7 @@ int32_t CXFA_SimpleParser::DoParse(IFX_Pause* pPause) {
m_pRootNode = ParseAsXDPPacket(GetDocumentNode(m_pXMLDoc.get()), m_ePacketID);
m_pXMLDoc->CloseXML();
m_pStream.Reset();
+
if (!m_pRootNode)
return XFA_PARSESTATUS_StatusErr;
@@ -368,9 +362,8 @@ void CXFA_SimpleParser::ConstructXFANode(CXFA_Node* pXFANode,
if (!pXFAChild)
return;
- CFX_WideString wsNodeStr;
CFDE_XMLElement* child = static_cast<CFDE_XMLElement*>(pXMLChild);
- child->GetLocalTagName(wsNodeStr);
+ CFX_WideString wsNodeStr = child->GetLocalTagName();
pXFAChild->SetCData(XFA_ATTRIBUTE_Name, wsNodeStr);
CFX_WideString wsChildValue;
XFA_GetPlainTextFromRichText(child, wsChildValue);
@@ -406,7 +399,7 @@ CFDE_XMLDoc* CXFA_SimpleParser::GetXMLDoc() const {
bool XFA_FDEExtension_ResolveNamespaceQualifier(
CFDE_XMLElement* pNode,
const CFX_WideStringC& wsQualifier,
- CFX_WideString& wsNamespaceURI) {
+ CFX_WideString* wsNamespaceURI) {
if (!pNode)
return false;
@@ -425,11 +418,11 @@ bool XFA_FDEExtension_ResolveNamespaceQualifier(
continue;
if (pNode->HasAttribute(wsNSAttribute.c_str())) {
- pNode->GetString(wsNSAttribute.c_str(), wsNamespaceURI);
+ *wsNamespaceURI = pNode->GetString(wsNSAttribute.c_str());
return true;
}
}
- wsNamespaceURI.clear();
+ wsNamespaceURI->clear();
return bRet;
}
@@ -468,6 +461,7 @@ CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_XDP(
XFA_GetPacketByIndex(XFA_PACKET_XDP)->eFlags)) {
return nullptr;
}
+
CXFA_Node* pXFARootNode =
m_pFactory->CreateNode(XFA_XDPPACKET_XDP, XFA_Element::Xfa);
if (!pXFARootNode)
@@ -475,109 +469,98 @@ CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_XDP(
m_pRootNode = pXFARootNode;
pXFARootNode->SetCData(XFA_ATTRIBUTE_Name, L"xfa");
- {
- CFDE_XMLElement* pElement = static_cast<CFDE_XMLElement*>(pXMLDocumentNode);
- int32_t iAttributeCount = pElement->CountAttributes();
- for (int32_t i = 0; i < iAttributeCount; i++) {
- CFX_WideString wsAttriName, wsAttriValue;
- pElement->GetAttribute(i, wsAttriName, wsAttriValue);
- if (wsAttriName == L"uuid")
- pXFARootNode->SetCData(XFA_ATTRIBUTE_Uuid, wsAttriValue);
- else if (wsAttriName == L"timeStamp")
- pXFARootNode->SetCData(XFA_ATTRIBUTE_TimeStamp, wsAttriValue);
- }
+
+ CFDE_XMLElement* pElement = static_cast<CFDE_XMLElement*>(pXMLDocumentNode);
+ for (auto it : pElement->GetAttributes()) {
+ if (it.first == L"uuid")
+ pXFARootNode->SetCData(XFA_ATTRIBUTE_Uuid, it.second);
+ else if (it.first == L"timeStamp")
+ pXFARootNode->SetCData(XFA_ATTRIBUTE_TimeStamp, it.second);
}
CFDE_XMLNode* pXMLConfigDOMRoot = nullptr;
CXFA_Node* pXFAConfigDOMRoot = nullptr;
- {
- for (CFDE_XMLNode* pChildItem =
- pXMLDocumentNode->GetNodeItem(CFDE_XMLNode::FirstChild);
- pChildItem;
- pChildItem = pChildItem->GetNodeItem(CFDE_XMLNode::NextSibling)) {
- const XFA_PACKETINFO* pPacketInfo =
- XFA_GetPacketByIndex(XFA_PACKET_Config);
- if (!MatchNodeName(pChildItem, pPacketInfo->pName, pPacketInfo->pURI,
- pPacketInfo->eFlags)) {
- continue;
- }
- if (pXFARootNode->GetFirstChildByName(pPacketInfo->uHash)) {
- return nullptr;
- }
- pXMLConfigDOMRoot = pChildItem;
- pXFAConfigDOMRoot =
- ParseAsXDPPacket_Config(pXMLConfigDOMRoot, XFA_XDPPACKET_Config);
- pXFARootNode->InsertChild(pXFAConfigDOMRoot, nullptr);
+ for (CFDE_XMLNode* pChildItem =
+ pXMLDocumentNode->GetNodeItem(CFDE_XMLNode::FirstChild);
+ pChildItem;
+ pChildItem = pChildItem->GetNodeItem(CFDE_XMLNode::NextSibling)) {
+ const XFA_PACKETINFO* pPacketInfo = XFA_GetPacketByIndex(XFA_PACKET_Config);
+ if (!MatchNodeName(pChildItem, pPacketInfo->pName, pPacketInfo->pURI,
+ pPacketInfo->eFlags)) {
+ continue;
}
+ if (pXFARootNode->GetFirstChildByName(pPacketInfo->uHash))
+ return nullptr;
+
+ pXMLConfigDOMRoot = pChildItem;
+ pXFAConfigDOMRoot =
+ ParseAsXDPPacket_Config(pXMLConfigDOMRoot, XFA_XDPPACKET_Config);
+ pXFARootNode->InsertChild(pXFAConfigDOMRoot, nullptr);
}
CFDE_XMLNode* pXMLDatasetsDOMRoot = nullptr;
CFDE_XMLNode* pXMLFormDOMRoot = nullptr;
CFDE_XMLNode* pXMLTemplateDOMRoot = nullptr;
- {
- for (CFDE_XMLNode* pChildItem =
- pXMLDocumentNode->GetNodeItem(CFDE_XMLNode::FirstChild);
- pChildItem;
- pChildItem = pChildItem->GetNodeItem(CFDE_XMLNode::NextSibling)) {
- if (!pChildItem || pChildItem->GetType() != FDE_XMLNODE_Element)
- continue;
- if (pChildItem == pXMLConfigDOMRoot)
- continue;
+ for (CFDE_XMLNode* pChildItem =
+ pXMLDocumentNode->GetNodeItem(CFDE_XMLNode::FirstChild);
+ pChildItem;
+ pChildItem = pChildItem->GetNodeItem(CFDE_XMLNode::NextSibling)) {
+ if (!pChildItem || pChildItem->GetType() != FDE_XMLNODE_Element)
+ continue;
+ if (pChildItem == pXMLConfigDOMRoot)
+ continue;
- CFDE_XMLElement* pElement =
- reinterpret_cast<CFDE_XMLElement*>(pChildItem);
- CFX_WideString wsPacketName;
- pElement->GetLocalTagName(wsPacketName);
- const XFA_PACKETINFO* pPacketInfo =
- GetPacketByName(wsPacketName.AsStringC());
- if (pPacketInfo && pPacketInfo->pURI) {
- if (!MatchNodeName(pElement, pPacketInfo->pName, pPacketInfo->pURI,
- pPacketInfo->eFlags)) {
- pPacketInfo = nullptr;
- }
+ CFDE_XMLElement* pElement = reinterpret_cast<CFDE_XMLElement*>(pChildItem);
+ CFX_WideString wsPacketName = pElement->GetLocalTagName();
+ const XFA_PACKETINFO* pPacketInfo =
+ GetPacketByName(wsPacketName.AsStringC());
+ if (pPacketInfo && pPacketInfo->pURI) {
+ if (!MatchNodeName(pElement, pPacketInfo->pName, pPacketInfo->pURI,
+ pPacketInfo->eFlags)) {
+ pPacketInfo = nullptr;
}
- XFA_XDPPACKET ePacket =
- pPacketInfo ? pPacketInfo->eName : XFA_XDPPACKET_USER;
- if (ePacket == XFA_XDPPACKET_XDP)
- continue;
- if (ePacket == XFA_XDPPACKET_Datasets) {
- if (pXMLDatasetsDOMRoot)
- return nullptr;
+ }
+ XFA_XDPPACKET ePacket =
+ pPacketInfo ? pPacketInfo->eName : XFA_XDPPACKET_USER;
+ if (ePacket == XFA_XDPPACKET_XDP)
+ continue;
+ if (ePacket == XFA_XDPPACKET_Datasets) {
+ if (pXMLDatasetsDOMRoot)
+ return nullptr;
- pXMLDatasetsDOMRoot = pElement;
- } else if (ePacket == XFA_XDPPACKET_Form) {
- if (pXMLFormDOMRoot)
- return nullptr;
+ pXMLDatasetsDOMRoot = pElement;
+ } else if (ePacket == XFA_XDPPACKET_Form) {
+ if (pXMLFormDOMRoot)
+ return nullptr;
- pXMLFormDOMRoot = pElement;
- } else if (ePacket == XFA_XDPPACKET_Template) {
- if (pXMLTemplateDOMRoot) {
- // Found a duplicate template packet.
+ pXMLFormDOMRoot = pElement;
+ } else if (ePacket == XFA_XDPPACKET_Template) {
+ // Found a duplicate template packet.
+ if (pXMLTemplateDOMRoot)
+ return nullptr;
+
+ CXFA_Node* pPacketNode = ParseAsXDPPacket(pElement, ePacket);
+ if (pPacketNode) {
+ pXMLTemplateDOMRoot = pElement;
+ pXFARootNode->InsertChild(pPacketNode);
+ }
+ } else {
+ CXFA_Node* pPacketNode = ParseAsXDPPacket(pElement, ePacket);
+ if (pPacketNode) {
+ if (pPacketInfo &&
+ (pPacketInfo->eFlags & XFA_XDPPACKET_FLAGS_SUPPORTONE) &&
+ pXFARootNode->GetFirstChildByName(pPacketInfo->uHash)) {
return nullptr;
}
- CXFA_Node* pPacketNode = ParseAsXDPPacket(pElement, ePacket);
- if (pPacketNode) {
- pXMLTemplateDOMRoot = pElement;
- pXFARootNode->InsertChild(pPacketNode);
- }
- } else {
- CXFA_Node* pPacketNode = ParseAsXDPPacket(pElement, ePacket);
- if (pPacketNode) {
- if (pPacketInfo &&
- (pPacketInfo->eFlags & XFA_XDPPACKET_FLAGS_SUPPORTONE) &&
- pXFARootNode->GetFirstChildByName(pPacketInfo->uHash)) {
- return nullptr;
- }
- pXFARootNode->InsertChild(pPacketNode);
- }
+ pXFARootNode->InsertChild(pPacketNode);
}
}
}
- if (!pXMLTemplateDOMRoot) {
- // No template is found.
+ // No template is found.
+ if (!pXMLTemplateDOMRoot)
return nullptr;
- }
+
if (pXMLDatasetsDOMRoot) {
CXFA_Node* pPacketNode =
ParseAsXDPPacket(pXMLDatasetsDOMRoot, XFA_XDPPACKET_Datasets);
@@ -590,6 +573,7 @@ CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_XDP(
if (pPacketNode)
pXFARootNode->InsertChild(pPacketNode);
}
+
pXFARootNode->SetXMLMappingNode(pXMLDocumentNode);
return pXFARootNode;
}
@@ -634,12 +618,11 @@ CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_TemplateForm(
pNode->SetCData(XFA_ATTRIBUTE_Name,
XFA_GetPacketByIndex(XFA_PACKET_Template)->pName);
if (m_bDocumentParser) {
- CFX_WideString wsNamespaceURI;
CFDE_XMLElement* pXMLDocumentElement =
static_cast<CFDE_XMLElement*>(pXMLDocumentNode);
- pXMLDocumentElement->GetNamespaceURI(wsNamespaceURI);
+ CFX_WideString wsNamespaceURI = pXMLDocumentElement->GetNamespaceURI();
if (wsNamespaceURI.IsEmpty())
- pXMLDocumentElement->GetString(L"xmlns:xfa", wsNamespaceURI);
+ wsNamespaceURI = pXMLDocumentElement->GetString(L"xmlns:xfa");
pNode->GetDocument()->RecognizeXFAVersionNumber(wsNamespaceURI);
}
@@ -653,8 +636,7 @@ CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_TemplateForm(
XFA_GetPacketByIndex(XFA_PACKET_Form)->eFlags)) {
CFDE_XMLElement* pXMLDocumentElement =
static_cast<CFDE_XMLElement*>(pXMLDocumentNode);
- CFX_WideString wsChecksum;
- pXMLDocumentElement->GetString(L"checksum", wsChecksum);
+ CFX_WideString wsChecksum = pXMLDocumentElement->GetString(L"checksum");
if (wsChecksum.GetLength() != 28 ||
m_pXMLParser->m_dwCheckStatus != 0x03) {
return nullptr;
@@ -750,8 +732,8 @@ CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_Data(
delete pDataXMLNode;
return nullptr;
}
- CFX_WideString wsLocalName;
- static_cast<CFDE_XMLElement*>(pDataXMLNode)->GetLocalTagName(wsLocalName);
+ CFX_WideString wsLocalName =
+ static_cast<CFDE_XMLElement*>(pDataXMLNode)->GetLocalTagName();
pNode->SetCData(XFA_ATTRIBUTE_Name, wsLocalName);
if (!DataLoader(pNode, pDataXMLNode, true))
return nullptr;
@@ -847,8 +829,8 @@ CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_User(
if (!pNode)
return nullptr;
- CFX_WideString wsName;
- static_cast<CFDE_XMLElement*>(pXMLDocumentNode)->GetLocalTagName(wsName);
+ CFX_WideString wsName =
+ static_cast<CFDE_XMLElement*>(pXMLDocumentNode)->GetLocalTagName();
pNode->SetCData(XFA_ATTRIBUTE_Name, wsName);
if (!UserPacketLoader(pNode, pXMLDocumentNode))
return nullptr;
@@ -880,8 +862,7 @@ CXFA_Node* CXFA_SimpleParser::NormalLoader(CXFA_Node* pXFANode,
switch (pXMLChild->GetType()) {
case FDE_XMLNODE_Element: {
CFDE_XMLElement* pXMLElement = static_cast<CFDE_XMLElement*>(pXMLChild);
- CFX_WideString wsTagName;
- pXMLElement->GetLocalTagName(wsTagName);
+ CFX_WideString wsTagName = pXMLElement->GetLocalTagName();
XFA_Element eType = XFA_GetElementTypeForName(wsTagName.AsStringC());
if (eType == XFA_Element::Unknown)
continue;
@@ -903,16 +884,12 @@ CXFA_Node* CXFA_SimpleParser::NormalLoader(CXFA_Node* pXFANode,
pXFAChild->SetAttribute(XFA_ATTRIBUTE_Name, wsTagName.AsStringC());
bool IsNeedValue = true;
- for (int32_t i = 0, count = pXMLElement->CountAttributes(); i < count;
- i++) {
- CFX_WideString wsAttrQualifiedName;
+ for (auto it : pXMLElement->GetAttributes()) {
CFX_WideString wsAttrName;
- CFX_WideString wsAttrValue;
- pXMLElement->GetAttribute(i, wsAttrQualifiedName, wsAttrValue);
- GetAttributeLocalName(wsAttrQualifiedName.AsStringC(), wsAttrName);
- if (wsAttrName == L"nil" && wsAttrValue == L"true") {
+ GetAttributeLocalName(it.first.AsStringC(), wsAttrName);
+ if (wsAttrName == L"nil" && it.second == L"true")
IsNeedValue = false;
- }
+
const XFA_ATTRIBUTEINFO* lpAttrInfo =
XFA_GetAttributeByName(wsAttrName.AsStringC());
if (!lpAttrInfo)
@@ -922,7 +899,7 @@ CXFA_Node* CXFA_SimpleParser::NormalLoader(CXFA_Node* pXFANode,
lpAttrInfo->eName != XFA_ATTRIBUTE_Save) {
continue;
}
- pXFAChild->SetAttribute(lpAttrInfo->eName, wsAttrValue.AsStringC());
+ pXFAChild->SetAttribute(lpAttrInfo->eName, it.second.AsStringC());
}
pXFANode->InsertChild(pXFAChild);
if (eType == XFA_Element::Validate || eType == XFA_Element::Locale) {
@@ -1025,8 +1002,8 @@ void CXFA_SimpleParser::ParseDataGroup(CXFA_Node* pXFANode,
case FDE_XMLNODE_Element: {
CFDE_XMLElement* pXMLElement = static_cast<CFDE_XMLElement*>(pXMLChild);
{
- CFX_WideString wsNamespaceURI;
- GetElementTagNamespaceURI(pXMLElement, wsNamespaceURI);
+ CFX_WideString wsNamespaceURI =
+ GetElementTagNamespaceURI(pXMLElement);
if (wsNamespaceURI == L"http://www.xfa.com/schema/xfa-package/" ||
wsNamespaceURI == L"http://www.xfa.org/schema/xfa-package/" ||
wsNamespaceURI == L"http://www.w3.org/2001/XMLSchema-instance") {
@@ -1077,21 +1054,17 @@ void CXFA_SimpleParser::ParseDataGroup(CXFA_Node* pXFANode,
if (!pXFAChild)
return;
- CFX_WideString wsNodeName;
- pXMLElement->GetLocalTagName(wsNodeName);
- pXFAChild->SetCData(XFA_ATTRIBUTE_Name, wsNodeName);
+ pXFAChild->SetCData(XFA_ATTRIBUTE_Name, pXMLElement->GetLocalTagName());
bool bNeedValue = true;
- for (int32_t i = 0; i < pXMLElement->CountAttributes(); ++i) {
- CFX_WideString wsQualifiedName;
- CFX_WideString wsValue;
+
+ for (auto it : pXMLElement->GetAttributes()) {
CFX_WideString wsName;
CFX_WideString wsNS;
- pXMLElement->GetAttribute(i, wsQualifiedName, wsValue);
- if (!ResolveAttribute(pXMLElement, wsQualifiedName.AsStringC(),
- wsName, wsNS)) {
+ if (!ResolveAttribute(pXMLElement, it.first.AsStringC(), wsName,
+ wsNS)) {
continue;
}
- if (wsName == L"nil" && wsValue == L"true") {
+ if (wsName == L"nil" && it.second == L"true") {
bNeedValue = false;
continue;
}
@@ -1107,8 +1080,8 @@ void CXFA_SimpleParser::ParseDataGroup(CXFA_Node* pXFANode,
return;
pXFAMetaData->SetCData(XFA_ATTRIBUTE_Name, wsName);
- pXFAMetaData->SetCData(XFA_ATTRIBUTE_QualifiedName, wsQualifiedName);
- pXFAMetaData->SetCData(XFA_ATTRIBUTE_Value, wsValue);
+ pXFAMetaData->SetCData(XFA_ATTRIBUTE_QualifiedName, it.first);
+ pXFAMetaData->SetCData(XFA_ATTRIBUTE_Value, it.second);
pXFAMetaData->SetEnum(XFA_ATTRIBUTE_Contains,
XFA_ATTRIBUTEENUM_MetaData);
pXFAChild->InsertChild(pXFAMetaData);
@@ -1209,8 +1182,8 @@ void CXFA_SimpleParser::ParseDataValue(CXFA_Node* pXFANode,
if (!pXFAChild)
return;
- CFX_WideString wsNodeStr;
- static_cast<CFDE_XMLElement*>(pXMLChild)->GetLocalTagName(wsNodeStr);
+ CFX_WideString wsNodeStr =
+ static_cast<CFDE_XMLElement*>(pXMLChild)->GetLocalTagName();
pXFAChild->SetCData(XFA_ATTRIBUTE_Name, wsNodeStr);
ParseDataValue(pXFAChild, pXMLChild, ePacketID);
pXFANode->InsertChild(pXFAChild);
@@ -1250,25 +1223,20 @@ void CXFA_SimpleParser::ParseInstruction(CXFA_Node* pXFANode,
if (!m_bDocumentParser)
return;
- CFX_WideString wsTargetName;
- pXMLInstruction->GetTargetName(wsTargetName);
+ CFX_WideString wsTargetName = pXMLInstruction->GetName();
+ const std::vector<CFX_WideString>& target_data =
+ pXMLInstruction->GetTargetData();
if (wsTargetName == L"originalXFAVersion") {
- CFX_WideString wsData;
- if (pXMLInstruction->GetData(0, wsData) &&
- (pXFANode->GetDocument()->RecognizeXFAVersionNumber(wsData) !=
- XFA_VERSION_UNKNOWN)) {
- wsData.clear();
- if (pXMLInstruction->GetData(1, wsData) &&
- wsData == L"v2.7-scripting:1") {
- pXFANode->GetDocument()->SetFlag(XFA_DOCFLAG_Scripting, true);
- }
+ if (target_data.size() > 1 &&
+ (pXFANode->GetDocument()->RecognizeXFAVersionNumber(target_data[0]) !=
+ XFA_VERSION_UNKNOWN) &&
+ target_data[1] == L"v2.7-scripting:1") {
+ pXFANode->GetDocument()->SetFlag(XFA_DOCFLAG_Scripting, true);
}
} else if (wsTargetName == L"acrobat") {
- CFX_WideString wsData;
- if (pXMLInstruction->GetData(0, wsData) && wsData == L"JavaScript") {
- if (pXMLInstruction->GetData(1, wsData) && wsData == L"strictScoping") {
- pXFANode->GetDocument()->SetFlag(XFA_DOCFLAG_StrictScoping, true);
- }
+ if (target_data.size() > 1 && target_data[0] == L"JavaScript" &&
+ target_data[1] == L"strictScoping") {
+ pXFANode->GetDocument()->SetFlag(XFA_DOCFLAG_StrictScoping, true);
}
}
}
diff --git a/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp b/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp
index eb16628a2e..82aec1f00d 100644
--- a/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp
+++ b/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp
@@ -284,14 +284,15 @@ void CreateDataBinding(CXFA_Node* pFormNode,
CFDE_XMLElement* pXMLDataElement =
static_cast<CFDE_XMLElement*>(pDataNode->GetXMLMappingNode());
ASSERT(pXMLDataElement);
- CFX_WideString wsContentType;
- CFX_WideString wsHref;
- pXMLDataElement->GetString(L"xfa:contentType", wsContentType);
+
+ CFX_WideString wsContentType =
+ pXMLDataElement->GetString(L"xfa:contentType");
if (!wsContentType.IsEmpty()) {
pDataNode->SetCData(XFA_ATTRIBUTE_ContentType, wsContentType);
image.SetContentType(wsContentType);
}
- pXMLDataElement->GetString(L"href", wsHref);
+
+ CFX_WideString wsHref = pXMLDataElement->GetString(L"href");
if (!wsHref.IsEmpty())
image.SetHref(wsHref);
}
diff --git a/xfa/fxfa/parser/xfa_utils.cpp b/xfa/fxfa/parser/xfa_utils.cpp
index 57d97519a1..6bd04c322f 100644
--- a/xfa/fxfa/parser/xfa_utils.cpp
+++ b/xfa/fxfa/parser/xfa_utils.cpp
@@ -177,8 +177,7 @@ void XFA_GetPlainTextFromRichText(CFDE_XMLNode* pXMLNode,
switch (pXMLNode->GetType()) {
case FDE_XMLNODE_Element: {
CFDE_XMLElement* pXMLElement = static_cast<CFDE_XMLElement*>(pXMLNode);
- CFX_WideString wsTag;
- pXMLElement->GetLocalTagName(wsTag);
+ CFX_WideString wsTag = pXMLElement->GetLocalTagName();
uint32_t uTag = FX_HashCode_GetW(wsTag.AsStringC(), true);
if (uTag == 0x0001f714) {
wsPlainText += L"\n";
diff --git a/xfa/fxfa/parser/xfa_utils.h b/xfa/fxfa/parser/xfa_utils.h
index d4461a39a7..36d62c7602 100644
--- a/xfa/fxfa/parser/xfa_utils.h
+++ b/xfa/fxfa/parser/xfa_utils.h
@@ -22,7 +22,7 @@ int XFA_GetMaxFractionalScale();
bool XFA_FDEExtension_ResolveNamespaceQualifier(
CFDE_XMLElement* pNode,
const CFX_WideStringC& wsQualifier,
- CFX_WideString& wsNamespaceURI);
+ CFX_WideString* wsNamespaceURI);
template <class NodeType, class TraverseStrategy>
class CXFA_NodeIteratorTemplate {