OLD | NEW |
| (Empty) |
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_PARSER_XFA_LAYOUT_PAGEMGR_NEW_H_ | |
8 #define XFA_FXFA_PARSER_XFA_LAYOUT_PAGEMGR_NEW_H_ | |
9 | |
10 #include "xfa/fxfa/parser/xfa_layout_itemlayout.h" | |
11 | |
12 class CXFA_LayoutItem; | |
13 | |
14 class CXFA_ContainerRecord { | |
15 public: | |
16 CXFA_ContainerRecord(CXFA_ContainerLayoutItem* pPageSet = nullptr, | |
17 CXFA_ContainerLayoutItem* pPageArea = nullptr, | |
18 CXFA_ContainerLayoutItem* pContentArea = nullptr) | |
19 : pCurPageSet(pPageSet), | |
20 pCurPageArea(pPageArea), | |
21 pCurContentArea(pContentArea) {} | |
22 CXFA_ContainerLayoutItem* pCurPageSet; | |
23 CXFA_ContainerLayoutItem* pCurPageArea; | |
24 CXFA_ContainerLayoutItem* pCurContentArea; | |
25 }; | |
26 | |
27 class CXFA_LayoutPageMgr { | |
28 public: | |
29 CXFA_LayoutPageMgr(CXFA_LayoutProcessor* pLayoutProcessor); | |
30 ~CXFA_LayoutPageMgr(); | |
31 | |
32 FX_BOOL InitLayoutPage(CXFA_Node* pFormNode); | |
33 FX_BOOL PrepareFirstPage(CXFA_Node* pRootSubform); | |
34 FX_FLOAT GetAvailHeight(); | |
35 FX_BOOL GetNextAvailContentHeight(FX_FLOAT fChildHeight); | |
36 void SubmitContentItem(CXFA_ContentLayoutItem* pContentLayoutItem, | |
37 XFA_ItemLayoutProcessorResult eStatus); | |
38 void FinishPaginatedPageSets(); | |
39 void SyncLayoutData(); | |
40 int32_t GetPageCount() const; | |
41 CXFA_ContainerLayoutItem* GetPage(int32_t index) const; | |
42 int32_t GetPageIndex(const CXFA_ContainerLayoutItem* pPage) const; | |
43 inline CXFA_ContainerLayoutItem* GetRootLayoutItem() const { | |
44 return m_pPageSetLayoutItemRoot; | |
45 } | |
46 FX_BOOL ProcessBreakBeforeOrAfter(CXFA_Node* pBreakNode, | |
47 FX_BOOL bBefore, | |
48 CXFA_Node*& pBreakLeaderNode, | |
49 CXFA_Node*& pBreakTrailerNode, | |
50 FX_BOOL& bCreatePage); | |
51 FX_BOOL ProcessOverflow(CXFA_Node* pFormNode, | |
52 CXFA_Node*& pLeaderNode, | |
53 CXFA_Node*& pTrailerNode, | |
54 FX_BOOL bDataMerge = FALSE, | |
55 FX_BOOL bCreatePage = TRUE); | |
56 CXFA_Node* QueryOverflow(CXFA_Node* pFormNode, | |
57 CXFA_LayoutContext* pLayoutContext = nullptr); | |
58 FX_BOOL ProcessBookendLeaderOrTrailer(CXFA_Node* pBookendNode, | |
59 FX_BOOL bLeader, | |
60 CXFA_Node*& pBookendAppendNode); | |
61 CXFA_LayoutItem* FindOrCreateLayoutItem(CXFA_Node* pFormNode); | |
62 | |
63 protected: | |
64 FX_BOOL AppendNewPage(FX_BOOL bFirstTemPage = FALSE); | |
65 void ReorderPendingLayoutRecordToTail(CXFA_ContainerRecord* pNewRecord, | |
66 CXFA_ContainerRecord* pPrevRecord); | |
67 void RemoveLayoutRecord(CXFA_ContainerRecord* pNewRecord, | |
68 CXFA_ContainerRecord* pPrevRecord); | |
69 inline CXFA_ContainerRecord* GetCurrentContainerRecord() { | |
70 CXFA_ContainerRecord* result = | |
71 ((CXFA_ContainerRecord*)m_rgProposedContainerRecord.GetAt( | |
72 m_pCurrentContainerRecord)); | |
73 ASSERT(result); | |
74 return result; | |
75 } | |
76 CXFA_ContainerRecord* CreateContainerRecord(CXFA_Node* pPageNode = nullptr, | |
77 FX_BOOL bCreateNew = FALSE); | |
78 void AddPageAreaLayoutItem(CXFA_ContainerRecord* pNewRecord, | |
79 CXFA_Node* pNewPageArea); | |
80 void AddContentAreaLayoutItem(CXFA_ContainerRecord* pNewRecord, | |
81 CXFA_Node* pContentArea); | |
82 FX_BOOL RunBreak(XFA_Element eBreakType, | |
83 XFA_ATTRIBUTEENUM eTargetType, | |
84 CXFA_Node* pTarget, | |
85 FX_BOOL bStartNew); | |
86 CXFA_Node* BreakOverflow(CXFA_Node* pOverflowNode, | |
87 CXFA_Node*& pLeaderTemplate, | |
88 CXFA_Node*& pTrailerTemplate, | |
89 FX_BOOL bCreatePage = TRUE); | |
90 FX_BOOL ResolveBookendLeaderOrTrailer(CXFA_Node* pBookendNode, | |
91 FX_BOOL bLeader, | |
92 CXFA_Node*& pBookendAppendTemplate); | |
93 FX_BOOL ExecuteBreakBeforeOrAfter(CXFA_Node* pCurNode, | |
94 FX_BOOL bBefore, | |
95 CXFA_Node*& pBreakLeaderTemplate, | |
96 CXFA_Node*& pBreakTrailerTemplate); | |
97 | |
98 int32_t CreateMinPageRecord(CXFA_Node* pPageArea, | |
99 FX_BOOL bTargetPageArea, | |
100 FX_BOOL bCreateLast = FALSE); | |
101 void CreateMinPageSetRecord(CXFA_Node* pPageSet, FX_BOOL bCreateAll = FALSE); | |
102 void CreateNextMinRecord(CXFA_Node* pRecordNode); | |
103 FX_BOOL FindPageAreaFromPageSet(CXFA_Node* pPageSet, | |
104 CXFA_Node* pStartChild, | |
105 CXFA_Node* pTargetPageArea = nullptr, | |
106 CXFA_Node* pTargetContentArea = nullptr, | |
107 FX_BOOL bNewPage = FALSE, | |
108 FX_BOOL bQuery = FALSE); | |
109 FX_BOOL FindPageAreaFromPageSet_Ordered( | |
110 CXFA_Node* pPageSet, | |
111 CXFA_Node* pStartChild, | |
112 CXFA_Node* pTargetPageArea = nullptr, | |
113 CXFA_Node* pTargetContentArea = nullptr, | |
114 FX_BOOL bNewPage = FALSE, | |
115 FX_BOOL bQuery = FALSE); | |
116 FX_BOOL FindPageAreaFromPageSet_SimplexDuplex( | |
117 CXFA_Node* pPageSet, | |
118 CXFA_Node* pStartChild, | |
119 CXFA_Node* pTargetPageArea = nullptr, | |
120 CXFA_Node* pTargetContentArea = nullptr, | |
121 FX_BOOL bNewPage = FALSE, | |
122 FX_BOOL bQuery = FALSE, | |
123 XFA_ATTRIBUTEENUM ePreferredPosition = XFA_ATTRIBUTEENUM_First); | |
124 FX_BOOL MatchPageAreaOddOrEven(CXFA_Node* pPageArea, FX_BOOL bLastMatch); | |
125 CXFA_Node* GetNextAvailPageArea(CXFA_Node* pTargetPageArea, | |
126 CXFA_Node* pTargetContentArea = nullptr, | |
127 FX_BOOL bNewPage = FALSE, | |
128 FX_BOOL bQuery = FALSE); | |
129 FX_BOOL GetNextContentArea(CXFA_Node* pTargetContentArea); | |
130 void InitPageSetMap(); | |
131 void ProcessLastPageSet(); | |
132 inline FX_BOOL IsPageSetRootOrderedOccurrence() { | |
133 return m_ePageSetMode == XFA_ATTRIBUTEENUM_OrderedOccurrence; | |
134 } | |
135 void ClearData(); | |
136 void ClearRecordList(); | |
137 void MergePageSetContents(); | |
138 void LayoutPageSetContents(); | |
139 void PrepareLayout(); | |
140 void SaveLayoutItem(CXFA_LayoutItem* pParentLayoutItem); | |
141 CXFA_LayoutProcessor* m_pLayoutProcessor; | |
142 CXFA_Node* m_pTemplatePageSetRoot; | |
143 CXFA_ContainerLayoutItem* m_pPageSetLayoutItemRoot; | |
144 CXFA_ContainerLayoutItem* m_pPageSetCurRoot; | |
145 FX_POSITION m_pCurrentContainerRecord; | |
146 CFX_PtrList m_rgProposedContainerRecord; | |
147 CXFA_Node* m_pCurPageArea; | |
148 int32_t m_nAvailPages; | |
149 int32_t m_nCurPageCount; | |
150 XFA_ATTRIBUTEENUM m_ePageSetMode; | |
151 FX_BOOL m_bCreateOverFlowPage; | |
152 CFX_MapPtrTemplate<CXFA_Node*, int32_t> m_pPageSetMap; | |
153 CFX_ArrayTemplate<CXFA_ContainerLayoutItem*> m_PageArray; | |
154 }; | |
155 | |
156 #endif // XFA_FXFA_PARSER_XFA_LAYOUT_PAGEMGR_NEW_H_ | |
OLD | NEW |