| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #include "xfa/fxfa/parser/xfa_layout_pagemgr_new.h" | 7 #include "xfa/fxfa/parser/cxfa_layoutpagemgr.h" |
| 8 | 8 |
| 9 #include "xfa/fxfa/app/xfa_ffnotify.h" | 9 #include "xfa/fxfa/app/xfa_ffnotify.h" |
| 10 #include "xfa/fxfa/parser/cxfa_containerlayoutitem.h" | 10 #include "xfa/fxfa/parser/cxfa_containerlayoutitem.h" |
| 11 #include "xfa/fxfa/parser/cxfa_contentlayoutitem.h" | 11 #include "xfa/fxfa/parser/cxfa_contentlayoutitem.h" |
| 12 #include "xfa/fxfa/parser/cxfa_document.h" | 12 #include "xfa/fxfa/parser/cxfa_document.h" |
| 13 #include "xfa/fxfa/parser/cxfa_layoutprocessor.h" | 13 #include "xfa/fxfa/parser/cxfa_layoutprocessor.h" |
| 14 #include "xfa/fxfa/parser/cxfa_measurement.h" | 14 #include "xfa/fxfa/parser/cxfa_measurement.h" |
| 15 #include "xfa/fxfa/parser/cxfa_scriptcontext.h" | 15 #include "xfa/fxfa/parser/cxfa_scriptcontext.h" |
| 16 #include "xfa/fxfa/parser/cxfa_traversestrategy_contentareacontainerlayoutitem.h
" | 16 #include "xfa/fxfa/parser/cxfa_traversestrategy_contentareacontainerlayoutitem.h
" |
| 17 #include "xfa/fxfa/parser/cxfa_traversestrategy_layoutitem.h" | 17 #include "xfa/fxfa/parser/cxfa_traversestrategy_layoutitem.h" |
| 18 #include "xfa/fxfa/parser/xfa_document_datamerger_imp.h" | 18 #include "xfa/fxfa/parser/xfa_document_datamerger_imp.h" |
| 19 #include "xfa/fxfa/parser/xfa_layout_itemlayout.h" | 19 #include "xfa/fxfa/parser/xfa_layout_itemlayout.h" |
| 20 #include "xfa/fxfa/parser/xfa_localemgr.h" | 20 #include "xfa/fxfa/parser/xfa_localemgr.h" |
| 21 #include "xfa/fxfa/parser/xfa_object.h" | 21 #include "xfa/fxfa/parser/xfa_object.h" |
| 22 #include "xfa/fxfa/parser/xfa_resolvenode_rs.h" | 22 #include "xfa/fxfa/parser/xfa_resolvenode_rs.h" |
| 23 #include "xfa/fxfa/parser/xfa_utils.h" | 23 #include "xfa/fxfa/parser/xfa_utils.h" |
| 24 | 24 |
| 25 namespace { | 25 namespace { |
| 26 | 26 |
| 27 class PageSetContainerLayoutItem { | 27 class PageSetContainerLayoutItem { |
| 28 public: | 28 public: |
| 29 static inline CXFA_ContainerLayoutItem* GetFirstChild( | 29 static CXFA_ContainerLayoutItem* GetFirstChild( |
| 30 CXFA_ContainerLayoutItem* pLayoutItem) { | 30 CXFA_ContainerLayoutItem* pLayoutItem) { |
| 31 if (pLayoutItem->m_pFormNode->GetElementType() != XFA_Element::PageSet) | 31 if (pLayoutItem->m_pFormNode->GetElementType() != XFA_Element::PageSet) |
| 32 return nullptr; | 32 return nullptr; |
| 33 | 33 |
| 34 CXFA_ContainerLayoutItem* pChildItem = | 34 CXFA_ContainerLayoutItem* pChildItem = |
| 35 static_cast<CXFA_ContainerLayoutItem*>(pLayoutItem->m_pFirstChild); | 35 static_cast<CXFA_ContainerLayoutItem*>(pLayoutItem->m_pFirstChild); |
| 36 while (pChildItem && | 36 while (pChildItem && |
| 37 pChildItem->m_pFormNode->GetElementType() != XFA_Element::PageSet) { | 37 pChildItem->m_pFormNode->GetElementType() != XFA_Element::PageSet) { |
| 38 pChildItem = | 38 pChildItem = |
| 39 static_cast<CXFA_ContainerLayoutItem*>(pChildItem->m_pNextSibling); | 39 static_cast<CXFA_ContainerLayoutItem*>(pChildItem->m_pNextSibling); |
| 40 } | 40 } |
| 41 return pChildItem; | 41 return pChildItem; |
| 42 } | 42 } |
| 43 | 43 |
| 44 static inline CXFA_ContainerLayoutItem* GetNextSibling( | 44 static CXFA_ContainerLayoutItem* GetNextSibling( |
| 45 CXFA_ContainerLayoutItem* pLayoutItem) { | 45 CXFA_ContainerLayoutItem* pLayoutItem) { |
| 46 CXFA_ContainerLayoutItem* pChildItem = | 46 CXFA_ContainerLayoutItem* pChildItem = |
| 47 static_cast<CXFA_ContainerLayoutItem*>(pLayoutItem->m_pNextSibling); | 47 static_cast<CXFA_ContainerLayoutItem*>(pLayoutItem->m_pNextSibling); |
| 48 while (pChildItem && | 48 while (pChildItem && |
| 49 pChildItem->m_pFormNode->GetElementType() != XFA_Element::PageSet) { | 49 pChildItem->m_pFormNode->GetElementType() != XFA_Element::PageSet) { |
| 50 pChildItem = | 50 pChildItem = |
| 51 static_cast<CXFA_ContainerLayoutItem*>(pChildItem->m_pNextSibling); | 51 static_cast<CXFA_ContainerLayoutItem*>(pChildItem->m_pNextSibling); |
| 52 } | 52 } |
| 53 return pChildItem; | 53 return pChildItem; |
| 54 } | 54 } |
| 55 | 55 |
| 56 static inline CXFA_ContainerLayoutItem* GetParent( | 56 static CXFA_ContainerLayoutItem* GetParent( |
| 57 CXFA_ContainerLayoutItem* pLayoutItem) { | 57 CXFA_ContainerLayoutItem* pLayoutItem) { |
| 58 return static_cast<CXFA_ContainerLayoutItem*>(pLayoutItem->m_pParent); | 58 return static_cast<CXFA_ContainerLayoutItem*>(pLayoutItem->m_pParent); |
| 59 } | 59 } |
| 60 }; | 60 }; |
| 61 | 61 |
| 62 uint32_t GetRelevant(CXFA_Node* pFormItem, uint32_t dwParentRelvant) { | 62 uint32_t GetRelevant(CXFA_Node* pFormItem, uint32_t dwParentRelvant) { |
| 63 uint32_t dwRelevant = XFA_WidgetStatus_Viewable | XFA_WidgetStatus_Printable; | 63 uint32_t dwRelevant = XFA_WidgetStatus_Viewable | XFA_WidgetStatus_Printable; |
| 64 CFX_WideStringC wsRelevant; | 64 CFX_WideStringC wsRelevant; |
| 65 if (pFormItem->TryCData(XFA_ATTRIBUTE_Relevant, wsRelevant)) { | 65 if (pFormItem->TryCData(XFA_ATTRIBUTE_Relevant, wsRelevant)) { |
| 66 if (wsRelevant == FX_WSTRC(L"+print") || wsRelevant == FX_WSTRC(L"print")) | 66 if (wsRelevant == FX_WSTRC(L"+print") || wsRelevant == FX_WSTRC(L"print")) |
| 67 dwRelevant &= ~XFA_WidgetStatus_Viewable; | 67 dwRelevant &= ~XFA_WidgetStatus_Viewable; |
| 68 else if (wsRelevant == FX_WSTRC(L"-print")) | 68 else if (wsRelevant == FX_WSTRC(L"-print")) |
| 69 dwRelevant &= ~XFA_WidgetStatus_Printable; | 69 dwRelevant &= ~XFA_WidgetStatus_Printable; |
| 70 } | 70 } |
| 71 |
| 71 if (!(dwParentRelvant & XFA_WidgetStatus_Viewable) && | 72 if (!(dwParentRelvant & XFA_WidgetStatus_Viewable) && |
| 72 (dwRelevant != XFA_WidgetStatus_Viewable)) { | 73 (dwRelevant != XFA_WidgetStatus_Viewable)) { |
| 73 dwRelevant &= ~XFA_WidgetStatus_Viewable; | 74 dwRelevant &= ~XFA_WidgetStatus_Viewable; |
| 74 } | 75 } |
| 76 |
| 75 if (!(dwParentRelvant & XFA_WidgetStatus_Printable) && | 77 if (!(dwParentRelvant & XFA_WidgetStatus_Printable) && |
| 76 (dwRelevant != XFA_WidgetStatus_Printable)) { | 78 (dwRelevant != XFA_WidgetStatus_Printable)) { |
| 77 dwRelevant &= ~XFA_WidgetStatus_Printable; | 79 dwRelevant &= ~XFA_WidgetStatus_Printable; |
| 78 } | 80 } |
| 79 return dwRelevant; | 81 return dwRelevant; |
| 80 } | 82 } |
| 81 | 83 |
| 82 void SyncContainer(CXFA_FFNotify* pNotify, | 84 void SyncContainer(CXFA_FFNotify* pNotify, |
| 83 CXFA_LayoutProcessor* pDocLayout, | 85 CXFA_LayoutProcessor* pDocLayout, |
| 84 CXFA_LayoutItem* pContainerItem, | 86 CXFA_LayoutItem* pContainerItem, |
| (...skipping 19 matching lines...) Expand all Loading... |
| 104 pChild = pChild->m_pNextSibling) { | 106 pChild = pChild->m_pNextSibling) { |
| 105 if (pChild->IsContentLayoutItem()) { | 107 if (pChild->IsContentLayoutItem()) { |
| 106 SyncContainer(pNotify, pDocLayout, pChild, dwRelevantContainer, | 108 SyncContainer(pNotify, pDocLayout, pChild, dwRelevantContainer, |
| 107 bVisibleItem, nPageIndex); | 109 bVisibleItem, nPageIndex); |
| 108 } | 110 } |
| 109 } | 111 } |
| 110 } | 112 } |
| 111 | 113 |
| 112 void ReorderLayoutItemToTail(CXFA_ContainerLayoutItem* pLayoutItem) { | 114 void ReorderLayoutItemToTail(CXFA_ContainerLayoutItem* pLayoutItem) { |
| 113 CXFA_ContainerLayoutItem* pParentLayoutItem = | 115 CXFA_ContainerLayoutItem* pParentLayoutItem = |
| 114 (CXFA_ContainerLayoutItem*)pLayoutItem->m_pParent; | 116 static_cast<CXFA_ContainerLayoutItem*>(pLayoutItem->m_pParent); |
| 115 if (!pParentLayoutItem) | 117 if (!pParentLayoutItem) |
| 116 return; | 118 return; |
| 117 | 119 |
| 118 pParentLayoutItem->RemoveChild(pLayoutItem); | 120 pParentLayoutItem->RemoveChild(pLayoutItem); |
| 119 pParentLayoutItem->AddChild(pLayoutItem); | 121 pParentLayoutItem->AddChild(pLayoutItem); |
| 120 } | 122 } |
| 121 | 123 |
| 122 void RemoveLayoutItem(CXFA_ContainerLayoutItem* pLayoutItem) { | 124 void RemoveLayoutItem(CXFA_ContainerLayoutItem* pLayoutItem) { |
| 123 CXFA_ContainerLayoutItem* pParentLayoutItem = | 125 CXFA_ContainerLayoutItem* pParentLayoutItem = |
| 124 (CXFA_ContainerLayoutItem*)pLayoutItem->m_pParent; | 126 static_cast<CXFA_ContainerLayoutItem*>(pLayoutItem->m_pParent); |
| 125 if (!pParentLayoutItem) | 127 if (!pParentLayoutItem) |
| 126 return; | 128 return; |
| 127 | 129 |
| 128 pParentLayoutItem->RemoveChild(pLayoutItem); | 130 pParentLayoutItem->RemoveChild(pLayoutItem); |
| 129 } | 131 } |
| 130 | 132 |
| 131 CXFA_Node* ResolveBreakTarget(CXFA_Node* pPageSetRoot, | 133 CXFA_Node* ResolveBreakTarget(CXFA_Node* pPageSetRoot, |
| 132 FX_BOOL bNewExprStyle, | 134 FX_BOOL bNewExprStyle, |
| 133 CFX_WideStringC& wsTargetExpr) { | 135 CFX_WideStringC& wsTargetExpr) { |
| 134 CXFA_Document* pDocument = pPageSetRoot->GetDocument(); | 136 CXFA_Document* pDocument = pPageSetRoot->GetDocument(); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 void SetLayoutGeneratedNodeFlag(CXFA_Node* pNode) { | 184 void SetLayoutGeneratedNodeFlag(CXFA_Node* pNode) { |
| 183 pNode->SetFlag(XFA_NodeFlag_LayoutGeneratedNode, false); | 185 pNode->SetFlag(XFA_NodeFlag_LayoutGeneratedNode, false); |
| 184 pNode->ClearFlag(XFA_NodeFlag_UnusedNode); | 186 pNode->ClearFlag(XFA_NodeFlag_UnusedNode); |
| 185 } | 187 } |
| 186 | 188 |
| 187 FX_BOOL CheckContentAreaNotUsed( | 189 FX_BOOL CheckContentAreaNotUsed( |
| 188 CXFA_ContainerLayoutItem* pPageAreaLayoutItem, | 190 CXFA_ContainerLayoutItem* pPageAreaLayoutItem, |
| 189 CXFA_Node* pContentArea, | 191 CXFA_Node* pContentArea, |
| 190 CXFA_ContainerLayoutItem*& pContentAreaLayoutItem) { | 192 CXFA_ContainerLayoutItem*& pContentAreaLayoutItem) { |
| 191 for (CXFA_ContainerLayoutItem* pLayoutItem = | 193 for (CXFA_ContainerLayoutItem* pLayoutItem = |
| 192 (CXFA_ContainerLayoutItem*)pPageAreaLayoutItem->m_pFirstChild; | 194 static_cast<CXFA_ContainerLayoutItem*>( |
| 193 pLayoutItem; | 195 pPageAreaLayoutItem->m_pFirstChild); |
| 194 pLayoutItem = (CXFA_ContainerLayoutItem*)pLayoutItem->m_pNextSibling) { | 196 pLayoutItem; pLayoutItem = static_cast<CXFA_ContainerLayoutItem*>( |
| 197 pLayoutItem->m_pNextSibling)) { |
| 195 if (pLayoutItem->m_pFormNode == pContentArea) { | 198 if (pLayoutItem->m_pFormNode == pContentArea) { |
| 196 if (!pLayoutItem->m_pFirstChild) { | 199 if (!pLayoutItem->m_pFirstChild) { |
| 197 pContentAreaLayoutItem = pLayoutItem; | 200 pContentAreaLayoutItem = pLayoutItem; |
| 198 return TRUE; | 201 return TRUE; |
| 199 } | 202 } |
| 200 return FALSE; | 203 return FALSE; |
| 201 } | 204 } |
| 202 } | 205 } |
| 203 return TRUE; | 206 return TRUE; |
| 204 } | 207 } |
| 205 | 208 |
| 206 void SyncRemoveLayoutItem(CXFA_LayoutItem* pParentLayoutItem, | 209 void SyncRemoveLayoutItem(CXFA_LayoutItem* pParentLayoutItem, |
| 207 CXFA_FFNotify* pNotify, | 210 CXFA_FFNotify* pNotify, |
| 208 CXFA_LayoutProcessor* pDocLayout) { | 211 CXFA_LayoutProcessor* pDocLayout) { |
| 209 CXFA_LayoutItem* pNextLayoutItem; | 212 CXFA_LayoutItem* pNextLayoutItem; |
| 210 CXFA_LayoutItem* pCurLayoutItem = pParentLayoutItem->m_pFirstChild; | 213 CXFA_LayoutItem* pCurLayoutItem = pParentLayoutItem->m_pFirstChild; |
| 211 while (pCurLayoutItem) { | 214 while (pCurLayoutItem) { |
| 212 pNextLayoutItem = pCurLayoutItem->m_pNextSibling; | 215 pNextLayoutItem = pCurLayoutItem->m_pNextSibling; |
| 213 if (pCurLayoutItem->m_pFirstChild) | 216 if (pCurLayoutItem->m_pFirstChild) |
| 214 SyncRemoveLayoutItem(pCurLayoutItem, pNotify, pDocLayout); | 217 SyncRemoveLayoutItem(pCurLayoutItem, pNotify, pDocLayout); |
| 215 | 218 |
| 216 pNotify->OnLayoutItemRemoving(pDocLayout, pCurLayoutItem); | 219 pNotify->OnLayoutItemRemoving(pDocLayout, pCurLayoutItem); |
| 217 delete pCurLayoutItem; | 220 delete pCurLayoutItem; |
| 218 pCurLayoutItem = pNextLayoutItem; | 221 pCurLayoutItem = pNextLayoutItem; |
| 219 } | 222 } |
| 220 } | 223 } |
| 221 | 224 |
| 222 } // namespace | 225 } // namespace |
| 223 | 226 |
| 227 class CXFA_ContainerRecord { |
| 228 public: |
| 229 CXFA_ContainerRecord(CXFA_ContainerLayoutItem* pPageSet = nullptr, |
| 230 CXFA_ContainerLayoutItem* pPageArea = nullptr, |
| 231 CXFA_ContainerLayoutItem* pContentArea = nullptr) |
| 232 : pCurPageSet(pPageSet), |
| 233 pCurPageArea(pPageArea), |
| 234 pCurContentArea(pContentArea) {} |
| 235 |
| 236 CXFA_ContainerLayoutItem* pCurPageSet; |
| 237 CXFA_ContainerLayoutItem* pCurPageArea; |
| 238 CXFA_ContainerLayoutItem* pCurContentArea; |
| 239 }; |
| 240 |
| 224 CXFA_LayoutPageMgr::CXFA_LayoutPageMgr(CXFA_LayoutProcessor* pLayoutProcessor) | 241 CXFA_LayoutPageMgr::CXFA_LayoutPageMgr(CXFA_LayoutProcessor* pLayoutProcessor) |
| 225 : m_pLayoutProcessor(pLayoutProcessor), | 242 : m_pLayoutProcessor(pLayoutProcessor), |
| 226 m_pTemplatePageSetRoot(nullptr), | 243 m_pTemplatePageSetRoot(nullptr), |
| 227 m_pPageSetLayoutItemRoot(nullptr), | 244 m_pPageSetLayoutItemRoot(nullptr), |
| 228 m_pPageSetCurRoot(nullptr), | 245 m_pPageSetCurRoot(nullptr), |
| 229 m_pCurrentContainerRecord(nullptr), | 246 m_pCurrentContainerRecord(nullptr), |
| 230 m_pCurPageArea(nullptr), | 247 m_pCurPageArea(nullptr), |
| 231 m_nAvailPages(0), | 248 m_nAvailPages(0), |
| 232 m_nCurPageCount(0), | 249 m_nCurPageCount(0), |
| 233 m_ePageSetMode(XFA_ATTRIBUTEENUM_OrderedOccurrence), | 250 m_ePageSetMode(XFA_ATTRIBUTEENUM_OrderedOccurrence), |
| 234 m_bCreateOverFlowPage(FALSE) {} | 251 m_bCreateOverFlowPage(FALSE) {} |
| 252 |
| 235 CXFA_LayoutPageMgr::~CXFA_LayoutPageMgr() { | 253 CXFA_LayoutPageMgr::~CXFA_LayoutPageMgr() { |
| 236 ClearData(); | 254 ClearData(); |
| 237 CXFA_LayoutItem* pLayoutItem = GetRootLayoutItem(); | 255 CXFA_LayoutItem* pLayoutItem = GetRootLayoutItem(); |
| 238 CXFA_LayoutItem* pNextLayout = nullptr; | 256 CXFA_LayoutItem* pNextLayout = nullptr; |
| 239 for (; pLayoutItem; pLayoutItem = pNextLayout) { | 257 for (; pLayoutItem; pLayoutItem = pNextLayout) { |
| 240 pNextLayout = pLayoutItem->m_pNextSibling; | 258 pNextLayout = pLayoutItem->m_pNextSibling; |
| 241 XFA_ReleaseLayoutItem(pLayoutItem); | 259 XFA_ReleaseLayoutItem(pLayoutItem); |
| 242 } | 260 } |
| 243 } | 261 } |
| 262 |
| 244 FX_BOOL CXFA_LayoutPageMgr::InitLayoutPage(CXFA_Node* pFormNode) { | 263 FX_BOOL CXFA_LayoutPageMgr::InitLayoutPage(CXFA_Node* pFormNode) { |
| 245 PrepareLayout(); | 264 PrepareLayout(); |
| 246 CXFA_Node* pTemplateNode = pFormNode->GetTemplateNode(); | 265 CXFA_Node* pTemplateNode = pFormNode->GetTemplateNode(); |
| 247 if (!pTemplateNode) { | 266 if (!pTemplateNode) |
| 248 return FALSE; | 267 return FALSE; |
| 249 } | 268 |
| 250 m_pTemplatePageSetRoot = pTemplateNode->GetProperty(0, XFA_Element::PageSet); | 269 m_pTemplatePageSetRoot = pTemplateNode->GetProperty(0, XFA_Element::PageSet); |
| 251 ASSERT(m_pTemplatePageSetRoot); | 270 ASSERT(m_pTemplatePageSetRoot); |
| 252 if (m_pPageSetLayoutItemRoot) { | 271 if (m_pPageSetLayoutItemRoot) { |
| 253 m_pPageSetLayoutItemRoot->m_pParent = nullptr; | 272 m_pPageSetLayoutItemRoot->m_pParent = nullptr; |
| 254 m_pPageSetLayoutItemRoot->m_pFirstChild = nullptr; | 273 m_pPageSetLayoutItemRoot->m_pFirstChild = nullptr; |
| 255 m_pPageSetLayoutItemRoot->m_pNextSibling = nullptr; | 274 m_pPageSetLayoutItemRoot->m_pNextSibling = nullptr; |
| 256 m_pPageSetLayoutItemRoot->m_pFormNode = m_pTemplatePageSetRoot; | 275 m_pPageSetLayoutItemRoot->m_pFormNode = m_pTemplatePageSetRoot; |
| 257 } else { | 276 } else { |
| 258 m_pPageSetLayoutItemRoot = | 277 m_pPageSetLayoutItemRoot = |
| 259 new CXFA_ContainerLayoutItem(m_pTemplatePageSetRoot); | 278 new CXFA_ContainerLayoutItem(m_pTemplatePageSetRoot); |
| 260 } | 279 } |
| 261 m_pPageSetCurRoot = m_pPageSetLayoutItemRoot; | 280 m_pPageSetCurRoot = m_pPageSetLayoutItemRoot; |
| 262 m_pTemplatePageSetRoot->SetUserData(XFA_LAYOUTITEMKEY, | 281 m_pTemplatePageSetRoot->SetUserData(XFA_LAYOUTITEMKEY, |
| 263 (void*)m_pPageSetLayoutItemRoot); | 282 (void*)m_pPageSetLayoutItemRoot); |
| 264 XFA_ATTRIBUTEENUM eRelation = | 283 XFA_ATTRIBUTEENUM eRelation = |
| 265 m_pTemplatePageSetRoot->GetEnum(XFA_ATTRIBUTE_Relation); | 284 m_pTemplatePageSetRoot->GetEnum(XFA_ATTRIBUTE_Relation); |
| 266 if (eRelation != XFA_ATTRIBUTEENUM_Unknown) { | 285 if (eRelation != XFA_ATTRIBUTEENUM_Unknown) |
| 267 m_ePageSetMode = eRelation; | 286 m_ePageSetMode = eRelation; |
| 268 } | 287 |
| 269 InitPageSetMap(); | 288 InitPageSetMap(); |
| 270 CXFA_Node* pPageArea = nullptr; | 289 CXFA_Node* pPageArea = nullptr; |
| 271 int32_t iCount = 0; | 290 int32_t iCount = 0; |
| 272 for (pPageArea = m_pTemplatePageSetRoot->GetNodeItem(XFA_NODEITEM_FirstChild); | 291 for (pPageArea = m_pTemplatePageSetRoot->GetNodeItem(XFA_NODEITEM_FirstChild); |
| 273 pPageArea; | 292 pPageArea; |
| 274 pPageArea = pPageArea->GetNodeItem(XFA_NODEITEM_NextSibling)) { | 293 pPageArea = pPageArea->GetNodeItem(XFA_NODEITEM_NextSibling)) { |
| 275 if (pPageArea->GetElementType() == XFA_Element::PageArea) { | 294 if (pPageArea->GetElementType() == XFA_Element::PageArea) { |
| 276 iCount++; | 295 iCount++; |
| 277 if (pPageArea->GetFirstChildByClass(XFA_Element::ContentArea)) { | 296 if (pPageArea->GetFirstChildByClass(XFA_Element::ContentArea)) |
| 278 return TRUE; | 297 return TRUE; |
| 279 } | |
| 280 } | 298 } |
| 281 } | 299 } |
| 282 if (iCount > 0) { | 300 if (iCount > 0) |
| 283 return FALSE; | 301 return FALSE; |
| 284 } | 302 |
| 285 CXFA_Document* pDocument = pTemplateNode->GetDocument(); | 303 CXFA_Document* pDocument = pTemplateNode->GetDocument(); |
| 286 pPageArea = m_pTemplatePageSetRoot->GetChild(0, XFA_Element::PageArea); | 304 pPageArea = m_pTemplatePageSetRoot->GetChild(0, XFA_Element::PageArea); |
| 287 if (!pPageArea) { | 305 if (!pPageArea) { |
| 288 pPageArea = pDocument->CreateNode(m_pTemplatePageSetRoot->GetPacketID(), | 306 pPageArea = pDocument->CreateNode(m_pTemplatePageSetRoot->GetPacketID(), |
| 289 XFA_Element::PageArea); | 307 XFA_Element::PageArea); |
| 290 if (!pPageArea) { | 308 if (!pPageArea) |
| 291 return FALSE; | 309 return FALSE; |
| 292 } | 310 |
| 293 m_pTemplatePageSetRoot->InsertChild(pPageArea, nullptr); | 311 m_pTemplatePageSetRoot->InsertChild(pPageArea, nullptr); |
| 294 pPageArea->SetFlag(XFA_NodeFlag_Initialized, true); | 312 pPageArea->SetFlag(XFA_NodeFlag_Initialized, true); |
| 295 } | 313 } |
| 296 CXFA_Node* pContentArea = pPageArea->GetChild(0, XFA_Element::ContentArea); | 314 CXFA_Node* pContentArea = pPageArea->GetChild(0, XFA_Element::ContentArea); |
| 297 if (!pContentArea) { | 315 if (!pContentArea) { |
| 298 pContentArea = pDocument->CreateNode(pPageArea->GetPacketID(), | 316 pContentArea = pDocument->CreateNode(pPageArea->GetPacketID(), |
| 299 XFA_Element::ContentArea); | 317 XFA_Element::ContentArea); |
| 300 if (!pContentArea) { | 318 if (!pContentArea) |
| 301 return FALSE; | 319 return FALSE; |
| 302 } | 320 |
| 303 pPageArea->InsertChild(pContentArea, nullptr); | 321 pPageArea->InsertChild(pContentArea, nullptr); |
| 304 pContentArea->SetFlag(XFA_NodeFlag_Initialized, true); | 322 pContentArea->SetFlag(XFA_NodeFlag_Initialized, true); |
| 305 pContentArea->SetMeasure(XFA_ATTRIBUTE_X, | 323 pContentArea->SetMeasure(XFA_ATTRIBUTE_X, |
| 306 CXFA_Measurement(0.25f, XFA_UNIT_In)); | 324 CXFA_Measurement(0.25f, XFA_UNIT_In)); |
| 307 pContentArea->SetMeasure(XFA_ATTRIBUTE_Y, | 325 pContentArea->SetMeasure(XFA_ATTRIBUTE_Y, |
| 308 CXFA_Measurement(0.25f, XFA_UNIT_In)); | 326 CXFA_Measurement(0.25f, XFA_UNIT_In)); |
| 309 pContentArea->SetMeasure(XFA_ATTRIBUTE_W, | 327 pContentArea->SetMeasure(XFA_ATTRIBUTE_W, |
| 310 CXFA_Measurement(8.0f, XFA_UNIT_In)); | 328 CXFA_Measurement(8.0f, XFA_UNIT_In)); |
| 311 pContentArea->SetMeasure(XFA_ATTRIBUTE_H, | 329 pContentArea->SetMeasure(XFA_ATTRIBUTE_H, |
| 312 CXFA_Measurement(10.5f, XFA_UNIT_In)); | 330 CXFA_Measurement(10.5f, XFA_UNIT_In)); |
| 313 } | 331 } |
| 314 CXFA_Node* pMedium = pPageArea->GetChild(0, XFA_Element::Medium); | 332 CXFA_Node* pMedium = pPageArea->GetChild(0, XFA_Element::Medium); |
| 315 if (!pMedium) { | 333 if (!pMedium) { |
| 316 pMedium = | 334 pMedium = |
| 317 pDocument->CreateNode(pPageArea->GetPacketID(), XFA_Element::Medium); | 335 pDocument->CreateNode(pPageArea->GetPacketID(), XFA_Element::Medium); |
| 318 if (!pContentArea) { | 336 if (!pContentArea) |
| 319 return FALSE; | 337 return FALSE; |
| 320 } | 338 |
| 321 pPageArea->InsertChild(pMedium, nullptr); | 339 pPageArea->InsertChild(pMedium, nullptr); |
| 322 pMedium->SetFlag(XFA_NodeFlag_Initialized, true); | 340 pMedium->SetFlag(XFA_NodeFlag_Initialized, true); |
| 323 pMedium->SetMeasure(XFA_ATTRIBUTE_Short, | 341 pMedium->SetMeasure(XFA_ATTRIBUTE_Short, |
| 324 CXFA_Measurement(8.5f, XFA_UNIT_In)); | 342 CXFA_Measurement(8.5f, XFA_UNIT_In)); |
| 325 pMedium->SetMeasure(XFA_ATTRIBUTE_Long, | 343 pMedium->SetMeasure(XFA_ATTRIBUTE_Long, |
| 326 CXFA_Measurement(11.0f, XFA_UNIT_In)); | 344 CXFA_Measurement(11.0f, XFA_UNIT_In)); |
| 327 } | 345 } |
| 328 return TRUE; | 346 return TRUE; |
| 329 } | 347 } |
| 348 |
| 330 FX_BOOL CXFA_LayoutPageMgr::PrepareFirstPage(CXFA_Node* pRootSubform) { | 349 FX_BOOL CXFA_LayoutPageMgr::PrepareFirstPage(CXFA_Node* pRootSubform) { |
| 331 FX_BOOL bProBreakBefore = FALSE; | 350 FX_BOOL bProBreakBefore = FALSE; |
| 332 CXFA_Node* pBreakBeforeNode = nullptr; | 351 CXFA_Node* pBreakBeforeNode = nullptr; |
| 333 while (pRootSubform) { | 352 while (pRootSubform) { |
| 334 for (CXFA_Node* pBreakNode = | 353 for (CXFA_Node* pBreakNode = |
| 335 pRootSubform->GetNodeItem(XFA_NODEITEM_FirstChild); | 354 pRootSubform->GetNodeItem(XFA_NODEITEM_FirstChild); |
| 336 pBreakNode; | 355 pBreakNode; |
| 337 pBreakNode = pBreakNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { | 356 pBreakNode = pBreakNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { |
| 338 XFA_Element eType = pBreakNode->GetElementType(); | 357 XFA_Element eType = pBreakNode->GetElementType(); |
| 339 if (eType == XFA_Element::BreakBefore || | 358 if (eType == XFA_Element::BreakBefore || |
| 340 (eType == XFA_Element::Break && | 359 (eType == XFA_Element::Break && |
| 341 pBreakNode->GetEnum(XFA_ATTRIBUTE_Before) != | 360 pBreakNode->GetEnum(XFA_ATTRIBUTE_Before) != |
| 342 XFA_ATTRIBUTEENUM_Auto)) { | 361 XFA_ATTRIBUTEENUM_Auto)) { |
| 343 bProBreakBefore = TRUE; | 362 bProBreakBefore = TRUE; |
| 344 pBreakBeforeNode = pBreakNode; | 363 pBreakBeforeNode = pBreakNode; |
| 345 break; | 364 break; |
| 346 } | 365 } |
| 347 } | 366 } |
| 348 if (bProBreakBefore) { | 367 if (bProBreakBefore) |
| 349 break; | 368 break; |
| 350 } | 369 |
| 351 bProBreakBefore = TRUE; | 370 bProBreakBefore = TRUE; |
| 352 pRootSubform = pRootSubform->GetFirstChildByClass(XFA_Element::Subform); | 371 pRootSubform = pRootSubform->GetFirstChildByClass(XFA_Element::Subform); |
| 353 while (pRootSubform && | 372 while (pRootSubform && |
| 354 !XFA_ItemLayoutProcessor_IsTakingSpace(pRootSubform)) { | 373 !XFA_ItemLayoutProcessor_IsTakingSpace(pRootSubform)) { |
| 355 pRootSubform = | 374 pRootSubform = |
| 356 pRootSubform->GetNextSameClassSibling(XFA_Element::Subform); | 375 pRootSubform->GetNextSameClassSibling(XFA_Element::Subform); |
| 357 } | 376 } |
| 358 } | 377 } |
| 359 CXFA_Node *pLeader, *pTrailer; | 378 CXFA_Node *pLeader, *pTrailer; |
| 360 if (pBreakBeforeNode && | 379 if (pBreakBeforeNode && |
| 361 ExecuteBreakBeforeOrAfter(pBreakBeforeNode, TRUE, pLeader, pTrailer)) { | 380 ExecuteBreakBeforeOrAfter(pBreakBeforeNode, TRUE, pLeader, pTrailer)) { |
| 362 m_pCurrentContainerRecord = m_rgProposedContainerRecord.GetHeadPosition(); | 381 m_pCurrentContainerRecord = m_rgProposedContainerRecord.GetHeadPosition(); |
| 363 return TRUE; | 382 return TRUE; |
| 364 } | 383 } |
| 365 return AppendNewPage(TRUE); | 384 return AppendNewPage(TRUE); |
| 366 } | 385 } |
| 386 |
| 367 FX_BOOL CXFA_LayoutPageMgr::AppendNewPage(FX_BOOL bFirstTemPage) { | 387 FX_BOOL CXFA_LayoutPageMgr::AppendNewPage(FX_BOOL bFirstTemPage) { |
| 368 if (m_pCurrentContainerRecord != | 388 if (m_pCurrentContainerRecord != |
| 369 m_rgProposedContainerRecord.GetTailPosition()) { | 389 m_rgProposedContainerRecord.GetTailPosition()) { |
| 370 return TRUE; | 390 return TRUE; |
| 371 } | 391 } |
| 372 CXFA_Node* pPageNode = GetNextAvailPageArea(nullptr); | 392 CXFA_Node* pPageNode = GetNextAvailPageArea(nullptr); |
| 373 if (!pPageNode) { | 393 if (!pPageNode) |
| 374 return FALSE; | 394 return FALSE; |
| 375 } | 395 if (bFirstTemPage && !m_pCurrentContainerRecord) |
| 376 if (bFirstTemPage && !m_pCurrentContainerRecord) { | |
| 377 m_pCurrentContainerRecord = m_rgProposedContainerRecord.GetHeadPosition(); | 396 m_pCurrentContainerRecord = m_rgProposedContainerRecord.GetHeadPosition(); |
| 378 } | |
| 379 return !bFirstTemPage || m_pCurrentContainerRecord; | 397 return !bFirstTemPage || m_pCurrentContainerRecord; |
| 380 } | 398 } |
| 381 | 399 |
| 382 void CXFA_LayoutPageMgr::RemoveLayoutRecord(CXFA_ContainerRecord* pNewRecord, | 400 void CXFA_LayoutPageMgr::RemoveLayoutRecord(CXFA_ContainerRecord* pNewRecord, |
| 383 CXFA_ContainerRecord* pPrevRecord) { | 401 CXFA_ContainerRecord* pPrevRecord) { |
| 384 if (!pNewRecord || !pPrevRecord) { | 402 if (!pNewRecord || !pPrevRecord) |
| 385 return; | 403 return; |
| 386 } | |
| 387 if (pNewRecord->pCurPageSet != pPrevRecord->pCurPageSet) { | 404 if (pNewRecord->pCurPageSet != pPrevRecord->pCurPageSet) { |
| 388 RemoveLayoutItem(pNewRecord->pCurPageSet); | 405 RemoveLayoutItem(pNewRecord->pCurPageSet); |
| 389 return; | 406 return; |
| 390 } | 407 } |
| 391 if (pNewRecord->pCurPageArea != pPrevRecord->pCurPageArea) { | 408 if (pNewRecord->pCurPageArea != pPrevRecord->pCurPageArea) { |
| 392 RemoveLayoutItem(pNewRecord->pCurPageArea); | 409 RemoveLayoutItem(pNewRecord->pCurPageArea); |
| 393 return; | 410 return; |
| 394 } | 411 } |
| 395 if (pNewRecord->pCurContentArea != pPrevRecord->pCurContentArea) { | 412 if (pNewRecord->pCurContentArea != pPrevRecord->pCurContentArea) { |
| 396 RemoveLayoutItem(pNewRecord->pCurContentArea); | 413 RemoveLayoutItem(pNewRecord->pCurContentArea); |
| 397 return; | 414 return; |
| 398 } | 415 } |
| 399 } | 416 } |
| 417 |
| 400 void CXFA_LayoutPageMgr::ReorderPendingLayoutRecordToTail( | 418 void CXFA_LayoutPageMgr::ReorderPendingLayoutRecordToTail( |
| 401 CXFA_ContainerRecord* pNewRecord, | 419 CXFA_ContainerRecord* pNewRecord, |
| 402 CXFA_ContainerRecord* pPrevRecord) { | 420 CXFA_ContainerRecord* pPrevRecord) { |
| 403 if (!pNewRecord || !pPrevRecord) { | 421 if (!pNewRecord || !pPrevRecord) |
| 404 return; | 422 return; |
| 405 } | |
| 406 if (pNewRecord->pCurPageSet != pPrevRecord->pCurPageSet) { | 423 if (pNewRecord->pCurPageSet != pPrevRecord->pCurPageSet) { |
| 407 ReorderLayoutItemToTail(pNewRecord->pCurPageSet); | 424 ReorderLayoutItemToTail(pNewRecord->pCurPageSet); |
| 408 return; | 425 return; |
| 409 } | 426 } |
| 410 if (pNewRecord->pCurPageArea != pPrevRecord->pCurPageArea) { | 427 if (pNewRecord->pCurPageArea != pPrevRecord->pCurPageArea) { |
| 411 ReorderLayoutItemToTail(pNewRecord->pCurPageArea); | 428 ReorderLayoutItemToTail(pNewRecord->pCurPageArea); |
| 412 return; | 429 return; |
| 413 } | 430 } |
| 414 if (pNewRecord->pCurContentArea != pPrevRecord->pCurContentArea) { | 431 if (pNewRecord->pCurContentArea != pPrevRecord->pCurContentArea) { |
| 415 ReorderLayoutItemToTail(pNewRecord->pCurContentArea); | 432 ReorderLayoutItemToTail(pNewRecord->pCurContentArea); |
| 416 return; | 433 return; |
| 417 } | 434 } |
| 418 } | 435 } |
| 436 |
| 419 void CXFA_LayoutPageMgr::SubmitContentItem( | 437 void CXFA_LayoutPageMgr::SubmitContentItem( |
| 420 CXFA_ContentLayoutItem* pContentLayoutItem, | 438 CXFA_ContentLayoutItem* pContentLayoutItem, |
| 421 XFA_ItemLayoutProcessorResult eStatus) { | 439 XFA_ItemLayoutProcessorResult eStatus) { |
| 422 if (pContentLayoutItem) { | 440 if (pContentLayoutItem) { |
| 423 GetCurrentContainerRecord()->pCurContentArea->AddChild(pContentLayoutItem); | 441 GetCurrentContainerRecord()->pCurContentArea->AddChild(pContentLayoutItem); |
| 424 m_bCreateOverFlowPage = FALSE; | 442 m_bCreateOverFlowPage = FALSE; |
| 425 } | 443 } |
| 444 |
| 426 if (eStatus != XFA_ItemLayoutProcessorResult_Done) { | 445 if (eStatus != XFA_ItemLayoutProcessorResult_Done) { |
| 427 if (eStatus == XFA_ItemLayoutProcessorResult_PageFullBreak && | 446 if (eStatus == XFA_ItemLayoutProcessorResult_PageFullBreak && |
| 428 m_pCurrentContainerRecord == | 447 m_pCurrentContainerRecord == |
| 429 m_rgProposedContainerRecord.GetTailPosition()) { | 448 m_rgProposedContainerRecord.GetTailPosition()) { |
| 430 AppendNewPage(); | 449 AppendNewPage(); |
| 431 } | 450 } |
| 432 m_pCurrentContainerRecord = m_rgProposedContainerRecord.GetTailPosition(); | 451 m_pCurrentContainerRecord = m_rgProposedContainerRecord.GetTailPosition(); |
| 433 m_pCurPageArea = GetCurrentContainerRecord()->pCurPageArea->m_pFormNode; | 452 m_pCurPageArea = GetCurrentContainerRecord()->pCurPageArea->m_pFormNode; |
| 434 } | 453 } |
| 435 } | 454 } |
| 455 |
| 436 FX_FLOAT CXFA_LayoutPageMgr::GetAvailHeight() { | 456 FX_FLOAT CXFA_LayoutPageMgr::GetAvailHeight() { |
| 437 CXFA_ContainerLayoutItem* pLayoutItem = | 457 CXFA_ContainerLayoutItem* pLayoutItem = |
| 438 GetCurrentContainerRecord()->pCurContentArea; | 458 GetCurrentContainerRecord()->pCurContentArea; |
| 439 if (!pLayoutItem || !pLayoutItem->m_pFormNode) | 459 if (!pLayoutItem || !pLayoutItem->m_pFormNode) |
| 440 return 0.0f; | 460 return 0.0f; |
| 461 |
| 441 FX_FLOAT fAvailHeight = | 462 FX_FLOAT fAvailHeight = |
| 442 pLayoutItem->m_pFormNode->GetMeasure(XFA_ATTRIBUTE_H).ToUnit(XFA_UNIT_Pt); | 463 pLayoutItem->m_pFormNode->GetMeasure(XFA_ATTRIBUTE_H).ToUnit(XFA_UNIT_Pt); |
| 443 if (fAvailHeight >= XFA_LAYOUT_FLOAT_PERCISION) | 464 if (fAvailHeight >= XFA_LAYOUT_FLOAT_PERCISION) |
| 444 return fAvailHeight; | 465 return fAvailHeight; |
| 445 if (m_pCurrentContainerRecord == | 466 if (m_pCurrentContainerRecord == |
| 446 m_rgProposedContainerRecord.GetHeadPosition()) { | 467 m_rgProposedContainerRecord.GetHeadPosition()) { |
| 447 return 0.0f; | 468 return 0.0f; |
| 448 } | 469 } |
| 449 return XFA_LAYOUT_FLOAT_MAX; | 470 return XFA_LAYOUT_FLOAT_MAX; |
| 450 } | 471 } |
| 451 | 472 |
| 452 FX_BOOL XFA_LayoutPageMgr_RunBreakTestScript(CXFA_Node* pTestScript) { | 473 FX_BOOL XFA_LayoutPageMgr_RunBreakTestScript(CXFA_Node* pTestScript) { |
| 453 CFX_WideString wsExpression; | 474 CFX_WideString wsExpression; |
| 454 pTestScript->TryContent(wsExpression); | 475 pTestScript->TryContent(wsExpression); |
| 455 if (wsExpression.IsEmpty()) { | 476 if (wsExpression.IsEmpty()) |
| 456 return TRUE; | 477 return TRUE; |
| 457 } | |
| 458 return pTestScript->GetDocument()->GetNotify()->RunScript( | 478 return pTestScript->GetDocument()->GetNotify()->RunScript( |
| 459 pTestScript, pTestScript->GetNodeItem(XFA_NODEITEM_Parent, | 479 pTestScript, pTestScript->GetNodeItem(XFA_NODEITEM_Parent, |
| 460 XFA_ObjectType::ContainerNode)); | 480 XFA_ObjectType::ContainerNode)); |
| 461 } | 481 } |
| 482 |
| 462 CXFA_ContainerRecord* CXFA_LayoutPageMgr::CreateContainerRecord( | 483 CXFA_ContainerRecord* CXFA_LayoutPageMgr::CreateContainerRecord( |
| 463 CXFA_Node* pPageNode, | 484 CXFA_Node* pPageNode, |
| 464 FX_BOOL bCreateNew) { | 485 FX_BOOL bCreateNew) { |
| 465 CXFA_ContainerRecord* pNewRecord = new CXFA_ContainerRecord(); | 486 CXFA_ContainerRecord* pNewRecord = new CXFA_ContainerRecord(); |
| 466 if (m_pCurrentContainerRecord) { | 487 if (m_pCurrentContainerRecord) { |
| 467 if (!IsPageSetRootOrderedOccurrence() || !pPageNode) { | 488 if (!IsPageSetRootOrderedOccurrence() || !pPageNode) { |
| 468 *pNewRecord = *GetCurrentContainerRecord(); | 489 *pNewRecord = *GetCurrentContainerRecord(); |
| 469 m_rgProposedContainerRecord.AddTail(pNewRecord); | 490 m_rgProposedContainerRecord.AddTail(pNewRecord); |
| 470 return pNewRecord; | 491 return pNewRecord; |
| 471 } | 492 } |
| 472 CXFA_Node* pPageSet = pPageNode->GetNodeItem(XFA_NODEITEM_Parent); | 493 CXFA_Node* pPageSet = pPageNode->GetNodeItem(XFA_NODEITEM_Parent); |
| 473 if (!bCreateNew) { | 494 if (!bCreateNew) { |
| 474 if (pPageSet == m_pTemplatePageSetRoot) { | 495 if (pPageSet == m_pTemplatePageSetRoot) { |
| 475 pNewRecord->pCurPageSet = m_pPageSetCurRoot; | 496 pNewRecord->pCurPageSet = m_pPageSetCurRoot; |
| 476 } else { | 497 } else { |
| 477 CXFA_ContainerLayoutItem* pParentLayoutItem = | 498 CXFA_ContainerLayoutItem* pParentLayoutItem = |
| 478 (CXFA_ContainerLayoutItem*)pPageSet->GetUserData(XFA_LAYOUTITEMKEY); | 499 static_cast<CXFA_ContainerLayoutItem*>( |
| 479 if (!pParentLayoutItem) { | 500 pPageSet->GetUserData(XFA_LAYOUTITEMKEY)); |
| 501 if (!pParentLayoutItem) |
| 480 pParentLayoutItem = m_pPageSetCurRoot; | 502 pParentLayoutItem = m_pPageSetCurRoot; |
| 481 } | 503 |
| 482 pNewRecord->pCurPageSet = pParentLayoutItem; | 504 pNewRecord->pCurPageSet = pParentLayoutItem; |
| 483 } | 505 } |
| 484 } else { | 506 } else { |
| 485 CXFA_ContainerLayoutItem* pParentPageSetLayout = nullptr; | 507 CXFA_ContainerLayoutItem* pParentPageSetLayout = nullptr; |
| 486 if (pPageSet == GetCurrentContainerRecord()->pCurPageSet->m_pFormNode) { | 508 if (pPageSet == GetCurrentContainerRecord()->pCurPageSet->m_pFormNode) { |
| 487 pParentPageSetLayout = | 509 pParentPageSetLayout = static_cast<CXFA_ContainerLayoutItem*>( |
| 488 (CXFA_ContainerLayoutItem*)GetCurrentContainerRecord() | 510 GetCurrentContainerRecord()->pCurPageSet->m_pParent); |
| 489 ->pCurPageSet->m_pParent; | |
| 490 } else { | 511 } else { |
| 491 pParentPageSetLayout = | 512 pParentPageSetLayout = static_cast<CXFA_ContainerLayoutItem*>( |
| 492 (CXFA_ContainerLayoutItem*)pPageSet->GetNodeItem( | 513 pPageSet->GetNodeItem(XFA_NODEITEM_Parent) |
| 493 XFA_NODEITEM_Parent) | 514 ->GetUserData(XFA_LAYOUTITEMKEY)); |
| 494 ->GetUserData(XFA_LAYOUTITEMKEY); | |
| 495 } | 515 } |
| 496 CXFA_ContainerLayoutItem* pPageSetLayoutItem = | 516 CXFA_ContainerLayoutItem* pPageSetLayoutItem = |
| 497 new CXFA_ContainerLayoutItem(pPageSet); | 517 new CXFA_ContainerLayoutItem(pPageSet); |
| 498 pPageSet->SetUserData(XFA_LAYOUTITEMKEY, (void*)pPageSetLayoutItem); | 518 pPageSet->SetUserData(XFA_LAYOUTITEMKEY, (void*)pPageSetLayoutItem); |
| 499 if (!pParentPageSetLayout) { | 519 if (!pParentPageSetLayout) { |
| 500 CXFA_ContainerLayoutItem* pPrePageSet = m_pPageSetLayoutItemRoot; | 520 CXFA_ContainerLayoutItem* pPrePageSet = m_pPageSetLayoutItemRoot; |
| 501 while (pPrePageSet->m_pNextSibling) { | 521 while (pPrePageSet->m_pNextSibling) { |
| 502 pPrePageSet = (CXFA_ContainerLayoutItem*)pPrePageSet->m_pNextSibling; | 522 pPrePageSet = static_cast<CXFA_ContainerLayoutItem*>( |
| 523 pPrePageSet->m_pNextSibling); |
| 503 } | 524 } |
| 525 |
| 504 pPrePageSet->m_pNextSibling = pPageSetLayoutItem; | 526 pPrePageSet->m_pNextSibling = pPageSetLayoutItem; |
| 505 m_pPageSetCurRoot = pPageSetLayoutItem; | 527 m_pPageSetCurRoot = pPageSetLayoutItem; |
| 506 } else { | 528 } else { |
| 507 pParentPageSetLayout->AddChild(pPageSetLayoutItem); | 529 pParentPageSetLayout->AddChild(pPageSetLayoutItem); |
| 508 } | 530 } |
| 509 pNewRecord->pCurPageSet = pPageSetLayoutItem; | 531 pNewRecord->pCurPageSet = pPageSetLayoutItem; |
| 510 } | 532 } |
| 511 } else { | 533 } else { |
| 512 if (pPageNode) { | 534 if (pPageNode) { |
| 513 CXFA_Node* pPageSet = pPageNode->GetNodeItem(XFA_NODEITEM_Parent); | 535 CXFA_Node* pPageSet = pPageNode->GetNodeItem(XFA_NODEITEM_Parent); |
| 514 if (pPageSet == m_pTemplatePageSetRoot) { | 536 if (pPageSet == m_pTemplatePageSetRoot) { |
| 515 pNewRecord->pCurPageSet = m_pPageSetLayoutItemRoot; | 537 pNewRecord->pCurPageSet = m_pPageSetLayoutItemRoot; |
| 516 } else { | 538 } else { |
| 517 CXFA_ContainerLayoutItem* pPageSetLayoutItem = | 539 CXFA_ContainerLayoutItem* pPageSetLayoutItem = |
| 518 new CXFA_ContainerLayoutItem(pPageSet); | 540 new CXFA_ContainerLayoutItem(pPageSet); |
| 519 pPageSet->SetUserData(XFA_LAYOUTITEMKEY, (void*)pPageSetLayoutItem); | 541 pPageSet->SetUserData(XFA_LAYOUTITEMKEY, (void*)pPageSetLayoutItem); |
| 520 m_pPageSetLayoutItemRoot->AddChild(pPageSetLayoutItem); | 542 m_pPageSetLayoutItemRoot->AddChild(pPageSetLayoutItem); |
| 521 pNewRecord->pCurPageSet = pPageSetLayoutItem; | 543 pNewRecord->pCurPageSet = pPageSetLayoutItem; |
| 522 } | 544 } |
| 523 } else { | 545 } else { |
| 524 pNewRecord->pCurPageSet = m_pPageSetLayoutItemRoot; | 546 pNewRecord->pCurPageSet = m_pPageSetLayoutItemRoot; |
| 525 } | 547 } |
| 526 } | 548 } |
| 527 m_rgProposedContainerRecord.AddTail(pNewRecord); | 549 m_rgProposedContainerRecord.AddTail(pNewRecord); |
| 528 return pNewRecord; | 550 return pNewRecord; |
| 529 } | 551 } |
| 552 |
| 530 void CXFA_LayoutPageMgr::AddPageAreaLayoutItem(CXFA_ContainerRecord* pNewRecord, | 553 void CXFA_LayoutPageMgr::AddPageAreaLayoutItem(CXFA_ContainerRecord* pNewRecord, |
| 531 CXFA_Node* pNewPageArea) { | 554 CXFA_Node* pNewPageArea) { |
| 532 CXFA_ContainerLayoutItem* pNewPageAreaLayoutItem = nullptr; | 555 CXFA_ContainerLayoutItem* pNewPageAreaLayoutItem = nullptr; |
| 533 if (m_PageArray.GetSize() > m_nAvailPages) { | 556 if (m_PageArray.GetSize() > m_nAvailPages) { |
| 534 CXFA_ContainerLayoutItem* pContainerItem = m_PageArray[m_nAvailPages]; | 557 CXFA_ContainerLayoutItem* pContainerItem = m_PageArray[m_nAvailPages]; |
| 535 pContainerItem->m_pFormNode = pNewPageArea; | 558 pContainerItem->m_pFormNode = pNewPageArea; |
| 536 m_nAvailPages++; | 559 m_nAvailPages++; |
| 537 pNewPageAreaLayoutItem = pContainerItem; | 560 pNewPageAreaLayoutItem = pContainerItem; |
| 538 } else { | 561 } else { |
| 539 CXFA_FFNotify* pNotify = pNewPageArea->GetDocument()->GetNotify(); | 562 CXFA_FFNotify* pNotify = pNewPageArea->GetDocument()->GetNotify(); |
| 540 CXFA_ContainerLayoutItem* pContainerItem = | 563 CXFA_ContainerLayoutItem* pContainerItem = |
| 541 (CXFA_ContainerLayoutItem*)pNotify->OnCreateLayoutItem(pNewPageArea); | 564 static_cast<CXFA_ContainerLayoutItem*>( |
| 565 pNotify->OnCreateLayoutItem(pNewPageArea)); |
| 542 m_PageArray.Add(pContainerItem); | 566 m_PageArray.Add(pContainerItem); |
| 543 m_nAvailPages++; | 567 m_nAvailPages++; |
| 544 pNotify->OnPageEvent(pContainerItem, XFA_PAGEVIEWEVENT_PostRemoved); | 568 pNotify->OnPageEvent(pContainerItem, XFA_PAGEVIEWEVENT_PostRemoved); |
| 545 pNewPageAreaLayoutItem = pContainerItem; | 569 pNewPageAreaLayoutItem = pContainerItem; |
| 546 } | 570 } |
| 547 pNewRecord->pCurPageSet->AddChild(pNewPageAreaLayoutItem); | 571 pNewRecord->pCurPageSet->AddChild(pNewPageAreaLayoutItem); |
| 548 pNewRecord->pCurPageArea = pNewPageAreaLayoutItem; | 572 pNewRecord->pCurPageArea = pNewPageAreaLayoutItem; |
| 549 pNewRecord->pCurContentArea = nullptr; | 573 pNewRecord->pCurContentArea = nullptr; |
| 550 } | 574 } |
| 575 |
| 551 void CXFA_LayoutPageMgr::AddContentAreaLayoutItem( | 576 void CXFA_LayoutPageMgr::AddContentAreaLayoutItem( |
| 552 CXFA_ContainerRecord* pNewRecord, | 577 CXFA_ContainerRecord* pNewRecord, |
| 553 CXFA_Node* pContentArea) { | 578 CXFA_Node* pContentArea) { |
| 554 if (!pContentArea) { | 579 if (!pContentArea) { |
| 555 pNewRecord->pCurContentArea = nullptr; | 580 pNewRecord->pCurContentArea = nullptr; |
| 556 return; | 581 return; |
| 557 } | 582 } |
| 558 CXFA_ContainerLayoutItem* pNewContentAreaLayoutItem = | 583 CXFA_ContainerLayoutItem* pNewContentAreaLayoutItem = |
| 559 new CXFA_ContainerLayoutItem(pContentArea); | 584 new CXFA_ContainerLayoutItem(pContentArea); |
| 560 ASSERT(pNewRecord->pCurPageArea); | 585 ASSERT(pNewRecord->pCurPageArea); |
| 561 pNewRecord->pCurPageArea->AddChild(pNewContentAreaLayoutItem); | 586 pNewRecord->pCurPageArea->AddChild(pNewContentAreaLayoutItem); |
| 562 pNewRecord->pCurContentArea = pNewContentAreaLayoutItem; | 587 pNewRecord->pCurContentArea = pNewContentAreaLayoutItem; |
| 563 } | 588 } |
| 564 | 589 |
| 565 void CXFA_LayoutPageMgr::FinishPaginatedPageSets() { | 590 void CXFA_LayoutPageMgr::FinishPaginatedPageSets() { |
| 566 CXFA_ContainerLayoutItem* pRootPageSetLayoutItem = m_pPageSetLayoutItemRoot; | 591 CXFA_ContainerLayoutItem* pRootPageSetLayoutItem = m_pPageSetLayoutItemRoot; |
| 567 for (; pRootPageSetLayoutItem; | 592 for (; pRootPageSetLayoutItem; |
| 568 pRootPageSetLayoutItem = | 593 pRootPageSetLayoutItem = static_cast<CXFA_ContainerLayoutItem*>( |
| 569 (CXFA_ContainerLayoutItem*)pRootPageSetLayoutItem->m_pNextSibling) { | 594 pRootPageSetLayoutItem->m_pNextSibling)) { |
| 570 CXFA_NodeIteratorTemplate<CXFA_ContainerLayoutItem, | 595 CXFA_NodeIteratorTemplate<CXFA_ContainerLayoutItem, |
| 571 PageSetContainerLayoutItem> | 596 PageSetContainerLayoutItem> |
| 572 sIterator(pRootPageSetLayoutItem); | 597 sIterator(pRootPageSetLayoutItem); |
| 573 for (CXFA_ContainerLayoutItem* pPageSetLayoutItem = sIterator.GetCurrent(); | 598 for (CXFA_ContainerLayoutItem* pPageSetLayoutItem = sIterator.GetCurrent(); |
| 574 pPageSetLayoutItem; pPageSetLayoutItem = sIterator.MoveToNext()) { | 599 pPageSetLayoutItem; pPageSetLayoutItem = sIterator.MoveToNext()) { |
| 575 XFA_ATTRIBUTEENUM ePageRelation = | 600 XFA_ATTRIBUTEENUM ePageRelation = |
| 576 pPageSetLayoutItem->m_pFormNode->GetEnum(XFA_ATTRIBUTE_Relation); | 601 pPageSetLayoutItem->m_pFormNode->GetEnum(XFA_ATTRIBUTE_Relation); |
| 577 switch (ePageRelation) { | 602 switch (ePageRelation) { |
| 578 case XFA_ATTRIBUTEENUM_OrderedOccurrence: | 603 case XFA_ATTRIBUTEENUM_OrderedOccurrence: |
| 579 default: { ProcessLastPageSet(); } break; | 604 default: { ProcessLastPageSet(); } break; |
| 580 case XFA_ATTRIBUTEENUM_SimplexPaginated: | 605 case XFA_ATTRIBUTEENUM_SimplexPaginated: |
| 581 case XFA_ATTRIBUTEENUM_DuplexPaginated: { | 606 case XFA_ATTRIBUTEENUM_DuplexPaginated: { |
| 582 CXFA_LayoutItem* pLastPageAreaLayoutItem = nullptr; | 607 CXFA_LayoutItem* pLastPageAreaLayoutItem = nullptr; |
| 583 int32_t nPageAreaCount = 0; | 608 int32_t nPageAreaCount = 0; |
| 584 for (CXFA_LayoutItem* pPageAreaLayoutItem = | 609 for (CXFA_LayoutItem* pPageAreaLayoutItem = |
| 585 pPageSetLayoutItem->m_pFirstChild; | 610 pPageSetLayoutItem->m_pFirstChild; |
| 586 pPageAreaLayoutItem; | 611 pPageAreaLayoutItem; |
| 587 pPageAreaLayoutItem = pPageAreaLayoutItem->m_pNextSibling) { | 612 pPageAreaLayoutItem = pPageAreaLayoutItem->m_pNextSibling) { |
| 588 if (pPageAreaLayoutItem->m_pFormNode->GetElementType() != | 613 if (pPageAreaLayoutItem->m_pFormNode->GetElementType() != |
| 589 XFA_Element::PageArea) { | 614 XFA_Element::PageArea) { |
| 590 continue; | 615 continue; |
| 591 } | 616 } |
| 592 nPageAreaCount++; | 617 nPageAreaCount++; |
| 593 pLastPageAreaLayoutItem = pPageAreaLayoutItem; | 618 pLastPageAreaLayoutItem = pPageAreaLayoutItem; |
| 594 } | 619 } |
| 595 if (!pLastPageAreaLayoutItem) { | 620 if (!pLastPageAreaLayoutItem) |
| 596 break; | 621 break; |
| 597 } | 622 |
| 598 if (!FindPageAreaFromPageSet_SimplexDuplex( | 623 if (!FindPageAreaFromPageSet_SimplexDuplex( |
| 599 pPageSetLayoutItem->m_pFormNode, nullptr, nullptr, nullptr, | 624 pPageSetLayoutItem->m_pFormNode, nullptr, nullptr, nullptr, |
| 600 TRUE, TRUE, nPageAreaCount == 1 ? XFA_ATTRIBUTEENUM_Only | 625 TRUE, TRUE, nPageAreaCount == 1 ? XFA_ATTRIBUTEENUM_Only |
| 601 : XFA_ATTRIBUTEENUM_Last) && | 626 : XFA_ATTRIBUTEENUM_Last) && |
| 602 (nPageAreaCount == 1 && | 627 (nPageAreaCount == 1 && |
| 603 !FindPageAreaFromPageSet_SimplexDuplex( | 628 !FindPageAreaFromPageSet_SimplexDuplex( |
| 604 pPageSetLayoutItem->m_pFormNode, nullptr, nullptr, nullptr, | 629 pPageSetLayoutItem->m_pFormNode, nullptr, nullptr, nullptr, |
| 605 TRUE, TRUE, XFA_ATTRIBUTEENUM_Last))) { | 630 TRUE, TRUE, XFA_ATTRIBUTEENUM_Last))) { |
| 606 break; | 631 break; |
| 607 } | 632 } |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 690 } else if (pNode->GetEnum(XFA_ATTRIBUTE_PagePosition) == | 715 } else if (pNode->GetEnum(XFA_ATTRIBUTE_PagePosition) == |
| 691 XFA_ATTRIBUTEENUM_Last) { | 716 XFA_ATTRIBUTEENUM_Last) { |
| 692 CXFA_ContainerRecord* pRecord = CreateContainerRecord(); | 717 CXFA_ContainerRecord* pRecord = CreateContainerRecord(); |
| 693 AddPageAreaLayoutItem(pRecord, pNode); | 718 AddPageAreaLayoutItem(pRecord, pNode); |
| 694 } | 719 } |
| 695 } break; | 720 } break; |
| 696 } | 721 } |
| 697 } | 722 } |
| 698 } | 723 } |
| 699 } | 724 } |
| 725 |
| 700 int32_t CXFA_LayoutPageMgr::GetPageCount() const { | 726 int32_t CXFA_LayoutPageMgr::GetPageCount() const { |
| 701 return m_PageArray.GetSize(); | 727 return m_PageArray.GetSize(); |
| 702 } | 728 } |
| 729 |
| 703 CXFA_ContainerLayoutItem* CXFA_LayoutPageMgr::GetPage(int32_t index) const { | 730 CXFA_ContainerLayoutItem* CXFA_LayoutPageMgr::GetPage(int32_t index) const { |
| 704 if (index < 0 || index >= m_PageArray.GetSize()) | 731 if (index < 0 || index >= m_PageArray.GetSize()) |
| 705 return nullptr; | 732 return nullptr; |
| 706 return m_PageArray[index]; | 733 return m_PageArray[index]; |
| 707 } | 734 } |
| 735 |
| 708 int32_t CXFA_LayoutPageMgr::GetPageIndex( | 736 int32_t CXFA_LayoutPageMgr::GetPageIndex( |
| 709 const CXFA_ContainerLayoutItem* pPage) const { | 737 const CXFA_ContainerLayoutItem* pPage) const { |
| 710 // FIXME: Find() method should take const. | 738 // FIXME: Find() method should take const. |
| 711 return m_PageArray.Find(const_cast<CXFA_ContainerLayoutItem*>(pPage)); | 739 return m_PageArray.Find(const_cast<CXFA_ContainerLayoutItem*>(pPage)); |
| 712 } | 740 } |
| 741 |
| 713 FX_BOOL CXFA_LayoutPageMgr::RunBreak(XFA_Element eBreakType, | 742 FX_BOOL CXFA_LayoutPageMgr::RunBreak(XFA_Element eBreakType, |
| 714 XFA_ATTRIBUTEENUM eTargetType, | 743 XFA_ATTRIBUTEENUM eTargetType, |
| 715 CXFA_Node* pTarget, | 744 CXFA_Node* pTarget, |
| 716 FX_BOOL bStartNew) { | 745 FX_BOOL bStartNew) { |
| 717 FX_BOOL bRet = FALSE; | 746 FX_BOOL bRet = FALSE; |
| 718 switch (eTargetType) { | 747 switch (eTargetType) { |
| 719 case XFA_ATTRIBUTEENUM_ContentArea: | 748 case XFA_ATTRIBUTEENUM_ContentArea: |
| 720 if (pTarget && pTarget->GetElementType() != XFA_Element::ContentArea) { | 749 if (pTarget && pTarget->GetElementType() != XFA_Element::ContentArea) |
| 721 pTarget = nullptr; | 750 pTarget = nullptr; |
| 722 } | |
| 723 if (!pTarget || !m_pCurrentContainerRecord || | 751 if (!pTarget || !m_pCurrentContainerRecord || |
| 724 pTarget != | 752 pTarget != |
| 725 GetCurrentContainerRecord()->pCurContentArea->m_pFormNode || | 753 GetCurrentContainerRecord()->pCurContentArea->m_pFormNode || |
| 726 bStartNew) { | 754 bStartNew) { |
| 727 CXFA_Node* pPageArea = nullptr; | 755 CXFA_Node* pPageArea = nullptr; |
| 728 if (pTarget) { | 756 if (pTarget) |
| 729 pPageArea = pTarget->GetNodeItem(XFA_NODEITEM_Parent); | 757 pPageArea = pTarget->GetNodeItem(XFA_NODEITEM_Parent); |
| 730 } | 758 |
| 731 pPageArea = GetNextAvailPageArea(pPageArea, pTarget); | 759 pPageArea = GetNextAvailPageArea(pPageArea, pTarget); |
| 732 bRet = !!pPageArea; | 760 bRet = !!pPageArea; |
| 733 } | 761 } |
| 734 break; | 762 break; |
| 735 case XFA_ATTRIBUTEENUM_PageArea: | 763 case XFA_ATTRIBUTEENUM_PageArea: |
| 736 if (pTarget && pTarget->GetElementType() != XFA_Element::PageArea) { | 764 if (pTarget && pTarget->GetElementType() != XFA_Element::PageArea) |
| 737 pTarget = nullptr; | 765 pTarget = nullptr; |
| 738 } | |
| 739 if (!pTarget || !m_pCurrentContainerRecord || | 766 if (!pTarget || !m_pCurrentContainerRecord || |
| 740 pTarget != GetCurrentContainerRecord()->pCurPageArea->m_pFormNode || | 767 pTarget != GetCurrentContainerRecord()->pCurPageArea->m_pFormNode || |
| 741 bStartNew) { | 768 bStartNew) { |
| 742 CXFA_Node* pPageArea = GetNextAvailPageArea(pTarget, nullptr, TRUE); | 769 CXFA_Node* pPageArea = GetNextAvailPageArea(pTarget, nullptr, TRUE); |
| 743 bRet = !!pPageArea; | 770 bRet = !!pPageArea; |
| 744 } | 771 } |
| 745 break; | 772 break; |
| 746 case XFA_ATTRIBUTEENUM_PageOdd: | 773 case XFA_ATTRIBUTEENUM_PageOdd: |
| 747 if (pTarget && pTarget->GetElementType() != XFA_Element::PageArea) { | 774 if (pTarget && pTarget->GetElementType() != XFA_Element::PageArea) |
| 748 pTarget = nullptr; | 775 pTarget = nullptr; |
| 749 } | |
| 750 break; | 776 break; |
| 751 case XFA_ATTRIBUTEENUM_PageEven: | 777 case XFA_ATTRIBUTEENUM_PageEven: |
| 752 if (pTarget && pTarget->GetElementType() != XFA_Element::PageArea) { | 778 if (pTarget && pTarget->GetElementType() != XFA_Element::PageArea) |
| 753 pTarget = nullptr; | 779 pTarget = nullptr; |
| 754 } | |
| 755 break; | 780 break; |
| 756 case XFA_ATTRIBUTEENUM_Auto: | 781 case XFA_ATTRIBUTEENUM_Auto: |
| 757 default: | 782 default: |
| 758 break; | 783 break; |
| 759 } | 784 } |
| 760 return bRet; | 785 return bRet; |
| 761 } | 786 } |
| 787 |
| 762 FX_BOOL CXFA_LayoutPageMgr::ExecuteBreakBeforeOrAfter( | 788 FX_BOOL CXFA_LayoutPageMgr::ExecuteBreakBeforeOrAfter( |
| 763 CXFA_Node* pCurNode, | 789 CXFA_Node* pCurNode, |
| 764 FX_BOOL bBefore, | 790 FX_BOOL bBefore, |
| 765 CXFA_Node*& pBreakLeaderTemplate, | 791 CXFA_Node*& pBreakLeaderTemplate, |
| 766 CXFA_Node*& pBreakTrailerTemplate) { | 792 CXFA_Node*& pBreakTrailerTemplate) { |
| 767 XFA_Element eType = pCurNode->GetElementType(); | 793 XFA_Element eType = pCurNode->GetElementType(); |
| 768 switch (eType) { | 794 switch (eType) { |
| 769 case XFA_Element::BreakBefore: | 795 case XFA_Element::BreakBefore: |
| 770 case XFA_Element::BreakAfter: { | 796 case XFA_Element::BreakAfter: { |
| 771 CFX_WideStringC wsBreakLeader, wsBreakTrailer; | 797 CFX_WideStringC wsBreakLeader, wsBreakTrailer; |
| 772 CXFA_Node* pFormNode = pCurNode->GetNodeItem( | 798 CXFA_Node* pFormNode = pCurNode->GetNodeItem( |
| 773 XFA_NODEITEM_Parent, XFA_ObjectType::ContainerNode); | 799 XFA_NODEITEM_Parent, XFA_ObjectType::ContainerNode); |
| 774 CXFA_Node* pContainer = pFormNode->GetTemplateNode(); | 800 CXFA_Node* pContainer = pFormNode->GetTemplateNode(); |
| 775 FX_BOOL bStartNew = pCurNode->GetInteger(XFA_ATTRIBUTE_StartNew) != 0; | 801 FX_BOOL bStartNew = pCurNode->GetInteger(XFA_ATTRIBUTE_StartNew) != 0; |
| 776 CXFA_Node* pScript = pCurNode->GetFirstChildByClass(XFA_Element::Script); | 802 CXFA_Node* pScript = pCurNode->GetFirstChildByClass(XFA_Element::Script); |
| 777 if (pScript && !XFA_LayoutPageMgr_RunBreakTestScript(pScript)) { | 803 if (pScript && !XFA_LayoutPageMgr_RunBreakTestScript(pScript)) |
| 778 return FALSE; | 804 return FALSE; |
| 779 } | 805 |
| 780 CFX_WideStringC wsTarget = pCurNode->GetCData(XFA_ATTRIBUTE_Target); | 806 CFX_WideStringC wsTarget = pCurNode->GetCData(XFA_ATTRIBUTE_Target); |
| 781 CXFA_Node* pTarget = | 807 CXFA_Node* pTarget = |
| 782 ResolveBreakTarget(m_pTemplatePageSetRoot, TRUE, wsTarget); | 808 ResolveBreakTarget(m_pTemplatePageSetRoot, TRUE, wsTarget); |
| 783 wsBreakTrailer = pCurNode->GetCData(XFA_ATTRIBUTE_Trailer); | 809 wsBreakTrailer = pCurNode->GetCData(XFA_ATTRIBUTE_Trailer); |
| 784 wsBreakLeader = pCurNode->GetCData(XFA_ATTRIBUTE_Leader); | 810 wsBreakLeader = pCurNode->GetCData(XFA_ATTRIBUTE_Leader); |
| 785 pBreakLeaderTemplate = | 811 pBreakLeaderTemplate = |
| 786 ResolveBreakTarget(pContainer, TRUE, wsBreakLeader); | 812 ResolveBreakTarget(pContainer, TRUE, wsBreakLeader); |
| 787 pBreakTrailerTemplate = | 813 pBreakTrailerTemplate = |
| 788 ResolveBreakTarget(pContainer, TRUE, wsBreakTrailer); | 814 ResolveBreakTarget(pContainer, TRUE, wsBreakTrailer); |
| 789 if (RunBreak(eType, pCurNode->GetEnum(XFA_ATTRIBUTE_TargetType), pTarget, | 815 if (RunBreak(eType, pCurNode->GetEnum(XFA_ATTRIBUTE_TargetType), pTarget, |
| 790 bStartNew)) { | 816 bStartNew)) { |
| 791 return TRUE; | 817 return TRUE; |
| 792 } else { | 818 } |
| 793 if (m_rgProposedContainerRecord.GetCount() > 0 && | 819 if (m_rgProposedContainerRecord.GetCount() > 0 && |
| 794 m_pCurrentContainerRecord == | 820 m_pCurrentContainerRecord == |
| 795 m_rgProposedContainerRecord.GetHeadPosition() && | 821 m_rgProposedContainerRecord.GetHeadPosition() && |
| 796 eType == XFA_Element::BreakBefore) { | 822 eType == XFA_Element::BreakBefore) { |
| 797 CXFA_Node* pParentNode = pFormNode->GetNodeItem( | 823 CXFA_Node* pParentNode = pFormNode->GetNodeItem( |
| 798 XFA_NODEITEM_Parent, XFA_ObjectType::ContainerNode); | 824 XFA_NODEITEM_Parent, XFA_ObjectType::ContainerNode); |
| 799 if (!pParentNode || | 825 if (!pParentNode || |
| 800 pFormNode != | 826 pFormNode != |
| 801 pParentNode->GetNodeItem(XFA_NODEITEM_FirstChild, | 827 pParentNode->GetNodeItem(XFA_NODEITEM_FirstChild, |
| 802 XFA_ObjectType::ContainerNode)) { | 828 XFA_ObjectType::ContainerNode)) { |
| 803 break; | 829 break; |
| 804 } | |
| 805 pParentNode = pParentNode->GetNodeItem(XFA_NODEITEM_Parent); | |
| 806 if (!pParentNode || | |
| 807 pParentNode->GetElementType() != XFA_Element::Form) { | |
| 808 break; | |
| 809 } | |
| 810 return TRUE; | |
| 811 } | 830 } |
| 831 pParentNode = pParentNode->GetNodeItem(XFA_NODEITEM_Parent); |
| 832 if (!pParentNode || |
| 833 pParentNode->GetElementType() != XFA_Element::Form) { |
| 834 break; |
| 835 } |
| 836 return TRUE; |
| 812 } | 837 } |
| 813 } break; | 838 break; |
| 839 } |
| 814 case XFA_Element::Break: { | 840 case XFA_Element::Break: { |
| 815 FX_BOOL bStartNew = pCurNode->GetInteger(XFA_ATTRIBUTE_StartNew) != 0; | 841 FX_BOOL bStartNew = pCurNode->GetInteger(XFA_ATTRIBUTE_StartNew) != 0; |
| 816 CFX_WideStringC wsTarget = pCurNode->GetCData( | 842 CFX_WideStringC wsTarget = pCurNode->GetCData( |
| 817 bBefore ? XFA_ATTRIBUTE_BeforeTarget : XFA_ATTRIBUTE_AfterTarget); | 843 bBefore ? XFA_ATTRIBUTE_BeforeTarget : XFA_ATTRIBUTE_AfterTarget); |
| 818 CXFA_Node* pTarget = | 844 CXFA_Node* pTarget = |
| 819 ResolveBreakTarget(m_pTemplatePageSetRoot, TRUE, wsTarget); | 845 ResolveBreakTarget(m_pTemplatePageSetRoot, TRUE, wsTarget); |
| 820 if (RunBreak(bBefore ? XFA_Element::BreakBefore : XFA_Element::BreakAfter, | 846 if (RunBreak(bBefore ? XFA_Element::BreakBefore : XFA_Element::BreakAfter, |
| 821 pCurNode->GetEnum(bBefore ? XFA_ATTRIBUTE_Before | 847 pCurNode->GetEnum(bBefore ? XFA_ATTRIBUTE_Before |
| 822 : XFA_ATTRIBUTE_After), | 848 : XFA_ATTRIBUTE_After), |
| 823 pTarget, bStartNew)) { | 849 pTarget, bStartNew)) { |
| 824 return TRUE; | 850 return TRUE; |
| 825 } | 851 } |
| 826 } break; | 852 break; |
| 853 } |
| 827 default: | 854 default: |
| 828 break; | 855 break; |
| 829 } | 856 } |
| 830 return FALSE; | 857 return FALSE; |
| 831 } | 858 } |
| 832 | 859 |
| 833 FX_BOOL CXFA_LayoutPageMgr::ProcessBreakBeforeOrAfter( | 860 FX_BOOL CXFA_LayoutPageMgr::ProcessBreakBeforeOrAfter( |
| 834 CXFA_Node* pBreakNode, | 861 CXFA_Node* pBreakNode, |
| 835 FX_BOOL bBefore, | 862 FX_BOOL bBefore, |
| 836 CXFA_Node*& pBreakLeaderNode, | 863 CXFA_Node*& pBreakLeaderNode, |
| 837 CXFA_Node*& pBreakTrailerNode, | 864 CXFA_Node*& pBreakTrailerNode, |
| 838 FX_BOOL& bCreatePage) { | 865 FX_BOOL& bCreatePage) { |
| 839 CXFA_Node* pLeaderTemplate = nullptr; | 866 CXFA_Node* pLeaderTemplate = nullptr; |
| 840 CXFA_Node* pTrailerTemplate = nullptr; | 867 CXFA_Node* pTrailerTemplate = nullptr; |
| 841 CXFA_Node* pFormNode = pBreakNode->GetNodeItem(XFA_NODEITEM_Parent, | 868 CXFA_Node* pFormNode = pBreakNode->GetNodeItem(XFA_NODEITEM_Parent, |
| 842 XFA_ObjectType::ContainerNode); | 869 XFA_ObjectType::ContainerNode); |
| 843 if (XFA_ItemLayoutProcessor_IsTakingSpace(pFormNode)) { | 870 if (XFA_ItemLayoutProcessor_IsTakingSpace(pFormNode)) { |
| 844 bCreatePage = ExecuteBreakBeforeOrAfter(pBreakNode, bBefore, | 871 bCreatePage = ExecuteBreakBeforeOrAfter(pBreakNode, bBefore, |
| 845 pLeaderTemplate, pTrailerTemplate); | 872 pLeaderTemplate, pTrailerTemplate); |
| 846 CXFA_Document* pDocument = pBreakNode->GetDocument(); | 873 CXFA_Document* pDocument = pBreakNode->GetDocument(); |
| 847 CXFA_Node* pDataScope = nullptr; | 874 CXFA_Node* pDataScope = nullptr; |
| 848 pFormNode = pFormNode->GetNodeItem(XFA_NODEITEM_Parent, | 875 pFormNode = pFormNode->GetNodeItem(XFA_NODEITEM_Parent, |
| 849 XFA_ObjectType::ContainerNode); | 876 XFA_ObjectType::ContainerNode); |
| 850 if (pLeaderTemplate) { | 877 if (pLeaderTemplate) { |
| 851 if (!pDataScope) { | 878 if (!pDataScope) |
| 852 pDataScope = XFA_DataMerge_FindDataScope(pFormNode); | 879 pDataScope = XFA_DataMerge_FindDataScope(pFormNode); |
| 853 } | 880 |
| 854 pBreakLeaderNode = pDocument->DataMerge_CopyContainer( | 881 pBreakLeaderNode = pDocument->DataMerge_CopyContainer( |
| 855 pLeaderTemplate, pFormNode, pDataScope, TRUE, TRUE, TRUE); | 882 pLeaderTemplate, pFormNode, pDataScope, TRUE, TRUE, TRUE); |
| 856 pDocument->DataMerge_UpdateBindingRelations(pBreakLeaderNode); | 883 pDocument->DataMerge_UpdateBindingRelations(pBreakLeaderNode); |
| 857 SetLayoutGeneratedNodeFlag(pBreakLeaderNode); | 884 SetLayoutGeneratedNodeFlag(pBreakLeaderNode); |
| 858 } | 885 } |
| 859 if (pTrailerTemplate) { | 886 if (pTrailerTemplate) { |
| 860 if (!pDataScope) { | 887 if (!pDataScope) |
| 861 pDataScope = XFA_DataMerge_FindDataScope(pFormNode); | 888 pDataScope = XFA_DataMerge_FindDataScope(pFormNode); |
| 862 } | 889 |
| 863 pBreakTrailerNode = pDocument->DataMerge_CopyContainer( | 890 pBreakTrailerNode = pDocument->DataMerge_CopyContainer( |
| 864 pTrailerTemplate, pFormNode, pDataScope, TRUE, TRUE, TRUE); | 891 pTrailerTemplate, pFormNode, pDataScope, TRUE, TRUE, TRUE); |
| 865 pDocument->DataMerge_UpdateBindingRelations(pBreakTrailerNode); | 892 pDocument->DataMerge_UpdateBindingRelations(pBreakTrailerNode); |
| 866 SetLayoutGeneratedNodeFlag(pBreakTrailerNode); | 893 SetLayoutGeneratedNodeFlag(pBreakTrailerNode); |
| 867 } | 894 } |
| 868 return TRUE; | 895 return TRUE; |
| 869 } | 896 } |
| 870 return FALSE; | 897 return FALSE; |
| 871 } | 898 } |
| 899 |
| 872 FX_BOOL CXFA_LayoutPageMgr::ProcessBookendLeaderOrTrailer( | 900 FX_BOOL CXFA_LayoutPageMgr::ProcessBookendLeaderOrTrailer( |
| 873 CXFA_Node* pBookendNode, | 901 CXFA_Node* pBookendNode, |
| 874 FX_BOOL bLeader, | 902 FX_BOOL bLeader, |
| 875 CXFA_Node*& pBookendAppendNode) { | 903 CXFA_Node*& pBookendAppendNode) { |
| 876 CXFA_Node* pLeaderTemplate = nullptr; | 904 CXFA_Node* pLeaderTemplate = nullptr; |
| 877 CXFA_Node* pFormNode = pBookendNode->GetNodeItem( | 905 CXFA_Node* pFormNode = pBookendNode->GetNodeItem( |
| 878 XFA_NODEITEM_Parent, XFA_ObjectType::ContainerNode); | 906 XFA_NODEITEM_Parent, XFA_ObjectType::ContainerNode); |
| 879 if (ResolveBookendLeaderOrTrailer(pBookendNode, bLeader, pLeaderTemplate)) { | 907 if (ResolveBookendLeaderOrTrailer(pBookendNode, bLeader, pLeaderTemplate)) { |
| 880 CXFA_Document* pDocument = pBookendNode->GetDocument(); | 908 CXFA_Document* pDocument = pBookendNode->GetDocument(); |
| 881 CXFA_Node* pDataScope = nullptr; | 909 CXFA_Node* pDataScope = nullptr; |
| 882 if (pLeaderTemplate) { | 910 if (pLeaderTemplate) { |
| 883 if (!pDataScope) { | 911 if (!pDataScope) |
| 884 pDataScope = XFA_DataMerge_FindDataScope(pFormNode); | 912 pDataScope = XFA_DataMerge_FindDataScope(pFormNode); |
| 885 } | 913 |
| 886 pBookendAppendNode = pDocument->DataMerge_CopyContainer( | 914 pBookendAppendNode = pDocument->DataMerge_CopyContainer( |
| 887 pLeaderTemplate, pFormNode, pDataScope, TRUE, TRUE, TRUE); | 915 pLeaderTemplate, pFormNode, pDataScope, TRUE, TRUE, TRUE); |
| 888 pDocument->DataMerge_UpdateBindingRelations(pBookendAppendNode); | 916 pDocument->DataMerge_UpdateBindingRelations(pBookendAppendNode); |
| 889 SetLayoutGeneratedNodeFlag(pBookendAppendNode); | 917 SetLayoutGeneratedNodeFlag(pBookendAppendNode); |
| 890 return TRUE; | 918 return TRUE; |
| 891 } | 919 } |
| 892 } | 920 } |
| 893 return FALSE; | 921 return FALSE; |
| 894 } | 922 } |
| 923 |
| 895 CXFA_Node* CXFA_LayoutPageMgr::BreakOverflow(CXFA_Node* pOverflowNode, | 924 CXFA_Node* CXFA_LayoutPageMgr::BreakOverflow(CXFA_Node* pOverflowNode, |
| 896 CXFA_Node*& pLeaderTemplate, | 925 CXFA_Node*& pLeaderTemplate, |
| 897 CXFA_Node*& pTrailerTemplate, | 926 CXFA_Node*& pTrailerTemplate, |
| 898 FX_BOOL bCreatePage) { | 927 FX_BOOL bCreatePage) { |
| 899 CXFA_Node* pContainer = | 928 CXFA_Node* pContainer = |
| 900 pOverflowNode | 929 pOverflowNode |
| 901 ->GetNodeItem(XFA_NODEITEM_Parent, XFA_ObjectType::ContainerNode) | 930 ->GetNodeItem(XFA_NODEITEM_Parent, XFA_ObjectType::ContainerNode) |
| 902 ->GetTemplateNode(); | 931 ->GetTemplateNode(); |
| 903 if (pOverflowNode->GetElementType() == XFA_Element::Break) { | 932 if (pOverflowNode->GetElementType() == XFA_Element::Break) { |
| 904 CFX_WideStringC wsOverflowLeader; | 933 CFX_WideStringC wsOverflowLeader; |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 973 pTrailerTemplate = ResolveBreakTarget(pContainer, TRUE, wsOverflowTrailer); | 1002 pTrailerTemplate = ResolveBreakTarget(pContainer, TRUE, wsOverflowTrailer); |
| 974 } | 1003 } |
| 975 return pOverflowNode; | 1004 return pOverflowNode; |
| 976 } | 1005 } |
| 977 | 1006 |
| 978 FX_BOOL CXFA_LayoutPageMgr::ProcessOverflow(CXFA_Node* pFormNode, | 1007 FX_BOOL CXFA_LayoutPageMgr::ProcessOverflow(CXFA_Node* pFormNode, |
| 979 CXFA_Node*& pLeaderNode, | 1008 CXFA_Node*& pLeaderNode, |
| 980 CXFA_Node*& pTrailerNode, | 1009 CXFA_Node*& pTrailerNode, |
| 981 FX_BOOL bDataMerge, | 1010 FX_BOOL bDataMerge, |
| 982 FX_BOOL bCreatePage) { | 1011 FX_BOOL bCreatePage) { |
| 983 if (!pFormNode) { | 1012 if (!pFormNode) |
| 984 return FALSE; | 1013 return FALSE; |
| 985 } | 1014 |
| 986 CXFA_Node* pLeaderTemplate = nullptr; | 1015 CXFA_Node* pLeaderTemplate = nullptr; |
| 987 CXFA_Node* pTrailerTemplate = nullptr; | 1016 CXFA_Node* pTrailerTemplate = nullptr; |
| 988 FX_BOOL bIsOverflowNode = FALSE; | 1017 FX_BOOL bIsOverflowNode = FALSE; |
| 989 if (pFormNode->GetElementType() == XFA_Element::Overflow || | 1018 if (pFormNode->GetElementType() == XFA_Element::Overflow || |
| 990 pFormNode->GetElementType() == XFA_Element::Break) { | 1019 pFormNode->GetElementType() == XFA_Element::Break) { |
| 991 bIsOverflowNode = TRUE; | 1020 bIsOverflowNode = TRUE; |
| 992 } | 1021 } |
| 993 for (CXFA_Node* pCurNode = | 1022 for (CXFA_Node* pCurNode = |
| 994 bIsOverflowNode ? pFormNode | 1023 bIsOverflowNode ? pFormNode |
| 995 : pFormNode->GetNodeItem(XFA_NODEITEM_FirstChild); | 1024 : pFormNode->GetNodeItem(XFA_NODEITEM_FirstChild); |
| 996 pCurNode; pCurNode = pCurNode->GetNodeItem((XFA_NODEITEM_NextSibling))) { | 1025 pCurNode; pCurNode = pCurNode->GetNodeItem((XFA_NODEITEM_NextSibling))) { |
| 997 if (BreakOverflow(pCurNode, pLeaderTemplate, pTrailerTemplate, | 1026 if (BreakOverflow(pCurNode, pLeaderTemplate, pTrailerTemplate, |
| 998 bCreatePage)) { | 1027 bCreatePage)) { |
| 999 if (bIsOverflowNode) { | 1028 if (bIsOverflowNode) |
| 1000 pFormNode = pCurNode->GetNodeItem(XFA_NODEITEM_Parent); | 1029 pFormNode = pCurNode->GetNodeItem(XFA_NODEITEM_Parent); |
| 1001 } | 1030 |
| 1002 CXFA_Document* pDocument = pCurNode->GetDocument(); | 1031 CXFA_Document* pDocument = pCurNode->GetDocument(); |
| 1003 CXFA_Node* pDataScope = nullptr; | 1032 CXFA_Node* pDataScope = nullptr; |
| 1004 if (pLeaderTemplate) { | 1033 if (pLeaderTemplate) { |
| 1005 if (!pDataScope) { | 1034 if (!pDataScope) |
| 1006 pDataScope = XFA_DataMerge_FindDataScope(pFormNode); | 1035 pDataScope = XFA_DataMerge_FindDataScope(pFormNode); |
| 1007 } | 1036 |
| 1008 pLeaderNode = pDocument->DataMerge_CopyContainer( | 1037 pLeaderNode = pDocument->DataMerge_CopyContainer( |
| 1009 pLeaderTemplate, pFormNode, pDataScope, TRUE, TRUE, TRUE); | 1038 pLeaderTemplate, pFormNode, pDataScope, TRUE, TRUE, TRUE); |
| 1010 pDocument->DataMerge_UpdateBindingRelations(pLeaderNode); | 1039 pDocument->DataMerge_UpdateBindingRelations(pLeaderNode); |
| 1011 SetLayoutGeneratedNodeFlag(pLeaderNode); | 1040 SetLayoutGeneratedNodeFlag(pLeaderNode); |
| 1012 } | 1041 } |
| 1013 if (pTrailerTemplate) { | 1042 if (pTrailerTemplate) { |
| 1014 if (!pDataScope) { | 1043 if (!pDataScope) |
| 1015 pDataScope = XFA_DataMerge_FindDataScope(pFormNode); | 1044 pDataScope = XFA_DataMerge_FindDataScope(pFormNode); |
| 1016 } | 1045 |
| 1017 pTrailerNode = pDocument->DataMerge_CopyContainer( | 1046 pTrailerNode = pDocument->DataMerge_CopyContainer( |
| 1018 pTrailerTemplate, pFormNode, pDataScope, TRUE, TRUE, TRUE); | 1047 pTrailerTemplate, pFormNode, pDataScope, TRUE, TRUE, TRUE); |
| 1019 pDocument->DataMerge_UpdateBindingRelations(pTrailerNode); | 1048 pDocument->DataMerge_UpdateBindingRelations(pTrailerNode); |
| 1020 SetLayoutGeneratedNodeFlag(pTrailerNode); | 1049 SetLayoutGeneratedNodeFlag(pTrailerNode); |
| 1021 } | 1050 } |
| 1022 return TRUE; | 1051 return TRUE; |
| 1023 } | 1052 } |
| 1024 if (bIsOverflowNode) { | 1053 if (bIsOverflowNode) { |
| 1025 break; | 1054 break; |
| 1026 } | 1055 } |
| 1027 } | 1056 } |
| 1028 return FALSE; | 1057 return FALSE; |
| 1029 } | 1058 } |
| 1059 |
| 1030 FX_BOOL CXFA_LayoutPageMgr::ResolveBookendLeaderOrTrailer( | 1060 FX_BOOL CXFA_LayoutPageMgr::ResolveBookendLeaderOrTrailer( |
| 1031 CXFA_Node* pBookendNode, | 1061 CXFA_Node* pBookendNode, |
| 1032 FX_BOOL bLeader, | 1062 FX_BOOL bLeader, |
| 1033 CXFA_Node*& pBookendAppendTemplate) { | 1063 CXFA_Node*& pBookendAppendTemplate) { |
| 1034 CFX_WideStringC wsBookendLeader; | 1064 CFX_WideStringC wsBookendLeader; |
| 1035 CXFA_Node* pContainer = | 1065 CXFA_Node* pContainer = |
| 1036 pBookendNode | 1066 pBookendNode |
| 1037 ->GetNodeItem(XFA_NODEITEM_Parent, XFA_ObjectType::ContainerNode) | 1067 ->GetNodeItem(XFA_NODEITEM_Parent, XFA_ObjectType::ContainerNode) |
| 1038 ->GetTemplateNode(); | 1068 ->GetTemplateNode(); |
| 1039 if (pBookendNode->GetElementType() == XFA_Element::Break) { | 1069 if (pBookendNode->GetElementType() == XFA_Element::Break) { |
| 1040 pBookendNode->TryCData( | 1070 pBookendNode->TryCData( |
| 1041 bLeader ? XFA_ATTRIBUTE_BookendLeader : XFA_ATTRIBUTE_BookendTrailer, | 1071 bLeader ? XFA_ATTRIBUTE_BookendLeader : XFA_ATTRIBUTE_BookendTrailer, |
| 1042 wsBookendLeader); | 1072 wsBookendLeader); |
| 1043 if (!wsBookendLeader.IsEmpty()) { | 1073 if (!wsBookendLeader.IsEmpty()) { |
| 1044 pBookendAppendTemplate = | 1074 pBookendAppendTemplate = |
| 1045 ResolveBreakTarget(pContainer, FALSE, wsBookendLeader); | 1075 ResolveBreakTarget(pContainer, FALSE, wsBookendLeader); |
| 1046 return TRUE; | 1076 return TRUE; |
| 1047 } | 1077 } |
| 1048 return FALSE; | 1078 return FALSE; |
| 1049 } else if (pBookendNode->GetElementType() == XFA_Element::Bookend) { | 1079 } else if (pBookendNode->GetElementType() == XFA_Element::Bookend) { |
| 1050 pBookendNode->TryCData( | 1080 pBookendNode->TryCData( |
| 1051 bLeader ? XFA_ATTRIBUTE_Leader : XFA_ATTRIBUTE_Trailer, | 1081 bLeader ? XFA_ATTRIBUTE_Leader : XFA_ATTRIBUTE_Trailer, |
| 1052 wsBookendLeader); | 1082 wsBookendLeader); |
| 1053 pBookendAppendTemplate = | 1083 pBookendAppendTemplate = |
| 1054 ResolveBreakTarget(pContainer, TRUE, wsBookendLeader); | 1084 ResolveBreakTarget(pContainer, TRUE, wsBookendLeader); |
| 1055 return TRUE; | 1085 return TRUE; |
| 1056 } | 1086 } |
| 1057 return FALSE; | 1087 return FALSE; |
| 1058 } | 1088 } |
| 1089 |
| 1059 FX_BOOL CXFA_LayoutPageMgr::FindPageAreaFromPageSet( | 1090 FX_BOOL CXFA_LayoutPageMgr::FindPageAreaFromPageSet( |
| 1060 CXFA_Node* pPageSet, | 1091 CXFA_Node* pPageSet, |
| 1061 CXFA_Node* pStartChild, | 1092 CXFA_Node* pStartChild, |
| 1062 CXFA_Node* pTargetPageArea, | 1093 CXFA_Node* pTargetPageArea, |
| 1063 CXFA_Node* pTargetContentArea, | 1094 CXFA_Node* pTargetContentArea, |
| 1064 FX_BOOL bNewPage, | 1095 FX_BOOL bNewPage, |
| 1065 FX_BOOL bQuery) { | 1096 FX_BOOL bQuery) { |
| 1066 if (!pPageSet && !pStartChild) { | 1097 if (!pPageSet && !pStartChild) |
| 1067 return FALSE; | 1098 return FALSE; |
| 1068 } | 1099 |
| 1069 if (IsPageSetRootOrderedOccurrence()) { | 1100 if (IsPageSetRootOrderedOccurrence()) { |
| 1070 return FindPageAreaFromPageSet_Ordered(pPageSet, pStartChild, | 1101 return FindPageAreaFromPageSet_Ordered(pPageSet, pStartChild, |
| 1071 pTargetPageArea, pTargetContentArea, | 1102 pTargetPageArea, pTargetContentArea, |
| 1072 bNewPage, bQuery); | 1103 bNewPage, bQuery); |
| 1073 } | 1104 } |
| 1074 XFA_ATTRIBUTEENUM ePreferredPosition = m_pCurrentContainerRecord | 1105 XFA_ATTRIBUTEENUM ePreferredPosition = m_pCurrentContainerRecord |
| 1075 ? XFA_ATTRIBUTEENUM_Rest | 1106 ? XFA_ATTRIBUTEENUM_Rest |
| 1076 : XFA_ATTRIBUTEENUM_First; | 1107 : XFA_ATTRIBUTEENUM_First; |
| 1077 return FindPageAreaFromPageSet_SimplexDuplex( | 1108 return FindPageAreaFromPageSet_SimplexDuplex( |
| 1078 pPageSet, pStartChild, pTargetPageArea, pTargetContentArea, bNewPage, | 1109 pPageSet, pStartChild, pTargetPageArea, pTargetContentArea, bNewPage, |
| 1079 bQuery, ePreferredPosition); | 1110 bQuery, ePreferredPosition); |
| 1080 } | 1111 } |
| 1112 |
| 1081 FX_BOOL CXFA_LayoutPageMgr::FindPageAreaFromPageSet_Ordered( | 1113 FX_BOOL CXFA_LayoutPageMgr::FindPageAreaFromPageSet_Ordered( |
| 1082 CXFA_Node* pPageSet, | 1114 CXFA_Node* pPageSet, |
| 1083 CXFA_Node* pStartChild, | 1115 CXFA_Node* pStartChild, |
| 1084 CXFA_Node* pTargetPageArea, | 1116 CXFA_Node* pTargetPageArea, |
| 1085 CXFA_Node* pTargetContentArea, | 1117 CXFA_Node* pTargetContentArea, |
| 1086 FX_BOOL bNewPage, | 1118 FX_BOOL bNewPage, |
| 1087 FX_BOOL bQuery) { | 1119 FX_BOOL bQuery) { |
| 1088 int32_t iPageSetCount = 0; | 1120 int32_t iPageSetCount = 0; |
| 1089 if (!pStartChild && !bQuery) { | 1121 if (!pStartChild && !bQuery) { |
| 1090 m_pPageSetMap.Lookup(pPageSet, iPageSetCount); | 1122 m_pPageSetMap.Lookup(pPageSet, iPageSetCount); |
| 1091 int32_t iMax = -1; | 1123 int32_t iMax = -1; |
| 1092 CXFA_Node* pOccurNode = pPageSet->GetFirstChildByClass(XFA_Element::Occur); | 1124 CXFA_Node* pOccurNode = pPageSet->GetFirstChildByClass(XFA_Element::Occur); |
| 1093 if (pOccurNode) { | 1125 if (pOccurNode) |
| 1094 pOccurNode->TryInteger(XFA_ATTRIBUTE_Max, iMax, FALSE); | 1126 pOccurNode->TryInteger(XFA_ATTRIBUTE_Max, iMax, FALSE); |
| 1095 } | 1127 if (iMax >= 0 && iMax <= iPageSetCount) |
| 1096 if (iMax >= 0 && iMax <= iPageSetCount) { | |
| 1097 return FALSE; | 1128 return FALSE; |
| 1098 } | |
| 1099 } | 1129 } |
| 1130 |
| 1100 FX_BOOL bRes = FALSE; | 1131 FX_BOOL bRes = FALSE; |
| 1101 CXFA_Node* pCurrentNode = | 1132 CXFA_Node* pCurrentNode = |
| 1102 pStartChild ? pStartChild->GetNodeItem(XFA_NODEITEM_NextSibling) | 1133 pStartChild ? pStartChild->GetNodeItem(XFA_NODEITEM_NextSibling) |
| 1103 : pPageSet->GetNodeItem(XFA_NODEITEM_FirstChild); | 1134 : pPageSet->GetNodeItem(XFA_NODEITEM_FirstChild); |
| 1104 for (; pCurrentNode; | 1135 for (; pCurrentNode; |
| 1105 pCurrentNode = pCurrentNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { | 1136 pCurrentNode = pCurrentNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { |
| 1106 if (pCurrentNode->GetElementType() == XFA_Element::PageArea) { | 1137 if (pCurrentNode->GetElementType() == XFA_Element::PageArea) { |
| 1107 if ((pTargetPageArea == pCurrentNode || !pTargetPageArea)) { | 1138 if ((pTargetPageArea == pCurrentNode || !pTargetPageArea)) { |
| 1108 if (!pCurrentNode->GetFirstChildByClass(XFA_Element::ContentArea)) { | 1139 if (!pCurrentNode->GetFirstChildByClass(XFA_Element::ContentArea)) { |
| 1109 if (pTargetPageArea == pCurrentNode) { | 1140 if (pTargetPageArea == pCurrentNode) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1120 pTargetContentArea = | 1151 pTargetContentArea = |
| 1121 pCurrentNode->GetFirstChildByClass(XFA_Element::ContentArea); | 1152 pCurrentNode->GetFirstChildByClass(XFA_Element::ContentArea); |
| 1122 } | 1153 } |
| 1123 AddContentAreaLayoutItem(pNewRecord, pTargetContentArea); | 1154 AddContentAreaLayoutItem(pNewRecord, pTargetContentArea); |
| 1124 } | 1155 } |
| 1125 m_pCurPageArea = pCurrentNode; | 1156 m_pCurPageArea = pCurrentNode; |
| 1126 m_nCurPageCount = 1; | 1157 m_nCurPageCount = 1; |
| 1127 bRes = TRUE; | 1158 bRes = TRUE; |
| 1128 break; | 1159 break; |
| 1129 } | 1160 } |
| 1130 if (!bQuery) { | 1161 if (!bQuery) |
| 1131 CreateMinPageRecord(pCurrentNode, FALSE); | 1162 CreateMinPageRecord(pCurrentNode, FALSE); |
| 1132 } | |
| 1133 } else if (pCurrentNode->GetElementType() == XFA_Element::PageSet) { | 1163 } else if (pCurrentNode->GetElementType() == XFA_Element::PageSet) { |
| 1134 if (FindPageAreaFromPageSet_Ordered(pCurrentNode, nullptr, | 1164 if (FindPageAreaFromPageSet_Ordered(pCurrentNode, nullptr, |
| 1135 pTargetPageArea, pTargetContentArea, | 1165 pTargetPageArea, pTargetContentArea, |
| 1136 bNewPage, bQuery)) { | 1166 bNewPage, bQuery)) { |
| 1137 bRes = TRUE; | 1167 bRes = TRUE; |
| 1138 break; | 1168 break; |
| 1139 } | 1169 } |
| 1140 if (!bQuery) { | 1170 if (!bQuery) |
| 1141 CreateMinPageSetRecord(pCurrentNode, TRUE); | 1171 CreateMinPageSetRecord(pCurrentNode, TRUE); |
| 1142 } | |
| 1143 } | 1172 } |
| 1144 } | 1173 } |
| 1145 if (!pStartChild && bRes && !bQuery) { | 1174 if (!pStartChild && bRes && !bQuery) |
| 1146 m_pPageSetMap.SetAt(pPageSet, ++iPageSetCount); | 1175 m_pPageSetMap.SetAt(pPageSet, ++iPageSetCount); |
| 1147 } | |
| 1148 return bRes; | 1176 return bRes; |
| 1149 } | 1177 } |
| 1178 |
| 1150 FX_BOOL CXFA_LayoutPageMgr::FindPageAreaFromPageSet_SimplexDuplex( | 1179 FX_BOOL CXFA_LayoutPageMgr::FindPageAreaFromPageSet_SimplexDuplex( |
| 1151 CXFA_Node* pPageSet, | 1180 CXFA_Node* pPageSet, |
| 1152 CXFA_Node* pStartChild, | 1181 CXFA_Node* pStartChild, |
| 1153 CXFA_Node* pTargetPageArea, | 1182 CXFA_Node* pTargetPageArea, |
| 1154 CXFA_Node* pTargetContentArea, | 1183 CXFA_Node* pTargetContentArea, |
| 1155 FX_BOOL bNewPage, | 1184 FX_BOOL bNewPage, |
| 1156 FX_BOOL bQuery, | 1185 FX_BOOL bQuery, |
| 1157 XFA_ATTRIBUTEENUM ePreferredPosition) { | 1186 XFA_ATTRIBUTEENUM ePreferredPosition) { |
| 1158 const XFA_ATTRIBUTEENUM eFallbackPosition = XFA_ATTRIBUTEENUM_Any; | 1187 const XFA_ATTRIBUTEENUM eFallbackPosition = XFA_ATTRIBUTEENUM_Any; |
| 1159 CXFA_Node* pPreferredPageArea = nullptr; | 1188 CXFA_Node* pPreferredPageArea = nullptr; |
| 1160 CXFA_Node* pFallbackPageArea = nullptr; | 1189 CXFA_Node* pFallbackPageArea = nullptr; |
| 1161 CXFA_Node* pCurrentNode = nullptr; | 1190 CXFA_Node* pCurrentNode = nullptr; |
| 1162 if (!pStartChild || pStartChild->GetElementType() == XFA_Element::PageArea) { | 1191 if (!pStartChild || pStartChild->GetElementType() == XFA_Element::PageArea) |
| 1163 pCurrentNode = pPageSet->GetNodeItem(XFA_NODEITEM_FirstChild); | 1192 pCurrentNode = pPageSet->GetNodeItem(XFA_NODEITEM_FirstChild); |
| 1164 } else { | 1193 else |
| 1165 pCurrentNode = pStartChild->GetNodeItem(XFA_NODEITEM_NextSibling); | 1194 pCurrentNode = pStartChild->GetNodeItem(XFA_NODEITEM_NextSibling); |
| 1166 } | 1195 |
| 1167 for (; pCurrentNode; | 1196 for (; pCurrentNode; |
| 1168 pCurrentNode = pCurrentNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { | 1197 pCurrentNode = pCurrentNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { |
| 1169 if (pCurrentNode->GetElementType() == XFA_Element::PageArea) { | 1198 if (pCurrentNode->GetElementType() == XFA_Element::PageArea) { |
| 1170 if (!MatchPageAreaOddOrEven(pCurrentNode, FALSE)) { | 1199 if (!MatchPageAreaOddOrEven(pCurrentNode, FALSE)) |
| 1171 continue; | 1200 continue; |
| 1172 } | 1201 |
| 1173 XFA_ATTRIBUTEENUM eCurPagePosition = | 1202 XFA_ATTRIBUTEENUM eCurPagePosition = |
| 1174 pCurrentNode->GetEnum(XFA_ATTRIBUTE_PagePosition); | 1203 pCurrentNode->GetEnum(XFA_ATTRIBUTE_PagePosition); |
| 1175 if (ePreferredPosition == XFA_ATTRIBUTEENUM_Last) { | 1204 if (ePreferredPosition == XFA_ATTRIBUTEENUM_Last) { |
| 1176 if (eCurPagePosition != ePreferredPosition) { | 1205 if (eCurPagePosition != ePreferredPosition) |
| 1177 continue; | 1206 continue; |
| 1178 } | |
| 1179 if (m_ePageSetMode == XFA_ATTRIBUTEENUM_SimplexPaginated || | 1207 if (m_ePageSetMode == XFA_ATTRIBUTEENUM_SimplexPaginated || |
| 1180 pCurrentNode->GetEnum(XFA_ATTRIBUTE_OddOrEven) == | 1208 pCurrentNode->GetEnum(XFA_ATTRIBUTE_OddOrEven) == |
| 1181 XFA_ATTRIBUTEENUM_Any) { | 1209 XFA_ATTRIBUTEENUM_Any) { |
| 1182 pPreferredPageArea = pCurrentNode; | 1210 pPreferredPageArea = pCurrentNode; |
| 1183 break; | 1211 break; |
| 1184 } | 1212 } |
| 1185 CXFA_ContainerRecord* pNewRecord = CreateContainerRecord(); | 1213 CXFA_ContainerRecord* pNewRecord = CreateContainerRecord(); |
| 1186 AddPageAreaLayoutItem(pNewRecord, pCurrentNode); | 1214 AddPageAreaLayoutItem(pNewRecord, pCurrentNode); |
| 1187 AddContentAreaLayoutItem(pNewRecord, pCurrentNode->GetFirstChildByClass( | 1215 AddContentAreaLayoutItem(pNewRecord, pCurrentNode->GetFirstChildByClass( |
| 1188 XFA_Element::ContentArea)); | 1216 XFA_Element::ContentArea)); |
| 1189 pPreferredPageArea = pCurrentNode; | 1217 pPreferredPageArea = pCurrentNode; |
| 1190 return FALSE; | 1218 return FALSE; |
| 1191 } else if (ePreferredPosition == XFA_ATTRIBUTEENUM_Only) { | 1219 } |
| 1192 if (eCurPagePosition != ePreferredPosition) { | 1220 if (ePreferredPosition == XFA_ATTRIBUTEENUM_Only) { |
| 1221 if (eCurPagePosition != ePreferredPosition) |
| 1193 continue; | 1222 continue; |
| 1194 } | |
| 1195 if (m_ePageSetMode != XFA_ATTRIBUTEENUM_DuplexPaginated || | 1223 if (m_ePageSetMode != XFA_ATTRIBUTEENUM_DuplexPaginated || |
| 1196 pCurrentNode->GetEnum(XFA_ATTRIBUTE_OddOrEven) == | 1224 pCurrentNode->GetEnum(XFA_ATTRIBUTE_OddOrEven) == |
| 1197 XFA_ATTRIBUTEENUM_Any) { | 1225 XFA_ATTRIBUTEENUM_Any) { |
| 1198 pPreferredPageArea = pCurrentNode; | 1226 pPreferredPageArea = pCurrentNode; |
| 1199 break; | 1227 break; |
| 1200 } | 1228 } |
| 1201 return FALSE; | 1229 return FALSE; |
| 1202 } | 1230 } |
| 1203 if ((pTargetPageArea == pCurrentNode || !pTargetPageArea)) { | 1231 if ((pTargetPageArea == pCurrentNode || !pTargetPageArea)) { |
| 1204 if (!pCurrentNode->GetFirstChildByClass(XFA_Element::ContentArea)) { | 1232 if (!pCurrentNode->GetFirstChildByClass(XFA_Element::ContentArea)) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1226 XFA_Element::ContentArea)); | 1254 XFA_Element::ContentArea)); |
| 1227 } | 1255 } |
| 1228 } else if (pCurrentNode->GetElementType() == XFA_Element::PageSet) { | 1256 } else if (pCurrentNode->GetElementType() == XFA_Element::PageSet) { |
| 1229 if (FindPageAreaFromPageSet_SimplexDuplex( | 1257 if (FindPageAreaFromPageSet_SimplexDuplex( |
| 1230 pCurrentNode, nullptr, pTargetPageArea, pTargetContentArea, | 1258 pCurrentNode, nullptr, pTargetPageArea, pTargetContentArea, |
| 1231 bNewPage, bQuery, ePreferredPosition)) { | 1259 bNewPage, bQuery, ePreferredPosition)) { |
| 1232 break; | 1260 break; |
| 1233 } | 1261 } |
| 1234 } | 1262 } |
| 1235 } | 1263 } |
| 1264 |
| 1236 CXFA_Node* pCurPageArea = nullptr; | 1265 CXFA_Node* pCurPageArea = nullptr; |
| 1237 if (pPreferredPageArea) { | 1266 if (pPreferredPageArea) |
| 1238 pCurPageArea = pPreferredPageArea; | 1267 pCurPageArea = pPreferredPageArea; |
| 1239 } else if (pFallbackPageArea) { | 1268 else if (pFallbackPageArea) |
| 1240 pCurPageArea = pFallbackPageArea; | 1269 pCurPageArea = pFallbackPageArea; |
| 1241 } | 1270 |
| 1242 if (!pCurPageArea) { | 1271 if (!pCurPageArea) |
| 1243 return FALSE; | 1272 return FALSE; |
| 1244 } | 1273 |
| 1245 if (!bQuery) { | 1274 if (!bQuery) { |
| 1246 CXFA_ContainerRecord* pNewRecord = CreateContainerRecord(); | 1275 CXFA_ContainerRecord* pNewRecord = CreateContainerRecord(); |
| 1247 AddPageAreaLayoutItem(pNewRecord, pCurPageArea); | 1276 AddPageAreaLayoutItem(pNewRecord, pCurPageArea); |
| 1248 if (!pTargetContentArea) { | 1277 if (!pTargetContentArea) { |
| 1249 pTargetContentArea = | 1278 pTargetContentArea = |
| 1250 pCurPageArea->GetFirstChildByClass(XFA_Element::ContentArea); | 1279 pCurPageArea->GetFirstChildByClass(XFA_Element::ContentArea); |
| 1251 } | 1280 } |
| 1252 AddContentAreaLayoutItem(pNewRecord, pTargetContentArea); | 1281 AddContentAreaLayoutItem(pNewRecord, pTargetContentArea); |
| 1253 } | 1282 } |
| 1254 m_pCurPageArea = pCurPageArea; | 1283 m_pCurPageArea = pCurPageArea; |
| 1255 return TRUE; | 1284 return TRUE; |
| 1256 } | 1285 } |
| 1286 |
| 1257 FX_BOOL CXFA_LayoutPageMgr::MatchPageAreaOddOrEven(CXFA_Node* pPageArea, | 1287 FX_BOOL CXFA_LayoutPageMgr::MatchPageAreaOddOrEven(CXFA_Node* pPageArea, |
| 1258 FX_BOOL bLastMatch) { | 1288 FX_BOOL bLastMatch) { |
| 1259 if (m_ePageSetMode != XFA_ATTRIBUTEENUM_DuplexPaginated) { | 1289 if (m_ePageSetMode != XFA_ATTRIBUTEENUM_DuplexPaginated) |
| 1260 return TRUE; | 1290 return TRUE; |
| 1261 } | 1291 |
| 1262 XFA_ATTRIBUTEENUM eOddOrEven = XFA_ATTRIBUTEENUM_Any; | 1292 XFA_ATTRIBUTEENUM eOddOrEven = XFA_ATTRIBUTEENUM_Any; |
| 1263 pPageArea->TryEnum(XFA_ATTRIBUTE_OddOrEven, eOddOrEven); | 1293 pPageArea->TryEnum(XFA_ATTRIBUTE_OddOrEven, eOddOrEven); |
| 1264 if (eOddOrEven != XFA_ATTRIBUTEENUM_Any) { | 1294 if (eOddOrEven != XFA_ATTRIBUTEENUM_Any) { |
| 1265 int32_t iPageCount = GetPageCount(); | 1295 int32_t iPageCount = GetPageCount(); |
| 1266 if (bLastMatch) { | 1296 if (bLastMatch) { |
| 1267 return eOddOrEven == XFA_ATTRIBUTEENUM_Odd ? iPageCount % 2 == 1 | 1297 return eOddOrEven == XFA_ATTRIBUTEENUM_Odd ? iPageCount % 2 == 1 |
| 1268 : iPageCount % 2 == 0; | 1298 : iPageCount % 2 == 0; |
| 1269 } | 1299 } |
| 1270 return eOddOrEven == XFA_ATTRIBUTEENUM_Odd ? iPageCount % 2 == 0 | 1300 return eOddOrEven == XFA_ATTRIBUTEENUM_Odd ? iPageCount % 2 == 0 |
| 1271 : iPageCount % 2 == 1; | 1301 : iPageCount % 2 == 1; |
| 1272 } | 1302 } |
| 1273 return TRUE; | 1303 return TRUE; |
| 1274 } | 1304 } |
| 1305 |
| 1275 CXFA_Node* CXFA_LayoutPageMgr::GetNextAvailPageArea( | 1306 CXFA_Node* CXFA_LayoutPageMgr::GetNextAvailPageArea( |
| 1276 CXFA_Node* pTargetPageArea, | 1307 CXFA_Node* pTargetPageArea, |
| 1277 CXFA_Node* pTargetContentArea, | 1308 CXFA_Node* pTargetContentArea, |
| 1278 FX_BOOL bNewPage, | 1309 FX_BOOL bNewPage, |
| 1279 FX_BOOL bQuery) { | 1310 FX_BOOL bQuery) { |
| 1280 if (!m_pCurPageArea) { | 1311 if (!m_pCurPageArea) { |
| 1281 FindPageAreaFromPageSet(m_pTemplatePageSetRoot, nullptr, pTargetPageArea, | 1312 FindPageAreaFromPageSet(m_pTemplatePageSetRoot, nullptr, pTargetPageArea, |
| 1282 pTargetContentArea, bNewPage, bQuery); | 1313 pTargetContentArea, bNewPage, bQuery); |
| 1283 ASSERT(m_pCurPageArea); | 1314 ASSERT(m_pCurPageArea); |
| 1284 return m_pCurPageArea; | 1315 return m_pCurPageArea; |
| 1285 } | 1316 } |
| 1317 |
| 1286 if (!pTargetPageArea || pTargetPageArea == m_pCurPageArea) { | 1318 if (!pTargetPageArea || pTargetPageArea == m_pCurPageArea) { |
| 1287 if (!bNewPage && GetNextContentArea(pTargetContentArea)) { | 1319 if (!bNewPage && GetNextContentArea(pTargetContentArea)) |
| 1288 return m_pCurPageArea; | 1320 return m_pCurPageArea; |
| 1289 } | 1321 |
| 1290 if (IsPageSetRootOrderedOccurrence()) { | 1322 if (IsPageSetRootOrderedOccurrence()) { |
| 1291 int32_t iMax = -1; | 1323 int32_t iMax = -1; |
| 1292 CXFA_Node* pOccurNode = | 1324 CXFA_Node* pOccurNode = |
| 1293 m_pCurPageArea->GetFirstChildByClass(XFA_Element::Occur); | 1325 m_pCurPageArea->GetFirstChildByClass(XFA_Element::Occur); |
| 1294 if (pOccurNode) { | 1326 if (pOccurNode) |
| 1295 pOccurNode->TryInteger(XFA_ATTRIBUTE_Max, iMax, FALSE); | 1327 pOccurNode->TryInteger(XFA_ATTRIBUTE_Max, iMax, FALSE); |
| 1296 } | |
| 1297 if ((iMax < 0 || m_nCurPageCount < iMax)) { | 1328 if ((iMax < 0 || m_nCurPageCount < iMax)) { |
| 1298 if (!bQuery) { | 1329 if (!bQuery) { |
| 1299 CXFA_ContainerRecord* pNewRecord = | 1330 CXFA_ContainerRecord* pNewRecord = |
| 1300 CreateContainerRecord(m_pCurPageArea); | 1331 CreateContainerRecord(m_pCurPageArea); |
| 1301 AddPageAreaLayoutItem(pNewRecord, m_pCurPageArea); | 1332 AddPageAreaLayoutItem(pNewRecord, m_pCurPageArea); |
| 1302 if (!pTargetContentArea) { | 1333 if (!pTargetContentArea) { |
| 1303 pTargetContentArea = | 1334 pTargetContentArea = |
| 1304 m_pCurPageArea->GetFirstChildByClass(XFA_Element::ContentArea); | 1335 m_pCurPageArea->GetFirstChildByClass(XFA_Element::ContentArea); |
| 1305 } | 1336 } |
| 1306 AddContentAreaLayoutItem(pNewRecord, pTargetContentArea); | 1337 AddContentAreaLayoutItem(pNewRecord, pTargetContentArea); |
| 1307 } | 1338 } |
| 1308 m_nCurPageCount++; | 1339 m_nCurPageCount++; |
| 1309 return m_pCurPageArea; | 1340 return m_pCurPageArea; |
| 1310 } | 1341 } |
| 1311 } | 1342 } |
| 1312 } | 1343 } |
| 1313 if (!bQuery && IsPageSetRootOrderedOccurrence()) { | 1344 |
| 1345 if (!bQuery && IsPageSetRootOrderedOccurrence()) |
| 1314 CreateMinPageRecord(m_pCurPageArea, FALSE, TRUE); | 1346 CreateMinPageRecord(m_pCurPageArea, FALSE, TRUE); |
| 1315 } | |
| 1316 if (FindPageAreaFromPageSet(m_pCurPageArea->GetNodeItem(XFA_NODEITEM_Parent), | 1347 if (FindPageAreaFromPageSet(m_pCurPageArea->GetNodeItem(XFA_NODEITEM_Parent), |
| 1317 m_pCurPageArea, pTargetPageArea, | 1348 m_pCurPageArea, pTargetPageArea, |
| 1318 pTargetContentArea, bNewPage, bQuery)) { | 1349 pTargetContentArea, bNewPage, bQuery)) { |
| 1319 return m_pCurPageArea; | 1350 return m_pCurPageArea; |
| 1320 } | 1351 } |
| 1352 |
| 1321 CXFA_Node* pPageSet = m_pCurPageArea->GetNodeItem(XFA_NODEITEM_Parent); | 1353 CXFA_Node* pPageSet = m_pCurPageArea->GetNodeItem(XFA_NODEITEM_Parent); |
| 1322 while (TRUE) { | 1354 while (TRUE) { |
| 1323 if (FindPageAreaFromPageSet(pPageSet, nullptr, pTargetPageArea, | 1355 if (FindPageAreaFromPageSet(pPageSet, nullptr, pTargetPageArea, |
| 1324 pTargetContentArea, bNewPage, bQuery)) { | 1356 pTargetContentArea, bNewPage, bQuery)) { |
| 1325 return m_pCurPageArea; | 1357 return m_pCurPageArea; |
| 1326 } | 1358 } |
| 1327 if (!bQuery && IsPageSetRootOrderedOccurrence()) { | 1359 if (!bQuery && IsPageSetRootOrderedOccurrence()) |
| 1328 CreateMinPageSetRecord(pPageSet); | 1360 CreateMinPageSetRecord(pPageSet); |
| 1329 } | |
| 1330 if (FindPageAreaFromPageSet(nullptr, pPageSet, pTargetPageArea, | 1361 if (FindPageAreaFromPageSet(nullptr, pPageSet, pTargetPageArea, |
| 1331 pTargetContentArea, bNewPage, bQuery)) { | 1362 pTargetContentArea, bNewPage, bQuery)) { |
| 1332 return m_pCurPageArea; | 1363 return m_pCurPageArea; |
| 1333 } | 1364 } |
| 1334 if (pPageSet == m_pTemplatePageSetRoot) { | 1365 if (pPageSet == m_pTemplatePageSetRoot) |
| 1335 break; | 1366 break; |
| 1336 } | 1367 |
| 1337 pPageSet = pPageSet->GetNodeItem(XFA_NODEITEM_Parent); | 1368 pPageSet = pPageSet->GetNodeItem(XFA_NODEITEM_Parent); |
| 1338 } | 1369 } |
| 1339 return nullptr; | 1370 return nullptr; |
| 1340 } | 1371 } |
| 1341 | 1372 |
| 1342 FX_BOOL CXFA_LayoutPageMgr::GetNextContentArea(CXFA_Node* pContentArea) { | 1373 FX_BOOL CXFA_LayoutPageMgr::GetNextContentArea(CXFA_Node* pContentArea) { |
| 1343 CXFA_Node* pCurContentNode = | 1374 CXFA_Node* pCurContentNode = |
| 1344 GetCurrentContainerRecord()->pCurContentArea->m_pFormNode; | 1375 GetCurrentContainerRecord()->pCurContentArea->m_pFormNode; |
| 1345 if (!pContentArea) { | 1376 if (!pContentArea) { |
| 1346 pContentArea = | 1377 pContentArea = |
| 1347 pCurContentNode->GetNextSameClassSibling(XFA_Element::ContentArea); | 1378 pCurContentNode->GetNextSameClassSibling(XFA_Element::ContentArea); |
| 1348 if (!pContentArea) { | 1379 if (!pContentArea) |
| 1349 return FALSE; | 1380 return FALSE; |
| 1350 } | |
| 1351 } else { | 1381 } else { |
| 1352 if (pContentArea->GetNodeItem(XFA_NODEITEM_Parent) != m_pCurPageArea) { | 1382 if (pContentArea->GetNodeItem(XFA_NODEITEM_Parent) != m_pCurPageArea) |
| 1353 return FALSE; | 1383 return FALSE; |
| 1354 } | 1384 |
| 1355 CXFA_ContainerLayoutItem* pContentAreaLayout = nullptr; | 1385 CXFA_ContainerLayoutItem* pContentAreaLayout = nullptr; |
| 1356 if (!CheckContentAreaNotUsed(GetCurrentContainerRecord()->pCurPageArea, | 1386 if (!CheckContentAreaNotUsed(GetCurrentContainerRecord()->pCurPageArea, |
| 1357 pContentArea, pContentAreaLayout)) { | 1387 pContentArea, pContentAreaLayout)) { |
| 1358 return FALSE; | 1388 return FALSE; |
| 1359 } | 1389 } |
| 1360 if (pContentAreaLayout) { | 1390 if (pContentAreaLayout) { |
| 1361 if (pContentAreaLayout->m_pFormNode != pCurContentNode) { | 1391 if (pContentAreaLayout->m_pFormNode != pCurContentNode) { |
| 1362 CXFA_ContainerRecord* pNewRecord = CreateContainerRecord(); | 1392 CXFA_ContainerRecord* pNewRecord = CreateContainerRecord(); |
| 1363 pNewRecord->pCurContentArea = pContentAreaLayout; | 1393 pNewRecord->pCurContentArea = pContentAreaLayout; |
| 1364 return TRUE; | 1394 return TRUE; |
| 1365 } else { | |
| 1366 return FALSE; | |
| 1367 } | 1395 } |
| 1396 return FALSE; |
| 1368 } | 1397 } |
| 1369 } | 1398 } |
| 1399 |
| 1370 CXFA_ContainerRecord* pNewRecord = CreateContainerRecord(); | 1400 CXFA_ContainerRecord* pNewRecord = CreateContainerRecord(); |
| 1371 AddContentAreaLayoutItem(pNewRecord, pContentArea); | 1401 AddContentAreaLayoutItem(pNewRecord, pContentArea); |
| 1372 return TRUE; | 1402 return TRUE; |
| 1373 } | 1403 } |
| 1404 |
| 1374 void CXFA_LayoutPageMgr::InitPageSetMap() { | 1405 void CXFA_LayoutPageMgr::InitPageSetMap() { |
| 1375 if (!IsPageSetRootOrderedOccurrence()) { | 1406 if (!IsPageSetRootOrderedOccurrence()) |
| 1376 return; | 1407 return; |
| 1377 } | 1408 |
| 1378 CXFA_NodeIterator sIterator(m_pTemplatePageSetRoot); | 1409 CXFA_NodeIterator sIterator(m_pTemplatePageSetRoot); |
| 1379 for (CXFA_Node* pPageSetNode = sIterator.GetCurrent(); pPageSetNode; | 1410 for (CXFA_Node* pPageSetNode = sIterator.GetCurrent(); pPageSetNode; |
| 1380 pPageSetNode = sIterator.MoveToNext()) { | 1411 pPageSetNode = sIterator.MoveToNext()) { |
| 1381 if (pPageSetNode->GetElementType() == XFA_Element::PageSet) { | 1412 if (pPageSetNode->GetElementType() == XFA_Element::PageSet) { |
| 1382 XFA_ATTRIBUTEENUM eRelation = | 1413 XFA_ATTRIBUTEENUM eRelation = |
| 1383 pPageSetNode->GetEnum(XFA_ATTRIBUTE_Relation); | 1414 pPageSetNode->GetEnum(XFA_ATTRIBUTE_Relation); |
| 1384 if (eRelation == XFA_ATTRIBUTEENUM_OrderedOccurrence) { | 1415 if (eRelation == XFA_ATTRIBUTEENUM_OrderedOccurrence) |
| 1385 m_pPageSetMap.SetAt(pPageSetNode, 0); | 1416 m_pPageSetMap.SetAt(pPageSetNode, 0); |
| 1386 } | |
| 1387 } | 1417 } |
| 1388 } | 1418 } |
| 1389 } | 1419 } |
| 1420 |
| 1390 int32_t CXFA_LayoutPageMgr::CreateMinPageRecord(CXFA_Node* pPageArea, | 1421 int32_t CXFA_LayoutPageMgr::CreateMinPageRecord(CXFA_Node* pPageArea, |
| 1391 FX_BOOL bTargetPageArea, | 1422 FX_BOOL bTargetPageArea, |
| 1392 FX_BOOL bCreateLast) { | 1423 FX_BOOL bCreateLast) { |
| 1393 if (!pPageArea) { | 1424 if (!pPageArea) |
| 1394 return 0; | 1425 return 0; |
| 1395 } | 1426 |
| 1396 CXFA_Node* pOccurNode = pPageArea->GetFirstChildByClass(XFA_Element::Occur); | 1427 CXFA_Node* pOccurNode = pPageArea->GetFirstChildByClass(XFA_Element::Occur); |
| 1397 int32_t iMin = 0; | 1428 int32_t iMin = 0; |
| 1398 if ((pOccurNode && pOccurNode->TryInteger(XFA_ATTRIBUTE_Min, iMin, FALSE)) || | 1429 if ((pOccurNode && pOccurNode->TryInteger(XFA_ATTRIBUTE_Min, iMin, FALSE)) || |
| 1399 bTargetPageArea) { | 1430 bTargetPageArea) { |
| 1400 CXFA_Node* pContentArea = | 1431 CXFA_Node* pContentArea = |
| 1401 pPageArea->GetFirstChildByClass(XFA_Element::ContentArea); | 1432 pPageArea->GetFirstChildByClass(XFA_Element::ContentArea); |
| 1402 if (iMin < 1 && bTargetPageArea && !pContentArea) { | 1433 if (iMin < 1 && bTargetPageArea && !pContentArea) |
| 1403 iMin = 1; | 1434 iMin = 1; |
| 1404 } | 1435 |
| 1405 int32_t i = 0; | 1436 int32_t i = 0; |
| 1406 if (bCreateLast) { | 1437 if (bCreateLast) |
| 1407 i = m_nCurPageCount; | 1438 i = m_nCurPageCount; |
| 1408 } | 1439 |
| 1409 for (; i < iMin; i++) { | 1440 for (; i < iMin; i++) { |
| 1410 CXFA_ContainerRecord* pNewRecord = CreateContainerRecord(); | 1441 CXFA_ContainerRecord* pNewRecord = CreateContainerRecord(); |
| 1411 AddPageAreaLayoutItem(pNewRecord, pPageArea); | 1442 AddPageAreaLayoutItem(pNewRecord, pPageArea); |
| 1412 AddContentAreaLayoutItem(pNewRecord, pContentArea); | 1443 AddContentAreaLayoutItem(pNewRecord, pContentArea); |
| 1413 } | 1444 } |
| 1414 } | 1445 } |
| 1415 return iMin; | 1446 return iMin; |
| 1416 } | 1447 } |
| 1448 |
| 1417 void CXFA_LayoutPageMgr::CreateMinPageSetRecord(CXFA_Node* pPageSet, | 1449 void CXFA_LayoutPageMgr::CreateMinPageSetRecord(CXFA_Node* pPageSet, |
| 1418 FX_BOOL bCreateAll) { | 1450 FX_BOOL bCreateAll) { |
| 1419 if (!pPageSet) { | 1451 if (!pPageSet) |
| 1420 return; | 1452 return; |
| 1421 } | 1453 |
| 1422 int32_t iCurSetCount = 0; | 1454 int32_t iCurSetCount = 0; |
| 1423 if (!m_pPageSetMap.Lookup(pPageSet, iCurSetCount)) { | 1455 if (!m_pPageSetMap.Lookup(pPageSet, iCurSetCount)) |
| 1424 return; | 1456 return; |
| 1425 } | 1457 if (bCreateAll) |
| 1426 if (bCreateAll) { | |
| 1427 iCurSetCount = 0; | 1458 iCurSetCount = 0; |
| 1428 } | 1459 |
| 1429 CXFA_Node* pOccurNode = pPageSet->GetFirstChildByClass(XFA_Element::Occur); | 1460 CXFA_Node* pOccurNode = pPageSet->GetFirstChildByClass(XFA_Element::Occur); |
| 1430 int32_t iMin = 0; | 1461 int32_t iMin = 0; |
| 1431 if (pOccurNode && pOccurNode->TryInteger(XFA_ATTRIBUTE_Min, iMin, FALSE)) { | 1462 if (pOccurNode && pOccurNode->TryInteger(XFA_ATTRIBUTE_Min, iMin, FALSE)) { |
| 1432 if (iCurSetCount < iMin) { | 1463 if (iCurSetCount < iMin) { |
| 1433 for (int32_t i = 0; i < iMin - iCurSetCount; i++) { | 1464 for (int32_t i = 0; i < iMin - iCurSetCount; i++) { |
| 1434 for (CXFA_Node* pCurrentPageNode = | 1465 for (CXFA_Node* pCurrentPageNode = |
| 1435 pPageSet->GetNodeItem(XFA_NODEITEM_FirstChild); | 1466 pPageSet->GetNodeItem(XFA_NODEITEM_FirstChild); |
| 1436 pCurrentPageNode; pCurrentPageNode = pCurrentPageNode->GetNodeItem( | 1467 pCurrentPageNode; pCurrentPageNode = pCurrentPageNode->GetNodeItem( |
| 1437 XFA_NODEITEM_NextSibling)) { | 1468 XFA_NODEITEM_NextSibling)) { |
| 1438 if (pCurrentPageNode->GetElementType() == XFA_Element::PageArea) { | 1469 if (pCurrentPageNode->GetElementType() == XFA_Element::PageArea) { |
| 1439 CreateMinPageRecord(pCurrentPageNode, FALSE); | 1470 CreateMinPageRecord(pCurrentPageNode, FALSE); |
| 1440 } else if (pCurrentPageNode->GetElementType() == | 1471 } else if (pCurrentPageNode->GetElementType() == |
| 1441 XFA_Element::PageSet) { | 1472 XFA_Element::PageSet) { |
| 1442 CreateMinPageSetRecord(pCurrentPageNode, TRUE); | 1473 CreateMinPageSetRecord(pCurrentPageNode, TRUE); |
| 1443 } | 1474 } |
| 1444 } | 1475 } |
| 1445 } | 1476 } |
| 1446 m_pPageSetMap.SetAt(pPageSet, iMin); | 1477 m_pPageSetMap.SetAt(pPageSet, iMin); |
| 1447 } | 1478 } |
| 1448 } | 1479 } |
| 1449 } | 1480 } |
| 1481 |
| 1450 void CXFA_LayoutPageMgr::CreateNextMinRecord(CXFA_Node* pRecordNode) { | 1482 void CXFA_LayoutPageMgr::CreateNextMinRecord(CXFA_Node* pRecordNode) { |
| 1451 if (!pRecordNode) { | 1483 if (!pRecordNode) |
| 1452 return; | 1484 return; |
| 1453 } | 1485 |
| 1454 for (CXFA_Node* pCurrentNode = | 1486 for (CXFA_Node* pCurrentNode = |
| 1455 pRecordNode->GetNodeItem(XFA_NODEITEM_NextSibling); | 1487 pRecordNode->GetNodeItem(XFA_NODEITEM_NextSibling); |
| 1456 pCurrentNode; | 1488 pCurrentNode; |
| 1457 pCurrentNode = pCurrentNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { | 1489 pCurrentNode = pCurrentNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { |
| 1458 if (pCurrentNode->GetElementType() == XFA_Element::PageArea) { | 1490 if (pCurrentNode->GetElementType() == XFA_Element::PageArea) |
| 1459 CreateMinPageRecord(pCurrentNode, FALSE); | 1491 CreateMinPageRecord(pCurrentNode, FALSE); |
| 1460 } else if (pCurrentNode->GetElementType() == XFA_Element::PageSet) { | 1492 else if (pCurrentNode->GetElementType() == XFA_Element::PageSet) |
| 1461 CreateMinPageSetRecord(pCurrentNode, TRUE); | 1493 CreateMinPageSetRecord(pCurrentNode, TRUE); |
| 1462 } | |
| 1463 } | 1494 } |
| 1464 } | 1495 } |
| 1496 |
| 1465 void CXFA_LayoutPageMgr::ProcessLastPageSet() { | 1497 void CXFA_LayoutPageMgr::ProcessLastPageSet() { |
| 1466 CreateMinPageRecord(m_pCurPageArea, FALSE, TRUE); | 1498 CreateMinPageRecord(m_pCurPageArea, FALSE, TRUE); |
| 1467 CreateNextMinRecord(m_pCurPageArea); | 1499 CreateNextMinRecord(m_pCurPageArea); |
| 1468 CXFA_Node* pPageSet = m_pCurPageArea->GetNodeItem(XFA_NODEITEM_Parent); | 1500 CXFA_Node* pPageSet = m_pCurPageArea->GetNodeItem(XFA_NODEITEM_Parent); |
| 1469 while (TRUE) { | 1501 while (TRUE) { |
| 1470 CreateMinPageSetRecord(pPageSet); | 1502 CreateMinPageSetRecord(pPageSet); |
| 1471 if (pPageSet == m_pTemplatePageSetRoot) { | 1503 if (pPageSet == m_pTemplatePageSetRoot) |
| 1472 break; | 1504 break; |
| 1473 } | 1505 |
| 1474 CreateNextMinRecord(pPageSet); | 1506 CreateNextMinRecord(pPageSet); |
| 1475 pPageSet = pPageSet->GetNodeItem(XFA_NODEITEM_Parent); | 1507 pPageSet = pPageSet->GetNodeItem(XFA_NODEITEM_Parent); |
| 1476 } | 1508 } |
| 1477 } | 1509 } |
| 1510 |
| 1478 FX_BOOL CXFA_LayoutPageMgr::GetNextAvailContentHeight(FX_FLOAT fChildHeight) { | 1511 FX_BOOL CXFA_LayoutPageMgr::GetNextAvailContentHeight(FX_FLOAT fChildHeight) { |
| 1479 CXFA_Node* pCurContentNode = | 1512 CXFA_Node* pCurContentNode = |
| 1480 GetCurrentContainerRecord()->pCurContentArea->m_pFormNode; | 1513 GetCurrentContainerRecord()->pCurContentArea->m_pFormNode; |
| 1481 if (!pCurContentNode) { | 1514 if (!pCurContentNode) |
| 1482 return FALSE; | 1515 return FALSE; |
| 1483 } | 1516 |
| 1484 pCurContentNode = | 1517 pCurContentNode = |
| 1485 pCurContentNode->GetNextSameClassSibling(XFA_Element::ContentArea); | 1518 pCurContentNode->GetNextSameClassSibling(XFA_Element::ContentArea); |
| 1486 if (pCurContentNode) { | 1519 if (pCurContentNode) { |
| 1487 FX_FLOAT fNextContentHeight = | 1520 FX_FLOAT fNextContentHeight = |
| 1488 pCurContentNode->GetMeasure(XFA_ATTRIBUTE_H).ToUnit(XFA_UNIT_Pt); | 1521 pCurContentNode->GetMeasure(XFA_ATTRIBUTE_H).ToUnit(XFA_UNIT_Pt); |
| 1489 return fNextContentHeight > fChildHeight; | 1522 return fNextContentHeight > fChildHeight; |
| 1490 } | 1523 } |
| 1524 |
| 1491 CXFA_Node* pPageNode = GetCurrentContainerRecord()->pCurPageArea->m_pFormNode; | 1525 CXFA_Node* pPageNode = GetCurrentContainerRecord()->pCurPageArea->m_pFormNode; |
| 1492 CXFA_Node* pOccurNode = pPageNode->GetFirstChildByClass(XFA_Element::Occur); | 1526 CXFA_Node* pOccurNode = pPageNode->GetFirstChildByClass(XFA_Element::Occur); |
| 1493 int32_t iMax = 0; | 1527 int32_t iMax = 0; |
| 1494 if (pOccurNode && pOccurNode->TryInteger(XFA_ATTRIBUTE_Max, iMax, FALSE)) { | 1528 if (pOccurNode && pOccurNode->TryInteger(XFA_ATTRIBUTE_Max, iMax, FALSE)) { |
| 1495 if (m_nCurPageCount == iMax) { | 1529 if (m_nCurPageCount == iMax) { |
| 1496 CXFA_Node* pSrcPage = m_pCurPageArea; | 1530 CXFA_Node* pSrcPage = m_pCurPageArea; |
| 1497 int32_t nSrcPageCount = m_nCurPageCount; | 1531 int32_t nSrcPageCount = m_nCurPageCount; |
| 1498 FX_POSITION psSrcRecord = m_rgProposedContainerRecord.GetTailPosition(); | 1532 FX_POSITION psSrcRecord = m_rgProposedContainerRecord.GetTailPosition(); |
| 1499 CXFA_Node* pNextPage = | 1533 CXFA_Node* pNextPage = |
| 1500 GetNextAvailPageArea(nullptr, nullptr, FALSE, TRUE); | 1534 GetNextAvailPageArea(nullptr, nullptr, FALSE, TRUE); |
| 1501 m_pCurPageArea = pSrcPage; | 1535 m_pCurPageArea = pSrcPage; |
| 1502 m_nCurPageCount = nSrcPageCount; | 1536 m_nCurPageCount = nSrcPageCount; |
| 1503 CXFA_ContainerRecord* pPrevRecord = | 1537 CXFA_ContainerRecord* pPrevRecord = static_cast<CXFA_ContainerRecord*>( |
| 1504 (CXFA_ContainerRecord*)m_rgProposedContainerRecord.GetNext( | 1538 m_rgProposedContainerRecord.GetNext(psSrcRecord)); |
| 1505 psSrcRecord); | |
| 1506 while (psSrcRecord) { | 1539 while (psSrcRecord) { |
| 1507 FX_POSITION psSaveRecord = psSrcRecord; | 1540 FX_POSITION psSaveRecord = psSrcRecord; |
| 1508 CXFA_ContainerRecord* pInsertRecord = | 1541 CXFA_ContainerRecord* pInsertRecord = |
| 1509 (CXFA_ContainerRecord*)m_rgProposedContainerRecord.GetNext( | 1542 static_cast<CXFA_ContainerRecord*>( |
| 1510 psSrcRecord); | 1543 m_rgProposedContainerRecord.GetNext(psSrcRecord)); |
| 1511 RemoveLayoutRecord(pInsertRecord, pPrevRecord); | 1544 RemoveLayoutRecord(pInsertRecord, pPrevRecord); |
| 1512 delete pInsertRecord; | 1545 delete pInsertRecord; |
| 1513 m_rgProposedContainerRecord.RemoveAt(psSaveRecord); | 1546 m_rgProposedContainerRecord.RemoveAt(psSaveRecord); |
| 1514 } | 1547 } |
| 1515 if (pNextPage) { | 1548 if (pNextPage) { |
| 1516 CXFA_Node* pContentArea = | 1549 CXFA_Node* pContentArea = |
| 1517 pNextPage->GetFirstChildByClass(XFA_Element::ContentArea); | 1550 pNextPage->GetFirstChildByClass(XFA_Element::ContentArea); |
| 1518 if (pContentArea) { | 1551 if (pContentArea) { |
| 1519 FX_FLOAT fNextContentHeight = | 1552 FX_FLOAT fNextContentHeight = |
| 1520 pContentArea->GetMeasure(XFA_ATTRIBUTE_H).ToUnit(XFA_UNIT_Pt); | 1553 pContentArea->GetMeasure(XFA_ATTRIBUTE_H).ToUnit(XFA_UNIT_Pt); |
| 1521 if (fNextContentHeight > fChildHeight) { | 1554 if (fNextContentHeight > fChildHeight) |
| 1522 return TRUE; | 1555 return TRUE; |
| 1523 } | |
| 1524 } | 1556 } |
| 1525 } | 1557 } |
| 1526 return FALSE; | 1558 return FALSE; |
| 1527 } | 1559 } |
| 1528 } | 1560 } |
| 1561 |
| 1529 CXFA_Node* pContentArea = | 1562 CXFA_Node* pContentArea = |
| 1530 pPageNode->GetFirstChildByClass(XFA_Element::ContentArea); | 1563 pPageNode->GetFirstChildByClass(XFA_Element::ContentArea); |
| 1531 FX_FLOAT fNextContentHeight = | 1564 FX_FLOAT fNextContentHeight = |
| 1532 pContentArea->GetMeasure(XFA_ATTRIBUTE_H).ToUnit(XFA_UNIT_Pt); | 1565 pContentArea->GetMeasure(XFA_ATTRIBUTE_H).ToUnit(XFA_UNIT_Pt); |
| 1533 if (fNextContentHeight < XFA_LAYOUT_FLOAT_PERCISION) { | 1566 if (fNextContentHeight < XFA_LAYOUT_FLOAT_PERCISION) |
| 1534 return TRUE; | 1567 return TRUE; |
| 1535 } | 1568 if (fNextContentHeight > fChildHeight) |
| 1536 if (fNextContentHeight > fChildHeight) { | |
| 1537 return TRUE; | 1569 return TRUE; |
| 1538 } | |
| 1539 return FALSE; | 1570 return FALSE; |
| 1540 } | 1571 } |
| 1572 |
| 1541 void CXFA_LayoutPageMgr::ClearData() { | 1573 void CXFA_LayoutPageMgr::ClearData() { |
| 1542 ClearRecordList(); | 1574 ClearRecordList(); |
| 1543 } | 1575 } |
| 1576 |
| 1544 void CXFA_LayoutPageMgr::ClearRecordList() { | 1577 void CXFA_LayoutPageMgr::ClearRecordList() { |
| 1545 if (!m_pTemplatePageSetRoot) { | 1578 if (!m_pTemplatePageSetRoot) |
| 1546 return; | 1579 return; |
| 1547 } | |
| 1548 if (m_rgProposedContainerRecord.GetCount() > 0) { | 1580 if (m_rgProposedContainerRecord.GetCount() > 0) { |
| 1549 FX_POSITION sPos; | 1581 FX_POSITION sPos; |
| 1550 sPos = m_rgProposedContainerRecord.GetHeadPosition(); | 1582 sPos = m_rgProposedContainerRecord.GetHeadPosition(); |
| 1551 while (sPos) { | 1583 while (sPos) { |
| 1552 CXFA_ContainerRecord* pRecord = | 1584 CXFA_ContainerRecord* pRecord = static_cast<CXFA_ContainerRecord*>( |
| 1553 (CXFA_ContainerRecord*)m_rgProposedContainerRecord.GetNext(sPos); | 1585 m_rgProposedContainerRecord.GetNext(sPos)); |
| 1554 delete pRecord; | 1586 delete pRecord; |
| 1555 } | 1587 } |
| 1556 m_rgProposedContainerRecord.RemoveAll(); | 1588 m_rgProposedContainerRecord.RemoveAll(); |
| 1557 } | 1589 } |
| 1558 m_pCurrentContainerRecord = nullptr; | 1590 m_pCurrentContainerRecord = nullptr; |
| 1559 m_pCurPageArea = nullptr; | 1591 m_pCurPageArea = nullptr; |
| 1560 m_nCurPageCount = 0; | 1592 m_nCurPageCount = 0; |
| 1561 m_bCreateOverFlowPage = FALSE; | 1593 m_bCreateOverFlowPage = FALSE; |
| 1562 m_pPageSetMap.RemoveAll(); | 1594 m_pPageSetMap.RemoveAll(); |
| 1563 } | 1595 } |
| 1596 |
| 1564 CXFA_LayoutItem* CXFA_LayoutPageMgr::FindOrCreateLayoutItem( | 1597 CXFA_LayoutItem* CXFA_LayoutPageMgr::FindOrCreateLayoutItem( |
| 1565 CXFA_Node* pFormNode) { | 1598 CXFA_Node* pFormNode) { |
| 1566 return pFormNode->GetDocument()->GetNotify()->OnCreateLayoutItem(pFormNode); | 1599 return pFormNode->GetDocument()->GetNotify()->OnCreateLayoutItem(pFormNode); |
| 1567 } | 1600 } |
| 1568 | 1601 |
| 1569 void CXFA_LayoutPageMgr::SaveLayoutItem(CXFA_LayoutItem* pParentLayoutItem) { | 1602 void CXFA_LayoutPageMgr::SaveLayoutItem(CXFA_LayoutItem* pParentLayoutItem) { |
| 1570 CXFA_LayoutItem* pNextLayoutItem; | 1603 CXFA_LayoutItem* pNextLayoutItem; |
| 1571 CXFA_LayoutItem* pCurLayoutItem = pParentLayoutItem->m_pFirstChild; | 1604 CXFA_LayoutItem* pCurLayoutItem = pParentLayoutItem->m_pFirstChild; |
| 1572 while (pCurLayoutItem) { | 1605 while (pCurLayoutItem) { |
| 1573 pNextLayoutItem = pCurLayoutItem->m_pNextSibling; | 1606 pNextLayoutItem = pCurLayoutItem->m_pNextSibling; |
| 1574 if (pCurLayoutItem->IsContentLayoutItem()) { | 1607 if (pCurLayoutItem->IsContentLayoutItem()) { |
| 1575 if (pCurLayoutItem->m_pFormNode->HasRemovedChildren()) { | 1608 if (pCurLayoutItem->m_pFormNode->HasRemovedChildren()) { |
| 1576 CXFA_FFNotify* pNotify = | 1609 CXFA_FFNotify* pNotify = |
| 1577 m_pTemplatePageSetRoot->GetDocument()->GetNotify(); | 1610 m_pTemplatePageSetRoot->GetDocument()->GetNotify(); |
| 1578 CXFA_LayoutProcessor* pDocLayout = | 1611 CXFA_LayoutProcessor* pDocLayout = |
| 1579 m_pTemplatePageSetRoot->GetDocument()->GetDocLayout(); | 1612 m_pTemplatePageSetRoot->GetDocument()->GetDocLayout(); |
| 1580 if (pCurLayoutItem->m_pFirstChild) { | 1613 if (pCurLayoutItem->m_pFirstChild) |
| 1581 SyncRemoveLayoutItem(pCurLayoutItem, pNotify, pDocLayout); | 1614 SyncRemoveLayoutItem(pCurLayoutItem, pNotify, pDocLayout); |
| 1582 } | 1615 |
| 1583 pNotify->OnLayoutItemRemoving(pDocLayout, pCurLayoutItem); | 1616 pNotify->OnLayoutItemRemoving(pDocLayout, pCurLayoutItem); |
| 1584 delete pCurLayoutItem; | 1617 delete pCurLayoutItem; |
| 1585 pCurLayoutItem = pNextLayoutItem; | 1618 pCurLayoutItem = pNextLayoutItem; |
| 1586 continue; | 1619 continue; |
| 1587 } | 1620 } |
| 1621 |
| 1588 if (pCurLayoutItem->m_pFormNode->IsLayoutGeneratedNode()) { | 1622 if (pCurLayoutItem->m_pFormNode->IsLayoutGeneratedNode()) { |
| 1589 CXFA_NodeIteratorTemplate<CXFA_Node, CXFA_TraverseStrategy_XFANode> | 1623 CXFA_NodeIteratorTemplate<CXFA_Node, CXFA_TraverseStrategy_XFANode> |
| 1590 sIterator(pCurLayoutItem->m_pFormNode); | 1624 sIterator(pCurLayoutItem->m_pFormNode); |
| 1591 for (CXFA_Node* pNode = sIterator.GetCurrent(); pNode; | 1625 for (CXFA_Node* pNode = sIterator.GetCurrent(); pNode; |
| 1592 pNode = sIterator.MoveToNext()) { | 1626 pNode = sIterator.MoveToNext()) { |
| 1593 pNode->SetFlag(XFA_NodeFlag_UnusedNode, false); | 1627 pNode->SetFlag(XFA_NodeFlag_UnusedNode, false); |
| 1594 } | 1628 } |
| 1595 } | 1629 } |
| 1596 } | 1630 } |
| 1597 if (pCurLayoutItem->m_pFirstChild) { | 1631 |
| 1632 if (pCurLayoutItem->m_pFirstChild) |
| 1598 SaveLayoutItem(pCurLayoutItem); | 1633 SaveLayoutItem(pCurLayoutItem); |
| 1599 } | 1634 |
| 1600 pCurLayoutItem->m_pParent = nullptr; | 1635 pCurLayoutItem->m_pParent = nullptr; |
| 1601 pCurLayoutItem->m_pNextSibling = nullptr; | 1636 pCurLayoutItem->m_pNextSibling = nullptr; |
| 1602 pCurLayoutItem->m_pFirstChild = nullptr; | 1637 pCurLayoutItem->m_pFirstChild = nullptr; |
| 1603 if (!pCurLayoutItem->IsContentLayoutItem() && | 1638 if (!pCurLayoutItem->IsContentLayoutItem() && |
| 1604 pCurLayoutItem->m_pFormNode->GetElementType() != | 1639 pCurLayoutItem->m_pFormNode->GetElementType() != |
| 1605 XFA_Element::PageArea) { | 1640 XFA_Element::PageArea) { |
| 1606 delete pCurLayoutItem; | 1641 delete pCurLayoutItem; |
| 1607 } | 1642 } |
| 1608 pCurLayoutItem = pNextLayoutItem; | 1643 pCurLayoutItem = pNextLayoutItem; |
| 1609 } | 1644 } |
| 1610 } | 1645 } |
| 1646 |
| 1611 CXFA_Node* CXFA_LayoutPageMgr::QueryOverflow( | 1647 CXFA_Node* CXFA_LayoutPageMgr::QueryOverflow( |
| 1612 CXFA_Node* pFormNode, | 1648 CXFA_Node* pFormNode, |
| 1613 CXFA_LayoutContext* pLayoutContext) { | 1649 CXFA_LayoutContext* pLayoutContext) { |
| 1614 for (CXFA_Node* pCurNode = pFormNode->GetNodeItem(XFA_NODEITEM_FirstChild); | 1650 for (CXFA_Node* pCurNode = pFormNode->GetNodeItem(XFA_NODEITEM_FirstChild); |
| 1615 pCurNode; pCurNode = pCurNode->GetNodeItem((XFA_NODEITEM_NextSibling))) { | 1651 pCurNode; pCurNode = pCurNode->GetNodeItem((XFA_NODEITEM_NextSibling))) { |
| 1616 if (pCurNode->GetElementType() == XFA_Element::Break) { | 1652 if (pCurNode->GetElementType() == XFA_Element::Break) { |
| 1617 CFX_WideStringC wsOverflowLeader; | 1653 CFX_WideStringC wsOverflowLeader; |
| 1618 CFX_WideStringC wsOverflowTarget; | 1654 CFX_WideStringC wsOverflowTarget; |
| 1619 CFX_WideStringC wsOverflowTrailer; | 1655 CFX_WideStringC wsOverflowTrailer; |
| 1620 pCurNode->TryCData(XFA_ATTRIBUTE_OverflowLeader, wsOverflowLeader); | 1656 pCurNode->TryCData(XFA_ATTRIBUTE_OverflowLeader, wsOverflowLeader); |
| 1621 pCurNode->TryCData(XFA_ATTRIBUTE_OverflowTrailer, wsOverflowTrailer); | 1657 pCurNode->TryCData(XFA_ATTRIBUTE_OverflowTrailer, wsOverflowTrailer); |
| 1622 pCurNode->TryCData(XFA_ATTRIBUTE_OverflowTarget, wsOverflowTarget); | 1658 pCurNode->TryCData(XFA_ATTRIBUTE_OverflowTarget, wsOverflowTarget); |
| 1623 if (!wsOverflowLeader.IsEmpty() || !wsOverflowTrailer.IsEmpty() || | 1659 if (!wsOverflowLeader.IsEmpty() || !wsOverflowTrailer.IsEmpty() || |
| 1624 !wsOverflowTarget.IsEmpty()) { | 1660 !wsOverflowTarget.IsEmpty()) { |
| 1625 return pCurNode; | 1661 return pCurNode; |
| 1626 } | 1662 } |
| 1627 return nullptr; | 1663 return nullptr; |
| 1628 } else if (pCurNode->GetElementType() == XFA_Element::Overflow) { | 1664 } |
| 1665 if (pCurNode->GetElementType() == XFA_Element::Overflow) |
| 1629 return pCurNode; | 1666 return pCurNode; |
| 1630 } | |
| 1631 } | 1667 } |
| 1632 return nullptr; | 1668 return nullptr; |
| 1633 } | 1669 } |
| 1634 | 1670 |
| 1635 void CXFA_LayoutPageMgr::MergePageSetContents() { | 1671 void CXFA_LayoutPageMgr::MergePageSetContents() { |
| 1636 CXFA_Document* pDocument = m_pTemplatePageSetRoot->GetDocument(); | 1672 CXFA_Document* pDocument = m_pTemplatePageSetRoot->GetDocument(); |
| 1637 CXFA_FFNotify* pNotify = pDocument->GetNotify(); | 1673 CXFA_FFNotify* pNotify = pDocument->GetNotify(); |
| 1638 CXFA_LayoutProcessor* pDocLayout = pDocument->GetDocLayout(); | 1674 CXFA_LayoutProcessor* pDocLayout = pDocument->GetDocLayout(); |
| 1639 CXFA_ContainerLayoutItem* pRootLayout = GetRootLayoutItem(); | 1675 CXFA_ContainerLayoutItem* pRootLayout = GetRootLayoutItem(); |
| 1640 { | 1676 { |
| 1641 for (int32_t iIndex = 0; iIndex < pDocument->m_pPendingPageSet.GetSize(); | 1677 for (int32_t iIndex = 0; iIndex < pDocument->m_pPendingPageSet.GetSize(); |
| 1642 iIndex++) { | 1678 iIndex++) { |
| 1643 CXFA_NodeIteratorTemplate<CXFA_Node, CXFA_TraverseStrategy_XFANode> | 1679 CXFA_NodeIteratorTemplate<CXFA_Node, CXFA_TraverseStrategy_XFANode> |
| 1644 sIterator(pDocument->m_pPendingPageSet.GetAt(iIndex)); | 1680 sIterator(pDocument->m_pPendingPageSet.GetAt(iIndex)); |
| 1645 for (CXFA_Node* pNode = sIterator.GetCurrent(); pNode; | 1681 for (CXFA_Node* pNode = sIterator.GetCurrent(); pNode; |
| 1646 pNode = sIterator.MoveToNext()) { | 1682 pNode = sIterator.MoveToNext()) { |
| 1647 if (pNode->IsContainerNode()) { | 1683 if (pNode->IsContainerNode()) { |
| 1648 CXFA_Node* pBindNode = pNode->GetBindData(); | 1684 CXFA_Node* pBindNode = pNode->GetBindData(); |
| 1649 if (pBindNode) { | 1685 if (pBindNode) { |
| 1650 pBindNode->RemoveBindItem(pNode); | 1686 pBindNode->RemoveBindItem(pNode); |
| 1651 pNode->SetObject(XFA_ATTRIBUTE_BindingNode, nullptr); | 1687 pNode->SetObject(XFA_ATTRIBUTE_BindingNode, nullptr); |
| 1652 } | 1688 } |
| 1653 } | 1689 } |
| 1654 pNode->SetFlag(XFA_NodeFlag_UnusedNode, true); | 1690 pNode->SetFlag(XFA_NodeFlag_UnusedNode, true); |
| 1655 } | 1691 } |
| 1656 } | 1692 } |
| 1657 } | 1693 } |
| 1694 |
| 1658 int32_t iIndex = 0; | 1695 int32_t iIndex = 0; |
| 1659 for (; pRootLayout; | 1696 for (; pRootLayout; pRootLayout = static_cast<CXFA_ContainerLayoutItem*>( |
| 1660 pRootLayout = (CXFA_ContainerLayoutItem*)pRootLayout->m_pNextSibling) { | 1697 pRootLayout->m_pNextSibling)) { |
| 1661 CXFA_Node* pPendingPageSet = nullptr; | 1698 CXFA_Node* pPendingPageSet = nullptr; |
| 1662 CXFA_NodeIteratorTemplate< | 1699 CXFA_NodeIteratorTemplate< |
| 1663 CXFA_ContainerLayoutItem, | 1700 CXFA_ContainerLayoutItem, |
| 1664 CXFA_TraverseStrategy_ContentAreaContainerLayoutItem> | 1701 CXFA_TraverseStrategy_ContentAreaContainerLayoutItem> |
| 1665 iterator(pRootLayout); | 1702 iterator(pRootLayout); |
| 1666 CXFA_ContainerLayoutItem* pRootPageSetContainerItem = iterator.GetCurrent(); | 1703 CXFA_ContainerLayoutItem* pRootPageSetContainerItem = iterator.GetCurrent(); |
| 1667 ASSERT(pRootPageSetContainerItem->m_pFormNode->GetElementType() == | 1704 ASSERT(pRootPageSetContainerItem->m_pFormNode->GetElementType() == |
| 1668 XFA_Element::PageSet); | 1705 XFA_Element::PageSet); |
| 1669 if (iIndex < pDocument->m_pPendingPageSet.GetSize()) { | 1706 if (iIndex < pDocument->m_pPendingPageSet.GetSize()) { |
| 1670 pPendingPageSet = pDocument->m_pPendingPageSet.GetAt(iIndex); | 1707 pPendingPageSet = pDocument->m_pPendingPageSet.GetAt(iIndex); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1682 if (pRootPageSetContainerItem->m_pFormNode->GetUserData( | 1719 if (pRootPageSetContainerItem->m_pFormNode->GetUserData( |
| 1683 XFA_LAYOUTITEMKEY) == pRootPageSetContainerItem) { | 1720 XFA_LAYOUTITEMKEY) == pRootPageSetContainerItem) { |
| 1684 pRootPageSetContainerItem->m_pFormNode->SetUserData(XFA_LAYOUTITEMKEY, | 1721 pRootPageSetContainerItem->m_pFormNode->SetUserData(XFA_LAYOUTITEMKEY, |
| 1685 nullptr); | 1722 nullptr); |
| 1686 } | 1723 } |
| 1687 pRootPageSetContainerItem->m_pFormNode = pPendingPageSet; | 1724 pRootPageSetContainerItem->m_pFormNode = pPendingPageSet; |
| 1688 pPendingPageSet->ClearFlag(XFA_NodeFlag_UnusedNode); | 1725 pPendingPageSet->ClearFlag(XFA_NodeFlag_UnusedNode); |
| 1689 for (CXFA_ContainerLayoutItem* pContainerItem = iterator.MoveToNext(); | 1726 for (CXFA_ContainerLayoutItem* pContainerItem = iterator.MoveToNext(); |
| 1690 pContainerItem; pContainerItem = iterator.MoveToNext()) { | 1727 pContainerItem; pContainerItem = iterator.MoveToNext()) { |
| 1691 CXFA_Node* pNode = pContainerItem->m_pFormNode; | 1728 CXFA_Node* pNode = pContainerItem->m_pFormNode; |
| 1692 if (pNode->GetPacketID() != XFA_XDPPACKET_Template) { | 1729 if (pNode->GetPacketID() != XFA_XDPPACKET_Template) |
| 1693 continue; | 1730 continue; |
| 1694 } | 1731 |
| 1695 switch (pNode->GetElementType()) { | 1732 switch (pNode->GetElementType()) { |
| 1696 case XFA_Element::PageSet: { | 1733 case XFA_Element::PageSet: { |
| 1697 CXFA_Node* pParentNode = pContainerItem->m_pParent->m_pFormNode; | 1734 CXFA_Node* pParentNode = pContainerItem->m_pParent->m_pFormNode; |
| 1698 pContainerItem->m_pFormNode = XFA_NodeMerge_CloneOrMergeContainer( | 1735 pContainerItem->m_pFormNode = XFA_NodeMerge_CloneOrMergeContainer( |
| 1699 pDocument, pParentNode, pContainerItem->m_pFormNode, TRUE, | 1736 pDocument, pParentNode, pContainerItem->m_pFormNode, TRUE, |
| 1700 nullptr); | 1737 nullptr); |
| 1701 } break; | 1738 break; |
| 1739 } |
| 1702 case XFA_Element::PageArea: { | 1740 case XFA_Element::PageArea: { |
| 1703 CXFA_ContainerLayoutItem* pFormLayout = pContainerItem; | 1741 CXFA_ContainerLayoutItem* pFormLayout = pContainerItem; |
| 1704 CXFA_Node* pParentNode = pContainerItem->m_pParent->m_pFormNode; | 1742 CXFA_Node* pParentNode = pContainerItem->m_pParent->m_pFormNode; |
| 1705 FX_BOOL bIsExistForm = TRUE; | 1743 FX_BOOL bIsExistForm = TRUE; |
| 1706 for (int32_t iLevel = 0; iLevel < 3; iLevel++) { | 1744 for (int32_t iLevel = 0; iLevel < 3; iLevel++) { |
| 1707 pFormLayout = (CXFA_ContainerLayoutItem*)pFormLayout->m_pFirstChild; | 1745 pFormLayout = static_cast<CXFA_ContainerLayoutItem*>( |
| 1746 pFormLayout->m_pFirstChild); |
| 1708 if (iLevel == 2) { | 1747 if (iLevel == 2) { |
| 1709 while (pFormLayout && | 1748 while (pFormLayout && |
| 1710 !XFA_ItemLayoutProcessor_IsTakingSpace( | 1749 !XFA_ItemLayoutProcessor_IsTakingSpace( |
| 1711 pFormLayout->m_pFormNode)) { | 1750 pFormLayout->m_pFormNode)) { |
| 1712 pFormLayout = | 1751 pFormLayout = static_cast<CXFA_ContainerLayoutItem*>( |
| 1713 (CXFA_ContainerLayoutItem*)pFormLayout->m_pNextSibling; | 1752 pFormLayout->m_pNextSibling); |
| 1714 } | 1753 } |
| 1715 } | 1754 } |
| 1716 if (!pFormLayout) { | 1755 if (!pFormLayout) { |
| 1717 bIsExistForm = FALSE; | 1756 bIsExistForm = FALSE; |
| 1718 break; | 1757 break; |
| 1719 } | 1758 } |
| 1720 } | 1759 } |
| 1721 if (bIsExistForm) { | 1760 if (bIsExistForm) { |
| 1722 CXFA_Node* pNewSubform = pFormLayout->m_pFormNode; | 1761 CXFA_Node* pNewSubform = pFormLayout->m_pFormNode; |
| 1723 if (pContainerItem->m_pOldSubform && | 1762 if (pContainerItem->m_pOldSubform && |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1740 if (pExistingNode) { | 1779 if (pExistingNode) { |
| 1741 pParentNode->RemoveChild(pExistingNode); | 1780 pParentNode->RemoveChild(pExistingNode); |
| 1742 } | 1781 } |
| 1743 } | 1782 } |
| 1744 pContainerItem->m_pOldSubform = pNewSubform; | 1783 pContainerItem->m_pOldSubform = pNewSubform; |
| 1745 } | 1784 } |
| 1746 pContainerItem->m_pFormNode = pDocument->DataMerge_CopyContainer( | 1785 pContainerItem->m_pFormNode = pDocument->DataMerge_CopyContainer( |
| 1747 pContainerItem->m_pFormNode, pParentNode, | 1786 pContainerItem->m_pFormNode, pParentNode, |
| 1748 ToNode(pDocument->GetXFAObject(XFA_HASHCODE_Record)), TRUE, TRUE, | 1787 ToNode(pDocument->GetXFAObject(XFA_HASHCODE_Record)), TRUE, TRUE, |
| 1749 TRUE); | 1788 TRUE); |
| 1750 } break; | 1789 break; |
| 1790 } |
| 1751 case XFA_Element::ContentArea: { | 1791 case XFA_Element::ContentArea: { |
| 1752 CXFA_Node* pParentNode = pContainerItem->m_pParent->m_pFormNode; | 1792 CXFA_Node* pParentNode = pContainerItem->m_pParent->m_pFormNode; |
| 1753 for (CXFA_Node* pChildNode = | 1793 for (CXFA_Node* pChildNode = |
| 1754 pParentNode->GetNodeItem(XFA_NODEITEM_FirstChild); | 1794 pParentNode->GetNodeItem(XFA_NODEITEM_FirstChild); |
| 1755 pChildNode; | 1795 pChildNode; |
| 1756 pChildNode = pChildNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { | 1796 pChildNode = pChildNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { |
| 1757 if (pChildNode->GetTemplateNode() != pContainerItem->m_pFormNode) { | 1797 if (pChildNode->GetTemplateNode() != pContainerItem->m_pFormNode) { |
| 1758 continue; | 1798 continue; |
| 1759 } | 1799 } |
| 1760 pContainerItem->m_pFormNode = pChildNode; | 1800 pContainerItem->m_pFormNode = pChildNode; |
| 1761 break; | 1801 break; |
| 1762 } | 1802 } |
| 1763 } break; | 1803 break; |
| 1804 } |
| 1764 default: | 1805 default: |
| 1765 break; | 1806 break; |
| 1766 } | 1807 } |
| 1767 } | 1808 } |
| 1768 if (!pPendingPageSet->GetNodeItem(XFA_NODEITEM_Parent)) { | 1809 if (!pPendingPageSet->GetNodeItem(XFA_NODEITEM_Parent)) { |
| 1769 CXFA_Node* pFormToplevelSubform = | 1810 CXFA_Node* pFormToplevelSubform = |
| 1770 pDocument->GetXFAObject(XFA_HASHCODE_Form) | 1811 pDocument->GetXFAObject(XFA_HASHCODE_Form) |
| 1771 ->AsNode() | 1812 ->AsNode() |
| 1772 ->GetFirstChildByClass(XFA_Element::Subform); | 1813 ->GetFirstChildByClass(XFA_Element::Subform); |
| 1773 pFormToplevelSubform->InsertChild(pPendingPageSet); | 1814 pFormToplevelSubform->InsertChild(pPendingPageSet); |
| 1774 } | 1815 } |
| 1775 pDocument->DataMerge_UpdateBindingRelations(pPendingPageSet); | 1816 pDocument->DataMerge_UpdateBindingRelations(pPendingPageSet); |
| 1776 pPendingPageSet->SetFlag(XFA_NodeFlag_Initialized, true); | 1817 pPendingPageSet->SetFlag(XFA_NodeFlag_Initialized, true); |
| 1777 } | 1818 } |
| 1819 |
| 1778 CXFA_Node* pPageSet = GetRootLayoutItem()->m_pFormNode; | 1820 CXFA_Node* pPageSet = GetRootLayoutItem()->m_pFormNode; |
| 1779 while (pPageSet) { | 1821 while (pPageSet) { |
| 1780 CXFA_Node* pNextPageSet = | 1822 CXFA_Node* pNextPageSet = |
| 1781 pPageSet->GetNextSameClassSibling(XFA_Element::PageSet); | 1823 pPageSet->GetNextSameClassSibling(XFA_Element::PageSet); |
| 1782 CXFA_NodeIteratorTemplate<CXFA_Node, CXFA_TraverseStrategy_XFANode> | 1824 CXFA_NodeIteratorTemplate<CXFA_Node, CXFA_TraverseStrategy_XFANode> |
| 1783 sIterator(pPageSet); | 1825 sIterator(pPageSet); |
| 1784 CXFA_Node* pNode = sIterator.GetCurrent(); | 1826 CXFA_Node* pNode = sIterator.GetCurrent(); |
| 1785 while (pNode) { | 1827 while (pNode) { |
| 1786 if (pNode->IsUnusedNode()) { | 1828 if (pNode->IsUnusedNode()) { |
| 1787 if (pNode->IsContainerNode()) { | 1829 if (pNode->IsContainerNode()) { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1818 pNode = sIterator.MoveToNext(); | 1860 pNode = sIterator.MoveToNext(); |
| 1819 } | 1861 } |
| 1820 } | 1862 } |
| 1821 pPageSet = pNextPageSet; | 1863 pPageSet = pNextPageSet; |
| 1822 } | 1864 } |
| 1823 } | 1865 } |
| 1824 | 1866 |
| 1825 void CXFA_LayoutPageMgr::LayoutPageSetContents() { | 1867 void CXFA_LayoutPageMgr::LayoutPageSetContents() { |
| 1826 CXFA_ContainerLayoutItem* pRootLayoutItem = GetRootLayoutItem(); | 1868 CXFA_ContainerLayoutItem* pRootLayoutItem = GetRootLayoutItem(); |
| 1827 for (; pRootLayoutItem; | 1869 for (; pRootLayoutItem; |
| 1828 pRootLayoutItem = | 1870 pRootLayoutItem = static_cast<CXFA_ContainerLayoutItem*>( |
| 1829 (CXFA_ContainerLayoutItem*)pRootLayoutItem->m_pNextSibling) { | 1871 pRootLayoutItem->m_pNextSibling)) { |
| 1830 CXFA_NodeIteratorTemplate< | 1872 CXFA_NodeIteratorTemplate< |
| 1831 CXFA_ContainerLayoutItem, | 1873 CXFA_ContainerLayoutItem, |
| 1832 CXFA_TraverseStrategy_ContentAreaContainerLayoutItem> | 1874 CXFA_TraverseStrategy_ContentAreaContainerLayoutItem> |
| 1833 iterator(pRootLayoutItem); | 1875 iterator(pRootLayoutItem); |
| 1834 for (CXFA_ContainerLayoutItem* pContainerItem = iterator.GetCurrent(); | 1876 for (CXFA_ContainerLayoutItem* pContainerItem = iterator.GetCurrent(); |
| 1835 pContainerItem; pContainerItem = iterator.MoveToNext()) { | 1877 pContainerItem; pContainerItem = iterator.MoveToNext()) { |
| 1836 CXFA_Node* pNode = pContainerItem->m_pFormNode; | 1878 CXFA_Node* pNode = pContainerItem->m_pFormNode; |
| 1837 switch (pNode->GetElementType()) { | 1879 switch (pNode->GetElementType()) { |
| 1838 case XFA_Element::PageArea: | 1880 case XFA_Element::PageArea: |
| 1839 m_pLayoutProcessor->GetRootRootItemLayoutProcessor() | 1881 m_pLayoutProcessor->GetRootRootItemLayoutProcessor() |
| 1840 ->DoLayoutPageArea(pContainerItem); | 1882 ->DoLayoutPageArea(pContainerItem); |
| 1841 break; | 1883 break; |
| 1842 default: | 1884 default: |
| 1843 break; | 1885 break; |
| 1844 } | 1886 } |
| 1845 } | 1887 } |
| 1846 } | 1888 } |
| 1847 } | 1889 } |
| 1848 | 1890 |
| 1849 void CXFA_LayoutPageMgr::SyncLayoutData() { | 1891 void CXFA_LayoutPageMgr::SyncLayoutData() { |
| 1850 MergePageSetContents(); | 1892 MergePageSetContents(); |
| 1851 LayoutPageSetContents(); | 1893 LayoutPageSetContents(); |
| 1852 CXFA_FFNotify* pNotify = m_pTemplatePageSetRoot->GetDocument()->GetNotify(); | 1894 CXFA_FFNotify* pNotify = m_pTemplatePageSetRoot->GetDocument()->GetNotify(); |
| 1853 int32_t nPageIdx = -1; | 1895 int32_t nPageIdx = -1; |
| 1854 CXFA_ContainerLayoutItem* pRootLayoutItem = GetRootLayoutItem(); | 1896 CXFA_ContainerLayoutItem* pRootLayoutItem = GetRootLayoutItem(); |
| 1855 for (; pRootLayoutItem; | 1897 for (; pRootLayoutItem; |
| 1856 pRootLayoutItem = | 1898 pRootLayoutItem = static_cast<CXFA_ContainerLayoutItem*>( |
| 1857 (CXFA_ContainerLayoutItem*)pRootLayoutItem->m_pNextSibling) { | 1899 pRootLayoutItem->m_pNextSibling)) { |
| 1858 CXFA_NodeIteratorTemplate< | 1900 CXFA_NodeIteratorTemplate< |
| 1859 CXFA_ContainerLayoutItem, | 1901 CXFA_ContainerLayoutItem, |
| 1860 CXFA_TraverseStrategy_ContentAreaContainerLayoutItem> | 1902 CXFA_TraverseStrategy_ContentAreaContainerLayoutItem> |
| 1861 iteratorParent(pRootLayoutItem); | 1903 iteratorParent(pRootLayoutItem); |
| 1862 for (CXFA_ContainerLayoutItem* pContainerItem = iteratorParent.GetCurrent(); | 1904 for (CXFA_ContainerLayoutItem* pContainerItem = iteratorParent.GetCurrent(); |
| 1863 pContainerItem; pContainerItem = iteratorParent.MoveToNext()) { | 1905 pContainerItem; pContainerItem = iteratorParent.MoveToNext()) { |
| 1864 switch (pContainerItem->m_pFormNode->GetElementType()) { | 1906 switch (pContainerItem->m_pFormNode->GetElementType()) { |
| 1865 case XFA_Element::PageArea: { | 1907 case XFA_Element::PageArea: { |
| 1866 nPageIdx++; | 1908 nPageIdx++; |
| 1867 uint32_t dwRelevant = | 1909 uint32_t dwRelevant = |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1879 } | 1921 } |
| 1880 FX_BOOL bVisible = | 1922 FX_BOOL bVisible = |
| 1881 (pContentItem->m_pFormNode->GetEnum(XFA_ATTRIBUTE_Presence) == | 1923 (pContentItem->m_pFormNode->GetEnum(XFA_ATTRIBUTE_Presence) == |
| 1882 XFA_ATTRIBUTEENUM_Visible); | 1924 XFA_ATTRIBUTEENUM_Visible); |
| 1883 uint32_t dwRelevantChild = | 1925 uint32_t dwRelevantChild = |
| 1884 GetRelevant(pContentItem->m_pFormNode, dwRelevant); | 1926 GetRelevant(pContentItem->m_pFormNode, dwRelevant); |
| 1885 SyncContainer(pNotify, m_pLayoutProcessor, pContentItem, | 1927 SyncContainer(pNotify, m_pLayoutProcessor, pContentItem, |
| 1886 dwRelevantChild, bVisible, nPageIdx); | 1928 dwRelevantChild, bVisible, nPageIdx); |
| 1887 pChildLayoutItem = iterator.SkipChildrenAndMoveToNext(); | 1929 pChildLayoutItem = iterator.SkipChildrenAndMoveToNext(); |
| 1888 } | 1930 } |
| 1889 } break; | 1931 break; |
| 1932 } |
| 1890 default: | 1933 default: |
| 1891 break; | 1934 break; |
| 1892 } | 1935 } |
| 1893 } | 1936 } |
| 1894 } | 1937 } |
| 1938 |
| 1895 int32_t nPage = m_PageArray.GetSize(); | 1939 int32_t nPage = m_PageArray.GetSize(); |
| 1896 for (int32_t i = nPage - 1; i >= m_nAvailPages; i--) { | 1940 for (int32_t i = nPage - 1; i >= m_nAvailPages; i--) { |
| 1897 CXFA_ContainerLayoutItem* pPage = m_PageArray[i]; | 1941 CXFA_ContainerLayoutItem* pPage = m_PageArray[i]; |
| 1898 m_PageArray.RemoveAt(i); | 1942 m_PageArray.RemoveAt(i); |
| 1899 pNotify->OnPageEvent(pPage, XFA_PAGEVIEWEVENT_PostRemoved); | 1943 pNotify->OnPageEvent(pPage, XFA_PAGEVIEWEVENT_PostRemoved); |
| 1900 delete pPage; | 1944 delete pPage; |
| 1901 } | 1945 } |
| 1902 ClearRecordList(); | 1946 ClearRecordList(); |
| 1903 } | 1947 } |
| 1948 |
| 1904 void XFA_ReleaseLayoutItem_NoPageArea(CXFA_LayoutItem* pLayoutItem) { | 1949 void XFA_ReleaseLayoutItem_NoPageArea(CXFA_LayoutItem* pLayoutItem) { |
| 1905 CXFA_LayoutItem *pNext, *pNode = pLayoutItem->m_pFirstChild; | 1950 CXFA_LayoutItem *pNext, *pNode = pLayoutItem->m_pFirstChild; |
| 1906 while (pNode) { | 1951 while (pNode) { |
| 1907 pNext = pNode->m_pNextSibling; | 1952 pNext = pNode->m_pNextSibling; |
| 1908 pNode->m_pParent = nullptr; | 1953 pNode->m_pParent = nullptr; |
| 1909 XFA_ReleaseLayoutItem_NoPageArea(pNode); | 1954 XFA_ReleaseLayoutItem_NoPageArea(pNode); |
| 1910 pNode = pNext; | 1955 pNode = pNext; |
| 1911 } | 1956 } |
| 1912 if (pLayoutItem->m_pFormNode->GetElementType() != XFA_Element::PageArea) { | 1957 if (pLayoutItem->m_pFormNode->GetElementType() != XFA_Element::PageArea) |
| 1913 delete pLayoutItem; | 1958 delete pLayoutItem; |
| 1914 } | |
| 1915 } | 1959 } |
| 1960 |
| 1916 void CXFA_LayoutPageMgr::PrepareLayout() { | 1961 void CXFA_LayoutPageMgr::PrepareLayout() { |
| 1917 m_pPageSetCurRoot = nullptr; | 1962 m_pPageSetCurRoot = nullptr; |
| 1918 m_ePageSetMode = XFA_ATTRIBUTEENUM_OrderedOccurrence; | 1963 m_ePageSetMode = XFA_ATTRIBUTEENUM_OrderedOccurrence; |
| 1919 m_nAvailPages = 0; | 1964 m_nAvailPages = 0; |
| 1920 ClearRecordList(); | 1965 ClearRecordList(); |
| 1921 if (!m_pPageSetLayoutItemRoot) { | 1966 if (!m_pPageSetLayoutItemRoot) |
| 1922 return; | 1967 return; |
| 1923 } | 1968 |
| 1924 CXFA_ContainerLayoutItem* pRootLayoutItem = m_pPageSetLayoutItemRoot; | 1969 CXFA_ContainerLayoutItem* pRootLayoutItem = m_pPageSetLayoutItemRoot; |
| 1925 if (pRootLayoutItem && | 1970 if (pRootLayoutItem && |
| 1926 pRootLayoutItem->m_pFormNode->GetPacketID() == XFA_XDPPACKET_Form) { | 1971 pRootLayoutItem->m_pFormNode->GetPacketID() == XFA_XDPPACKET_Form) { |
| 1927 CXFA_Node* pPageSetFormNode = pRootLayoutItem->m_pFormNode; | 1972 CXFA_Node* pPageSetFormNode = pRootLayoutItem->m_pFormNode; |
| 1928 pRootLayoutItem->m_pFormNode->GetDocument()->m_pPendingPageSet.RemoveAll(); | 1973 pRootLayoutItem->m_pFormNode->GetDocument()->m_pPendingPageSet.RemoveAll(); |
| 1929 if (pPageSetFormNode->HasRemovedChildren()) { | 1974 if (pPageSetFormNode->HasRemovedChildren()) { |
| 1930 XFA_ReleaseLayoutItem(pRootLayoutItem); | 1975 XFA_ReleaseLayoutItem(pRootLayoutItem); |
| 1931 m_pPageSetLayoutItemRoot = nullptr; | 1976 m_pPageSetLayoutItemRoot = nullptr; |
| 1932 pRootLayoutItem = nullptr; | 1977 pRootLayoutItem = nullptr; |
| 1933 pPageSetFormNode = nullptr; | 1978 pPageSetFormNode = nullptr; |
| 1934 m_PageArray.RemoveAll(); | 1979 m_PageArray.RemoveAll(); |
| 1935 } | 1980 } |
| 1936 while (pPageSetFormNode) { | 1981 while (pPageSetFormNode) { |
| 1937 CXFA_Node* pNextPageSet = | 1982 CXFA_Node* pNextPageSet = |
| 1938 pPageSetFormNode->GetNextSameClassSibling(XFA_Element::PageSet); | 1983 pPageSetFormNode->GetNextSameClassSibling(XFA_Element::PageSet); |
| 1939 pPageSetFormNode->GetNodeItem(XFA_NODEITEM_Parent) | 1984 pPageSetFormNode->GetNodeItem(XFA_NODEITEM_Parent) |
| 1940 ->RemoveChild(pPageSetFormNode, FALSE); | 1985 ->RemoveChild(pPageSetFormNode, FALSE); |
| 1941 pRootLayoutItem->m_pFormNode->GetDocument()->m_pPendingPageSet.Add( | 1986 pRootLayoutItem->m_pFormNode->GetDocument()->m_pPendingPageSet.Add( |
| 1942 pPageSetFormNode); | 1987 pPageSetFormNode); |
| 1943 pPageSetFormNode = pNextPageSet; | 1988 pPageSetFormNode = pNextPageSet; |
| 1944 } | 1989 } |
| 1945 } | 1990 } |
| 1946 pRootLayoutItem = m_pPageSetLayoutItemRoot; | 1991 pRootLayoutItem = m_pPageSetLayoutItemRoot; |
| 1947 CXFA_ContainerLayoutItem* pNextLayout = nullptr; | 1992 CXFA_ContainerLayoutItem* pNextLayout = nullptr; |
| 1948 for (; pRootLayoutItem; pRootLayoutItem = pNextLayout) { | 1993 for (; pRootLayoutItem; pRootLayoutItem = pNextLayout) { |
| 1949 pNextLayout = (CXFA_ContainerLayoutItem*)pRootLayoutItem->m_pNextSibling; | 1994 pNextLayout = |
| 1995 static_cast<CXFA_ContainerLayoutItem*>(pRootLayoutItem->m_pNextSibling); |
| 1950 SaveLayoutItem(pRootLayoutItem); | 1996 SaveLayoutItem(pRootLayoutItem); |
| 1951 delete pRootLayoutItem; | 1997 delete pRootLayoutItem; |
| 1952 } | 1998 } |
| 1953 m_pPageSetLayoutItemRoot = nullptr; | 1999 m_pPageSetLayoutItemRoot = nullptr; |
| 1954 } | 2000 } |
| OLD | NEW |