Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
cxfa_viewlayoutprocessor.h
Go to the documentation of this file.
1// Copyright 2014 The PDFium Authors
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_LAYOUT_CXFA_VIEWLAYOUTPROCESSOR_H_
8#define XFA_FXFA_LAYOUT_CXFA_VIEWLAYOUTPROCESSOR_H_
9
10#include <iterator>
11#include <list>
12#include <map>
13#include <vector>
14
15#include "core/fxcrt/unowned_ptr.h"
16#include "core/fxcrt/unowned_ptr_exclusion.h"
17#include "fxjs/gc/heap.h"
18#include "third_party/abseil-cpp/absl/types/optional.h"
19#include "v8/include/cppgc/garbage-collected.h"
20#include "v8/include/cppgc/member.h"
21#include "v8/include/cppgc/prefinalizer.h"
22#include "v8/include/cppgc/visitor.h"
23#include "xfa/fxfa/layout/cxfa_contentlayoutprocessor.h"
24
25class CXFA_LayoutItem;
26class CXFA_LayoutProcessor;
27class CXFA_Node;
28
31 CPPGC_USING_PRE_FINALIZER(CXFA_ViewLayoutProcessor, PreFinalize);
32
33 public:
34 struct BreakData {
35 CPPGC_STACK_ALLOCATED(); // Raw/Unowned pointers allowed.
36 public:
40 };
41
42 struct OverflowData {
43 CPPGC_STACK_ALLOCATED(); // Raw/Unowned pointers allowed.
44 public:
47 };
48
51
52 void PreFinalize();
53 void Trace(cppgc::Visitor* visitor) const;
54 cppgc::Heap* GetHeap() const { return m_pHeap; }
55
56 bool InitLayoutPage(CXFA_Node* pFormNode);
57 bool PrepareFirstPage(CXFA_Node* pRootSubform);
58 float GetAvailHeight();
59 bool GetNextAvailContentHeight(float fChildHeight);
60 void SubmitContentItem(CXFA_ContentLayoutItem* pContentLayoutItem,
63 void SyncLayoutData();
64 int32_t GetPageCount() const;
65 CXFA_ViewLayoutItem* GetPage(int32_t index) const;
66 int32_t GetPageIndex(const CXFA_ViewLayoutItem* pPage) const;
67 CXFA_ViewLayoutItem* GetRootLayoutItem() const {
68 return m_pPageSetRootLayoutItem;
69 }
73 bool bCreatePage);
75 CXFA_Node* ProcessBookendLeader(const CXFA_Node* pBookendNode);
76 CXFA_Node* ProcessBookendTrailer(const CXFA_Node* pBookendNode);
77
78 private:
79 class CXFA_ViewRecord : public cppgc::GarbageCollected<CXFA_ViewRecord> {
80 public:
82 ~CXFA_ViewRecord();
83
84 void Trace(cppgc::Visitor* visitor) const;
85
86 cppgc::Member<CXFA_ViewLayoutItem> pCurPageSet;
87 cppgc::Member<CXFA_ViewLayoutItem> pCurPageArea;
88 cppgc::Member<CXFA_ViewLayoutItem> pCurContentArea;
89
90 private:
91 CXFA_ViewRecord();
92 };
93
94 CXFA_ViewLayoutProcessor(cppgc::Heap* pHeap,
95 CXFA_LayoutProcessor* pLayoutProcessor);
96
97 bool AppendNewPage(bool bFirstTemPage);
98 void RemoveLayoutRecord(CXFA_ViewRecord* pNewRecord,
99 CXFA_ViewRecord* pPrevRecord);
100 bool HasCurrentViewRecord() const {
101 return m_CurrentViewRecordIter != m_ProposedViewRecords.end();
102 }
103 CXFA_ViewRecord* GetCurrentViewRecord() {
104 return HasCurrentViewRecord() ? m_CurrentViewRecordIter->Get() : nullptr;
105 }
106 const CXFA_ViewRecord* GetCurrentViewRecord() const {
107 return HasCurrentViewRecord() ? m_CurrentViewRecordIter->Get() : nullptr;
108 }
109 void ResetToFirstViewRecord() {
110 m_CurrentViewRecordIter = m_ProposedViewRecords.begin();
111 }
115 }
117 CXFA_ViewRecord* CreateViewRecord(CXFA_Node* pPageNode, bool bCreateNew);
118 CXFA_ViewRecord* CreateViewRecordSimple();
119 void AddPageAreaLayoutItem(CXFA_ViewRecord* pNewRecord,
120 CXFA_Node* pNewPageArea);
121 void AddContentAreaLayoutItem(CXFA_ViewRecord* pNewRecord,
122 CXFA_Node* pContentArea);
123 bool RunBreak(XFA_Element eBreakType,
124 XFA_AttributeValue eTargetType,
125 CXFA_Node* pTarget,
126 bool bStartNew);
127 bool ShouldGetNextPageArea(CXFA_Node* pTarget, bool bStartNew) const;
128 bool BreakOverflow(const CXFA_Node* pOverflowNode,
129 bool bCreatePage,
130 CXFA_Node** pLeaderTemplate,
131 CXFA_Node** pTrailerTemplate);
132 CXFA_Node* ProcessBookendLeaderOrTrailer(const CXFA_Node* pBookendNode,
133 bool bLeader);
134 CXFA_Node* ResolveBookendLeaderOrTrailer(const CXFA_Node* pBookendNode,
135 bool bLeader);
136 absl::optional<BreakData> ProcessBreakBeforeOrAfter(
137 const CXFA_Node* pBreakNode,
138 bool bBefore);
139 BreakData ExecuteBreakBeforeOrAfter(const CXFA_Node* pCurNode, bool bBefore);
140
141 int32_t CreateMinPageRecord(CXFA_Node* pPageArea,
142 bool bTargetPageArea,
143 bool bCreateLast);
144 void CreateMinPageSetRecord(CXFA_Node* pPageSet, bool bCreateAll);
145 void CreateNextMinRecord(CXFA_Node* pRecordNode);
146 bool FindPageAreaFromPageSet(CXFA_Node* pPageSet,
147 CXFA_Node* pStartChild,
148 CXFA_Node* pTargetPageArea,
149 CXFA_Node* pTargetContentArea,
150 bool bNewPage,
151 bool bQuery);
152 bool FindPageAreaFromPageSet_Ordered(CXFA_Node* pPageSet,
153 CXFA_Node* pStartChild,
154 CXFA_Node* pTargetPageArea,
155 CXFA_Node* pTargetContentArea,
156 bool bNewPage,
157 bool bQuery);
158 bool FindPageAreaFromPageSet_SimplexDuplex(
159 CXFA_Node* pPageSet,
160 CXFA_Node* pStartChild,
161 CXFA_Node* pTargetPageArea,
162 CXFA_Node* pTargetContentArea,
163 bool bNewPage,
164 bool bQuery,
165 XFA_AttributeValue ePreferredPosition);
166 bool MatchPageAreaOddOrEven(CXFA_Node* pPageArea);
167 CXFA_Node* GetNextAvailPageArea(CXFA_Node* pTargetPageArea,
168 CXFA_Node* pTargetContentArea,
169 bool bNewPage,
170 bool bQuery);
171 bool GetNextContentArea(CXFA_Node* pTargetContentArea);
172 void InitPageSetMap();
173 void ProcessLastPageSet();
174 bool IsPageSetRootOrderedOccurrence() const {
175 return m_ePageSetMode == XFA_AttributeValue::OrderedOccurrence;
176 }
177 void ClearData();
178 void MergePageSetContents();
179 void LayoutPageSetContents();
180 void PrepareLayout();
181 void SaveLayoutItemChildren(CXFA_LayoutItem* pParentLayoutItem);
182 void ProcessSimplexOrDuplexPageSets(CXFA_ViewLayoutItem* pPageSetLayoutItem,
183 bool bIsSimplex);
184
185 UnownedPtr<cppgc::Heap> m_pHeap;
186 cppgc::Member<CXFA_LayoutProcessor> m_pLayoutProcessor;
187 cppgc::Member<CXFA_Node> m_pPageSetNode;
188 cppgc::Member<CXFA_Node> m_pCurPageArea;
189 cppgc::Member<CXFA_ViewLayoutItem> m_pPageSetRootLayoutItem;
190 cppgc::Member<CXFA_ViewLayoutItem> m_pPageSetCurLayoutItem;
193 int32_t m_nAvailPages = 0;
194 int32_t m_nCurPageCount = 0;
195 XFA_AttributeValue m_ePageSetMode = XFA_AttributeValue::OrderedOccurrence;
196 bool m_bCreateOverFlowPage = false;
199};
200
201#endif // XFA_FXFA_LAYOUT_CXFA_VIEWLAYOUTPROCESSOR_H_
void InsertAfter(CXFA_ContentLayoutItem *pNext)
CXFA_ContentLayoutItem * GetNext() const
CXFA_ContentLayoutItem * GetLast()
Result DoLayout(bool bUseBreakControl, float fHeightLimit, float fRealHeight)
void DoLayoutPageArea(CXFA_ViewLayoutItem *pPageAreaLayoutItem)
CXFA_ContentLayoutItem * ExtractLayoutItem()
void Trace(cppgc::Visitor *visitor) const
CXFA_FFNotify * GetNotify() const
void StartFieldDrawLayout(CXFA_Node *pItem, float *pCalcWidth, float *pCalcHeight)
void OnLayoutItemRemoving(CXFA_LayoutProcessor *pLayout, CXFA_LayoutItem *pSender)
bool IsContentLayoutItem() const
CXFA_ContentLayoutItem * AsContentLayoutItem()
CXFA_Node * GetFormNode() const
static CXFA_LayoutProcessor * FromDocument(const CXFA_Document *pXFADoc)
void RemoveChildAndNotify(CXFA_Node *pNode, bool bNotify)
CXFA_Node * GetFirstContainerChild() const
CXFA_Node * GetNextContainerSibling() const
XFA_AttributeValue GetIntact()
bool IsLayoutGeneratedNode() const
Definition cxfa_node.h:166
void SetBindingNode(CXFA_Node *node)
void SetFlag(XFA_NodeFlag dwFlag)
CXFA_Node * GetTemplateNodeIfExists() const
CXFA_Node * GetPrevContainerSibling() const
CXFA_Node * GetBindData()
bool RemoveBindItem(CXFA_Node *pFormNode)
bool IsUnusedNode() const
Definition cxfa_node.h:165
bool PresenceRequiresSpace() const
XFA_Element GetElementType() const
Definition cxfa_object.h:91
CXFA_Document * GetDocument() const
Definition cxfa_object.h:48
bool IsContainerNode() const
Definition cxfa_object.h:69
int32_t GetPageIndex(const CXFA_ViewLayoutItem *pPage) const
CXFA_ViewLayoutItem * GetPage(int32_t index) const
CXFA_Node * QueryOverflow(CXFA_Node *pFormNode)
absl::optional< BreakData > ProcessBreakAfter(const CXFA_Node *pBreakNode)
absl::optional< OverflowData > ProcessOverflow(CXFA_Node *pFormNode, bool bCreatePage)
bool PrepareFirstPage(CXFA_Node *pRootSubform)
bool InitLayoutPage(CXFA_Node *pFormNode)
CXFA_Node * ProcessBookendTrailer(const CXFA_Node *pBookendNode)
CXFA_ViewLayoutItem * GetRootLayoutItem() const
void Trace(cppgc::Visitor *visitor) const
CXFA_Node * ProcessBookendLeader(const CXFA_Node *pBookendNode)
absl::optional< BreakData > ProcessBreakBefore(const CXFA_Node *pBreakNode)
void SubmitContentItem(CXFA_ContentLayoutItem *pContentLayoutItem, CXFA_ContentLayoutProcessor::Result eStatus)
bool GetNextAvailContentHeight(float fChildHeight)
bool IsEmpty() const
Definition widestring.h:118
constexpr float kXFALayoutPrecision
XFA_VERSION
@ XFA_VERSION_207
XFA_NodeFlag
Definition cxfa_node.h:77
XFA_Unit
Definition fxfa_basic.h:91
XFA_Attribute
Definition fxfa_basic.h:67
XFA_Element
Definition fxfa_basic.h:75
XFA_AttributeValue
Definition fxfa_basic.h:60
#define CONSTRUCT_VIA_MAKE_GARBAGE_COLLECTED
Definition heap.h:32
Definition heap.h:12
#define CHECK(cvref)
UNOWNED_PTR_EXCLUSION CXFA_Node * pTrailer
UNOWNED_PTR_EXCLUSION CXFA_Node * pLeader
UNOWNED_PTR_EXCLUSION CXFA_Node * pTrailer
UNOWNED_PTR_EXCLUSION CXFA_Node * pLeader
#define UNOWNED_PTR_EXCLUSION