From f351ba03ebf31103c0a6a0c00b1477d39c060139 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Mon, 27 Nov 2017 18:28:06 +0000 Subject: Add some helpers for attribute lookup This CL adds helpers to CXFA_Node to convert from strings to attributes and from attributes to their string names. A static_assert was added to make sure the list of attributes is the same size as the attribute data so the checks can be removed. Change-Id: Idebc65021d71f604bcf498e4cf42252af00d802b Reviewed-on: https://pdfium-review.googlesource.com/19270 Reviewed-by: Henrique Nakashima Commit-Queue: dsinclair --- xfa/fxfa/parser/cxfa_dataexporter.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'xfa/fxfa/parser/cxfa_dataexporter.cpp') diff --git a/xfa/fxfa/parser/cxfa_dataexporter.cpp b/xfa/fxfa/parser/cxfa_dataexporter.cpp index f28649fffa..edb7e1e186 100644 --- a/xfa/fxfa/parser/cxfa_dataexporter.cpp +++ b/xfa/fxfa/parser/cxfa_dataexporter.cpp @@ -87,7 +87,7 @@ WideString ExportEncodeContent(const WideString& str) { void SaveAttribute(CXFA_Node* pNode, XFA_Attribute eName, - const WideStringView& wsName, + const WideString& wsName, bool bProto, WideString& wsOutput) { if (!bProto && !pNode->JSNode()->HasAttribute(eName)) @@ -175,13 +175,13 @@ void RegenerateFormFile_Changed(CXFA_Node* pNode, if (attr == XFA_Attribute::Unknown) break; - const XFA_ATTRIBUTEINFO* pAttr = XFA_GetAttributeByID(attr); - if (pAttr->eName == XFA_Attribute::Name || - (AttributeSaveInDataModel(pNode, pAttr->eName) && !bSaveXML)) { + if (attr == XFA_Attribute::Name || + (AttributeSaveInDataModel(pNode, attr) && !bSaveXML)) { continue; } WideString wsAttr; - SaveAttribute(pNode, pAttr->eName, pAttr->pName, bSaveXML, wsAttr); + SaveAttribute(pNode, attr, CXFA_Node::AttributeToName(attr), bSaveXML, + wsAttr); wsAttrs += wsAttr; } @@ -360,13 +360,11 @@ void RegenerateFormFile_Container( XFA_Attribute attr = pNode->GetAttribute(i); if (attr == XFA_Attribute::Unknown) break; - - const XFA_ATTRIBUTEINFO* pAttr = XFA_GetAttributeByID(attr); - if (pAttr->eName == XFA_Attribute::Name) + if (attr == XFA_Attribute::Name) continue; WideString wsAttr; - SaveAttribute(pNode, pAttr->eName, pAttr->pName, false, wsAttr); + SaveAttribute(pNode, attr, CXFA_Node::AttributeToName(attr), false, wsAttr); wsOutput += wsAttr; } -- cgit v1.2.3