• 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 XFA_FXFA_XFA_FFDOCVIEW_H_
8 #define XFA_FXFA_XFA_FFDOCVIEW_H_
9 
10 #include <map>
11 #include <memory>
12 #include <vector>
13 
14 #include "xfa/fxfa/cxfa_eventparam.h"
15 #include "xfa/fxfa/xfa_ffdoc.h"
16 
17 class CXFA_FFWidgetHandler;
18 class CXFA_FFDoc;
19 class CXFA_FFWidget;
20 class CXFA_WidgetAccIterator;
21 
22 extern const XFA_ATTRIBUTEENUM gs_EventActivity[];
23 enum XFA_DOCVIEW_LAYOUTSTATUS {
24   XFA_DOCVIEW_LAYOUTSTATUS_None,
25   XFA_DOCVIEW_LAYOUTSTATUS_Start,
26   XFA_DOCVIEW_LAYOUTSTATUS_FormInitialize,
27   XFA_DOCVIEW_LAYOUTSTATUS_FormInitCalculate,
28   XFA_DOCVIEW_LAYOUTSTATUS_FormInitValidate,
29   XFA_DOCVIEW_LAYOUTSTATUS_FormFormReady,
30   XFA_DOCVIEW_LAYOUTSTATUS_Doing,
31   XFA_DOCVIEW_LAYOUTSTATUS_PagesetInitialize,
32   XFA_DOCVIEW_LAYOUTSTATUS_PagesetInitCalculate,
33   XFA_DOCVIEW_LAYOUTSTATUS_PagesetInitValidate,
34   XFA_DOCVIEW_LAYOUTSTATUS_PagesetFormReady,
35   XFA_DOCVIEW_LAYOUTSTATUS_LayoutReady,
36   XFA_DOCVIEW_LAYOUTSTATUS_DocReady,
37   XFA_DOCVIEW_LAYOUTSTATUS_End
38 };
39 class CXFA_FFDocView {
40  public:
41   explicit CXFA_FFDocView(CXFA_FFDoc* pDoc);
42   ~CXFA_FFDocView();
43 
GetDoc()44   CXFA_FFDoc* GetDoc() { return m_pDoc; }
45   int32_t StartLayout(int32_t iStartPage = 0);
46   int32_t DoLayout(IFX_Pause* pPause);
47   void StopLayout();
48   int32_t GetLayoutStatus();
49   void UpdateDocView();
50   int32_t CountPageViews();
51   CXFA_FFPageView* GetPageView(int32_t nIndex);
52 
53   void ResetWidgetData(CXFA_WidgetAcc* pWidgetAcc);
54   int32_t ProcessWidgetEvent(CXFA_EventParam* pParam,
55                              CXFA_WidgetAcc* pWidgetAcc);
56   CXFA_FFWidgetHandler* GetWidgetHandler();
57   CXFA_WidgetAccIterator* CreateWidgetAccIterator(
58       XFA_WIDGETORDER eOrder = XFA_WIDGETORDER_PreOrder);
59   CXFA_FFWidget* GetFocusWidget();
60   void KillFocus();
61   bool SetFocus(CXFA_FFWidget* hWidget);
62   CXFA_FFWidget* GetWidgetByName(const CFX_WideString& wsName,
63                                  CXFA_FFWidget* pRefWidget);
64   CXFA_WidgetAcc* GetWidgetAccByName(const CFX_WideString& wsName,
65                                      CXFA_WidgetAcc* pRefWidgetAcc);
66   CXFA_LayoutProcessor* GetXFALayout() const;
67   void OnPageEvent(CXFA_ContainerLayoutItem* pSender, uint32_t dwEvent);
68   void LockUpdate();
69   void UnlockUpdate();
70   bool IsUpdateLocked();
71   void ClearInvalidateList();
72   void AddInvalidateRect(CXFA_FFWidget* pWidget, const CFX_RectF& rtInvalidate);
73   void AddInvalidateRect(CXFA_FFPageView* pPageView,
74                          const CFX_RectF& rtInvalidate);
75   void RunInvalidate();
76   void RunDocClose();
77   void DestroyDocView();
78 
79   bool InitValidate(CXFA_Node* pNode);
80   bool RunValidate();
81 
82   void SetChangeMark();
83 
84   void AddValidateWidget(CXFA_WidgetAcc* pWidget);
85   void AddCalculateNodeNotify(CXFA_Node* pNodeChange);
86   void AddCalculateWidgetAcc(CXFA_WidgetAcc* pWidgetAcc);
87   int32_t RunCalculateWidgets();
88   bool IsStaticNotify();
89   bool RunLayout();
90   void RunSubformIndexChange();
91   void AddNewFormNode(CXFA_Node* pNode);
92   void AddIndexChangedSubform(CXFA_Node* pNode);
93   CXFA_WidgetAcc* GetFocusWidgetAcc();
94   void SetFocusWidgetAcc(CXFA_WidgetAcc* pWidgetAcc);
95   void DeleteLayoutItem(CXFA_FFWidget* pWidget);
96   int32_t ExecEventActivityByDeepFirst(CXFA_Node* pFormNode,
97                                        XFA_EVENTTYPE eEventType,
98                                        bool bIsFormReady,
99                                        bool bRecursive,
100                                        CXFA_Node* pExclude);
101   bool m_bLayoutEvent;
102   std::vector<CFX_WideString> m_arrNullTestMsg;
103   CXFA_FFWidget* m_pListFocusWidget;
104   bool m_bInLayoutStatus;
105 
106  protected:
107   bool RunEventLayoutReady();
108   void RunBindItems();
109   bool InitCalculate(CXFA_Node* pNode);
110   void InitLayout(CXFA_Node* pNode);
111   void RunCalculateRecursive(int32_t& iIndex);
112   void ShowNullTestMsg();
113   bool ResetSingleWidgetAccData(CXFA_WidgetAcc* pWidgetAcc);
114   CXFA_Node* GetRootSubform();
115 
116   CXFA_FFDoc* const m_pDoc;
117   std::unique_ptr<CXFA_FFWidgetHandler> m_pWidgetHandler;
118   CXFA_LayoutProcessor* m_pXFADocLayout;  // not owned.
119   CXFA_WidgetAcc* m_pFocusAcc;            // not owned.
120   CXFA_FFWidget* m_pFocusWidget;          // not owned.
121   CXFA_FFWidget* m_pOldFocusWidget;       // not owned.
122   std::map<CXFA_FFPageView*, std::unique_ptr<CFX_RectF>> m_mapPageInvalidate;
123   std::vector<CXFA_WidgetAcc*> m_ValidateAccs;
124   std::vector<CXFA_WidgetAcc*> m_CalculateAccs;
125   std::vector<CXFA_Node*> m_BindItems;
126   std::vector<CXFA_Node*> m_NewAddedNodes;
127   std::vector<CXFA_Node*> m_IndexChangedSubforms;
128   XFA_DOCVIEW_LAYOUTSTATUS m_iStatus;
129   int32_t m_iLock;
130   friend class CXFA_FFNotify;
131 };
132 
133 class CXFA_WidgetAccIterator {
134  public:
135   CXFA_WidgetAccIterator(CXFA_FFDocView* pDocView, CXFA_Node* pTravelRoot);
136   ~CXFA_WidgetAccIterator();
137 
138   void Reset();
139   CXFA_WidgetAcc* MoveToFirst();
140   CXFA_WidgetAcc* MoveToLast();
141   CXFA_WidgetAcc* MoveToNext();
142   CXFA_WidgetAcc* MoveToPrevious();
143   CXFA_WidgetAcc* GetCurrentWidgetAcc();
144   bool SetCurrentWidgetAcc(CXFA_WidgetAcc* hWidget);
145   void SkipTree();
146 
147  protected:
148   CXFA_ContainerIterator m_ContentIterator;
149   CXFA_FFDocView* const m_pDocView;
150   CXFA_WidgetAcc* m_pCurWidgetAcc;  // not owned.
151 };
152 
153 #endif  // XFA_FXFA_XFA_FFDOCVIEW_H_
154