OLD | NEW |
| (Empty) |
1 // Copyright 2014 PDFium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | |
6 | |
7 #include "xfa/src/fxfa/parser/xfa_layout_itemlayout.h" | |
8 | |
9 #include <algorithm> | |
10 #include <memory> | |
11 | |
12 #include "xfa/src/fgas/crt/fgas_algorithm.h" | |
13 #include "xfa/src/fxfa/fm2js/xfa_fm2jsapi.h" | |
14 #include "xfa/src/fxfa/parser/xfa_docdata.h" | |
15 #include "xfa/src/fxfa/parser/xfa_doclayout.h" | |
16 #include "xfa/src/fxfa/parser/xfa_document.h" | |
17 #include "xfa/src/fxfa/parser/xfa_document_layout_imp.h" | |
18 #include "xfa/src/fxfa/parser/xfa_layout_appadapter.h" | |
19 #include "xfa/src/fxfa/parser/xfa_layout_pagemgr_new.h" | |
20 #include "xfa/src/fxfa/parser/xfa_localemgr.h" | |
21 #include "xfa/src/fxfa/parser/xfa_object.h" | |
22 #include "xfa/src/fxfa/parser/xfa_parser.h" | |
23 #include "xfa/src/fxfa/parser/xfa_script.h" | |
24 #include "xfa/src/fxfa/parser/xfa_utils.h" | |
25 | |
26 CXFA_ItemLayoutProcessor::CXFA_ItemLayoutProcessor(CXFA_Node* pNode, | |
27 CXFA_LayoutPageMgr* pPageMgr) | |
28 : m_bKeepBreakFinish(FALSE), | |
29 m_bIsProcessKeep(FALSE), | |
30 m_pKeepHeadNode(nullptr), | |
31 m_pKeepTailNode(nullptr), | |
32 m_pFormNode(pNode), | |
33 m_pLayoutItem(nullptr), | |
34 m_pOldLayoutItem(nullptr), | |
35 m_pCurChildNode(XFA_LAYOUT_INVALIDNODE), | |
36 m_pCurChildPreprocessor(nullptr), | |
37 m_nCurChildNodeStage(XFA_ItemLayoutProcessorStages_None), | |
38 m_fUsedSize(0), | |
39 m_pPageMgr(pPageMgr), | |
40 m_bBreakPending(TRUE), | |
41 m_fLastRowWidth(0), | |
42 m_fLastRowY(0), | |
43 m_fWidthLimite(0), | |
44 m_bUseInheriated(FALSE), | |
45 m_ePreProcessRs(XFA_ItemLayoutProcessorResult_Done), | |
46 m_bHasAvailHeight(TRUE) { | |
47 FXSYS_assert(m_pFormNode && (m_pFormNode->IsContainerNode() || | |
48 m_pFormNode->GetClassID() == XFA_ELEMENT_Form)); | |
49 m_pOldLayoutItem = | |
50 (CXFA_ContentLayoutItem*)m_pFormNode->GetUserData(XFA_LAYOUTITEMKEY); | |
51 } | |
52 CXFA_ContentLayoutItem* CXFA_ItemLayoutProcessor::CreateContentLayoutItem( | |
53 CXFA_Node* pFormNode) { | |
54 if (!pFormNode) { | |
55 return NULL; | |
56 } | |
57 CXFA_ContentLayoutItem* pLayoutItem = NULL; | |
58 if (m_pOldLayoutItem) { | |
59 pLayoutItem = m_pOldLayoutItem; | |
60 m_pOldLayoutItem = m_pOldLayoutItem->m_pNext; | |
61 return pLayoutItem; | |
62 } | |
63 pLayoutItem = (CXFA_ContentLayoutItem*)pFormNode->GetDocument() | |
64 ->GetParser() | |
65 ->GetNotify() | |
66 ->OnCreateLayoutItem(pFormNode); | |
67 CXFA_ContentLayoutItem* pPrevLayoutItem = | |
68 (CXFA_ContentLayoutItem*)pFormNode->GetUserData(XFA_LAYOUTITEMKEY); | |
69 if (pPrevLayoutItem) { | |
70 while (pPrevLayoutItem->m_pNext) { | |
71 pPrevLayoutItem = pPrevLayoutItem->m_pNext; | |
72 } | |
73 pPrevLayoutItem->m_pNext = pLayoutItem; | |
74 pLayoutItem->m_pPrev = pPrevLayoutItem; | |
75 } else { | |
76 pFormNode->SetUserData(XFA_LAYOUTITEMKEY, pLayoutItem); | |
77 } | |
78 return pLayoutItem; | |
79 } | |
80 FX_BOOL CXFA_ItemLayoutProcessor::FindLayoutItemSplitPos( | |
81 CXFA_ContentLayoutItem* pLayoutItem, | |
82 FX_FLOAT fCurVerticalOffset, | |
83 FX_FLOAT& fProposedSplitPos, | |
84 FX_BOOL& bAppChange, | |
85 FX_BOOL bCalculateMargin) { | |
86 CXFA_Node* pFormNode = pLayoutItem->m_pFormNode; | |
87 if (fProposedSplitPos > fCurVerticalOffset + XFA_LAYOUT_FLOAT_PERCISION && | |
88 fProposedSplitPos <= fCurVerticalOffset + pLayoutItem->m_sSize.y - | |
89 XFA_LAYOUT_FLOAT_PERCISION) { | |
90 switch (pFormNode->GetIntact()) { | |
91 case XFA_ATTRIBUTEENUM_None: { | |
92 FX_BOOL bAnyChanged = FALSE; | |
93 CXFA_Document* pDocument = pFormNode->GetDocument(); | |
94 IXFA_Notify* pNotify = pDocument->GetParser()->GetNotify(); | |
95 FX_FLOAT fCurTopMargin = 0, fCurBottomMargin = 0; | |
96 CXFA_Node* pMarginNode = | |
97 pFormNode->GetFirstChildByClass(XFA_ELEMENT_Margin); | |
98 if (pMarginNode && bCalculateMargin) { | |
99 fCurTopMargin = pMarginNode->GetMeasure(XFA_ATTRIBUTE_TopInset) | |
100 .ToUnit(XFA_UNIT_Pt); | |
101 fCurBottomMargin = pMarginNode->GetMeasure(XFA_ATTRIBUTE_BottomInset) | |
102 .ToUnit(XFA_UNIT_Pt); | |
103 } | |
104 FX_BOOL bChanged = TRUE; | |
105 while (bChanged) { | |
106 bChanged = FALSE; | |
107 { | |
108 FX_FLOAT fRelSplitPos = fProposedSplitPos - fCurVerticalOffset; | |
109 if (pNotify->FindSplitPos(pFormNode, pLayoutItem->GetIndex(), | |
110 fRelSplitPos)) { | |
111 bAnyChanged = TRUE; | |
112 bChanged = TRUE; | |
113 fProposedSplitPos = fCurVerticalOffset + fRelSplitPos; | |
114 bAppChange = TRUE; | |
115 if (fProposedSplitPos <= | |
116 fCurVerticalOffset + XFA_LAYOUT_FLOAT_PERCISION) { | |
117 return TRUE; | |
118 } | |
119 } | |
120 } | |
121 FX_FLOAT fRelSplitPos = fProposedSplitPos - fCurBottomMargin; | |
122 for (CXFA_ContentLayoutItem* pChildItem = | |
123 (CXFA_ContentLayoutItem*)pLayoutItem->m_pFirstChild; | |
124 pChildItem; | |
125 pChildItem = | |
126 (CXFA_ContentLayoutItem*)pChildItem->m_pNextSibling) { | |
127 FX_FLOAT fChildOffset = | |
128 fCurVerticalOffset + fCurTopMargin + pChildItem->m_sPos.y; | |
129 FX_BOOL bAppChange = FALSE; | |
130 if (FindLayoutItemSplitPos(pChildItem, fChildOffset, fRelSplitPos, | |
131 bAppChange, bCalculateMargin)) { | |
132 if (fRelSplitPos - fChildOffset < XFA_LAYOUT_FLOAT_PERCISION && | |
133 bAppChange) { | |
134 fProposedSplitPos = fRelSplitPos - fCurTopMargin; | |
135 } else { | |
136 fProposedSplitPos = fRelSplitPos + fCurBottomMargin; | |
137 } | |
138 bAnyChanged = TRUE; | |
139 bChanged = TRUE; | |
140 if (fProposedSplitPos <= | |
141 fCurVerticalOffset + XFA_LAYOUT_FLOAT_PERCISION) { | |
142 return TRUE; | |
143 } | |
144 if (bAnyChanged) { | |
145 break; | |
146 } | |
147 } | |
148 } | |
149 } | |
150 return bAnyChanged; | |
151 } break; | |
152 case XFA_ATTRIBUTEENUM_ContentArea: | |
153 case XFA_ATTRIBUTEENUM_PageArea: { | |
154 fProposedSplitPos = fCurVerticalOffset; | |
155 return TRUE; | |
156 } | |
157 default: | |
158 return FALSE; | |
159 } | |
160 } | |
161 return FALSE; | |
162 } | |
163 static XFA_ATTRIBUTEENUM XFA_ItemLayoutProcessor_GetLayout( | |
164 CXFA_Node* pFormNode, | |
165 FX_BOOL& bRootForceTb) { | |
166 bRootForceTb = FALSE; | |
167 XFA_ATTRIBUTEENUM eLayoutMode; | |
168 if (pFormNode->TryEnum(XFA_ATTRIBUTE_Layout, eLayoutMode, FALSE)) { | |
169 return eLayoutMode; | |
170 } | |
171 CXFA_Node* pParentNode = pFormNode->GetNodeItem(XFA_NODEITEM_Parent); | |
172 if (pParentNode && pParentNode->GetClassID() == XFA_ELEMENT_Form) { | |
173 bRootForceTb = TRUE; | |
174 return XFA_ATTRIBUTEENUM_Tb; | |
175 } | |
176 return XFA_ATTRIBUTEENUM_Position; | |
177 } | |
178 static FX_BOOL XFA_ExistContainerKeep(CXFA_Node* pCurNode, FX_BOOL bPreFind) { | |
179 if (pCurNode == NULL || !XFA_ItemLayoutProcessor_IsTakingSpace(pCurNode)) { | |
180 return FALSE; | |
181 } | |
182 XFA_NODEITEM eItemType = XFA_NODEITEM_PrevSibling; | |
183 if (!bPreFind) { | |
184 eItemType = XFA_NODEITEM_NextSibling; | |
185 } | |
186 CXFA_Node* pPreContainer = | |
187 pCurNode->GetNodeItem(eItemType, XFA_OBJECTTYPE_ContainerNode); | |
188 if (pPreContainer == NULL) { | |
189 return FALSE; | |
190 } | |
191 CXFA_Node* pKeep = pCurNode->GetFirstChildByClass(XFA_ELEMENT_Keep); | |
192 if (pKeep) { | |
193 XFA_ATTRIBUTEENUM ePrevious; | |
194 XFA_ATTRIBUTE eKeepType = XFA_ATTRIBUTE_Previous; | |
195 if (!bPreFind) { | |
196 eKeepType = XFA_ATTRIBUTE_Next; | |
197 } | |
198 if (pKeep->TryEnum(eKeepType, ePrevious, FALSE)) { | |
199 if (ePrevious == XFA_ATTRIBUTEENUM_ContentArea || | |
200 ePrevious == XFA_ATTRIBUTEENUM_PageArea) { | |
201 return TRUE; | |
202 } | |
203 } | |
204 } | |
205 pKeep = pPreContainer->GetFirstChildByClass(XFA_ELEMENT_Keep); | |
206 if (!pKeep) { | |
207 return FALSE; | |
208 } | |
209 XFA_ATTRIBUTEENUM eNext; | |
210 XFA_ATTRIBUTE eKeepType = XFA_ATTRIBUTE_Next; | |
211 if (!bPreFind) { | |
212 eKeepType = XFA_ATTRIBUTE_Previous; | |
213 } | |
214 if (!pKeep->TryEnum(eKeepType, eNext, FALSE)) { | |
215 return FALSE; | |
216 } | |
217 if (eNext == XFA_ATTRIBUTEENUM_ContentArea || | |
218 eNext == XFA_ATTRIBUTEENUM_PageArea) { | |
219 return TRUE; | |
220 } | |
221 return FALSE; | |
222 } | |
223 FX_FLOAT CXFA_ItemLayoutProcessor::FindSplitPos(FX_FLOAT fProposedSplitPos) { | |
224 ASSERT(m_pLayoutItem); | |
225 XFA_ATTRIBUTEENUM eLayout = m_pFormNode->GetEnum(XFA_ATTRIBUTE_Layout); | |
226 FX_BOOL bCalculateMargin = TRUE; | |
227 if (eLayout == XFA_ATTRIBUTEENUM_Position) { | |
228 bCalculateMargin = FALSE; | |
229 } | |
230 while (fProposedSplitPos > XFA_LAYOUT_FLOAT_PERCISION) { | |
231 FX_BOOL bAppChange = FALSE; | |
232 if (!FindLayoutItemSplitPos(m_pLayoutItem, 0, fProposedSplitPos, bAppChange, | |
233 bCalculateMargin)) { | |
234 break; | |
235 } | |
236 } | |
237 return fProposedSplitPos; | |
238 } | |
239 void CXFA_ItemLayoutProcessor::SplitLayoutItem( | |
240 CXFA_ContentLayoutItem* pLayoutItem, | |
241 CXFA_ContentLayoutItem* pSecondParent, | |
242 FX_FLOAT fSplitPos) { | |
243 FX_FLOAT fCurTopMargin = 0, fCurBottomMargin = 0; | |
244 XFA_ATTRIBUTEENUM eLayout = m_pFormNode->GetEnum(XFA_ATTRIBUTE_Layout); | |
245 FX_BOOL bCalculateMargin = TRUE; | |
246 if (eLayout == XFA_ATTRIBUTEENUM_Position) { | |
247 bCalculateMargin = FALSE; | |
248 } | |
249 CXFA_Node* pMarginNode = | |
250 pLayoutItem->m_pFormNode->GetFirstChildByClass(XFA_ELEMENT_Margin); | |
251 if (pMarginNode && bCalculateMargin) { | |
252 fCurTopMargin = | |
253 pMarginNode->GetMeasure(XFA_ATTRIBUTE_TopInset).ToUnit(XFA_UNIT_Pt); | |
254 fCurBottomMargin = | |
255 pMarginNode->GetMeasure(XFA_ATTRIBUTE_BottomInset).ToUnit(XFA_UNIT_Pt); | |
256 } | |
257 CXFA_ContentLayoutItem* pSecondLayoutItem = NULL; | |
258 if (m_pCurChildPreprocessor && | |
259 m_pCurChildPreprocessor->m_pFormNode == pLayoutItem->m_pFormNode) { | |
260 pSecondLayoutItem = m_pCurChildPreprocessor->CreateContentLayoutItem( | |
261 pLayoutItem->m_pFormNode); | |
262 } else { | |
263 pSecondLayoutItem = CreateContentLayoutItem(pLayoutItem->m_pFormNode); | |
264 } | |
265 pSecondLayoutItem->m_sPos.x = pLayoutItem->m_sPos.x; | |
266 pSecondLayoutItem->m_sSize.x = pLayoutItem->m_sSize.x; | |
267 pSecondLayoutItem->m_sPos.y = 0; | |
268 pSecondLayoutItem->m_sSize.y = pLayoutItem->m_sSize.y - fSplitPos; | |
269 pLayoutItem->m_sSize.y -= pSecondLayoutItem->m_sSize.y; | |
270 if (pLayoutItem->m_pFirstChild) { | |
271 pSecondLayoutItem->m_sSize.y += fCurTopMargin; | |
272 } | |
273 if (pSecondParent) { | |
274 pSecondParent->AddChild(pSecondLayoutItem); | |
275 if (fCurTopMargin > 0 && pLayoutItem->m_pFirstChild) { | |
276 pSecondParent->m_sSize.y += fCurTopMargin; | |
277 CXFA_ContentLayoutItem* pParentItem = | |
278 (CXFA_ContentLayoutItem*)pSecondParent->m_pParent; | |
279 while (pParentItem) { | |
280 pParentItem->m_sSize.y += fCurTopMargin; | |
281 pParentItem = (CXFA_ContentLayoutItem*)pParentItem->m_pParent; | |
282 } | |
283 } | |
284 } else { | |
285 pSecondLayoutItem->m_pParent = pLayoutItem->m_pParent; | |
286 pSecondLayoutItem->m_pNextSibling = pLayoutItem->m_pNextSibling; | |
287 pLayoutItem->m_pNextSibling = pSecondLayoutItem; | |
288 } | |
289 CXFA_ContentLayoutItem* pChildren = | |
290 (CXFA_ContentLayoutItem*)pLayoutItem->m_pFirstChild; | |
291 pLayoutItem->m_pFirstChild = NULL; | |
292 FX_FLOAT lHeightForKeep = 0; | |
293 CFX_ArrayTemplate<CXFA_ContentLayoutItem*> keepLayoutItems; | |
294 FX_FLOAT fAddMarginHeight = 0; | |
295 for (CXFA_ContentLayoutItem *pChildItem = pChildren, *pChildNext = NULL; | |
296 pChildItem; pChildItem = pChildNext) { | |
297 pChildNext = (CXFA_ContentLayoutItem*)pChildItem->m_pNextSibling; | |
298 pChildItem->m_pNextSibling = NULL; | |
299 if (fSplitPos <= fCurTopMargin + pChildItem->m_sPos.y + fCurBottomMargin + | |
300 XFA_LAYOUT_FLOAT_PERCISION) { | |
301 if (!XFA_ExistContainerKeep(pChildItem->m_pFormNode, TRUE)) { | |
302 pChildItem->m_sPos.y -= fSplitPos - fCurBottomMargin; | |
303 pChildItem->m_sPos.y += lHeightForKeep; | |
304 pChildItem->m_sPos.y += fAddMarginHeight; | |
305 pSecondLayoutItem->AddChild(pChildItem); | |
306 } else { | |
307 if (lHeightForKeep < XFA_LAYOUT_FLOAT_PERCISION) { | |
308 for (int32_t iIndex = 0; iIndex < keepLayoutItems.GetSize(); | |
309 iIndex++) { | |
310 CXFA_ContentLayoutItem* pPreItem = keepLayoutItems[iIndex]; | |
311 pLayoutItem->RemoveChild(pPreItem); | |
312 pPreItem->m_sPos.y -= fSplitPos; | |
313 if (pPreItem->m_sPos.y < 0) { | |
314 pPreItem->m_sPos.y = 0; | |
315 } | |
316 if (pPreItem->m_sPos.y + pPreItem->m_sSize.y > lHeightForKeep) { | |
317 pPreItem->m_sPos.y = lHeightForKeep; | |
318 lHeightForKeep += pPreItem->m_sSize.y; | |
319 pSecondLayoutItem->m_sSize.y += pPreItem->m_sSize.y; | |
320 if (pSecondParent) { | |
321 pSecondParent->m_sSize.y += pPreItem->m_sSize.y; | |
322 } | |
323 } | |
324 pSecondLayoutItem->AddChild(pPreItem); | |
325 } | |
326 } | |
327 pChildItem->m_sPos.y -= fSplitPos; | |
328 pChildItem->m_sPos.y += lHeightForKeep; | |
329 pChildItem->m_sPos.y += fAddMarginHeight; | |
330 pSecondLayoutItem->AddChild(pChildItem); | |
331 } | |
332 } else if (fSplitPos + XFA_LAYOUT_FLOAT_PERCISION >= | |
333 fCurTopMargin + fCurBottomMargin + pChildItem->m_sPos.y + | |
334 pChildItem->m_sSize.y) { | |
335 pLayoutItem->AddChild(pChildItem); | |
336 if (XFA_ExistContainerKeep(pChildItem->m_pFormNode, FALSE)) { | |
337 keepLayoutItems.Add(pChildItem); | |
338 } else { | |
339 keepLayoutItems.RemoveAll(); | |
340 } | |
341 } else { | |
342 FX_FLOAT fOldHeight = pSecondLayoutItem->m_sSize.y; | |
343 SplitLayoutItem( | |
344 pChildItem, pSecondLayoutItem, | |
345 fSplitPos - fCurTopMargin - fCurBottomMargin - pChildItem->m_sPos.y); | |
346 fAddMarginHeight = pSecondLayoutItem->m_sSize.y - fOldHeight; | |
347 pLayoutItem->AddChild(pChildItem); | |
348 } | |
349 } | |
350 } | |
351 void CXFA_ItemLayoutProcessor::SplitLayoutItem(FX_FLOAT fSplitPos) { | |
352 ASSERT(m_pLayoutItem); | |
353 SplitLayoutItem(m_pLayoutItem, NULL, fSplitPos); | |
354 } | |
355 | |
356 IXFA_LayoutPage* CXFA_LayoutItem::GetPage() const { | |
357 for (CXFA_LayoutItem* pCurNode = const_cast<CXFA_LayoutItem*>(this); pCurNode; | |
358 pCurNode = pCurNode->m_pParent) { | |
359 if (pCurNode->m_pFormNode->GetClassID() == XFA_ELEMENT_PageArea) | |
360 return static_cast<CXFA_ContainerLayoutItem*>(pCurNode); | |
361 } | |
362 return nullptr; | |
363 } | |
364 | |
365 CXFA_Node* CXFA_LayoutItem::GetFormNode() const { | |
366 return m_pFormNode; | |
367 } | |
368 | |
369 void CXFA_LayoutItem::GetRect(CFX_RectF& rtLayout, FX_BOOL bRelative) const { | |
370 ASSERT(m_bIsContentLayoutItem); | |
371 const CXFA_ContentLayoutItem* pThis = | |
372 static_cast<const CXFA_ContentLayoutItem*>(this); | |
373 CFX_PointF sPos = pThis->m_sPos; | |
374 CFX_SizeF sSize = pThis->m_sSize; | |
375 if (!bRelative) { | |
376 for (CXFA_LayoutItem* pLayoutItem = pThis->m_pParent; pLayoutItem; | |
377 pLayoutItem = pLayoutItem->m_pParent) { | |
378 if (CXFA_ContentLayoutItem* pContent = | |
379 pLayoutItem->AsContentLayoutItem()) { | |
380 sPos += pContent->m_sPos; | |
381 if (CXFA_Node* pMarginNode = | |
382 pLayoutItem->m_pFormNode->GetFirstChildByClass( | |
383 XFA_ELEMENT_Margin)) { | |
384 sPos += CFX_PointF(pMarginNode->GetMeasure(XFA_ATTRIBUTE_LeftInset) | |
385 .ToUnit(XFA_UNIT_Pt), | |
386 pMarginNode->GetMeasure(XFA_ATTRIBUTE_TopInset) | |
387 .ToUnit(XFA_UNIT_Pt)); | |
388 } | |
389 } else { | |
390 if (pLayoutItem->m_pFormNode->GetClassID() == XFA_ELEMENT_ContentArea) { | |
391 sPos += | |
392 CFX_PointF(pLayoutItem->m_pFormNode->GetMeasure(XFA_ATTRIBUTE_X) | |
393 .ToUnit(XFA_UNIT_Pt), | |
394 pLayoutItem->m_pFormNode->GetMeasure(XFA_ATTRIBUTE_Y) | |
395 .ToUnit(XFA_UNIT_Pt)); | |
396 break; | |
397 } else if (pLayoutItem->m_pFormNode->GetClassID() == | |
398 XFA_ELEMENT_PageArea) { | |
399 break; | |
400 } | |
401 } | |
402 } | |
403 } | |
404 rtLayout.Set(sPos.x, sPos.y, sSize.x, sSize.y); | |
405 } | |
406 | |
407 CXFA_LayoutItem* CXFA_LayoutItem::GetParent() const { | |
408 return m_pParent; | |
409 } | |
410 | |
411 const CXFA_LayoutItem* CXFA_LayoutItem::GetFirst() const { | |
412 ASSERT(m_bIsContentLayoutItem); | |
413 const CXFA_ContentLayoutItem* pCurNode = | |
414 static_cast<const CXFA_ContentLayoutItem*>(this); | |
415 while (pCurNode->m_pPrev) { | |
416 pCurNode = pCurNode->m_pPrev; | |
417 } | |
418 return pCurNode; | |
419 } | |
420 | |
421 CXFA_LayoutItem* CXFA_LayoutItem::GetFirst() { | |
422 ASSERT(m_bIsContentLayoutItem); | |
423 CXFA_ContentLayoutItem* pCurNode = static_cast<CXFA_ContentLayoutItem*>(this); | |
424 while (pCurNode->m_pPrev) { | |
425 pCurNode = pCurNode->m_pPrev; | |
426 } | |
427 return pCurNode; | |
428 } | |
429 | |
430 CXFA_LayoutItem* CXFA_LayoutItem::GetLast() { | |
431 ASSERT(m_bIsContentLayoutItem); | |
432 CXFA_ContentLayoutItem* pCurNode = static_cast<CXFA_ContentLayoutItem*>(this); | |
433 while (pCurNode->m_pNext) { | |
434 pCurNode = pCurNode->m_pNext; | |
435 } | |
436 return pCurNode; | |
437 } | |
438 | |
439 const CXFA_LayoutItem* CXFA_LayoutItem::GetLast() const { | |
440 ASSERT(m_bIsContentLayoutItem); | |
441 const CXFA_ContentLayoutItem* pCurNode = | |
442 static_cast<const CXFA_ContentLayoutItem*>(this); | |
443 while (pCurNode->m_pNext) { | |
444 pCurNode = pCurNode->m_pNext; | |
445 } | |
446 return pCurNode; | |
447 } | |
448 | |
449 CXFA_LayoutItem* CXFA_LayoutItem::GetPrev() const { | |
450 ASSERT(m_bIsContentLayoutItem); | |
451 return static_cast<const CXFA_ContentLayoutItem*>(this)->m_pPrev; | |
452 } | |
453 | |
454 CXFA_LayoutItem* CXFA_LayoutItem::GetNext() const { | |
455 ASSERT(m_bIsContentLayoutItem); | |
456 return static_cast<const CXFA_ContentLayoutItem*>(this)->m_pNext; | |
457 } | |
458 | |
459 int32_t CXFA_LayoutItem::GetIndex() const { | |
460 ASSERT(m_bIsContentLayoutItem); | |
461 int32_t iIndex = 0; | |
462 const CXFA_ContentLayoutItem* pCurNode = | |
463 static_cast<const CXFA_ContentLayoutItem*>(this); | |
464 while (pCurNode->m_pPrev) { | |
465 pCurNode = pCurNode->m_pPrev; | |
466 ++iIndex; | |
467 } | |
468 return iIndex; | |
469 } | |
470 | |
471 int32_t CXFA_LayoutItem::GetCount() const { | |
472 ASSERT(m_bIsContentLayoutItem); | |
473 int32_t iCount = GetIndex() + 1; | |
474 const CXFA_ContentLayoutItem* pCurNode = | |
475 static_cast<const CXFA_ContentLayoutItem*>(this); | |
476 while (pCurNode->m_pNext) { | |
477 pCurNode = pCurNode->m_pNext; | |
478 iCount++; | |
479 } | |
480 return iCount; | |
481 } | |
482 | |
483 void CXFA_LayoutItem::AddChild(CXFA_LayoutItem* pChildItem) { | |
484 if (pChildItem->m_pParent) { | |
485 pChildItem->m_pParent->RemoveChild(pChildItem); | |
486 } | |
487 pChildItem->m_pParent = this; | |
488 if (m_pFirstChild == NULL) { | |
489 m_pFirstChild = pChildItem; | |
490 } else { | |
491 CXFA_LayoutItem* pExistingChildItem = m_pFirstChild; | |
492 while (pExistingChildItem->m_pNextSibling) { | |
493 pExistingChildItem = pExistingChildItem->m_pNextSibling; | |
494 } | |
495 pExistingChildItem->m_pNextSibling = pChildItem; | |
496 } | |
497 } | |
498 void CXFA_LayoutItem::AddHeadChild(CXFA_LayoutItem* pChildItem) { | |
499 if (pChildItem->m_pParent) { | |
500 pChildItem->m_pParent->RemoveChild(pChildItem); | |
501 } | |
502 pChildItem->m_pParent = this; | |
503 if (m_pFirstChild == NULL) { | |
504 m_pFirstChild = pChildItem; | |
505 } else { | |
506 CXFA_LayoutItem* pExistingChildItem = m_pFirstChild; | |
507 m_pFirstChild = pChildItem; | |
508 m_pFirstChild->m_pNextSibling = pExistingChildItem; | |
509 } | |
510 } | |
511 void CXFA_LayoutItem::InsertChild(CXFA_LayoutItem* pBeforeItem, | |
512 CXFA_LayoutItem* pChildItem) { | |
513 if (pBeforeItem->m_pParent != this) { | |
514 return; | |
515 } | |
516 if (pChildItem->m_pParent) { | |
517 pChildItem->m_pParent = NULL; | |
518 } | |
519 pChildItem->m_pParent = this; | |
520 CXFA_LayoutItem* pExistingChildItem = pBeforeItem->m_pNextSibling; | |
521 pBeforeItem->m_pNextSibling = pChildItem; | |
522 pChildItem->m_pNextSibling = pExistingChildItem; | |
523 } | |
524 void CXFA_LayoutItem::RemoveChild(CXFA_LayoutItem* pChildItem) { | |
525 if (pChildItem->m_pParent != this) { | |
526 return; | |
527 } | |
528 if (m_pFirstChild == pChildItem) { | |
529 m_pFirstChild = pChildItem->m_pNextSibling; | |
530 } else { | |
531 CXFA_LayoutItem* pExistingChildItem = m_pFirstChild; | |
532 while (pExistingChildItem && | |
533 pExistingChildItem->m_pNextSibling != pChildItem) { | |
534 pExistingChildItem = pExistingChildItem->m_pNextSibling; | |
535 } | |
536 if (pExistingChildItem) { | |
537 pExistingChildItem->m_pNextSibling = pChildItem->m_pNextSibling; | |
538 } | |
539 } | |
540 pChildItem->m_pNextSibling = NULL; | |
541 pChildItem->m_pParent = NULL; | |
542 } | |
543 CXFA_ContentLayoutItem* CXFA_ItemLayoutProcessor::ExtractLayoutItem() { | |
544 CXFA_ContentLayoutItem* pLayoutItem = m_pLayoutItem; | |
545 if (pLayoutItem) { | |
546 m_pLayoutItem = (CXFA_ContentLayoutItem*)pLayoutItem->m_pNextSibling; | |
547 pLayoutItem->m_pNextSibling = NULL; | |
548 } | |
549 if (m_nCurChildNodeStage == XFA_ItemLayoutProcessorStages_Done && | |
550 ToContentLayoutItem(m_pOldLayoutItem)) { | |
551 if (m_pOldLayoutItem->m_pPrev) { | |
552 m_pOldLayoutItem->m_pPrev->m_pNext = NULL; | |
553 } | |
554 IXFA_Notify* pNotify = | |
555 m_pOldLayoutItem->m_pFormNode->GetDocument()->GetParser()->GetNotify(); | |
556 IXFA_DocLayout* pDocLayout = | |
557 m_pOldLayoutItem->m_pFormNode->GetDocument()->GetDocLayout(); | |
558 CXFA_ContentLayoutItem* pOldLayoutItem = m_pOldLayoutItem; | |
559 while (pOldLayoutItem) { | |
560 CXFA_ContentLayoutItem* pNextOldLayoutItem = pOldLayoutItem->m_pNext; | |
561 pNotify->OnLayoutEvent(pDocLayout, pOldLayoutItem, | |
562 XFA_LAYOUTEVENT_ItemRemoving); | |
563 delete pOldLayoutItem; | |
564 pOldLayoutItem = pNextOldLayoutItem; | |
565 } | |
566 m_pOldLayoutItem = NULL; | |
567 } | |
568 return pLayoutItem; | |
569 } | |
570 static FX_BOOL XFA_ItemLayoutProcessor_FindBreakNode( | |
571 CXFA_Node* pContainerNode, | |
572 CXFA_Node*& pCurActionNode, | |
573 XFA_ItemLayoutProcessorStages& nCurStage, | |
574 FX_BOOL bBreakBefore) { | |
575 FX_BOOL bFindRs = FALSE; | |
576 for (CXFA_Node* pBreakNode = pContainerNode; pBreakNode; | |
577 pBreakNode = pBreakNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { | |
578 XFA_ATTRIBUTE eAttributeType = XFA_ATTRIBUTE_Before; | |
579 if (!bBreakBefore) { | |
580 eAttributeType = XFA_ATTRIBUTE_After; | |
581 } | |
582 switch (pBreakNode->GetClassID()) { | |
583 case XFA_ELEMENT_BreakBefore: { | |
584 if (bBreakBefore) { | |
585 pCurActionNode = pBreakNode; | |
586 nCurStage = XFA_ItemLayoutProcessorStages_BreakBefore; | |
587 bFindRs = TRUE; | |
588 } | |
589 } break; | |
590 case XFA_ELEMENT_BreakAfter: { | |
591 if (!bBreakBefore) { | |
592 pCurActionNode = pBreakNode; | |
593 nCurStage = XFA_ItemLayoutProcessorStages_BreakAfter; | |
594 bFindRs = TRUE; | |
595 } | |
596 } break; | |
597 case XFA_ELEMENT_Break: | |
598 if (pBreakNode->GetEnum(eAttributeType) != XFA_ATTRIBUTEENUM_Auto) { | |
599 pCurActionNode = pBreakNode; | |
600 nCurStage = XFA_ItemLayoutProcessorStages_BreakBefore; | |
601 if (!bBreakBefore) { | |
602 nCurStage = XFA_ItemLayoutProcessorStages_BreakAfter; | |
603 } | |
604 bFindRs = TRUE; | |
605 break; | |
606 } | |
607 default: | |
608 break; | |
609 } | |
610 if (bFindRs) { | |
611 break; | |
612 } | |
613 } | |
614 return bFindRs; | |
615 } | |
616 static void XFA_DeleteLayoutGeneratedNode(CXFA_Node* pGenerateNode) { | |
617 IXFA_Notify* pNotify = pGenerateNode->GetDocument()->GetParser()->GetNotify(); | |
618 IXFA_DocLayout* pDocLayout = pGenerateNode->GetDocument()->GetDocLayout(); | |
619 CXFA_NodeIteratorTemplate<CXFA_Node, CXFA_TraverseStrategy_XFANode> sIterator( | |
620 pGenerateNode); | |
621 for (CXFA_Node* pNode = sIterator.GetCurrent(); pNode; | |
622 pNode = sIterator.MoveToNext()) { | |
623 CXFA_ContentLayoutItem* pCurLayoutItem = | |
624 (CXFA_ContentLayoutItem*)pNode->GetUserData(XFA_LAYOUTITEMKEY); | |
625 CXFA_ContentLayoutItem* pNextLayoutItem = NULL; | |
626 while (pCurLayoutItem) { | |
627 pNextLayoutItem = pCurLayoutItem->m_pNext; | |
628 pNotify->OnLayoutEvent(pDocLayout, pCurLayoutItem, | |
629 XFA_LAYOUTEVENT_ItemRemoving); | |
630 delete pCurLayoutItem; | |
631 pCurLayoutItem = pNextLayoutItem; | |
632 } | |
633 } | |
634 pGenerateNode->GetNodeItem(XFA_NODEITEM_Parent)->RemoveChild(pGenerateNode); | |
635 } | |
636 void CXFA_ItemLayoutProcessor::XFA_ItemLayoutProcessor_GotoNextContainerNode( | |
637 CXFA_Node*& pCurActionNode, | |
638 XFA_ItemLayoutProcessorStages& nCurStage, | |
639 CXFA_Node* pParentContainer, | |
640 FX_BOOL bUsePageBreak) { | |
641 CXFA_Node* pEntireContainer = pParentContainer; | |
642 CXFA_Node* pChildContainer = XFA_LAYOUT_INVALIDNODE; | |
643 switch (nCurStage) { | |
644 case XFA_ItemLayoutProcessorStages_BreakBefore: | |
645 case XFA_ItemLayoutProcessorStages_BreakAfter: { | |
646 pChildContainer = pCurActionNode->GetNodeItem(XFA_NODEITEM_Parent); | |
647 } break; | |
648 case XFA_ItemLayoutProcessorStages_Keep: | |
649 case XFA_ItemLayoutProcessorStages_Container: | |
650 pChildContainer = pCurActionNode; | |
651 break; | |
652 default: | |
653 pChildContainer = XFA_LAYOUT_INVALIDNODE; | |
654 break; | |
655 } | |
656 switch (nCurStage) { | |
657 case XFA_ItemLayoutProcessorStages_Keep: { | |
658 CXFA_Node* pBreakAfterNode = | |
659 pChildContainer->GetNodeItem(XFA_NODEITEM_FirstChild); | |
660 if (!m_bKeepBreakFinish && | |
661 XFA_ItemLayoutProcessor_FindBreakNode(pBreakAfterNode, pCurActionNode, | |
662 nCurStage, FALSE)) { | |
663 return; | |
664 } | |
665 goto CheckNextChildContainer; | |
666 } | |
667 case XFA_ItemLayoutProcessorStages_None: { | |
668 pCurActionNode = XFA_LAYOUT_INVALIDNODE; | |
669 case XFA_ItemLayoutProcessorStages_BookendLeader: | |
670 for (CXFA_Node* pBookendNode = | |
671 pCurActionNode == XFA_LAYOUT_INVALIDNODE | |
672 ? pEntireContainer->GetNodeItem(XFA_NODEITEM_FirstChild) | |
673 : pCurActionNode->GetNodeItem(XFA_NODEITEM_NextSibling); | |
674 pBookendNode; pBookendNode = pBookendNode->GetNodeItem( | |
675 XFA_NODEITEM_NextSibling)) { | |
676 switch (pBookendNode->GetClassID()) { | |
677 case XFA_ELEMENT_Bookend: | |
678 case XFA_ELEMENT_Break: | |
679 pCurActionNode = pBookendNode; | |
680 nCurStage = XFA_ItemLayoutProcessorStages_BookendLeader; | |
681 return; | |
682 default: | |
683 break; | |
684 } | |
685 } | |
686 } | |
687 { | |
688 pCurActionNode = XFA_LAYOUT_INVALIDNODE; | |
689 case XFA_ItemLayoutProcessorStages_BreakBefore: | |
690 if (pCurActionNode != XFA_LAYOUT_INVALIDNODE) { | |
691 CXFA_Node* pBreakBeforeNode = | |
692 pCurActionNode->GetNodeItem(XFA_NODEITEM_NextSibling); | |
693 if (!m_bKeepBreakFinish && | |
694 XFA_ItemLayoutProcessor_FindBreakNode( | |
695 pBreakBeforeNode, pCurActionNode, nCurStage, TRUE)) { | |
696 return; | |
697 } | |
698 if (m_bIsProcessKeep) { | |
699 if (ProcessKeepNodesForBreakBefore(pCurActionNode, nCurStage, | |
700 pChildContainer)) { | |
701 return; | |
702 } | |
703 goto CheckNextChildContainer; | |
704 } | |
705 pCurActionNode = pChildContainer; | |
706 nCurStage = XFA_ItemLayoutProcessorStages_Container; | |
707 return; | |
708 } | |
709 goto CheckNextChildContainer; | |
710 } | |
711 case XFA_ItemLayoutProcessorStages_Container: { | |
712 pCurActionNode = XFA_LAYOUT_INVALIDNODE; | |
713 case XFA_ItemLayoutProcessorStages_BreakAfter: { | |
714 if (pCurActionNode == XFA_LAYOUT_INVALIDNODE) { | |
715 CXFA_Node* pBreakAfterNode = | |
716 pChildContainer->GetNodeItem(XFA_NODEITEM_FirstChild); | |
717 if (!m_bKeepBreakFinish && | |
718 XFA_ItemLayoutProcessor_FindBreakNode( | |
719 pBreakAfterNode, pCurActionNode, nCurStage, FALSE)) { | |
720 return; | |
721 } | |
722 } else { | |
723 CXFA_Node* pBreakAfterNode = | |
724 pCurActionNode->GetNodeItem(XFA_NODEITEM_NextSibling); | |
725 if (XFA_ItemLayoutProcessor_FindBreakNode( | |
726 pBreakAfterNode, pCurActionNode, nCurStage, FALSE)) { | |
727 return; | |
728 } | |
729 } | |
730 goto CheckNextChildContainer; | |
731 } | |
732 } | |
733 CheckNextChildContainer : { | |
734 CXFA_Node* pNextChildContainer = | |
735 pChildContainer == XFA_LAYOUT_INVALIDNODE | |
736 ? pEntireContainer->GetNodeItem(XFA_NODEITEM_FirstChild, | |
737 XFA_OBJECTTYPE_ContainerNode) | |
738 : pChildContainer->GetNodeItem(XFA_NODEITEM_NextSibling, | |
739 XFA_OBJECTTYPE_ContainerNode); | |
740 while (pNextChildContainer && | |
741 pNextChildContainer->HasFlag(XFA_NODEFLAG_LayoutGeneratedNode)) { | |
742 CXFA_Node* pSaveNode = pNextChildContainer; | |
743 pNextChildContainer = pNextChildContainer->GetNodeItem( | |
744 XFA_NODEITEM_NextSibling, XFA_OBJECTTYPE_ContainerNode); | |
745 if (pSaveNode->HasFlag(XFA_NODEFLAG_UnusedNode)) { | |
746 XFA_DeleteLayoutGeneratedNode(pSaveNode); | |
747 } | |
748 } | |
749 if (!pNextChildContainer) { | |
750 goto NoMoreChildContainer; | |
751 } | |
752 FX_BOOL bLastKeep = FALSE; | |
753 if (ProcessKeepNodesForCheckNext(pCurActionNode, nCurStage, | |
754 pNextChildContainer, bLastKeep)) { | |
755 return; | |
756 } | |
757 if (!m_bKeepBreakFinish && !bLastKeep && | |
758 XFA_ItemLayoutProcessor_FindBreakNode( | |
759 pNextChildContainer->GetNodeItem(XFA_NODEITEM_FirstChild), | |
760 pCurActionNode, nCurStage, TRUE)) { | |
761 return; | |
762 } | |
763 pCurActionNode = pNextChildContainer; | |
764 if (m_bIsProcessKeep) { | |
765 nCurStage = XFA_ItemLayoutProcessorStages_Keep; | |
766 } else { | |
767 nCurStage = XFA_ItemLayoutProcessorStages_Container; | |
768 } | |
769 return; | |
770 } | |
771 NoMoreChildContainer : { | |
772 pCurActionNode = XFA_LAYOUT_INVALIDNODE; | |
773 case XFA_ItemLayoutProcessorStages_BookendTrailer: | |
774 for (CXFA_Node* pBookendNode = | |
775 pCurActionNode == XFA_LAYOUT_INVALIDNODE | |
776 ? pEntireContainer->GetNodeItem(XFA_NODEITEM_FirstChild) | |
777 : pCurActionNode->GetNodeItem(XFA_NODEITEM_NextSibling); | |
778 pBookendNode; pBookendNode = pBookendNode->GetNodeItem( | |
779 XFA_NODEITEM_NextSibling)) { | |
780 switch (pBookendNode->GetClassID()) { | |
781 case XFA_ELEMENT_Bookend: | |
782 case XFA_ELEMENT_Break: | |
783 pCurActionNode = pBookendNode; | |
784 nCurStage = XFA_ItemLayoutProcessorStages_BookendTrailer; | |
785 return; | |
786 default: | |
787 break; | |
788 } | |
789 } | |
790 } | |
791 default: | |
792 pCurActionNode = NULL; | |
793 nCurStage = XFA_ItemLayoutProcessorStages_Done; | |
794 } | |
795 } | |
796 FX_BOOL CXFA_ItemLayoutProcessor::ProcessKeepNodesForCheckNext( | |
797 CXFA_Node*& pCurActionNode, | |
798 XFA_ItemLayoutProcessorStages& nCurStage, | |
799 CXFA_Node*& pNextContainer, | |
800 FX_BOOL& bLastKeepNode) { | |
801 const bool bCanSplit = pNextContainer->GetIntact() == XFA_ATTRIBUTEENUM_None; | |
802 FX_BOOL bNextKeep = FALSE; | |
803 if (XFA_ExistContainerKeep(pNextContainer, FALSE)) { | |
804 bNextKeep = TRUE; | |
805 } | |
806 if (bNextKeep && !bCanSplit) { | |
807 if (!m_bIsProcessKeep && !m_bKeepBreakFinish) { | |
808 m_pKeepHeadNode = pNextContainer; | |
809 m_bIsProcessKeep = TRUE; | |
810 } | |
811 } else { | |
812 if (m_bIsProcessKeep && m_pKeepHeadNode) { | |
813 m_pKeepTailNode = pNextContainer; | |
814 if (!m_bKeepBreakFinish && | |
815 XFA_ItemLayoutProcessor_FindBreakNode( | |
816 pNextContainer->GetNodeItem(XFA_NODEITEM_FirstChild), | |
817 pCurActionNode, nCurStage, TRUE)) { | |
818 return TRUE; | |
819 } else { | |
820 pNextContainer = m_pKeepHeadNode; | |
821 m_bKeepBreakFinish = TRUE; | |
822 m_pKeepHeadNode = NULL; | |
823 m_pKeepTailNode = NULL; | |
824 m_bIsProcessKeep = FALSE; | |
825 } | |
826 } else { | |
827 if (m_bKeepBreakFinish) { | |
828 bLastKeepNode = TRUE; | |
829 } | |
830 m_bKeepBreakFinish = FALSE; | |
831 } | |
832 } | |
833 return FALSE; | |
834 } | |
835 FX_BOOL CXFA_ItemLayoutProcessor::ProcessKeepNodesForBreakBefore( | |
836 CXFA_Node*& pCurActionNode, | |
837 XFA_ItemLayoutProcessorStages& nCurStage, | |
838 CXFA_Node* pContainerNode) { | |
839 if (m_pKeepTailNode == pContainerNode) { | |
840 pCurActionNode = m_pKeepHeadNode; | |
841 m_bKeepBreakFinish = TRUE; | |
842 m_pKeepHeadNode = NULL; | |
843 m_pKeepTailNode = NULL; | |
844 m_bIsProcessKeep = FALSE; | |
845 nCurStage = XFA_ItemLayoutProcessorStages_Container; | |
846 return TRUE; | |
847 } | |
848 CXFA_Node* pBreakAfterNode = | |
849 pContainerNode->GetNodeItem(XFA_NODEITEM_FirstChild); | |
850 if (XFA_ItemLayoutProcessor_FindBreakNode(pBreakAfterNode, pCurActionNode, | |
851 nCurStage, FALSE)) { | |
852 return TRUE; | |
853 } | |
854 return FALSE; | |
855 } | |
856 FX_BOOL XFA_ItemLayoutProcessor_IsTakingSpace(CXFA_Node* pNode) { | |
857 XFA_ATTRIBUTEENUM ePresence = pNode->GetEnum(XFA_ATTRIBUTE_Presence); | |
858 return ePresence == XFA_ATTRIBUTEENUM_Visible || | |
859 ePresence == XFA_ATTRIBUTEENUM_Invisible; | |
860 } | |
861 static inline void XFA_ItemLayoutProcessor_CalculateContainerSpecfiedSize( | |
862 CXFA_Node* pFormNode, | |
863 FX_FLOAT& fContainerWidth, | |
864 FX_FLOAT& fContainerHeight, | |
865 FX_BOOL& bContainerWidthAutoSize, | |
866 FX_BOOL& bContainerHeightAutoSize) { | |
867 fContainerWidth = 0; | |
868 fContainerHeight = 0; | |
869 bContainerWidthAutoSize = TRUE; | |
870 bContainerHeightAutoSize = TRUE; | |
871 XFA_ELEMENT eClassID = pFormNode->GetClassID(); | |
872 CXFA_Measurement mTmpValue; | |
873 if (bContainerWidthAutoSize && | |
874 (eClassID == XFA_ELEMENT_Subform || eClassID == XFA_ELEMENT_ExclGroup) && | |
875 pFormNode->TryMeasure(XFA_ATTRIBUTE_W, mTmpValue, FALSE) && | |
876 mTmpValue.GetValue() > XFA_LAYOUT_FLOAT_PERCISION) { | |
877 fContainerWidth = mTmpValue.ToUnit(XFA_UNIT_Pt); | |
878 bContainerWidthAutoSize = FALSE; | |
879 } | |
880 if (bContainerHeightAutoSize && | |
881 (eClassID == XFA_ELEMENT_Subform || eClassID == XFA_ELEMENT_ExclGroup) && | |
882 pFormNode->TryMeasure(XFA_ATTRIBUTE_H, mTmpValue, FALSE) && | |
883 mTmpValue.GetValue() > XFA_LAYOUT_FLOAT_PERCISION) { | |
884 fContainerHeight = mTmpValue.ToUnit(XFA_UNIT_Pt); | |
885 bContainerHeightAutoSize = FALSE; | |
886 } | |
887 if (bContainerWidthAutoSize && eClassID == XFA_ELEMENT_Subform && | |
888 pFormNode->TryMeasure(XFA_ATTRIBUTE_MaxW, mTmpValue, FALSE) && | |
889 mTmpValue.GetValue() > XFA_LAYOUT_FLOAT_PERCISION) { | |
890 fContainerWidth = mTmpValue.ToUnit(XFA_UNIT_Pt); | |
891 bContainerWidthAutoSize = FALSE; | |
892 } | |
893 if (bContainerHeightAutoSize && eClassID == XFA_ELEMENT_Subform && | |
894 pFormNode->TryMeasure(XFA_ATTRIBUTE_MaxH, mTmpValue, FALSE) && | |
895 mTmpValue.GetValue() > XFA_LAYOUT_FLOAT_PERCISION) { | |
896 fContainerHeight = mTmpValue.ToUnit(XFA_UNIT_Pt); | |
897 bContainerHeightAutoSize = FALSE; | |
898 } | |
899 } | |
900 static inline void | |
901 XFA_ItemLayoutProcessor_CalculateContainerComponentSizeFromContentSize( | |
902 CXFA_Node* pFormNode, | |
903 FX_BOOL bContainerWidthAutoSize, | |
904 FX_FLOAT fContentCalculatedWidth, | |
905 FX_FLOAT& fContainerWidth, | |
906 FX_BOOL bContainerHeightAutoSize, | |
907 FX_FLOAT fContentCalculatedHeight, | |
908 FX_FLOAT& fContainerHeight) { | |
909 CXFA_Node* pMarginNode = pFormNode->GetFirstChildByClass(XFA_ELEMENT_Margin); | |
910 CXFA_Measurement mTmpValue; | |
911 if (bContainerWidthAutoSize) { | |
912 fContainerWidth = fContentCalculatedWidth; | |
913 if (pMarginNode) { | |
914 if (pMarginNode->TryMeasure(XFA_ATTRIBUTE_LeftInset, mTmpValue, FALSE)) { | |
915 fContainerWidth += mTmpValue.ToUnit(XFA_UNIT_Pt); | |
916 } | |
917 if (pMarginNode->TryMeasure(XFA_ATTRIBUTE_RightInset, mTmpValue, FALSE)) { | |
918 fContainerWidth += mTmpValue.ToUnit(XFA_UNIT_Pt); | |
919 } | |
920 } | |
921 } | |
922 if (bContainerHeightAutoSize) { | |
923 fContainerHeight = fContentCalculatedHeight; | |
924 if (pMarginNode) { | |
925 if (pMarginNode->TryMeasure(XFA_ATTRIBUTE_TopInset, mTmpValue, FALSE)) { | |
926 fContainerHeight += mTmpValue.ToUnit(XFA_UNIT_Pt); | |
927 } | |
928 if (pMarginNode->TryMeasure(XFA_ATTRIBUTE_BottomInset, mTmpValue, | |
929 FALSE)) { | |
930 fContainerHeight += mTmpValue.ToUnit(XFA_UNIT_Pt); | |
931 } | |
932 } | |
933 } | |
934 } | |
935 void CXFA_ItemLayoutProcessor::CalculatePositionedContainerPos( | |
936 CXFA_Node* pNode, | |
937 FX_FLOAT fWidth, | |
938 FX_FLOAT fHeight, | |
939 FX_FLOAT& fAbsoluteX, | |
940 FX_FLOAT& fAbsoluteY) { | |
941 XFA_ATTRIBUTEENUM eAnchorType = pNode->GetEnum(XFA_ATTRIBUTE_AnchorType); | |
942 int32_t nAnchorType = 0; | |
943 switch (eAnchorType) { | |
944 case XFA_ATTRIBUTEENUM_TopLeft: | |
945 nAnchorType = 0; | |
946 break; | |
947 case XFA_ATTRIBUTEENUM_TopCenter: | |
948 nAnchorType = 1; | |
949 break; | |
950 case XFA_ATTRIBUTEENUM_TopRight: | |
951 nAnchorType = 2; | |
952 break; | |
953 case XFA_ATTRIBUTEENUM_MiddleLeft: | |
954 nAnchorType = 3; | |
955 break; | |
956 case XFA_ATTRIBUTEENUM_MiddleCenter: | |
957 nAnchorType = 4; | |
958 break; | |
959 case XFA_ATTRIBUTEENUM_MiddleRight: | |
960 nAnchorType = 5; | |
961 break; | |
962 case XFA_ATTRIBUTEENUM_BottomLeft: | |
963 nAnchorType = 6; | |
964 break; | |
965 case XFA_ATTRIBUTEENUM_BottomCenter: | |
966 nAnchorType = 7; | |
967 break; | |
968 case XFA_ATTRIBUTEENUM_BottomRight: | |
969 nAnchorType = 8; | |
970 break; | |
971 default: | |
972 break; | |
973 } | |
974 static const uint8_t nNextPos[4][9] = {{0, 1, 2, 3, 4, 5, 6, 7, 8}, | |
975 {6, 3, 0, 7, 4, 1, 8, 5, 2}, | |
976 {8, 7, 6, 5, 4, 3, 2, 1, 0}, | |
977 {2, 5, 8, 1, 4, 7, 0, 3, 6}}; | |
978 | |
979 FX_FLOAT fAnchorX = pNode->GetMeasure(XFA_ATTRIBUTE_X).ToUnit(XFA_UNIT_Pt); | |
980 FX_FLOAT fAnchorY = pNode->GetMeasure(XFA_ATTRIBUTE_Y).ToUnit(XFA_UNIT_Pt); | |
981 int32_t nRotate = | |
982 FXSYS_round(pNode->GetMeasure(XFA_ATTRIBUTE_Rotate).GetValue()); | |
983 nRotate = XFA_MapRotation(nRotate) / 90; | |
984 int32_t nAbsoluteAnchorType = nNextPos[nRotate][nAnchorType]; | |
985 fAbsoluteX = fAnchorX; | |
986 fAbsoluteY = fAnchorY; | |
987 switch (nAbsoluteAnchorType / 3) { | |
988 case 1: | |
989 fAbsoluteY -= fHeight / 2; | |
990 break; | |
991 case 2: | |
992 fAbsoluteY -= fHeight; | |
993 break; | |
994 default: | |
995 break; | |
996 } | |
997 switch (nAbsoluteAnchorType % 3) { | |
998 case 1: | |
999 fAbsoluteX -= fWidth / 2; | |
1000 break; | |
1001 case 2: | |
1002 fAbsoluteX -= fWidth; | |
1003 break; | |
1004 default: | |
1005 break; | |
1006 } | |
1007 } | |
1008 FX_BOOL CXFA_ItemLayoutProcessor::IncrementRelayoutNode( | |
1009 CXFA_LayoutProcessor* pLayoutProcessor, | |
1010 CXFA_Node* pNode, | |
1011 CXFA_Node* pParentNode) { | |
1012 return FALSE; | |
1013 } | |
1014 void CXFA_ItemLayoutProcessor::DoLayoutPageArea( | |
1015 CXFA_ContainerLayoutItem* pPageAreaLayoutItem) { | |
1016 CXFA_Node* pFormNode = pPageAreaLayoutItem->m_pFormNode; | |
1017 CXFA_Node* pCurChildNode = XFA_LAYOUT_INVALIDNODE; | |
1018 XFA_ItemLayoutProcessorStages nCurChildNodeStage = | |
1019 XFA_ItemLayoutProcessorStages_None; | |
1020 CXFA_LayoutItem* pBeforeItem = NULL; | |
1021 for (XFA_ItemLayoutProcessor_GotoNextContainerNode( | |
1022 pCurChildNode, nCurChildNodeStage, pFormNode, FALSE); | |
1023 pCurChildNode; XFA_ItemLayoutProcessor_GotoNextContainerNode( | |
1024 pCurChildNode, nCurChildNodeStage, pFormNode, FALSE)) { | |
1025 if (nCurChildNodeStage != XFA_ItemLayoutProcessorStages_Container) { | |
1026 continue; | |
1027 } | |
1028 if (pCurChildNode->GetClassID() == XFA_ELEMENT_Variables) { | |
1029 continue; | |
1030 } | |
1031 CXFA_ItemLayoutProcessor* pProcessor = | |
1032 new CXFA_ItemLayoutProcessor(pCurChildNode, NULL); | |
1033 pProcessor->DoLayout(FALSE, XFA_LAYOUT_FLOAT_MAX); | |
1034 if (!pProcessor->HasLayoutItem()) { | |
1035 delete pProcessor; | |
1036 continue; | |
1037 } | |
1038 FX_FLOAT fWidth, fHeight; | |
1039 pProcessor->GetCurrentComponentSize(fWidth, fHeight); | |
1040 FX_FLOAT fAbsoluteX = 0, fAbsoluteY = 0; | |
1041 CalculatePositionedContainerPos(pCurChildNode, fWidth, fHeight, fAbsoluteX, | |
1042 fAbsoluteY); | |
1043 pProcessor->SetCurrentComponentPos(fAbsoluteX, fAbsoluteY); | |
1044 CXFA_LayoutItem* pProcessItem = pProcessor->ExtractLayoutItem(); | |
1045 if (pBeforeItem == NULL) { | |
1046 pPageAreaLayoutItem->AddHeadChild(pProcessItem); | |
1047 } else { | |
1048 pPageAreaLayoutItem->InsertChild(pBeforeItem, pProcessItem); | |
1049 } | |
1050 pBeforeItem = pProcessItem; | |
1051 delete pProcessor; | |
1052 } | |
1053 pBeforeItem = NULL; | |
1054 CXFA_LayoutItem* pLayoutItem = pPageAreaLayoutItem->m_pFirstChild; | |
1055 while (pLayoutItem) { | |
1056 if (!pLayoutItem->IsContentLayoutItem() || | |
1057 pLayoutItem->m_pFormNode->GetClassID() != XFA_ELEMENT_Draw) { | |
1058 pLayoutItem = pLayoutItem->m_pNextSibling; | |
1059 continue; | |
1060 } | |
1061 if (pLayoutItem->m_pFormNode->GetClassID() == XFA_ELEMENT_Draw) { | |
1062 CXFA_LayoutItem* pNextLayoutItem = pLayoutItem->m_pNextSibling; | |
1063 pPageAreaLayoutItem->RemoveChild(pLayoutItem); | |
1064 if (pBeforeItem == NULL) { | |
1065 pPageAreaLayoutItem->AddHeadChild(pLayoutItem); | |
1066 } else { | |
1067 pPageAreaLayoutItem->InsertChild(pBeforeItem, pLayoutItem); | |
1068 } | |
1069 pBeforeItem = pLayoutItem; | |
1070 pLayoutItem = pNextLayoutItem; | |
1071 } | |
1072 } | |
1073 } | |
1074 void CXFA_ItemLayoutProcessor::DoLayoutPositionedContainer( | |
1075 CXFA_LayoutContext* pContext) { | |
1076 if (m_pLayoutItem) | |
1077 return; | |
1078 | |
1079 m_pLayoutItem = CreateContentLayoutItem(m_pFormNode); | |
1080 FX_BOOL bIgnoreXY = (m_pFormNode->GetEnum(XFA_ATTRIBUTE_Layout) != | |
1081 XFA_ATTRIBUTEENUM_Position); | |
1082 FX_FLOAT fContainerWidth = 0, fContainerHeight = 0; | |
1083 FX_BOOL bContainerWidthAutoSize = TRUE, bContainerHeightAutoSize = TRUE; | |
1084 XFA_ItemLayoutProcessor_CalculateContainerSpecfiedSize( | |
1085 m_pFormNode, fContainerWidth, fContainerHeight, bContainerWidthAutoSize, | |
1086 bContainerHeightAutoSize); | |
1087 FX_FLOAT fContentCalculatedWidth = 0, fContentCalculatedHeight = 0; | |
1088 FX_FLOAT fHiddenContentCalculatedWidth = 0, | |
1089 fHiddenContentCalculatedHeight = 0; | |
1090 if (m_pCurChildNode == XFA_LAYOUT_INVALIDNODE) { | |
1091 XFA_ItemLayoutProcessor_GotoNextContainerNode( | |
1092 m_pCurChildNode, m_nCurChildNodeStage, m_pFormNode, FALSE); | |
1093 } | |
1094 int32_t iColIndex = 0; | |
1095 for (; m_pCurChildNode; XFA_ItemLayoutProcessor_GotoNextContainerNode( | |
1096 m_pCurChildNode, m_nCurChildNodeStage, m_pFormNode, FALSE)) { | |
1097 if (m_nCurChildNodeStage != XFA_ItemLayoutProcessorStages_Container) { | |
1098 continue; | |
1099 } | |
1100 if (m_pCurChildNode->GetClassID() == XFA_ELEMENT_Variables) { | |
1101 continue; | |
1102 } | |
1103 CXFA_ItemLayoutProcessor* pProcessor = | |
1104 new CXFA_ItemLayoutProcessor(m_pCurChildNode, m_pPageMgr); | |
1105 if (pContext && pContext->m_prgSpecifiedColumnWidths) { | |
1106 int32_t iColSpan = m_pCurChildNode->GetInteger(XFA_ATTRIBUTE_ColSpan); | |
1107 if (iColSpan <= | |
1108 pContext->m_prgSpecifiedColumnWidths->GetSize() - iColIndex) { | |
1109 pContext->m_fCurColumnWidth = 0; | |
1110 pContext->m_bCurColumnWidthAvaiable = TRUE; | |
1111 if (iColSpan == -1) | |
1112 iColSpan = pContext->m_prgSpecifiedColumnWidths->GetSize(); | |
1113 for (int32_t i = 0; iColIndex + i < iColSpan; ++i) { | |
1114 pContext->m_fCurColumnWidth += | |
1115 pContext->m_prgSpecifiedColumnWidths->GetAt(iColIndex + i); | |
1116 } | |
1117 if (pContext->m_fCurColumnWidth == 0) | |
1118 pContext->m_bCurColumnWidthAvaiable = FALSE; | |
1119 iColIndex += iColSpan >= 0 ? iColSpan : 0; | |
1120 } | |
1121 } | |
1122 pProcessor->DoLayout(FALSE, XFA_LAYOUT_FLOAT_MAX, XFA_LAYOUT_FLOAT_MAX, | |
1123 pContext); | |
1124 if (!pProcessor->HasLayoutItem()) { | |
1125 delete pProcessor; | |
1126 continue; | |
1127 } | |
1128 FX_FLOAT fWidth, fHeight; | |
1129 pProcessor->GetCurrentComponentSize(fWidth, fHeight); | |
1130 FX_BOOL bChangeParentSize = FALSE; | |
1131 if (XFA_ItemLayoutProcessor_IsTakingSpace(m_pCurChildNode)) { | |
1132 bChangeParentSize = TRUE; | |
1133 } | |
1134 FX_FLOAT fAbsoluteX = 0, fAbsoluteY = 0; | |
1135 if (!bIgnoreXY) { | |
1136 CalculatePositionedContainerPos(m_pCurChildNode, fWidth, fHeight, | |
1137 fAbsoluteX, fAbsoluteY); | |
1138 } | |
1139 pProcessor->SetCurrentComponentPos(fAbsoluteX, fAbsoluteY); | |
1140 if (bContainerWidthAutoSize) { | |
1141 FX_FLOAT fChildSuppliedWidth = fAbsoluteX + fWidth; | |
1142 if (bChangeParentSize) { | |
1143 if (fContentCalculatedWidth < fChildSuppliedWidth) { | |
1144 fContentCalculatedWidth = fChildSuppliedWidth; | |
1145 } | |
1146 } else { | |
1147 if (fHiddenContentCalculatedWidth < fChildSuppliedWidth && | |
1148 m_pCurChildNode->GetClassID() != XFA_ELEMENT_Subform) { | |
1149 fHiddenContentCalculatedWidth = fChildSuppliedWidth; | |
1150 } | |
1151 } | |
1152 } | |
1153 if (bContainerHeightAutoSize) { | |
1154 FX_FLOAT fChildSuppliedHeight = fAbsoluteY + fHeight; | |
1155 if (bChangeParentSize) { | |
1156 if (fContentCalculatedHeight < fChildSuppliedHeight) { | |
1157 fContentCalculatedHeight = fChildSuppliedHeight; | |
1158 } | |
1159 } else { | |
1160 if (fHiddenContentCalculatedHeight < fChildSuppliedHeight && | |
1161 m_pCurChildNode->GetClassID() != XFA_ELEMENT_Subform) { | |
1162 fHiddenContentCalculatedHeight = fChildSuppliedHeight; | |
1163 } | |
1164 } | |
1165 } | |
1166 m_pLayoutItem->AddChild(pProcessor->ExtractLayoutItem()); | |
1167 delete pProcessor; | |
1168 } | |
1169 XFA_VERSION eVersion = m_pFormNode->GetDocument()->GetCurVersionMode(); | |
1170 if (fContentCalculatedWidth == 0 && eVersion < XFA_VERSION_207) { | |
1171 fContentCalculatedWidth = fHiddenContentCalculatedWidth; | |
1172 } | |
1173 if (fContentCalculatedHeight == 0 && eVersion < XFA_VERSION_207) { | |
1174 fContentCalculatedHeight = fHiddenContentCalculatedHeight; | |
1175 } | |
1176 XFA_ItemLayoutProcessor_CalculateContainerComponentSizeFromContentSize( | |
1177 m_pFormNode, bContainerWidthAutoSize, fContentCalculatedWidth, | |
1178 fContainerWidth, bContainerHeightAutoSize, fContentCalculatedHeight, | |
1179 fContainerHeight); | |
1180 SetCurrentComponentSize(fContainerWidth, fContainerHeight); | |
1181 } | |
1182 static inline void XFA_ItemLayoutProcessor_UpdateWidgetSize( | |
1183 CXFA_ContentLayoutItem* pLayoutItem, | |
1184 FX_FLOAT& fWidth, | |
1185 FX_FLOAT& fHeight) { | |
1186 CXFA_Node* pNode = pLayoutItem->m_pFormNode; | |
1187 ASSERT(pNode); | |
1188 XFA_ELEMENT eClassID = pNode->GetClassID(); | |
1189 switch (eClassID) { | |
1190 case XFA_ELEMENT_Subform: | |
1191 case XFA_ELEMENT_Area: | |
1192 case XFA_ELEMENT_ExclGroup: | |
1193 case XFA_ELEMENT_SubformSet: { | |
1194 if (fWidth < -XFA_LAYOUT_FLOAT_PERCISION) { | |
1195 fWidth = pLayoutItem->m_sSize.x; | |
1196 } | |
1197 if (fHeight < -XFA_LAYOUT_FLOAT_PERCISION) { | |
1198 fHeight = pLayoutItem->m_sSize.y; | |
1199 } | |
1200 break; | |
1201 } | |
1202 case XFA_ELEMENT_Draw: | |
1203 case XFA_ELEMENT_Field: { | |
1204 pNode->GetDocument()->GetParser()->GetNotify()->StartFieldDrawLayout( | |
1205 pNode, fWidth, fHeight); | |
1206 break; | |
1207 } | |
1208 default: | |
1209 ASSERT(FALSE); | |
1210 } | |
1211 } | |
1212 static inline void XFA_ItemLayoutProcessor_RelocateTableRowCells( | |
1213 CXFA_ContentLayoutItem* pLayoutRow, | |
1214 const CFX_ArrayTemplate<FX_FLOAT>& rgSpecifiedColumnWidths, | |
1215 XFA_ATTRIBUTEENUM eLayout) { | |
1216 FX_FLOAT fContainerWidth = 0, fContainerHeight = 0; | |
1217 FX_BOOL bContainerWidthAutoSize = TRUE, bContainerHeightAutoSize = TRUE; | |
1218 XFA_ItemLayoutProcessor_CalculateContainerSpecfiedSize( | |
1219 pLayoutRow->m_pFormNode, fContainerWidth, fContainerHeight, | |
1220 bContainerWidthAutoSize, bContainerHeightAutoSize); | |
1221 CXFA_Node* pMarginNode = | |
1222 pLayoutRow->m_pFormNode->GetFirstChildByClass(XFA_ELEMENT_Margin); | |
1223 FX_FLOAT fLeftInset = 0, fTopInset = 0, fRightInset = 0, fBottomInset = 0; | |
1224 if (pMarginNode) { | |
1225 fLeftInset = | |
1226 pMarginNode->GetMeasure(XFA_ATTRIBUTE_LeftInset).ToUnit(XFA_UNIT_Pt); | |
1227 fTopInset = | |
1228 pMarginNode->GetMeasure(XFA_ATTRIBUTE_TopInset).ToUnit(XFA_UNIT_Pt); | |
1229 fRightInset = | |
1230 pMarginNode->GetMeasure(XFA_ATTRIBUTE_RightInset).ToUnit(XFA_UNIT_Pt); | |
1231 fBottomInset = | |
1232 pMarginNode->GetMeasure(XFA_ATTRIBUTE_BottomInset).ToUnit(XFA_UNIT_Pt); | |
1233 } | |
1234 FX_FLOAT fContentWidthLimit = | |
1235 bContainerWidthAutoSize ? XFA_LAYOUT_FLOAT_MAX | |
1236 : fContainerWidth - fLeftInset - fRightInset; | |
1237 FX_FLOAT fContentCurrentHeight = | |
1238 pLayoutRow->m_sSize.y - fTopInset - fBottomInset; | |
1239 FX_FLOAT fContentCalculatedWidth = 0, fContentCalculatedHeight = 0; | |
1240 FX_FLOAT fCurrentColX = 0; | |
1241 int32_t nCurrentColIdx = 0; | |
1242 FX_BOOL bMetWholeRowCell = FALSE; | |
1243 for (CXFA_ContentLayoutItem* pLayoutChild = | |
1244 (CXFA_ContentLayoutItem*)pLayoutRow->m_pFirstChild; | |
1245 pLayoutChild; | |
1246 pLayoutChild = (CXFA_ContentLayoutItem*)pLayoutChild->m_pNextSibling) { | |
1247 int32_t nOriginalColSpan = | |
1248 pLayoutChild->m_pFormNode->GetInteger(XFA_ATTRIBUTE_ColSpan); | |
1249 int32_t nColSpan = nOriginalColSpan; | |
1250 FX_FLOAT fColSpanWidth = 0; | |
1251 if (nColSpan == -1 || | |
1252 nCurrentColIdx + nColSpan > rgSpecifiedColumnWidths.GetSize()) { | |
1253 nColSpan = rgSpecifiedColumnWidths.GetSize() - nCurrentColIdx; | |
1254 } | |
1255 for (int32_t i = 0; i < nColSpan; i++) { | |
1256 fColSpanWidth += rgSpecifiedColumnWidths[nCurrentColIdx + i]; | |
1257 } | |
1258 if (nColSpan != nOriginalColSpan) { | |
1259 fColSpanWidth = bMetWholeRowCell ? 0 : std::max(fColSpanWidth, | |
1260 pLayoutChild->m_sSize.y); | |
1261 } | |
1262 if (nOriginalColSpan == -1) { | |
1263 bMetWholeRowCell = TRUE; | |
1264 } | |
1265 pLayoutChild->m_sPos = CFX_PointF(fCurrentColX, 0); | |
1266 pLayoutChild->m_sSize.x = fColSpanWidth; | |
1267 if (XFA_ItemLayoutProcessor_IsTakingSpace(pLayoutChild->m_pFormNode)) { | |
1268 fCurrentColX += fColSpanWidth; | |
1269 nCurrentColIdx += nColSpan; | |
1270 FX_FLOAT fNewHeight = | |
1271 bContainerHeightAutoSize ? -1 : fContentCurrentHeight; | |
1272 XFA_ItemLayoutProcessor_UpdateWidgetSize(pLayoutChild, fColSpanWidth, | |
1273 fNewHeight); | |
1274 pLayoutChild->m_sSize.y = fNewHeight; | |
1275 if (bContainerHeightAutoSize) { | |
1276 FX_FLOAT fChildSuppliedHeight = pLayoutChild->m_sSize.y; | |
1277 if (fContentCalculatedHeight < fChildSuppliedHeight) { | |
1278 fContentCalculatedHeight = fChildSuppliedHeight; | |
1279 } | |
1280 } | |
1281 } | |
1282 } | |
1283 if (bContainerHeightAutoSize) { | |
1284 for (CXFA_ContentLayoutItem* pLayoutChild = | |
1285 (CXFA_ContentLayoutItem*)pLayoutRow->m_pFirstChild; | |
1286 pLayoutChild; | |
1287 pLayoutChild = (CXFA_ContentLayoutItem*)pLayoutChild->m_pNextSibling) { | |
1288 XFA_ItemLayoutProcessor_UpdateWidgetSize( | |
1289 pLayoutChild, pLayoutChild->m_sSize.x, fContentCalculatedHeight); | |
1290 FX_FLOAT fOldChildHeight = pLayoutChild->m_sSize.y; | |
1291 pLayoutChild->m_sSize.y = fContentCalculatedHeight; | |
1292 CXFA_Node* pParaNode = | |
1293 pLayoutChild->m_pFormNode->GetFirstChildByClass(XFA_ELEMENT_Para); | |
1294 if (pParaNode && pLayoutChild->m_pFirstChild) { | |
1295 FX_FLOAT fOffHeight = fContentCalculatedHeight - fOldChildHeight; | |
1296 XFA_ATTRIBUTEENUM eVType = pParaNode->GetEnum(XFA_ATTRIBUTE_VAlign); | |
1297 switch (eVType) { | |
1298 case XFA_ATTRIBUTEENUM_Middle: | |
1299 fOffHeight = fOffHeight / 2; | |
1300 break; | |
1301 case XFA_ATTRIBUTEENUM_Bottom: | |
1302 break; | |
1303 case XFA_ATTRIBUTEENUM_Top: | |
1304 default: | |
1305 fOffHeight = 0; | |
1306 break; | |
1307 } | |
1308 if (fOffHeight > 0) { | |
1309 for (CXFA_ContentLayoutItem* pInnerLayoutChild = | |
1310 (CXFA_ContentLayoutItem*)pLayoutChild->m_pFirstChild; | |
1311 pInnerLayoutChild; | |
1312 pInnerLayoutChild = | |
1313 (CXFA_ContentLayoutItem*)pInnerLayoutChild->m_pNextSibling) { | |
1314 pInnerLayoutChild->m_sPos.y += fOffHeight; | |
1315 } | |
1316 } | |
1317 } | |
1318 } | |
1319 } | |
1320 if (bContainerWidthAutoSize) { | |
1321 FX_FLOAT fChildSuppliedWidth = fCurrentColX; | |
1322 if (fContentWidthLimit < XFA_LAYOUT_FLOAT_MAX && | |
1323 fContentWidthLimit > fChildSuppliedWidth) { | |
1324 fChildSuppliedWidth = fContentWidthLimit; | |
1325 } | |
1326 if (fContentCalculatedWidth < fChildSuppliedWidth) { | |
1327 fContentCalculatedWidth = fChildSuppliedWidth; | |
1328 } | |
1329 } else { | |
1330 fContentCalculatedWidth = fContainerWidth - fLeftInset - fRightInset; | |
1331 } | |
1332 if (pLayoutRow->m_pFormNode->GetEnum(XFA_ATTRIBUTE_Layout) == | |
1333 XFA_ATTRIBUTEENUM_Rl_row) { | |
1334 for (CXFA_ContentLayoutItem* pLayoutChild = | |
1335 (CXFA_ContentLayoutItem*)pLayoutRow->m_pFirstChild; | |
1336 pLayoutChild; | |
1337 pLayoutChild = (CXFA_ContentLayoutItem*)pLayoutChild->m_pNextSibling) { | |
1338 pLayoutChild->m_sPos.x = fContentCalculatedWidth - | |
1339 pLayoutChild->m_sPos.x - pLayoutChild->m_sSize.x; | |
1340 } | |
1341 } | |
1342 XFA_ItemLayoutProcessor_CalculateContainerComponentSizeFromContentSize( | |
1343 pLayoutRow->m_pFormNode, bContainerWidthAutoSize, fContentCalculatedWidth, | |
1344 fContainerWidth, bContainerHeightAutoSize, fContentCalculatedHeight, | |
1345 fContainerHeight); | |
1346 pLayoutRow->m_sSize = CFX_SizeF(fContainerWidth, fContainerHeight); | |
1347 } | |
1348 void CXFA_ItemLayoutProcessor::DoLayoutTableContainer(CXFA_Node* pLayoutNode) { | |
1349 if (m_pLayoutItem) | |
1350 return; | |
1351 | |
1352 if (pLayoutNode == NULL) { | |
1353 pLayoutNode = m_pFormNode; | |
1354 } | |
1355 ASSERT(m_pCurChildNode == XFA_LAYOUT_INVALIDNODE); | |
1356 m_pLayoutItem = CreateContentLayoutItem(m_pFormNode); | |
1357 FX_FLOAT fContainerWidth = 0, fContainerHeight = 0; | |
1358 FX_BOOL bContainerWidthAutoSize = TRUE, bContainerHeightAutoSize = TRUE; | |
1359 XFA_ItemLayoutProcessor_CalculateContainerSpecfiedSize( | |
1360 m_pFormNode, fContainerWidth, fContainerHeight, bContainerWidthAutoSize, | |
1361 bContainerHeightAutoSize); | |
1362 FX_FLOAT fContentCalculatedWidth = 0, fContentCalculatedHeight = 0; | |
1363 CXFA_Node* pMarginNode = | |
1364 m_pFormNode->GetFirstChildByClass(XFA_ELEMENT_Margin); | |
1365 FX_FLOAT fLeftInset = 0; | |
1366 FX_FLOAT fRightInset = 0; | |
1367 if (pMarginNode) { | |
1368 fLeftInset = | |
1369 pMarginNode->GetMeasure(XFA_ATTRIBUTE_LeftInset).ToUnit(XFA_UNIT_Pt); | |
1370 fRightInset = | |
1371 pMarginNode->GetMeasure(XFA_ATTRIBUTE_RightInset).ToUnit(XFA_UNIT_Pt); | |
1372 } | |
1373 FX_FLOAT fContentWidthLimit = | |
1374 bContainerWidthAutoSize ? XFA_LAYOUT_FLOAT_MAX | |
1375 : fContainerWidth - fLeftInset - fRightInset; | |
1376 CFX_WideStringC wsColumnWidths; | |
1377 if (pLayoutNode->TryCData(XFA_ATTRIBUTE_ColumnWidths, wsColumnWidths)) { | |
1378 CFX_WideStringArray widths; | |
1379 if (FX_SeparateStringW(wsColumnWidths.GetPtr(), wsColumnWidths.GetLength(), | |
1380 L' ', widths) > 0) { | |
1381 int32_t iCols = widths.GetSize(); | |
1382 CFX_WideString wsWidth; | |
1383 for (int32_t i = 0; i < iCols; i++) { | |
1384 wsWidth = widths[i]; | |
1385 wsWidth.TrimLeft(L' '); | |
1386 if (!wsWidth.IsEmpty()) { | |
1387 CXFA_Measurement measure(wsWidth); | |
1388 m_rgSpecifiedColumnWidths.Add(measure.ToUnit(XFA_UNIT_Pt)); | |
1389 } | |
1390 } | |
1391 } | |
1392 } | |
1393 int32_t iSpecifiedColumnCount = m_rgSpecifiedColumnWidths.GetSize(); | |
1394 CXFA_LayoutContext layoutContext; | |
1395 layoutContext.m_prgSpecifiedColumnWidths = &m_rgSpecifiedColumnWidths; | |
1396 CXFA_LayoutContext* pLayoutContext = | |
1397 iSpecifiedColumnCount > 0 ? &layoutContext : NULL; | |
1398 if (m_pCurChildNode == XFA_LAYOUT_INVALIDNODE) { | |
1399 XFA_ItemLayoutProcessor_GotoNextContainerNode( | |
1400 m_pCurChildNode, m_nCurChildNodeStage, m_pFormNode, FALSE); | |
1401 } | |
1402 for (; m_pCurChildNode; XFA_ItemLayoutProcessor_GotoNextContainerNode( | |
1403 m_pCurChildNode, m_nCurChildNodeStage, m_pFormNode, FALSE)) { | |
1404 layoutContext.m_bCurColumnWidthAvaiable = FALSE; | |
1405 layoutContext.m_fCurColumnWidth = 0; | |
1406 if (m_nCurChildNodeStage != XFA_ItemLayoutProcessorStages_Container) { | |
1407 continue; | |
1408 } | |
1409 CXFA_ItemLayoutProcessor* pProcessor = | |
1410 new CXFA_ItemLayoutProcessor(m_pCurChildNode, m_pPageMgr); | |
1411 pProcessor->DoLayout(FALSE, XFA_LAYOUT_FLOAT_MAX, XFA_LAYOUT_FLOAT_MAX, | |
1412 pLayoutContext); | |
1413 if (!pProcessor->HasLayoutItem()) { | |
1414 delete pProcessor; | |
1415 continue; | |
1416 } | |
1417 m_pLayoutItem->AddChild(pProcessor->ExtractLayoutItem()); | |
1418 delete pProcessor; | |
1419 } | |
1420 int32_t iRowCount = 0, iColCount = 0; | |
1421 { | |
1422 CFX_ArrayTemplate<CXFA_ContentLayoutItem*> rgRowItems; | |
1423 CFX_ArrayTemplate<int32_t> rgRowItemsSpan; | |
1424 CFX_ArrayTemplate<FX_FLOAT> rgRowItemsWidth; | |
1425 for (CXFA_ContentLayoutItem* pLayoutChild = | |
1426 (CXFA_ContentLayoutItem*)m_pLayoutItem->m_pFirstChild; | |
1427 pLayoutChild; | |
1428 pLayoutChild = (CXFA_ContentLayoutItem*)pLayoutChild->m_pNextSibling) { | |
1429 if (pLayoutChild->m_pFormNode->GetClassID() != XFA_ELEMENT_Subform) { | |
1430 continue; | |
1431 } | |
1432 if (!XFA_ItemLayoutProcessor_IsTakingSpace(pLayoutChild->m_pFormNode)) { | |
1433 continue; | |
1434 } | |
1435 XFA_ATTRIBUTEENUM eLayout = | |
1436 pLayoutChild->m_pFormNode->GetEnum(XFA_ATTRIBUTE_Layout); | |
1437 if (eLayout != XFA_ATTRIBUTEENUM_Row && | |
1438 eLayout != XFA_ATTRIBUTEENUM_Rl_row) { | |
1439 continue; | |
1440 } | |
1441 if (CXFA_ContentLayoutItem* pRowLayoutCell = | |
1442 (CXFA_ContentLayoutItem*)pLayoutChild->m_pFirstChild) { | |
1443 rgRowItems.Add(pRowLayoutCell); | |
1444 int32_t iColSpan = | |
1445 pRowLayoutCell->m_pFormNode->GetInteger(XFA_ATTRIBUTE_ColSpan); | |
1446 rgRowItemsSpan.Add(iColSpan); | |
1447 rgRowItemsWidth.Add(pRowLayoutCell->m_sSize.x); | |
1448 } | |
1449 } | |
1450 iRowCount = rgRowItems.GetSize(); | |
1451 iColCount = 0; | |
1452 FX_BOOL bMoreColumns = TRUE; | |
1453 while (bMoreColumns) { | |
1454 bMoreColumns = FALSE; | |
1455 FX_BOOL bAutoCol = FALSE; | |
1456 for (int32_t i = 0; i < iRowCount; i++) { | |
1457 while (rgRowItems[i] && (rgRowItemsSpan[i] <= 0 || | |
1458 !XFA_ItemLayoutProcessor_IsTakingSpace( | |
1459 rgRowItems[i]->m_pFormNode))) { | |
1460 CXFA_ContentLayoutItem* pNewCell = | |
1461 (CXFA_ContentLayoutItem*)rgRowItems[i]->m_pNextSibling; | |
1462 if (rgRowItemsSpan[i] < 0 && XFA_ItemLayoutProcessor_IsTakingSpace( | |
1463 rgRowItems[i]->m_pFormNode)) { | |
1464 pNewCell = NULL; | |
1465 } | |
1466 rgRowItems[i] = pNewCell; | |
1467 rgRowItemsSpan[i] = | |
1468 pNewCell | |
1469 ? pNewCell->m_pFormNode->GetInteger(XFA_ATTRIBUTE_ColSpan) | |
1470 : 0; | |
1471 rgRowItemsWidth[i] = pNewCell ? pNewCell->m_sSize.x : 0; | |
1472 } | |
1473 CXFA_ContentLayoutItem* pCell = rgRowItems[i]; | |
1474 if (!pCell) { | |
1475 continue; | |
1476 } | |
1477 bMoreColumns = TRUE; | |
1478 if (rgRowItemsSpan[i] == 1) { | |
1479 if (iColCount >= iSpecifiedColumnCount) { | |
1480 for (int32_t j = 0, c = iColCount + 1 - | |
1481 m_rgSpecifiedColumnWidths.GetSize(); | |
1482 j < c; j++) { | |
1483 m_rgSpecifiedColumnWidths.Add(0); | |
1484 } | |
1485 } | |
1486 if (m_rgSpecifiedColumnWidths[iColCount] < | |
1487 XFA_LAYOUT_FLOAT_PERCISION) { | |
1488 bAutoCol = TRUE; | |
1489 } | |
1490 if (bAutoCol && | |
1491 m_rgSpecifiedColumnWidths[iColCount] < rgRowItemsWidth[i]) { | |
1492 m_rgSpecifiedColumnWidths[iColCount] = rgRowItemsWidth[i]; | |
1493 } | |
1494 } | |
1495 } | |
1496 if (bMoreColumns) { | |
1497 FX_FLOAT fFinalColumnWidth = 0.0f; | |
1498 if (iColCount < m_rgSpecifiedColumnWidths.GetSize()) | |
1499 fFinalColumnWidth = m_rgSpecifiedColumnWidths[iColCount]; | |
1500 for (int32_t i = 0; i < iRowCount; ++i) { | |
1501 if (!rgRowItems[i]) | |
1502 continue; | |
1503 --rgRowItemsSpan[i]; | |
1504 rgRowItemsWidth[i] -= fFinalColumnWidth; | |
1505 } | |
1506 ++iColCount; | |
1507 } | |
1508 } | |
1509 } | |
1510 FX_FLOAT fCurrentRowY = 0; | |
1511 for (CXFA_ContentLayoutItem* pLayoutChild = | |
1512 (CXFA_ContentLayoutItem*)m_pLayoutItem->m_pFirstChild; | |
1513 pLayoutChild; | |
1514 pLayoutChild = (CXFA_ContentLayoutItem*)pLayoutChild->m_pNextSibling) { | |
1515 if (!XFA_ItemLayoutProcessor_IsTakingSpace(pLayoutChild->m_pFormNode)) { | |
1516 continue; | |
1517 } | |
1518 if (pLayoutChild->m_pFormNode->GetClassID() == XFA_ELEMENT_Subform) { | |
1519 XFA_ATTRIBUTEENUM eSubformLayout = | |
1520 pLayoutChild->m_pFormNode->GetEnum(XFA_ATTRIBUTE_Layout); | |
1521 if (eSubformLayout == XFA_ATTRIBUTEENUM_Row || | |
1522 eSubformLayout == XFA_ATTRIBUTEENUM_Rl_row) { | |
1523 XFA_ItemLayoutProcessor_RelocateTableRowCells( | |
1524 pLayoutChild, m_rgSpecifiedColumnWidths, eSubformLayout); | |
1525 } | |
1526 } | |
1527 pLayoutChild->m_sPos.y = fCurrentRowY; | |
1528 if (bContainerWidthAutoSize) { | |
1529 pLayoutChild->m_sPos.x = 0; | |
1530 } else { | |
1531 switch (pLayoutChild->m_pFormNode->GetEnum(XFA_ATTRIBUTE_HAlign)) { | |
1532 case XFA_ATTRIBUTEENUM_Left: | |
1533 default: | |
1534 pLayoutChild->m_sPos.x = 0; | |
1535 break; | |
1536 case XFA_ATTRIBUTEENUM_Center: | |
1537 pLayoutChild->m_sPos.x = | |
1538 (fContentWidthLimit - pLayoutChild->m_sSize.x) / 2; | |
1539 break; | |
1540 case XFA_ATTRIBUTEENUM_Right: | |
1541 pLayoutChild->m_sPos.x = fContentWidthLimit - pLayoutChild->m_sSize.x; | |
1542 break; | |
1543 } | |
1544 } | |
1545 if (bContainerWidthAutoSize) { | |
1546 FX_FLOAT fChildSuppliedWidth = | |
1547 pLayoutChild->m_sPos.x + pLayoutChild->m_sSize.x; | |
1548 if (fContentWidthLimit < XFA_LAYOUT_FLOAT_MAX && | |
1549 fContentWidthLimit > fChildSuppliedWidth) { | |
1550 fChildSuppliedWidth = fContentWidthLimit; | |
1551 } | |
1552 if (fContentCalculatedWidth < fChildSuppliedWidth) { | |
1553 fContentCalculatedWidth = fChildSuppliedWidth; | |
1554 } | |
1555 } | |
1556 fCurrentRowY += pLayoutChild->m_sSize.y; | |
1557 } | |
1558 if (bContainerHeightAutoSize) { | |
1559 FX_FLOAT fChildSuppliedHeight = fCurrentRowY; | |
1560 if (fContentCalculatedHeight < fChildSuppliedHeight) { | |
1561 fContentCalculatedHeight = fChildSuppliedHeight; | |
1562 } | |
1563 } | |
1564 XFA_ItemLayoutProcessor_CalculateContainerComponentSizeFromContentSize( | |
1565 m_pFormNode, bContainerWidthAutoSize, fContentCalculatedWidth, | |
1566 fContainerWidth, bContainerHeightAutoSize, fContentCalculatedHeight, | |
1567 fContainerHeight); | |
1568 SetCurrentComponentSize(fContainerWidth, fContainerHeight); | |
1569 } | |
1570 static uint8_t XFA_ItemLayoutProcessor_HAlignEnumToInt( | |
1571 XFA_ATTRIBUTEENUM eHAlign) { | |
1572 switch (eHAlign) { | |
1573 case XFA_ATTRIBUTEENUM_Center: | |
1574 return 1; | |
1575 case XFA_ATTRIBUTEENUM_Right: | |
1576 return 2; | |
1577 case XFA_ATTRIBUTEENUM_Left: | |
1578 default: | |
1579 return 0; | |
1580 } | |
1581 } | |
1582 static void XFA_ItemLayoutProcessor_UpdatePendedItemLayout( | |
1583 CXFA_ItemLayoutProcessor* pProcessor, | |
1584 CXFA_ContentLayoutItem* pLayoutItem) { | |
1585 XFA_ATTRIBUTEENUM eLayout = | |
1586 pLayoutItem->m_pFormNode->GetEnum(XFA_ATTRIBUTE_Layout); | |
1587 switch (eLayout) { | |
1588 case XFA_ATTRIBUTEENUM_Row: | |
1589 case XFA_ATTRIBUTEENUM_Rl_row: | |
1590 XFA_ItemLayoutProcessor_RelocateTableRowCells( | |
1591 pLayoutItem, pProcessor->m_rgSpecifiedColumnWidths, eLayout); | |
1592 break; | |
1593 default: | |
1594 break; | |
1595 } | |
1596 } | |
1597 FX_BOOL CXFA_ItemLayoutProcessor::IsAddNewRowForTrailer( | |
1598 CXFA_ContentLayoutItem* pTrailerItem) { | |
1599 if (!pTrailerItem) { | |
1600 return FALSE; | |
1601 } | |
1602 FX_FLOAT fWidth = pTrailerItem->m_sSize.x; | |
1603 XFA_ATTRIBUTEENUM eLayout = m_pFormNode->GetEnum(XFA_ATTRIBUTE_Layout); | |
1604 if (eLayout != XFA_ATTRIBUTEENUM_Tb && m_fWidthLimite > fWidth) { | |
1605 return FALSE; | |
1606 } | |
1607 return TRUE; | |
1608 } | |
1609 static void XFA_ItemLayoutProcessor_AddTrailerBeforeSplit( | |
1610 CXFA_ItemLayoutProcessor* pProcessor, | |
1611 FX_FLOAT fSplitPos, | |
1612 CXFA_ContentLayoutItem* pTrailerLayoutItem, | |
1613 FX_BOOL bUseInherited = FALSE) { | |
1614 if (!pTrailerLayoutItem) { | |
1615 return; | |
1616 } | |
1617 FX_FLOAT fHeight = pTrailerLayoutItem->m_sSize.y; | |
1618 if (bUseInherited) { | |
1619 FX_FLOAT fNewSplitPos = 0; | |
1620 if (fSplitPos - fHeight > XFA_LAYOUT_FLOAT_PERCISION) { | |
1621 fNewSplitPos = pProcessor->FindSplitPos(fSplitPos - fHeight); | |
1622 } | |
1623 if (fNewSplitPos > XFA_LAYOUT_FLOAT_PERCISION) { | |
1624 pProcessor->SplitLayoutItem(fNewSplitPos); | |
1625 } | |
1626 return; | |
1627 } | |
1628 XFA_ItemLayoutProcessor_UpdatePendedItemLayout(pProcessor, | |
1629 pTrailerLayoutItem); | |
1630 CXFA_Node* pMarginNode = | |
1631 pProcessor->m_pFormNode->GetFirstChildByClass(XFA_ELEMENT_Margin); | |
1632 FX_FLOAT fLeftInset = 0, fTopInset = 0, fRightInset = 0, fBottomInset = 0; | |
1633 if (pMarginNode) { | |
1634 fLeftInset = | |
1635 pMarginNode->GetMeasure(XFA_ATTRIBUTE_LeftInset).ToUnit(XFA_UNIT_Pt); | |
1636 fTopInset = | |
1637 pMarginNode->GetMeasure(XFA_ATTRIBUTE_TopInset).ToUnit(XFA_UNIT_Pt); | |
1638 fRightInset = | |
1639 pMarginNode->GetMeasure(XFA_ATTRIBUTE_RightInset).ToUnit(XFA_UNIT_Pt); | |
1640 fBottomInset = | |
1641 pMarginNode->GetMeasure(XFA_ATTRIBUTE_BottomInset).ToUnit(XFA_UNIT_Pt); | |
1642 } | |
1643 if (!pProcessor->IsAddNewRowForTrailer(pTrailerLayoutItem)) { | |
1644 pTrailerLayoutItem->m_sPos.y = pProcessor->m_fLastRowY; | |
1645 pTrailerLayoutItem->m_sPos.x = pProcessor->m_fLastRowWidth; | |
1646 pProcessor->m_pLayoutItem->m_sSize.x += pTrailerLayoutItem->m_sSize.x; | |
1647 pProcessor->m_pLayoutItem->AddChild(pTrailerLayoutItem); | |
1648 return; | |
1649 } | |
1650 FX_FLOAT fNewSplitPos = 0; | |
1651 if (fSplitPos - fHeight > XFA_LAYOUT_FLOAT_PERCISION) { | |
1652 fNewSplitPos = pProcessor->FindSplitPos(fSplitPos - fHeight); | |
1653 } | |
1654 if (fNewSplitPos > XFA_LAYOUT_FLOAT_PERCISION) { | |
1655 pProcessor->SplitLayoutItem(fNewSplitPos); | |
1656 pTrailerLayoutItem->m_sPos.y = fNewSplitPos - fTopInset - fBottomInset; | |
1657 } else { | |
1658 pTrailerLayoutItem->m_sPos.y = fSplitPos - fTopInset - fBottomInset; | |
1659 } | |
1660 switch (pTrailerLayoutItem->m_pFormNode->GetEnum(XFA_ATTRIBUTE_HAlign)) { | |
1661 case XFA_ATTRIBUTEENUM_Left: | |
1662 default: | |
1663 pTrailerLayoutItem->m_sPos.x = fLeftInset; | |
1664 break; | |
1665 case XFA_ATTRIBUTEENUM_Right: | |
1666 pTrailerLayoutItem->m_sPos.x = pProcessor->m_pLayoutItem->m_sSize.x - | |
1667 fRightInset - | |
1668 pTrailerLayoutItem->m_sSize.x; | |
1669 break; | |
1670 case XFA_ATTRIBUTEENUM_Center: | |
1671 pTrailerLayoutItem->m_sPos.x = | |
1672 (pProcessor->m_pLayoutItem->m_sSize.x - fLeftInset - fRightInset - | |
1673 pTrailerLayoutItem->m_sSize.x) / | |
1674 2; | |
1675 break; | |
1676 } | |
1677 pProcessor->m_pLayoutItem->m_sSize.y += fHeight; | |
1678 pProcessor->m_pLayoutItem->AddChild(pTrailerLayoutItem); | |
1679 } | |
1680 static void XFA_ItemLayoutProcessor_AddLeaderAfterSplit( | |
1681 CXFA_ItemLayoutProcessor* pProcessor, | |
1682 CXFA_ContentLayoutItem* pLeaderLayoutItem) { | |
1683 XFA_ItemLayoutProcessor_UpdatePendedItemLayout(pProcessor, pLeaderLayoutItem); | |
1684 CXFA_Node* pMarginNode = | |
1685 pProcessor->m_pFormNode->GetFirstChildByClass(XFA_ELEMENT_Margin); | |
1686 FX_FLOAT fLeftInset = 0; | |
1687 FX_FLOAT fRightInset = 0; | |
1688 if (pMarginNode) { | |
1689 fLeftInset = | |
1690 pMarginNode->GetMeasure(XFA_ATTRIBUTE_LeftInset).ToUnit(XFA_UNIT_Pt); | |
1691 fRightInset = | |
1692 pMarginNode->GetMeasure(XFA_ATTRIBUTE_RightInset).ToUnit(XFA_UNIT_Pt); | |
1693 } | |
1694 FX_FLOAT fHeight = pLeaderLayoutItem->m_sSize.y; | |
1695 for (CXFA_ContentLayoutItem* pChildItem = | |
1696 (CXFA_ContentLayoutItem*)pProcessor->m_pLayoutItem->m_pFirstChild; | |
1697 pChildItem; | |
1698 pChildItem = (CXFA_ContentLayoutItem*)pChildItem->m_pNextSibling) { | |
1699 pChildItem->m_sPos.y += fHeight; | |
1700 } | |
1701 pLeaderLayoutItem->m_sPos.y = 0; | |
1702 switch (pLeaderLayoutItem->m_pFormNode->GetEnum(XFA_ATTRIBUTE_HAlign)) { | |
1703 case XFA_ATTRIBUTEENUM_Left: | |
1704 default: | |
1705 pLeaderLayoutItem->m_sPos.x = fLeftInset; | |
1706 break; | |
1707 case XFA_ATTRIBUTEENUM_Right: | |
1708 pLeaderLayoutItem->m_sPos.x = pProcessor->m_pLayoutItem->m_sSize.x - | |
1709 fRightInset - pLeaderLayoutItem->m_sSize.x; | |
1710 break; | |
1711 case XFA_ATTRIBUTEENUM_Center: | |
1712 pLeaderLayoutItem->m_sPos.x = | |
1713 (pProcessor->m_pLayoutItem->m_sSize.x - fLeftInset - fRightInset - | |
1714 pLeaderLayoutItem->m_sSize.x) / | |
1715 2; | |
1716 break; | |
1717 } | |
1718 pProcessor->m_pLayoutItem->m_sSize.y += fHeight; | |
1719 pProcessor->m_pLayoutItem->AddChild(pLeaderLayoutItem); | |
1720 } | |
1721 static void XFA_ItemLayoutProcessor_AddPendingNode( | |
1722 CXFA_ItemLayoutProcessor* pProcessor, | |
1723 CXFA_Node* pPendingNode, | |
1724 FX_BOOL bBreakPending) { | |
1725 pProcessor->m_PendingNodes.push_back(pPendingNode); | |
1726 pProcessor->m_bBreakPending = bBreakPending; | |
1727 } | |
1728 static FX_FLOAT XFA_ItemLayoutProcessor_InsertPendingItems( | |
1729 CXFA_ItemLayoutProcessor* pProcessor, | |
1730 CXFA_Node* pCurChildNode) { | |
1731 FX_FLOAT fTotalHeight = 0; | |
1732 if (pProcessor->m_PendingNodes.empty()) { | |
1733 return fTotalHeight; | |
1734 } | |
1735 if (!pProcessor->m_pLayoutItem) { | |
1736 pProcessor->m_pLayoutItem = | |
1737 pProcessor->CreateContentLayoutItem(pCurChildNode); | |
1738 pProcessor->m_pLayoutItem->m_sSize.clear(); | |
1739 } | |
1740 while (!pProcessor->m_PendingNodes.empty()) { | |
1741 std::unique_ptr<CXFA_ItemLayoutProcessor> pPendingProcessor( | |
1742 new CXFA_ItemLayoutProcessor(pProcessor->m_PendingNodes.front(), | |
1743 nullptr)); | |
1744 pProcessor->m_PendingNodes.pop_front(); | |
1745 pPendingProcessor->DoLayout(FALSE, XFA_LAYOUT_FLOAT_MAX); | |
1746 CXFA_ContentLayoutItem* pPendingLayoutItem = | |
1747 pPendingProcessor->HasLayoutItem() | |
1748 ? pPendingProcessor->ExtractLayoutItem() | |
1749 : nullptr; | |
1750 if (pPendingLayoutItem) { | |
1751 XFA_ItemLayoutProcessor_AddLeaderAfterSplit(pProcessor, | |
1752 pPendingLayoutItem); | |
1753 if (pProcessor->m_bBreakPending) { | |
1754 fTotalHeight += pPendingLayoutItem->m_sSize.y; | |
1755 } | |
1756 } | |
1757 } | |
1758 return fTotalHeight; | |
1759 } | |
1760 FX_FLOAT CXFA_ItemLayoutProcessor::InsertKeepLayoutItems() { | |
1761 FX_FLOAT fTotalHeight = 0; | |
1762 if (m_arrayKeepItems.GetSize()) { | |
1763 if (!m_pLayoutItem) { | |
1764 m_pLayoutItem = CreateContentLayoutItem(m_pFormNode); | |
1765 m_pLayoutItem->m_sSize.clear(); | |
1766 } | |
1767 for (int32_t iIndex = m_arrayKeepItems.GetSize() - 1; iIndex >= 0; | |
1768 iIndex--) { | |
1769 XFA_ItemLayoutProcessor_AddLeaderAfterSplit(this, | |
1770 m_arrayKeepItems[iIndex]); | |
1771 fTotalHeight += m_arrayKeepItems[iIndex]->m_sSize.y; | |
1772 } | |
1773 m_arrayKeepItems.RemoveAll(); | |
1774 } | |
1775 return fTotalHeight; | |
1776 } | |
1777 FX_BOOL CXFA_ItemLayoutProcessor::ProcessKeepForSplite( | |
1778 CXFA_ItemLayoutProcessor* pParentProcessor, | |
1779 CXFA_ItemLayoutProcessor* pChildProcessor, | |
1780 XFA_ItemLayoutProcessorResult eRetValue, | |
1781 CFX_ArrayTemplate<CXFA_ContentLayoutItem*>& rgCurLineLayoutItem, | |
1782 FX_FLOAT& fContentCurRowAvailWidth, | |
1783 FX_FLOAT& fContentCurRowHeight, | |
1784 FX_FLOAT& fContentCurRowY, | |
1785 FX_BOOL& bAddedItemInRow, | |
1786 FX_BOOL& bForceEndPage, | |
1787 XFA_ItemLayoutProcessorResult& result) { | |
1788 if (pParentProcessor == NULL || pChildProcessor == NULL) { | |
1789 return FALSE; | |
1790 } | |
1791 if (pParentProcessor->m_pCurChildNode->GetIntact() != | |
1792 XFA_ATTRIBUTEENUM_None || | |
1793 !pChildProcessor->m_bHasAvailHeight) { | |
1794 if (XFA_ExistContainerKeep(pParentProcessor->m_pCurChildNode, TRUE)) { | |
1795 FX_FLOAT fChildWidth, fChildHeight; | |
1796 pChildProcessor->GetCurrentComponentSize(fChildWidth, fChildHeight); | |
1797 CFX_ArrayTemplate<CXFA_ContentLayoutItem*> keepLayoutItems; | |
1798 if (pParentProcessor->JudgePutNextPage(pParentProcessor->m_pLayoutItem, | |
1799 fChildHeight, keepLayoutItems)) { | |
1800 m_arrayKeepItems.RemoveAll(); | |
1801 for (int32_t iIndex = 0; iIndex < keepLayoutItems.GetSize(); iIndex++) { | |
1802 CXFA_ContentLayoutItem* pItem = keepLayoutItems.GetAt(iIndex); | |
1803 pParentProcessor->m_pLayoutItem->RemoveChild(pItem); | |
1804 fContentCurRowY -= pItem->m_sSize.y; | |
1805 m_arrayKeepItems.Add(pItem); | |
1806 } | |
1807 bAddedItemInRow = TRUE; | |
1808 bForceEndPage = TRUE; | |
1809 result = XFA_ItemLayoutProcessorResult_PageFullBreak; | |
1810 return TRUE; | |
1811 } | |
1812 rgCurLineLayoutItem.Add(pChildProcessor->ExtractLayoutItem()); | |
1813 bAddedItemInRow = TRUE; | |
1814 fContentCurRowAvailWidth -= fChildWidth; | |
1815 if (fContentCurRowHeight < fChildHeight) { | |
1816 fContentCurRowHeight = fChildHeight; | |
1817 } | |
1818 result = eRetValue; | |
1819 return TRUE; | |
1820 } | |
1821 } | |
1822 return FALSE; | |
1823 } | |
1824 FX_BOOL CXFA_ItemLayoutProcessor::JudgePutNextPage( | |
1825 CXFA_ContentLayoutItem* pParentLayoutItem, | |
1826 FX_FLOAT fChildHeight, | |
1827 CFX_ArrayTemplate<CXFA_ContentLayoutItem*>& pKeepItems) { | |
1828 if (pParentLayoutItem == NULL) { | |
1829 return FALSE; | |
1830 } | |
1831 FX_FLOAT fItemsHeight = 0; | |
1832 for (CXFA_ContentLayoutItem* pChildLayoutItem = | |
1833 (CXFA_ContentLayoutItem*)pParentLayoutItem->m_pFirstChild; | |
1834 pChildLayoutItem; | |
1835 pChildLayoutItem = | |
1836 (CXFA_ContentLayoutItem*)pChildLayoutItem->m_pNextSibling) { | |
1837 if (XFA_ExistContainerKeep(pChildLayoutItem->m_pFormNode, FALSE)) { | |
1838 pKeepItems.Add(pChildLayoutItem); | |
1839 fItemsHeight += pChildLayoutItem->m_sSize.y; | |
1840 } else { | |
1841 pKeepItems.RemoveAll(); | |
1842 fItemsHeight = 0; | |
1843 } | |
1844 } | |
1845 fItemsHeight += fChildHeight; | |
1846 if (m_pPageMgr->GetNextAvailContentHeight(fItemsHeight)) { | |
1847 return TRUE; | |
1848 } | |
1849 return FALSE; | |
1850 } | |
1851 void CXFA_ItemLayoutProcessor::ProcessUnUseBinds(CXFA_Node* pFormNode) { | |
1852 if (!pFormNode) { | |
1853 return; | |
1854 } | |
1855 CXFA_NodeIteratorTemplate<CXFA_Node, CXFA_TraverseStrategy_XFANode> sIterator( | |
1856 pFormNode); | |
1857 for (CXFA_Node* pNode = sIterator.MoveToNext(); pNode; | |
1858 pNode = sIterator.MoveToNext()) { | |
1859 if (pNode->IsContainerNode()) { | |
1860 CXFA_Node* pBindNode = pNode->GetBindData(); | |
1861 if (pBindNode) { | |
1862 pBindNode->RemoveBindItem(pNode); | |
1863 pNode->SetObject(XFA_ATTRIBUTE_BindingNode, NULL); | |
1864 } | |
1865 } | |
1866 pNode->SetFlag(XFA_NODEFLAG_UnusedNode); | |
1867 } | |
1868 } | |
1869 void CXFA_ItemLayoutProcessor::ProcessUnUseOverFlow( | |
1870 CXFA_Node* pLeaderNode, | |
1871 CXFA_Node* pTrailerNode, | |
1872 CXFA_ContentLayoutItem* pTrailerItem, | |
1873 CXFA_Node* pFormNode) { | |
1874 ProcessUnUseBinds(pLeaderNode); | |
1875 ProcessUnUseBinds(pTrailerNode); | |
1876 if (pFormNode == NULL) { | |
1877 return; | |
1878 } | |
1879 if (pFormNode->GetClassID() == XFA_ELEMENT_Overflow || | |
1880 pFormNode->GetClassID() == XFA_ELEMENT_Break) { | |
1881 pFormNode = pFormNode->GetNodeItem(XFA_NODEITEM_Parent); | |
1882 } | |
1883 if (pLeaderNode && pFormNode) { | |
1884 pFormNode->RemoveChild(pLeaderNode); | |
1885 } | |
1886 if (pTrailerNode && pFormNode) { | |
1887 pFormNode->RemoveChild(pTrailerNode); | |
1888 } | |
1889 if (pTrailerItem) { | |
1890 XFA_ReleaseLayoutItem(pTrailerItem); | |
1891 } | |
1892 } | |
1893 static XFA_ItemLayoutProcessorResult XFA_ItemLayoutProcessor_InsertFlowedItem( | |
1894 CXFA_ItemLayoutProcessor* pThis, | |
1895 CXFA_ItemLayoutProcessor*& pProcessor, | |
1896 FX_BOOL bContainerWidthAutoSize, | |
1897 FX_BOOL bContainerHeightAutoSize, | |
1898 FX_FLOAT fContainerHeight, | |
1899 XFA_ATTRIBUTEENUM eFlowStrategy, | |
1900 uint8_t& uCurHAlignState, | |
1901 CFX_ArrayTemplate<CXFA_ContentLayoutItem*>(&rgCurLineLayoutItems)[3], | |
1902 FX_BOOL bUseBreakControl, | |
1903 FX_FLOAT fAvailHeight, | |
1904 FX_FLOAT fRealHeight, | |
1905 FX_FLOAT& fContentCurRowY, | |
1906 FX_FLOAT& fContentWidthLimit, | |
1907 FX_FLOAT& fContentCurRowAvailWidth, | |
1908 FX_FLOAT& fContentCurRowHeight, | |
1909 FX_BOOL& bAddedItemInRow, | |
1910 FX_BOOL& bForceEndPage, | |
1911 CXFA_LayoutContext* pLayoutContext = NULL, | |
1912 FX_BOOL bNewRow = FALSE) { | |
1913 FX_BOOL bTakeSpace = | |
1914 XFA_ItemLayoutProcessor_IsTakingSpace(pProcessor->m_pFormNode); | |
1915 uint8_t uHAlign = XFA_ItemLayoutProcessor_HAlignEnumToInt( | |
1916 pThis->m_pCurChildNode->GetEnum(XFA_ATTRIBUTE_HAlign)); | |
1917 if (bContainerWidthAutoSize) { | |
1918 uHAlign = 0; | |
1919 } | |
1920 if ((eFlowStrategy != XFA_ATTRIBUTEENUM_Rl_tb && uHAlign < uCurHAlignState) || | |
1921 (eFlowStrategy == XFA_ATTRIBUTEENUM_Rl_tb && uHAlign > uCurHAlignState)) { | |
1922 return XFA_ItemLayoutProcessorResult_RowFullBreak; | |
1923 } | |
1924 uCurHAlignState = uHAlign; | |
1925 FX_BOOL bIsOwnSplite = | |
1926 pProcessor->m_pFormNode->GetIntact() == XFA_ATTRIBUTEENUM_None; | |
1927 FX_BOOL bUseRealHeight = | |
1928 bTakeSpace && bContainerHeightAutoSize && bIsOwnSplite && | |
1929 pProcessor->m_pFormNode->GetNodeItem(XFA_NODEITEM_Parent)->GetIntact() == | |
1930 XFA_ATTRIBUTEENUM_None; | |
1931 FX_BOOL bIsTransHeight = bTakeSpace; | |
1932 if (bIsTransHeight && !bIsOwnSplite) { | |
1933 FX_BOOL bRootForceTb = FALSE; | |
1934 XFA_ATTRIBUTEENUM eLayoutStrategy = XFA_ItemLayoutProcessor_GetLayout( | |
1935 pProcessor->m_pFormNode, bRootForceTb); | |
1936 if (eLayoutStrategy == XFA_ATTRIBUTEENUM_Lr_tb || | |
1937 eLayoutStrategy == XFA_ATTRIBUTEENUM_Rl_tb) { | |
1938 bIsTransHeight = FALSE; | |
1939 } | |
1940 } | |
1941 FX_BOOL bUseInherited = FALSE; | |
1942 CXFA_LayoutContext layoutContext; | |
1943 if (pThis->m_pPageMgr) { | |
1944 CXFA_Node* pOverflowNode = | |
1945 pThis->m_pPageMgr->QueryOverflow(pThis->m_pFormNode); | |
1946 if (pOverflowNode) { | |
1947 layoutContext.m_pOverflowNode = pOverflowNode; | |
1948 layoutContext.m_pOverflowProcessor = pThis; | |
1949 pLayoutContext = &layoutContext; | |
1950 } | |
1951 } | |
1952 XFA_ItemLayoutProcessorResult eRetValue = XFA_ItemLayoutProcessorResult_Done; | |
1953 if (!bNewRow || | |
1954 pProcessor->m_ePreProcessRs == XFA_ItemLayoutProcessorResult_Done) { | |
1955 eRetValue = pProcessor->DoLayout( | |
1956 bTakeSpace ? bUseBreakControl : FALSE, | |
1957 bUseRealHeight ? fRealHeight - fContentCurRowY : XFA_LAYOUT_FLOAT_MAX, | |
1958 bIsTransHeight ? fRealHeight - fContentCurRowY : XFA_LAYOUT_FLOAT_MAX, | |
1959 pLayoutContext); | |
1960 pProcessor->m_ePreProcessRs = eRetValue; | |
1961 } else { | |
1962 eRetValue = pProcessor->m_ePreProcessRs; | |
1963 pProcessor->m_ePreProcessRs = XFA_ItemLayoutProcessorResult_Done; | |
1964 } | |
1965 if (pProcessor->HasLayoutItem() == FALSE) { | |
1966 return eRetValue; | |
1967 } | |
1968 FX_FLOAT fChildWidth, fChildHeight; | |
1969 pProcessor->GetCurrentComponentSize(fChildWidth, fChildHeight); | |
1970 if (bUseRealHeight && fRealHeight < XFA_LAYOUT_FLOAT_PERCISION) { | |
1971 fRealHeight = XFA_LAYOUT_FLOAT_MAX; | |
1972 fAvailHeight = XFA_LAYOUT_FLOAT_MAX; | |
1973 } | |
1974 if (!bTakeSpace || | |
1975 (fChildWidth <= fContentCurRowAvailWidth + XFA_LAYOUT_FLOAT_PERCISION) || | |
1976 (fContentWidthLimit - fContentCurRowAvailWidth <= | |
1977 XFA_LAYOUT_FLOAT_PERCISION)) { | |
1978 CXFA_Node *pOverflowLeaderNode = NULL, *pOverflowTrailerNode = NULL, | |
1979 *pFormNode = NULL; | |
1980 CXFA_ContentLayoutItem* pTrailerLayoutItem = NULL; | |
1981 FX_BOOL bIsAddTrailerHeight = FALSE; | |
1982 if (pThis->m_pPageMgr && | |
1983 pProcessor->m_pFormNode->GetIntact() == XFA_ATTRIBUTEENUM_None) { | |
1984 pFormNode = pThis->m_pPageMgr->QueryOverflow(pProcessor->m_pFormNode); | |
1985 if (pFormNode == NULL && pLayoutContext && | |
1986 pLayoutContext->m_pOverflowProcessor) { | |
1987 pFormNode = pLayoutContext->m_pOverflowNode; | |
1988 bUseInherited = TRUE; | |
1989 } | |
1990 if (pThis->m_pPageMgr->ProcessOverflow(pFormNode, pOverflowLeaderNode, | |
1991 pOverflowTrailerNode, FALSE, | |
1992 FALSE)) { | |
1993 if (pProcessor->JudgeLeaderOrTrailerForOccur(pOverflowTrailerNode)) { | |
1994 if (pOverflowTrailerNode) { | |
1995 CXFA_ItemLayoutProcessor* pOverflowLeaderProcessor = | |
1996 new CXFA_ItemLayoutProcessor(pOverflowTrailerNode, NULL); | |
1997 pOverflowLeaderProcessor->DoLayout(FALSE, XFA_LAYOUT_FLOAT_MAX); | |
1998 pTrailerLayoutItem = | |
1999 pOverflowLeaderProcessor->HasLayoutItem() | |
2000 ? pOverflowLeaderProcessor->ExtractLayoutItem() | |
2001 : NULL; | |
2002 delete pOverflowLeaderProcessor; | |
2003 } | |
2004 if (bUseInherited) { | |
2005 bIsAddTrailerHeight = | |
2006 pThis->IsAddNewRowForTrailer(pTrailerLayoutItem); | |
2007 } else { | |
2008 bIsAddTrailerHeight = | |
2009 pProcessor->IsAddNewRowForTrailer(pTrailerLayoutItem); | |
2010 } | |
2011 if (bIsAddTrailerHeight) { | |
2012 FX_FLOAT fTrailerHeight = pTrailerLayoutItem->m_sSize.y; | |
2013 fChildHeight += fTrailerHeight; | |
2014 bIsAddTrailerHeight = TRUE; | |
2015 } | |
2016 } | |
2017 } | |
2018 } | |
2019 if (!bTakeSpace || | |
2020 fContentCurRowY + fChildHeight <= | |
2021 fAvailHeight + XFA_LAYOUT_FLOAT_PERCISION || | |
2022 (!bContainerHeightAutoSize && | |
2023 pThis->m_fUsedSize + fAvailHeight + XFA_LAYOUT_FLOAT_PERCISION >= | |
2024 fContainerHeight)) { | |
2025 if (!bTakeSpace || eRetValue == XFA_ItemLayoutProcessorResult_Done) { | |
2026 if (pProcessor->m_bUseInheriated) { | |
2027 if (pTrailerLayoutItem) { | |
2028 XFA_ItemLayoutProcessor_AddTrailerBeforeSplit( | |
2029 pProcessor, fChildHeight, pTrailerLayoutItem); | |
2030 } | |
2031 if (pProcessor->JudgeLeaderOrTrailerForOccur(pOverflowLeaderNode)) { | |
2032 XFA_ItemLayoutProcessor_AddPendingNode(pProcessor, | |
2033 pOverflowLeaderNode, FALSE); | |
2034 } | |
2035 pProcessor->m_bUseInheriated = FALSE; | |
2036 } else { | |
2037 if (bIsAddTrailerHeight) { | |
2038 fChildHeight -= pTrailerLayoutItem->m_sSize.y; | |
2039 } | |
2040 pProcessor->ProcessUnUseOverFlow(pOverflowLeaderNode, | |
2041 pOverflowTrailerNode, | |
2042 pTrailerLayoutItem, pFormNode); | |
2043 } | |
2044 CXFA_ContentLayoutItem* pChildLayoutItem = | |
2045 pProcessor->ExtractLayoutItem(); | |
2046 if (XFA_ExistContainerKeep(pProcessor->m_pFormNode, FALSE) && | |
2047 pProcessor->m_pFormNode->GetIntact() == XFA_ATTRIBUTEENUM_None) { | |
2048 pThis->m_arrayKeepItems.Add(pChildLayoutItem); | |
2049 } else { | |
2050 pThis->m_arrayKeepItems.RemoveAll(); | |
2051 } | |
2052 rgCurLineLayoutItems[uHAlign].Add(pChildLayoutItem); | |
2053 bAddedItemInRow = TRUE; | |
2054 if (bTakeSpace) { | |
2055 fContentCurRowAvailWidth -= fChildWidth; | |
2056 if (fContentCurRowHeight < fChildHeight) { | |
2057 fContentCurRowHeight = fChildHeight; | |
2058 } | |
2059 } | |
2060 return XFA_ItemLayoutProcessorResult_Done; | |
2061 } else { | |
2062 if (eRetValue == XFA_ItemLayoutProcessorResult_PageFullBreak) { | |
2063 if (pProcessor->m_bUseInheriated) { | |
2064 if (pTrailerLayoutItem) { | |
2065 XFA_ItemLayoutProcessor_AddTrailerBeforeSplit( | |
2066 pProcessor, fChildHeight, pTrailerLayoutItem); | |
2067 } | |
2068 if (pProcessor->JudgeLeaderOrTrailerForOccur(pOverflowLeaderNode)) { | |
2069 XFA_ItemLayoutProcessor_AddPendingNode( | |
2070 pProcessor, pOverflowLeaderNode, FALSE); | |
2071 } | |
2072 pProcessor->m_bUseInheriated = FALSE; | |
2073 } else { | |
2074 if (bIsAddTrailerHeight) { | |
2075 fChildHeight -= pTrailerLayoutItem->m_sSize.y; | |
2076 } | |
2077 pProcessor->ProcessUnUseOverFlow(pOverflowLeaderNode, | |
2078 pOverflowTrailerNode, | |
2079 pTrailerLayoutItem, pFormNode); | |
2080 } | |
2081 } | |
2082 rgCurLineLayoutItems[uHAlign].Add(pProcessor->ExtractLayoutItem()); | |
2083 bAddedItemInRow = TRUE; | |
2084 fContentCurRowAvailWidth -= fChildWidth; | |
2085 if (fContentCurRowHeight < fChildHeight) { | |
2086 fContentCurRowHeight = fChildHeight; | |
2087 } | |
2088 return eRetValue; | |
2089 } | |
2090 } else { | |
2091 XFA_ItemLayoutProcessorResult eResult; | |
2092 if (pThis->ProcessKeepForSplite( | |
2093 pThis, pProcessor, eRetValue, rgCurLineLayoutItems[uHAlign], | |
2094 fContentCurRowAvailWidth, fContentCurRowHeight, fContentCurRowY, | |
2095 bAddedItemInRow, bForceEndPage, eResult)) { | |
2096 return eResult; | |
2097 } | |
2098 bForceEndPage = TRUE; | |
2099 FX_FLOAT fSplitPos = | |
2100 pProcessor->FindSplitPos(fAvailHeight - fContentCurRowY); | |
2101 if (fSplitPos > XFA_LAYOUT_FLOAT_PERCISION) { | |
2102 XFA_ATTRIBUTEENUM eLayout = | |
2103 pProcessor->m_pFormNode->GetEnum(XFA_ATTRIBUTE_Layout); | |
2104 if (eLayout == XFA_ATTRIBUTEENUM_Tb && | |
2105 eRetValue == XFA_ItemLayoutProcessorResult_Done) { | |
2106 pProcessor->ProcessUnUseOverFlow(pOverflowLeaderNode, | |
2107 pOverflowTrailerNode, | |
2108 pTrailerLayoutItem, pFormNode); | |
2109 rgCurLineLayoutItems[uHAlign].Add(pProcessor->ExtractLayoutItem()); | |
2110 bAddedItemInRow = TRUE; | |
2111 if (bTakeSpace) { | |
2112 fContentCurRowAvailWidth -= fChildWidth; | |
2113 if (fContentCurRowHeight < fChildHeight) { | |
2114 fContentCurRowHeight = fChildHeight; | |
2115 } | |
2116 } | |
2117 return XFA_ItemLayoutProcessorResult_PageFullBreak; | |
2118 } | |
2119 CXFA_Node *pTempLeaderNode = NULL, *pTempTrailerNode = NULL; | |
2120 if (pThis->m_pPageMgr && !pProcessor->m_bUseInheriated && | |
2121 eRetValue != XFA_ItemLayoutProcessorResult_PageFullBreak) { | |
2122 pThis->m_pPageMgr->ProcessOverflow(pFormNode, pTempLeaderNode, | |
2123 pTempTrailerNode, FALSE, TRUE); | |
2124 } | |
2125 if (pTrailerLayoutItem && bIsAddTrailerHeight) { | |
2126 XFA_ItemLayoutProcessor_AddTrailerBeforeSplit( | |
2127 pProcessor, fSplitPos, pTrailerLayoutItem, bUseInherited); | |
2128 } else { | |
2129 pProcessor->SplitLayoutItem(fSplitPos); | |
2130 } | |
2131 if (bUseInherited) { | |
2132 pProcessor->ProcessUnUseOverFlow(pOverflowLeaderNode, | |
2133 pOverflowTrailerNode, | |
2134 pTrailerLayoutItem, pFormNode); | |
2135 pThis->m_bUseInheriated = TRUE; | |
2136 } else { | |
2137 if (pProcessor->m_pLayoutItem->m_pFirstChild && | |
2138 pProcessor->m_pLayoutItem->m_pFirstChild->m_pNextSibling == | |
2139 NULL && | |
2140 pProcessor->m_pLayoutItem->m_pFirstChild->m_pFormNode->HasFlag( | |
2141 XFA_NODEFLAG_LayoutGeneratedNode)) { | |
2142 pProcessor->ProcessUnUseOverFlow(pOverflowLeaderNode, | |
2143 pOverflowTrailerNode, | |
2144 pTrailerLayoutItem, pFormNode); | |
2145 } else { | |
2146 if (pProcessor->JudgeLeaderOrTrailerForOccur(pOverflowLeaderNode)) { | |
2147 XFA_ItemLayoutProcessor_AddPendingNode( | |
2148 pProcessor, pOverflowLeaderNode, FALSE); | |
2149 } | |
2150 } | |
2151 } | |
2152 if (pProcessor->m_pLayoutItem->m_pNextSibling) { | |
2153 pProcessor->GetCurrentComponentSize(fChildWidth, fChildHeight); | |
2154 rgCurLineLayoutItems[uHAlign].Add(pProcessor->ExtractLayoutItem()); | |
2155 bAddedItemInRow = TRUE; | |
2156 if (bTakeSpace) { | |
2157 fContentCurRowAvailWidth -= fChildWidth; | |
2158 if (fContentCurRowHeight < fChildHeight) { | |
2159 fContentCurRowHeight = fChildHeight; | |
2160 } | |
2161 } | |
2162 } | |
2163 return XFA_ItemLayoutProcessorResult_PageFullBreak; | |
2164 } else if (fContentCurRowY <= XFA_LAYOUT_FLOAT_PERCISION) { | |
2165 pProcessor->GetCurrentComponentSize(fChildWidth, fChildHeight); | |
2166 if (pProcessor->m_pPageMgr->GetNextAvailContentHeight(fChildHeight)) { | |
2167 CXFA_Node *pTempLeaderNode = NULL, *pTempTrailerNode = NULL; | |
2168 if (pThis->m_pPageMgr) { | |
2169 if (pFormNode == NULL && pLayoutContext) { | |
2170 pFormNode = pLayoutContext->m_pOverflowProcessor->m_pFormNode; | |
2171 } | |
2172 pThis->m_pPageMgr->ProcessOverflow(pFormNode, pTempLeaderNode, | |
2173 pTempTrailerNode, FALSE, TRUE); | |
2174 } | |
2175 if (bUseInherited) { | |
2176 pProcessor->ProcessUnUseOverFlow(pOverflowLeaderNode, | |
2177 pOverflowTrailerNode, | |
2178 pTrailerLayoutItem, pFormNode); | |
2179 pThis->m_bUseInheriated = TRUE; | |
2180 } | |
2181 return XFA_ItemLayoutProcessorResult_PageFullBreak; | |
2182 } | |
2183 rgCurLineLayoutItems[uHAlign].Add(pProcessor->ExtractLayoutItem()); | |
2184 bAddedItemInRow = TRUE; | |
2185 if (bTakeSpace) { | |
2186 fContentCurRowAvailWidth -= fChildWidth; | |
2187 if (fContentCurRowHeight < fChildHeight) { | |
2188 fContentCurRowHeight = fChildHeight; | |
2189 } | |
2190 } | |
2191 if (eRetValue == XFA_ItemLayoutProcessorResult_Done) { | |
2192 bForceEndPage = FALSE; | |
2193 } | |
2194 return eRetValue; | |
2195 } else { | |
2196 XFA_ATTRIBUTEENUM eLayout = | |
2197 pProcessor->m_pFormNode->GetEnum(XFA_ATTRIBUTE_Layout); | |
2198 if (pProcessor->m_pFormNode->GetIntact() == XFA_ATTRIBUTEENUM_None && | |
2199 eLayout == XFA_ATTRIBUTEENUM_Tb) { | |
2200 if (pThis->m_pPageMgr) { | |
2201 pThis->m_pPageMgr->ProcessOverflow(pFormNode, pOverflowLeaderNode, | |
2202 pOverflowTrailerNode, FALSE, | |
2203 TRUE); | |
2204 } | |
2205 if (pTrailerLayoutItem) { | |
2206 XFA_ItemLayoutProcessor_AddTrailerBeforeSplit(pProcessor, fSplitPos, | |
2207 pTrailerLayoutItem); | |
2208 } | |
2209 if (pProcessor->JudgeLeaderOrTrailerForOccur(pOverflowLeaderNode)) { | |
2210 XFA_ItemLayoutProcessor_AddPendingNode(pProcessor, | |
2211 pOverflowLeaderNode, FALSE); | |
2212 } | |
2213 } else { | |
2214 if (eRetValue == XFA_ItemLayoutProcessorResult_Done) { | |
2215 if (pFormNode == NULL && pLayoutContext) { | |
2216 pFormNode = pLayoutContext->m_pOverflowProcessor->m_pFormNode; | |
2217 } | |
2218 if (pThis->m_pPageMgr) { | |
2219 pThis->m_pPageMgr->ProcessOverflow(pFormNode, pOverflowLeaderNode, | |
2220 pOverflowTrailerNode, FALSE, | |
2221 TRUE); | |
2222 } | |
2223 if (bUseInherited) { | |
2224 pProcessor->ProcessUnUseOverFlow(pOverflowLeaderNode, | |
2225 pOverflowTrailerNode, | |
2226 pTrailerLayoutItem, pFormNode); | |
2227 pThis->m_bUseInheriated = TRUE; | |
2228 } | |
2229 } | |
2230 } | |
2231 return XFA_ItemLayoutProcessorResult_PageFullBreak; | |
2232 } | |
2233 } | |
2234 } else { | |
2235 return XFA_ItemLayoutProcessorResult_RowFullBreak; | |
2236 } | |
2237 return XFA_ItemLayoutProcessorResult_Done; | |
2238 } | |
2239 XFA_ItemLayoutProcessorResult CXFA_ItemLayoutProcessor::DoLayoutFlowedContainer( | |
2240 FX_BOOL bUseBreakControl, | |
2241 XFA_ATTRIBUTEENUM eFlowStrategy, | |
2242 FX_FLOAT fHeightLimit, | |
2243 FX_FLOAT fRealHeight, | |
2244 CXFA_LayoutContext* pContext, | |
2245 FX_BOOL bRootForceTb) { | |
2246 m_bHasAvailHeight = TRUE; | |
2247 FX_FLOAT fContainerWidth = 0, fContainerHeight = 0; | |
2248 FX_BOOL bBreakDone = FALSE; | |
2249 FX_BOOL bContainerWidthAutoSize = TRUE, bContainerHeightAutoSize = TRUE; | |
2250 FX_BOOL bForceEndPage = FALSE; | |
2251 FX_BOOL bIsManualBreak = FALSE; | |
2252 if (m_pCurChildPreprocessor) { | |
2253 m_pCurChildPreprocessor->m_ePreProcessRs = | |
2254 XFA_ItemLayoutProcessorResult_Done; | |
2255 } | |
2256 XFA_ItemLayoutProcessor_CalculateContainerSpecfiedSize( | |
2257 m_pFormNode, fContainerWidth, fContainerHeight, bContainerWidthAutoSize, | |
2258 bContainerHeightAutoSize); | |
2259 if (pContext && pContext->m_bCurColumnWidthAvaiable) { | |
2260 bContainerWidthAutoSize = FALSE; | |
2261 fContainerWidth = pContext->m_fCurColumnWidth; | |
2262 } | |
2263 if (!bContainerHeightAutoSize) { | |
2264 fContainerHeight -= m_fUsedSize; | |
2265 } | |
2266 if (!bContainerHeightAutoSize) { | |
2267 CXFA_Node* pParentNode = m_pFormNode->GetNodeItem(XFA_NODEITEM_Parent); | |
2268 FX_BOOL bFocrTb = FALSE; | |
2269 if (pParentNode && | |
2270 XFA_ItemLayoutProcessor_GetLayout(pParentNode, bFocrTb) == | |
2271 XFA_ATTRIBUTEENUM_Row) { | |
2272 CXFA_Node* pChildContainer = m_pFormNode->GetNodeItem( | |
2273 XFA_NODEITEM_FirstChild, XFA_OBJECTTYPE_ContainerNode); | |
2274 if (pChildContainer && | |
2275 pChildContainer->GetNodeItem(XFA_NODEITEM_NextSibling, | |
2276 XFA_OBJECTTYPE_ContainerNode)) { | |
2277 fContainerHeight = 0; | |
2278 bContainerHeightAutoSize = TRUE; | |
2279 } | |
2280 } | |
2281 } | |
2282 CXFA_Node* pMarginNode = | |
2283 m_pFormNode->GetFirstChildByClass(XFA_ELEMENT_Margin); | |
2284 FX_FLOAT fLeftInset = 0, fTopInset = 0, fRightInset = 0, fBottomInset = 0; | |
2285 if (pMarginNode) { | |
2286 fLeftInset = | |
2287 pMarginNode->GetMeasure(XFA_ATTRIBUTE_LeftInset).ToUnit(XFA_UNIT_Pt); | |
2288 fTopInset = | |
2289 pMarginNode->GetMeasure(XFA_ATTRIBUTE_TopInset).ToUnit(XFA_UNIT_Pt); | |
2290 fRightInset = | |
2291 pMarginNode->GetMeasure(XFA_ATTRIBUTE_RightInset).ToUnit(XFA_UNIT_Pt); | |
2292 fBottomInset = | |
2293 pMarginNode->GetMeasure(XFA_ATTRIBUTE_BottomInset).ToUnit(XFA_UNIT_Pt); | |
2294 } | |
2295 FX_FLOAT fContentWidthLimit = | |
2296 bContainerWidthAutoSize ? XFA_LAYOUT_FLOAT_MAX | |
2297 : fContainerWidth - fLeftInset - fRightInset; | |
2298 FX_FLOAT fContentCalculatedWidth = 0, fContentCalculatedHeight = 0; | |
2299 FX_FLOAT fAvailHeight = fHeightLimit - fTopInset - fBottomInset; | |
2300 if (fAvailHeight < 0) { | |
2301 m_bHasAvailHeight = FALSE; | |
2302 } | |
2303 fRealHeight = fRealHeight - fTopInset - fBottomInset; | |
2304 FX_FLOAT fContentCurRowY = 0; | |
2305 CXFA_ContentLayoutItem* pLayoutChild = NULL; | |
2306 if (m_pLayoutItem) { | |
2307 if (m_nCurChildNodeStage != XFA_ItemLayoutProcessorStages_Done && | |
2308 eFlowStrategy != XFA_ATTRIBUTEENUM_Tb) { | |
2309 pLayoutChild = (CXFA_ContentLayoutItem*)m_pLayoutItem->m_pFirstChild; | |
2310 for (CXFA_ContentLayoutItem* pLayoutNext = pLayoutChild; pLayoutNext; | |
2311 pLayoutNext = (CXFA_ContentLayoutItem*)pLayoutNext->m_pNextSibling) { | |
2312 if (pLayoutNext->m_sPos.y != pLayoutChild->m_sPos.y) { | |
2313 pLayoutChild = pLayoutNext; | |
2314 } | |
2315 } | |
2316 } | |
2317 for (CXFA_ContentLayoutItem* pLayoutTempChild = | |
2318 (CXFA_ContentLayoutItem*)m_pLayoutItem->m_pFirstChild; | |
2319 pLayoutTempChild != pLayoutChild; | |
2320 pLayoutTempChild = | |
2321 (CXFA_ContentLayoutItem*)pLayoutTempChild->m_pNextSibling) { | |
2322 if (XFA_ItemLayoutProcessor_IsTakingSpace( | |
2323 pLayoutTempChild->m_pFormNode)) { | |
2324 FX_FLOAT fChildContentWidth = | |
2325 pLayoutTempChild->m_sPos.x + pLayoutTempChild->m_sSize.x; | |
2326 FX_FLOAT fChildContentHeight = | |
2327 pLayoutTempChild->m_sPos.y + pLayoutTempChild->m_sSize.y; | |
2328 if (fContentCalculatedWidth < fChildContentWidth) { | |
2329 fContentCalculatedWidth = fChildContentWidth; | |
2330 } | |
2331 if (fContentCalculatedHeight < fChildContentHeight) { | |
2332 fContentCalculatedHeight = fChildContentHeight; | |
2333 } | |
2334 } | |
2335 } | |
2336 if (pLayoutChild) { | |
2337 fContentCurRowY = pLayoutChild->m_sPos.y; | |
2338 } else { | |
2339 fContentCurRowY = fContentCalculatedHeight; | |
2340 } | |
2341 } | |
2342 fContentCurRowY += InsertKeepLayoutItems(); | |
2343 if (m_nCurChildNodeStage == XFA_ItemLayoutProcessorStages_None) { | |
2344 XFA_ItemLayoutProcessor_GotoNextContainerNode( | |
2345 m_pCurChildNode, m_nCurChildNodeStage, m_pFormNode, TRUE); | |
2346 } | |
2347 fContentCurRowY += | |
2348 XFA_ItemLayoutProcessor_InsertPendingItems(this, m_pFormNode); | |
2349 if (m_pCurChildPreprocessor && | |
2350 m_nCurChildNodeStage == XFA_ItemLayoutProcessorStages_Container) { | |
2351 if (XFA_ExistContainerKeep(m_pCurChildPreprocessor->GetFormNode(), FALSE)) { | |
2352 m_pKeepHeadNode = m_pCurChildNode; | |
2353 m_bIsProcessKeep = TRUE; | |
2354 m_nCurChildNodeStage = XFA_ItemLayoutProcessorStages_Keep; | |
2355 } | |
2356 } | |
2357 while (m_nCurChildNodeStage != XFA_ItemLayoutProcessorStages_Done) { | |
2358 FX_FLOAT fContentCurRowHeight = 0; | |
2359 FX_FLOAT fContentCurRowAvailWidth = fContentWidthLimit; | |
2360 m_fWidthLimite = fContentCurRowAvailWidth; | |
2361 CFX_ArrayTemplate<CXFA_ContentLayoutItem*> rgCurLineLayoutItems[3]; | |
2362 uint8_t uCurHAlignState = | |
2363 (eFlowStrategy != XFA_ATTRIBUTEENUM_Rl_tb ? 0 : 2); | |
2364 if (pLayoutChild) { | |
2365 for (CXFA_ContentLayoutItem* pLayoutNext = pLayoutChild; pLayoutNext; | |
2366 pLayoutNext = (CXFA_ContentLayoutItem*)pLayoutNext->m_pNextSibling) { | |
2367 if (pLayoutNext->m_pNextSibling == NULL && m_pCurChildPreprocessor && | |
2368 m_pCurChildPreprocessor->m_pFormNode == pLayoutNext->m_pFormNode) { | |
2369 pLayoutNext->m_pNext = m_pCurChildPreprocessor->m_pLayoutItem; | |
2370 m_pCurChildPreprocessor->m_pLayoutItem = pLayoutNext; | |
2371 break; | |
2372 } | |
2373 uint8_t uHAlign = XFA_ItemLayoutProcessor_HAlignEnumToInt( | |
2374 pLayoutNext->m_pFormNode->GetEnum(XFA_ATTRIBUTE_HAlign)); | |
2375 rgCurLineLayoutItems[uHAlign].Add(pLayoutNext); | |
2376 if (eFlowStrategy == XFA_ATTRIBUTEENUM_Lr_tb) { | |
2377 if (uHAlign > uCurHAlignState) { | |
2378 uCurHAlignState = uHAlign; | |
2379 } | |
2380 } else if (uHAlign < uCurHAlignState) { | |
2381 uCurHAlignState = uHAlign; | |
2382 } | |
2383 if (XFA_ItemLayoutProcessor_IsTakingSpace(pLayoutNext->m_pFormNode)) { | |
2384 if (pLayoutNext->m_sSize.y > fContentCurRowHeight) { | |
2385 fContentCurRowHeight = pLayoutNext->m_sSize.y; | |
2386 } | |
2387 fContentCurRowAvailWidth -= pLayoutNext->m_sSize.x; | |
2388 } | |
2389 } | |
2390 if ((CXFA_ContentLayoutItem*)m_pLayoutItem->m_pFirstChild == | |
2391 pLayoutChild) { | |
2392 m_pLayoutItem->m_pFirstChild = NULL; | |
2393 } else { | |
2394 CXFA_ContentLayoutItem* pLayoutNext = | |
2395 (CXFA_ContentLayoutItem*)m_pLayoutItem->m_pFirstChild; | |
2396 for (; pLayoutNext; | |
2397 pLayoutNext = | |
2398 (CXFA_ContentLayoutItem*)pLayoutNext->m_pNextSibling) { | |
2399 if ((CXFA_ContentLayoutItem*)pLayoutNext->m_pNextSibling == | |
2400 pLayoutChild) { | |
2401 pLayoutNext->m_pNextSibling = NULL; | |
2402 break; | |
2403 } | |
2404 } | |
2405 } | |
2406 CXFA_ContentLayoutItem* pLayoutNextTemp = | |
2407 (CXFA_ContentLayoutItem*)pLayoutChild; | |
2408 while (pLayoutNextTemp) { | |
2409 pLayoutNextTemp->m_pParent = NULL; | |
2410 CXFA_ContentLayoutItem* pSaveLayoutNext = | |
2411 (CXFA_ContentLayoutItem*)pLayoutNextTemp->m_pNextSibling; | |
2412 pLayoutNextTemp->m_pNextSibling = NULL; | |
2413 pLayoutNextTemp = pSaveLayoutNext; | |
2414 } | |
2415 pLayoutChild = NULL; | |
2416 } | |
2417 while (m_pCurChildNode) { | |
2418 CXFA_ItemLayoutProcessor* pProcessor = NULL; | |
2419 FX_BOOL bAddedItemInRow = FALSE; | |
2420 fContentCurRowY += | |
2421 XFA_ItemLayoutProcessor_InsertPendingItems(this, m_pFormNode); | |
2422 switch (m_nCurChildNodeStage) { | |
2423 case XFA_ItemLayoutProcessorStages_Keep: | |
2424 case XFA_ItemLayoutProcessorStages_None: | |
2425 break; | |
2426 case XFA_ItemLayoutProcessorStages_BreakBefore: { | |
2427 for (int32_t iIndex = 0; iIndex < m_arrayKeepItems.GetSize(); | |
2428 iIndex++) { | |
2429 CXFA_ContentLayoutItem* pItem = m_arrayKeepItems.GetAt(iIndex); | |
2430 m_pLayoutItem->RemoveChild(pItem); | |
2431 fContentCalculatedHeight -= pItem->m_sSize.y; | |
2432 } | |
2433 CXFA_Node *pLeaderNode = NULL, *pTrailerNode = NULL; | |
2434 FX_BOOL bCreatePage = FALSE; | |
2435 if (bUseBreakControl && m_pPageMgr && | |
2436 m_pPageMgr->ProcessBreakBeforeOrAfter(m_pCurChildNode, TRUE, | |
2437 pLeaderNode, pTrailerNode, | |
2438 bCreatePage) && | |
2439 m_pFormNode->GetClassID() != XFA_ELEMENT_Form && bCreatePage) { | |
2440 if (JudgeLeaderOrTrailerForOccur(pLeaderNode)) { | |
2441 XFA_ItemLayoutProcessor_AddPendingNode(this, pLeaderNode, TRUE); | |
2442 } | |
2443 if (JudgeLeaderOrTrailerForOccur(pTrailerNode)) { | |
2444 if (m_pFormNode->GetNodeItem(XFA_NODEITEM_Parent)->GetClassID() == | |
2445 XFA_ELEMENT_Form && | |
2446 m_pLayoutItem == NULL) { | |
2447 XFA_ItemLayoutProcessor_AddPendingNode(this, pTrailerNode, | |
2448 TRUE); | |
2449 } else { | |
2450 CXFA_ItemLayoutProcessor* pProcessor = | |
2451 new CXFA_ItemLayoutProcessor(pTrailerNode, NULL); | |
2452 XFA_ItemLayoutProcessor_InsertFlowedItem( | |
2453 this, pProcessor, bContainerWidthAutoSize, | |
2454 bContainerHeightAutoSize, fContainerHeight, eFlowStrategy, | |
2455 uCurHAlignState, rgCurLineLayoutItems, FALSE, | |
2456 XFA_LAYOUT_FLOAT_MAX, XFA_LAYOUT_FLOAT_MAX, fContentCurRowY, | |
2457 fContentWidthLimit, fContentCurRowAvailWidth, | |
2458 fContentCurRowHeight, bAddedItemInRow, bForceEndPage, | |
2459 pContext); | |
2460 delete pProcessor; | |
2461 pProcessor = NULL; | |
2462 } | |
2463 } | |
2464 XFA_ItemLayoutProcessor_GotoNextContainerNode( | |
2465 m_pCurChildNode, m_nCurChildNodeStage, m_pFormNode, TRUE); | |
2466 bForceEndPage = TRUE; | |
2467 bIsManualBreak = TRUE; | |
2468 goto SuspendAndCreateNewRow; | |
2469 } | |
2470 } break; | |
2471 case XFA_ItemLayoutProcessorStages_BreakAfter: { | |
2472 CXFA_Node *pLeaderNode = NULL, *pTrailerNode = NULL; | |
2473 FX_BOOL bCreatePage = FALSE; | |
2474 if (bUseBreakControl && m_pPageMgr && | |
2475 m_pPageMgr->ProcessBreakBeforeOrAfter(m_pCurChildNode, FALSE, | |
2476 pLeaderNode, pTrailerNode, | |
2477 bCreatePage) && | |
2478 m_pFormNode->GetClassID() != XFA_ELEMENT_Form) { | |
2479 if (JudgeLeaderOrTrailerForOccur(pTrailerNode)) { | |
2480 CXFA_ItemLayoutProcessor* pProcessor = | |
2481 new CXFA_ItemLayoutProcessor(pTrailerNode, NULL); | |
2482 XFA_ItemLayoutProcessor_InsertFlowedItem( | |
2483 this, pProcessor, bContainerWidthAutoSize, | |
2484 bContainerHeightAutoSize, fContainerHeight, eFlowStrategy, | |
2485 uCurHAlignState, rgCurLineLayoutItems, FALSE, | |
2486 XFA_LAYOUT_FLOAT_MAX, XFA_LAYOUT_FLOAT_MAX, fContentCurRowY, | |
2487 fContentWidthLimit, fContentCurRowAvailWidth, | |
2488 fContentCurRowHeight, bAddedItemInRow, bForceEndPage, | |
2489 pContext); | |
2490 delete pProcessor; | |
2491 pProcessor = NULL; | |
2492 } | |
2493 if (!bCreatePage) { | |
2494 if (JudgeLeaderOrTrailerForOccur(pLeaderNode)) { | |
2495 CalculateRowChildPosition( | |
2496 rgCurLineLayoutItems, eFlowStrategy, | |
2497 bContainerHeightAutoSize, bContainerWidthAutoSize, | |
2498 fContentCalculatedWidth, fContentCalculatedHeight, | |
2499 fContentCurRowY, fContentCurRowHeight, fContentWidthLimit); | |
2500 rgCurLineLayoutItems->RemoveAll(); | |
2501 CXFA_ItemLayoutProcessor* pProcessor = | |
2502 new CXFA_ItemLayoutProcessor(pLeaderNode, NULL); | |
2503 XFA_ItemLayoutProcessor_InsertFlowedItem( | |
2504 this, pProcessor, bContainerWidthAutoSize, | |
2505 bContainerHeightAutoSize, fContainerHeight, eFlowStrategy, | |
2506 uCurHAlignState, rgCurLineLayoutItems, FALSE, | |
2507 XFA_LAYOUT_FLOAT_MAX, XFA_LAYOUT_FLOAT_MAX, fContentCurRowY, | |
2508 fContentWidthLimit, fContentCurRowAvailWidth, | |
2509 fContentCurRowHeight, bAddedItemInRow, bForceEndPage, | |
2510 pContext); | |
2511 delete pProcessor; | |
2512 pProcessor = NULL; | |
2513 } | |
2514 } else { | |
2515 if (JudgeLeaderOrTrailerForOccur(pLeaderNode)) { | |
2516 XFA_ItemLayoutProcessor_AddPendingNode(this, pLeaderNode, TRUE); | |
2517 } | |
2518 } | |
2519 XFA_ItemLayoutProcessor_GotoNextContainerNode( | |
2520 m_pCurChildNode, m_nCurChildNodeStage, m_pFormNode, TRUE); | |
2521 if (bCreatePage) { | |
2522 bForceEndPage = TRUE; | |
2523 bIsManualBreak = TRUE; | |
2524 if (m_nCurChildNodeStage == XFA_ItemLayoutProcessorStages_Done) { | |
2525 bBreakDone = TRUE; | |
2526 } | |
2527 } | |
2528 goto SuspendAndCreateNewRow; | |
2529 } | |
2530 } break; | |
2531 case XFA_ItemLayoutProcessorStages_BookendLeader: { | |
2532 CXFA_Node* pLeaderNode = NULL; | |
2533 if (m_pCurChildPreprocessor) { | |
2534 pProcessor = m_pCurChildPreprocessor; | |
2535 m_pCurChildPreprocessor = NULL; | |
2536 } else if (m_pPageMgr && | |
2537 m_pPageMgr->ProcessBookendLeaderOrTrailer( | |
2538 m_pCurChildNode, TRUE, pLeaderNode)) { | |
2539 pProcessor = new CXFA_ItemLayoutProcessor(pLeaderNode, m_pPageMgr); | |
2540 } | |
2541 if (pProcessor) { | |
2542 if (XFA_ItemLayoutProcessor_InsertFlowedItem( | |
2543 this, pProcessor, bContainerWidthAutoSize, | |
2544 bContainerHeightAutoSize, fContainerHeight, eFlowStrategy, | |
2545 uCurHAlignState, rgCurLineLayoutItems, bUseBreakControl, | |
2546 fAvailHeight, fRealHeight, fContentCurRowY, | |
2547 fContentWidthLimit, fContentCurRowAvailWidth, | |
2548 fContentCurRowHeight, bAddedItemInRow, bForceEndPage, | |
2549 pContext) != XFA_ItemLayoutProcessorResult_Done) { | |
2550 goto SuspendAndCreateNewRow; | |
2551 } else { | |
2552 delete pProcessor; | |
2553 pProcessor = NULL; | |
2554 } | |
2555 } | |
2556 } break; | |
2557 case XFA_ItemLayoutProcessorStages_BookendTrailer: { | |
2558 CXFA_Node* pTrailerNode = NULL; | |
2559 if (m_pCurChildPreprocessor) { | |
2560 pProcessor = m_pCurChildPreprocessor; | |
2561 m_pCurChildPreprocessor = NULL; | |
2562 } else if (m_pPageMgr && | |
2563 m_pPageMgr->ProcessBookendLeaderOrTrailer( | |
2564 m_pCurChildNode, FALSE, pTrailerNode)) { | |
2565 pProcessor = new CXFA_ItemLayoutProcessor(pTrailerNode, m_pPageMgr); | |
2566 } | |
2567 if (pProcessor) { | |
2568 if (XFA_ItemLayoutProcessor_InsertFlowedItem( | |
2569 this, pProcessor, bContainerWidthAutoSize, | |
2570 bContainerHeightAutoSize, fContainerHeight, eFlowStrategy, | |
2571 uCurHAlignState, rgCurLineLayoutItems, bUseBreakControl, | |
2572 fAvailHeight, fRealHeight, fContentCurRowY, | |
2573 fContentWidthLimit, fContentCurRowAvailWidth, | |
2574 fContentCurRowHeight, bAddedItemInRow, bForceEndPage, | |
2575 pContext) != XFA_ItemLayoutProcessorResult_Done) { | |
2576 goto SuspendAndCreateNewRow; | |
2577 } else { | |
2578 delete pProcessor; | |
2579 pProcessor = NULL; | |
2580 } | |
2581 } | |
2582 } break; | |
2583 case XFA_ItemLayoutProcessorStages_Container: | |
2584 ASSERT(m_pCurChildNode->IsContainerNode()); | |
2585 if (m_pCurChildNode->GetClassID() == XFA_ELEMENT_Variables) { | |
2586 break; | |
2587 } | |
2588 if (fContentCurRowY >= fHeightLimit + XFA_LAYOUT_FLOAT_PERCISION && | |
2589 XFA_ItemLayoutProcessor_IsTakingSpace(m_pCurChildNode)) { | |
2590 bForceEndPage = TRUE; | |
2591 goto SuspendAndCreateNewRow; | |
2592 } | |
2593 if (m_pCurChildNode->IsContainerNode()) { | |
2594 FX_BOOL bNewRow = FALSE; | |
2595 if (m_pCurChildPreprocessor) { | |
2596 pProcessor = m_pCurChildPreprocessor; | |
2597 m_pCurChildPreprocessor = NULL; | |
2598 bNewRow = TRUE; | |
2599 } else { | |
2600 pProcessor = | |
2601 new CXFA_ItemLayoutProcessor(m_pCurChildNode, m_pPageMgr); | |
2602 } | |
2603 XFA_ItemLayoutProcessor_InsertPendingItems(pProcessor, | |
2604 m_pCurChildNode); | |
2605 XFA_ItemLayoutProcessorResult rs = | |
2606 XFA_ItemLayoutProcessor_InsertFlowedItem( | |
2607 this, pProcessor, bContainerWidthAutoSize, | |
2608 bContainerHeightAutoSize, fContainerHeight, eFlowStrategy, | |
2609 uCurHAlignState, rgCurLineLayoutItems, bUseBreakControl, | |
2610 fAvailHeight, fRealHeight, fContentCurRowY, | |
2611 fContentWidthLimit, fContentCurRowAvailWidth, | |
2612 fContentCurRowHeight, bAddedItemInRow, bForceEndPage, | |
2613 pContext, bNewRow); | |
2614 switch (rs) { | |
2615 case XFA_ItemLayoutProcessorResult_ManualBreak: | |
2616 bIsManualBreak = TRUE; | |
2617 case XFA_ItemLayoutProcessorResult_PageFullBreak: | |
2618 bForceEndPage = TRUE; | |
2619 case XFA_ItemLayoutProcessorResult_RowFullBreak: | |
2620 goto SuspendAndCreateNewRow; | |
2621 case XFA_ItemLayoutProcessorResult_Done: | |
2622 default: | |
2623 fContentCurRowY += XFA_ItemLayoutProcessor_InsertPendingItems( | |
2624 pProcessor, m_pCurChildNode); | |
2625 delete pProcessor; | |
2626 pProcessor = NULL; | |
2627 } | |
2628 } | |
2629 break; | |
2630 case XFA_ItemLayoutProcessorStages_Done: | |
2631 break; | |
2632 default: | |
2633 break; | |
2634 } | |
2635 XFA_ItemLayoutProcessor_GotoNextContainerNode( | |
2636 m_pCurChildNode, m_nCurChildNodeStage, m_pFormNode, TRUE); | |
2637 if (bAddedItemInRow && eFlowStrategy == XFA_ATTRIBUTEENUM_Tb) { | |
2638 break; | |
2639 } else { | |
2640 continue; | |
2641 } | |
2642 SuspendAndCreateNewRow: | |
2643 if (pProcessor) { | |
2644 m_pCurChildPreprocessor = pProcessor; | |
2645 } | |
2646 break; | |
2647 } | |
2648 CalculateRowChildPosition(rgCurLineLayoutItems, eFlowStrategy, | |
2649 bContainerHeightAutoSize, bContainerWidthAutoSize, | |
2650 fContentCalculatedWidth, fContentCalculatedHeight, | |
2651 fContentCurRowY, fContentCurRowHeight, | |
2652 fContentWidthLimit, bRootForceTb); | |
2653 m_fWidthLimite = fContentCurRowAvailWidth; | |
2654 if (bForceEndPage) { | |
2655 break; | |
2656 } | |
2657 } | |
2658 FX_BOOL bRetValue = | |
2659 m_nCurChildNodeStage == XFA_ItemLayoutProcessorStages_Done && | |
2660 m_PendingNodes.empty(); | |
2661 if (bBreakDone) { | |
2662 bRetValue = FALSE; | |
2663 } | |
2664 XFA_ItemLayoutProcessor_CalculateContainerComponentSizeFromContentSize( | |
2665 m_pFormNode, bContainerWidthAutoSize, fContentCalculatedWidth, | |
2666 fContainerWidth, bContainerHeightAutoSize, fContentCalculatedHeight, | |
2667 fContainerHeight); | |
2668 if (fContainerHeight >= XFA_LAYOUT_FLOAT_PERCISION || m_pLayoutItem || | |
2669 bRetValue) { | |
2670 if (m_pLayoutItem == NULL) { | |
2671 m_pLayoutItem = CreateContentLayoutItem(m_pFormNode); | |
2672 } | |
2673 if (fContainerHeight < 0) { | |
2674 fContainerHeight = 0; | |
2675 } | |
2676 SetCurrentComponentSize(fContainerWidth, fContainerHeight); | |
2677 if (bForceEndPage) { | |
2678 m_fUsedSize = 0; | |
2679 } else { | |
2680 m_fUsedSize += m_pLayoutItem->m_sSize.y; | |
2681 } | |
2682 } | |
2683 return bRetValue | |
2684 ? XFA_ItemLayoutProcessorResult_Done | |
2685 : (bIsManualBreak ? XFA_ItemLayoutProcessorResult_ManualBreak | |
2686 : XFA_ItemLayoutProcessorResult_PageFullBreak); | |
2687 } | |
2688 FX_BOOL CXFA_ItemLayoutProcessor::CalculateRowChildPosition( | |
2689 CFX_ArrayTemplate<CXFA_ContentLayoutItem*>(&rgCurLineLayoutItems)[3], | |
2690 XFA_ATTRIBUTEENUM eFlowStrategy, | |
2691 FX_BOOL bContainerHeightAutoSize, | |
2692 FX_BOOL bContainerWidthAutoSize, | |
2693 FX_FLOAT& fContentCalculatedWidth, | |
2694 FX_FLOAT& fContentCalculatedHeight, | |
2695 FX_FLOAT& fContentCurRowY, | |
2696 FX_FLOAT fContentCurRowHeight, | |
2697 FX_FLOAT fContentWidthLimit, | |
2698 FX_BOOL bRootForceTb) { | |
2699 int32_t nGroupLengths[3] = {0, 0, 0}; | |
2700 FX_FLOAT fGroupWidths[3] = {0, 0, 0}; | |
2701 int32_t nTotalLength = 0; | |
2702 for (int32_t i = 0; i < 3; i++) { | |
2703 nGroupLengths[i] = rgCurLineLayoutItems[i].GetSize(); | |
2704 for (int32_t c = nGroupLengths[i], j = 0; j < c; j++) { | |
2705 nTotalLength++; | |
2706 if (XFA_ItemLayoutProcessor_IsTakingSpace( | |
2707 rgCurLineLayoutItems[i][j]->m_pFormNode)) { | |
2708 fGroupWidths[i] += rgCurLineLayoutItems[i][j]->m_sSize.x; | |
2709 } | |
2710 } | |
2711 } | |
2712 if (!nTotalLength) { | |
2713 if (bContainerHeightAutoSize) { | |
2714 FX_FLOAT fNewHeight = fContentCurRowY; | |
2715 if (fContentCalculatedHeight > fNewHeight) { | |
2716 fContentCalculatedHeight = fNewHeight; | |
2717 } | |
2718 } | |
2719 return FALSE; | |
2720 } | |
2721 if (m_pLayoutItem == NULL) { | |
2722 m_pLayoutItem = CreateContentLayoutItem(m_pFormNode); | |
2723 } | |
2724 if (eFlowStrategy != XFA_ATTRIBUTEENUM_Rl_tb) { | |
2725 FX_FLOAT fCurPos; | |
2726 fCurPos = 0; | |
2727 for (int32_t c = nGroupLengths[0], j = 0; j < c; j++) { | |
2728 if (bRootForceTb) { | |
2729 FX_FLOAT fAbsoluteX, fAbsoluteY; | |
2730 CalculatePositionedContainerPos(rgCurLineLayoutItems[0][j]->m_pFormNode, | |
2731 rgCurLineLayoutItems[0][j]->m_sSize.x, | |
2732 rgCurLineLayoutItems[0][j]->m_sSize.y, | |
2733 fAbsoluteX, fAbsoluteY); | |
2734 rgCurLineLayoutItems[0][j]->m_sPos = CFX_PointF(fAbsoluteX, fAbsoluteY); | |
2735 } else { | |
2736 rgCurLineLayoutItems[0][j]->m_sPos = | |
2737 CFX_PointF(fCurPos, fContentCurRowY); | |
2738 if (XFA_ItemLayoutProcessor_IsTakingSpace( | |
2739 rgCurLineLayoutItems[0][j]->m_pFormNode)) { | |
2740 fCurPos += rgCurLineLayoutItems[0][j]->m_sSize.x; | |
2741 } | |
2742 } | |
2743 m_pLayoutItem->AddChild(rgCurLineLayoutItems[0][j]); | |
2744 m_fLastRowWidth = fCurPos; | |
2745 } | |
2746 fCurPos = (fContentWidthLimit + fGroupWidths[0] - fGroupWidths[1] - | |
2747 fGroupWidths[2]) / | |
2748 2; | |
2749 for (int32_t c = nGroupLengths[1], j = 0; j < c; j++) { | |
2750 if (bRootForceTb) { | |
2751 FX_FLOAT fAbsoluteX, fAbsoluteY; | |
2752 CalculatePositionedContainerPos(rgCurLineLayoutItems[1][j]->m_pFormNode, | |
2753 rgCurLineLayoutItems[1][j]->m_sSize.x, | |
2754 rgCurLineLayoutItems[1][j]->m_sSize.y, | |
2755 fAbsoluteX, fAbsoluteY); | |
2756 rgCurLineLayoutItems[1][j]->m_sPos = CFX_PointF(fAbsoluteX, fAbsoluteY); | |
2757 } else { | |
2758 rgCurLineLayoutItems[1][j]->m_sPos = | |
2759 CFX_PointF(fCurPos, fContentCurRowY); | |
2760 if (XFA_ItemLayoutProcessor_IsTakingSpace( | |
2761 rgCurLineLayoutItems[1][j]->m_pFormNode)) { | |
2762 fCurPos += rgCurLineLayoutItems[1][j]->m_sSize.x; | |
2763 } | |
2764 } | |
2765 m_pLayoutItem->AddChild(rgCurLineLayoutItems[1][j]); | |
2766 m_fLastRowWidth = fCurPos; | |
2767 } | |
2768 fCurPos = fContentWidthLimit - fGroupWidths[2]; | |
2769 for (int32_t c = nGroupLengths[2], j = 0; j < c; j++) { | |
2770 if (bRootForceTb) { | |
2771 FX_FLOAT fAbsoluteX, fAbsoluteY; | |
2772 CalculatePositionedContainerPos(rgCurLineLayoutItems[2][j]->m_pFormNode, | |
2773 rgCurLineLayoutItems[2][j]->m_sSize.x, | |
2774 rgCurLineLayoutItems[2][j]->m_sSize.y, | |
2775 fAbsoluteX, fAbsoluteY); | |
2776 rgCurLineLayoutItems[2][j]->m_sPos = CFX_PointF(fAbsoluteX, fAbsoluteY); | |
2777 } else { | |
2778 rgCurLineLayoutItems[2][j]->m_sPos = | |
2779 CFX_PointF(fCurPos, fContentCurRowY); | |
2780 if (XFA_ItemLayoutProcessor_IsTakingSpace( | |
2781 rgCurLineLayoutItems[2][j]->m_pFormNode)) { | |
2782 fCurPos += rgCurLineLayoutItems[2][j]->m_sSize.x; | |
2783 } | |
2784 } | |
2785 m_pLayoutItem->AddChild(rgCurLineLayoutItems[2][j]); | |
2786 m_fLastRowWidth = fCurPos; | |
2787 } | |
2788 } else { | |
2789 FX_FLOAT fCurPos; | |
2790 fCurPos = fGroupWidths[0]; | |
2791 for (int32_t c = nGroupLengths[0], j = 0; j < c; j++) { | |
2792 if (XFA_ItemLayoutProcessor_IsTakingSpace( | |
2793 rgCurLineLayoutItems[0][j]->m_pFormNode)) { | |
2794 fCurPos -= rgCurLineLayoutItems[0][j]->m_sSize.x; | |
2795 } | |
2796 rgCurLineLayoutItems[0][j]->m_sPos = CFX_PointF(fCurPos, fContentCurRowY); | |
2797 m_pLayoutItem->AddChild(rgCurLineLayoutItems[0][j]); | |
2798 m_fLastRowWidth = fCurPos; | |
2799 } | |
2800 fCurPos = (fContentWidthLimit + fGroupWidths[0] + fGroupWidths[1] - | |
2801 fGroupWidths[2]) / | |
2802 2; | |
2803 for (int32_t c = nGroupLengths[1], j = 0; j < c; j++) { | |
2804 if (XFA_ItemLayoutProcessor_IsTakingSpace( | |
2805 rgCurLineLayoutItems[1][j]->m_pFormNode)) { | |
2806 fCurPos -= rgCurLineLayoutItems[1][j]->m_sSize.x; | |
2807 } | |
2808 rgCurLineLayoutItems[1][j]->m_sPos = CFX_PointF(fCurPos, fContentCurRowY); | |
2809 m_pLayoutItem->AddChild(rgCurLineLayoutItems[1][j]); | |
2810 m_fLastRowWidth = fCurPos; | |
2811 } | |
2812 fCurPos = fContentWidthLimit; | |
2813 for (int32_t c = nGroupLengths[2], j = 0; j < c; j++) { | |
2814 if (XFA_ItemLayoutProcessor_IsTakingSpace( | |
2815 rgCurLineLayoutItems[2][j]->m_pFormNode)) { | |
2816 fCurPos -= rgCurLineLayoutItems[2][j]->m_sSize.x; | |
2817 } | |
2818 rgCurLineLayoutItems[2][j]->m_sPos = CFX_PointF(fCurPos, fContentCurRowY); | |
2819 m_pLayoutItem->AddChild(rgCurLineLayoutItems[2][j]); | |
2820 m_fLastRowWidth = fCurPos; | |
2821 } | |
2822 } | |
2823 m_fLastRowY = fContentCurRowY; | |
2824 fContentCurRowY += fContentCurRowHeight; | |
2825 if (bContainerWidthAutoSize) { | |
2826 FX_FLOAT fChildSuppliedWidth = fGroupWidths[0]; | |
2827 if (fContentWidthLimit < XFA_LAYOUT_FLOAT_MAX && | |
2828 fContentWidthLimit > fChildSuppliedWidth) { | |
2829 fChildSuppliedWidth = fContentWidthLimit; | |
2830 } | |
2831 if (fContentCalculatedWidth < fChildSuppliedWidth) { | |
2832 fContentCalculatedWidth = fChildSuppliedWidth; | |
2833 } | |
2834 } | |
2835 if (bContainerHeightAutoSize) { | |
2836 FX_FLOAT fChildSuppliedHeight = fContentCurRowY; | |
2837 if (fContentCalculatedHeight < fChildSuppliedHeight) { | |
2838 fContentCalculatedHeight = fChildSuppliedHeight; | |
2839 } | |
2840 } | |
2841 return TRUE; | |
2842 } | |
2843 CXFA_Node* CXFA_ItemLayoutProcessor::GetSubformSetParent( | |
2844 CXFA_Node* pSubformSet) { | |
2845 if (pSubformSet && pSubformSet->GetClassID() == XFA_ELEMENT_SubformSet) { | |
2846 CXFA_Node* pParent = pSubformSet->GetNodeItem(XFA_NODEITEM_Parent); | |
2847 while (pParent) { | |
2848 if (pParent->GetClassID() != XFA_ELEMENT_SubformSet) { | |
2849 return pParent; | |
2850 } | |
2851 pParent = pParent->GetNodeItem(XFA_NODEITEM_Parent); | |
2852 } | |
2853 } | |
2854 return pSubformSet; | |
2855 } | |
2856 void CXFA_ItemLayoutProcessor::DoLayoutField() { | |
2857 if (m_pLayoutItem) | |
2858 return; | |
2859 | |
2860 ASSERT(m_pCurChildNode == XFA_LAYOUT_INVALIDNODE); | |
2861 m_pLayoutItem = CreateContentLayoutItem(m_pFormNode); | |
2862 if (!m_pLayoutItem) { | |
2863 return; | |
2864 } | |
2865 CXFA_Document* pDocument = m_pFormNode->GetDocument(); | |
2866 IXFA_Notify* pNotify = pDocument->GetParser()->GetNotify(); | |
2867 FX_FLOAT fHeight = -1; | |
2868 FX_FLOAT fWidth = -1; | |
2869 pNotify->StartFieldDrawLayout(m_pFormNode, fWidth, fHeight); | |
2870 int32_t nRotate = | |
2871 FXSYS_round(m_pFormNode->GetMeasure(XFA_ATTRIBUTE_Rotate).GetValue()); | |
2872 nRotate = XFA_MapRotation(nRotate); | |
2873 if (nRotate == 90 || nRotate == 270) { | |
2874 FX_FLOAT fTmp = fWidth; | |
2875 fWidth = fHeight; | |
2876 fHeight = fTmp; | |
2877 } | |
2878 SetCurrentComponentSize(fWidth, fHeight); | |
2879 } | |
2880 XFA_ItemLayoutProcessorResult CXFA_ItemLayoutProcessor::DoLayout( | |
2881 FX_BOOL bUseBreakControl, | |
2882 FX_FLOAT fHeightLimit, | |
2883 FX_FLOAT fRealHeight, | |
2884 CXFA_LayoutContext* pContext) { | |
2885 XFA_ELEMENT eClassID = m_pFormNode->GetClassID(); | |
2886 switch (eClassID) { | |
2887 case XFA_ELEMENT_Subform: | |
2888 case XFA_ELEMENT_Area: | |
2889 case XFA_ELEMENT_ExclGroup: | |
2890 case XFA_ELEMENT_SubformSet: { | |
2891 FX_BOOL bRootForceTb = FALSE; | |
2892 CXFA_Node* pLayoutNode = GetSubformSetParent(m_pFormNode); | |
2893 XFA_ATTRIBUTEENUM eLayoutStrategy = | |
2894 XFA_ItemLayoutProcessor_GetLayout(pLayoutNode, bRootForceTb); | |
2895 switch (eLayoutStrategy) { | |
2896 case XFA_ATTRIBUTEENUM_Tb: | |
2897 case XFA_ATTRIBUTEENUM_Lr_tb: | |
2898 case XFA_ATTRIBUTEENUM_Rl_tb: | |
2899 return DoLayoutFlowedContainer(bUseBreakControl, eLayoutStrategy, | |
2900 fHeightLimit, fRealHeight, pContext, | |
2901 bRootForceTb); | |
2902 case XFA_ATTRIBUTEENUM_Position: | |
2903 case XFA_ATTRIBUTEENUM_Row: | |
2904 case XFA_ATTRIBUTEENUM_Rl_row: | |
2905 default: | |
2906 DoLayoutPositionedContainer(pContext); | |
2907 m_nCurChildNodeStage = XFA_ItemLayoutProcessorStages_Done; | |
2908 return XFA_ItemLayoutProcessorResult_Done; | |
2909 case XFA_ATTRIBUTEENUM_Table: | |
2910 DoLayoutTableContainer(pLayoutNode); | |
2911 m_nCurChildNodeStage = XFA_ItemLayoutProcessorStages_Done; | |
2912 return XFA_ItemLayoutProcessorResult_Done; | |
2913 } | |
2914 } | |
2915 case XFA_ELEMENT_Draw: | |
2916 case XFA_ELEMENT_Field: | |
2917 DoLayoutField(); | |
2918 m_nCurChildNodeStage = XFA_ItemLayoutProcessorStages_Done; | |
2919 return XFA_ItemLayoutProcessorResult_Done; | |
2920 case XFA_ELEMENT_ContentArea: | |
2921 return XFA_ItemLayoutProcessorResult_Done; | |
2922 default: | |
2923 return XFA_ItemLayoutProcessorResult_Done; | |
2924 } | |
2925 } | |
2926 void CXFA_ItemLayoutProcessor::GetCurrentComponentPos(FX_FLOAT& fAbsoluteX, | |
2927 FX_FLOAT& fAbsoluteY) { | |
2928 ASSERT(m_pLayoutItem); | |
2929 fAbsoluteX = m_pLayoutItem->m_sPos.x; | |
2930 fAbsoluteY = m_pLayoutItem->m_sPos.y; | |
2931 } | |
2932 void CXFA_ItemLayoutProcessor::GetCurrentComponentSize(FX_FLOAT& fWidth, | |
2933 FX_FLOAT& fHeight) { | |
2934 ASSERT(m_pLayoutItem); | |
2935 fWidth = m_pLayoutItem->m_sSize.x; | |
2936 fHeight = m_pLayoutItem->m_sSize.y; | |
2937 } | |
2938 void CXFA_ItemLayoutProcessor::SetCurrentComponentPos(FX_FLOAT fAbsoluteX, | |
2939 FX_FLOAT fAbsoluteY) { | |
2940 m_pLayoutItem->m_sPos = CFX_PointF(fAbsoluteX, fAbsoluteY); | |
2941 } | |
2942 void CXFA_ItemLayoutProcessor::SetCurrentComponentSize(FX_FLOAT fWidth, | |
2943 FX_FLOAT fHeight) { | |
2944 m_pLayoutItem->m_sSize = CFX_SizeF(fWidth, fHeight); | |
2945 } | |
2946 FX_BOOL CXFA_ItemLayoutProcessor::JudgeLeaderOrTrailerForOccur( | |
2947 CXFA_Node* pFormNode) { | |
2948 if (pFormNode == NULL) { | |
2949 return FALSE; | |
2950 } | |
2951 CXFA_Node* pTemplate = pFormNode->GetTemplateNode(); | |
2952 if (!pTemplate) { | |
2953 pTemplate = pFormNode; | |
2954 } | |
2955 CXFA_Occur NodeOccur(pTemplate->GetFirstChildByClass(XFA_ELEMENT_Occur)); | |
2956 int32_t iMax = NodeOccur.GetMax(); | |
2957 if (iMax > -1) { | |
2958 int32_t iCount = | |
2959 (int32_t)(uintptr_t)m_PendingNodesCount.GetValueAt(pTemplate); | |
2960 if (iCount >= iMax) { | |
2961 return FALSE; | |
2962 } | |
2963 iCount++; | |
2964 m_PendingNodesCount.SetAt(pTemplate, (void*)(uintptr_t)(iCount)); | |
2965 return TRUE; | |
2966 } | |
2967 return TRUE; | |
2968 } | |
OLD | NEW |