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