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