• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2014 The PDFium Authors
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_CXFA_FFDOCVIEW_H_
8 #define XFA_FXFA_CXFA_FFDOCVIEW_H_
9 
10 #include <list>
11 #include <vector>
12 
13 #include "fxjs/gc/heap.h"
14 #include "v8/include/cppgc/garbage-collected.h"
15 #include "v8/include/cppgc/member.h"
16 #include "v8/include/cppgc/visitor.h"
17 #include "xfa/fxfa/cxfa_eventparam.h"
18 #include "xfa/fxfa/cxfa_ffdoc.h"
19 #include "xfa/fxfa/cxfa_ffwidget.h"
20 #include "xfa/fxfa/fxfa.h"
21 
22 class CXFA_BindItems;
23 class CXFA_FFDoc;
24 class CXFA_FFWidgetHandler;
25 class CXFA_Node;
26 class CXFA_Subform;
27 class CXFA_ViewLayoutItem;
28 
29 extern const XFA_AttributeValue kXFAEventActivity[];
30 
31 class CXFA_FFDocView : public cppgc::GarbageCollected<CXFA_FFDocView> {
32  public:
33   enum class LayoutStatus : uint8_t { kNone, kStart, kDoing, kEnd };
34 
35   class UpdateScope {
36     CPPGC_STACK_ALLOCATED();
37 
38    public:
39     explicit UpdateScope(CXFA_FFDocView* pDocView);
40     ~UpdateScope();
41 
42    private:
43     UnownedPtr<CXFA_FFDocView> const m_pDocView;
44   };
45 
46   CONSTRUCT_VIA_MAKE_GARBAGE_COLLECTED;
47   ~CXFA_FFDocView();
48 
49   void Trace(cppgc::Visitor* visitor) const;
50 
GetDoc()51   CXFA_FFDoc* GetDoc() const { return m_pDoc; }
52   int32_t StartLayout();
53   int32_t DoLayout();
54   void StopLayout();
55 
SetLayoutEvent()56   void SetLayoutEvent() { m_bLayoutEvent = true; }
InLayoutStatus()57   bool InLayoutStatus() const { return m_bInLayoutStatus; }
GetLayoutStatus()58   LayoutStatus GetLayoutStatus() const { return m_iStatus; }
59 
60   void UpdateDocView();
61   void UpdateUIDisplay(CXFA_Node* pNode, CXFA_FFWidget* pExcept);
62 
63   int32_t CountPageViews() const;
64   CXFA_FFPageView* GetPageView(int32_t nIndex) const;
65 
66   void ResetNode(CXFA_Node* pNode);
67   CXFA_Node* GetRootSubform();
68   CXFA_FFWidgetHandler* GetWidgetHandler();
GetFocusWidget()69   CXFA_FFWidget* GetFocusWidget() const { return m_pFocusWidget; }
70   bool SetFocus(CXFA_FFWidget* pNewFocus);
71   CXFA_FFWidget* GetWidgetForNode(CXFA_Node* node);
72   CXFA_FFWidget* GetWidgetByName(const WideString& wsName,
73                                  CXFA_FFWidget* pRefWidget);
74   CXFA_LayoutProcessor* GetLayoutProcessor() const;
75   void OnPageViewEvent(CXFA_ViewLayoutItem* pSender,
76                        CXFA_FFDoc::PageViewEvent eEvent);
LockUpdate()77   void LockUpdate() { m_iLock++; }
UnlockUpdate()78   void UnlockUpdate() { m_iLock--; }
79   void InvalidateRect(CXFA_FFPageView* pPageView,
80                       const CFX_RectF& rtInvalidate);
81   void RunDocClose();
82 
83   void ProcessValueChanged(CXFA_Node* node);
84   void SetChangeMark();
85 
86   void AddValidateNode(CXFA_Node* node);
87   void AddCalculateNodeNotify(CXFA_Node* pNodeChange);
88   void AddCalculateNode(CXFA_Node* node);
89 
90   bool RunLayout();
91   void AddNewFormNode(CXFA_Node* pNode);
92   void AddIndexChangedSubform(CXFA_Subform* pNode);
GetFocusNode()93   CXFA_Node* GetFocusNode() const { return m_pFocusNode; }
94   void SetFocusNode(CXFA_Node* pNode);
95   void DeleteLayoutItem(CXFA_FFWidget* pWidget);
96   XFA_EventError ExecEventActivityByDeepFirst(CXFA_Node* pFormNode,
97                                               XFA_EVENTTYPE eEventType,
98                                               bool bIsFormReady,
99                                               bool bRecursive);
100 
AddBindItem(CXFA_BindItems * item)101   void AddBindItem(CXFA_BindItems* item) { m_BindItems.push_back(item); }
102   void AddNullTestMsg(const WideString& msg);
103 
104  private:
105   explicit CXFA_FFDocView(CXFA_FFDoc* pDoc);
106 
107   bool RunEventLayoutReady();
108   void RunBindItems();
109   void InitCalculate(CXFA_Node* pNode);
110   void InitLayout(CXFA_Node* pNode);
111   size_t RunCalculateRecursive(size_t index);
112   void ShowNullTestMsg();
113   bool ResetSingleNodeData(CXFA_Node* pNode);
114 
IsUpdateLocked()115   bool IsUpdateLocked() const { return m_iLock > 0; }
116   bool InitValidate(CXFA_Node* pNode);
117   bool RunValidate();
118   XFA_EventError RunCalculateWidgets();
119   void RunSubformIndexChange();
120 
121   cppgc::Member<CXFA_FFDoc> const m_pDoc;
122   cppgc::Member<CXFA_FFWidgetHandler> m_pWidgetHandler;
123   cppgc::Member<CXFA_Node> m_pFocusNode;
124   cppgc::Member<CXFA_FFWidget> m_pFocusWidget;
125   std::list<cppgc::Member<CXFA_Node>> m_ValidateNodes;
126   std::vector<cppgc::Member<CXFA_Node>> m_CalculateNodes;
127   std::list<cppgc::Member<CXFA_BindItems>> m_BindItems;
128   std::list<cppgc::Member<CXFA_Node>> m_NewAddedNodes;
129   std::list<cppgc::Member<CXFA_Subform>> m_IndexChangedSubforms;
130   std::vector<WideString> m_NullTestMsgArray;
131   bool m_bLayoutEvent = false;
132   bool m_bInLayoutStatus = false;
133   LayoutStatus m_iStatus = LayoutStatus::kNone;
134   int32_t m_iLock = 0;
135 };
136 
137 #endif  // XFA_FXFA_CXFA_FFDOCVIEW_H_
138