Merge XFA to PDFium master at 4dc95e7 on 10/28/2014
[pdfium.git] / xfa / src / fxfa / src / parser / xfa_layout_pagemgr_new.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 _XFA_LAYOUT_PAGEMGR_H_\r
8 #define _XFA_LAYOUT_PAGEMGR_H_\r
9 class CXFA_ContainerRecord : public CFX_Object\r
10 {\r
11 public:\r
12     CXFA_ContainerRecord(CXFA_ContainerLayoutItemImpl* pPageSet = NULL, CXFA_ContainerLayoutItemImpl* pPageArea = NULL, CXFA_ContainerLayoutItemImpl* pContentArea = NULL)\r
13         : pCurPageSet(pPageSet), pCurPageArea(pPageArea), pCurContentArea(pContentArea)\r
14     {\r
15     }\r
16     CXFA_ContainerLayoutItemImpl* pCurPageSet;\r
17     CXFA_ContainerLayoutItemImpl* pCurPageArea;\r
18     CXFA_ContainerLayoutItemImpl* pCurContentArea;\r
19 };\r
20 class CXFA_LayoutPageMgr : public CFX_Object\r
21 {\r
22 public:\r
23     CXFA_LayoutPageMgr(CXFA_LayoutProcessor* pLayoutProcessor);\r
24     ~CXFA_LayoutPageMgr();\r
25     FX_BOOL             InitLayoutPage(CXFA_Node* pFormNode);\r
26     FX_BOOL             PrepareFirstPage(CXFA_Node* pRootSubform);\r
27     FX_FLOAT    GetAvailHeight();\r
28     FX_BOOL             GetNextAvailContentHeight(FX_FLOAT fChildHeight);\r
29     void                SubmitContentItem(CXFA_ContentLayoutItemImpl* pContentLayoutItem, XFA_ItemLayoutProcessorResult eStatus);\r
30     void                FinishPaginatedPageSets();\r
31     void                SyncLayoutData();\r
32     FX_INT32                    GetPageCount() const;\r
33     IXFA_LayoutPage*    GetPage(FX_INT32 index) const;\r
34     FX_INT32                    GetPageIndex(IXFA_LayoutPage* pPage) const;\r
35     inline CXFA_ContainerLayoutItemImpl*        GetRootLayoutItem() const\r
36     {\r
37         return m_pPageSetLayoutItemRoot;\r
38     }\r
39     FX_BOOL             ProcessBreakBeforeOrAfter(CXFA_Node* pBreakNode, FX_BOOL bBefore, CXFA_Node* &pBreakLeaderNode, CXFA_Node* &pBreakTrailerNode, FX_BOOL& bCreatePage);\r
40     FX_BOOL             ProcessOverflow(CXFA_Node* pFormNode, CXFA_Node* &pLeaderNode, CXFA_Node* &pTrailerNode, FX_BOOL bDataMerge = FALSE, FX_BOOL bCreatePage = TRUE);\r
41     CXFA_Node*  QueryOverflow(CXFA_Node* pFormNode, CXFA_LayoutContext* pLayoutContext = NULL);\r
42     FX_BOOL             ProcessBookendLeaderOrTrailer(CXFA_Node* pBookendNode, FX_BOOL bLeader, CXFA_Node* &pBookendAppendNode);\r
43     CXFA_LayoutItemImpl* FindOrCreateLayoutItem(CXFA_Node* pFormNode);\r
44 protected:\r
45     FX_BOOL     AppendNewPage(FX_BOOL bFirstTemPage = FALSE);\r
46     void                ReorderPendingLayoutRecordToTail(CXFA_ContainerRecord* pNewRecord, CXFA_ContainerRecord* pPrevRecord);\r
47     void                RemoveLayoutRecord(CXFA_ContainerRecord* pNewRecord, CXFA_ContainerRecord* pPrevRecord);\r
48     inline CXFA_ContainerRecord* GetCurrentContainerRecord()\r
49     {\r
50         CXFA_ContainerRecord* result = ((CXFA_ContainerRecord*)m_rgProposedContainerRecord.GetAt(m_pCurrentContainerRecord));\r
51         ASSERT(result);\r
52         return result;\r
53     }\r
54     CXFA_ContainerRecord* CreateContainerRecord(CXFA_Node* pPageNode = NULL, FX_BOOL bCreateNew = FALSE);\r
55     void                AddPageAreaLayoutItem(CXFA_ContainerRecord* pNewRecord, CXFA_Node* pNewPageArea);\r
56     void                AddContentAreaLayoutItem(CXFA_ContainerRecord* pNewRecord, CXFA_Node* pContentArea);\r
57     FX_BOOL             RunBreak(XFA_ELEMENT eBreakType, XFA_ATTRIBUTEENUM eTargetType, CXFA_Node* pTarget, FX_BOOL bStartNew);\r
58     CXFA_Node*  BreakOverflow(CXFA_Node* pOverflowNode, CXFA_Node*& pLeaderTemplate, CXFA_Node*& pTrailerTemplate, FX_BOOL bCreatePage = TRUE);\r
59     FX_BOOL             ResolveBookendLeaderOrTrailer(CXFA_Node* pBookendNode, FX_BOOL bLeader, CXFA_Node* &pBookendAppendTemplate);\r
60     FX_BOOL             ExecuteBreakBeforeOrAfter(CXFA_Node* pCurNode, FX_BOOL bBefore, CXFA_Node* &pBreakLeaderTemplate, CXFA_Node* &pBreakTrailerTemplate);\r
61 \r
62     FX_INT32    CreateMinPageRecord(CXFA_Node* pPageArea, FX_BOOL bTargetPageArea, FX_BOOL bCreateLast = FALSE);\r
63     void                CreateMinPageSetRecord(CXFA_Node* pPageSet, FX_BOOL bCreateAll = FALSE);\r
64     void                CreateNextMinRecord(CXFA_Node* pRecordNode);\r
65     FX_BOOL             FindPageAreaFromPageSet(CXFA_Node* pPageSet, CXFA_Node* pStartChild, CXFA_Node* pTargetPageArea = NULL, CXFA_Node* pTargetContentArea = NULL, FX_BOOL bNewPage = FALSE, FX_BOOL bQuery = FALSE);\r
66     FX_BOOL             FindPageAreaFromPageSet_Ordered(CXFA_Node* pPageSet, CXFA_Node* pStartChild, CXFA_Node* pTargetPageArea = NULL, CXFA_Node* pTargetContentArea = NULL, FX_BOOL bNewPage = FALSE, FX_BOOL bQuery = FALSE);\r
67     FX_BOOL             FindPageAreaFromPageSet_SimplexDuplex(CXFA_Node* pPageSet, CXFA_Node* pStartChild, CXFA_Node* pTargetPageArea = NULL, CXFA_Node* pTargetContentArea = NULL, FX_BOOL bNewPage = FALSE, FX_BOOL bQuery = FALSE, XFA_ATTRIBUTEENUM ePreferredPosition = XFA_ATTRIBUTEENUM_First);\r
68     FX_BOOL             MatchPageAreaOddOrEven(CXFA_Node* pPageArea, FX_BOOL bLastMatch);\r
69     CXFA_Node*  GetNextAvailPageArea(CXFA_Node* pTargetPageArea, CXFA_Node* pTargetContentArea = NULL, FX_BOOL bNewPage = FALSE, FX_BOOL bQuery = FALSE);\r
70     FX_BOOL             GetNextContentArea(CXFA_Node* pTargetContentArea);\r
71     void                InitPageSetMap();\r
72     void                ProcessLastPageSet();\r
73     inline      FX_BOOL IsPageSetRootOrderedOccurrence()\r
74     {\r
75         return m_ePageSetMode == XFA_ATTRIBUTEENUM_OrderedOccurrence;\r
76     }\r
77     void                ClearData();\r
78     void                ClearRecordList();\r
79     void                MergePageSetContents();\r
80     void                LayoutPageSetContents();\r
81     void                PrepareLayout();\r
82     CXFA_LayoutProcessor*                               m_pLayoutProcessor;\r
83     CXFA_Node*                                                  m_pTemplatePageSetRoot;\r
84     CXFA_ContainerLayoutItemImpl*               m_pPageSetLayoutItemRoot;\r
85     CXFA_ContainerLayoutItemImpl*               m_pPageSetCurRoot;\r
86     FX_POSITION                                                 m_pCurrentContainerRecord;\r
87     CFX_PtrList                                                 m_rgProposedContainerRecord;\r
88     CXFA_Node*                                                  m_pCurPageArea;\r
89     FX_INT32                                                    m_nAvailPages;\r
90     FX_INT32                                                    m_nCurPageCount;\r
91     XFA_ATTRIBUTEENUM                                   m_ePageSetMode;\r
92     FX_BOOL                                                             m_bCreateOverFlowPage;\r
93     CFX_MapPtrTemplate<CXFA_Node*, FX_INT32> m_pPageSetMap;\r
94 #ifdef _XFA_LAYOUTITEM_MAPCACHE_\r
95     void                                                SaveLayoutItem(CXFA_LayoutItemImpl* pParentLayoutItem);\r
96     CFX_MapPtrToPtr                             m_NodeToContent;\r
97 #elif defined(_XFA_LAYOUTITEM_ProcessCACHE_)\r
98     void                                                SaveLayoutItem(CXFA_LayoutItemImpl* pParentLayoutItem);\r
99 #endif\r
100     CFX_ArrayTemplate<CXFA_ContainerLayoutItemImpl*>                            m_PageArray;\r
101 };\r
102 #endif\r