summaryrefslogtreecommitdiff
path: root/xfa/fxfa/parser/cxfa_node.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'xfa/fxfa/parser/cxfa_node.cpp')
-rw-r--r--xfa/fxfa/parser/cxfa_node.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp
index 99f0eea5a8..f24bddb990 100644
--- a/xfa/fxfa/parser/cxfa_node.cpp
+++ b/xfa/fxfa/parser/cxfa_node.cpp
@@ -141,6 +141,21 @@ WideString CXFA_Node::AttributeEnumToName(XFA_ATTRIBUTEENUM item) {
return g_XFAEnumData[static_cast<int32_t>(item)].pName;
}
+// static
+pdfium::Optional<XFA_ATTRIBUTEENUM> CXFA_Node::NameToAttributeEnum(
+ const WideStringView& name) {
+ if (name.IsEmpty())
+ return {};
+
+ auto* it = std::lower_bound(g_XFAEnumData, g_XFAEnumData + g_iXFAEnumCount,
+ FX_HashCode_GetW(name, false),
+ [](const XFA_ATTRIBUTEENUMINFO& arg,
+ uint32_t hash) { return arg.uHash < hash; });
+ if (it != g_XFAEnumData + g_iXFAEnumCount && name == it->pName)
+ return {it->eName};
+ return {};
+}
+
CXFA_Node::CXFA_Node(CXFA_Document* pDoc,
uint16_t ePacket,
uint32_t validPackets,