blob: 71aba6efa84dca8f056e680e69e5ba3bbb2b43c9 [file] [log] [blame]
Dan Sinclair1770c022016-03-14 14:14:16 -04001// 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
Dan Sinclaird19aa7c2017-11-06 17:10:21 +00007#ifndef FXJS_CFXJSE_RESOLVEPROCESSOR_H_
8#define FXJS_CFXJSE_RESOLVEPROCESSOR_H_
Dan Sinclair1770c022016-03-14 14:14:16 -04009
weilib4d1b572016-08-10 14:50:48 -070010#include <memory>
Tom Sepezf8a94392017-03-14 12:13:22 -070011#include <vector>
weilib4d1b572016-08-10 14:50:48 -070012
dsinclair31f87402016-07-20 06:34:45 -070013#include "xfa/fxfa/parser/xfa_resolvenode_rs.h"
Dan Sinclair1770c022016-03-14 14:14:16 -040014
15class CXFA_NodeHelper;
Dan Sinclair3fff90a2017-11-01 13:12:39 +000016class CFXJSE_Engine;
Dan Sinclair1770c022016-03-14 14:14:16 -040017
Dan Sinclaird19aa7c2017-11-06 17:10:21 +000018class CFXJSE_ResolveNodeData {
Dan Sinclair1770c022016-03-14 14:14:16 -040019 public:
Dan Sinclaird19aa7c2017-11-06 17:10:21 +000020 explicit CFXJSE_ResolveNodeData(CFXJSE_Engine* pSC);
21 ~CFXJSE_ResolveNodeData();
weili47bcd4c2016-06-16 08:00:06 -070022
Dan Sinclair3fff90a2017-11-01 13:12:39 +000023 CFXJSE_Engine* m_pSC;
Tom Sepezf8a94392017-03-14 12:13:22 -070024 CXFA_Object* m_CurObject;
Ryan Harrison275e2602017-09-18 14:23:18 -040025 WideString m_wsName;
dsinclaircbfef572016-05-18 13:16:12 -070026 XFA_HashCode m_uHashName;
Ryan Harrison275e2602017-09-18 14:23:18 -040027 WideString m_wsCondition;
Dan Sinclair1770c022016-03-14 14:14:16 -040028 int32_t m_nLevel;
Tom Sepezf8a94392017-03-14 12:13:22 -070029 std::vector<CXFA_Object*> m_Objects; // Not owned.
tsepezdeee3d22016-03-25 14:38:58 -070030 uint32_t m_dwStyles;
Dan Sinclair1770c022016-03-14 14:14:16 -040031 const XFA_SCRIPTATTRIBUTEINFO* m_pScriptAttribute;
Dan Sinclair33beb4e2017-12-04 19:12:16 +000032 XFA_ResolveNode_RSType m_dwFlag;
Dan Sinclair1770c022016-03-14 14:14:16 -040033};
weilibff506d2016-06-20 11:37:05 -070034
Dan Sinclaird19aa7c2017-11-06 17:10:21 +000035class CFXJSE_ResolveProcessor {
Dan Sinclair1770c022016-03-14 14:14:16 -040036 public:
Dan Sinclaird19aa7c2017-11-06 17:10:21 +000037 CFXJSE_ResolveProcessor();
38 ~CFXJSE_ResolveProcessor();
weilibff506d2016-06-20 11:37:05 -070039
Dan Sinclair76e336d2017-12-04 18:08:58 +000040 bool Resolve(CFXJSE_ResolveNodeData& rnd);
Ryan Harrison275e2602017-09-18 14:23:18 -040041 int32_t GetFilter(const WideStringView& wsExpression,
dsinclaird1cf2392016-07-11 06:46:59 -070042 int32_t nStart,
Dan Sinclaird19aa7c2017-11-06 17:10:21 +000043 CFXJSE_ResolveNodeData& rnd);
Ryan Harrison275e2602017-09-18 14:23:18 -040044 void SetIndexDataBind(WideString& wsNextCondition,
dsinclaird1cf2392016-07-11 06:46:59 -070045 int32_t& iIndex,
46 int32_t iCount);
47 void SetCurStart(int32_t start) { m_iCurStart = start; }
48
weilib4d1b572016-08-10 14:50:48 -070049 CXFA_NodeHelper* GetNodeHelper() const { return m_pNodeHelper.get(); }
Dan Sinclair1770c022016-03-14 14:14:16 -040050
51 private:
Dan Sinclair76e336d2017-12-04 18:08:58 +000052 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);
Dan Sinclaird19aa7c2017-11-06 17:10:21 +000061 void SetStylesForChild(uint32_t dwParentStyles, CFXJSE_ResolveNodeData& rnd);
Dan Sinclair1770c022016-03-14 14:14:16 -040062
dsinclaird1cf2392016-07-11 06:46:59 -070063 void ConditionArray(int32_t iCurIndex,
Ryan Harrison275e2602017-09-18 14:23:18 -040064 WideString wsCondition,
dsinclaird1cf2392016-07-11 06:46:59 -070065 int32_t iFoundCount,
Dan Sinclaird19aa7c2017-11-06 17:10:21 +000066 CFXJSE_ResolveNodeData& rnd);
dsinclaird1cf2392016-07-11 06:46:59 -070067 void DoPredicateFilter(int32_t iCurIndex,
Ryan Harrison275e2602017-09-18 14:23:18 -040068 WideString wsCondition,
dsinclaird1cf2392016-07-11 06:46:59 -070069 int32_t iFoundCount,
Dan Sinclaird19aa7c2017-11-06 17:10:21 +000070 CFXJSE_ResolveNodeData& rnd);
71 void FilterCondition(CFXJSE_ResolveNodeData& rnd, WideString wsCondition);
dsinclaird1cf2392016-07-11 06:46:59 -070072
Dan Sinclair1770c022016-03-14 14:14:16 -040073 int32_t m_iCurStart;
weilib4d1b572016-08-10 14:50:48 -070074 std::unique_ptr<CXFA_NodeHelper> m_pNodeHelper;
Dan Sinclair1770c022016-03-14 14:14:16 -040075};
76
Dan Sinclaird19aa7c2017-11-06 17:10:21 +000077#endif // FXJS_CFXJSE_RESOLVEPROCESSOR_H_