• 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 FXJS_CFXJSE_RESOLVEPROCESSOR_H_
8 #define FXJS_CFXJSE_RESOLVEPROCESSOR_H_
9 
10 #include <memory>
11 #include <vector>
12 
13 #include "xfa/fxfa/parser/xfa_resolvenode_rs.h"
14 
15 class CXFA_NodeHelper;
16 class CFXJSE_Engine;
17 
18 class CFXJSE_ResolveNodeData {
19  public:
20   explicit CFXJSE_ResolveNodeData(CFXJSE_Engine* pSC);
21   ~CFXJSE_ResolveNodeData();
22 
23   CFXJSE_Engine* m_pSC;
24   CXFA_Object* m_CurObject;
25   WideString m_wsName;
26   XFA_HashCode m_uHashName;
27   WideString m_wsCondition;
28   int32_t m_nLevel;
29   std::vector<CXFA_Object*> m_Objects;  // Not owned.
30   uint32_t m_dwStyles;
31   const XFA_SCRIPTATTRIBUTEINFO* m_pScriptAttribute;
32   XFA_ResolveNode_RSType m_dwFlag;
33 };
34 
35 class CFXJSE_ResolveProcessor {
36  public:
37   CFXJSE_ResolveProcessor();
38   ~CFXJSE_ResolveProcessor();
39 
40   bool Resolve(CFXJSE_ResolveNodeData& rnd);
41   int32_t GetFilter(const WideStringView& wsExpression,
42                     int32_t nStart,
43                     CFXJSE_ResolveNodeData& rnd);
44   void SetIndexDataBind(WideString& wsNextCondition,
45                         int32_t& iIndex,
46                         int32_t iCount);
SetCurStart(int32_t start)47   void SetCurStart(int32_t start) { m_iCurStart = start; }
48 
GetNodeHelper()49   CXFA_NodeHelper* GetNodeHelper() const { return m_pNodeHelper.get(); }
50 
51  private:
52   bool ResolveForAttributeRs(CXFA_Object* curNode,
53                              CFXJSE_ResolveNodeData& rnd,
54                              const WideStringView& strAttr);
55   bool ResolveAnyChild(CFXJSE_ResolveNodeData& rnd);
56   bool ResolveDollar(CFXJSE_ResolveNodeData& rnd);
57   bool ResolveExcalmatory(CFXJSE_ResolveNodeData& rnd);
58   bool ResolveNumberSign(CFXJSE_ResolveNodeData& rnd);
59   bool ResolveAsterisk(CFXJSE_ResolveNodeData& rnd);
60   bool ResolveNormal(CFXJSE_ResolveNodeData& rnd);
61   void SetStylesForChild(uint32_t dwParentStyles, CFXJSE_ResolveNodeData& rnd);
62 
63   void ConditionArray(int32_t iCurIndex,
64                       WideString wsCondition,
65                       int32_t iFoundCount,
66                       CFXJSE_ResolveNodeData& rnd);
67   void DoPredicateFilter(int32_t iCurIndex,
68                          WideString wsCondition,
69                          int32_t iFoundCount,
70                          CFXJSE_ResolveNodeData& rnd);
71   void FilterCondition(CFXJSE_ResolveNodeData& rnd, WideString wsCondition);
72 
73   int32_t m_iCurStart;
74   std::unique_ptr<CXFA_NodeHelper> m_pNodeHelper;
75 };
76 
77 #endif  // FXJS_CFXJSE_RESOLVEPROCESSOR_H_
78