diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2017-04-05 11:48:21 -0400 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-04-05 16:10:44 +0000 |
commit | 5fa4e981ed6c431d86c51a74eba19ea4b816f541 (patch) | |
tree | 4bfa4afc2b89e1a423ec4838937042780eaa6191 /xfa/fxfa/parser/cxfa_node.cpp | |
parent | ddcb6e7f47e2769fb4565bd4430ecb465a1f5417 (diff) | |
download | pdfium-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/fxfa/parser/cxfa_node.cpp')
-rw-r--r-- | xfa/fxfa/parser/cxfa_node.cpp | 21 |
1 files changed, 12 insertions, 9 deletions
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(); |