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