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