OLD | NEW |
| (Empty) |
1 // Copyright 2014 PDFium Authors. All rights reserved. | |
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_SCRIPT_H_ | |
8 #define XFA_FXFA_PARSER_XFA_SCRIPT_H_ | |
9 | |
10 #include "fxjs/include/cfxjse_value.h" | |
11 #include "xfa/fxfa/include/fxfa.h" | |
12 #include "xfa/fxfa/parser/cxfa_valuearray.h" | |
13 | |
14 #define XFA_RESOLVENODE_Children 0x0001 | |
15 #define XFA_RESOLVENODE_Attributes 0x0004 | |
16 #define XFA_RESOLVENODE_Properties 0x0008 | |
17 #define XFA_RESOLVENODE_Siblings 0x0020 | |
18 #define XFA_RESOLVENODE_Parent 0x0040 | |
19 #define XFA_RESOLVENODE_AnyChild 0x0080 | |
20 #define XFA_RESOLVENODE_ALL 0x0100 | |
21 #define XFA_RESOLVENODE_CreateNode 0x0400 | |
22 #define XFA_RESOLVENODE_Bind 0x0800 | |
23 #define XFA_RESOLVENODE_BindNew 0x1000 | |
24 | |
25 enum XFA_SCRIPTLANGTYPE { | |
26 XFA_SCRIPTLANGTYPE_Formcalc = XFA_SCRIPTTYPE_Formcalc, | |
27 XFA_SCRIPTLANGTYPE_Javascript = XFA_SCRIPTTYPE_Javascript, | |
28 XFA_SCRIPTLANGTYPE_Unkown = XFA_SCRIPTTYPE_Unkown, | |
29 }; | |
30 | |
31 enum XFA_RESOVENODE_RSTYPE { | |
32 XFA_RESOVENODE_RSTYPE_Nodes, | |
33 XFA_RESOVENODE_RSTYPE_Attribute, | |
34 XFA_RESOLVENODE_RSTYPE_CreateNodeOne, | |
35 XFA_RESOLVENODE_RSTYPE_CreateNodeAll, | |
36 XFA_RESOLVENODE_RSTYPE_CreateNodeMidAll, | |
37 XFA_RESOVENODE_RSTYPE_ExistNodes, | |
38 }; | |
39 | |
40 struct XFA_RESOLVENODE_RS { | |
41 XFA_RESOLVENODE_RS(); | |
42 ~XFA_RESOLVENODE_RS(); | |
43 | |
44 int32_t GetAttributeResult(CXFA_ValueArray& valueArray) const { | |
45 if (pScriptAttribute && pScriptAttribute->eValueType == XFA_SCRIPT_Object) { | |
46 v8::Isolate* pIsolate = valueArray.m_pIsolate; | |
47 for (int32_t i = 0; i < nodes.GetSize(); i++) { | |
48 std::unique_ptr<CFXJSE_Value> pValue(new CFXJSE_Value(pIsolate)); | |
49 (nodes[i]->*(pScriptAttribute->lpfnCallback))( | |
50 pValue.get(), FALSE, (XFA_ATTRIBUTE)pScriptAttribute->eAttribute); | |
51 valueArray.Add(pValue.release()); | |
52 } | |
53 } | |
54 return valueArray.GetSize(); | |
55 } | |
56 | |
57 CXFA_ObjArray nodes; | |
58 XFA_RESOVENODE_RSTYPE dwFlags; | |
59 const XFA_SCRIPTATTRIBUTEINFO* pScriptAttribute; | |
60 }; | |
61 | |
62 inline XFA_RESOLVENODE_RS::XFA_RESOLVENODE_RS() | |
63 : dwFlags(XFA_RESOVENODE_RSTYPE_Nodes), pScriptAttribute(nullptr) {} | |
64 | |
65 inline XFA_RESOLVENODE_RS::~XFA_RESOLVENODE_RS() { | |
66 nodes.RemoveAll(); | |
67 } | |
68 #endif // XFA_FXFA_PARSER_XFA_SCRIPT_H_ | |
OLD | NEW |