Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(422)

Side by Side Diff: xfa/fxfa/parser/cxfa_layoutpagemgr.cpp

Issue 2467203003: Remove FX_BOOL from xfa. (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « xfa/fxfa/parser/cxfa_layoutpagemgr.h ('k') | xfa/fxfa/parser/cxfa_layoutprocessor.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "xfa/fxfa/parser/cxfa_layoutpagemgr.h" 7 #include "xfa/fxfa/parser/cxfa_layoutpagemgr.h"
8 8
9 #include "xfa/fxfa/app/xfa_ffnotify.h" 9 #include "xfa/fxfa/app/xfa_ffnotify.h"
10 #include "xfa/fxfa/parser/cxfa_containerlayoutitem.h" 10 #include "xfa/fxfa/parser/cxfa_containerlayoutitem.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 (dwRelevant != XFA_WidgetStatus_Printable)) { 78 (dwRelevant != XFA_WidgetStatus_Printable)) {
79 dwRelevant &= ~XFA_WidgetStatus_Printable; 79 dwRelevant &= ~XFA_WidgetStatus_Printable;
80 } 80 }
81 return dwRelevant; 81 return dwRelevant;
82 } 82 }
83 83
84 void SyncContainer(CXFA_FFNotify* pNotify, 84 void SyncContainer(CXFA_FFNotify* pNotify,
85 CXFA_LayoutProcessor* pDocLayout, 85 CXFA_LayoutProcessor* pDocLayout,
86 CXFA_LayoutItem* pContainerItem, 86 CXFA_LayoutItem* pContainerItem,
87 uint32_t dwRelevant, 87 uint32_t dwRelevant,
88 FX_BOOL bVisible, 88 bool bVisible,
89 int32_t nPageIndex) { 89 int32_t nPageIndex) {
90 FX_BOOL bVisibleItem = FALSE; 90 bool bVisibleItem = false;
91 uint32_t dwStatus = 0; 91 uint32_t dwStatus = 0;
92 uint32_t dwRelevantContainer = 0; 92 uint32_t dwRelevantContainer = 0;
93 if (bVisible) { 93 if (bVisible) {
94 XFA_ATTRIBUTEENUM eAttributeValue = 94 XFA_ATTRIBUTEENUM eAttributeValue =
95 pContainerItem->m_pFormNode->GetEnum(XFA_ATTRIBUTE_Presence); 95 pContainerItem->m_pFormNode->GetEnum(XFA_ATTRIBUTE_Presence);
96 if (eAttributeValue == XFA_ATTRIBUTEENUM_Visible || 96 if (eAttributeValue == XFA_ATTRIBUTEENUM_Visible ||
97 eAttributeValue == XFA_ATTRIBUTEENUM_Unknown) { 97 eAttributeValue == XFA_ATTRIBUTEENUM_Unknown) {
98 bVisibleItem = TRUE; 98 bVisibleItem = true;
99 } 99 }
100 dwRelevantContainer = GetRelevant(pContainerItem->m_pFormNode, dwRelevant); 100 dwRelevantContainer = GetRelevant(pContainerItem->m_pFormNode, dwRelevant);
101 dwStatus = 101 dwStatus =
102 (bVisibleItem ? XFA_WidgetStatus_Visible : 0) | dwRelevantContainer; 102 (bVisibleItem ? XFA_WidgetStatus_Visible : 0) | dwRelevantContainer;
103 } 103 }
104 pNotify->OnLayoutItemAdded(pDocLayout, pContainerItem, nPageIndex, dwStatus); 104 pNotify->OnLayoutItemAdded(pDocLayout, pContainerItem, nPageIndex, dwStatus);
105 for (CXFA_LayoutItem* pChild = pContainerItem->m_pFirstChild; pChild; 105 for (CXFA_LayoutItem* pChild = pContainerItem->m_pFirstChild; pChild;
106 pChild = pChild->m_pNextSibling) { 106 pChild = pChild->m_pNextSibling) {
107 if (pChild->IsContentLayoutItem()) { 107 if (pChild->IsContentLayoutItem()) {
108 SyncContainer(pNotify, pDocLayout, pChild, dwRelevantContainer, 108 SyncContainer(pNotify, pDocLayout, pChild, dwRelevantContainer,
(...skipping 15 matching lines...) Expand all
124 void RemoveLayoutItem(CXFA_ContainerLayoutItem* pLayoutItem) { 124 void RemoveLayoutItem(CXFA_ContainerLayoutItem* pLayoutItem) {
125 CXFA_ContainerLayoutItem* pParentLayoutItem = 125 CXFA_ContainerLayoutItem* pParentLayoutItem =
126 static_cast<CXFA_ContainerLayoutItem*>(pLayoutItem->m_pParent); 126 static_cast<CXFA_ContainerLayoutItem*>(pLayoutItem->m_pParent);
127 if (!pParentLayoutItem) 127 if (!pParentLayoutItem)
128 return; 128 return;
129 129
130 pParentLayoutItem->RemoveChild(pLayoutItem); 130 pParentLayoutItem->RemoveChild(pLayoutItem);
131 } 131 }
132 132
133 CXFA_Node* ResolveBreakTarget(CXFA_Node* pPageSetRoot, 133 CXFA_Node* ResolveBreakTarget(CXFA_Node* pPageSetRoot,
134 FX_BOOL bNewExprStyle, 134 bool bNewExprStyle,
135 CFX_WideStringC& wsTargetExpr) { 135 CFX_WideStringC& wsTargetExpr) {
136 CXFA_Document* pDocument = pPageSetRoot->GetDocument(); 136 CXFA_Document* pDocument = pPageSetRoot->GetDocument();
137 if (wsTargetExpr.IsEmpty()) 137 if (wsTargetExpr.IsEmpty())
138 return nullptr; 138 return nullptr;
139 139
140 CFX_WideString wsTargetAll(wsTargetExpr); 140 CFX_WideString wsTargetAll(wsTargetExpr);
141 wsTargetAll.TrimLeft(); 141 wsTargetAll.TrimLeft();
142 wsTargetAll.TrimRight(); 142 wsTargetAll.TrimRight();
143 int32_t iSpliteIndex = 0; 143 int32_t iSpliteIndex = 0;
144 FX_BOOL bTargetAllFind = TRUE; 144 bool bTargetAllFind = true;
145 while (iSpliteIndex != -1) { 145 while (iSpliteIndex != -1) {
146 CFX_WideString wsExpr; 146 CFX_WideString wsExpr;
147 int32_t iSpliteNextIndex = 0; 147 int32_t iSpliteNextIndex = 0;
148 if (!bTargetAllFind) { 148 if (!bTargetAllFind) {
149 iSpliteNextIndex = wsTargetAll.Find(' ', iSpliteIndex); 149 iSpliteNextIndex = wsTargetAll.Find(' ', iSpliteIndex);
150 wsExpr = wsTargetAll.Mid(iSpliteIndex, iSpliteNextIndex - iSpliteIndex); 150 wsExpr = wsTargetAll.Mid(iSpliteIndex, iSpliteNextIndex - iSpliteIndex);
151 } else { 151 } else {
152 wsExpr = wsTargetAll; 152 wsExpr = wsTargetAll;
153 } 153 }
154 if (wsExpr.IsEmpty()) 154 if (wsExpr.IsEmpty())
155 return nullptr; 155 return nullptr;
156 156
157 bTargetAllFind = FALSE; 157 bTargetAllFind = false;
158 if (wsExpr.GetAt(0) == '#') { 158 if (wsExpr.GetAt(0) == '#') {
159 CXFA_Node* pNode = pDocument->GetNodeByID( 159 CXFA_Node* pNode = pDocument->GetNodeByID(
160 ToNode(pDocument->GetXFAObject(XFA_HASHCODE_Template)), 160 ToNode(pDocument->GetXFAObject(XFA_HASHCODE_Template)),
161 wsExpr.Mid(1).AsStringC()); 161 wsExpr.Mid(1).AsStringC());
162 if (pNode) 162 if (pNode)
163 return pNode; 163 return pNode;
164 } else if (bNewExprStyle) { 164 } else if (bNewExprStyle) {
165 CFX_WideString wsProcessedTarget = wsExpr; 165 CFX_WideString wsProcessedTarget = wsExpr;
166 if (wsExpr.Left(4) == FX_WSTRC(L"som(") && 166 if (wsExpr.Left(4) == FX_WSTRC(L"som(") &&
167 wsExpr.Right(1) == FX_WSTRC(L")")) { 167 wsExpr.Right(1) == FX_WSTRC(L")")) {
(...skipping 11 matching lines...) Expand all
179 iSpliteIndex = iSpliteNextIndex; 179 iSpliteIndex = iSpliteNextIndex;
180 } 180 }
181 return nullptr; 181 return nullptr;
182 } 182 }
183 183
184 void SetLayoutGeneratedNodeFlag(CXFA_Node* pNode) { 184 void SetLayoutGeneratedNodeFlag(CXFA_Node* pNode) {
185 pNode->SetFlag(XFA_NodeFlag_LayoutGeneratedNode, false); 185 pNode->SetFlag(XFA_NodeFlag_LayoutGeneratedNode, false);
186 pNode->ClearFlag(XFA_NodeFlag_UnusedNode); 186 pNode->ClearFlag(XFA_NodeFlag_UnusedNode);
187 } 187 }
188 188
189 FX_BOOL CheckContentAreaNotUsed( 189 bool CheckContentAreaNotUsed(
190 CXFA_ContainerLayoutItem* pPageAreaLayoutItem, 190 CXFA_ContainerLayoutItem* pPageAreaLayoutItem,
191 CXFA_Node* pContentArea, 191 CXFA_Node* pContentArea,
192 CXFA_ContainerLayoutItem*& pContentAreaLayoutItem) { 192 CXFA_ContainerLayoutItem*& pContentAreaLayoutItem) {
193 for (CXFA_ContainerLayoutItem* pLayoutItem = 193 for (CXFA_ContainerLayoutItem* pLayoutItem =
194 static_cast<CXFA_ContainerLayoutItem*>( 194 static_cast<CXFA_ContainerLayoutItem*>(
195 pPageAreaLayoutItem->m_pFirstChild); 195 pPageAreaLayoutItem->m_pFirstChild);
196 pLayoutItem; pLayoutItem = static_cast<CXFA_ContainerLayoutItem*>( 196 pLayoutItem; pLayoutItem = static_cast<CXFA_ContainerLayoutItem*>(
197 pLayoutItem->m_pNextSibling)) { 197 pLayoutItem->m_pNextSibling)) {
198 if (pLayoutItem->m_pFormNode == pContentArea) { 198 if (pLayoutItem->m_pFormNode == pContentArea) {
199 if (!pLayoutItem->m_pFirstChild) { 199 if (!pLayoutItem->m_pFirstChild) {
200 pContentAreaLayoutItem = pLayoutItem; 200 pContentAreaLayoutItem = pLayoutItem;
201 return TRUE; 201 return true;
202 } 202 }
203 return FALSE; 203 return false;
204 } 204 }
205 } 205 }
206 return TRUE; 206 return true;
207 } 207 }
208 208
209 void SyncRemoveLayoutItem(CXFA_LayoutItem* pParentLayoutItem, 209 void SyncRemoveLayoutItem(CXFA_LayoutItem* pParentLayoutItem,
210 CXFA_FFNotify* pNotify, 210 CXFA_FFNotify* pNotify,
211 CXFA_LayoutProcessor* pDocLayout) { 211 CXFA_LayoutProcessor* pDocLayout) {
212 CXFA_LayoutItem* pNextLayoutItem; 212 CXFA_LayoutItem* pNextLayoutItem;
213 CXFA_LayoutItem* pCurLayoutItem = pParentLayoutItem->m_pFirstChild; 213 CXFA_LayoutItem* pCurLayoutItem = pParentLayoutItem->m_pFirstChild;
214 while (pCurLayoutItem) { 214 while (pCurLayoutItem) {
215 pNextLayoutItem = pCurLayoutItem->m_pNextSibling; 215 pNextLayoutItem = pCurLayoutItem->m_pNextSibling;
216 if (pCurLayoutItem->m_pFirstChild) 216 if (pCurLayoutItem->m_pFirstChild)
(...skipping 24 matching lines...) Expand all
241 CXFA_LayoutPageMgr::CXFA_LayoutPageMgr(CXFA_LayoutProcessor* pLayoutProcessor) 241 CXFA_LayoutPageMgr::CXFA_LayoutPageMgr(CXFA_LayoutProcessor* pLayoutProcessor)
242 : m_pLayoutProcessor(pLayoutProcessor), 242 : m_pLayoutProcessor(pLayoutProcessor),
243 m_pTemplatePageSetRoot(nullptr), 243 m_pTemplatePageSetRoot(nullptr),
244 m_pPageSetLayoutItemRoot(nullptr), 244 m_pPageSetLayoutItemRoot(nullptr),
245 m_pPageSetCurRoot(nullptr), 245 m_pPageSetCurRoot(nullptr),
246 m_pCurrentContainerRecord(nullptr), 246 m_pCurrentContainerRecord(nullptr),
247 m_pCurPageArea(nullptr), 247 m_pCurPageArea(nullptr),
248 m_nAvailPages(0), 248 m_nAvailPages(0),
249 m_nCurPageCount(0), 249 m_nCurPageCount(0),
250 m_ePageSetMode(XFA_ATTRIBUTEENUM_OrderedOccurrence), 250 m_ePageSetMode(XFA_ATTRIBUTEENUM_OrderedOccurrence),
251 m_bCreateOverFlowPage(FALSE) {} 251 m_bCreateOverFlowPage(false) {}
252 252
253 CXFA_LayoutPageMgr::~CXFA_LayoutPageMgr() { 253 CXFA_LayoutPageMgr::~CXFA_LayoutPageMgr() {
254 ClearData(); 254 ClearData();
255 CXFA_LayoutItem* pLayoutItem = GetRootLayoutItem(); 255 CXFA_LayoutItem* pLayoutItem = GetRootLayoutItem();
256 CXFA_LayoutItem* pNextLayout = nullptr; 256 CXFA_LayoutItem* pNextLayout = nullptr;
257 for (; pLayoutItem; pLayoutItem = pNextLayout) { 257 for (; pLayoutItem; pLayoutItem = pNextLayout) {
258 pNextLayout = pLayoutItem->m_pNextSibling; 258 pNextLayout = pLayoutItem->m_pNextSibling;
259 XFA_ReleaseLayoutItem(pLayoutItem); 259 XFA_ReleaseLayoutItem(pLayoutItem);
260 } 260 }
261 } 261 }
262 262
263 FX_BOOL CXFA_LayoutPageMgr::InitLayoutPage(CXFA_Node* pFormNode) { 263 bool CXFA_LayoutPageMgr::InitLayoutPage(CXFA_Node* pFormNode) {
264 PrepareLayout(); 264 PrepareLayout();
265 CXFA_Node* pTemplateNode = pFormNode->GetTemplateNode(); 265 CXFA_Node* pTemplateNode = pFormNode->GetTemplateNode();
266 if (!pTemplateNode) 266 if (!pTemplateNode)
267 return FALSE; 267 return false;
268 268
269 m_pTemplatePageSetRoot = pTemplateNode->GetProperty(0, XFA_Element::PageSet); 269 m_pTemplatePageSetRoot = pTemplateNode->GetProperty(0, XFA_Element::PageSet);
270 ASSERT(m_pTemplatePageSetRoot); 270 ASSERT(m_pTemplatePageSetRoot);
271 if (m_pPageSetLayoutItemRoot) { 271 if (m_pPageSetLayoutItemRoot) {
272 m_pPageSetLayoutItemRoot->m_pParent = nullptr; 272 m_pPageSetLayoutItemRoot->m_pParent = nullptr;
273 m_pPageSetLayoutItemRoot->m_pFirstChild = nullptr; 273 m_pPageSetLayoutItemRoot->m_pFirstChild = nullptr;
274 m_pPageSetLayoutItemRoot->m_pNextSibling = nullptr; 274 m_pPageSetLayoutItemRoot->m_pNextSibling = nullptr;
275 m_pPageSetLayoutItemRoot->m_pFormNode = m_pTemplatePageSetRoot; 275 m_pPageSetLayoutItemRoot->m_pFormNode = m_pTemplatePageSetRoot;
276 } else { 276 } else {
277 m_pPageSetLayoutItemRoot = 277 m_pPageSetLayoutItemRoot =
278 new CXFA_ContainerLayoutItem(m_pTemplatePageSetRoot); 278 new CXFA_ContainerLayoutItem(m_pTemplatePageSetRoot);
279 } 279 }
280 m_pPageSetCurRoot = m_pPageSetLayoutItemRoot; 280 m_pPageSetCurRoot = m_pPageSetLayoutItemRoot;
281 m_pTemplatePageSetRoot->SetUserData(XFA_LAYOUTITEMKEY, 281 m_pTemplatePageSetRoot->SetUserData(XFA_LAYOUTITEMKEY,
282 (void*)m_pPageSetLayoutItemRoot); 282 (void*)m_pPageSetLayoutItemRoot);
283 XFA_ATTRIBUTEENUM eRelation = 283 XFA_ATTRIBUTEENUM eRelation =
284 m_pTemplatePageSetRoot->GetEnum(XFA_ATTRIBUTE_Relation); 284 m_pTemplatePageSetRoot->GetEnum(XFA_ATTRIBUTE_Relation);
285 if (eRelation != XFA_ATTRIBUTEENUM_Unknown) 285 if (eRelation != XFA_ATTRIBUTEENUM_Unknown)
286 m_ePageSetMode = eRelation; 286 m_ePageSetMode = eRelation;
287 287
288 InitPageSetMap(); 288 InitPageSetMap();
289 CXFA_Node* pPageArea = nullptr; 289 CXFA_Node* pPageArea = nullptr;
290 int32_t iCount = 0; 290 int32_t iCount = 0;
291 for (pPageArea = m_pTemplatePageSetRoot->GetNodeItem(XFA_NODEITEM_FirstChild); 291 for (pPageArea = m_pTemplatePageSetRoot->GetNodeItem(XFA_NODEITEM_FirstChild);
292 pPageArea; 292 pPageArea;
293 pPageArea = pPageArea->GetNodeItem(XFA_NODEITEM_NextSibling)) { 293 pPageArea = pPageArea->GetNodeItem(XFA_NODEITEM_NextSibling)) {
294 if (pPageArea->GetElementType() == XFA_Element::PageArea) { 294 if (pPageArea->GetElementType() == XFA_Element::PageArea) {
295 iCount++; 295 iCount++;
296 if (pPageArea->GetFirstChildByClass(XFA_Element::ContentArea)) 296 if (pPageArea->GetFirstChildByClass(XFA_Element::ContentArea))
297 return TRUE; 297 return true;
298 } 298 }
299 } 299 }
300 if (iCount > 0) 300 if (iCount > 0)
301 return FALSE; 301 return false;
302 302
303 CXFA_Document* pDocument = pTemplateNode->GetDocument(); 303 CXFA_Document* pDocument = pTemplateNode->GetDocument();
304 pPageArea = m_pTemplatePageSetRoot->GetChild(0, XFA_Element::PageArea); 304 pPageArea = m_pTemplatePageSetRoot->GetChild(0, XFA_Element::PageArea);
305 if (!pPageArea) { 305 if (!pPageArea) {
306 pPageArea = pDocument->CreateNode(m_pTemplatePageSetRoot->GetPacketID(), 306 pPageArea = pDocument->CreateNode(m_pTemplatePageSetRoot->GetPacketID(),
307 XFA_Element::PageArea); 307 XFA_Element::PageArea);
308 if (!pPageArea) 308 if (!pPageArea)
309 return FALSE; 309 return false;
310 310
311 m_pTemplatePageSetRoot->InsertChild(pPageArea, nullptr); 311 m_pTemplatePageSetRoot->InsertChild(pPageArea, nullptr);
312 pPageArea->SetFlag(XFA_NodeFlag_Initialized, true); 312 pPageArea->SetFlag(XFA_NodeFlag_Initialized, true);
313 } 313 }
314 CXFA_Node* pContentArea = pPageArea->GetChild(0, XFA_Element::ContentArea); 314 CXFA_Node* pContentArea = pPageArea->GetChild(0, XFA_Element::ContentArea);
315 if (!pContentArea) { 315 if (!pContentArea) {
316 pContentArea = pDocument->CreateNode(pPageArea->GetPacketID(), 316 pContentArea = pDocument->CreateNode(pPageArea->GetPacketID(),
317 XFA_Element::ContentArea); 317 XFA_Element::ContentArea);
318 if (!pContentArea) 318 if (!pContentArea)
319 return FALSE; 319 return false;
320 320
321 pPageArea->InsertChild(pContentArea, nullptr); 321 pPageArea->InsertChild(pContentArea, nullptr);
322 pContentArea->SetFlag(XFA_NodeFlag_Initialized, true); 322 pContentArea->SetFlag(XFA_NodeFlag_Initialized, true);
323 pContentArea->SetMeasure(XFA_ATTRIBUTE_X, 323 pContentArea->SetMeasure(XFA_ATTRIBUTE_X,
324 CXFA_Measurement(0.25f, XFA_UNIT_In)); 324 CXFA_Measurement(0.25f, XFA_UNIT_In));
325 pContentArea->SetMeasure(XFA_ATTRIBUTE_Y, 325 pContentArea->SetMeasure(XFA_ATTRIBUTE_Y,
326 CXFA_Measurement(0.25f, XFA_UNIT_In)); 326 CXFA_Measurement(0.25f, XFA_UNIT_In));
327 pContentArea->SetMeasure(XFA_ATTRIBUTE_W, 327 pContentArea->SetMeasure(XFA_ATTRIBUTE_W,
328 CXFA_Measurement(8.0f, XFA_UNIT_In)); 328 CXFA_Measurement(8.0f, XFA_UNIT_In));
329 pContentArea->SetMeasure(XFA_ATTRIBUTE_H, 329 pContentArea->SetMeasure(XFA_ATTRIBUTE_H,
330 CXFA_Measurement(10.5f, XFA_UNIT_In)); 330 CXFA_Measurement(10.5f, XFA_UNIT_In));
331 } 331 }
332 CXFA_Node* pMedium = pPageArea->GetChild(0, XFA_Element::Medium); 332 CXFA_Node* pMedium = pPageArea->GetChild(0, XFA_Element::Medium);
333 if (!pMedium) { 333 if (!pMedium) {
334 pMedium = 334 pMedium =
335 pDocument->CreateNode(pPageArea->GetPacketID(), XFA_Element::Medium); 335 pDocument->CreateNode(pPageArea->GetPacketID(), XFA_Element::Medium);
336 if (!pContentArea) 336 if (!pContentArea)
337 return FALSE; 337 return false;
338 338
339 pPageArea->InsertChild(pMedium, nullptr); 339 pPageArea->InsertChild(pMedium, nullptr);
340 pMedium->SetFlag(XFA_NodeFlag_Initialized, true); 340 pMedium->SetFlag(XFA_NodeFlag_Initialized, true);
341 pMedium->SetMeasure(XFA_ATTRIBUTE_Short, 341 pMedium->SetMeasure(XFA_ATTRIBUTE_Short,
342 CXFA_Measurement(8.5f, XFA_UNIT_In)); 342 CXFA_Measurement(8.5f, XFA_UNIT_In));
343 pMedium->SetMeasure(XFA_ATTRIBUTE_Long, 343 pMedium->SetMeasure(XFA_ATTRIBUTE_Long,
344 CXFA_Measurement(11.0f, XFA_UNIT_In)); 344 CXFA_Measurement(11.0f, XFA_UNIT_In));
345 } 345 }
346 return TRUE; 346 return true;
347 } 347 }
348 348
349 FX_BOOL CXFA_LayoutPageMgr::PrepareFirstPage(CXFA_Node* pRootSubform) { 349 bool CXFA_LayoutPageMgr::PrepareFirstPage(CXFA_Node* pRootSubform) {
350 FX_BOOL bProBreakBefore = FALSE; 350 bool bProBreakBefore = false;
351 CXFA_Node* pBreakBeforeNode = nullptr; 351 CXFA_Node* pBreakBeforeNode = nullptr;
352 while (pRootSubform) { 352 while (pRootSubform) {
353 for (CXFA_Node* pBreakNode = 353 for (CXFA_Node* pBreakNode =
354 pRootSubform->GetNodeItem(XFA_NODEITEM_FirstChild); 354 pRootSubform->GetNodeItem(XFA_NODEITEM_FirstChild);
355 pBreakNode; 355 pBreakNode;
356 pBreakNode = pBreakNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { 356 pBreakNode = pBreakNode->GetNodeItem(XFA_NODEITEM_NextSibling)) {
357 XFA_Element eType = pBreakNode->GetElementType(); 357 XFA_Element eType = pBreakNode->GetElementType();
358 if (eType == XFA_Element::BreakBefore || 358 if (eType == XFA_Element::BreakBefore ||
359 (eType == XFA_Element::Break && 359 (eType == XFA_Element::Break &&
360 pBreakNode->GetEnum(XFA_ATTRIBUTE_Before) != 360 pBreakNode->GetEnum(XFA_ATTRIBUTE_Before) !=
361 XFA_ATTRIBUTEENUM_Auto)) { 361 XFA_ATTRIBUTEENUM_Auto)) {
362 bProBreakBefore = TRUE; 362 bProBreakBefore = true;
363 pBreakBeforeNode = pBreakNode; 363 pBreakBeforeNode = pBreakNode;
364 break; 364 break;
365 } 365 }
366 } 366 }
367 if (bProBreakBefore) 367 if (bProBreakBefore)
368 break; 368 break;
369 369
370 bProBreakBefore = TRUE; 370 bProBreakBefore = true;
371 pRootSubform = pRootSubform->GetFirstChildByClass(XFA_Element::Subform); 371 pRootSubform = pRootSubform->GetFirstChildByClass(XFA_Element::Subform);
372 while (pRootSubform && 372 while (pRootSubform &&
373 !XFA_ItemLayoutProcessor_IsTakingSpace(pRootSubform)) { 373 !XFA_ItemLayoutProcessor_IsTakingSpace(pRootSubform)) {
374 pRootSubform = 374 pRootSubform =
375 pRootSubform->GetNextSameClassSibling(XFA_Element::Subform); 375 pRootSubform->GetNextSameClassSibling(XFA_Element::Subform);
376 } 376 }
377 } 377 }
378 CXFA_Node *pLeader, *pTrailer; 378 CXFA_Node *pLeader, *pTrailer;
379 if (pBreakBeforeNode && 379 if (pBreakBeforeNode &&
380 ExecuteBreakBeforeOrAfter(pBreakBeforeNode, TRUE, pLeader, pTrailer)) { 380 ExecuteBreakBeforeOrAfter(pBreakBeforeNode, true, pLeader, pTrailer)) {
381 m_pCurrentContainerRecord = m_rgProposedContainerRecord.GetHeadPosition(); 381 m_pCurrentContainerRecord = m_rgProposedContainerRecord.GetHeadPosition();
382 return TRUE; 382 return true;
383 } 383 }
384 return AppendNewPage(TRUE); 384 return AppendNewPage(true);
385 } 385 }
386 386
387 FX_BOOL CXFA_LayoutPageMgr::AppendNewPage(FX_BOOL bFirstTemPage) { 387 bool CXFA_LayoutPageMgr::AppendNewPage(bool bFirstTemPage) {
388 if (m_pCurrentContainerRecord != 388 if (m_pCurrentContainerRecord !=
389 m_rgProposedContainerRecord.GetTailPosition()) { 389 m_rgProposedContainerRecord.GetTailPosition()) {
390 return TRUE; 390 return true;
391 } 391 }
392 CXFA_Node* pPageNode = GetNextAvailPageArea(nullptr); 392 CXFA_Node* pPageNode = GetNextAvailPageArea(nullptr);
393 if (!pPageNode) 393 if (!pPageNode)
394 return FALSE; 394 return false;
395 if (bFirstTemPage && !m_pCurrentContainerRecord) 395 if (bFirstTemPage && !m_pCurrentContainerRecord)
396 m_pCurrentContainerRecord = m_rgProposedContainerRecord.GetHeadPosition(); 396 m_pCurrentContainerRecord = m_rgProposedContainerRecord.GetHeadPosition();
397 return !bFirstTemPage || m_pCurrentContainerRecord; 397 return !bFirstTemPage || m_pCurrentContainerRecord;
398 } 398 }
399 399
400 void CXFA_LayoutPageMgr::RemoveLayoutRecord(CXFA_ContainerRecord* pNewRecord, 400 void CXFA_LayoutPageMgr::RemoveLayoutRecord(CXFA_ContainerRecord* pNewRecord,
401 CXFA_ContainerRecord* pPrevRecord) { 401 CXFA_ContainerRecord* pPrevRecord) {
402 if (!pNewRecord || !pPrevRecord) 402 if (!pNewRecord || !pPrevRecord)
403 return; 403 return;
404 if (pNewRecord->pCurPageSet != pPrevRecord->pCurPageSet) { 404 if (pNewRecord->pCurPageSet != pPrevRecord->pCurPageSet) {
(...skipping 27 matching lines...) Expand all
432 ReorderLayoutItemToTail(pNewRecord->pCurContentArea); 432 ReorderLayoutItemToTail(pNewRecord->pCurContentArea);
433 return; 433 return;
434 } 434 }
435 } 435 }
436 436
437 void CXFA_LayoutPageMgr::SubmitContentItem( 437 void CXFA_LayoutPageMgr::SubmitContentItem(
438 CXFA_ContentLayoutItem* pContentLayoutItem, 438 CXFA_ContentLayoutItem* pContentLayoutItem,
439 XFA_ItemLayoutProcessorResult eStatus) { 439 XFA_ItemLayoutProcessorResult eStatus) {
440 if (pContentLayoutItem) { 440 if (pContentLayoutItem) {
441 GetCurrentContainerRecord()->pCurContentArea->AddChild(pContentLayoutItem); 441 GetCurrentContainerRecord()->pCurContentArea->AddChild(pContentLayoutItem);
442 m_bCreateOverFlowPage = FALSE; 442 m_bCreateOverFlowPage = false;
443 } 443 }
444 444
445 if (eStatus != XFA_ItemLayoutProcessorResult_Done) { 445 if (eStatus != XFA_ItemLayoutProcessorResult_Done) {
446 if (eStatus == XFA_ItemLayoutProcessorResult_PageFullBreak && 446 if (eStatus == XFA_ItemLayoutProcessorResult_PageFullBreak &&
447 m_pCurrentContainerRecord == 447 m_pCurrentContainerRecord ==
448 m_rgProposedContainerRecord.GetTailPosition()) { 448 m_rgProposedContainerRecord.GetTailPosition()) {
449 AppendNewPage(); 449 AppendNewPage();
450 } 450 }
451 m_pCurrentContainerRecord = m_rgProposedContainerRecord.GetTailPosition(); 451 m_pCurrentContainerRecord = m_rgProposedContainerRecord.GetTailPosition();
452 m_pCurPageArea = GetCurrentContainerRecord()->pCurPageArea->m_pFormNode; 452 m_pCurPageArea = GetCurrentContainerRecord()->pCurPageArea->m_pFormNode;
(...skipping 10 matching lines...) Expand all
463 pLayoutItem->m_pFormNode->GetMeasure(XFA_ATTRIBUTE_H).ToUnit(XFA_UNIT_Pt); 463 pLayoutItem->m_pFormNode->GetMeasure(XFA_ATTRIBUTE_H).ToUnit(XFA_UNIT_Pt);
464 if (fAvailHeight >= XFA_LAYOUT_FLOAT_PERCISION) 464 if (fAvailHeight >= XFA_LAYOUT_FLOAT_PERCISION)
465 return fAvailHeight; 465 return fAvailHeight;
466 if (m_pCurrentContainerRecord == 466 if (m_pCurrentContainerRecord ==
467 m_rgProposedContainerRecord.GetHeadPosition()) { 467 m_rgProposedContainerRecord.GetHeadPosition()) {
468 return 0.0f; 468 return 0.0f;
469 } 469 }
470 return XFA_LAYOUT_FLOAT_MAX; 470 return XFA_LAYOUT_FLOAT_MAX;
471 } 471 }
472 472
473 FX_BOOL XFA_LayoutPageMgr_RunBreakTestScript(CXFA_Node* pTestScript) { 473 bool XFA_LayoutPageMgr_RunBreakTestScript(CXFA_Node* pTestScript) {
474 CFX_WideString wsExpression; 474 CFX_WideString wsExpression;
475 pTestScript->TryContent(wsExpression); 475 pTestScript->TryContent(wsExpression);
476 if (wsExpression.IsEmpty()) 476 if (wsExpression.IsEmpty())
477 return TRUE; 477 return true;
478 return pTestScript->GetDocument()->GetNotify()->RunScript( 478 return pTestScript->GetDocument()->GetNotify()->RunScript(
479 pTestScript, pTestScript->GetNodeItem(XFA_NODEITEM_Parent, 479 pTestScript, pTestScript->GetNodeItem(XFA_NODEITEM_Parent,
480 XFA_ObjectType::ContainerNode)); 480 XFA_ObjectType::ContainerNode));
481 } 481 }
482 482
483 CXFA_ContainerRecord* CXFA_LayoutPageMgr::CreateContainerRecord( 483 CXFA_ContainerRecord* CXFA_LayoutPageMgr::CreateContainerRecord(
484 CXFA_Node* pPageNode, 484 CXFA_Node* pPageNode,
485 FX_BOOL bCreateNew) { 485 bool bCreateNew) {
486 CXFA_ContainerRecord* pNewRecord = new CXFA_ContainerRecord(); 486 CXFA_ContainerRecord* pNewRecord = new CXFA_ContainerRecord();
487 if (m_pCurrentContainerRecord) { 487 if (m_pCurrentContainerRecord) {
488 if (!IsPageSetRootOrderedOccurrence() || !pPageNode) { 488 if (!IsPageSetRootOrderedOccurrence() || !pPageNode) {
489 *pNewRecord = *GetCurrentContainerRecord(); 489 *pNewRecord = *GetCurrentContainerRecord();
490 m_rgProposedContainerRecord.AddTail(pNewRecord); 490 m_rgProposedContainerRecord.AddTail(pNewRecord);
491 return pNewRecord; 491 return pNewRecord;
492 } 492 }
493 CXFA_Node* pPageSet = pPageNode->GetNodeItem(XFA_NODEITEM_Parent); 493 CXFA_Node* pPageSet = pPageNode->GetNodeItem(XFA_NODEITEM_Parent);
494 if (!bCreateNew) { 494 if (!bCreateNew) {
495 if (pPageSet == m_pTemplatePageSetRoot) { 495 if (pPageSet == m_pTemplatePageSetRoot) {
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
615 continue; 615 continue;
616 } 616 }
617 nPageAreaCount++; 617 nPageAreaCount++;
618 pLastPageAreaLayoutItem = pPageAreaLayoutItem; 618 pLastPageAreaLayoutItem = pPageAreaLayoutItem;
619 } 619 }
620 if (!pLastPageAreaLayoutItem) 620 if (!pLastPageAreaLayoutItem)
621 break; 621 break;
622 622
623 if (!FindPageAreaFromPageSet_SimplexDuplex( 623 if (!FindPageAreaFromPageSet_SimplexDuplex(
624 pPageSetLayoutItem->m_pFormNode, nullptr, nullptr, nullptr, 624 pPageSetLayoutItem->m_pFormNode, nullptr, nullptr, nullptr,
625 TRUE, TRUE, nPageAreaCount == 1 ? XFA_ATTRIBUTEENUM_Only 625 true, true, nPageAreaCount == 1 ? XFA_ATTRIBUTEENUM_Only
626 : XFA_ATTRIBUTEENUM_Last) && 626 : XFA_ATTRIBUTEENUM_Last) &&
627 (nPageAreaCount == 1 && 627 (nPageAreaCount == 1 &&
628 !FindPageAreaFromPageSet_SimplexDuplex( 628 !FindPageAreaFromPageSet_SimplexDuplex(
629 pPageSetLayoutItem->m_pFormNode, nullptr, nullptr, nullptr, 629 pPageSetLayoutItem->m_pFormNode, nullptr, nullptr, nullptr,
630 TRUE, TRUE, XFA_ATTRIBUTEENUM_Last))) { 630 true, true, XFA_ATTRIBUTEENUM_Last))) {
631 break; 631 break;
632 } 632 }
633 CXFA_Node* pNode = m_pCurPageArea; 633 CXFA_Node* pNode = m_pCurPageArea;
634 XFA_ATTRIBUTEENUM eCurChoice = 634 XFA_ATTRIBUTEENUM eCurChoice =
635 pNode->GetEnum(XFA_ATTRIBUTE_PagePosition); 635 pNode->GetEnum(XFA_ATTRIBUTE_PagePosition);
636 if (eCurChoice == XFA_ATTRIBUTEENUM_Last) { 636 if (eCurChoice == XFA_ATTRIBUTEENUM_Last) {
637 XFA_ATTRIBUTEENUM eOddOrEven = XFA_ATTRIBUTEENUM_Any; 637 XFA_ATTRIBUTEENUM eOddOrEven = XFA_ATTRIBUTEENUM_Any;
638 pNode->TryEnum(XFA_ATTRIBUTE_OddOrEven, eOddOrEven); 638 pNode->TryEnum(XFA_ATTRIBUTE_OddOrEven, eOddOrEven);
639 XFA_ATTRIBUTEENUM eLastChoice = 639 XFA_ATTRIBUTEENUM eLastChoice =
640 pLastPageAreaLayoutItem->m_pFormNode->GetEnum( 640 pLastPageAreaLayoutItem->m_pFormNode->GetEnum(
641 XFA_ATTRIBUTE_PagePosition); 641 XFA_ATTRIBUTE_PagePosition);
642 if (eLastChoice == XFA_ATTRIBUTEENUM_First && 642 if (eLastChoice == XFA_ATTRIBUTEENUM_First &&
643 (ePageRelation == XFA_ATTRIBUTEENUM_SimplexPaginated || 643 (ePageRelation == XFA_ATTRIBUTEENUM_SimplexPaginated ||
644 eOddOrEven != XFA_ATTRIBUTEENUM_Odd)) { 644 eOddOrEven != XFA_ATTRIBUTEENUM_Odd)) {
645 CXFA_ContainerRecord* pRecord = CreateContainerRecord(); 645 CXFA_ContainerRecord* pRecord = CreateContainerRecord();
646 AddPageAreaLayoutItem(pRecord, pNode); 646 AddPageAreaLayoutItem(pRecord, pNode);
647 break; 647 break;
648 } 648 }
649 } 649 }
650 FX_BOOL bUsable = TRUE; 650 bool bUsable = true;
651 CFX_ArrayTemplate<FX_FLOAT> rgUsedHeights; 651 CFX_ArrayTemplate<FX_FLOAT> rgUsedHeights;
652 for (CXFA_LayoutItem* pChildLayoutItem = 652 for (CXFA_LayoutItem* pChildLayoutItem =
653 pLastPageAreaLayoutItem->m_pFirstChild; 653 pLastPageAreaLayoutItem->m_pFirstChild;
654 pChildLayoutItem; 654 pChildLayoutItem;
655 pChildLayoutItem = pChildLayoutItem->m_pNextSibling) { 655 pChildLayoutItem = pChildLayoutItem->m_pNextSibling) {
656 if (pChildLayoutItem->m_pFormNode->GetElementType() != 656 if (pChildLayoutItem->m_pFormNode->GetElementType() !=
657 XFA_Element::ContentArea) { 657 XFA_Element::ContentArea) {
658 continue; 658 continue;
659 } 659 }
660 FX_FLOAT fUsedHeight = 0; 660 FX_FLOAT fUsedHeight = 0;
(...skipping 17 matching lines...) Expand all
678 pContentAreaNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { 678 pContentAreaNode->GetNodeItem(XFA_NODEITEM_NextSibling)) {
679 if (pContentAreaNode->GetElementType() != 679 if (pContentAreaNode->GetElementType() !=
680 XFA_Element::ContentArea) { 680 XFA_Element::ContentArea) {
681 continue; 681 continue;
682 } 682 }
683 iCurContentAreaIndex++; 683 iCurContentAreaIndex++;
684 if (rgUsedHeights[iCurContentAreaIndex] > 684 if (rgUsedHeights[iCurContentAreaIndex] >
685 pContentAreaNode->GetMeasure(XFA_ATTRIBUTE_H) 685 pContentAreaNode->GetMeasure(XFA_ATTRIBUTE_H)
686 .ToUnit(XFA_UNIT_Pt) + 686 .ToUnit(XFA_UNIT_Pt) +
687 XFA_LAYOUT_FLOAT_PERCISION) { 687 XFA_LAYOUT_FLOAT_PERCISION) {
688 bUsable = FALSE; 688 bUsable = false;
689 break; 689 break;
690 } 690 }
691 } 691 }
692 if (bUsable) { 692 if (bUsable) {
693 CXFA_LayoutItem* pChildLayoutItem = 693 CXFA_LayoutItem* pChildLayoutItem =
694 pLastPageAreaLayoutItem->m_pFirstChild; 694 pLastPageAreaLayoutItem->m_pFirstChild;
695 CXFA_Node* pContentAreaNode = 695 CXFA_Node* pContentAreaNode =
696 pNode->GetNodeItem(XFA_NODEITEM_FirstChild); 696 pNode->GetNodeItem(XFA_NODEITEM_FirstChild);
697 pLastPageAreaLayoutItem->m_pFormNode = pNode; 697 pLastPageAreaLayoutItem->m_pFormNode = pNode;
698 while (pChildLayoutItem && pContentAreaNode) { 698 while (pChildLayoutItem && pContentAreaNode) {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
732 return nullptr; 732 return nullptr;
733 return m_PageArray[index]; 733 return m_PageArray[index];
734 } 734 }
735 735
736 int32_t CXFA_LayoutPageMgr::GetPageIndex( 736 int32_t CXFA_LayoutPageMgr::GetPageIndex(
737 const CXFA_ContainerLayoutItem* pPage) const { 737 const CXFA_ContainerLayoutItem* pPage) const {
738 // FIXME: Find() method should take const. 738 // FIXME: Find() method should take const.
739 return m_PageArray.Find(const_cast<CXFA_ContainerLayoutItem*>(pPage)); 739 return m_PageArray.Find(const_cast<CXFA_ContainerLayoutItem*>(pPage));
740 } 740 }
741 741
742 FX_BOOL CXFA_LayoutPageMgr::RunBreak(XFA_Element eBreakType, 742 bool CXFA_LayoutPageMgr::RunBreak(XFA_Element eBreakType,
743 XFA_ATTRIBUTEENUM eTargetType, 743 XFA_ATTRIBUTEENUM eTargetType,
744 CXFA_Node* pTarget, 744 CXFA_Node* pTarget,
745 FX_BOOL bStartNew) { 745 bool bStartNew) {
746 FX_BOOL bRet = FALSE; 746 bool bRet = false;
747 switch (eTargetType) { 747 switch (eTargetType) {
748 case XFA_ATTRIBUTEENUM_ContentArea: 748 case XFA_ATTRIBUTEENUM_ContentArea:
749 if (pTarget && pTarget->GetElementType() != XFA_Element::ContentArea) 749 if (pTarget && pTarget->GetElementType() != XFA_Element::ContentArea)
750 pTarget = nullptr; 750 pTarget = nullptr;
751 if (!pTarget || !m_pCurrentContainerRecord || 751 if (!pTarget || !m_pCurrentContainerRecord ||
752 pTarget != 752 pTarget !=
753 GetCurrentContainerRecord()->pCurContentArea->m_pFormNode || 753 GetCurrentContainerRecord()->pCurContentArea->m_pFormNode ||
754 bStartNew) { 754 bStartNew) {
755 CXFA_Node* pPageArea = nullptr; 755 CXFA_Node* pPageArea = nullptr;
756 if (pTarget) 756 if (pTarget)
757 pPageArea = pTarget->GetNodeItem(XFA_NODEITEM_Parent); 757 pPageArea = pTarget->GetNodeItem(XFA_NODEITEM_Parent);
758 758
759 pPageArea = GetNextAvailPageArea(pPageArea, pTarget); 759 pPageArea = GetNextAvailPageArea(pPageArea, pTarget);
760 bRet = !!pPageArea; 760 bRet = !!pPageArea;
761 } 761 }
762 break; 762 break;
763 case XFA_ATTRIBUTEENUM_PageArea: 763 case XFA_ATTRIBUTEENUM_PageArea:
764 if (pTarget && pTarget->GetElementType() != XFA_Element::PageArea) 764 if (pTarget && pTarget->GetElementType() != XFA_Element::PageArea)
765 pTarget = nullptr; 765 pTarget = nullptr;
766 if (!pTarget || !m_pCurrentContainerRecord || 766 if (!pTarget || !m_pCurrentContainerRecord ||
767 pTarget != GetCurrentContainerRecord()->pCurPageArea->m_pFormNode || 767 pTarget != GetCurrentContainerRecord()->pCurPageArea->m_pFormNode ||
768 bStartNew) { 768 bStartNew) {
769 CXFA_Node* pPageArea = GetNextAvailPageArea(pTarget, nullptr, TRUE); 769 CXFA_Node* pPageArea = GetNextAvailPageArea(pTarget, nullptr, true);
770 bRet = !!pPageArea; 770 bRet = !!pPageArea;
771 } 771 }
772 break; 772 break;
773 case XFA_ATTRIBUTEENUM_PageOdd: 773 case XFA_ATTRIBUTEENUM_PageOdd:
774 if (pTarget && pTarget->GetElementType() != XFA_Element::PageArea) 774 if (pTarget && pTarget->GetElementType() != XFA_Element::PageArea)
775 pTarget = nullptr; 775 pTarget = nullptr;
776 break; 776 break;
777 case XFA_ATTRIBUTEENUM_PageEven: 777 case XFA_ATTRIBUTEENUM_PageEven:
778 if (pTarget && pTarget->GetElementType() != XFA_Element::PageArea) 778 if (pTarget && pTarget->GetElementType() != XFA_Element::PageArea)
779 pTarget = nullptr; 779 pTarget = nullptr;
780 break; 780 break;
781 case XFA_ATTRIBUTEENUM_Auto: 781 case XFA_ATTRIBUTEENUM_Auto:
782 default: 782 default:
783 break; 783 break;
784 } 784 }
785 return bRet; 785 return bRet;
786 } 786 }
787 787
788 FX_BOOL CXFA_LayoutPageMgr::ExecuteBreakBeforeOrAfter( 788 bool CXFA_LayoutPageMgr::ExecuteBreakBeforeOrAfter(
789 CXFA_Node* pCurNode, 789 CXFA_Node* pCurNode,
790 FX_BOOL bBefore, 790 bool bBefore,
791 CXFA_Node*& pBreakLeaderTemplate, 791 CXFA_Node*& pBreakLeaderTemplate,
792 CXFA_Node*& pBreakTrailerTemplate) { 792 CXFA_Node*& pBreakTrailerTemplate) {
793 XFA_Element eType = pCurNode->GetElementType(); 793 XFA_Element eType = pCurNode->GetElementType();
794 switch (eType) { 794 switch (eType) {
795 case XFA_Element::BreakBefore: 795 case XFA_Element::BreakBefore:
796 case XFA_Element::BreakAfter: { 796 case XFA_Element::BreakAfter: {
797 CFX_WideStringC wsBreakLeader, wsBreakTrailer; 797 CFX_WideStringC wsBreakLeader, wsBreakTrailer;
798 CXFA_Node* pFormNode = pCurNode->GetNodeItem( 798 CXFA_Node* pFormNode = pCurNode->GetNodeItem(
799 XFA_NODEITEM_Parent, XFA_ObjectType::ContainerNode); 799 XFA_NODEITEM_Parent, XFA_ObjectType::ContainerNode);
800 CXFA_Node* pContainer = pFormNode->GetTemplateNode(); 800 CXFA_Node* pContainer = pFormNode->GetTemplateNode();
801 FX_BOOL bStartNew = pCurNode->GetInteger(XFA_ATTRIBUTE_StartNew) != 0; 801 bool bStartNew = pCurNode->GetInteger(XFA_ATTRIBUTE_StartNew) != 0;
802 CXFA_Node* pScript = pCurNode->GetFirstChildByClass(XFA_Element::Script); 802 CXFA_Node* pScript = pCurNode->GetFirstChildByClass(XFA_Element::Script);
803 if (pScript && !XFA_LayoutPageMgr_RunBreakTestScript(pScript)) 803 if (pScript && !XFA_LayoutPageMgr_RunBreakTestScript(pScript))
804 return FALSE; 804 return false;
805 805
806 CFX_WideStringC wsTarget = pCurNode->GetCData(XFA_ATTRIBUTE_Target); 806 CFX_WideStringC wsTarget = pCurNode->GetCData(XFA_ATTRIBUTE_Target);
807 CXFA_Node* pTarget = 807 CXFA_Node* pTarget =
808 ResolveBreakTarget(m_pTemplatePageSetRoot, TRUE, wsTarget); 808 ResolveBreakTarget(m_pTemplatePageSetRoot, true, wsTarget);
809 wsBreakTrailer = pCurNode->GetCData(XFA_ATTRIBUTE_Trailer); 809 wsBreakTrailer = pCurNode->GetCData(XFA_ATTRIBUTE_Trailer);
810 wsBreakLeader = pCurNode->GetCData(XFA_ATTRIBUTE_Leader); 810 wsBreakLeader = pCurNode->GetCData(XFA_ATTRIBUTE_Leader);
811 pBreakLeaderTemplate = 811 pBreakLeaderTemplate =
812 ResolveBreakTarget(pContainer, TRUE, wsBreakLeader); 812 ResolveBreakTarget(pContainer, true, wsBreakLeader);
813 pBreakTrailerTemplate = 813 pBreakTrailerTemplate =
814 ResolveBreakTarget(pContainer, TRUE, wsBreakTrailer); 814 ResolveBreakTarget(pContainer, true, wsBreakTrailer);
815 if (RunBreak(eType, pCurNode->GetEnum(XFA_ATTRIBUTE_TargetType), pTarget, 815 if (RunBreak(eType, pCurNode->GetEnum(XFA_ATTRIBUTE_TargetType), pTarget,
816 bStartNew)) { 816 bStartNew)) {
817 return TRUE; 817 return true;
818 } 818 }
819 if (m_rgProposedContainerRecord.GetCount() > 0 && 819 if (m_rgProposedContainerRecord.GetCount() > 0 &&
820 m_pCurrentContainerRecord == 820 m_pCurrentContainerRecord ==
821 m_rgProposedContainerRecord.GetHeadPosition() && 821 m_rgProposedContainerRecord.GetHeadPosition() &&
822 eType == XFA_Element::BreakBefore) { 822 eType == XFA_Element::BreakBefore) {
823 CXFA_Node* pParentNode = pFormNode->GetNodeItem( 823 CXFA_Node* pParentNode = pFormNode->GetNodeItem(
824 XFA_NODEITEM_Parent, XFA_ObjectType::ContainerNode); 824 XFA_NODEITEM_Parent, XFA_ObjectType::ContainerNode);
825 if (!pParentNode || 825 if (!pParentNode ||
826 pFormNode != 826 pFormNode !=
827 pParentNode->GetNodeItem(XFA_NODEITEM_FirstChild, 827 pParentNode->GetNodeItem(XFA_NODEITEM_FirstChild,
828 XFA_ObjectType::ContainerNode)) { 828 XFA_ObjectType::ContainerNode)) {
829 break; 829 break;
830 } 830 }
831 pParentNode = pParentNode->GetNodeItem(XFA_NODEITEM_Parent); 831 pParentNode = pParentNode->GetNodeItem(XFA_NODEITEM_Parent);
832 if (!pParentNode || 832 if (!pParentNode ||
833 pParentNode->GetElementType() != XFA_Element::Form) { 833 pParentNode->GetElementType() != XFA_Element::Form) {
834 break; 834 break;
835 } 835 }
836 return TRUE; 836 return true;
837 } 837 }
838 break; 838 break;
839 } 839 }
840 case XFA_Element::Break: { 840 case XFA_Element::Break: {
841 FX_BOOL bStartNew = pCurNode->GetInteger(XFA_ATTRIBUTE_StartNew) != 0; 841 bool bStartNew = pCurNode->GetInteger(XFA_ATTRIBUTE_StartNew) != 0;
842 CFX_WideStringC wsTarget = pCurNode->GetCData( 842 CFX_WideStringC wsTarget = pCurNode->GetCData(
843 bBefore ? XFA_ATTRIBUTE_BeforeTarget : XFA_ATTRIBUTE_AfterTarget); 843 bBefore ? XFA_ATTRIBUTE_BeforeTarget : XFA_ATTRIBUTE_AfterTarget);
844 CXFA_Node* pTarget = 844 CXFA_Node* pTarget =
845 ResolveBreakTarget(m_pTemplatePageSetRoot, TRUE, wsTarget); 845 ResolveBreakTarget(m_pTemplatePageSetRoot, true, wsTarget);
846 if (RunBreak(bBefore ? XFA_Element::BreakBefore : XFA_Element::BreakAfter, 846 if (RunBreak(bBefore ? XFA_Element::BreakBefore : XFA_Element::BreakAfter,
847 pCurNode->GetEnum(bBefore ? XFA_ATTRIBUTE_Before 847 pCurNode->GetEnum(bBefore ? XFA_ATTRIBUTE_Before
848 : XFA_ATTRIBUTE_After), 848 : XFA_ATTRIBUTE_After),
849 pTarget, bStartNew)) { 849 pTarget, bStartNew)) {
850 return TRUE; 850 return true;
851 } 851 }
852 break; 852 break;
853 } 853 }
854 default: 854 default:
855 break; 855 break;
856 } 856 }
857 return FALSE; 857 return false;
858 } 858 }
859 859
860 FX_BOOL CXFA_LayoutPageMgr::ProcessBreakBeforeOrAfter( 860 bool CXFA_LayoutPageMgr::ProcessBreakBeforeOrAfter(
861 CXFA_Node* pBreakNode, 861 CXFA_Node* pBreakNode,
862 FX_BOOL bBefore, 862 bool bBefore,
863 CXFA_Node*& pBreakLeaderNode, 863 CXFA_Node*& pBreakLeaderNode,
864 CXFA_Node*& pBreakTrailerNode, 864 CXFA_Node*& pBreakTrailerNode,
865 FX_BOOL& bCreatePage) { 865 bool& bCreatePage) {
866 CXFA_Node* pLeaderTemplate = nullptr; 866 CXFA_Node* pLeaderTemplate = nullptr;
867 CXFA_Node* pTrailerTemplate = nullptr; 867 CXFA_Node* pTrailerTemplate = nullptr;
868 CXFA_Node* pFormNode = pBreakNode->GetNodeItem(XFA_NODEITEM_Parent, 868 CXFA_Node* pFormNode = pBreakNode->GetNodeItem(XFA_NODEITEM_Parent,
869 XFA_ObjectType::ContainerNode); 869 XFA_ObjectType::ContainerNode);
870 if (XFA_ItemLayoutProcessor_IsTakingSpace(pFormNode)) { 870 if (XFA_ItemLayoutProcessor_IsTakingSpace(pFormNode)) {
871 bCreatePage = ExecuteBreakBeforeOrAfter(pBreakNode, bBefore, 871 bCreatePage = ExecuteBreakBeforeOrAfter(pBreakNode, bBefore,
872 pLeaderTemplate, pTrailerTemplate); 872 pLeaderTemplate, pTrailerTemplate);
873 CXFA_Document* pDocument = pBreakNode->GetDocument(); 873 CXFA_Document* pDocument = pBreakNode->GetDocument();
874 CXFA_Node* pDataScope = nullptr; 874 CXFA_Node* pDataScope = nullptr;
875 pFormNode = pFormNode->GetNodeItem(XFA_NODEITEM_Parent, 875 pFormNode = pFormNode->GetNodeItem(XFA_NODEITEM_Parent,
876 XFA_ObjectType::ContainerNode); 876 XFA_ObjectType::ContainerNode);
877 if (pLeaderTemplate) { 877 if (pLeaderTemplate) {
878 if (!pDataScope) 878 if (!pDataScope)
879 pDataScope = XFA_DataMerge_FindDataScope(pFormNode); 879 pDataScope = XFA_DataMerge_FindDataScope(pFormNode);
880 880
881 pBreakLeaderNode = pDocument->DataMerge_CopyContainer( 881 pBreakLeaderNode = pDocument->DataMerge_CopyContainer(
882 pLeaderTemplate, pFormNode, pDataScope, TRUE, TRUE, TRUE); 882 pLeaderTemplate, pFormNode, pDataScope, true, true, true);
883 pDocument->DataMerge_UpdateBindingRelations(pBreakLeaderNode); 883 pDocument->DataMerge_UpdateBindingRelations(pBreakLeaderNode);
884 SetLayoutGeneratedNodeFlag(pBreakLeaderNode); 884 SetLayoutGeneratedNodeFlag(pBreakLeaderNode);
885 } 885 }
886 if (pTrailerTemplate) { 886 if (pTrailerTemplate) {
887 if (!pDataScope) 887 if (!pDataScope)
888 pDataScope = XFA_DataMerge_FindDataScope(pFormNode); 888 pDataScope = XFA_DataMerge_FindDataScope(pFormNode);
889 889
890 pBreakTrailerNode = pDocument->DataMerge_CopyContainer( 890 pBreakTrailerNode = pDocument->DataMerge_CopyContainer(
891 pTrailerTemplate, pFormNode, pDataScope, TRUE, TRUE, TRUE); 891 pTrailerTemplate, pFormNode, pDataScope, true, true, true);
892 pDocument->DataMerge_UpdateBindingRelations(pBreakTrailerNode); 892 pDocument->DataMerge_UpdateBindingRelations(pBreakTrailerNode);
893 SetLayoutGeneratedNodeFlag(pBreakTrailerNode); 893 SetLayoutGeneratedNodeFlag(pBreakTrailerNode);
894 } 894 }
895 return TRUE; 895 return true;
896 } 896 }
897 return FALSE; 897 return false;
898 } 898 }
899 899
900 FX_BOOL CXFA_LayoutPageMgr::ProcessBookendLeaderOrTrailer( 900 bool CXFA_LayoutPageMgr::ProcessBookendLeaderOrTrailer(
901 CXFA_Node* pBookendNode, 901 CXFA_Node* pBookendNode,
902 FX_BOOL bLeader, 902 bool bLeader,
903 CXFA_Node*& pBookendAppendNode) { 903 CXFA_Node*& pBookendAppendNode) {
904 CXFA_Node* pLeaderTemplate = nullptr; 904 CXFA_Node* pLeaderTemplate = nullptr;
905 CXFA_Node* pFormNode = pBookendNode->GetNodeItem( 905 CXFA_Node* pFormNode = pBookendNode->GetNodeItem(
906 XFA_NODEITEM_Parent, XFA_ObjectType::ContainerNode); 906 XFA_NODEITEM_Parent, XFA_ObjectType::ContainerNode);
907 if (ResolveBookendLeaderOrTrailer(pBookendNode, bLeader, pLeaderTemplate)) { 907 if (ResolveBookendLeaderOrTrailer(pBookendNode, bLeader, pLeaderTemplate)) {
908 CXFA_Document* pDocument = pBookendNode->GetDocument(); 908 CXFA_Document* pDocument = pBookendNode->GetDocument();
909 CXFA_Node* pDataScope = nullptr; 909 CXFA_Node* pDataScope = nullptr;
910 if (pLeaderTemplate) { 910 if (pLeaderTemplate) {
911 if (!pDataScope) 911 if (!pDataScope)
912 pDataScope = XFA_DataMerge_FindDataScope(pFormNode); 912 pDataScope = XFA_DataMerge_FindDataScope(pFormNode);
913 913
914 pBookendAppendNode = pDocument->DataMerge_CopyContainer( 914 pBookendAppendNode = pDocument->DataMerge_CopyContainer(
915 pLeaderTemplate, pFormNode, pDataScope, TRUE, TRUE, TRUE); 915 pLeaderTemplate, pFormNode, pDataScope, true, true, true);
916 pDocument->DataMerge_UpdateBindingRelations(pBookendAppendNode); 916 pDocument->DataMerge_UpdateBindingRelations(pBookendAppendNode);
917 SetLayoutGeneratedNodeFlag(pBookendAppendNode); 917 SetLayoutGeneratedNodeFlag(pBookendAppendNode);
918 return TRUE; 918 return true;
919 } 919 }
920 } 920 }
921 return FALSE; 921 return false;
922 } 922 }
923 923
924 CXFA_Node* CXFA_LayoutPageMgr::BreakOverflow(CXFA_Node* pOverflowNode, 924 CXFA_Node* CXFA_LayoutPageMgr::BreakOverflow(CXFA_Node* pOverflowNode,
925 CXFA_Node*& pLeaderTemplate, 925 CXFA_Node*& pLeaderTemplate,
926 CXFA_Node*& pTrailerTemplate, 926 CXFA_Node*& pTrailerTemplate,
927 FX_BOOL bCreatePage) { 927 bool bCreatePage) {
928 CXFA_Node* pContainer = 928 CXFA_Node* pContainer =
929 pOverflowNode 929 pOverflowNode
930 ->GetNodeItem(XFA_NODEITEM_Parent, XFA_ObjectType::ContainerNode) 930 ->GetNodeItem(XFA_NODEITEM_Parent, XFA_ObjectType::ContainerNode)
931 ->GetTemplateNode(); 931 ->GetTemplateNode();
932 if (pOverflowNode->GetElementType() == XFA_Element::Break) { 932 if (pOverflowNode->GetElementType() == XFA_Element::Break) {
933 CFX_WideStringC wsOverflowLeader; 933 CFX_WideStringC wsOverflowLeader;
934 CFX_WideStringC wsOverflowTarget; 934 CFX_WideStringC wsOverflowTarget;
935 CFX_WideStringC wsOverflowTrailer; 935 CFX_WideStringC wsOverflowTrailer;
936 pOverflowNode->TryCData(XFA_ATTRIBUTE_OverflowLeader, wsOverflowLeader); 936 pOverflowNode->TryCData(XFA_ATTRIBUTE_OverflowLeader, wsOverflowLeader);
937 pOverflowNode->TryCData(XFA_ATTRIBUTE_OverflowTrailer, wsOverflowTrailer); 937 pOverflowNode->TryCData(XFA_ATTRIBUTE_OverflowTrailer, wsOverflowTrailer);
938 pOverflowNode->TryCData(XFA_ATTRIBUTE_OverflowTarget, wsOverflowTarget); 938 pOverflowNode->TryCData(XFA_ATTRIBUTE_OverflowTarget, wsOverflowTarget);
939 if (!wsOverflowLeader.IsEmpty() || !wsOverflowTrailer.IsEmpty() || 939 if (!wsOverflowLeader.IsEmpty() || !wsOverflowTrailer.IsEmpty() ||
940 !wsOverflowTarget.IsEmpty()) { 940 !wsOverflowTarget.IsEmpty()) {
941 if (!wsOverflowTarget.IsEmpty() && bCreatePage && 941 if (!wsOverflowTarget.IsEmpty() && bCreatePage &&
942 !m_bCreateOverFlowPage) { 942 !m_bCreateOverFlowPage) {
943 CXFA_Node* pTarget = 943 CXFA_Node* pTarget =
944 ResolveBreakTarget(m_pTemplatePageSetRoot, TRUE, wsOverflowTarget); 944 ResolveBreakTarget(m_pTemplatePageSetRoot, true, wsOverflowTarget);
945 if (pTarget) { 945 if (pTarget) {
946 m_bCreateOverFlowPage = TRUE; 946 m_bCreateOverFlowPage = true;
947 switch (pTarget->GetElementType()) { 947 switch (pTarget->GetElementType()) {
948 case XFA_Element::PageArea: 948 case XFA_Element::PageArea:
949 RunBreak(XFA_Element::Overflow, XFA_ATTRIBUTEENUM_PageArea, 949 RunBreak(XFA_Element::Overflow, XFA_ATTRIBUTEENUM_PageArea,
950 pTarget, TRUE); 950 pTarget, true);
951 break; 951 break;
952 case XFA_Element::ContentArea: 952 case XFA_Element::ContentArea:
953 RunBreak(XFA_Element::Overflow, XFA_ATTRIBUTEENUM_ContentArea, 953 RunBreak(XFA_Element::Overflow, XFA_ATTRIBUTEENUM_ContentArea,
954 pTarget, TRUE); 954 pTarget, true);
955 break; 955 break;
956 default: 956 default:
957 break; 957 break;
958 } 958 }
959 } 959 }
960 } 960 }
961 if (!bCreatePage) { 961 if (!bCreatePage) {
962 pLeaderTemplate = 962 pLeaderTemplate =
963 ResolveBreakTarget(pContainer, TRUE, wsOverflowLeader); 963 ResolveBreakTarget(pContainer, true, wsOverflowLeader);
964 pTrailerTemplate = 964 pTrailerTemplate =
965 ResolveBreakTarget(pContainer, TRUE, wsOverflowTrailer); 965 ResolveBreakTarget(pContainer, true, wsOverflowTrailer);
966 } 966 }
967 return pOverflowNode; 967 return pOverflowNode;
968 } 968 }
969 return nullptr; 969 return nullptr;
970 } 970 }
971 971
972 if (pOverflowNode->GetElementType() != XFA_Element::Overflow) 972 if (pOverflowNode->GetElementType() != XFA_Element::Overflow)
973 return nullptr; 973 return nullptr;
974 974
975 CFX_WideStringC wsOverflowLeader; 975 CFX_WideStringC wsOverflowLeader;
976 CFX_WideStringC wsOverflowTrailer; 976 CFX_WideStringC wsOverflowTrailer;
977 CFX_WideStringC wsOverflowTarget; 977 CFX_WideStringC wsOverflowTarget;
978 pOverflowNode->TryCData(XFA_ATTRIBUTE_Leader, wsOverflowLeader); 978 pOverflowNode->TryCData(XFA_ATTRIBUTE_Leader, wsOverflowLeader);
979 pOverflowNode->TryCData(XFA_ATTRIBUTE_Trailer, wsOverflowTrailer); 979 pOverflowNode->TryCData(XFA_ATTRIBUTE_Trailer, wsOverflowTrailer);
980 pOverflowNode->TryCData(XFA_ATTRIBUTE_Target, wsOverflowTarget); 980 pOverflowNode->TryCData(XFA_ATTRIBUTE_Target, wsOverflowTarget);
981 if (!wsOverflowTarget.IsEmpty() && bCreatePage && !m_bCreateOverFlowPage) { 981 if (!wsOverflowTarget.IsEmpty() && bCreatePage && !m_bCreateOverFlowPage) {
982 CXFA_Node* pTarget = 982 CXFA_Node* pTarget =
983 ResolveBreakTarget(m_pTemplatePageSetRoot, TRUE, wsOverflowTarget); 983 ResolveBreakTarget(m_pTemplatePageSetRoot, true, wsOverflowTarget);
984 if (pTarget) { 984 if (pTarget) {
985 m_bCreateOverFlowPage = TRUE; 985 m_bCreateOverFlowPage = true;
986 switch (pTarget->GetElementType()) { 986 switch (pTarget->GetElementType()) {
987 case XFA_Element::PageArea: 987 case XFA_Element::PageArea:
988 RunBreak(XFA_Element::Overflow, XFA_ATTRIBUTEENUM_PageArea, pTarget, 988 RunBreak(XFA_Element::Overflow, XFA_ATTRIBUTEENUM_PageArea, pTarget,
989 TRUE); 989 true);
990 break; 990 break;
991 case XFA_Element::ContentArea: 991 case XFA_Element::ContentArea:
992 RunBreak(XFA_Element::Overflow, XFA_ATTRIBUTEENUM_ContentArea, 992 RunBreak(XFA_Element::Overflow, XFA_ATTRIBUTEENUM_ContentArea,
993 pTarget, TRUE); 993 pTarget, true);
994 break; 994 break;
995 default: 995 default:
996 break; 996 break;
997 } 997 }
998 } 998 }
999 } 999 }
1000 if (!bCreatePage) { 1000 if (!bCreatePage) {
1001 pLeaderTemplate = ResolveBreakTarget(pContainer, TRUE, wsOverflowLeader); 1001 pLeaderTemplate = ResolveBreakTarget(pContainer, true, wsOverflowLeader);
1002 pTrailerTemplate = ResolveBreakTarget(pContainer, TRUE, wsOverflowTrailer); 1002 pTrailerTemplate = ResolveBreakTarget(pContainer, true, wsOverflowTrailer);
1003 } 1003 }
1004 return pOverflowNode; 1004 return pOverflowNode;
1005 } 1005 }
1006 1006
1007 FX_BOOL CXFA_LayoutPageMgr::ProcessOverflow(CXFA_Node* pFormNode, 1007 bool CXFA_LayoutPageMgr::ProcessOverflow(CXFA_Node* pFormNode,
1008 CXFA_Node*& pLeaderNode, 1008 CXFA_Node*& pLeaderNode,
1009 CXFA_Node*& pTrailerNode, 1009 CXFA_Node*& pTrailerNode,
1010 FX_BOOL bDataMerge, 1010 bool bDataMerge,
1011 FX_BOOL bCreatePage) { 1011 bool bCreatePage) {
1012 if (!pFormNode) 1012 if (!pFormNode)
1013 return FALSE; 1013 return false;
1014 1014
1015 CXFA_Node* pLeaderTemplate = nullptr; 1015 CXFA_Node* pLeaderTemplate = nullptr;
1016 CXFA_Node* pTrailerTemplate = nullptr; 1016 CXFA_Node* pTrailerTemplate = nullptr;
1017 FX_BOOL bIsOverflowNode = FALSE; 1017 bool bIsOverflowNode = false;
1018 if (pFormNode->GetElementType() == XFA_Element::Overflow || 1018 if (pFormNode->GetElementType() == XFA_Element::Overflow ||
1019 pFormNode->GetElementType() == XFA_Element::Break) { 1019 pFormNode->GetElementType() == XFA_Element::Break) {
1020 bIsOverflowNode = TRUE; 1020 bIsOverflowNode = true;
1021 } 1021 }
1022 for (CXFA_Node* pCurNode = 1022 for (CXFA_Node* pCurNode =
1023 bIsOverflowNode ? pFormNode 1023 bIsOverflowNode ? pFormNode
1024 : pFormNode->GetNodeItem(XFA_NODEITEM_FirstChild); 1024 : pFormNode->GetNodeItem(XFA_NODEITEM_FirstChild);
1025 pCurNode; pCurNode = pCurNode->GetNodeItem((XFA_NODEITEM_NextSibling))) { 1025 pCurNode; pCurNode = pCurNode->GetNodeItem((XFA_NODEITEM_NextSibling))) {
1026 if (BreakOverflow(pCurNode, pLeaderTemplate, pTrailerTemplate, 1026 if (BreakOverflow(pCurNode, pLeaderTemplate, pTrailerTemplate,
1027 bCreatePage)) { 1027 bCreatePage)) {
1028 if (bIsOverflowNode) 1028 if (bIsOverflowNode)
1029 pFormNode = pCurNode->GetNodeItem(XFA_NODEITEM_Parent); 1029 pFormNode = pCurNode->GetNodeItem(XFA_NODEITEM_Parent);
1030 1030
1031 CXFA_Document* pDocument = pCurNode->GetDocument(); 1031 CXFA_Document* pDocument = pCurNode->GetDocument();
1032 CXFA_Node* pDataScope = nullptr; 1032 CXFA_Node* pDataScope = nullptr;
1033 if (pLeaderTemplate) { 1033 if (pLeaderTemplate) {
1034 if (!pDataScope) 1034 if (!pDataScope)
1035 pDataScope = XFA_DataMerge_FindDataScope(pFormNode); 1035 pDataScope = XFA_DataMerge_FindDataScope(pFormNode);
1036 1036
1037 pLeaderNode = pDocument->DataMerge_CopyContainer( 1037 pLeaderNode = pDocument->DataMerge_CopyContainer(
1038 pLeaderTemplate, pFormNode, pDataScope, TRUE, TRUE, TRUE); 1038 pLeaderTemplate, pFormNode, pDataScope, true, true, true);
1039 pDocument->DataMerge_UpdateBindingRelations(pLeaderNode); 1039 pDocument->DataMerge_UpdateBindingRelations(pLeaderNode);
1040 SetLayoutGeneratedNodeFlag(pLeaderNode); 1040 SetLayoutGeneratedNodeFlag(pLeaderNode);
1041 } 1041 }
1042 if (pTrailerTemplate) { 1042 if (pTrailerTemplate) {
1043 if (!pDataScope) 1043 if (!pDataScope)
1044 pDataScope = XFA_DataMerge_FindDataScope(pFormNode); 1044 pDataScope = XFA_DataMerge_FindDataScope(pFormNode);
1045 1045
1046 pTrailerNode = pDocument->DataMerge_CopyContainer( 1046 pTrailerNode = pDocument->DataMerge_CopyContainer(
1047 pTrailerTemplate, pFormNode, pDataScope, TRUE, TRUE, TRUE); 1047 pTrailerTemplate, pFormNode, pDataScope, true, true, true);
1048 pDocument->DataMerge_UpdateBindingRelations(pTrailerNode); 1048 pDocument->DataMerge_UpdateBindingRelations(pTrailerNode);
1049 SetLayoutGeneratedNodeFlag(pTrailerNode); 1049 SetLayoutGeneratedNodeFlag(pTrailerNode);
1050 } 1050 }
1051 return TRUE; 1051 return true;
1052 } 1052 }
1053 if (bIsOverflowNode) { 1053 if (bIsOverflowNode) {
1054 break; 1054 break;
1055 } 1055 }
1056 } 1056 }
1057 return FALSE; 1057 return false;
1058 } 1058 }
1059 1059
1060 FX_BOOL CXFA_LayoutPageMgr::ResolveBookendLeaderOrTrailer( 1060 bool CXFA_LayoutPageMgr::ResolveBookendLeaderOrTrailer(
1061 CXFA_Node* pBookendNode, 1061 CXFA_Node* pBookendNode,
1062 FX_BOOL bLeader, 1062 bool bLeader,
1063 CXFA_Node*& pBookendAppendTemplate) { 1063 CXFA_Node*& pBookendAppendTemplate) {
1064 CFX_WideStringC wsBookendLeader; 1064 CFX_WideStringC wsBookendLeader;
1065 CXFA_Node* pContainer = 1065 CXFA_Node* pContainer =
1066 pBookendNode 1066 pBookendNode
1067 ->GetNodeItem(XFA_NODEITEM_Parent, XFA_ObjectType::ContainerNode) 1067 ->GetNodeItem(XFA_NODEITEM_Parent, XFA_ObjectType::ContainerNode)
1068 ->GetTemplateNode(); 1068 ->GetTemplateNode();
1069 if (pBookendNode->GetElementType() == XFA_Element::Break) { 1069 if (pBookendNode->GetElementType() == XFA_Element::Break) {
1070 pBookendNode->TryCData( 1070 pBookendNode->TryCData(
1071 bLeader ? XFA_ATTRIBUTE_BookendLeader : XFA_ATTRIBUTE_BookendTrailer, 1071 bLeader ? XFA_ATTRIBUTE_BookendLeader : XFA_ATTRIBUTE_BookendTrailer,
1072 wsBookendLeader); 1072 wsBookendLeader);
1073 if (!wsBookendLeader.IsEmpty()) { 1073 if (!wsBookendLeader.IsEmpty()) {
1074 pBookendAppendTemplate = 1074 pBookendAppendTemplate =
1075 ResolveBreakTarget(pContainer, FALSE, wsBookendLeader); 1075 ResolveBreakTarget(pContainer, false, wsBookendLeader);
1076 return TRUE; 1076 return true;
1077 } 1077 }
1078 return FALSE; 1078 return false;
1079 } else if (pBookendNode->GetElementType() == XFA_Element::Bookend) { 1079 } else if (pBookendNode->GetElementType() == XFA_Element::Bookend) {
1080 pBookendNode->TryCData( 1080 pBookendNode->TryCData(
1081 bLeader ? XFA_ATTRIBUTE_Leader : XFA_ATTRIBUTE_Trailer, 1081 bLeader ? XFA_ATTRIBUTE_Leader : XFA_ATTRIBUTE_Trailer,
1082 wsBookendLeader); 1082 wsBookendLeader);
1083 pBookendAppendTemplate = 1083 pBookendAppendTemplate =
1084 ResolveBreakTarget(pContainer, TRUE, wsBookendLeader); 1084 ResolveBreakTarget(pContainer, true, wsBookendLeader);
1085 return TRUE; 1085 return true;
1086 } 1086 }
1087 return FALSE; 1087 return false;
1088 } 1088 }
1089 1089
1090 FX_BOOL CXFA_LayoutPageMgr::FindPageAreaFromPageSet( 1090 bool CXFA_LayoutPageMgr::FindPageAreaFromPageSet(CXFA_Node* pPageSet,
1091 CXFA_Node* pPageSet, 1091 CXFA_Node* pStartChild,
1092 CXFA_Node* pStartChild, 1092 CXFA_Node* pTargetPageArea,
1093 CXFA_Node* pTargetPageArea, 1093 CXFA_Node* pTargetContentArea,
1094 CXFA_Node* pTargetContentArea, 1094 bool bNewPage,
1095 FX_BOOL bNewPage, 1095 bool bQuery) {
1096 FX_BOOL bQuery) {
1097 if (!pPageSet && !pStartChild) 1096 if (!pPageSet && !pStartChild)
1098 return FALSE; 1097 return false;
1099 1098
1100 if (IsPageSetRootOrderedOccurrence()) { 1099 if (IsPageSetRootOrderedOccurrence()) {
1101 return FindPageAreaFromPageSet_Ordered(pPageSet, pStartChild, 1100 return FindPageAreaFromPageSet_Ordered(pPageSet, pStartChild,
1102 pTargetPageArea, pTargetContentArea, 1101 pTargetPageArea, pTargetContentArea,
1103 bNewPage, bQuery); 1102 bNewPage, bQuery);
1104 } 1103 }
1105 XFA_ATTRIBUTEENUM ePreferredPosition = m_pCurrentContainerRecord 1104 XFA_ATTRIBUTEENUM ePreferredPosition = m_pCurrentContainerRecord
1106 ? XFA_ATTRIBUTEENUM_Rest 1105 ? XFA_ATTRIBUTEENUM_Rest
1107 : XFA_ATTRIBUTEENUM_First; 1106 : XFA_ATTRIBUTEENUM_First;
1108 return FindPageAreaFromPageSet_SimplexDuplex( 1107 return FindPageAreaFromPageSet_SimplexDuplex(
1109 pPageSet, pStartChild, pTargetPageArea, pTargetContentArea, bNewPage, 1108 pPageSet, pStartChild, pTargetPageArea, pTargetContentArea, bNewPage,
1110 bQuery, ePreferredPosition); 1109 bQuery, ePreferredPosition);
1111 } 1110 }
1112 1111
1113 FX_BOOL CXFA_LayoutPageMgr::FindPageAreaFromPageSet_Ordered( 1112 bool CXFA_LayoutPageMgr::FindPageAreaFromPageSet_Ordered(
1114 CXFA_Node* pPageSet, 1113 CXFA_Node* pPageSet,
1115 CXFA_Node* pStartChild, 1114 CXFA_Node* pStartChild,
1116 CXFA_Node* pTargetPageArea, 1115 CXFA_Node* pTargetPageArea,
1117 CXFA_Node* pTargetContentArea, 1116 CXFA_Node* pTargetContentArea,
1118 FX_BOOL bNewPage, 1117 bool bNewPage,
1119 FX_BOOL bQuery) { 1118 bool bQuery) {
1120 int32_t iPageSetCount = 0; 1119 int32_t iPageSetCount = 0;
1121 if (!pStartChild && !bQuery) { 1120 if (!pStartChild && !bQuery) {
1122 m_pPageSetMap.Lookup(pPageSet, iPageSetCount); 1121 m_pPageSetMap.Lookup(pPageSet, iPageSetCount);
1123 int32_t iMax = -1; 1122 int32_t iMax = -1;
1124 CXFA_Node* pOccurNode = pPageSet->GetFirstChildByClass(XFA_Element::Occur); 1123 CXFA_Node* pOccurNode = pPageSet->GetFirstChildByClass(XFA_Element::Occur);
1125 if (pOccurNode) 1124 if (pOccurNode)
1126 pOccurNode->TryInteger(XFA_ATTRIBUTE_Max, iMax, FALSE); 1125 pOccurNode->TryInteger(XFA_ATTRIBUTE_Max, iMax, false);
1127 if (iMax >= 0 && iMax <= iPageSetCount) 1126 if (iMax >= 0 && iMax <= iPageSetCount)
1128 return FALSE; 1127 return false;
1129 } 1128 }
1130 1129
1131 FX_BOOL bRes = FALSE; 1130 bool bRes = false;
1132 CXFA_Node* pCurrentNode = 1131 CXFA_Node* pCurrentNode =
1133 pStartChild ? pStartChild->GetNodeItem(XFA_NODEITEM_NextSibling) 1132 pStartChild ? pStartChild->GetNodeItem(XFA_NODEITEM_NextSibling)
1134 : pPageSet->GetNodeItem(XFA_NODEITEM_FirstChild); 1133 : pPageSet->GetNodeItem(XFA_NODEITEM_FirstChild);
1135 for (; pCurrentNode; 1134 for (; pCurrentNode;
1136 pCurrentNode = pCurrentNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { 1135 pCurrentNode = pCurrentNode->GetNodeItem(XFA_NODEITEM_NextSibling)) {
1137 if (pCurrentNode->GetElementType() == XFA_Element::PageArea) { 1136 if (pCurrentNode->GetElementType() == XFA_Element::PageArea) {
1138 if ((pTargetPageArea == pCurrentNode || !pTargetPageArea)) { 1137 if ((pTargetPageArea == pCurrentNode || !pTargetPageArea)) {
1139 if (!pCurrentNode->GetFirstChildByClass(XFA_Element::ContentArea)) { 1138 if (!pCurrentNode->GetFirstChildByClass(XFA_Element::ContentArea)) {
1140 if (pTargetPageArea == pCurrentNode) { 1139 if (pTargetPageArea == pCurrentNode) {
1141 CreateMinPageRecord(pCurrentNode, TRUE); 1140 CreateMinPageRecord(pCurrentNode, true);
1142 pTargetPageArea = nullptr; 1141 pTargetPageArea = nullptr;
1143 } 1142 }
1144 continue; 1143 continue;
1145 } 1144 }
1146 if (!bQuery) { 1145 if (!bQuery) {
1147 CXFA_ContainerRecord* pNewRecord = 1146 CXFA_ContainerRecord* pNewRecord =
1148 CreateContainerRecord(pCurrentNode, !pStartChild); 1147 CreateContainerRecord(pCurrentNode, !pStartChild);
1149 AddPageAreaLayoutItem(pNewRecord, pCurrentNode); 1148 AddPageAreaLayoutItem(pNewRecord, pCurrentNode);
1150 if (!pTargetContentArea) { 1149 if (!pTargetContentArea) {
1151 pTargetContentArea = 1150 pTargetContentArea =
1152 pCurrentNode->GetFirstChildByClass(XFA_Element::ContentArea); 1151 pCurrentNode->GetFirstChildByClass(XFA_Element::ContentArea);
1153 } 1152 }
1154 AddContentAreaLayoutItem(pNewRecord, pTargetContentArea); 1153 AddContentAreaLayoutItem(pNewRecord, pTargetContentArea);
1155 } 1154 }
1156 m_pCurPageArea = pCurrentNode; 1155 m_pCurPageArea = pCurrentNode;
1157 m_nCurPageCount = 1; 1156 m_nCurPageCount = 1;
1158 bRes = TRUE; 1157 bRes = true;
1159 break; 1158 break;
1160 } 1159 }
1161 if (!bQuery) 1160 if (!bQuery)
1162 CreateMinPageRecord(pCurrentNode, FALSE); 1161 CreateMinPageRecord(pCurrentNode, false);
1163 } else if (pCurrentNode->GetElementType() == XFA_Element::PageSet) { 1162 } else if (pCurrentNode->GetElementType() == XFA_Element::PageSet) {
1164 if (FindPageAreaFromPageSet_Ordered(pCurrentNode, nullptr, 1163 if (FindPageAreaFromPageSet_Ordered(pCurrentNode, nullptr,
1165 pTargetPageArea, pTargetContentArea, 1164 pTargetPageArea, pTargetContentArea,
1166 bNewPage, bQuery)) { 1165 bNewPage, bQuery)) {
1167 bRes = TRUE; 1166 bRes = true;
1168 break; 1167 break;
1169 } 1168 }
1170 if (!bQuery) 1169 if (!bQuery)
1171 CreateMinPageSetRecord(pCurrentNode, TRUE); 1170 CreateMinPageSetRecord(pCurrentNode, true);
1172 } 1171 }
1173 } 1172 }
1174 if (!pStartChild && bRes && !bQuery) 1173 if (!pStartChild && bRes && !bQuery)
1175 m_pPageSetMap.SetAt(pPageSet, ++iPageSetCount); 1174 m_pPageSetMap.SetAt(pPageSet, ++iPageSetCount);
1176 return bRes; 1175 return bRes;
1177 } 1176 }
1178 1177
1179 FX_BOOL CXFA_LayoutPageMgr::FindPageAreaFromPageSet_SimplexDuplex( 1178 bool CXFA_LayoutPageMgr::FindPageAreaFromPageSet_SimplexDuplex(
1180 CXFA_Node* pPageSet, 1179 CXFA_Node* pPageSet,
1181 CXFA_Node* pStartChild, 1180 CXFA_Node* pStartChild,
1182 CXFA_Node* pTargetPageArea, 1181 CXFA_Node* pTargetPageArea,
1183 CXFA_Node* pTargetContentArea, 1182 CXFA_Node* pTargetContentArea,
1184 FX_BOOL bNewPage, 1183 bool bNewPage,
1185 FX_BOOL bQuery, 1184 bool bQuery,
1186 XFA_ATTRIBUTEENUM ePreferredPosition) { 1185 XFA_ATTRIBUTEENUM ePreferredPosition) {
1187 const XFA_ATTRIBUTEENUM eFallbackPosition = XFA_ATTRIBUTEENUM_Any; 1186 const XFA_ATTRIBUTEENUM eFallbackPosition = XFA_ATTRIBUTEENUM_Any;
1188 CXFA_Node* pPreferredPageArea = nullptr; 1187 CXFA_Node* pPreferredPageArea = nullptr;
1189 CXFA_Node* pFallbackPageArea = nullptr; 1188 CXFA_Node* pFallbackPageArea = nullptr;
1190 CXFA_Node* pCurrentNode = nullptr; 1189 CXFA_Node* pCurrentNode = nullptr;
1191 if (!pStartChild || pStartChild->GetElementType() == XFA_Element::PageArea) 1190 if (!pStartChild || pStartChild->GetElementType() == XFA_Element::PageArea)
1192 pCurrentNode = pPageSet->GetNodeItem(XFA_NODEITEM_FirstChild); 1191 pCurrentNode = pPageSet->GetNodeItem(XFA_NODEITEM_FirstChild);
1193 else 1192 else
1194 pCurrentNode = pStartChild->GetNodeItem(XFA_NODEITEM_NextSibling); 1193 pCurrentNode = pStartChild->GetNodeItem(XFA_NODEITEM_NextSibling);
1195 1194
1196 for (; pCurrentNode; 1195 for (; pCurrentNode;
1197 pCurrentNode = pCurrentNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { 1196 pCurrentNode = pCurrentNode->GetNodeItem(XFA_NODEITEM_NextSibling)) {
1198 if (pCurrentNode->GetElementType() == XFA_Element::PageArea) { 1197 if (pCurrentNode->GetElementType() == XFA_Element::PageArea) {
1199 if (!MatchPageAreaOddOrEven(pCurrentNode, FALSE)) 1198 if (!MatchPageAreaOddOrEven(pCurrentNode, false))
1200 continue; 1199 continue;
1201 1200
1202 XFA_ATTRIBUTEENUM eCurPagePosition = 1201 XFA_ATTRIBUTEENUM eCurPagePosition =
1203 pCurrentNode->GetEnum(XFA_ATTRIBUTE_PagePosition); 1202 pCurrentNode->GetEnum(XFA_ATTRIBUTE_PagePosition);
1204 if (ePreferredPosition == XFA_ATTRIBUTEENUM_Last) { 1203 if (ePreferredPosition == XFA_ATTRIBUTEENUM_Last) {
1205 if (eCurPagePosition != ePreferredPosition) 1204 if (eCurPagePosition != ePreferredPosition)
1206 continue; 1205 continue;
1207 if (m_ePageSetMode == XFA_ATTRIBUTEENUM_SimplexPaginated || 1206 if (m_ePageSetMode == XFA_ATTRIBUTEENUM_SimplexPaginated ||
1208 pCurrentNode->GetEnum(XFA_ATTRIBUTE_OddOrEven) == 1207 pCurrentNode->GetEnum(XFA_ATTRIBUTE_OddOrEven) ==
1209 XFA_ATTRIBUTEENUM_Any) { 1208 XFA_ATTRIBUTEENUM_Any) {
1210 pPreferredPageArea = pCurrentNode; 1209 pPreferredPageArea = pCurrentNode;
1211 break; 1210 break;
1212 } 1211 }
1213 CXFA_ContainerRecord* pNewRecord = CreateContainerRecord(); 1212 CXFA_ContainerRecord* pNewRecord = CreateContainerRecord();
1214 AddPageAreaLayoutItem(pNewRecord, pCurrentNode); 1213 AddPageAreaLayoutItem(pNewRecord, pCurrentNode);
1215 AddContentAreaLayoutItem(pNewRecord, pCurrentNode->GetFirstChildByClass( 1214 AddContentAreaLayoutItem(pNewRecord, pCurrentNode->GetFirstChildByClass(
1216 XFA_Element::ContentArea)); 1215 XFA_Element::ContentArea));
1217 pPreferredPageArea = pCurrentNode; 1216 pPreferredPageArea = pCurrentNode;
1218 return FALSE; 1217 return false;
1219 } 1218 }
1220 if (ePreferredPosition == XFA_ATTRIBUTEENUM_Only) { 1219 if (ePreferredPosition == XFA_ATTRIBUTEENUM_Only) {
1221 if (eCurPagePosition != ePreferredPosition) 1220 if (eCurPagePosition != ePreferredPosition)
1222 continue; 1221 continue;
1223 if (m_ePageSetMode != XFA_ATTRIBUTEENUM_DuplexPaginated || 1222 if (m_ePageSetMode != XFA_ATTRIBUTEENUM_DuplexPaginated ||
1224 pCurrentNode->GetEnum(XFA_ATTRIBUTE_OddOrEven) == 1223 pCurrentNode->GetEnum(XFA_ATTRIBUTE_OddOrEven) ==
1225 XFA_ATTRIBUTEENUM_Any) { 1224 XFA_ATTRIBUTEENUM_Any) {
1226 pPreferredPageArea = pCurrentNode; 1225 pPreferredPageArea = pCurrentNode;
1227 break; 1226 break;
1228 } 1227 }
1229 return FALSE; 1228 return false;
1230 } 1229 }
1231 if ((pTargetPageArea == pCurrentNode || !pTargetPageArea)) { 1230 if ((pTargetPageArea == pCurrentNode || !pTargetPageArea)) {
1232 if (!pCurrentNode->GetFirstChildByClass(XFA_Element::ContentArea)) { 1231 if (!pCurrentNode->GetFirstChildByClass(XFA_Element::ContentArea)) {
1233 if (pTargetPageArea == pCurrentNode) { 1232 if (pTargetPageArea == pCurrentNode) {
1234 CXFA_ContainerRecord* pNewRecord = CreateContainerRecord(); 1233 CXFA_ContainerRecord* pNewRecord = CreateContainerRecord();
1235 AddPageAreaLayoutItem(pNewRecord, pCurrentNode); 1234 AddPageAreaLayoutItem(pNewRecord, pCurrentNode);
1236 pTargetPageArea = nullptr; 1235 pTargetPageArea = nullptr;
1237 } 1236 }
1238 continue; 1237 continue;
1239 } 1238 }
1240 if ((ePreferredPosition == XFA_ATTRIBUTEENUM_Rest && 1239 if ((ePreferredPosition == XFA_ATTRIBUTEENUM_Rest &&
1241 eCurPagePosition == XFA_ATTRIBUTEENUM_Any) || 1240 eCurPagePosition == XFA_ATTRIBUTEENUM_Any) ||
1242 eCurPagePosition == ePreferredPosition) { 1241 eCurPagePosition == ePreferredPosition) {
1243 pPreferredPageArea = pCurrentNode; 1242 pPreferredPageArea = pCurrentNode;
1244 break; 1243 break;
1245 } else if (eCurPagePosition == eFallbackPosition && 1244 } else if (eCurPagePosition == eFallbackPosition &&
1246 !pFallbackPageArea) { 1245 !pFallbackPageArea) {
1247 pFallbackPageArea = pCurrentNode; 1246 pFallbackPageArea = pCurrentNode;
1248 } 1247 }
1249 } else if (pTargetPageArea && 1248 } else if (pTargetPageArea &&
1250 !MatchPageAreaOddOrEven(pTargetPageArea, FALSE)) { 1249 !MatchPageAreaOddOrEven(pTargetPageArea, false)) {
1251 CXFA_ContainerRecord* pNewRecord = CreateContainerRecord(); 1250 CXFA_ContainerRecord* pNewRecord = CreateContainerRecord();
1252 AddPageAreaLayoutItem(pNewRecord, pCurrentNode); 1251 AddPageAreaLayoutItem(pNewRecord, pCurrentNode);
1253 AddContentAreaLayoutItem(pNewRecord, pCurrentNode->GetFirstChildByClass( 1252 AddContentAreaLayoutItem(pNewRecord, pCurrentNode->GetFirstChildByClass(
1254 XFA_Element::ContentArea)); 1253 XFA_Element::ContentArea));
1255 } 1254 }
1256 } else if (pCurrentNode->GetElementType() == XFA_Element::PageSet) { 1255 } else if (pCurrentNode->GetElementType() == XFA_Element::PageSet) {
1257 if (FindPageAreaFromPageSet_SimplexDuplex( 1256 if (FindPageAreaFromPageSet_SimplexDuplex(
1258 pCurrentNode, nullptr, pTargetPageArea, pTargetContentArea, 1257 pCurrentNode, nullptr, pTargetPageArea, pTargetContentArea,
1259 bNewPage, bQuery, ePreferredPosition)) { 1258 bNewPage, bQuery, ePreferredPosition)) {
1260 break; 1259 break;
1261 } 1260 }
1262 } 1261 }
1263 } 1262 }
1264 1263
1265 CXFA_Node* pCurPageArea = nullptr; 1264 CXFA_Node* pCurPageArea = nullptr;
1266 if (pPreferredPageArea) 1265 if (pPreferredPageArea)
1267 pCurPageArea = pPreferredPageArea; 1266 pCurPageArea = pPreferredPageArea;
1268 else if (pFallbackPageArea) 1267 else if (pFallbackPageArea)
1269 pCurPageArea = pFallbackPageArea; 1268 pCurPageArea = pFallbackPageArea;
1270 1269
1271 if (!pCurPageArea) 1270 if (!pCurPageArea)
1272 return FALSE; 1271 return false;
1273 1272
1274 if (!bQuery) { 1273 if (!bQuery) {
1275 CXFA_ContainerRecord* pNewRecord = CreateContainerRecord(); 1274 CXFA_ContainerRecord* pNewRecord = CreateContainerRecord();
1276 AddPageAreaLayoutItem(pNewRecord, pCurPageArea); 1275 AddPageAreaLayoutItem(pNewRecord, pCurPageArea);
1277 if (!pTargetContentArea) { 1276 if (!pTargetContentArea) {
1278 pTargetContentArea = 1277 pTargetContentArea =
1279 pCurPageArea->GetFirstChildByClass(XFA_Element::ContentArea); 1278 pCurPageArea->GetFirstChildByClass(XFA_Element::ContentArea);
1280 } 1279 }
1281 AddContentAreaLayoutItem(pNewRecord, pTargetContentArea); 1280 AddContentAreaLayoutItem(pNewRecord, pTargetContentArea);
1282 } 1281 }
1283 m_pCurPageArea = pCurPageArea; 1282 m_pCurPageArea = pCurPageArea;
1284 return TRUE; 1283 return true;
1285 } 1284 }
1286 1285
1287 FX_BOOL CXFA_LayoutPageMgr::MatchPageAreaOddOrEven(CXFA_Node* pPageArea, 1286 bool CXFA_LayoutPageMgr::MatchPageAreaOddOrEven(CXFA_Node* pPageArea,
1288 FX_BOOL bLastMatch) { 1287 bool bLastMatch) {
1289 if (m_ePageSetMode != XFA_ATTRIBUTEENUM_DuplexPaginated) 1288 if (m_ePageSetMode != XFA_ATTRIBUTEENUM_DuplexPaginated)
1290 return TRUE; 1289 return true;
1291 1290
1292 XFA_ATTRIBUTEENUM eOddOrEven = XFA_ATTRIBUTEENUM_Any; 1291 XFA_ATTRIBUTEENUM eOddOrEven = XFA_ATTRIBUTEENUM_Any;
1293 pPageArea->TryEnum(XFA_ATTRIBUTE_OddOrEven, eOddOrEven); 1292 pPageArea->TryEnum(XFA_ATTRIBUTE_OddOrEven, eOddOrEven);
1294 if (eOddOrEven != XFA_ATTRIBUTEENUM_Any) { 1293 if (eOddOrEven != XFA_ATTRIBUTEENUM_Any) {
1295 int32_t iPageCount = GetPageCount(); 1294 int32_t iPageCount = GetPageCount();
1296 if (bLastMatch) { 1295 if (bLastMatch) {
1297 return eOddOrEven == XFA_ATTRIBUTEENUM_Odd ? iPageCount % 2 == 1 1296 return eOddOrEven == XFA_ATTRIBUTEENUM_Odd ? iPageCount % 2 == 1
1298 : iPageCount % 2 == 0; 1297 : iPageCount % 2 == 0;
1299 } 1298 }
1300 return eOddOrEven == XFA_ATTRIBUTEENUM_Odd ? iPageCount % 2 == 0 1299 return eOddOrEven == XFA_ATTRIBUTEENUM_Odd ? iPageCount % 2 == 0
1301 : iPageCount % 2 == 1; 1300 : iPageCount % 2 == 1;
1302 } 1301 }
1303 return TRUE; 1302 return true;
1304 } 1303 }
1305 1304
1306 CXFA_Node* CXFA_LayoutPageMgr::GetNextAvailPageArea( 1305 CXFA_Node* CXFA_LayoutPageMgr::GetNextAvailPageArea(
1307 CXFA_Node* pTargetPageArea, 1306 CXFA_Node* pTargetPageArea,
1308 CXFA_Node* pTargetContentArea, 1307 CXFA_Node* pTargetContentArea,
1309 FX_BOOL bNewPage, 1308 bool bNewPage,
1310 FX_BOOL bQuery) { 1309 bool bQuery) {
1311 if (!m_pCurPageArea) { 1310 if (!m_pCurPageArea) {
1312 FindPageAreaFromPageSet(m_pTemplatePageSetRoot, nullptr, pTargetPageArea, 1311 FindPageAreaFromPageSet(m_pTemplatePageSetRoot, nullptr, pTargetPageArea,
1313 pTargetContentArea, bNewPage, bQuery); 1312 pTargetContentArea, bNewPage, bQuery);
1314 ASSERT(m_pCurPageArea); 1313 ASSERT(m_pCurPageArea);
1315 return m_pCurPageArea; 1314 return m_pCurPageArea;
1316 } 1315 }
1317 1316
1318 if (!pTargetPageArea || pTargetPageArea == m_pCurPageArea) { 1317 if (!pTargetPageArea || pTargetPageArea == m_pCurPageArea) {
1319 if (!bNewPage && GetNextContentArea(pTargetContentArea)) 1318 if (!bNewPage && GetNextContentArea(pTargetContentArea))
1320 return m_pCurPageArea; 1319 return m_pCurPageArea;
1321 1320
1322 if (IsPageSetRootOrderedOccurrence()) { 1321 if (IsPageSetRootOrderedOccurrence()) {
1323 int32_t iMax = -1; 1322 int32_t iMax = -1;
1324 CXFA_Node* pOccurNode = 1323 CXFA_Node* pOccurNode =
1325 m_pCurPageArea->GetFirstChildByClass(XFA_Element::Occur); 1324 m_pCurPageArea->GetFirstChildByClass(XFA_Element::Occur);
1326 if (pOccurNode) 1325 if (pOccurNode)
1327 pOccurNode->TryInteger(XFA_ATTRIBUTE_Max, iMax, FALSE); 1326 pOccurNode->TryInteger(XFA_ATTRIBUTE_Max, iMax, false);
1328 if ((iMax < 0 || m_nCurPageCount < iMax)) { 1327 if ((iMax < 0 || m_nCurPageCount < iMax)) {
1329 if (!bQuery) { 1328 if (!bQuery) {
1330 CXFA_ContainerRecord* pNewRecord = 1329 CXFA_ContainerRecord* pNewRecord =
1331 CreateContainerRecord(m_pCurPageArea); 1330 CreateContainerRecord(m_pCurPageArea);
1332 AddPageAreaLayoutItem(pNewRecord, m_pCurPageArea); 1331 AddPageAreaLayoutItem(pNewRecord, m_pCurPageArea);
1333 if (!pTargetContentArea) { 1332 if (!pTargetContentArea) {
1334 pTargetContentArea = 1333 pTargetContentArea =
1335 m_pCurPageArea->GetFirstChildByClass(XFA_Element::ContentArea); 1334 m_pCurPageArea->GetFirstChildByClass(XFA_Element::ContentArea);
1336 } 1335 }
1337 AddContentAreaLayoutItem(pNewRecord, pTargetContentArea); 1336 AddContentAreaLayoutItem(pNewRecord, pTargetContentArea);
1338 } 1337 }
1339 m_nCurPageCount++; 1338 m_nCurPageCount++;
1340 return m_pCurPageArea; 1339 return m_pCurPageArea;
1341 } 1340 }
1342 } 1341 }
1343 } 1342 }
1344 1343
1345 if (!bQuery && IsPageSetRootOrderedOccurrence()) 1344 if (!bQuery && IsPageSetRootOrderedOccurrence())
1346 CreateMinPageRecord(m_pCurPageArea, FALSE, TRUE); 1345 CreateMinPageRecord(m_pCurPageArea, false, true);
1347 if (FindPageAreaFromPageSet(m_pCurPageArea->GetNodeItem(XFA_NODEITEM_Parent), 1346 if (FindPageAreaFromPageSet(m_pCurPageArea->GetNodeItem(XFA_NODEITEM_Parent),
1348 m_pCurPageArea, pTargetPageArea, 1347 m_pCurPageArea, pTargetPageArea,
1349 pTargetContentArea, bNewPage, bQuery)) { 1348 pTargetContentArea, bNewPage, bQuery)) {
1350 return m_pCurPageArea; 1349 return m_pCurPageArea;
1351 } 1350 }
1352 1351
1353 CXFA_Node* pPageSet = m_pCurPageArea->GetNodeItem(XFA_NODEITEM_Parent); 1352 CXFA_Node* pPageSet = m_pCurPageArea->GetNodeItem(XFA_NODEITEM_Parent);
1354 while (TRUE) { 1353 while (true) {
1355 if (FindPageAreaFromPageSet(pPageSet, nullptr, pTargetPageArea, 1354 if (FindPageAreaFromPageSet(pPageSet, nullptr, pTargetPageArea,
1356 pTargetContentArea, bNewPage, bQuery)) { 1355 pTargetContentArea, bNewPage, bQuery)) {
1357 return m_pCurPageArea; 1356 return m_pCurPageArea;
1358 } 1357 }
1359 if (!bQuery && IsPageSetRootOrderedOccurrence()) 1358 if (!bQuery && IsPageSetRootOrderedOccurrence())
1360 CreateMinPageSetRecord(pPageSet); 1359 CreateMinPageSetRecord(pPageSet);
1361 if (FindPageAreaFromPageSet(nullptr, pPageSet, pTargetPageArea, 1360 if (FindPageAreaFromPageSet(nullptr, pPageSet, pTargetPageArea,
1362 pTargetContentArea, bNewPage, bQuery)) { 1361 pTargetContentArea, bNewPage, bQuery)) {
1363 return m_pCurPageArea; 1362 return m_pCurPageArea;
1364 } 1363 }
1365 if (pPageSet == m_pTemplatePageSetRoot) 1364 if (pPageSet == m_pTemplatePageSetRoot)
1366 break; 1365 break;
1367 1366
1368 pPageSet = pPageSet->GetNodeItem(XFA_NODEITEM_Parent); 1367 pPageSet = pPageSet->GetNodeItem(XFA_NODEITEM_Parent);
1369 } 1368 }
1370 return nullptr; 1369 return nullptr;
1371 } 1370 }
1372 1371
1373 FX_BOOL CXFA_LayoutPageMgr::GetNextContentArea(CXFA_Node* pContentArea) { 1372 bool CXFA_LayoutPageMgr::GetNextContentArea(CXFA_Node* pContentArea) {
1374 CXFA_Node* pCurContentNode = 1373 CXFA_Node* pCurContentNode =
1375 GetCurrentContainerRecord()->pCurContentArea->m_pFormNode; 1374 GetCurrentContainerRecord()->pCurContentArea->m_pFormNode;
1376 if (!pContentArea) { 1375 if (!pContentArea) {
1377 pContentArea = 1376 pContentArea =
1378 pCurContentNode->GetNextSameClassSibling(XFA_Element::ContentArea); 1377 pCurContentNode->GetNextSameClassSibling(XFA_Element::ContentArea);
1379 if (!pContentArea) 1378 if (!pContentArea)
1380 return FALSE; 1379 return false;
1381 } else { 1380 } else {
1382 if (pContentArea->GetNodeItem(XFA_NODEITEM_Parent) != m_pCurPageArea) 1381 if (pContentArea->GetNodeItem(XFA_NODEITEM_Parent) != m_pCurPageArea)
1383 return FALSE; 1382 return false;
1384 1383
1385 CXFA_ContainerLayoutItem* pContentAreaLayout = nullptr; 1384 CXFA_ContainerLayoutItem* pContentAreaLayout = nullptr;
1386 if (!CheckContentAreaNotUsed(GetCurrentContainerRecord()->pCurPageArea, 1385 if (!CheckContentAreaNotUsed(GetCurrentContainerRecord()->pCurPageArea,
1387 pContentArea, pContentAreaLayout)) { 1386 pContentArea, pContentAreaLayout)) {
1388 return FALSE; 1387 return false;
1389 } 1388 }
1390 if (pContentAreaLayout) { 1389 if (pContentAreaLayout) {
1391 if (pContentAreaLayout->m_pFormNode != pCurContentNode) { 1390 if (pContentAreaLayout->m_pFormNode != pCurContentNode) {
1392 CXFA_ContainerRecord* pNewRecord = CreateContainerRecord(); 1391 CXFA_ContainerRecord* pNewRecord = CreateContainerRecord();
1393 pNewRecord->pCurContentArea = pContentAreaLayout; 1392 pNewRecord->pCurContentArea = pContentAreaLayout;
1394 return TRUE; 1393 return true;
1395 } 1394 }
1396 return FALSE; 1395 return false;
1397 } 1396 }
1398 } 1397 }
1399 1398
1400 CXFA_ContainerRecord* pNewRecord = CreateContainerRecord(); 1399 CXFA_ContainerRecord* pNewRecord = CreateContainerRecord();
1401 AddContentAreaLayoutItem(pNewRecord, pContentArea); 1400 AddContentAreaLayoutItem(pNewRecord, pContentArea);
1402 return TRUE; 1401 return true;
1403 } 1402 }
1404 1403
1405 void CXFA_LayoutPageMgr::InitPageSetMap() { 1404 void CXFA_LayoutPageMgr::InitPageSetMap() {
1406 if (!IsPageSetRootOrderedOccurrence()) 1405 if (!IsPageSetRootOrderedOccurrence())
1407 return; 1406 return;
1408 1407
1409 CXFA_NodeIterator sIterator(m_pTemplatePageSetRoot); 1408 CXFA_NodeIterator sIterator(m_pTemplatePageSetRoot);
1410 for (CXFA_Node* pPageSetNode = sIterator.GetCurrent(); pPageSetNode; 1409 for (CXFA_Node* pPageSetNode = sIterator.GetCurrent(); pPageSetNode;
1411 pPageSetNode = sIterator.MoveToNext()) { 1410 pPageSetNode = sIterator.MoveToNext()) {
1412 if (pPageSetNode->GetElementType() == XFA_Element::PageSet) { 1411 if (pPageSetNode->GetElementType() == XFA_Element::PageSet) {
1413 XFA_ATTRIBUTEENUM eRelation = 1412 XFA_ATTRIBUTEENUM eRelation =
1414 pPageSetNode->GetEnum(XFA_ATTRIBUTE_Relation); 1413 pPageSetNode->GetEnum(XFA_ATTRIBUTE_Relation);
1415 if (eRelation == XFA_ATTRIBUTEENUM_OrderedOccurrence) 1414 if (eRelation == XFA_ATTRIBUTEENUM_OrderedOccurrence)
1416 m_pPageSetMap.SetAt(pPageSetNode, 0); 1415 m_pPageSetMap.SetAt(pPageSetNode, 0);
1417 } 1416 }
1418 } 1417 }
1419 } 1418 }
1420 1419
1421 int32_t CXFA_LayoutPageMgr::CreateMinPageRecord(CXFA_Node* pPageArea, 1420 int32_t CXFA_LayoutPageMgr::CreateMinPageRecord(CXFA_Node* pPageArea,
1422 FX_BOOL bTargetPageArea, 1421 bool bTargetPageArea,
1423 FX_BOOL bCreateLast) { 1422 bool bCreateLast) {
1424 if (!pPageArea) 1423 if (!pPageArea)
1425 return 0; 1424 return 0;
1426 1425
1427 CXFA_Node* pOccurNode = pPageArea->GetFirstChildByClass(XFA_Element::Occur); 1426 CXFA_Node* pOccurNode = pPageArea->GetFirstChildByClass(XFA_Element::Occur);
1428 int32_t iMin = 0; 1427 int32_t iMin = 0;
1429 if ((pOccurNode && pOccurNode->TryInteger(XFA_ATTRIBUTE_Min, iMin, FALSE)) || 1428 if ((pOccurNode && pOccurNode->TryInteger(XFA_ATTRIBUTE_Min, iMin, false)) ||
1430 bTargetPageArea) { 1429 bTargetPageArea) {
1431 CXFA_Node* pContentArea = 1430 CXFA_Node* pContentArea =
1432 pPageArea->GetFirstChildByClass(XFA_Element::ContentArea); 1431 pPageArea->GetFirstChildByClass(XFA_Element::ContentArea);
1433 if (iMin < 1 && bTargetPageArea && !pContentArea) 1432 if (iMin < 1 && bTargetPageArea && !pContentArea)
1434 iMin = 1; 1433 iMin = 1;
1435 1434
1436 int32_t i = 0; 1435 int32_t i = 0;
1437 if (bCreateLast) 1436 if (bCreateLast)
1438 i = m_nCurPageCount; 1437 i = m_nCurPageCount;
1439 1438
1440 for (; i < iMin; i++) { 1439 for (; i < iMin; i++) {
1441 CXFA_ContainerRecord* pNewRecord = CreateContainerRecord(); 1440 CXFA_ContainerRecord* pNewRecord = CreateContainerRecord();
1442 AddPageAreaLayoutItem(pNewRecord, pPageArea); 1441 AddPageAreaLayoutItem(pNewRecord, pPageArea);
1443 AddContentAreaLayoutItem(pNewRecord, pContentArea); 1442 AddContentAreaLayoutItem(pNewRecord, pContentArea);
1444 } 1443 }
1445 } 1444 }
1446 return iMin; 1445 return iMin;
1447 } 1446 }
1448 1447
1449 void CXFA_LayoutPageMgr::CreateMinPageSetRecord(CXFA_Node* pPageSet, 1448 void CXFA_LayoutPageMgr::CreateMinPageSetRecord(CXFA_Node* pPageSet,
1450 FX_BOOL bCreateAll) { 1449 bool bCreateAll) {
1451 if (!pPageSet) 1450 if (!pPageSet)
1452 return; 1451 return;
1453 1452
1454 int32_t iCurSetCount = 0; 1453 int32_t iCurSetCount = 0;
1455 if (!m_pPageSetMap.Lookup(pPageSet, iCurSetCount)) 1454 if (!m_pPageSetMap.Lookup(pPageSet, iCurSetCount))
1456 return; 1455 return;
1457 if (bCreateAll) 1456 if (bCreateAll)
1458 iCurSetCount = 0; 1457 iCurSetCount = 0;
1459 1458
1460 CXFA_Node* pOccurNode = pPageSet->GetFirstChildByClass(XFA_Element::Occur); 1459 CXFA_Node* pOccurNode = pPageSet->GetFirstChildByClass(XFA_Element::Occur);
1461 int32_t iMin = 0; 1460 int32_t iMin = 0;
1462 if (pOccurNode && pOccurNode->TryInteger(XFA_ATTRIBUTE_Min, iMin, FALSE)) { 1461 if (pOccurNode && pOccurNode->TryInteger(XFA_ATTRIBUTE_Min, iMin, false)) {
1463 if (iCurSetCount < iMin) { 1462 if (iCurSetCount < iMin) {
1464 for (int32_t i = 0; i < iMin - iCurSetCount; i++) { 1463 for (int32_t i = 0; i < iMin - iCurSetCount; i++) {
1465 for (CXFA_Node* pCurrentPageNode = 1464 for (CXFA_Node* pCurrentPageNode =
1466 pPageSet->GetNodeItem(XFA_NODEITEM_FirstChild); 1465 pPageSet->GetNodeItem(XFA_NODEITEM_FirstChild);
1467 pCurrentPageNode; pCurrentPageNode = pCurrentPageNode->GetNodeItem( 1466 pCurrentPageNode; pCurrentPageNode = pCurrentPageNode->GetNodeItem(
1468 XFA_NODEITEM_NextSibling)) { 1467 XFA_NODEITEM_NextSibling)) {
1469 if (pCurrentPageNode->GetElementType() == XFA_Element::PageArea) { 1468 if (pCurrentPageNode->GetElementType() == XFA_Element::PageArea) {
1470 CreateMinPageRecord(pCurrentPageNode, FALSE); 1469 CreateMinPageRecord(pCurrentPageNode, false);
1471 } else if (pCurrentPageNode->GetElementType() == 1470 } else if (pCurrentPageNode->GetElementType() ==
1472 XFA_Element::PageSet) { 1471 XFA_Element::PageSet) {
1473 CreateMinPageSetRecord(pCurrentPageNode, TRUE); 1472 CreateMinPageSetRecord(pCurrentPageNode, true);
1474 } 1473 }
1475 } 1474 }
1476 } 1475 }
1477 m_pPageSetMap.SetAt(pPageSet, iMin); 1476 m_pPageSetMap.SetAt(pPageSet, iMin);
1478 } 1477 }
1479 } 1478 }
1480 } 1479 }
1481 1480
1482 void CXFA_LayoutPageMgr::CreateNextMinRecord(CXFA_Node* pRecordNode) { 1481 void CXFA_LayoutPageMgr::CreateNextMinRecord(CXFA_Node* pRecordNode) {
1483 if (!pRecordNode) 1482 if (!pRecordNode)
1484 return; 1483 return;
1485 1484
1486 for (CXFA_Node* pCurrentNode = 1485 for (CXFA_Node* pCurrentNode =
1487 pRecordNode->GetNodeItem(XFA_NODEITEM_NextSibling); 1486 pRecordNode->GetNodeItem(XFA_NODEITEM_NextSibling);
1488 pCurrentNode; 1487 pCurrentNode;
1489 pCurrentNode = pCurrentNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { 1488 pCurrentNode = pCurrentNode->GetNodeItem(XFA_NODEITEM_NextSibling)) {
1490 if (pCurrentNode->GetElementType() == XFA_Element::PageArea) 1489 if (pCurrentNode->GetElementType() == XFA_Element::PageArea)
1491 CreateMinPageRecord(pCurrentNode, FALSE); 1490 CreateMinPageRecord(pCurrentNode, false);
1492 else if (pCurrentNode->GetElementType() == XFA_Element::PageSet) 1491 else if (pCurrentNode->GetElementType() == XFA_Element::PageSet)
1493 CreateMinPageSetRecord(pCurrentNode, TRUE); 1492 CreateMinPageSetRecord(pCurrentNode, true);
1494 } 1493 }
1495 } 1494 }
1496 1495
1497 void CXFA_LayoutPageMgr::ProcessLastPageSet() { 1496 void CXFA_LayoutPageMgr::ProcessLastPageSet() {
1498 CreateMinPageRecord(m_pCurPageArea, FALSE, TRUE); 1497 CreateMinPageRecord(m_pCurPageArea, false, true);
1499 CreateNextMinRecord(m_pCurPageArea); 1498 CreateNextMinRecord(m_pCurPageArea);
1500 CXFA_Node* pPageSet = m_pCurPageArea->GetNodeItem(XFA_NODEITEM_Parent); 1499 CXFA_Node* pPageSet = m_pCurPageArea->GetNodeItem(XFA_NODEITEM_Parent);
1501 while (TRUE) { 1500 while (true) {
1502 CreateMinPageSetRecord(pPageSet); 1501 CreateMinPageSetRecord(pPageSet);
1503 if (pPageSet == m_pTemplatePageSetRoot) 1502 if (pPageSet == m_pTemplatePageSetRoot)
1504 break; 1503 break;
1505 1504
1506 CreateNextMinRecord(pPageSet); 1505 CreateNextMinRecord(pPageSet);
1507 pPageSet = pPageSet->GetNodeItem(XFA_NODEITEM_Parent); 1506 pPageSet = pPageSet->GetNodeItem(XFA_NODEITEM_Parent);
1508 } 1507 }
1509 } 1508 }
1510 1509
1511 FX_BOOL CXFA_LayoutPageMgr::GetNextAvailContentHeight(FX_FLOAT fChildHeight) { 1510 bool CXFA_LayoutPageMgr::GetNextAvailContentHeight(FX_FLOAT fChildHeight) {
1512 CXFA_Node* pCurContentNode = 1511 CXFA_Node* pCurContentNode =
1513 GetCurrentContainerRecord()->pCurContentArea->m_pFormNode; 1512 GetCurrentContainerRecord()->pCurContentArea->m_pFormNode;
1514 if (!pCurContentNode) 1513 if (!pCurContentNode)
1515 return FALSE; 1514 return false;
1516 1515
1517 pCurContentNode = 1516 pCurContentNode =
1518 pCurContentNode->GetNextSameClassSibling(XFA_Element::ContentArea); 1517 pCurContentNode->GetNextSameClassSibling(XFA_Element::ContentArea);
1519 if (pCurContentNode) { 1518 if (pCurContentNode) {
1520 FX_FLOAT fNextContentHeight = 1519 FX_FLOAT fNextContentHeight =
1521 pCurContentNode->GetMeasure(XFA_ATTRIBUTE_H).ToUnit(XFA_UNIT_Pt); 1520 pCurContentNode->GetMeasure(XFA_ATTRIBUTE_H).ToUnit(XFA_UNIT_Pt);
1522 return fNextContentHeight > fChildHeight; 1521 return fNextContentHeight > fChildHeight;
1523 } 1522 }
1524 1523
1525 CXFA_Node* pPageNode = GetCurrentContainerRecord()->pCurPageArea->m_pFormNode; 1524 CXFA_Node* pPageNode = GetCurrentContainerRecord()->pCurPageArea->m_pFormNode;
1526 CXFA_Node* pOccurNode = pPageNode->GetFirstChildByClass(XFA_Element::Occur); 1525 CXFA_Node* pOccurNode = pPageNode->GetFirstChildByClass(XFA_Element::Occur);
1527 int32_t iMax = 0; 1526 int32_t iMax = 0;
1528 if (pOccurNode && pOccurNode->TryInteger(XFA_ATTRIBUTE_Max, iMax, FALSE)) { 1527 if (pOccurNode && pOccurNode->TryInteger(XFA_ATTRIBUTE_Max, iMax, false)) {
1529 if (m_nCurPageCount == iMax) { 1528 if (m_nCurPageCount == iMax) {
1530 CXFA_Node* pSrcPage = m_pCurPageArea; 1529 CXFA_Node* pSrcPage = m_pCurPageArea;
1531 int32_t nSrcPageCount = m_nCurPageCount; 1530 int32_t nSrcPageCount = m_nCurPageCount;
1532 FX_POSITION psSrcRecord = m_rgProposedContainerRecord.GetTailPosition(); 1531 FX_POSITION psSrcRecord = m_rgProposedContainerRecord.GetTailPosition();
1533 CXFA_Node* pNextPage = 1532 CXFA_Node* pNextPage =
1534 GetNextAvailPageArea(nullptr, nullptr, FALSE, TRUE); 1533 GetNextAvailPageArea(nullptr, nullptr, false, true);
1535 m_pCurPageArea = pSrcPage; 1534 m_pCurPageArea = pSrcPage;
1536 m_nCurPageCount = nSrcPageCount; 1535 m_nCurPageCount = nSrcPageCount;
1537 CXFA_ContainerRecord* pPrevRecord = static_cast<CXFA_ContainerRecord*>( 1536 CXFA_ContainerRecord* pPrevRecord = static_cast<CXFA_ContainerRecord*>(
1538 m_rgProposedContainerRecord.GetNext(psSrcRecord)); 1537 m_rgProposedContainerRecord.GetNext(psSrcRecord));
1539 while (psSrcRecord) { 1538 while (psSrcRecord) {
1540 FX_POSITION psSaveRecord = psSrcRecord; 1539 FX_POSITION psSaveRecord = psSrcRecord;
1541 CXFA_ContainerRecord* pInsertRecord = 1540 CXFA_ContainerRecord* pInsertRecord =
1542 static_cast<CXFA_ContainerRecord*>( 1541 static_cast<CXFA_ContainerRecord*>(
1543 m_rgProposedContainerRecord.GetNext(psSrcRecord)); 1542 m_rgProposedContainerRecord.GetNext(psSrcRecord));
1544 RemoveLayoutRecord(pInsertRecord, pPrevRecord); 1543 RemoveLayoutRecord(pInsertRecord, pPrevRecord);
1545 delete pInsertRecord; 1544 delete pInsertRecord;
1546 m_rgProposedContainerRecord.RemoveAt(psSaveRecord); 1545 m_rgProposedContainerRecord.RemoveAt(psSaveRecord);
1547 } 1546 }
1548 if (pNextPage) { 1547 if (pNextPage) {
1549 CXFA_Node* pContentArea = 1548 CXFA_Node* pContentArea =
1550 pNextPage->GetFirstChildByClass(XFA_Element::ContentArea); 1549 pNextPage->GetFirstChildByClass(XFA_Element::ContentArea);
1551 if (pContentArea) { 1550 if (pContentArea) {
1552 FX_FLOAT fNextContentHeight = 1551 FX_FLOAT fNextContentHeight =
1553 pContentArea->GetMeasure(XFA_ATTRIBUTE_H).ToUnit(XFA_UNIT_Pt); 1552 pContentArea->GetMeasure(XFA_ATTRIBUTE_H).ToUnit(XFA_UNIT_Pt);
1554 if (fNextContentHeight > fChildHeight) 1553 if (fNextContentHeight > fChildHeight)
1555 return TRUE; 1554 return true;
1556 } 1555 }
1557 } 1556 }
1558 return FALSE; 1557 return false;
1559 } 1558 }
1560 } 1559 }
1561 1560
1562 CXFA_Node* pContentArea = 1561 CXFA_Node* pContentArea =
1563 pPageNode->GetFirstChildByClass(XFA_Element::ContentArea); 1562 pPageNode->GetFirstChildByClass(XFA_Element::ContentArea);
1564 FX_FLOAT fNextContentHeight = 1563 FX_FLOAT fNextContentHeight =
1565 pContentArea->GetMeasure(XFA_ATTRIBUTE_H).ToUnit(XFA_UNIT_Pt); 1564 pContentArea->GetMeasure(XFA_ATTRIBUTE_H).ToUnit(XFA_UNIT_Pt);
1566 if (fNextContentHeight < XFA_LAYOUT_FLOAT_PERCISION) 1565 if (fNextContentHeight < XFA_LAYOUT_FLOAT_PERCISION)
1567 return TRUE; 1566 return true;
1568 if (fNextContentHeight > fChildHeight) 1567 if (fNextContentHeight > fChildHeight)
1569 return TRUE; 1568 return true;
1570 return FALSE; 1569 return false;
1571 } 1570 }
1572 1571
1573 void CXFA_LayoutPageMgr::ClearData() { 1572 void CXFA_LayoutPageMgr::ClearData() {
1574 ClearRecordList(); 1573 ClearRecordList();
1575 } 1574 }
1576 1575
1577 void CXFA_LayoutPageMgr::ClearRecordList() { 1576 void CXFA_LayoutPageMgr::ClearRecordList() {
1578 if (!m_pTemplatePageSetRoot) 1577 if (!m_pTemplatePageSetRoot)
1579 return; 1578 return;
1580 if (m_rgProposedContainerRecord.GetCount() > 0) { 1579 if (m_rgProposedContainerRecord.GetCount() > 0) {
1581 FX_POSITION sPos; 1580 FX_POSITION sPos;
1582 sPos = m_rgProposedContainerRecord.GetHeadPosition(); 1581 sPos = m_rgProposedContainerRecord.GetHeadPosition();
1583 while (sPos) { 1582 while (sPos) {
1584 CXFA_ContainerRecord* pRecord = static_cast<CXFA_ContainerRecord*>( 1583 CXFA_ContainerRecord* pRecord = static_cast<CXFA_ContainerRecord*>(
1585 m_rgProposedContainerRecord.GetNext(sPos)); 1584 m_rgProposedContainerRecord.GetNext(sPos));
1586 delete pRecord; 1585 delete pRecord;
1587 } 1586 }
1588 m_rgProposedContainerRecord.RemoveAll(); 1587 m_rgProposedContainerRecord.RemoveAll();
1589 } 1588 }
1590 m_pCurrentContainerRecord = nullptr; 1589 m_pCurrentContainerRecord = nullptr;
1591 m_pCurPageArea = nullptr; 1590 m_pCurPageArea = nullptr;
1592 m_nCurPageCount = 0; 1591 m_nCurPageCount = 0;
1593 m_bCreateOverFlowPage = FALSE; 1592 m_bCreateOverFlowPage = false;
1594 m_pPageSetMap.RemoveAll(); 1593 m_pPageSetMap.RemoveAll();
1595 } 1594 }
1596 1595
1597 CXFA_LayoutItem* CXFA_LayoutPageMgr::FindOrCreateLayoutItem( 1596 CXFA_LayoutItem* CXFA_LayoutPageMgr::FindOrCreateLayoutItem(
1598 CXFA_Node* pFormNode) { 1597 CXFA_Node* pFormNode) {
1599 return pFormNode->GetDocument()->GetNotify()->OnCreateLayoutItem(pFormNode); 1598 return pFormNode->GetDocument()->GetNotify()->OnCreateLayoutItem(pFormNode);
1600 } 1599 }
1601 1600
1602 void CXFA_LayoutPageMgr::SaveLayoutItem(CXFA_LayoutItem* pParentLayoutItem) { 1601 void CXFA_LayoutPageMgr::SaveLayoutItem(CXFA_LayoutItem* pParentLayoutItem) {
1603 CXFA_LayoutItem* pNextLayoutItem; 1602 CXFA_LayoutItem* pNextLayoutItem;
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
1704 ASSERT(pRootPageSetContainerItem->m_pFormNode->GetElementType() == 1703 ASSERT(pRootPageSetContainerItem->m_pFormNode->GetElementType() ==
1705 XFA_Element::PageSet); 1704 XFA_Element::PageSet);
1706 if (iIndex < pDocument->m_pPendingPageSet.GetSize()) { 1705 if (iIndex < pDocument->m_pPendingPageSet.GetSize()) {
1707 pPendingPageSet = pDocument->m_pPendingPageSet.GetAt(iIndex); 1706 pPendingPageSet = pDocument->m_pPendingPageSet.GetAt(iIndex);
1708 iIndex++; 1707 iIndex++;
1709 } 1708 }
1710 if (!pPendingPageSet) { 1709 if (!pPendingPageSet) {
1711 if (pRootPageSetContainerItem->m_pFormNode->GetPacketID() == 1710 if (pRootPageSetContainerItem->m_pFormNode->GetPacketID() ==
1712 XFA_XDPPACKET_Template) { 1711 XFA_XDPPACKET_Template) {
1713 pPendingPageSet = 1712 pPendingPageSet =
1714 pRootPageSetContainerItem->m_pFormNode->CloneTemplateToForm(FALSE); 1713 pRootPageSetContainerItem->m_pFormNode->CloneTemplateToForm(false);
1715 } else { 1714 } else {
1716 pPendingPageSet = pRootPageSetContainerItem->m_pFormNode; 1715 pPendingPageSet = pRootPageSetContainerItem->m_pFormNode;
1717 } 1716 }
1718 } 1717 }
1719 if (pRootPageSetContainerItem->m_pFormNode->GetUserData( 1718 if (pRootPageSetContainerItem->m_pFormNode->GetUserData(
1720 XFA_LAYOUTITEMKEY) == pRootPageSetContainerItem) { 1719 XFA_LAYOUTITEMKEY) == pRootPageSetContainerItem) {
1721 pRootPageSetContainerItem->m_pFormNode->SetUserData(XFA_LAYOUTITEMKEY, 1720 pRootPageSetContainerItem->m_pFormNode->SetUserData(XFA_LAYOUTITEMKEY,
1722 nullptr); 1721 nullptr);
1723 } 1722 }
1724 pRootPageSetContainerItem->m_pFormNode = pPendingPageSet; 1723 pRootPageSetContainerItem->m_pFormNode = pPendingPageSet;
1725 pPendingPageSet->ClearFlag(XFA_NodeFlag_UnusedNode); 1724 pPendingPageSet->ClearFlag(XFA_NodeFlag_UnusedNode);
1726 for (CXFA_ContainerLayoutItem* pContainerItem = iterator.MoveToNext(); 1725 for (CXFA_ContainerLayoutItem* pContainerItem = iterator.MoveToNext();
1727 pContainerItem; pContainerItem = iterator.MoveToNext()) { 1726 pContainerItem; pContainerItem = iterator.MoveToNext()) {
1728 CXFA_Node* pNode = pContainerItem->m_pFormNode; 1727 CXFA_Node* pNode = pContainerItem->m_pFormNode;
1729 if (pNode->GetPacketID() != XFA_XDPPACKET_Template) 1728 if (pNode->GetPacketID() != XFA_XDPPACKET_Template)
1730 continue; 1729 continue;
1731 1730
1732 switch (pNode->GetElementType()) { 1731 switch (pNode->GetElementType()) {
1733 case XFA_Element::PageSet: { 1732 case XFA_Element::PageSet: {
1734 CXFA_Node* pParentNode = pContainerItem->m_pParent->m_pFormNode; 1733 CXFA_Node* pParentNode = pContainerItem->m_pParent->m_pFormNode;
1735 pContainerItem->m_pFormNode = XFA_NodeMerge_CloneOrMergeContainer( 1734 pContainerItem->m_pFormNode = XFA_NodeMerge_CloneOrMergeContainer(
1736 pDocument, pParentNode, pContainerItem->m_pFormNode, TRUE, 1735 pDocument, pParentNode, pContainerItem->m_pFormNode, true,
1737 nullptr); 1736 nullptr);
1738 break; 1737 break;
1739 } 1738 }
1740 case XFA_Element::PageArea: { 1739 case XFA_Element::PageArea: {
1741 CXFA_ContainerLayoutItem* pFormLayout = pContainerItem; 1740 CXFA_ContainerLayoutItem* pFormLayout = pContainerItem;
1742 CXFA_Node* pParentNode = pContainerItem->m_pParent->m_pFormNode; 1741 CXFA_Node* pParentNode = pContainerItem->m_pParent->m_pFormNode;
1743 FX_BOOL bIsExistForm = TRUE; 1742 bool bIsExistForm = true;
1744 for (int32_t iLevel = 0; iLevel < 3; iLevel++) { 1743 for (int32_t iLevel = 0; iLevel < 3; iLevel++) {
1745 pFormLayout = static_cast<CXFA_ContainerLayoutItem*>( 1744 pFormLayout = static_cast<CXFA_ContainerLayoutItem*>(
1746 pFormLayout->m_pFirstChild); 1745 pFormLayout->m_pFirstChild);
1747 if (iLevel == 2) { 1746 if (iLevel == 2) {
1748 while (pFormLayout && 1747 while (pFormLayout &&
1749 !XFA_ItemLayoutProcessor_IsTakingSpace( 1748 !XFA_ItemLayoutProcessor_IsTakingSpace(
1750 pFormLayout->m_pFormNode)) { 1749 pFormLayout->m_pFormNode)) {
1751 pFormLayout = static_cast<CXFA_ContainerLayoutItem*>( 1750 pFormLayout = static_cast<CXFA_ContainerLayoutItem*>(
1752 pFormLayout->m_pNextSibling); 1751 pFormLayout->m_pNextSibling);
1753 } 1752 }
1754 } 1753 }
1755 if (!pFormLayout) { 1754 if (!pFormLayout) {
1756 bIsExistForm = FALSE; 1755 bIsExistForm = false;
1757 break; 1756 break;
1758 } 1757 }
1759 } 1758 }
1760 if (bIsExistForm) { 1759 if (bIsExistForm) {
1761 CXFA_Node* pNewSubform = pFormLayout->m_pFormNode; 1760 CXFA_Node* pNewSubform = pFormLayout->m_pFormNode;
1762 if (pContainerItem->m_pOldSubform && 1761 if (pContainerItem->m_pOldSubform &&
1763 pContainerItem->m_pOldSubform != pNewSubform) { 1762 pContainerItem->m_pOldSubform != pNewSubform) {
1764 CXFA_Node* pExistingNode = XFA_DataMerge_FindFormDOMInstance( 1763 CXFA_Node* pExistingNode = XFA_DataMerge_FindFormDOMInstance(
1765 pDocument, pContainerItem->m_pFormNode->GetElementType(), 1764 pDocument, pContainerItem->m_pFormNode->GetElementType(),
1766 pContainerItem->m_pFormNode->GetNameHash(), pParentNode); 1765 pContainerItem->m_pFormNode->GetNameHash(), pParentNode);
(...skipping 10 matching lines...) Expand all
1777 } 1776 }
1778 } 1777 }
1779 if (pExistingNode) { 1778 if (pExistingNode) {
1780 pParentNode->RemoveChild(pExistingNode); 1779 pParentNode->RemoveChild(pExistingNode);
1781 } 1780 }
1782 } 1781 }
1783 pContainerItem->m_pOldSubform = pNewSubform; 1782 pContainerItem->m_pOldSubform = pNewSubform;
1784 } 1783 }
1785 pContainerItem->m_pFormNode = pDocument->DataMerge_CopyContainer( 1784 pContainerItem->m_pFormNode = pDocument->DataMerge_CopyContainer(
1786 pContainerItem->m_pFormNode, pParentNode, 1785 pContainerItem->m_pFormNode, pParentNode,
1787 ToNode(pDocument->GetXFAObject(XFA_HASHCODE_Record)), TRUE, TRUE, 1786 ToNode(pDocument->GetXFAObject(XFA_HASHCODE_Record)), true, true,
1788 TRUE); 1787 true);
1789 break; 1788 break;
1790 } 1789 }
1791 case XFA_Element::ContentArea: { 1790 case XFA_Element::ContentArea: {
1792 CXFA_Node* pParentNode = pContainerItem->m_pParent->m_pFormNode; 1791 CXFA_Node* pParentNode = pContainerItem->m_pParent->m_pFormNode;
1793 for (CXFA_Node* pChildNode = 1792 for (CXFA_Node* pChildNode =
1794 pParentNode->GetNodeItem(XFA_NODEITEM_FirstChild); 1793 pParentNode->GetNodeItem(XFA_NODEITEM_FirstChild);
1795 pChildNode; 1794 pChildNode;
1796 pChildNode = pChildNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { 1795 pChildNode = pChildNode->GetNodeItem(XFA_NODEITEM_NextSibling)) {
1797 if (pChildNode->GetTemplateNode() != pContainerItem->m_pFormNode) { 1796 if (pChildNode->GetTemplateNode() != pContainerItem->m_pFormNode) {
1798 continue; 1797 continue;
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
1912 CXFA_TraverseStrategy_LayoutItem> 1911 CXFA_TraverseStrategy_LayoutItem>
1913 iterator(pContainerItem); 1912 iterator(pContainerItem);
1914 CXFA_LayoutItem* pChildLayoutItem = iterator.GetCurrent(); 1913 CXFA_LayoutItem* pChildLayoutItem = iterator.GetCurrent();
1915 while (pChildLayoutItem) { 1914 while (pChildLayoutItem) {
1916 CXFA_ContentLayoutItem* pContentItem = 1915 CXFA_ContentLayoutItem* pContentItem =
1917 pChildLayoutItem->AsContentLayoutItem(); 1916 pChildLayoutItem->AsContentLayoutItem();
1918 if (!pContentItem) { 1917 if (!pContentItem) {
1919 pChildLayoutItem = iterator.MoveToNext(); 1918 pChildLayoutItem = iterator.MoveToNext();
1920 continue; 1919 continue;
1921 } 1920 }
1922 FX_BOOL bVisible = 1921 bool bVisible =
1923 (pContentItem->m_pFormNode->GetEnum(XFA_ATTRIBUTE_Presence) == 1922 (pContentItem->m_pFormNode->GetEnum(XFA_ATTRIBUTE_Presence) ==
1924 XFA_ATTRIBUTEENUM_Visible); 1923 XFA_ATTRIBUTEENUM_Visible);
1925 uint32_t dwRelevantChild = 1924 uint32_t dwRelevantChild =
1926 GetRelevant(pContentItem->m_pFormNode, dwRelevant); 1925 GetRelevant(pContentItem->m_pFormNode, dwRelevant);
1927 SyncContainer(pNotify, m_pLayoutProcessor, pContentItem, 1926 SyncContainer(pNotify, m_pLayoutProcessor, pContentItem,
1928 dwRelevantChild, bVisible, nPageIdx); 1927 dwRelevantChild, bVisible, nPageIdx);
1929 pChildLayoutItem = iterator.SkipChildrenAndMoveToNext(); 1928 pChildLayoutItem = iterator.SkipChildrenAndMoveToNext();
1930 } 1929 }
1931 break; 1930 break;
1932 } 1931 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1975 XFA_ReleaseLayoutItem(pRootLayoutItem); 1974 XFA_ReleaseLayoutItem(pRootLayoutItem);
1976 m_pPageSetLayoutItemRoot = nullptr; 1975 m_pPageSetLayoutItemRoot = nullptr;
1977 pRootLayoutItem = nullptr; 1976 pRootLayoutItem = nullptr;
1978 pPageSetFormNode = nullptr; 1977 pPageSetFormNode = nullptr;
1979 m_PageArray.RemoveAll(); 1978 m_PageArray.RemoveAll();
1980 } 1979 }
1981 while (pPageSetFormNode) { 1980 while (pPageSetFormNode) {
1982 CXFA_Node* pNextPageSet = 1981 CXFA_Node* pNextPageSet =
1983 pPageSetFormNode->GetNextSameClassSibling(XFA_Element::PageSet); 1982 pPageSetFormNode->GetNextSameClassSibling(XFA_Element::PageSet);
1984 pPageSetFormNode->GetNodeItem(XFA_NODEITEM_Parent) 1983 pPageSetFormNode->GetNodeItem(XFA_NODEITEM_Parent)
1985 ->RemoveChild(pPageSetFormNode, FALSE); 1984 ->RemoveChild(pPageSetFormNode, false);
1986 pRootLayoutItem->m_pFormNode->GetDocument()->m_pPendingPageSet.Add( 1985 pRootLayoutItem->m_pFormNode->GetDocument()->m_pPendingPageSet.Add(
1987 pPageSetFormNode); 1986 pPageSetFormNode);
1988 pPageSetFormNode = pNextPageSet; 1987 pPageSetFormNode = pNextPageSet;
1989 } 1988 }
1990 } 1989 }
1991 pRootLayoutItem = m_pPageSetLayoutItemRoot; 1990 pRootLayoutItem = m_pPageSetLayoutItemRoot;
1992 CXFA_ContainerLayoutItem* pNextLayout = nullptr; 1991 CXFA_ContainerLayoutItem* pNextLayout = nullptr;
1993 for (; pRootLayoutItem; pRootLayoutItem = pNextLayout) { 1992 for (; pRootLayoutItem; pRootLayoutItem = pNextLayout) {
1994 pNextLayout = 1993 pNextLayout =
1995 static_cast<CXFA_ContainerLayoutItem*>(pRootLayoutItem->m_pNextSibling); 1994 static_cast<CXFA_ContainerLayoutItem*>(pRootLayoutItem->m_pNextSibling);
1996 SaveLayoutItem(pRootLayoutItem); 1995 SaveLayoutItem(pRootLayoutItem);
1997 delete pRootLayoutItem; 1996 delete pRootLayoutItem;
1998 } 1997 }
1999 m_pPageSetLayoutItemRoot = nullptr; 1998 m_pPageSetLayoutItemRoot = nullptr;
2000 } 1999 }
OLDNEW
« no previous file with comments | « xfa/fxfa/parser/cxfa_layoutpagemgr.h ('k') | xfa/fxfa/parser/cxfa_layoutprocessor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698