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