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