1 // Copyright 2016 The PDFium Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 6 7 #ifndef XFA_FXFA_PARSER_XFA_BASIC_DATA_H_ 8 #define XFA_FXFA_PARSER_XFA_BASIC_DATA_H_ 9 10 #include <stddef.h> 11 12 #include <optional> 13 14 #include "core/fxcrt/widestring.h" 15 #include "fxjs/xfa/cjx_object.h" 16 #include "xfa/fxfa/fxfa_basic.h" 17 18 using XFA_ATTRIBUTE_CALLBACK = void (*)(v8::Isolate* pIsolate, 19 CJX_Object* pNode, 20 v8::Local<v8::Value>* pValue, 21 bool bSetting, 22 XFA_Attribute eAttribute); 23 24 enum class XFA_PacketMatch : uint8_t { 25 kCompleteMatch = 1, 26 kPrefixMatch, 27 kNoMatch, 28 }; 29 30 enum class XFA_PacketSupport : uint8_t { 31 kSupportOne = 1, 32 kSupportMany, 33 }; 34 35 struct XFA_PACKETINFO { 36 XFA_PacketType packet_type; 37 XFA_PacketMatch match; 38 XFA_PacketSupport support; 39 const char* name; 40 const char* uri; 41 }; 42 43 struct XFA_ATTRIBUTEINFO { 44 XFA_Attribute attribute; 45 XFA_ScriptType eValueType; 46 }; 47 48 struct XFA_SCRIPTATTRIBUTEINFO { 49 XFA_Attribute attribute; 50 XFA_ScriptType eValueType; 51 XFA_ATTRIBUTE_CALLBACK callback = nullptr; 52 }; 53 54 XFA_PACKETINFO XFA_GetPacketByIndex(XFA_PacketType ePacket); 55 std::optional<XFA_PACKETINFO> XFA_GetPacketByName(WideStringView wsName); 56 57 ByteStringView XFA_ElementToName(XFA_Element elem); 58 XFA_Element XFA_GetElementByName(WideStringView name); 59 60 ByteStringView XFA_AttributeToName(XFA_Attribute attr); 61 std::optional<XFA_ATTRIBUTEINFO> XFA_GetAttributeByName(WideStringView name); 62 63 ByteStringView XFA_AttributeValueToName(XFA_AttributeValue item); 64 std::optional<XFA_AttributeValue> XFA_GetAttributeValueByName( 65 WideStringView name); 66 67 std::optional<XFA_SCRIPTATTRIBUTEINFO> XFA_GetScriptAttributeByName( 68 XFA_Element eElement, 69 WideStringView wsAttributeName); 70 71 #endif // XFA_FXFA_PARSER_XFA_BASIC_DATA_H_ 72