From 5fa4e981ed6c431d86c51a74eba19ea4b816f541 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Wed, 5 Apr 2017 11:48:21 -0400 Subject: Move XML attribute handling to a base class. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Commit-Queue: dsinclair --- xfa/fxfa/parser/cxfa_node.cpp | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'xfa/fxfa/parser/cxfa_node.cpp') 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(pXMLNode)->GetString( - CFX_WideString::FromUTF8(bsAttributeName.AsStringC()).c_str(), - wsAttributeValue); + wsAttributeValue = static_cast(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(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(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(reinterpret_cast(pValue))); static_cast(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(pXMLNode)->GetNamespaceURI(wsNamespace); + wsNamespace = static_cast(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(pXMLNode), - GetCData(XFA_ATTRIBUTE_QualifiedName), wsNamespace); + GetCData(XFA_ATTRIBUTE_QualifiedName), &wsNamespace); } - static_cast(pXMLNode)->GetNamespaceURI(wsNamespace); + wsNamespace = static_cast(pXMLNode)->GetNamespaceURI(); return true; } else { CXFA_Node* pModelNode = GetModelNode(); -- cgit v1.2.3