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