Home | History | Annotate | Download | only in parser
      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_CXFA_RESOLVEPROCESSOR_H_
      8 #define XFA_FXFA_PARSER_CXFA_RESOLVEPROCESSOR_H_
      9 
     10 #include <memory>
     11 
     12 #include "xfa/fxfa/parser/xfa_object.h"
     13 #include "xfa/fxfa/parser/xfa_resolvenode_rs.h"
     14 
     15 class CXFA_NodeHelper;
     16 class CXFA_ScriptContext;
     17 
     18 class CXFA_ResolveNodesData {
     19  public:
     20   explicit CXFA_ResolveNodesData(CXFA_ScriptContext* pSC = nullptr);
     21   ~CXFA_ResolveNodesData();
     22 
     23   CXFA_ScriptContext* m_pSC;
     24   CXFA_Object* m_CurNode;
     25   CFX_WideString m_wsName;
     26   XFA_HashCode m_uHashName;
     27   CFX_WideString m_wsCondition;
     28   int32_t m_nLevel;
     29   CXFA_ObjArray m_Nodes;
     30   uint32_t m_dwStyles;
     31   const XFA_SCRIPTATTRIBUTEINFO* m_pScriptAttribute;
     32   XFA_RESOVENODE_RSTYPE m_dwFlag;
     33 };
     34 
     35 class CXFA_ResolveProcessor {
     36  public:
     37   CXFA_ResolveProcessor();
     38   ~CXFA_ResolveProcessor();
     39 
     40   int32_t Resolve(CXFA_ResolveNodesData& rnd);
     41   int32_t GetFilter(const CFX_WideStringC& wsExpression,
     42                     int32_t nStart,
     43                     CXFA_ResolveNodesData& rnd);
     44   int32_t SetResultCreateNode(XFA_RESOLVENODE_RS& resolveNodeRS,
     45                               CFX_WideString& wsLastCondition);
     46   void SetIndexDataBind(CFX_WideString& wsNextCondition,
     47                         int32_t& iIndex,
     48                         int32_t iCount);
     49   void SetCurStart(int32_t start) { m_iCurStart = start; }
     50 
     51   CXFA_NodeHelper* GetNodeHelper() const { return m_pNodeHelper.get(); }
     52 
     53  private:
     54   int32_t ResolveForAttributeRs(CXFA_Object* curNode,
     55                                 CXFA_ResolveNodesData& rnd,
     56                                 const CFX_WideStringC& strAttr);
     57   int32_t ResolveAnyChild(CXFA_ResolveNodesData& rnd);
     58   int32_t ResolveDollar(CXFA_ResolveNodesData& rnd);
     59   int32_t ResolveExcalmatory(CXFA_ResolveNodesData& rnd);
     60   int32_t ResolveNumberSign(CXFA_ResolveNodesData& rnd);
     61   int32_t ResolveAsterisk(CXFA_ResolveNodesData& rnd);
     62   int32_t ResolveNormal(CXFA_ResolveNodesData& rnd);
     63   int32_t ResolvePopStack(CFX_ArrayTemplate<int32_t>& stack);
     64   void SetStylesForChild(uint32_t dwParentStyles, CXFA_ResolveNodesData& rnd);
     65 
     66   void ConditionArray(int32_t iCurIndex,
     67                       CFX_WideString wsCondition,
     68                       int32_t iFoundCount,
     69                       CXFA_ResolveNodesData& rnd);
     70   void DoPredicateFilter(int32_t iCurIndex,
     71                          CFX_WideString wsCondition,
     72                          int32_t iFoundCount,
     73                          CXFA_ResolveNodesData& rnd);
     74   void FilterCondition(CXFA_ResolveNodesData& rnd, CFX_WideString wsCondition);
     75 
     76   int32_t m_iCurStart;
     77   std::unique_ptr<CXFA_NodeHelper> m_pNodeHelper;
     78 };
     79 
     80 #endif  // XFA_FXFA_PARSER_CXFA_RESOLVEPROCESSOR_H_
     81