| 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/xfa_layout_pagemgr_new.h" | 
|     8  |     8  | 
|     9 #include "xfa/fxfa/app/xfa_ffnotify.h" |     9 #include "xfa/fxfa/app/xfa_ffnotify.h" | 
|    10 #include "xfa/fxfa/parser/xfa_doclayout.h" |    10 #include "xfa/fxfa/parser/xfa_doclayout.h" | 
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   185  |   185  | 
|   186 FX_BOOL CheckContentAreaNotUsed( |   186 FX_BOOL CheckContentAreaNotUsed( | 
|   187     CXFA_ContainerLayoutItem* pPageAreaLayoutItem, |   187     CXFA_ContainerLayoutItem* pPageAreaLayoutItem, | 
|   188     CXFA_Node* pContentArea, |   188     CXFA_Node* pContentArea, | 
|   189     CXFA_ContainerLayoutItem*& pContentAreaLayoutItem) { |   189     CXFA_ContainerLayoutItem*& pContentAreaLayoutItem) { | 
|   190   for (CXFA_ContainerLayoutItem* pLayoutItem = |   190   for (CXFA_ContainerLayoutItem* pLayoutItem = | 
|   191            (CXFA_ContainerLayoutItem*)pPageAreaLayoutItem->m_pFirstChild; |   191            (CXFA_ContainerLayoutItem*)pPageAreaLayoutItem->m_pFirstChild; | 
|   192        pLayoutItem; |   192        pLayoutItem; | 
|   193        pLayoutItem = (CXFA_ContainerLayoutItem*)pLayoutItem->m_pNextSibling) { |   193        pLayoutItem = (CXFA_ContainerLayoutItem*)pLayoutItem->m_pNextSibling) { | 
|   194     if (pLayoutItem->m_pFormNode == pContentArea) { |   194     if (pLayoutItem->m_pFormNode == pContentArea) { | 
|   195       if (pLayoutItem->m_pFirstChild == NULL) { |   195       if (!pLayoutItem->m_pFirstChild) { | 
|   196         pContentAreaLayoutItem = pLayoutItem; |   196         pContentAreaLayoutItem = pLayoutItem; | 
|   197         return TRUE; |   197         return TRUE; | 
|   198       } |   198       } | 
|   199       return FALSE; |   199       return FALSE; | 
|   200     } |   200     } | 
|   201   } |   201   } | 
|   202   return TRUE; |   202   return TRUE; | 
|   203 } |   203 } | 
|   204  |   204  | 
|   205 void SyncRemoveLayoutItem(CXFA_LayoutItem* pParentLayoutItem, |   205 void SyncRemoveLayoutItem(CXFA_LayoutItem* pParentLayoutItem, | 
| (...skipping 21 matching lines...) Expand all  Loading... | 
|   227       m_pPageSetCurRoot(nullptr), |   227       m_pPageSetCurRoot(nullptr), | 
|   228       m_pCurrentContainerRecord(nullptr), |   228       m_pCurrentContainerRecord(nullptr), | 
|   229       m_pCurPageArea(nullptr), |   229       m_pCurPageArea(nullptr), | 
|   230       m_nAvailPages(0), |   230       m_nAvailPages(0), | 
|   231       m_nCurPageCount(0), |   231       m_nCurPageCount(0), | 
|   232       m_ePageSetMode(XFA_ATTRIBUTEENUM_OrderedOccurrence), |   232       m_ePageSetMode(XFA_ATTRIBUTEENUM_OrderedOccurrence), | 
|   233       m_bCreateOverFlowPage(FALSE) {} |   233       m_bCreateOverFlowPage(FALSE) {} | 
|   234 CXFA_LayoutPageMgr::~CXFA_LayoutPageMgr() { |   234 CXFA_LayoutPageMgr::~CXFA_LayoutPageMgr() { | 
|   235   ClearData(); |   235   ClearData(); | 
|   236   CXFA_LayoutItem* pLayoutItem = GetRootLayoutItem(); |   236   CXFA_LayoutItem* pLayoutItem = GetRootLayoutItem(); | 
|   237   CXFA_LayoutItem* pNextLayout = NULL; |   237   CXFA_LayoutItem* pNextLayout = nullptr; | 
|   238   for (; pLayoutItem; pLayoutItem = pNextLayout) { |   238   for (; pLayoutItem; pLayoutItem = pNextLayout) { | 
|   239     pNextLayout = pLayoutItem->m_pNextSibling; |   239     pNextLayout = pLayoutItem->m_pNextSibling; | 
|   240     XFA_ReleaseLayoutItem(pLayoutItem); |   240     XFA_ReleaseLayoutItem(pLayoutItem); | 
|   241   } |   241   } | 
|   242 } |   242 } | 
|   243 FX_BOOL CXFA_LayoutPageMgr::InitLayoutPage(CXFA_Node* pFormNode) { |   243 FX_BOOL CXFA_LayoutPageMgr::InitLayoutPage(CXFA_Node* pFormNode) { | 
|   244   PrepareLayout(); |   244   PrepareLayout(); | 
|   245   CXFA_Node* pTemplateNode = pFormNode->GetTemplateNode(); |   245   CXFA_Node* pTemplateNode = pFormNode->GetTemplateNode(); | 
|   246   if (!pTemplateNode) { |   246   if (!pTemplateNode) { | 
|   247     return FALSE; |   247     return FALSE; | 
|   248   } |   248   } | 
|   249   m_pTemplatePageSetRoot = pTemplateNode->GetProperty(0, XFA_Element::PageSet); |   249   m_pTemplatePageSetRoot = pTemplateNode->GetProperty(0, XFA_Element::PageSet); | 
|   250   ASSERT(m_pTemplatePageSetRoot); |   250   ASSERT(m_pTemplatePageSetRoot); | 
|   251   if (m_pPageSetLayoutItemRoot) { |   251   if (m_pPageSetLayoutItemRoot) { | 
|   252     m_pPageSetLayoutItemRoot->m_pParent = NULL; |   252     m_pPageSetLayoutItemRoot->m_pParent = nullptr; | 
|   253     m_pPageSetLayoutItemRoot->m_pFirstChild = NULL; |   253     m_pPageSetLayoutItemRoot->m_pFirstChild = nullptr; | 
|   254     m_pPageSetLayoutItemRoot->m_pNextSibling = NULL; |   254     m_pPageSetLayoutItemRoot->m_pNextSibling = nullptr; | 
|   255     m_pPageSetLayoutItemRoot->m_pFormNode = m_pTemplatePageSetRoot; |   255     m_pPageSetLayoutItemRoot->m_pFormNode = m_pTemplatePageSetRoot; | 
|   256   } else { |   256   } else { | 
|   257     m_pPageSetLayoutItemRoot = |   257     m_pPageSetLayoutItemRoot = | 
|   258         new CXFA_ContainerLayoutItem(m_pTemplatePageSetRoot); |   258         new CXFA_ContainerLayoutItem(m_pTemplatePageSetRoot); | 
|   259   } |   259   } | 
|   260   m_pPageSetCurRoot = m_pPageSetLayoutItemRoot; |   260   m_pPageSetCurRoot = m_pPageSetLayoutItemRoot; | 
|   261   m_pTemplatePageSetRoot->SetUserData(XFA_LAYOUTITEMKEY, |   261   m_pTemplatePageSetRoot->SetUserData(XFA_LAYOUTITEMKEY, | 
|   262                                       (void*)m_pPageSetLayoutItemRoot); |   262                                       (void*)m_pPageSetLayoutItemRoot); | 
|   263   XFA_ATTRIBUTEENUM eRelation = |   263   XFA_ATTRIBUTEENUM eRelation = | 
|   264       m_pTemplatePageSetRoot->GetEnum(XFA_ATTRIBUTE_Relation); |   264       m_pTemplatePageSetRoot->GetEnum(XFA_ATTRIBUTE_Relation); | 
|   265   if (eRelation != XFA_ATTRIBUTEENUM_Unknown) { |   265   if (eRelation != XFA_ATTRIBUTEENUM_Unknown) { | 
|   266     m_ePageSetMode = eRelation; |   266     m_ePageSetMode = eRelation; | 
|   267   } |   267   } | 
|   268   InitPageSetMap(); |   268   InitPageSetMap(); | 
|   269   CXFA_Node* pPageArea = NULL; |   269   CXFA_Node* pPageArea = nullptr; | 
|   270   int32_t iCount = 0; |   270   int32_t iCount = 0; | 
|   271   for (pPageArea = m_pTemplatePageSetRoot->GetNodeItem(XFA_NODEITEM_FirstChild); |   271   for (pPageArea = m_pTemplatePageSetRoot->GetNodeItem(XFA_NODEITEM_FirstChild); | 
|   272        pPageArea; |   272        pPageArea; | 
|   273        pPageArea = pPageArea->GetNodeItem(XFA_NODEITEM_NextSibling)) { |   273        pPageArea = pPageArea->GetNodeItem(XFA_NODEITEM_NextSibling)) { | 
|   274     if (pPageArea->GetElementType() == XFA_Element::PageArea) { |   274     if (pPageArea->GetElementType() == XFA_Element::PageArea) { | 
|   275       iCount++; |   275       iCount++; | 
|   276       if (pPageArea->GetFirstChildByClass(XFA_Element::ContentArea)) { |   276       if (pPageArea->GetFirstChildByClass(XFA_Element::ContentArea)) { | 
|   277         return TRUE; |   277         return TRUE; | 
|   278       } |   278       } | 
|   279     } |   279     } | 
|   280   } |   280   } | 
|   281   if (iCount > 0) { |   281   if (iCount > 0) { | 
|   282     return FALSE; |   282     return FALSE; | 
|   283   } |   283   } | 
|   284   CXFA_Document* pDocument = pTemplateNode->GetDocument(); |   284   CXFA_Document* pDocument = pTemplateNode->GetDocument(); | 
|   285   CXFA_Document* pObjFactory = pDocument->GetParser()->GetFactory(); |   285   CXFA_Document* pObjFactory = pDocument->GetParser()->GetFactory(); | 
|   286   pPageArea = m_pTemplatePageSetRoot->GetChild(0, XFA_Element::PageArea); |   286   pPageArea = m_pTemplatePageSetRoot->GetChild(0, XFA_Element::PageArea); | 
|   287   if (!pPageArea) { |   287   if (!pPageArea) { | 
|   288     pPageArea = pObjFactory->CreateNode(m_pTemplatePageSetRoot->GetPacketID(), |   288     pPageArea = pObjFactory->CreateNode(m_pTemplatePageSetRoot->GetPacketID(), | 
|   289                                         XFA_Element::PageArea); |   289                                         XFA_Element::PageArea); | 
|   290     if (!pPageArea) { |   290     if (!pPageArea) { | 
|   291       return FALSE; |   291       return FALSE; | 
|   292     } |   292     } | 
|   293     m_pTemplatePageSetRoot->InsertChild(pPageArea, NULL); |   293     m_pTemplatePageSetRoot->InsertChild(pPageArea, nullptr); | 
|   294     pPageArea->SetFlag(XFA_NodeFlag_Initialized, true); |   294     pPageArea->SetFlag(XFA_NodeFlag_Initialized, true); | 
|   295   } |   295   } | 
|   296   CXFA_Node* pContentArea = pPageArea->GetChild(0, XFA_Element::ContentArea); |   296   CXFA_Node* pContentArea = pPageArea->GetChild(0, XFA_Element::ContentArea); | 
|   297   if (!pContentArea) { |   297   if (!pContentArea) { | 
|   298     pContentArea = pObjFactory->CreateNode(pPageArea->GetPacketID(), |   298     pContentArea = pObjFactory->CreateNode(pPageArea->GetPacketID(), | 
|   299                                            XFA_Element::ContentArea); |   299                                            XFA_Element::ContentArea); | 
|   300     if (!pContentArea) { |   300     if (!pContentArea) { | 
|   301       return FALSE; |   301       return FALSE; | 
|   302     } |   302     } | 
|   303     pPageArea->InsertChild(pContentArea, NULL); |   303     pPageArea->InsertChild(pContentArea, nullptr); | 
|   304     pContentArea->SetFlag(XFA_NodeFlag_Initialized, true); |   304     pContentArea->SetFlag(XFA_NodeFlag_Initialized, true); | 
|   305     pContentArea->SetMeasure(XFA_ATTRIBUTE_X, |   305     pContentArea->SetMeasure(XFA_ATTRIBUTE_X, | 
|   306                              CXFA_Measurement(0.25f, XFA_UNIT_In)); |   306                              CXFA_Measurement(0.25f, XFA_UNIT_In)); | 
|   307     pContentArea->SetMeasure(XFA_ATTRIBUTE_Y, |   307     pContentArea->SetMeasure(XFA_ATTRIBUTE_Y, | 
|   308                              CXFA_Measurement(0.25f, XFA_UNIT_In)); |   308                              CXFA_Measurement(0.25f, XFA_UNIT_In)); | 
|   309     pContentArea->SetMeasure(XFA_ATTRIBUTE_W, |   309     pContentArea->SetMeasure(XFA_ATTRIBUTE_W, | 
|   310                              CXFA_Measurement(8.0f, XFA_UNIT_In)); |   310                              CXFA_Measurement(8.0f, XFA_UNIT_In)); | 
|   311     pContentArea->SetMeasure(XFA_ATTRIBUTE_H, |   311     pContentArea->SetMeasure(XFA_ATTRIBUTE_H, | 
|   312                              CXFA_Measurement(10.5f, XFA_UNIT_In)); |   312                              CXFA_Measurement(10.5f, XFA_UNIT_In)); | 
|   313   } |   313   } | 
|   314   CXFA_Node* pMedium = pPageArea->GetChild(0, XFA_Element::Medium); |   314   CXFA_Node* pMedium = pPageArea->GetChild(0, XFA_Element::Medium); | 
|   315   if (!pMedium) { |   315   if (!pMedium) { | 
|   316     pMedium = |   316     pMedium = | 
|   317         pObjFactory->CreateNode(pPageArea->GetPacketID(), XFA_Element::Medium); |   317         pObjFactory->CreateNode(pPageArea->GetPacketID(), XFA_Element::Medium); | 
|   318     if (!pContentArea) { |   318     if (!pContentArea) { | 
|   319       return FALSE; |   319       return FALSE; | 
|   320     } |   320     } | 
|   321     pPageArea->InsertChild(pMedium, NULL); |   321     pPageArea->InsertChild(pMedium, nullptr); | 
|   322     pMedium->SetFlag(XFA_NodeFlag_Initialized, true); |   322     pMedium->SetFlag(XFA_NodeFlag_Initialized, true); | 
|   323     pMedium->SetMeasure(XFA_ATTRIBUTE_Short, |   323     pMedium->SetMeasure(XFA_ATTRIBUTE_Short, | 
|   324                         CXFA_Measurement(8.5f, XFA_UNIT_In)); |   324                         CXFA_Measurement(8.5f, XFA_UNIT_In)); | 
|   325     pMedium->SetMeasure(XFA_ATTRIBUTE_Long, |   325     pMedium->SetMeasure(XFA_ATTRIBUTE_Long, | 
|   326                         CXFA_Measurement(11.0f, XFA_UNIT_In)); |   326                         CXFA_Measurement(11.0f, XFA_UNIT_In)); | 
|   327   } |   327   } | 
|   328   return TRUE; |   328   return TRUE; | 
|   329 } |   329 } | 
|   330 FX_BOOL CXFA_LayoutPageMgr::PrepareFirstPage(CXFA_Node* pRootSubform) { |   330 FX_BOOL CXFA_LayoutPageMgr::PrepareFirstPage(CXFA_Node* pRootSubform) { | 
|   331   FX_BOOL bProBreakBefore = FALSE; |   331   FX_BOOL bProBreakBefore = FALSE; | 
|   332   CXFA_Node* pBreakBeforeNode = NULL; |   332   CXFA_Node* pBreakBeforeNode = nullptr; | 
|   333   while (pRootSubform) { |   333   while (pRootSubform) { | 
|   334     for (CXFA_Node* pBreakNode = |   334     for (CXFA_Node* pBreakNode = | 
|   335              pRootSubform->GetNodeItem(XFA_NODEITEM_FirstChild); |   335              pRootSubform->GetNodeItem(XFA_NODEITEM_FirstChild); | 
|   336          pBreakNode; |   336          pBreakNode; | 
|   337          pBreakNode = pBreakNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { |   337          pBreakNode = pBreakNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { | 
|   338       XFA_Element eType = pBreakNode->GetElementType(); |   338       XFA_Element eType = pBreakNode->GetElementType(); | 
|   339       if (eType == XFA_Element::BreakBefore || |   339       if (eType == XFA_Element::BreakBefore || | 
|   340           (eType == XFA_Element::Break && |   340           (eType == XFA_Element::Break && | 
|   341            pBreakNode->GetEnum(XFA_ATTRIBUTE_Before) != |   341            pBreakNode->GetEnum(XFA_ATTRIBUTE_Before) != | 
|   342                XFA_ATTRIBUTEENUM_Auto)) { |   342                XFA_ATTRIBUTEENUM_Auto)) { | 
| (...skipping 19 matching lines...) Expand all  Loading... | 
|   362     m_pCurrentContainerRecord = m_rgProposedContainerRecord.GetHeadPosition(); |   362     m_pCurrentContainerRecord = m_rgProposedContainerRecord.GetHeadPosition(); | 
|   363     return TRUE; |   363     return TRUE; | 
|   364   } |   364   } | 
|   365   return AppendNewPage(TRUE); |   365   return AppendNewPage(TRUE); | 
|   366 } |   366 } | 
|   367 FX_BOOL CXFA_LayoutPageMgr::AppendNewPage(FX_BOOL bFirstTemPage) { |   367 FX_BOOL CXFA_LayoutPageMgr::AppendNewPage(FX_BOOL bFirstTemPage) { | 
|   368   if (m_pCurrentContainerRecord != |   368   if (m_pCurrentContainerRecord != | 
|   369       m_rgProposedContainerRecord.GetTailPosition()) { |   369       m_rgProposedContainerRecord.GetTailPosition()) { | 
|   370     return TRUE; |   370     return TRUE; | 
|   371   } |   371   } | 
|   372   CXFA_Node* pPageNode = GetNextAvailPageArea(NULL); |   372   CXFA_Node* pPageNode = GetNextAvailPageArea(nullptr); | 
|   373   if (!pPageNode) { |   373   if (!pPageNode) { | 
|   374     return FALSE; |   374     return FALSE; | 
|   375   } |   375   } | 
|   376   if (bFirstTemPage && m_pCurrentContainerRecord == NULL) { |   376   if (bFirstTemPage && !m_pCurrentContainerRecord) { | 
|   377     m_pCurrentContainerRecord = m_rgProposedContainerRecord.GetHeadPosition(); |   377     m_pCurrentContainerRecord = m_rgProposedContainerRecord.GetHeadPosition(); | 
|   378   } |   378   } | 
|   379   return !bFirstTemPage || m_pCurrentContainerRecord; |   379   return !bFirstTemPage || m_pCurrentContainerRecord; | 
|   380 } |   380 } | 
|   381  |   381  | 
|   382 void CXFA_LayoutPageMgr::RemoveLayoutRecord(CXFA_ContainerRecord* pNewRecord, |   382 void CXFA_LayoutPageMgr::RemoveLayoutRecord(CXFA_ContainerRecord* pNewRecord, | 
|   383                                             CXFA_ContainerRecord* pPrevRecord) { |   383                                             CXFA_ContainerRecord* pPrevRecord) { | 
|   384   if (!pNewRecord || !pPrevRecord) { |   384   if (!pNewRecord || !pPrevRecord) { | 
|   385     return; |   385     return; | 
|   386   } |   386   } | 
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   457   } |   457   } | 
|   458   return pTestScript->GetDocument()->GetParser()->GetNotify()->RunScript( |   458   return pTestScript->GetDocument()->GetParser()->GetNotify()->RunScript( | 
|   459       pTestScript, pTestScript->GetNodeItem(XFA_NODEITEM_Parent, |   459       pTestScript, pTestScript->GetNodeItem(XFA_NODEITEM_Parent, | 
|   460                                             XFA_ObjectType::ContainerNode)); |   460                                             XFA_ObjectType::ContainerNode)); | 
|   461 } |   461 } | 
|   462 CXFA_ContainerRecord* CXFA_LayoutPageMgr::CreateContainerRecord( |   462 CXFA_ContainerRecord* CXFA_LayoutPageMgr::CreateContainerRecord( | 
|   463     CXFA_Node* pPageNode, |   463     CXFA_Node* pPageNode, | 
|   464     FX_BOOL bCreateNew) { |   464     FX_BOOL bCreateNew) { | 
|   465   CXFA_ContainerRecord* pNewRecord = new CXFA_ContainerRecord(); |   465   CXFA_ContainerRecord* pNewRecord = new CXFA_ContainerRecord(); | 
|   466   if (m_pCurrentContainerRecord) { |   466   if (m_pCurrentContainerRecord) { | 
|   467     if (!IsPageSetRootOrderedOccurrence() || pPageNode == NULL) { |   467     if (!IsPageSetRootOrderedOccurrence() || !pPageNode) { | 
|   468       *pNewRecord = *GetCurrentContainerRecord(); |   468       *pNewRecord = *GetCurrentContainerRecord(); | 
|   469       m_rgProposedContainerRecord.AddTail(pNewRecord); |   469       m_rgProposedContainerRecord.AddTail(pNewRecord); | 
|   470       return pNewRecord; |   470       return pNewRecord; | 
|   471     } |   471     } | 
|   472     CXFA_Node* pPageSet = pPageNode->GetNodeItem(XFA_NODEITEM_Parent); |   472     CXFA_Node* pPageSet = pPageNode->GetNodeItem(XFA_NODEITEM_Parent); | 
|   473     if (!bCreateNew) { |   473     if (!bCreateNew) { | 
|   474       if (pPageSet == m_pTemplatePageSetRoot) { |   474       if (pPageSet == m_pTemplatePageSetRoot) { | 
|   475         pNewRecord->pCurPageSet = m_pPageSetCurRoot; |   475         pNewRecord->pCurPageSet = m_pPageSetCurRoot; | 
|   476       } else { |   476       } else { | 
|   477         CXFA_ContainerLayoutItem* pParentLayoutItem = |   477         CXFA_ContainerLayoutItem* pParentLayoutItem = | 
|   478             (CXFA_ContainerLayoutItem*)pPageSet->GetUserData(XFA_LAYOUTITEMKEY); |   478             (CXFA_ContainerLayoutItem*)pPageSet->GetUserData(XFA_LAYOUTITEMKEY); | 
|   479         if (pParentLayoutItem == NULL) { |   479         if (!pParentLayoutItem) { | 
|   480           pParentLayoutItem = m_pPageSetCurRoot; |   480           pParentLayoutItem = m_pPageSetCurRoot; | 
|   481         } |   481         } | 
|   482         pNewRecord->pCurPageSet = pParentLayoutItem; |   482         pNewRecord->pCurPageSet = pParentLayoutItem; | 
|   483       } |   483       } | 
|   484     } else { |   484     } else { | 
|   485       CXFA_ContainerLayoutItem* pParentPageSetLayout = NULL; |   485       CXFA_ContainerLayoutItem* pParentPageSetLayout = nullptr; | 
|   486       if (pPageSet == GetCurrentContainerRecord()->pCurPageSet->m_pFormNode) { |   486       if (pPageSet == GetCurrentContainerRecord()->pCurPageSet->m_pFormNode) { | 
|   487         pParentPageSetLayout = |   487         pParentPageSetLayout = | 
|   488             (CXFA_ContainerLayoutItem*)GetCurrentContainerRecord() |   488             (CXFA_ContainerLayoutItem*)GetCurrentContainerRecord() | 
|   489                 ->pCurPageSet->m_pParent; |   489                 ->pCurPageSet->m_pParent; | 
|   490       } else { |   490       } else { | 
|   491         pParentPageSetLayout = |   491         pParentPageSetLayout = | 
|   492             (CXFA_ContainerLayoutItem*)pPageSet->GetNodeItem( |   492             (CXFA_ContainerLayoutItem*)pPageSet->GetNodeItem( | 
|   493                                                    XFA_NODEITEM_Parent) |   493                                                    XFA_NODEITEM_Parent) | 
|   494                 ->GetUserData(XFA_LAYOUTITEMKEY); |   494                 ->GetUserData(XFA_LAYOUTITEMKEY); | 
|   495       } |   495       } | 
|   496       CXFA_ContainerLayoutItem* pPageSetLayoutItem = |   496       CXFA_ContainerLayoutItem* pPageSetLayoutItem = | 
|   497           new CXFA_ContainerLayoutItem(pPageSet); |   497           new CXFA_ContainerLayoutItem(pPageSet); | 
|   498       pPageSet->SetUserData(XFA_LAYOUTITEMKEY, (void*)pPageSetLayoutItem); |   498       pPageSet->SetUserData(XFA_LAYOUTITEMKEY, (void*)pPageSetLayoutItem); | 
|   499       if (pParentPageSetLayout == NULL) { |   499       if (!pParentPageSetLayout) { | 
|   500         CXFA_ContainerLayoutItem* pPrePageSet = m_pPageSetLayoutItemRoot; |   500         CXFA_ContainerLayoutItem* pPrePageSet = m_pPageSetLayoutItemRoot; | 
|   501         while (pPrePageSet->m_pNextSibling) { |   501         while (pPrePageSet->m_pNextSibling) { | 
|   502           pPrePageSet = (CXFA_ContainerLayoutItem*)pPrePageSet->m_pNextSibling; |   502           pPrePageSet = (CXFA_ContainerLayoutItem*)pPrePageSet->m_pNextSibling; | 
|   503         } |   503         } | 
|   504         pPrePageSet->m_pNextSibling = pPageSetLayoutItem; |   504         pPrePageSet->m_pNextSibling = pPageSetLayoutItem; | 
|   505         m_pPageSetCurRoot = pPageSetLayoutItem; |   505         m_pPageSetCurRoot = pPageSetLayoutItem; | 
|   506       } else { |   506       } else { | 
|   507         pParentPageSetLayout->AddChild(pPageSetLayoutItem); |   507         pParentPageSetLayout->AddChild(pPageSetLayoutItem); | 
|   508       } |   508       } | 
|   509       pNewRecord->pCurPageSet = pPageSetLayoutItem; |   509       pNewRecord->pCurPageSet = pPageSetLayoutItem; | 
| (...skipping 12 matching lines...) Expand all  Loading... | 
|   522       } |   522       } | 
|   523     } else { |   523     } else { | 
|   524       pNewRecord->pCurPageSet = m_pPageSetLayoutItemRoot; |   524       pNewRecord->pCurPageSet = m_pPageSetLayoutItemRoot; | 
|   525     } |   525     } | 
|   526   } |   526   } | 
|   527   m_rgProposedContainerRecord.AddTail(pNewRecord); |   527   m_rgProposedContainerRecord.AddTail(pNewRecord); | 
|   528   return pNewRecord; |   528   return pNewRecord; | 
|   529 } |   529 } | 
|   530 void CXFA_LayoutPageMgr::AddPageAreaLayoutItem(CXFA_ContainerRecord* pNewRecord, |   530 void CXFA_LayoutPageMgr::AddPageAreaLayoutItem(CXFA_ContainerRecord* pNewRecord, | 
|   531                                                CXFA_Node* pNewPageArea) { |   531                                                CXFA_Node* pNewPageArea) { | 
|   532   CXFA_ContainerLayoutItem* pNewPageAreaLayoutItem = NULL; |   532   CXFA_ContainerLayoutItem* pNewPageAreaLayoutItem = nullptr; | 
|   533   if (m_PageArray.GetSize() > m_nAvailPages) { |   533   if (m_PageArray.GetSize() > m_nAvailPages) { | 
|   534     CXFA_ContainerLayoutItem* pContainerItem = m_PageArray[m_nAvailPages]; |   534     CXFA_ContainerLayoutItem* pContainerItem = m_PageArray[m_nAvailPages]; | 
|   535     pContainerItem->m_pFormNode = pNewPageArea; |   535     pContainerItem->m_pFormNode = pNewPageArea; | 
|   536     m_nAvailPages++; |   536     m_nAvailPages++; | 
|   537     pNewPageAreaLayoutItem = pContainerItem; |   537     pNewPageAreaLayoutItem = pContainerItem; | 
|   538   } else { |   538   } else { | 
|   539     CXFA_FFNotify* pNotify = |   539     CXFA_FFNotify* pNotify = | 
|   540         pNewPageArea->GetDocument()->GetParser()->GetNotify(); |   540         pNewPageArea->GetDocument()->GetParser()->GetNotify(); | 
|   541     CXFA_ContainerLayoutItem* pContainerItem = |   541     CXFA_ContainerLayoutItem* pContainerItem = | 
|   542         (CXFA_ContainerLayoutItem*)pNotify->OnCreateLayoutItem(pNewPageArea); |   542         (CXFA_ContainerLayoutItem*)pNotify->OnCreateLayoutItem(pNewPageArea); | 
|   543     m_PageArray.Add(pContainerItem); |   543     m_PageArray.Add(pContainerItem); | 
|   544     m_nAvailPages++; |   544     m_nAvailPages++; | 
|   545     pNotify->OnPageEvent(pContainerItem, XFA_PAGEVIEWEVENT_PostRemoved); |   545     pNotify->OnPageEvent(pContainerItem, XFA_PAGEVIEWEVENT_PostRemoved); | 
|   546     pNewPageAreaLayoutItem = pContainerItem; |   546     pNewPageAreaLayoutItem = pContainerItem; | 
|   547   } |   547   } | 
|   548   pNewRecord->pCurPageSet->AddChild(pNewPageAreaLayoutItem); |   548   pNewRecord->pCurPageSet->AddChild(pNewPageAreaLayoutItem); | 
|   549   pNewRecord->pCurPageArea = pNewPageAreaLayoutItem; |   549   pNewRecord->pCurPageArea = pNewPageAreaLayoutItem; | 
|   550   pNewRecord->pCurContentArea = NULL; |   550   pNewRecord->pCurContentArea = nullptr; | 
|   551 } |   551 } | 
|   552 void CXFA_LayoutPageMgr::AddContentAreaLayoutItem( |   552 void CXFA_LayoutPageMgr::AddContentAreaLayoutItem( | 
|   553     CXFA_ContainerRecord* pNewRecord, |   553     CXFA_ContainerRecord* pNewRecord, | 
|   554     CXFA_Node* pContentArea) { |   554     CXFA_Node* pContentArea) { | 
|   555   if (pContentArea == NULL) { |   555   if (!pContentArea) { | 
|   556     pNewRecord->pCurContentArea = NULL; |   556     pNewRecord->pCurContentArea = nullptr; | 
|   557     return; |   557     return; | 
|   558   } |   558   } | 
|   559   CXFA_ContainerLayoutItem* pNewContentAreaLayoutItem = |   559   CXFA_ContainerLayoutItem* pNewContentAreaLayoutItem = | 
|   560       new CXFA_ContainerLayoutItem(pContentArea); |   560       new CXFA_ContainerLayoutItem(pContentArea); | 
|   561   ASSERT(pNewRecord->pCurPageArea); |   561   ASSERT(pNewRecord->pCurPageArea); | 
|   562   pNewRecord->pCurPageArea->AddChild(pNewContentAreaLayoutItem); |   562   pNewRecord->pCurPageArea->AddChild(pNewContentAreaLayoutItem); | 
|   563   pNewRecord->pCurContentArea = pNewContentAreaLayoutItem; |   563   pNewRecord->pCurContentArea = pNewContentAreaLayoutItem; | 
|   564 } |   564 } | 
|   565  |   565  | 
|   566 void CXFA_LayoutPageMgr::FinishPaginatedPageSets() { |   566 void CXFA_LayoutPageMgr::FinishPaginatedPageSets() { | 
|   567   CXFA_ContainerLayoutItem* pRootPageSetLayoutItem = m_pPageSetLayoutItemRoot; |   567   CXFA_ContainerLayoutItem* pRootPageSetLayoutItem = m_pPageSetLayoutItemRoot; | 
|   568   for (; pRootPageSetLayoutItem; |   568   for (; pRootPageSetLayoutItem; | 
|   569        pRootPageSetLayoutItem = |   569        pRootPageSetLayoutItem = | 
|   570            (CXFA_ContainerLayoutItem*)pRootPageSetLayoutItem->m_pNextSibling) { |   570            (CXFA_ContainerLayoutItem*)pRootPageSetLayoutItem->m_pNextSibling) { | 
|   571     CXFA_NodeIteratorTemplate<CXFA_ContainerLayoutItem, |   571     CXFA_NodeIteratorTemplate<CXFA_ContainerLayoutItem, | 
|   572                               PageSetContainerLayoutItem> |   572                               PageSetContainerLayoutItem> | 
|   573         sIterator(pRootPageSetLayoutItem); |   573         sIterator(pRootPageSetLayoutItem); | 
|   574     for (CXFA_ContainerLayoutItem* pPageSetLayoutItem = sIterator.GetCurrent(); |   574     for (CXFA_ContainerLayoutItem* pPageSetLayoutItem = sIterator.GetCurrent(); | 
|   575          pPageSetLayoutItem; pPageSetLayoutItem = sIterator.MoveToNext()) { |   575          pPageSetLayoutItem; pPageSetLayoutItem = sIterator.MoveToNext()) { | 
|   576       XFA_ATTRIBUTEENUM ePageRelation = |   576       XFA_ATTRIBUTEENUM ePageRelation = | 
|   577           pPageSetLayoutItem->m_pFormNode->GetEnum(XFA_ATTRIBUTE_Relation); |   577           pPageSetLayoutItem->m_pFormNode->GetEnum(XFA_ATTRIBUTE_Relation); | 
|   578       switch (ePageRelation) { |   578       switch (ePageRelation) { | 
|   579         case XFA_ATTRIBUTEENUM_OrderedOccurrence: |   579         case XFA_ATTRIBUTEENUM_OrderedOccurrence: | 
|   580         default: { ProcessLastPageSet(); } break; |   580         default: { ProcessLastPageSet(); } break; | 
|   581         case XFA_ATTRIBUTEENUM_SimplexPaginated: |   581         case XFA_ATTRIBUTEENUM_SimplexPaginated: | 
|   582         case XFA_ATTRIBUTEENUM_DuplexPaginated: { |   582         case XFA_ATTRIBUTEENUM_DuplexPaginated: { | 
|   583           CXFA_LayoutItem* pLastPageAreaLayoutItem = NULL; |   583           CXFA_LayoutItem* pLastPageAreaLayoutItem = nullptr; | 
|   584           int32_t nPageAreaCount = 0; |   584           int32_t nPageAreaCount = 0; | 
|   585           for (CXFA_LayoutItem* pPageAreaLayoutItem = |   585           for (CXFA_LayoutItem* pPageAreaLayoutItem = | 
|   586                    pPageSetLayoutItem->m_pFirstChild; |   586                    pPageSetLayoutItem->m_pFirstChild; | 
|   587                pPageAreaLayoutItem; |   587                pPageAreaLayoutItem; | 
|   588                pPageAreaLayoutItem = pPageAreaLayoutItem->m_pNextSibling) { |   588                pPageAreaLayoutItem = pPageAreaLayoutItem->m_pNextSibling) { | 
|   589             if (pPageAreaLayoutItem->m_pFormNode->GetElementType() != |   589             if (pPageAreaLayoutItem->m_pFormNode->GetElementType() != | 
|   590                 XFA_Element::PageArea) { |   590                 XFA_Element::PageArea) { | 
|   591               continue; |   591               continue; | 
|   592             } |   592             } | 
|   593             nPageAreaCount++; |   593             nPageAreaCount++; | 
|   594             pLastPageAreaLayoutItem = pPageAreaLayoutItem; |   594             pLastPageAreaLayoutItem = pPageAreaLayoutItem; | 
|   595           } |   595           } | 
|   596           if (!pLastPageAreaLayoutItem) { |   596           if (!pLastPageAreaLayoutItem) { | 
|   597             break; |   597             break; | 
|   598           } |   598           } | 
|   599           if (!FindPageAreaFromPageSet_SimplexDuplex( |   599           if (!FindPageAreaFromPageSet_SimplexDuplex( | 
|   600                   pPageSetLayoutItem->m_pFormNode, NULL, NULL, NULL, TRUE, TRUE, |   600                   pPageSetLayoutItem->m_pFormNode, nullptr, nullptr, nullptr, | 
|   601                   nPageAreaCount == 1 ? XFA_ATTRIBUTEENUM_Only |   601                   TRUE, TRUE, nPageAreaCount == 1 ? XFA_ATTRIBUTEENUM_Only | 
|   602                                       : XFA_ATTRIBUTEENUM_Last) && |   602                                                   : XFA_ATTRIBUTEENUM_Last) && | 
|   603               (nPageAreaCount == 1 && |   603               (nPageAreaCount == 1 && | 
|   604                !FindPageAreaFromPageSet_SimplexDuplex( |   604                !FindPageAreaFromPageSet_SimplexDuplex( | 
|   605                    pPageSetLayoutItem->m_pFormNode, NULL, NULL, NULL, TRUE, |   605                    pPageSetLayoutItem->m_pFormNode, nullptr, nullptr, nullptr, | 
|   606                    TRUE, XFA_ATTRIBUTEENUM_Last))) { |   606                    TRUE, TRUE, XFA_ATTRIBUTEENUM_Last))) { | 
|   607             break; |   607             break; | 
|   608           } |   608           } | 
|   609           CXFA_Node* pNode = m_pCurPageArea; |   609           CXFA_Node* pNode = m_pCurPageArea; | 
|   610           XFA_ATTRIBUTEENUM eCurChoice = |   610           XFA_ATTRIBUTEENUM eCurChoice = | 
|   611               pNode->GetEnum(XFA_ATTRIBUTE_PagePosition); |   611               pNode->GetEnum(XFA_ATTRIBUTE_PagePosition); | 
|   612           if (eCurChoice == XFA_ATTRIBUTEENUM_Last) { |   612           if (eCurChoice == XFA_ATTRIBUTEENUM_Last) { | 
|   613             XFA_ATTRIBUTEENUM eOddOrEven = XFA_ATTRIBUTEENUM_Any; |   613             XFA_ATTRIBUTEENUM eOddOrEven = XFA_ATTRIBUTEENUM_Any; | 
|   614             pNode->TryEnum(XFA_ATTRIBUTE_OddOrEven, eOddOrEven); |   614             pNode->TryEnum(XFA_ATTRIBUTE_OddOrEven, eOddOrEven); | 
|   615             XFA_ATTRIBUTEENUM eLastChoice = |   615             XFA_ATTRIBUTEENUM eLastChoice = | 
|   616                 pLastPageAreaLayoutItem->m_pFormNode->GetEnum( |   616                 pLastPageAreaLayoutItem->m_pFormNode->GetEnum( | 
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   712   return m_PageArray.Find(const_cast<CXFA_ContainerLayoutItem*>(pPage)); |   712   return m_PageArray.Find(const_cast<CXFA_ContainerLayoutItem*>(pPage)); | 
|   713 } |   713 } | 
|   714 FX_BOOL CXFA_LayoutPageMgr::RunBreak(XFA_Element eBreakType, |   714 FX_BOOL CXFA_LayoutPageMgr::RunBreak(XFA_Element eBreakType, | 
|   715                                      XFA_ATTRIBUTEENUM eTargetType, |   715                                      XFA_ATTRIBUTEENUM eTargetType, | 
|   716                                      CXFA_Node* pTarget, |   716                                      CXFA_Node* pTarget, | 
|   717                                      FX_BOOL bStartNew) { |   717                                      FX_BOOL bStartNew) { | 
|   718   FX_BOOL bRet = FALSE; |   718   FX_BOOL bRet = FALSE; | 
|   719   switch (eTargetType) { |   719   switch (eTargetType) { | 
|   720     case XFA_ATTRIBUTEENUM_ContentArea: |   720     case XFA_ATTRIBUTEENUM_ContentArea: | 
|   721       if (pTarget && pTarget->GetElementType() != XFA_Element::ContentArea) { |   721       if (pTarget && pTarget->GetElementType() != XFA_Element::ContentArea) { | 
|   722         pTarget = NULL; |   722         pTarget = nullptr; | 
|   723       } |   723       } | 
|   724       if (!pTarget || !m_pCurrentContainerRecord || |   724       if (!pTarget || !m_pCurrentContainerRecord || | 
|   725           pTarget != |   725           pTarget != | 
|   726               GetCurrentContainerRecord()->pCurContentArea->m_pFormNode || |   726               GetCurrentContainerRecord()->pCurContentArea->m_pFormNode || | 
|   727           bStartNew) { |   727           bStartNew) { | 
|   728         CXFA_Node* pPageArea = NULL; |   728         CXFA_Node* pPageArea = nullptr; | 
|   729         if (pTarget) { |   729         if (pTarget) { | 
|   730           pPageArea = pTarget->GetNodeItem(XFA_NODEITEM_Parent); |   730           pPageArea = pTarget->GetNodeItem(XFA_NODEITEM_Parent); | 
|   731         } |   731         } | 
|   732         pPageArea = GetNextAvailPageArea(pPageArea, pTarget); |   732         pPageArea = GetNextAvailPageArea(pPageArea, pTarget); | 
|   733         bRet = pPageArea != NULL; |   733         bRet = !!pPageArea; | 
|   734       } |   734       } | 
|   735       break; |   735       break; | 
|   736     case XFA_ATTRIBUTEENUM_PageArea: |   736     case XFA_ATTRIBUTEENUM_PageArea: | 
|   737       if (pTarget && pTarget->GetElementType() != XFA_Element::PageArea) { |   737       if (pTarget && pTarget->GetElementType() != XFA_Element::PageArea) { | 
|   738         pTarget = NULL; |   738         pTarget = nullptr; | 
|   739       } |   739       } | 
|   740       if (!pTarget || !m_pCurrentContainerRecord || |   740       if (!pTarget || !m_pCurrentContainerRecord || | 
|   741           pTarget != GetCurrentContainerRecord()->pCurPageArea->m_pFormNode || |   741           pTarget != GetCurrentContainerRecord()->pCurPageArea->m_pFormNode || | 
|   742           bStartNew) { |   742           bStartNew) { | 
|   743         CXFA_Node* pPageArea = GetNextAvailPageArea(pTarget, NULL, TRUE); |   743         CXFA_Node* pPageArea = GetNextAvailPageArea(pTarget, nullptr, TRUE); | 
|   744         bRet = pPageArea != NULL; |   744         bRet = !!pPageArea; | 
|   745       } |   745       } | 
|   746       break; |   746       break; | 
|   747     case XFA_ATTRIBUTEENUM_PageOdd: |   747     case XFA_ATTRIBUTEENUM_PageOdd: | 
|   748       if (pTarget && pTarget->GetElementType() != XFA_Element::PageArea) { |   748       if (pTarget && pTarget->GetElementType() != XFA_Element::PageArea) { | 
|   749         pTarget = NULL; |   749         pTarget = nullptr; | 
|   750       } |   750       } | 
|   751       break; |   751       break; | 
|   752     case XFA_ATTRIBUTEENUM_PageEven: |   752     case XFA_ATTRIBUTEENUM_PageEven: | 
|   753       if (pTarget && pTarget->GetElementType() != XFA_Element::PageArea) { |   753       if (pTarget && pTarget->GetElementType() != XFA_Element::PageArea) { | 
|   754         pTarget = NULL; |   754         pTarget = nullptr; | 
|   755       } |   755       } | 
|   756       break; |   756       break; | 
|   757     case XFA_ATTRIBUTEENUM_Auto: |   757     case XFA_ATTRIBUTEENUM_Auto: | 
|   758     default: |   758     default: | 
|   759       break; |   759       break; | 
|   760   } |   760   } | 
|   761   return bRet; |   761   return bRet; | 
|   762 } |   762 } | 
|   763 FX_BOOL CXFA_LayoutPageMgr::ExecuteBreakBeforeOrAfter( |   763 FX_BOOL CXFA_LayoutPageMgr::ExecuteBreakBeforeOrAfter( | 
|   764     CXFA_Node* pCurNode, |   764     CXFA_Node* pCurNode, | 
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   830   } |   830   } | 
|   831   return FALSE; |   831   return FALSE; | 
|   832 } |   832 } | 
|   833  |   833  | 
|   834 FX_BOOL CXFA_LayoutPageMgr::ProcessBreakBeforeOrAfter( |   834 FX_BOOL CXFA_LayoutPageMgr::ProcessBreakBeforeOrAfter( | 
|   835     CXFA_Node* pBreakNode, |   835     CXFA_Node* pBreakNode, | 
|   836     FX_BOOL bBefore, |   836     FX_BOOL bBefore, | 
|   837     CXFA_Node*& pBreakLeaderNode, |   837     CXFA_Node*& pBreakLeaderNode, | 
|   838     CXFA_Node*& pBreakTrailerNode, |   838     CXFA_Node*& pBreakTrailerNode, | 
|   839     FX_BOOL& bCreatePage) { |   839     FX_BOOL& bCreatePage) { | 
|   840   CXFA_Node *pLeaderTemplate = NULL, *pTrailerTemplate = NULL; |   840   CXFA_Node* pLeaderTemplate = nullptr; | 
 |   841   CXFA_Node* pTrailerTemplate = nullptr; | 
|   841   CXFA_Node* pFormNode = pBreakNode->GetNodeItem(XFA_NODEITEM_Parent, |   842   CXFA_Node* pFormNode = pBreakNode->GetNodeItem(XFA_NODEITEM_Parent, | 
|   842                                                  XFA_ObjectType::ContainerNode); |   843                                                  XFA_ObjectType::ContainerNode); | 
|   843   if (XFA_ItemLayoutProcessor_IsTakingSpace(pFormNode)) { |   844   if (XFA_ItemLayoutProcessor_IsTakingSpace(pFormNode)) { | 
|   844     bCreatePage = ExecuteBreakBeforeOrAfter(pBreakNode, bBefore, |   845     bCreatePage = ExecuteBreakBeforeOrAfter(pBreakNode, bBefore, | 
|   845                                             pLeaderTemplate, pTrailerTemplate); |   846                                             pLeaderTemplate, pTrailerTemplate); | 
|   846     CXFA_Document* pDocument = pBreakNode->GetDocument(); |   847     CXFA_Document* pDocument = pBreakNode->GetDocument(); | 
|   847     CXFA_Node* pDataScope = NULL; |   848     CXFA_Node* pDataScope = nullptr; | 
|   848     pFormNode = pFormNode->GetNodeItem(XFA_NODEITEM_Parent, |   849     pFormNode = pFormNode->GetNodeItem(XFA_NODEITEM_Parent, | 
|   849                                        XFA_ObjectType::ContainerNode); |   850                                        XFA_ObjectType::ContainerNode); | 
|   850     if (pLeaderTemplate) { |   851     if (pLeaderTemplate) { | 
|   851       if (!pDataScope) { |   852       if (!pDataScope) { | 
|   852         pDataScope = XFA_DataMerge_FindDataScope(pFormNode); |   853         pDataScope = XFA_DataMerge_FindDataScope(pFormNode); | 
|   853       } |   854       } | 
|   854       pBreakLeaderNode = pDocument->DataMerge_CopyContainer( |   855       pBreakLeaderNode = pDocument->DataMerge_CopyContainer( | 
|   855           pLeaderTemplate, pFormNode, pDataScope, TRUE); |   856           pLeaderTemplate, pFormNode, pDataScope, TRUE); | 
|   856       pDocument->DataMerge_UpdateBindingRelations(pBreakLeaderNode); |   857       pDocument->DataMerge_UpdateBindingRelations(pBreakLeaderNode); | 
|   857       SetLayoutGeneratedNodeFlag(pBreakLeaderNode); |   858       SetLayoutGeneratedNodeFlag(pBreakLeaderNode); | 
|   858     } |   859     } | 
|   859     if (pTrailerTemplate) { |   860     if (pTrailerTemplate) { | 
|   860       if (!pDataScope) { |   861       if (!pDataScope) { | 
|   861         pDataScope = XFA_DataMerge_FindDataScope(pFormNode); |   862         pDataScope = XFA_DataMerge_FindDataScope(pFormNode); | 
|   862       } |   863       } | 
|   863       pBreakTrailerNode = pDocument->DataMerge_CopyContainer( |   864       pBreakTrailerNode = pDocument->DataMerge_CopyContainer( | 
|   864           pTrailerTemplate, pFormNode, pDataScope, TRUE); |   865           pTrailerTemplate, pFormNode, pDataScope, TRUE); | 
|   865       pDocument->DataMerge_UpdateBindingRelations(pBreakTrailerNode); |   866       pDocument->DataMerge_UpdateBindingRelations(pBreakTrailerNode); | 
|   866       SetLayoutGeneratedNodeFlag(pBreakTrailerNode); |   867       SetLayoutGeneratedNodeFlag(pBreakTrailerNode); | 
|   867     } |   868     } | 
|   868     return TRUE; |   869     return TRUE; | 
|   869   } |   870   } | 
|   870   return FALSE; |   871   return FALSE; | 
|   871 } |   872 } | 
|   872 FX_BOOL CXFA_LayoutPageMgr::ProcessBookendLeaderOrTrailer( |   873 FX_BOOL CXFA_LayoutPageMgr::ProcessBookendLeaderOrTrailer( | 
|   873     CXFA_Node* pBookendNode, |   874     CXFA_Node* pBookendNode, | 
|   874     FX_BOOL bLeader, |   875     FX_BOOL bLeader, | 
|   875     CXFA_Node*& pBookendAppendNode) { |   876     CXFA_Node*& pBookendAppendNode) { | 
|   876   CXFA_Node* pLeaderTemplate = NULL; |   877   CXFA_Node* pLeaderTemplate = nullptr; | 
|   877   CXFA_Node* pFormNode = pBookendNode->GetNodeItem( |   878   CXFA_Node* pFormNode = pBookendNode->GetNodeItem( | 
|   878       XFA_NODEITEM_Parent, XFA_ObjectType::ContainerNode); |   879       XFA_NODEITEM_Parent, XFA_ObjectType::ContainerNode); | 
|   879   if (ResolveBookendLeaderOrTrailer(pBookendNode, bLeader, pLeaderTemplate)) { |   880   if (ResolveBookendLeaderOrTrailer(pBookendNode, bLeader, pLeaderTemplate)) { | 
|   880     CXFA_Document* pDocument = pBookendNode->GetDocument(); |   881     CXFA_Document* pDocument = pBookendNode->GetDocument(); | 
|   881     CXFA_Node* pDataScope = NULL; |   882     CXFA_Node* pDataScope = nullptr; | 
|   882     if (pLeaderTemplate) { |   883     if (pLeaderTemplate) { | 
|   883       if (!pDataScope) { |   884       if (!pDataScope) { | 
|   884         pDataScope = XFA_DataMerge_FindDataScope(pFormNode); |   885         pDataScope = XFA_DataMerge_FindDataScope(pFormNode); | 
|   885       } |   886       } | 
|   886       pBookendAppendNode = pDocument->DataMerge_CopyContainer( |   887       pBookendAppendNode = pDocument->DataMerge_CopyContainer( | 
|   887           pLeaderTemplate, pFormNode, pDataScope, TRUE); |   888           pLeaderTemplate, pFormNode, pDataScope, TRUE); | 
|   888       pDocument->DataMerge_UpdateBindingRelations(pBookendAppendNode); |   889       pDocument->DataMerge_UpdateBindingRelations(pBookendAppendNode); | 
|   889       SetLayoutGeneratedNodeFlag(pBookendAppendNode); |   890       SetLayoutGeneratedNodeFlag(pBookendAppendNode); | 
|   890       return TRUE; |   891       return TRUE; | 
|   891     } |   892     } | 
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   930         } |   931         } | 
|   931       } |   932       } | 
|   932       if (!bCreatePage) { |   933       if (!bCreatePage) { | 
|   933         pLeaderTemplate = |   934         pLeaderTemplate = | 
|   934             ResolveBreakTarget(pContainer, TRUE, wsOverflowLeader); |   935             ResolveBreakTarget(pContainer, TRUE, wsOverflowLeader); | 
|   935         pTrailerTemplate = |   936         pTrailerTemplate = | 
|   936             ResolveBreakTarget(pContainer, TRUE, wsOverflowTrailer); |   937             ResolveBreakTarget(pContainer, TRUE, wsOverflowTrailer); | 
|   937       } |   938       } | 
|   938       return pOverflowNode; |   939       return pOverflowNode; | 
|   939     } |   940     } | 
|   940     return NULL; |   941     return nullptr; | 
|   941   } else if (pOverflowNode->GetElementType() == XFA_Element::Overflow) { |   942   } | 
|   942     CFX_WideStringC wsOverflowLeader; |   943  | 
|   943     CFX_WideStringC wsOverflowTrailer; |   944   if (pOverflowNode->GetElementType() != XFA_Element::Overflow) | 
|   944     CFX_WideStringC wsOverflowTarget; |   945     return nullptr; | 
|   945     pOverflowNode->TryCData(XFA_ATTRIBUTE_Leader, wsOverflowLeader); |   946  | 
|   946     pOverflowNode->TryCData(XFA_ATTRIBUTE_Trailer, wsOverflowTrailer); |   947   CFX_WideStringC wsOverflowLeader; | 
|   947     pOverflowNode->TryCData(XFA_ATTRIBUTE_Target, wsOverflowTarget); |   948   CFX_WideStringC wsOverflowTrailer; | 
|   948     if (!wsOverflowTarget.IsEmpty() && bCreatePage && !m_bCreateOverFlowPage) { |   949   CFX_WideStringC wsOverflowTarget; | 
|   949       CXFA_Node* pTarget = |   950   pOverflowNode->TryCData(XFA_ATTRIBUTE_Leader, wsOverflowLeader); | 
|   950           ResolveBreakTarget(m_pTemplatePageSetRoot, TRUE, wsOverflowTarget); |   951   pOverflowNode->TryCData(XFA_ATTRIBUTE_Trailer, wsOverflowTrailer); | 
|   951       if (pTarget) { |   952   pOverflowNode->TryCData(XFA_ATTRIBUTE_Target, wsOverflowTarget); | 
|   952         m_bCreateOverFlowPage = TRUE; |   953   if (!wsOverflowTarget.IsEmpty() && bCreatePage && !m_bCreateOverFlowPage) { | 
|   953         switch (pTarget->GetElementType()) { |   954     CXFA_Node* pTarget = | 
|   954           case XFA_Element::PageArea: |   955         ResolveBreakTarget(m_pTemplatePageSetRoot, TRUE, wsOverflowTarget); | 
|   955             RunBreak(XFA_Element::Overflow, XFA_ATTRIBUTEENUM_PageArea, pTarget, |   956     if (pTarget) { | 
|   956                      TRUE); |   957       m_bCreateOverFlowPage = TRUE; | 
|   957             break; |   958       switch (pTarget->GetElementType()) { | 
|   958           case XFA_Element::ContentArea: |   959         case XFA_Element::PageArea: | 
|   959             RunBreak(XFA_Element::Overflow, XFA_ATTRIBUTEENUM_ContentArea, |   960           RunBreak(XFA_Element::Overflow, XFA_ATTRIBUTEENUM_PageArea, pTarget, | 
|   960                      pTarget, TRUE); |   961                    TRUE); | 
|   961             break; |   962           break; | 
|   962           default: |   963         case XFA_Element::ContentArea: | 
|   963             break; |   964           RunBreak(XFA_Element::Overflow, XFA_ATTRIBUTEENUM_ContentArea, | 
|   964         } |   965                    pTarget, TRUE); | 
 |   966           break; | 
 |   967         default: | 
 |   968           break; | 
|   965       } |   969       } | 
|   966     } |   970     } | 
|   967     if (!bCreatePage) { |  | 
|   968       pLeaderTemplate = ResolveBreakTarget(pContainer, TRUE, wsOverflowLeader); |  | 
|   969       pTrailerTemplate = |  | 
|   970           ResolveBreakTarget(pContainer, TRUE, wsOverflowTrailer); |  | 
|   971     } |  | 
|   972     return pOverflowNode; |  | 
|   973   } |   971   } | 
|   974   return nullptr; |   972   if (!bCreatePage) { | 
 |   973     pLeaderTemplate = ResolveBreakTarget(pContainer, TRUE, wsOverflowLeader); | 
 |   974     pTrailerTemplate = ResolveBreakTarget(pContainer, TRUE, wsOverflowTrailer); | 
 |   975   } | 
 |   976   return pOverflowNode; | 
|   975 } |   977 } | 
|   976  |   978  | 
|   977 FX_BOOL CXFA_LayoutPageMgr::ProcessOverflow(CXFA_Node* pFormNode, |   979 FX_BOOL CXFA_LayoutPageMgr::ProcessOverflow(CXFA_Node* pFormNode, | 
|   978                                             CXFA_Node*& pLeaderNode, |   980                                             CXFA_Node*& pLeaderNode, | 
|   979                                             CXFA_Node*& pTrailerNode, |   981                                             CXFA_Node*& pTrailerNode, | 
|   980                                             FX_BOOL bDataMerge, |   982                                             FX_BOOL bDataMerge, | 
|   981                                             FX_BOOL bCreatePage) { |   983                                             FX_BOOL bCreatePage) { | 
|   982   if (pFormNode == NULL) { |   984   if (!pFormNode) { | 
|   983     return FALSE; |   985     return FALSE; | 
|   984   } |   986   } | 
|   985   CXFA_Node *pLeaderTemplate = NULL, *pTrailerTemplate = NULL; |   987   CXFA_Node* pLeaderTemplate = nullptr; | 
 |   988   CXFA_Node* pTrailerTemplate = nullptr; | 
|   986   FX_BOOL bIsOverflowNode = FALSE; |   989   FX_BOOL bIsOverflowNode = FALSE; | 
|   987   if (pFormNode->GetElementType() == XFA_Element::Overflow || |   990   if (pFormNode->GetElementType() == XFA_Element::Overflow || | 
|   988       pFormNode->GetElementType() == XFA_Element::Break) { |   991       pFormNode->GetElementType() == XFA_Element::Break) { | 
|   989     bIsOverflowNode = TRUE; |   992     bIsOverflowNode = TRUE; | 
|   990   } |   993   } | 
|   991   for (CXFA_Node* pCurNode = |   994   for (CXFA_Node* pCurNode = | 
|   992            bIsOverflowNode ? pFormNode |   995            bIsOverflowNode ? pFormNode | 
|   993                            : pFormNode->GetNodeItem(XFA_NODEITEM_FirstChild); |   996                            : pFormNode->GetNodeItem(XFA_NODEITEM_FirstChild); | 
|   994        pCurNode; pCurNode = pCurNode->GetNodeItem((XFA_NODEITEM_NextSibling))) { |   997        pCurNode; pCurNode = pCurNode->GetNodeItem((XFA_NODEITEM_NextSibling))) { | 
|   995     if (BreakOverflow(pCurNode, pLeaderTemplate, pTrailerTemplate, |   998     if (BreakOverflow(pCurNode, pLeaderTemplate, pTrailerTemplate, | 
|   996                       bCreatePage)) { |   999                       bCreatePage)) { | 
|   997       if (bIsOverflowNode) { |  1000       if (bIsOverflowNode) { | 
|   998         pFormNode = pCurNode->GetNodeItem(XFA_NODEITEM_Parent); |  1001         pFormNode = pCurNode->GetNodeItem(XFA_NODEITEM_Parent); | 
|   999       } |  1002       } | 
|  1000       CXFA_Document* pDocument = pCurNode->GetDocument(); |  1003       CXFA_Document* pDocument = pCurNode->GetDocument(); | 
|  1001       CXFA_Node* pDataScope = NULL; |  1004       CXFA_Node* pDataScope = nullptr; | 
|  1002       if (pLeaderTemplate) { |  1005       if (pLeaderTemplate) { | 
|  1003         if (!pDataScope) { |  1006         if (!pDataScope) { | 
|  1004           pDataScope = XFA_DataMerge_FindDataScope(pFormNode); |  1007           pDataScope = XFA_DataMerge_FindDataScope(pFormNode); | 
|  1005         } |  1008         } | 
|  1006         pLeaderNode = pDocument->DataMerge_CopyContainer( |  1009         pLeaderNode = pDocument->DataMerge_CopyContainer( | 
|  1007             pLeaderTemplate, pFormNode, pDataScope, TRUE); |  1010             pLeaderTemplate, pFormNode, pDataScope, TRUE); | 
|  1008         pDocument->DataMerge_UpdateBindingRelations(pLeaderNode); |  1011         pDocument->DataMerge_UpdateBindingRelations(pLeaderNode); | 
|  1009         SetLayoutGeneratedNodeFlag(pLeaderNode); |  1012         SetLayoutGeneratedNodeFlag(pLeaderNode); | 
|  1010       } |  1013       } | 
|  1011       if (pTrailerTemplate) { |  1014       if (pTrailerTemplate) { | 
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1054   } |  1057   } | 
|  1055   return FALSE; |  1058   return FALSE; | 
|  1056 } |  1059 } | 
|  1057 FX_BOOL CXFA_LayoutPageMgr::FindPageAreaFromPageSet( |  1060 FX_BOOL CXFA_LayoutPageMgr::FindPageAreaFromPageSet( | 
|  1058     CXFA_Node* pPageSet, |  1061     CXFA_Node* pPageSet, | 
|  1059     CXFA_Node* pStartChild, |  1062     CXFA_Node* pStartChild, | 
|  1060     CXFA_Node* pTargetPageArea, |  1063     CXFA_Node* pTargetPageArea, | 
|  1061     CXFA_Node* pTargetContentArea, |  1064     CXFA_Node* pTargetContentArea, | 
|  1062     FX_BOOL bNewPage, |  1065     FX_BOOL bNewPage, | 
|  1063     FX_BOOL bQuery) { |  1066     FX_BOOL bQuery) { | 
|  1064   if (pPageSet == NULL && pStartChild == NULL) { |  1067   if (!pPageSet && !pStartChild) { | 
|  1065     return FALSE; |  1068     return FALSE; | 
|  1066   } |  1069   } | 
|  1067   if (IsPageSetRootOrderedOccurrence()) { |  1070   if (IsPageSetRootOrderedOccurrence()) { | 
|  1068     return FindPageAreaFromPageSet_Ordered(pPageSet, pStartChild, |  1071     return FindPageAreaFromPageSet_Ordered(pPageSet, pStartChild, | 
|  1069                                            pTargetPageArea, pTargetContentArea, |  1072                                            pTargetPageArea, pTargetContentArea, | 
|  1070                                            bNewPage, bQuery); |  1073                                            bNewPage, bQuery); | 
|  1071   } |  1074   } | 
|  1072   XFA_ATTRIBUTEENUM ePreferredPosition = m_pCurrentContainerRecord |  1075   XFA_ATTRIBUTEENUM ePreferredPosition = m_pCurrentContainerRecord | 
|  1073                                              ? XFA_ATTRIBUTEENUM_Rest |  1076                                              ? XFA_ATTRIBUTEENUM_Rest | 
|  1074                                              : XFA_ATTRIBUTEENUM_First; |  1077                                              : XFA_ATTRIBUTEENUM_First; | 
| (...skipping 20 matching lines...) Expand all  Loading... | 
|  1095       return FALSE; |  1098       return FALSE; | 
|  1096     } |  1099     } | 
|  1097   } |  1100   } | 
|  1098   FX_BOOL bRes = FALSE; |  1101   FX_BOOL bRes = FALSE; | 
|  1099   CXFA_Node* pCurrentNode = |  1102   CXFA_Node* pCurrentNode = | 
|  1100       pStartChild ? pStartChild->GetNodeItem(XFA_NODEITEM_NextSibling) |  1103       pStartChild ? pStartChild->GetNodeItem(XFA_NODEITEM_NextSibling) | 
|  1101                   : pPageSet->GetNodeItem(XFA_NODEITEM_FirstChild); |  1104                   : pPageSet->GetNodeItem(XFA_NODEITEM_FirstChild); | 
|  1102   for (; pCurrentNode; |  1105   for (; pCurrentNode; | 
|  1103        pCurrentNode = pCurrentNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { |  1106        pCurrentNode = pCurrentNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { | 
|  1104     if (pCurrentNode->GetElementType() == XFA_Element::PageArea) { |  1107     if (pCurrentNode->GetElementType() == XFA_Element::PageArea) { | 
|  1105       if ((pTargetPageArea == pCurrentNode || pTargetPageArea == NULL)) { |  1108       if ((pTargetPageArea == pCurrentNode || !pTargetPageArea)) { | 
|  1106         if (pCurrentNode->GetFirstChildByClass(XFA_Element::ContentArea) == |  1109         if (!pCurrentNode->GetFirstChildByClass(XFA_Element::ContentArea)) { | 
|  1107             NULL) { |  | 
|  1108           if (pTargetPageArea == pCurrentNode) { |  1110           if (pTargetPageArea == pCurrentNode) { | 
|  1109             CreateMinPageRecord(pCurrentNode, TRUE); |  1111             CreateMinPageRecord(pCurrentNode, TRUE); | 
|  1110             pTargetPageArea = NULL; |  1112             pTargetPageArea = nullptr; | 
|  1111           } |  1113           } | 
|  1112           continue; |  1114           continue; | 
|  1113         } |  1115         } | 
|  1114         if (!bQuery) { |  1116         if (!bQuery) { | 
|  1115           CXFA_ContainerRecord* pNewRecord = |  1117           CXFA_ContainerRecord* pNewRecord = | 
|  1116               CreateContainerRecord(pCurrentNode, pStartChild == NULL); |  1118               CreateContainerRecord(pCurrentNode, !pStartChild); | 
|  1117           AddPageAreaLayoutItem(pNewRecord, pCurrentNode); |  1119           AddPageAreaLayoutItem(pNewRecord, pCurrentNode); | 
|  1118           if (pTargetContentArea == NULL) { |  1120           if (!pTargetContentArea) { | 
|  1119             pTargetContentArea = |  1121             pTargetContentArea = | 
|  1120                 pCurrentNode->GetFirstChildByClass(XFA_Element::ContentArea); |  1122                 pCurrentNode->GetFirstChildByClass(XFA_Element::ContentArea); | 
|  1121           } |  1123           } | 
|  1122           AddContentAreaLayoutItem(pNewRecord, pTargetContentArea); |  1124           AddContentAreaLayoutItem(pNewRecord, pTargetContentArea); | 
|  1123         } |  1125         } | 
|  1124         m_pCurPageArea = pCurrentNode; |  1126         m_pCurPageArea = pCurrentNode; | 
|  1125         m_nCurPageCount = 1; |  1127         m_nCurPageCount = 1; | 
|  1126         bRes = TRUE; |  1128         bRes = TRUE; | 
|  1127         break; |  1129         break; | 
|  1128       } |  1130       } | 
|  1129       if (!bQuery) { |  1131       if (!bQuery) { | 
|  1130         CreateMinPageRecord(pCurrentNode, FALSE); |  1132         CreateMinPageRecord(pCurrentNode, FALSE); | 
|  1131       } |  1133       } | 
|  1132     } else if (pCurrentNode->GetElementType() == XFA_Element::PageSet) { |  1134     } else if (pCurrentNode->GetElementType() == XFA_Element::PageSet) { | 
|  1133       if (FindPageAreaFromPageSet_Ordered(pCurrentNode, NULL, pTargetPageArea, |  1135       if (FindPageAreaFromPageSet_Ordered(pCurrentNode, nullptr, | 
|  1134                                           pTargetContentArea, bNewPage, |  1136                                           pTargetPageArea, pTargetContentArea, | 
|  1135                                           bQuery)) { |  1137                                           bNewPage, bQuery)) { | 
|  1136         bRes = TRUE; |  1138         bRes = TRUE; | 
|  1137         break; |  1139         break; | 
|  1138       } |  1140       } | 
|  1139       if (!bQuery) { |  1141       if (!bQuery) { | 
|  1140         CreateMinPageSetRecord(pCurrentNode, TRUE); |  1142         CreateMinPageSetRecord(pCurrentNode, TRUE); | 
|  1141       } |  1143       } | 
|  1142     } |  1144     } | 
|  1143   } |  1145   } | 
|  1144   if (!pStartChild && bRes && !bQuery) { |  1146   if (!pStartChild && bRes && !bQuery) { | 
|  1145     m_pPageSetMap.SetAt(pPageSet, ++iPageSetCount); |  1147     m_pPageSetMap.SetAt(pPageSet, ++iPageSetCount); | 
|  1146   } |  1148   } | 
|  1147   return bRes; |  1149   return bRes; | 
|  1148 } |  1150 } | 
|  1149 FX_BOOL CXFA_LayoutPageMgr::FindPageAreaFromPageSet_SimplexDuplex( |  1151 FX_BOOL CXFA_LayoutPageMgr::FindPageAreaFromPageSet_SimplexDuplex( | 
|  1150     CXFA_Node* pPageSet, |  1152     CXFA_Node* pPageSet, | 
|  1151     CXFA_Node* pStartChild, |  1153     CXFA_Node* pStartChild, | 
|  1152     CXFA_Node* pTargetPageArea, |  1154     CXFA_Node* pTargetPageArea, | 
|  1153     CXFA_Node* pTargetContentArea, |  1155     CXFA_Node* pTargetContentArea, | 
|  1154     FX_BOOL bNewPage, |  1156     FX_BOOL bNewPage, | 
|  1155     FX_BOOL bQuery, |  1157     FX_BOOL bQuery, | 
|  1156     XFA_ATTRIBUTEENUM ePreferredPosition) { |  1158     XFA_ATTRIBUTEENUM ePreferredPosition) { | 
|  1157   const XFA_ATTRIBUTEENUM eFallbackPosition = XFA_ATTRIBUTEENUM_Any; |  1159   const XFA_ATTRIBUTEENUM eFallbackPosition = XFA_ATTRIBUTEENUM_Any; | 
|  1158   CXFA_Node *pPreferredPageArea = NULL, *pFallbackPageArea = NULL; |  1160   CXFA_Node* pPreferredPageArea = nullptr; | 
|  1159   CXFA_Node* pCurrentNode = NULL; |  1161   CXFA_Node* pFallbackPageArea = nullptr; | 
 |  1162   CXFA_Node* pCurrentNode = nullptr; | 
|  1160   if (!pStartChild || pStartChild->GetElementType() == XFA_Element::PageArea) { |  1163   if (!pStartChild || pStartChild->GetElementType() == XFA_Element::PageArea) { | 
|  1161     pCurrentNode = pPageSet->GetNodeItem(XFA_NODEITEM_FirstChild); |  1164     pCurrentNode = pPageSet->GetNodeItem(XFA_NODEITEM_FirstChild); | 
|  1162   } else { |  1165   } else { | 
|  1163     pCurrentNode = pStartChild->GetNodeItem(XFA_NODEITEM_NextSibling); |  1166     pCurrentNode = pStartChild->GetNodeItem(XFA_NODEITEM_NextSibling); | 
|  1164   } |  1167   } | 
|  1165   for (; pCurrentNode; |  1168   for (; pCurrentNode; | 
|  1166        pCurrentNode = pCurrentNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { |  1169        pCurrentNode = pCurrentNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { | 
|  1167     if (pCurrentNode->GetElementType() == XFA_Element::PageArea) { |  1170     if (pCurrentNode->GetElementType() == XFA_Element::PageArea) { | 
|  1168       if (!MatchPageAreaOddOrEven(pCurrentNode, FALSE)) { |  1171       if (!MatchPageAreaOddOrEven(pCurrentNode, FALSE)) { | 
|  1169         continue; |  1172         continue; | 
| (...skipping 21 matching lines...) Expand all  Loading... | 
|  1191           continue; |  1194           continue; | 
|  1192         } |  1195         } | 
|  1193         if (m_ePageSetMode != XFA_ATTRIBUTEENUM_DuplexPaginated || |  1196         if (m_ePageSetMode != XFA_ATTRIBUTEENUM_DuplexPaginated || | 
|  1194             pCurrentNode->GetEnum(XFA_ATTRIBUTE_OddOrEven) == |  1197             pCurrentNode->GetEnum(XFA_ATTRIBUTE_OddOrEven) == | 
|  1195                 XFA_ATTRIBUTEENUM_Any) { |  1198                 XFA_ATTRIBUTEENUM_Any) { | 
|  1196           pPreferredPageArea = pCurrentNode; |  1199           pPreferredPageArea = pCurrentNode; | 
|  1197           break; |  1200           break; | 
|  1198         } |  1201         } | 
|  1199         return FALSE; |  1202         return FALSE; | 
|  1200       } |  1203       } | 
|  1201       if ((pTargetPageArea == pCurrentNode || pTargetPageArea == NULL)) { |  1204       if ((pTargetPageArea == pCurrentNode || !pTargetPageArea)) { | 
|  1202         if (pCurrentNode->GetFirstChildByClass(XFA_Element::ContentArea) == |  1205         if (!pCurrentNode->GetFirstChildByClass(XFA_Element::ContentArea)) { | 
|  1203             NULL) { |  | 
|  1204           if (pTargetPageArea == pCurrentNode) { |  1206           if (pTargetPageArea == pCurrentNode) { | 
|  1205             CXFA_ContainerRecord* pNewRecord = CreateContainerRecord(); |  1207             CXFA_ContainerRecord* pNewRecord = CreateContainerRecord(); | 
|  1206             AddPageAreaLayoutItem(pNewRecord, pCurrentNode); |  1208             AddPageAreaLayoutItem(pNewRecord, pCurrentNode); | 
|  1207             pTargetPageArea = NULL; |  1209             pTargetPageArea = nullptr; | 
|  1208           } |  1210           } | 
|  1209           continue; |  1211           continue; | 
|  1210         } |  1212         } | 
|  1211         if ((ePreferredPosition == XFA_ATTRIBUTEENUM_Rest && |  1213         if ((ePreferredPosition == XFA_ATTRIBUTEENUM_Rest && | 
|  1212              eCurPagePosition == XFA_ATTRIBUTEENUM_Any) || |  1214              eCurPagePosition == XFA_ATTRIBUTEENUM_Any) || | 
|  1213             eCurPagePosition == ePreferredPosition) { |  1215             eCurPagePosition == ePreferredPosition) { | 
|  1214           pPreferredPageArea = pCurrentNode; |  1216           pPreferredPageArea = pCurrentNode; | 
|  1215           break; |  1217           break; | 
|  1216         } else if (eCurPagePosition == eFallbackPosition && |  1218         } else if (eCurPagePosition == eFallbackPosition && | 
|  1217                    !pFallbackPageArea) { |  1219                    !pFallbackPageArea) { | 
|  1218           pFallbackPageArea = pCurrentNode; |  1220           pFallbackPageArea = pCurrentNode; | 
|  1219         } |  1221         } | 
|  1220       } else if (pTargetPageArea && |  1222       } else if (pTargetPageArea && | 
|  1221                  !MatchPageAreaOddOrEven(pTargetPageArea, FALSE)) { |  1223                  !MatchPageAreaOddOrEven(pTargetPageArea, FALSE)) { | 
|  1222         CXFA_ContainerRecord* pNewRecord = CreateContainerRecord(); |  1224         CXFA_ContainerRecord* pNewRecord = CreateContainerRecord(); | 
|  1223         AddPageAreaLayoutItem(pNewRecord, pCurrentNode); |  1225         AddPageAreaLayoutItem(pNewRecord, pCurrentNode); | 
|  1224         AddContentAreaLayoutItem(pNewRecord, pCurrentNode->GetFirstChildByClass( |  1226         AddContentAreaLayoutItem(pNewRecord, pCurrentNode->GetFirstChildByClass( | 
|  1225                                                  XFA_Element::ContentArea)); |  1227                                                  XFA_Element::ContentArea)); | 
|  1226       } |  1228       } | 
|  1227     } else if (pCurrentNode->GetElementType() == XFA_Element::PageSet) { |  1229     } else if (pCurrentNode->GetElementType() == XFA_Element::PageSet) { | 
|  1228       if (FindPageAreaFromPageSet_SimplexDuplex( |  1230       if (FindPageAreaFromPageSet_SimplexDuplex( | 
|  1229               pCurrentNode, NULL, pTargetPageArea, pTargetContentArea, bNewPage, |  1231               pCurrentNode, nullptr, pTargetPageArea, pTargetContentArea, | 
|  1230               bQuery, ePreferredPosition)) { |  1232               bNewPage, bQuery, ePreferredPosition)) { | 
|  1231         break; |  1233         break; | 
|  1232       } |  1234       } | 
|  1233     } |  1235     } | 
|  1234   } |  1236   } | 
|  1235   CXFA_Node* pCurPageArea = NULL; |  1237   CXFA_Node* pCurPageArea = nullptr; | 
|  1236   if (pPreferredPageArea) { |  1238   if (pPreferredPageArea) { | 
|  1237     pCurPageArea = pPreferredPageArea; |  1239     pCurPageArea = pPreferredPageArea; | 
|  1238   } else if (pFallbackPageArea) { |  1240   } else if (pFallbackPageArea) { | 
|  1239     pCurPageArea = pFallbackPageArea; |  1241     pCurPageArea = pFallbackPageArea; | 
|  1240   } |  1242   } | 
|  1241   if (!pCurPageArea) { |  1243   if (!pCurPageArea) { | 
|  1242     return FALSE; |  1244     return FALSE; | 
|  1243   } |  1245   } | 
|  1244   if (!bQuery) { |  1246   if (!bQuery) { | 
|  1245     CXFA_ContainerRecord* pNewRecord = CreateContainerRecord(); |  1247     CXFA_ContainerRecord* pNewRecord = CreateContainerRecord(); | 
|  1246     AddPageAreaLayoutItem(pNewRecord, pCurPageArea); |  1248     AddPageAreaLayoutItem(pNewRecord, pCurPageArea); | 
|  1247     if (pTargetContentArea == NULL) { |  1249     if (!pTargetContentArea) { | 
|  1248       pTargetContentArea = |  1250       pTargetContentArea = | 
|  1249           pCurPageArea->GetFirstChildByClass(XFA_Element::ContentArea); |  1251           pCurPageArea->GetFirstChildByClass(XFA_Element::ContentArea); | 
|  1250     } |  1252     } | 
|  1251     AddContentAreaLayoutItem(pNewRecord, pTargetContentArea); |  1253     AddContentAreaLayoutItem(pNewRecord, pTargetContentArea); | 
|  1252   } |  1254   } | 
|  1253   m_pCurPageArea = pCurPageArea; |  1255   m_pCurPageArea = pCurPageArea; | 
|  1254   return TRUE; |  1256   return TRUE; | 
|  1255 } |  1257 } | 
|  1256 FX_BOOL CXFA_LayoutPageMgr::MatchPageAreaOddOrEven(CXFA_Node* pPageArea, |  1258 FX_BOOL CXFA_LayoutPageMgr::MatchPageAreaOddOrEven(CXFA_Node* pPageArea, | 
|  1257                                                    FX_BOOL bLastMatch) { |  1259                                                    FX_BOOL bLastMatch) { | 
| (...skipping 11 matching lines...) Expand all  Loading... | 
|  1269     return eOddOrEven == XFA_ATTRIBUTEENUM_Odd ? iPageCount % 2 == 0 |  1271     return eOddOrEven == XFA_ATTRIBUTEENUM_Odd ? iPageCount % 2 == 0 | 
|  1270                                                : iPageCount % 2 == 1; |  1272                                                : iPageCount % 2 == 1; | 
|  1271   } |  1273   } | 
|  1272   return TRUE; |  1274   return TRUE; | 
|  1273 } |  1275 } | 
|  1274 CXFA_Node* CXFA_LayoutPageMgr::GetNextAvailPageArea( |  1276 CXFA_Node* CXFA_LayoutPageMgr::GetNextAvailPageArea( | 
|  1275     CXFA_Node* pTargetPageArea, |  1277     CXFA_Node* pTargetPageArea, | 
|  1276     CXFA_Node* pTargetContentArea, |  1278     CXFA_Node* pTargetContentArea, | 
|  1277     FX_BOOL bNewPage, |  1279     FX_BOOL bNewPage, | 
|  1278     FX_BOOL bQuery) { |  1280     FX_BOOL bQuery) { | 
|  1279   if (m_pCurPageArea == NULL) { |  1281   if (!m_pCurPageArea) { | 
|  1280     FindPageAreaFromPageSet(m_pTemplatePageSetRoot, NULL, pTargetPageArea, |  1282     FindPageAreaFromPageSet(m_pTemplatePageSetRoot, nullptr, pTargetPageArea, | 
|  1281                             pTargetContentArea, bNewPage, bQuery); |  1283                             pTargetContentArea, bNewPage, bQuery); | 
|  1282     ASSERT(m_pCurPageArea); |  1284     ASSERT(m_pCurPageArea); | 
|  1283     return m_pCurPageArea; |  1285     return m_pCurPageArea; | 
|  1284   } |  1286   } | 
|  1285   if (pTargetPageArea == NULL || pTargetPageArea == m_pCurPageArea) { |  1287   if (!pTargetPageArea || pTargetPageArea == m_pCurPageArea) { | 
|  1286     if (!bNewPage && GetNextContentArea(pTargetContentArea)) { |  1288     if (!bNewPage && GetNextContentArea(pTargetContentArea)) { | 
|  1287       return m_pCurPageArea; |  1289       return m_pCurPageArea; | 
|  1288     } |  1290     } | 
|  1289     if (IsPageSetRootOrderedOccurrence()) { |  1291     if (IsPageSetRootOrderedOccurrence()) { | 
|  1290       int32_t iMax = -1; |  1292       int32_t iMax = -1; | 
|  1291       CXFA_Node* pOccurNode = |  1293       CXFA_Node* pOccurNode = | 
|  1292           m_pCurPageArea->GetFirstChildByClass(XFA_Element::Occur); |  1294           m_pCurPageArea->GetFirstChildByClass(XFA_Element::Occur); | 
|  1293       if (pOccurNode) { |  1295       if (pOccurNode) { | 
|  1294         pOccurNode->TryInteger(XFA_ATTRIBUTE_Max, iMax, FALSE); |  1296         pOccurNode->TryInteger(XFA_ATTRIBUTE_Max, iMax, FALSE); | 
|  1295       } |  1297       } | 
|  1296       if ((iMax < 0 || m_nCurPageCount < iMax)) { |  1298       if ((iMax < 0 || m_nCurPageCount < iMax)) { | 
|  1297         if (!bQuery) { |  1299         if (!bQuery) { | 
|  1298           CXFA_ContainerRecord* pNewRecord = |  1300           CXFA_ContainerRecord* pNewRecord = | 
|  1299               CreateContainerRecord(m_pCurPageArea); |  1301               CreateContainerRecord(m_pCurPageArea); | 
|  1300           AddPageAreaLayoutItem(pNewRecord, m_pCurPageArea); |  1302           AddPageAreaLayoutItem(pNewRecord, m_pCurPageArea); | 
|  1301           if (pTargetContentArea == NULL) { |  1303           if (!pTargetContentArea) { | 
|  1302             pTargetContentArea = |  1304             pTargetContentArea = | 
|  1303                 m_pCurPageArea->GetFirstChildByClass(XFA_Element::ContentArea); |  1305                 m_pCurPageArea->GetFirstChildByClass(XFA_Element::ContentArea); | 
|  1304           } |  1306           } | 
|  1305           AddContentAreaLayoutItem(pNewRecord, pTargetContentArea); |  1307           AddContentAreaLayoutItem(pNewRecord, pTargetContentArea); | 
|  1306         } |  1308         } | 
|  1307         m_nCurPageCount++; |  1309         m_nCurPageCount++; | 
|  1308         return m_pCurPageArea; |  1310         return m_pCurPageArea; | 
|  1309       } |  1311       } | 
|  1310     } |  1312     } | 
|  1311   } |  1313   } | 
|  1312   if (!bQuery && IsPageSetRootOrderedOccurrence()) { |  1314   if (!bQuery && IsPageSetRootOrderedOccurrence()) { | 
|  1313     CreateMinPageRecord(m_pCurPageArea, FALSE, TRUE); |  1315     CreateMinPageRecord(m_pCurPageArea, FALSE, TRUE); | 
|  1314   } |  1316   } | 
|  1315   if (FindPageAreaFromPageSet(m_pCurPageArea->GetNodeItem(XFA_NODEITEM_Parent), |  1317   if (FindPageAreaFromPageSet(m_pCurPageArea->GetNodeItem(XFA_NODEITEM_Parent), | 
|  1316                               m_pCurPageArea, pTargetPageArea, |  1318                               m_pCurPageArea, pTargetPageArea, | 
|  1317                               pTargetContentArea, bNewPage, bQuery)) { |  1319                               pTargetContentArea, bNewPage, bQuery)) { | 
|  1318     return m_pCurPageArea; |  1320     return m_pCurPageArea; | 
|  1319   } |  1321   } | 
|  1320   CXFA_Node* pPageSet = m_pCurPageArea->GetNodeItem(XFA_NODEITEM_Parent); |  1322   CXFA_Node* pPageSet = m_pCurPageArea->GetNodeItem(XFA_NODEITEM_Parent); | 
|  1321   while (TRUE) { |  1323   while (TRUE) { | 
|  1322     if (FindPageAreaFromPageSet(pPageSet, NULL, pTargetPageArea, |  1324     if (FindPageAreaFromPageSet(pPageSet, nullptr, pTargetPageArea, | 
|  1323                                 pTargetContentArea, bNewPage, bQuery)) { |  1325                                 pTargetContentArea, bNewPage, bQuery)) { | 
|  1324       return m_pCurPageArea; |  1326       return m_pCurPageArea; | 
|  1325     } |  1327     } | 
|  1326     if (!bQuery && IsPageSetRootOrderedOccurrence()) { |  1328     if (!bQuery && IsPageSetRootOrderedOccurrence()) { | 
|  1327       CreateMinPageSetRecord(pPageSet); |  1329       CreateMinPageSetRecord(pPageSet); | 
|  1328     } |  1330     } | 
|  1329     if (FindPageAreaFromPageSet(NULL, pPageSet, pTargetPageArea, |  1331     if (FindPageAreaFromPageSet(nullptr, pPageSet, pTargetPageArea, | 
|  1330                                 pTargetContentArea, bNewPage, bQuery)) { |  1332                                 pTargetContentArea, bNewPage, bQuery)) { | 
|  1331       return m_pCurPageArea; |  1333       return m_pCurPageArea; | 
|  1332     } |  1334     } | 
|  1333     if (pPageSet == m_pTemplatePageSetRoot) { |  1335     if (pPageSet == m_pTemplatePageSetRoot) { | 
|  1334       break; |  1336       break; | 
|  1335     } |  1337     } | 
|  1336     pPageSet = pPageSet->GetNodeItem(XFA_NODEITEM_Parent); |  1338     pPageSet = pPageSet->GetNodeItem(XFA_NODEITEM_Parent); | 
|  1337   } |  1339   } | 
|  1338   return NULL; |  1340   return nullptr; | 
|  1339 } |  1341 } | 
|  1340  |  1342  | 
|  1341 FX_BOOL CXFA_LayoutPageMgr::GetNextContentArea(CXFA_Node* pContentArea) { |  1343 FX_BOOL CXFA_LayoutPageMgr::GetNextContentArea(CXFA_Node* pContentArea) { | 
|  1342   CXFA_Node* pCurContentNode = |  1344   CXFA_Node* pCurContentNode = | 
|  1343       GetCurrentContainerRecord()->pCurContentArea->m_pFormNode; |  1345       GetCurrentContainerRecord()->pCurContentArea->m_pFormNode; | 
|  1344   if (pContentArea == NULL) { |  1346   if (!pContentArea) { | 
|  1345     pContentArea = |  1347     pContentArea = | 
|  1346         pCurContentNode->GetNextSameClassSibling(XFA_Element::ContentArea); |  1348         pCurContentNode->GetNextSameClassSibling(XFA_Element::ContentArea); | 
|  1347     if (pContentArea == NULL) { |  1349     if (!pContentArea) { | 
|  1348       return FALSE; |  1350       return FALSE; | 
|  1349     } |  1351     } | 
|  1350   } else { |  1352   } else { | 
|  1351     if (pContentArea->GetNodeItem(XFA_NODEITEM_Parent) != m_pCurPageArea) { |  1353     if (pContentArea->GetNodeItem(XFA_NODEITEM_Parent) != m_pCurPageArea) { | 
|  1352       return FALSE; |  1354       return FALSE; | 
|  1353     } |  1355     } | 
|  1354     CXFA_ContainerLayoutItem* pContentAreaLayout = NULL; |  1356     CXFA_ContainerLayoutItem* pContentAreaLayout = nullptr; | 
|  1355     if (!CheckContentAreaNotUsed(GetCurrentContainerRecord()->pCurPageArea, |  1357     if (!CheckContentAreaNotUsed(GetCurrentContainerRecord()->pCurPageArea, | 
|  1356                                  pContentArea, pContentAreaLayout)) { |  1358                                  pContentArea, pContentAreaLayout)) { | 
|  1357       return FALSE; |  1359       return FALSE; | 
|  1358     } |  1360     } | 
|  1359     if (pContentAreaLayout) { |  1361     if (pContentAreaLayout) { | 
|  1360       if (pContentAreaLayout->m_pFormNode != pCurContentNode) { |  1362       if (pContentAreaLayout->m_pFormNode != pCurContentNode) { | 
|  1361         CXFA_ContainerRecord* pNewRecord = CreateContainerRecord(); |  1363         CXFA_ContainerRecord* pNewRecord = CreateContainerRecord(); | 
|  1362         pNewRecord->pCurContentArea = pContentAreaLayout; |  1364         pNewRecord->pCurContentArea = pContentAreaLayout; | 
|  1363         return TRUE; |  1365         return TRUE; | 
|  1364       } else { |  1366       } else { | 
| (...skipping 17 matching lines...) Expand all  Loading... | 
|  1382           pPageSetNode->GetEnum(XFA_ATTRIBUTE_Relation); |  1384           pPageSetNode->GetEnum(XFA_ATTRIBUTE_Relation); | 
|  1383       if (eRelation == XFA_ATTRIBUTEENUM_OrderedOccurrence) { |  1385       if (eRelation == XFA_ATTRIBUTEENUM_OrderedOccurrence) { | 
|  1384         m_pPageSetMap.SetAt(pPageSetNode, 0); |  1386         m_pPageSetMap.SetAt(pPageSetNode, 0); | 
|  1385       } |  1387       } | 
|  1386     } |  1388     } | 
|  1387   } |  1389   } | 
|  1388 } |  1390 } | 
|  1389 int32_t CXFA_LayoutPageMgr::CreateMinPageRecord(CXFA_Node* pPageArea, |  1391 int32_t CXFA_LayoutPageMgr::CreateMinPageRecord(CXFA_Node* pPageArea, | 
|  1390                                                 FX_BOOL bTargetPageArea, |  1392                                                 FX_BOOL bTargetPageArea, | 
|  1391                                                 FX_BOOL bCreateLast) { |  1393                                                 FX_BOOL bCreateLast) { | 
|  1392   if (pPageArea == NULL) { |  1394   if (!pPageArea) { | 
|  1393     return 0; |  1395     return 0; | 
|  1394   } |  1396   } | 
|  1395   CXFA_Node* pOccurNode = pPageArea->GetFirstChildByClass(XFA_Element::Occur); |  1397   CXFA_Node* pOccurNode = pPageArea->GetFirstChildByClass(XFA_Element::Occur); | 
|  1396   int32_t iMin = 0; |  1398   int32_t iMin = 0; | 
|  1397   if ((pOccurNode && pOccurNode->TryInteger(XFA_ATTRIBUTE_Min, iMin, FALSE)) || |  1399   if ((pOccurNode && pOccurNode->TryInteger(XFA_ATTRIBUTE_Min, iMin, FALSE)) || | 
|  1398       bTargetPageArea) { |  1400       bTargetPageArea) { | 
|  1399     CXFA_Node* pContentArea = |  1401     CXFA_Node* pContentArea = | 
|  1400         pPageArea->GetFirstChildByClass(XFA_Element::ContentArea); |  1402         pPageArea->GetFirstChildByClass(XFA_Element::ContentArea); | 
|  1401     if (iMin < 1 && bTargetPageArea && !pContentArea) { |  1403     if (iMin < 1 && bTargetPageArea && !pContentArea) { | 
|  1402       iMin = 1; |  1404       iMin = 1; | 
|  1403     } |  1405     } | 
|  1404     int32_t i = 0; |  1406     int32_t i = 0; | 
|  1405     if (bCreateLast) { |  1407     if (bCreateLast) { | 
|  1406       i = m_nCurPageCount; |  1408       i = m_nCurPageCount; | 
|  1407     } |  1409     } | 
|  1408     for (; i < iMin; i++) { |  1410     for (; i < iMin; i++) { | 
|  1409       CXFA_ContainerRecord* pNewRecord = CreateContainerRecord(); |  1411       CXFA_ContainerRecord* pNewRecord = CreateContainerRecord(); | 
|  1410       AddPageAreaLayoutItem(pNewRecord, pPageArea); |  1412       AddPageAreaLayoutItem(pNewRecord, pPageArea); | 
|  1411       AddContentAreaLayoutItem(pNewRecord, pContentArea); |  1413       AddContentAreaLayoutItem(pNewRecord, pContentArea); | 
|  1412     } |  1414     } | 
|  1413   } |  1415   } | 
|  1414   return iMin; |  1416   return iMin; | 
|  1415 } |  1417 } | 
|  1416 void CXFA_LayoutPageMgr::CreateMinPageSetRecord(CXFA_Node* pPageSet, |  1418 void CXFA_LayoutPageMgr::CreateMinPageSetRecord(CXFA_Node* pPageSet, | 
|  1417                                                 FX_BOOL bCreateAll) { |  1419                                                 FX_BOOL bCreateAll) { | 
|  1418   if (pPageSet == NULL) { |  1420   if (!pPageSet) { | 
|  1419     return; |  1421     return; | 
|  1420   } |  1422   } | 
|  1421   int32_t iCurSetCount = 0; |  1423   int32_t iCurSetCount = 0; | 
|  1422   if (!m_pPageSetMap.Lookup(pPageSet, iCurSetCount)) { |  1424   if (!m_pPageSetMap.Lookup(pPageSet, iCurSetCount)) { | 
|  1423     return; |  1425     return; | 
|  1424   } |  1426   } | 
|  1425   if (bCreateAll) { |  1427   if (bCreateAll) { | 
|  1426     iCurSetCount = 0; |  1428     iCurSetCount = 0; | 
|  1427   } |  1429   } | 
|  1428   CXFA_Node* pOccurNode = pPageSet->GetFirstChildByClass(XFA_Element::Occur); |  1430   CXFA_Node* pOccurNode = pPageSet->GetFirstChildByClass(XFA_Element::Occur); | 
| (...skipping 11 matching lines...) Expand all  Loading... | 
|  1440                      XFA_Element::PageSet) { |  1442                      XFA_Element::PageSet) { | 
|  1441             CreateMinPageSetRecord(pCurrentPageNode, TRUE); |  1443             CreateMinPageSetRecord(pCurrentPageNode, TRUE); | 
|  1442           } |  1444           } | 
|  1443         } |  1445         } | 
|  1444       } |  1446       } | 
|  1445       m_pPageSetMap.SetAt(pPageSet, iMin); |  1447       m_pPageSetMap.SetAt(pPageSet, iMin); | 
|  1446     } |  1448     } | 
|  1447   } |  1449   } | 
|  1448 } |  1450 } | 
|  1449 void CXFA_LayoutPageMgr::CreateNextMinRecord(CXFA_Node* pRecordNode) { |  1451 void CXFA_LayoutPageMgr::CreateNextMinRecord(CXFA_Node* pRecordNode) { | 
|  1450   if (pRecordNode == NULL) { |  1452   if (!pRecordNode) { | 
|  1451     return; |  1453     return; | 
|  1452   } |  1454   } | 
|  1453   for (CXFA_Node* pCurrentNode = |  1455   for (CXFA_Node* pCurrentNode = | 
|  1454            pRecordNode->GetNodeItem(XFA_NODEITEM_NextSibling); |  1456            pRecordNode->GetNodeItem(XFA_NODEITEM_NextSibling); | 
|  1455        pCurrentNode; |  1457        pCurrentNode; | 
|  1456        pCurrentNode = pCurrentNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { |  1458        pCurrentNode = pCurrentNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { | 
|  1457     if (pCurrentNode->GetElementType() == XFA_Element::PageArea) { |  1459     if (pCurrentNode->GetElementType() == XFA_Element::PageArea) { | 
|  1458       CreateMinPageRecord(pCurrentNode, FALSE); |  1460       CreateMinPageRecord(pCurrentNode, FALSE); | 
|  1459     } else if (pCurrentNode->GetElementType() == XFA_Element::PageSet) { |  1461     } else if (pCurrentNode->GetElementType() == XFA_Element::PageSet) { | 
|  1460       CreateMinPageSetRecord(pCurrentNode, TRUE); |  1462       CreateMinPageSetRecord(pCurrentNode, TRUE); | 
|  1461     } |  1463     } | 
|  1462   } |  1464   } | 
|  1463 } |  1465 } | 
|  1464 void CXFA_LayoutPageMgr::ProcessLastPageSet() { |  1466 void CXFA_LayoutPageMgr::ProcessLastPageSet() { | 
|  1465   CreateMinPageRecord(m_pCurPageArea, FALSE, TRUE); |  1467   CreateMinPageRecord(m_pCurPageArea, FALSE, TRUE); | 
|  1466   CreateNextMinRecord(m_pCurPageArea); |  1468   CreateNextMinRecord(m_pCurPageArea); | 
|  1467   CXFA_Node* pPageSet = m_pCurPageArea->GetNodeItem(XFA_NODEITEM_Parent); |  1469   CXFA_Node* pPageSet = m_pCurPageArea->GetNodeItem(XFA_NODEITEM_Parent); | 
|  1468   while (TRUE) { |  1470   while (TRUE) { | 
|  1469     CreateMinPageSetRecord(pPageSet); |  1471     CreateMinPageSetRecord(pPageSet); | 
|  1470     if (pPageSet == m_pTemplatePageSetRoot) { |  1472     if (pPageSet == m_pTemplatePageSetRoot) { | 
|  1471       break; |  1473       break; | 
|  1472     } |  1474     } | 
|  1473     CreateNextMinRecord(pPageSet); |  1475     CreateNextMinRecord(pPageSet); | 
|  1474     pPageSet = pPageSet->GetNodeItem(XFA_NODEITEM_Parent); |  1476     pPageSet = pPageSet->GetNodeItem(XFA_NODEITEM_Parent); | 
|  1475   } |  1477   } | 
|  1476 } |  1478 } | 
|  1477 FX_BOOL CXFA_LayoutPageMgr::GetNextAvailContentHeight(FX_FLOAT fChildHeight) { |  1479 FX_BOOL CXFA_LayoutPageMgr::GetNextAvailContentHeight(FX_FLOAT fChildHeight) { | 
|  1478   CXFA_Node* pCurContentNode = |  1480   CXFA_Node* pCurContentNode = | 
|  1479       GetCurrentContainerRecord()->pCurContentArea->m_pFormNode; |  1481       GetCurrentContainerRecord()->pCurContentArea->m_pFormNode; | 
|  1480   if (pCurContentNode == NULL) { |  1482   if (!pCurContentNode) { | 
|  1481     return FALSE; |  1483     return FALSE; | 
|  1482   } |  1484   } | 
|  1483   pCurContentNode = |  1485   pCurContentNode = | 
|  1484       pCurContentNode->GetNextSameClassSibling(XFA_Element::ContentArea); |  1486       pCurContentNode->GetNextSameClassSibling(XFA_Element::ContentArea); | 
|  1485   if (pCurContentNode) { |  1487   if (pCurContentNode) { | 
|  1486     FX_FLOAT fNextContentHeight = |  1488     FX_FLOAT fNextContentHeight = | 
|  1487         pCurContentNode->GetMeasure(XFA_ATTRIBUTE_H).ToUnit(XFA_UNIT_Pt); |  1489         pCurContentNode->GetMeasure(XFA_ATTRIBUTE_H).ToUnit(XFA_UNIT_Pt); | 
|  1488     return fNextContentHeight > fChildHeight; |  1490     return fNextContentHeight > fChildHeight; | 
|  1489   } |  1491   } | 
|  1490   CXFA_Node* pPageNode = GetCurrentContainerRecord()->pCurPageArea->m_pFormNode; |  1492   CXFA_Node* pPageNode = GetCurrentContainerRecord()->pCurPageArea->m_pFormNode; | 
|  1491   CXFA_Node* pOccurNode = pPageNode->GetFirstChildByClass(XFA_Element::Occur); |  1493   CXFA_Node* pOccurNode = pPageNode->GetFirstChildByClass(XFA_Element::Occur); | 
|  1492   int32_t iMax = 0; |  1494   int32_t iMax = 0; | 
|  1493   if (pOccurNode && pOccurNode->TryInteger(XFA_ATTRIBUTE_Max, iMax, FALSE)) { |  1495   if (pOccurNode && pOccurNode->TryInteger(XFA_ATTRIBUTE_Max, iMax, FALSE)) { | 
|  1494     if (m_nCurPageCount == iMax) { |  1496     if (m_nCurPageCount == iMax) { | 
|  1495       CXFA_Node* pSrcPage = m_pCurPageArea; |  1497       CXFA_Node* pSrcPage = m_pCurPageArea; | 
|  1496       int32_t nSrcPageCount = m_nCurPageCount; |  1498       int32_t nSrcPageCount = m_nCurPageCount; | 
|  1497       FX_POSITION psSrcRecord = m_rgProposedContainerRecord.GetTailPosition(); |  1499       FX_POSITION psSrcRecord = m_rgProposedContainerRecord.GetTailPosition(); | 
|  1498       CXFA_Node* pNextPage = GetNextAvailPageArea(NULL, NULL, FALSE, TRUE); |  1500       CXFA_Node* pNextPage = | 
 |  1501           GetNextAvailPageArea(nullptr, nullptr, FALSE, TRUE); | 
|  1499       m_pCurPageArea = pSrcPage; |  1502       m_pCurPageArea = pSrcPage; | 
|  1500       m_nCurPageCount = nSrcPageCount; |  1503       m_nCurPageCount = nSrcPageCount; | 
|  1501       CXFA_ContainerRecord* pPrevRecord = |  1504       CXFA_ContainerRecord* pPrevRecord = | 
|  1502           (CXFA_ContainerRecord*)m_rgProposedContainerRecord.GetNext( |  1505           (CXFA_ContainerRecord*)m_rgProposedContainerRecord.GetNext( | 
|  1503               psSrcRecord); |  1506               psSrcRecord); | 
|  1504       while (psSrcRecord) { |  1507       while (psSrcRecord) { | 
|  1505         FX_POSITION psSaveRecord = psSrcRecord; |  1508         FX_POSITION psSaveRecord = psSrcRecord; | 
|  1506         CXFA_ContainerRecord* pInsertRecord = |  1509         CXFA_ContainerRecord* pInsertRecord = | 
|  1507             (CXFA_ContainerRecord*)m_rgProposedContainerRecord.GetNext( |  1510             (CXFA_ContainerRecord*)m_rgProposedContainerRecord.GetNext( | 
|  1508                 psSrcRecord); |  1511                 psSrcRecord); | 
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1546   if (m_rgProposedContainerRecord.GetCount() > 0) { |  1549   if (m_rgProposedContainerRecord.GetCount() > 0) { | 
|  1547     FX_POSITION sPos; |  1550     FX_POSITION sPos; | 
|  1548     sPos = m_rgProposedContainerRecord.GetHeadPosition(); |  1551     sPos = m_rgProposedContainerRecord.GetHeadPosition(); | 
|  1549     while (sPos) { |  1552     while (sPos) { | 
|  1550       CXFA_ContainerRecord* pRecord = |  1553       CXFA_ContainerRecord* pRecord = | 
|  1551           (CXFA_ContainerRecord*)m_rgProposedContainerRecord.GetNext(sPos); |  1554           (CXFA_ContainerRecord*)m_rgProposedContainerRecord.GetNext(sPos); | 
|  1552       delete pRecord; |  1555       delete pRecord; | 
|  1553     } |  1556     } | 
|  1554     m_rgProposedContainerRecord.RemoveAll(); |  1557     m_rgProposedContainerRecord.RemoveAll(); | 
|  1555   } |  1558   } | 
|  1556   m_pCurrentContainerRecord = NULL; |  1559   m_pCurrentContainerRecord = nullptr; | 
|  1557   m_pCurPageArea = NULL; |  1560   m_pCurPageArea = nullptr; | 
|  1558   m_nCurPageCount = 0; |  1561   m_nCurPageCount = 0; | 
|  1559   m_bCreateOverFlowPage = FALSE; |  1562   m_bCreateOverFlowPage = FALSE; | 
|  1560   m_pPageSetMap.RemoveAll(); |  1563   m_pPageSetMap.RemoveAll(); | 
|  1561 } |  1564 } | 
|  1562 CXFA_LayoutItem* CXFA_LayoutPageMgr::FindOrCreateLayoutItem( |  1565 CXFA_LayoutItem* CXFA_LayoutPageMgr::FindOrCreateLayoutItem( | 
|  1563     CXFA_Node* pFormNode) { |  1566     CXFA_Node* pFormNode) { | 
|  1564   return pFormNode->GetDocument()->GetParser()->GetNotify()->OnCreateLayoutItem( |  1567   return pFormNode->GetDocument()->GetParser()->GetNotify()->OnCreateLayoutItem( | 
|  1565       pFormNode); |  1568       pFormNode); | 
|  1566 } |  1569 } | 
|  1567  |  1570  | 
| (...skipping 21 matching lines...) Expand all  Loading... | 
|  1589             sIterator(pCurLayoutItem->m_pFormNode); |  1592             sIterator(pCurLayoutItem->m_pFormNode); | 
|  1590         for (CXFA_Node* pNode = sIterator.GetCurrent(); pNode; |  1593         for (CXFA_Node* pNode = sIterator.GetCurrent(); pNode; | 
|  1591              pNode = sIterator.MoveToNext()) { |  1594              pNode = sIterator.MoveToNext()) { | 
|  1592           pNode->SetFlag(XFA_NodeFlag_UnusedNode, false); |  1595           pNode->SetFlag(XFA_NodeFlag_UnusedNode, false); | 
|  1593         } |  1596         } | 
|  1594       } |  1597       } | 
|  1595     } |  1598     } | 
|  1596     if (pCurLayoutItem->m_pFirstChild) { |  1599     if (pCurLayoutItem->m_pFirstChild) { | 
|  1597       SaveLayoutItem(pCurLayoutItem); |  1600       SaveLayoutItem(pCurLayoutItem); | 
|  1598     } |  1601     } | 
|  1599     pCurLayoutItem->m_pParent = NULL; |  1602     pCurLayoutItem->m_pParent = nullptr; | 
|  1600     pCurLayoutItem->m_pNextSibling = NULL; |  1603     pCurLayoutItem->m_pNextSibling = nullptr; | 
|  1601     pCurLayoutItem->m_pFirstChild = NULL; |  1604     pCurLayoutItem->m_pFirstChild = nullptr; | 
|  1602     if (!pCurLayoutItem->IsContentLayoutItem() && |  1605     if (!pCurLayoutItem->IsContentLayoutItem() && | 
|  1603         pCurLayoutItem->m_pFormNode->GetElementType() != |  1606         pCurLayoutItem->m_pFormNode->GetElementType() != | 
|  1604             XFA_Element::PageArea) { |  1607             XFA_Element::PageArea) { | 
|  1605       delete pCurLayoutItem; |  1608       delete pCurLayoutItem; | 
|  1606     } |  1609     } | 
|  1607     pCurLayoutItem = pNextLayoutItem; |  1610     pCurLayoutItem = pNextLayoutItem; | 
|  1608   } |  1611   } | 
|  1609 } |  1612 } | 
|  1610 CXFA_Node* CXFA_LayoutPageMgr::QueryOverflow( |  1613 CXFA_Node* CXFA_LayoutPageMgr::QueryOverflow( | 
|  1611     CXFA_Node* pFormNode, |  1614     CXFA_Node* pFormNode, | 
|  1612     CXFA_LayoutContext* pLayoutContext) { |  1615     CXFA_LayoutContext* pLayoutContext) { | 
|  1613   for (CXFA_Node* pCurNode = pFormNode->GetNodeItem(XFA_NODEITEM_FirstChild); |  1616   for (CXFA_Node* pCurNode = pFormNode->GetNodeItem(XFA_NODEITEM_FirstChild); | 
|  1614        pCurNode; pCurNode = pCurNode->GetNodeItem((XFA_NODEITEM_NextSibling))) { |  1617        pCurNode; pCurNode = pCurNode->GetNodeItem((XFA_NODEITEM_NextSibling))) { | 
|  1615     if (pCurNode->GetElementType() == XFA_Element::Break) { |  1618     if (pCurNode->GetElementType() == XFA_Element::Break) { | 
|  1616       CFX_WideStringC wsOverflowLeader; |  1619       CFX_WideStringC wsOverflowLeader; | 
|  1617       CFX_WideStringC wsOverflowTarget; |  1620       CFX_WideStringC wsOverflowTarget; | 
|  1618       CFX_WideStringC wsOverflowTrailer; |  1621       CFX_WideStringC wsOverflowTrailer; | 
|  1619       pCurNode->TryCData(XFA_ATTRIBUTE_OverflowLeader, wsOverflowLeader); |  1622       pCurNode->TryCData(XFA_ATTRIBUTE_OverflowLeader, wsOverflowLeader); | 
|  1620       pCurNode->TryCData(XFA_ATTRIBUTE_OverflowTrailer, wsOverflowTrailer); |  1623       pCurNode->TryCData(XFA_ATTRIBUTE_OverflowTrailer, wsOverflowTrailer); | 
|  1621       pCurNode->TryCData(XFA_ATTRIBUTE_OverflowTarget, wsOverflowTarget); |  1624       pCurNode->TryCData(XFA_ATTRIBUTE_OverflowTarget, wsOverflowTarget); | 
|  1622       if (!wsOverflowLeader.IsEmpty() || !wsOverflowTrailer.IsEmpty() || |  1625       if (!wsOverflowLeader.IsEmpty() || !wsOverflowTrailer.IsEmpty() || | 
|  1623           !wsOverflowTarget.IsEmpty()) { |  1626           !wsOverflowTarget.IsEmpty()) { | 
|  1624         return pCurNode; |  1627         return pCurNode; | 
|  1625       } |  1628       } | 
|  1626       return NULL; |  1629       return nullptr; | 
|  1627     } else if (pCurNode->GetElementType() == XFA_Element::Overflow) { |  1630     } else if (pCurNode->GetElementType() == XFA_Element::Overflow) { | 
|  1628       return pCurNode; |  1631       return pCurNode; | 
|  1629     } |  1632     } | 
|  1630   } |  1633   } | 
|  1631   return NULL; |  1634   return nullptr; | 
|  1632 } |  1635 } | 
|  1633  |  1636  | 
|  1634 void CXFA_LayoutPageMgr::MergePageSetContents() { |  1637 void CXFA_LayoutPageMgr::MergePageSetContents() { | 
|  1635   CXFA_Document* pDocument = m_pTemplatePageSetRoot->GetDocument(); |  1638   CXFA_Document* pDocument = m_pTemplatePageSetRoot->GetDocument(); | 
|  1636   CXFA_FFNotify* pNotify = pDocument->GetParser()->GetNotify(); |  1639   CXFA_FFNotify* pNotify = pDocument->GetParser()->GetNotify(); | 
|  1637   CXFA_LayoutProcessor* pDocLayout = pDocument->GetDocLayout(); |  1640   CXFA_LayoutProcessor* pDocLayout = pDocument->GetDocLayout(); | 
|  1638   CXFA_ContainerLayoutItem* pRootLayout = GetRootLayoutItem(); |  1641   CXFA_ContainerLayoutItem* pRootLayout = GetRootLayoutItem(); | 
|  1639   { |  1642   { | 
|  1640     for (int32_t iIndex = 0; iIndex < pDocument->m_pPendingPageSet.GetSize(); |  1643     for (int32_t iIndex = 0; iIndex < pDocument->m_pPendingPageSet.GetSize(); | 
|  1641          iIndex++) { |  1644          iIndex++) { | 
|  1642       CXFA_NodeIteratorTemplate<CXFA_Node, CXFA_TraverseStrategy_XFANode> |  1645       CXFA_NodeIteratorTemplate<CXFA_Node, CXFA_TraverseStrategy_XFANode> | 
|  1643           sIterator(pDocument->m_pPendingPageSet.GetAt(iIndex)); |  1646           sIterator(pDocument->m_pPendingPageSet.GetAt(iIndex)); | 
|  1644       for (CXFA_Node* pNode = sIterator.GetCurrent(); pNode; |  1647       for (CXFA_Node* pNode = sIterator.GetCurrent(); pNode; | 
|  1645            pNode = sIterator.MoveToNext()) { |  1648            pNode = sIterator.MoveToNext()) { | 
|  1646         if (pNode->IsContainerNode()) { |  1649         if (pNode->IsContainerNode()) { | 
|  1647           CXFA_Node* pBindNode = pNode->GetBindData(); |  1650           CXFA_Node* pBindNode = pNode->GetBindData(); | 
|  1648           if (pBindNode) { |  1651           if (pBindNode) { | 
|  1649             pBindNode->RemoveBindItem(pNode); |  1652             pBindNode->RemoveBindItem(pNode); | 
|  1650             pNode->SetObject(XFA_ATTRIBUTE_BindingNode, NULL); |  1653             pNode->SetObject(XFA_ATTRIBUTE_BindingNode, nullptr); | 
|  1651           } |  1654           } | 
|  1652         } |  1655         } | 
|  1653         pNode->SetFlag(XFA_NodeFlag_UnusedNode, true); |  1656         pNode->SetFlag(XFA_NodeFlag_UnusedNode, true); | 
|  1654       } |  1657       } | 
|  1655     } |  1658     } | 
|  1656   } |  1659   } | 
|  1657   int32_t iIndex = 0; |  1660   int32_t iIndex = 0; | 
|  1658   for (; pRootLayout; |  1661   for (; pRootLayout; | 
|  1659        pRootLayout = (CXFA_ContainerLayoutItem*)pRootLayout->m_pNextSibling) { |  1662        pRootLayout = (CXFA_ContainerLayoutItem*)pRootLayout->m_pNextSibling) { | 
|  1660     CXFA_Node* pPendingPageSet = nullptr; |  1663     CXFA_Node* pPendingPageSet = nullptr; | 
| (...skipping 13 matching lines...) Expand all  Loading... | 
|  1674           XFA_XDPPACKET_Template) { |  1677           XFA_XDPPACKET_Template) { | 
|  1675         pPendingPageSet = |  1678         pPendingPageSet = | 
|  1676             pRootPageSetContainerItem->m_pFormNode->CloneTemplateToForm(FALSE); |  1679             pRootPageSetContainerItem->m_pFormNode->CloneTemplateToForm(FALSE); | 
|  1677       } else { |  1680       } else { | 
|  1678         pPendingPageSet = pRootPageSetContainerItem->m_pFormNode; |  1681         pPendingPageSet = pRootPageSetContainerItem->m_pFormNode; | 
|  1679       } |  1682       } | 
|  1680     } |  1683     } | 
|  1681     if (pRootPageSetContainerItem->m_pFormNode->GetUserData( |  1684     if (pRootPageSetContainerItem->m_pFormNode->GetUserData( | 
|  1682             XFA_LAYOUTITEMKEY) == pRootPageSetContainerItem) { |  1685             XFA_LAYOUTITEMKEY) == pRootPageSetContainerItem) { | 
|  1683       pRootPageSetContainerItem->m_pFormNode->SetUserData(XFA_LAYOUTITEMKEY, |  1686       pRootPageSetContainerItem->m_pFormNode->SetUserData(XFA_LAYOUTITEMKEY, | 
|  1684                                                           NULL); |  1687                                                           nullptr); | 
|  1685     } |  1688     } | 
|  1686     pRootPageSetContainerItem->m_pFormNode = pPendingPageSet; |  1689     pRootPageSetContainerItem->m_pFormNode = pPendingPageSet; | 
|  1687     pPendingPageSet->ClearFlag(XFA_NodeFlag_UnusedNode); |  1690     pPendingPageSet->ClearFlag(XFA_NodeFlag_UnusedNode); | 
|  1688     for (CXFA_ContainerLayoutItem* pContainerItem = iterator.MoveToNext(); |  1691     for (CXFA_ContainerLayoutItem* pContainerItem = iterator.MoveToNext(); | 
|  1689          pContainerItem; pContainerItem = iterator.MoveToNext()) { |  1692          pContainerItem; pContainerItem = iterator.MoveToNext()) { | 
|  1690       CXFA_Node* pNode = pContainerItem->m_pFormNode; |  1693       CXFA_Node* pNode = pContainerItem->m_pFormNode; | 
|  1691       if (pNode->GetPacketID() != XFA_XDPPACKET_Template) { |  1694       if (pNode->GetPacketID() != XFA_XDPPACKET_Template) { | 
|  1692         continue; |  1695         continue; | 
|  1693       } |  1696       } | 
|  1694       switch (pNode->GetElementType()) { |  1697       switch (pNode->GetElementType()) { | 
|  1695         case XFA_Element::PageSet: { |  1698         case XFA_Element::PageSet: { | 
|  1696           CXFA_Node* pParentNode = pContainerItem->m_pParent->m_pFormNode; |  1699           CXFA_Node* pParentNode = pContainerItem->m_pParent->m_pFormNode; | 
|  1697           pContainerItem->m_pFormNode = XFA_NodeMerge_CloneOrMergeContainer( |  1700           pContainerItem->m_pFormNode = XFA_NodeMerge_CloneOrMergeContainer( | 
|  1698               pDocument, pParentNode, pContainerItem->m_pFormNode, TRUE); |  1701               pDocument, pParentNode, pContainerItem->m_pFormNode, TRUE); | 
|  1699         } break; |  1702         } break; | 
|  1700         case XFA_Element::PageArea: { |  1703         case XFA_Element::PageArea: { | 
|  1701           CXFA_ContainerLayoutItem* pFormLayout = pContainerItem; |  1704           CXFA_ContainerLayoutItem* pFormLayout = pContainerItem; | 
|  1702           CXFA_Node* pParentNode = pContainerItem->m_pParent->m_pFormNode; |  1705           CXFA_Node* pParentNode = pContainerItem->m_pParent->m_pFormNode; | 
|  1703           FX_BOOL bIsExistForm = TRUE; |  1706           FX_BOOL bIsExistForm = TRUE; | 
|  1704           for (int32_t iLevel = 0; iLevel < 3; iLevel++) { |  1707           for (int32_t iLevel = 0; iLevel < 3; iLevel++) { | 
|  1705             pFormLayout = (CXFA_ContainerLayoutItem*)pFormLayout->m_pFirstChild; |  1708             pFormLayout = (CXFA_ContainerLayoutItem*)pFormLayout->m_pFirstChild; | 
|  1706             if (iLevel == 2) { |  1709             if (iLevel == 2) { | 
|  1707               while (pFormLayout && |  1710               while (pFormLayout && | 
|  1708                      !XFA_ItemLayoutProcessor_IsTakingSpace( |  1711                      !XFA_ItemLayoutProcessor_IsTakingSpace( | 
|  1709                          pFormLayout->m_pFormNode)) { |  1712                          pFormLayout->m_pFormNode)) { | 
|  1710                 pFormLayout = |  1713                 pFormLayout = | 
|  1711                     (CXFA_ContainerLayoutItem*)pFormLayout->m_pNextSibling; |  1714                     (CXFA_ContainerLayoutItem*)pFormLayout->m_pNextSibling; | 
|  1712               } |  1715               } | 
|  1713             } |  1716             } | 
|  1714             if (pFormLayout == NULL) { |  1717             if (!pFormLayout) { | 
|  1715               bIsExistForm = FALSE; |  1718               bIsExistForm = FALSE; | 
|  1716               break; |  1719               break; | 
|  1717             } |  1720             } | 
|  1718           } |  1721           } | 
|  1719           if (bIsExistForm) { |  1722           if (bIsExistForm) { | 
|  1720             CXFA_Node* pNewSubform = pFormLayout->m_pFormNode; |  1723             CXFA_Node* pNewSubform = pFormLayout->m_pFormNode; | 
|  1721             if (pContainerItem->m_pOldSubform && |  1724             if (pContainerItem->m_pOldSubform && | 
|  1722                 pContainerItem->m_pOldSubform != pNewSubform) { |  1725                 pContainerItem->m_pOldSubform != pNewSubform) { | 
|  1723               CXFA_Node* pExistingNode = XFA_DataMerge_FindFormDOMInstance( |  1726               CXFA_Node* pExistingNode = XFA_DataMerge_FindFormDOMInstance( | 
|  1724                   pDocument, pContainerItem->m_pFormNode->GetElementType(), |  1727                   pDocument, pContainerItem->m_pFormNode->GetElementType(), | 
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1896     m_PageArray.RemoveAt(i); |  1899     m_PageArray.RemoveAt(i); | 
|  1897     pNotify->OnPageEvent(pPage, XFA_PAGEVIEWEVENT_PostRemoved); |  1900     pNotify->OnPageEvent(pPage, XFA_PAGEVIEWEVENT_PostRemoved); | 
|  1898     delete pPage; |  1901     delete pPage; | 
|  1899   } |  1902   } | 
|  1900   ClearRecordList(); |  1903   ClearRecordList(); | 
|  1901 } |  1904 } | 
|  1902 void XFA_ReleaseLayoutItem_NoPageArea(CXFA_LayoutItem* pLayoutItem) { |  1905 void XFA_ReleaseLayoutItem_NoPageArea(CXFA_LayoutItem* pLayoutItem) { | 
|  1903   CXFA_LayoutItem *pNext, *pNode = pLayoutItem->m_pFirstChild; |  1906   CXFA_LayoutItem *pNext, *pNode = pLayoutItem->m_pFirstChild; | 
|  1904   while (pNode) { |  1907   while (pNode) { | 
|  1905     pNext = pNode->m_pNextSibling; |  1908     pNext = pNode->m_pNextSibling; | 
|  1906     pNode->m_pParent = NULL; |  1909     pNode->m_pParent = nullptr; | 
|  1907     XFA_ReleaseLayoutItem_NoPageArea(pNode); |  1910     XFA_ReleaseLayoutItem_NoPageArea(pNode); | 
|  1908     pNode = pNext; |  1911     pNode = pNext; | 
|  1909   } |  1912   } | 
|  1910   if (pLayoutItem->m_pFormNode->GetElementType() != XFA_Element::PageArea) { |  1913   if (pLayoutItem->m_pFormNode->GetElementType() != XFA_Element::PageArea) { | 
|  1911     delete pLayoutItem; |  1914     delete pLayoutItem; | 
|  1912   } |  1915   } | 
|  1913 } |  1916 } | 
|  1914 void CXFA_LayoutPageMgr::PrepareLayout() { |  1917 void CXFA_LayoutPageMgr::PrepareLayout() { | 
|  1915   m_pPageSetCurRoot = NULL; |  1918   m_pPageSetCurRoot = nullptr; | 
|  1916   m_ePageSetMode = XFA_ATTRIBUTEENUM_OrderedOccurrence; |  1919   m_ePageSetMode = XFA_ATTRIBUTEENUM_OrderedOccurrence; | 
|  1917   m_nAvailPages = 0; |  1920   m_nAvailPages = 0; | 
|  1918   ClearRecordList(); |  1921   ClearRecordList(); | 
|  1919   if (!m_pPageSetLayoutItemRoot) { |  1922   if (!m_pPageSetLayoutItemRoot) { | 
|  1920     return; |  1923     return; | 
|  1921   } |  1924   } | 
|  1922   CXFA_ContainerLayoutItem* pRootLayoutItem = m_pPageSetLayoutItemRoot; |  1925   CXFA_ContainerLayoutItem* pRootLayoutItem = m_pPageSetLayoutItemRoot; | 
|  1923   if (pRootLayoutItem && |  1926   if (pRootLayoutItem && | 
|  1924       pRootLayoutItem->m_pFormNode->GetPacketID() == XFA_XDPPACKET_Form) { |  1927       pRootLayoutItem->m_pFormNode->GetPacketID() == XFA_XDPPACKET_Form) { | 
|  1925     CXFA_Node* pPageSetFormNode = pRootLayoutItem->m_pFormNode; |  1928     CXFA_Node* pPageSetFormNode = pRootLayoutItem->m_pFormNode; | 
|  1926     pRootLayoutItem->m_pFormNode->GetDocument()->m_pPendingPageSet.RemoveAll(); |  1929     pRootLayoutItem->m_pFormNode->GetDocument()->m_pPendingPageSet.RemoveAll(); | 
|  1927     if (pPageSetFormNode->HasRemovedChildren()) { |  1930     if (pPageSetFormNode->HasRemovedChildren()) { | 
|  1928       XFA_ReleaseLayoutItem(pRootLayoutItem); |  1931       XFA_ReleaseLayoutItem(pRootLayoutItem); | 
|  1929       m_pPageSetLayoutItemRoot = NULL; |  1932       m_pPageSetLayoutItemRoot = nullptr; | 
|  1930       pRootLayoutItem = NULL; |  1933       pRootLayoutItem = nullptr; | 
|  1931       pPageSetFormNode = NULL; |  1934       pPageSetFormNode = nullptr; | 
|  1932       m_PageArray.RemoveAll(); |  1935       m_PageArray.RemoveAll(); | 
|  1933     } |  1936     } | 
|  1934     while (pPageSetFormNode) { |  1937     while (pPageSetFormNode) { | 
|  1935       CXFA_Node* pNextPageSet = |  1938       CXFA_Node* pNextPageSet = | 
|  1936           pPageSetFormNode->GetNextSameClassSibling(XFA_Element::PageSet); |  1939           pPageSetFormNode->GetNextSameClassSibling(XFA_Element::PageSet); | 
|  1937       pPageSetFormNode->GetNodeItem(XFA_NODEITEM_Parent) |  1940       pPageSetFormNode->GetNodeItem(XFA_NODEITEM_Parent) | 
|  1938           ->RemoveChild(pPageSetFormNode, FALSE); |  1941           ->RemoveChild(pPageSetFormNode, FALSE); | 
|  1939       pRootLayoutItem->m_pFormNode->GetDocument()->m_pPendingPageSet.Add( |  1942       pRootLayoutItem->m_pFormNode->GetDocument()->m_pPendingPageSet.Add( | 
|  1940           pPageSetFormNode); |  1943           pPageSetFormNode); | 
|  1941       pPageSetFormNode = pNextPageSet; |  1944       pPageSetFormNode = pNextPageSet; | 
|  1942     } |  1945     } | 
|  1943   } |  1946   } | 
|  1944   pRootLayoutItem = m_pPageSetLayoutItemRoot; |  1947   pRootLayoutItem = m_pPageSetLayoutItemRoot; | 
|  1945   CXFA_ContainerLayoutItem* pNextLayout = NULL; |  1948   CXFA_ContainerLayoutItem* pNextLayout = nullptr; | 
|  1946   for (; pRootLayoutItem; pRootLayoutItem = pNextLayout) { |  1949   for (; pRootLayoutItem; pRootLayoutItem = pNextLayout) { | 
|  1947     pNextLayout = (CXFA_ContainerLayoutItem*)pRootLayoutItem->m_pNextSibling; |  1950     pNextLayout = (CXFA_ContainerLayoutItem*)pRootLayoutItem->m_pNextSibling; | 
|  1948     SaveLayoutItem(pRootLayoutItem); |  1951     SaveLayoutItem(pRootLayoutItem); | 
|  1949     delete pRootLayoutItem; |  1952     delete pRootLayoutItem; | 
|  1950   } |  1953   } | 
|  1951   m_pPageSetLayoutItemRoot = NULL; |  1954   m_pPageSetLayoutItemRoot = nullptr; | 
|  1952 } |  1955 } | 
| OLD | NEW |