| 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/fm2js/xfa_fm2jsapi.h" | 10 #include "xfa/fxfa/fm2js/xfa_fm2jsapi.h" |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 CXFA_Document* pDocument = pTemplateNode->GetDocument(); | 87 CXFA_Document* pDocument = pTemplateNode->GetDocument(); |
| 88 CXFA_Document* pObjFactory = pDocument->GetParser()->GetFactory(); | 88 CXFA_Document* pObjFactory = pDocument->GetParser()->GetFactory(); |
| 89 pPageArea = m_pTemplatePageSetRoot->GetChild(0, XFA_ELEMENT_PageArea); | 89 pPageArea = m_pTemplatePageSetRoot->GetChild(0, XFA_ELEMENT_PageArea); |
| 90 if (!pPageArea) { | 90 if (!pPageArea) { |
| 91 pPageArea = pObjFactory->CreateNode(m_pTemplatePageSetRoot->GetPacketID(), | 91 pPageArea = pObjFactory->CreateNode(m_pTemplatePageSetRoot->GetPacketID(), |
| 92 XFA_ELEMENT_PageArea); | 92 XFA_ELEMENT_PageArea); |
| 93 if (!pPageArea) { | 93 if (!pPageArea) { |
| 94 return FALSE; | 94 return FALSE; |
| 95 } | 95 } |
| 96 m_pTemplatePageSetRoot->InsertChild(pPageArea, NULL); | 96 m_pTemplatePageSetRoot->InsertChild(pPageArea, NULL); |
| 97 pPageArea->SetFlag(XFA_NODEFLAG_Initialized); | 97 pPageArea->SetFlag(XFA_NODEFLAG_Initialized, true); |
| 98 } | 98 } |
| 99 CXFA_Node* pContentArea = pPageArea->GetChild(0, XFA_ELEMENT_ContentArea); | 99 CXFA_Node* pContentArea = pPageArea->GetChild(0, XFA_ELEMENT_ContentArea); |
| 100 if (!pContentArea) { | 100 if (!pContentArea) { |
| 101 pContentArea = pObjFactory->CreateNode(pPageArea->GetPacketID(), | 101 pContentArea = pObjFactory->CreateNode(pPageArea->GetPacketID(), |
| 102 XFA_ELEMENT_ContentArea); | 102 XFA_ELEMENT_ContentArea); |
| 103 if (!pContentArea) { | 103 if (!pContentArea) { |
| 104 return FALSE; | 104 return FALSE; |
| 105 } | 105 } |
| 106 pPageArea->InsertChild(pContentArea, NULL); | 106 pPageArea->InsertChild(pContentArea, NULL); |
| 107 pContentArea->SetFlag(XFA_NODEFLAG_Initialized); | 107 pContentArea->SetFlag(XFA_NODEFLAG_Initialized, true); |
| 108 pContentArea->SetMeasure(XFA_ATTRIBUTE_X, | 108 pContentArea->SetMeasure(XFA_ATTRIBUTE_X, |
| 109 CXFA_Measurement(0.25f, XFA_UNIT_In)); | 109 CXFA_Measurement(0.25f, XFA_UNIT_In)); |
| 110 pContentArea->SetMeasure(XFA_ATTRIBUTE_Y, | 110 pContentArea->SetMeasure(XFA_ATTRIBUTE_Y, |
| 111 CXFA_Measurement(0.25f, XFA_UNIT_In)); | 111 CXFA_Measurement(0.25f, XFA_UNIT_In)); |
| 112 pContentArea->SetMeasure(XFA_ATTRIBUTE_W, | 112 pContentArea->SetMeasure(XFA_ATTRIBUTE_W, |
| 113 CXFA_Measurement(8.0f, XFA_UNIT_In)); | 113 CXFA_Measurement(8.0f, XFA_UNIT_In)); |
| 114 pContentArea->SetMeasure(XFA_ATTRIBUTE_H, | 114 pContentArea->SetMeasure(XFA_ATTRIBUTE_H, |
| 115 CXFA_Measurement(10.5f, XFA_UNIT_In)); | 115 CXFA_Measurement(10.5f, XFA_UNIT_In)); |
| 116 } | 116 } |
| 117 CXFA_Node* pMedium = pPageArea->GetChild(0, XFA_ELEMENT_Medium); | 117 CXFA_Node* pMedium = pPageArea->GetChild(0, XFA_ELEMENT_Medium); |
| 118 if (!pMedium) { | 118 if (!pMedium) { |
| 119 pMedium = | 119 pMedium = |
| 120 pObjFactory->CreateNode(pPageArea->GetPacketID(), XFA_ELEMENT_Medium); | 120 pObjFactory->CreateNode(pPageArea->GetPacketID(), XFA_ELEMENT_Medium); |
| 121 if (!pContentArea) { | 121 if (!pContentArea) { |
| 122 return FALSE; | 122 return FALSE; |
| 123 } | 123 } |
| 124 pPageArea->InsertChild(pMedium, NULL); | 124 pPageArea->InsertChild(pMedium, NULL); |
| 125 pMedium->SetFlag(XFA_NODEFLAG_Initialized); | 125 pMedium->SetFlag(XFA_NODEFLAG_Initialized, true); |
| 126 pMedium->SetMeasure(XFA_ATTRIBUTE_Short, | 126 pMedium->SetMeasure(XFA_ATTRIBUTE_Short, |
| 127 CXFA_Measurement(8.5f, XFA_UNIT_In)); | 127 CXFA_Measurement(8.5f, XFA_UNIT_In)); |
| 128 pMedium->SetMeasure(XFA_ATTRIBUTE_Long, | 128 pMedium->SetMeasure(XFA_ATTRIBUTE_Long, |
| 129 CXFA_Measurement(11.0f, XFA_UNIT_In)); | 129 CXFA_Measurement(11.0f, XFA_UNIT_In)); |
| 130 } | 130 } |
| 131 return TRUE; | 131 return TRUE; |
| 132 } | 132 } |
| 133 FX_BOOL CXFA_LayoutPageMgr::PrepareFirstPage(CXFA_Node* pRootSubform) { | 133 FX_BOOL CXFA_LayoutPageMgr::PrepareFirstPage(CXFA_Node* pRootSubform) { |
| 134 FX_BOOL bProBreakBefore = FALSE; | 134 FX_BOOL bProBreakBefore = FALSE; |
| 135 CXFA_Node* pBreakBeforeNode = NULL; | 135 CXFA_Node* pBreakBeforeNode = NULL; |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 pContainerItem->m_pFormNode = pNewPageArea; | 408 pContainerItem->m_pFormNode = pNewPageArea; |
| 409 m_nAvailPages++; | 409 m_nAvailPages++; |
| 410 pNewPageAreaLayoutItem = pContainerItem; | 410 pNewPageAreaLayoutItem = pContainerItem; |
| 411 } else { | 411 } else { |
| 412 CXFA_FFNotify* pNotify = | 412 CXFA_FFNotify* pNotify = |
| 413 pNewPageArea->GetDocument()->GetParser()->GetNotify(); | 413 pNewPageArea->GetDocument()->GetParser()->GetNotify(); |
| 414 CXFA_ContainerLayoutItem* pContainerItem = | 414 CXFA_ContainerLayoutItem* pContainerItem = |
| 415 (CXFA_ContainerLayoutItem*)pNotify->OnCreateLayoutItem(pNewPageArea); | 415 (CXFA_ContainerLayoutItem*)pNotify->OnCreateLayoutItem(pNewPageArea); |
| 416 m_PageArray.Add(pContainerItem); | 416 m_PageArray.Add(pContainerItem); |
| 417 m_nAvailPages++; | 417 m_nAvailPages++; |
| 418 pNotify->OnPageEvent(pContainerItem, XFA_PAGEEVENT_PageAdded, | 418 pNotify->OnPageEvent(pContainerItem, XFA_PAGEVIEWEVENT_PostRemoved); |
| 419 (void*)(uintptr_t)m_nAvailPages); | |
| 420 pNewPageAreaLayoutItem = pContainerItem; | 419 pNewPageAreaLayoutItem = pContainerItem; |
| 421 } | 420 } |
| 422 pNewRecord->pCurPageSet->AddChild(pNewPageAreaLayoutItem); | 421 pNewRecord->pCurPageSet->AddChild(pNewPageAreaLayoutItem); |
| 423 pNewRecord->pCurPageArea = pNewPageAreaLayoutItem; | 422 pNewRecord->pCurPageArea = pNewPageAreaLayoutItem; |
| 424 pNewRecord->pCurContentArea = NULL; | 423 pNewRecord->pCurContentArea = NULL; |
| 425 } | 424 } |
| 426 void CXFA_LayoutPageMgr::AddContentAreaLayoutItem( | 425 void CXFA_LayoutPageMgr::AddContentAreaLayoutItem( |
| 427 CXFA_ContainerRecord* pNewRecord, | 426 CXFA_ContainerRecord* pNewRecord, |
| 428 CXFA_Node* pContentArea) { | 427 CXFA_Node* pContentArea) { |
| 429 if (pContentArea == NULL) { | 428 if (pContentArea == NULL) { |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 738 pTarget, bStartNew)) { | 737 pTarget, bStartNew)) { |
| 739 return TRUE; | 738 return TRUE; |
| 740 } | 739 } |
| 741 } break; | 740 } break; |
| 742 default: | 741 default: |
| 743 break; | 742 break; |
| 744 } | 743 } |
| 745 return FALSE; | 744 return FALSE; |
| 746 } | 745 } |
| 747 static void XFA_SetLayoutGeneratedNodeFlag(CXFA_Node* pNode) { | 746 static void XFA_SetLayoutGeneratedNodeFlag(CXFA_Node* pNode) { |
| 748 pNode->SetFlag(XFA_NODEFLAG_LayoutGeneratedNode, TRUE, FALSE); | 747 pNode->SetFlag(XFA_NODEFLAG_LayoutGeneratedNode, false); |
| 749 pNode->SetFlag(XFA_NODEFLAG_UnusedNode, FALSE, FALSE); | 748 pNode->ClearFlag(XFA_NODEFLAG_UnusedNode); |
| 750 } | 749 } |
| 751 FX_BOOL CXFA_LayoutPageMgr::ProcessBreakBeforeOrAfter( | 750 FX_BOOL CXFA_LayoutPageMgr::ProcessBreakBeforeOrAfter( |
| 752 CXFA_Node* pBreakNode, | 751 CXFA_Node* pBreakNode, |
| 753 FX_BOOL bBefore, | 752 FX_BOOL bBefore, |
| 754 CXFA_Node*& pBreakLeaderNode, | 753 CXFA_Node*& pBreakLeaderNode, |
| 755 CXFA_Node*& pBreakTrailerNode, | 754 CXFA_Node*& pBreakTrailerNode, |
| 756 FX_BOOL& bCreatePage) { | 755 FX_BOOL& bCreatePage) { |
| 757 CXFA_Node *pLeaderTemplate = NULL, *pTrailerTemplate = NULL; | 756 CXFA_Node *pLeaderTemplate = NULL, *pTrailerTemplate = NULL; |
| 758 CXFA_Node* pFormNode = pBreakNode->GetNodeItem(XFA_NODEITEM_Parent, | 757 CXFA_Node* pFormNode = pBreakNode->GetNodeItem(XFA_NODEITEM_Parent, |
| 759 XFA_OBJECTTYPE_ContainerNode); | 758 XFA_OBJECTTYPE_ContainerNode); |
| (...skipping 740 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1500 static void XFA_SyncRemoveLayoutItem(CXFA_LayoutItem* pParentLayoutItem, | 1499 static void XFA_SyncRemoveLayoutItem(CXFA_LayoutItem* pParentLayoutItem, |
| 1501 CXFA_FFNotify* pNotify, | 1500 CXFA_FFNotify* pNotify, |
| 1502 CXFA_LayoutProcessor* pDocLayout) { | 1501 CXFA_LayoutProcessor* pDocLayout) { |
| 1503 CXFA_LayoutItem* pNextLayoutItem; | 1502 CXFA_LayoutItem* pNextLayoutItem; |
| 1504 CXFA_LayoutItem* pCurLayoutItem = pParentLayoutItem->m_pFirstChild; | 1503 CXFA_LayoutItem* pCurLayoutItem = pParentLayoutItem->m_pFirstChild; |
| 1505 while (pCurLayoutItem) { | 1504 while (pCurLayoutItem) { |
| 1506 pNextLayoutItem = pCurLayoutItem->m_pNextSibling; | 1505 pNextLayoutItem = pCurLayoutItem->m_pNextSibling; |
| 1507 if (pCurLayoutItem->m_pFirstChild) { | 1506 if (pCurLayoutItem->m_pFirstChild) { |
| 1508 XFA_SyncRemoveLayoutItem(pCurLayoutItem, pNotify, pDocLayout); | 1507 XFA_SyncRemoveLayoutItem(pCurLayoutItem, pNotify, pDocLayout); |
| 1509 } | 1508 } |
| 1510 pNotify->OnLayoutEvent(pDocLayout, pCurLayoutItem, | 1509 pNotify->OnLayoutItemRemoving(pDocLayout, pCurLayoutItem); |
| 1511 XFA_LAYOUTEVENT_ItemRemoving); | |
| 1512 delete pCurLayoutItem; | 1510 delete pCurLayoutItem; |
| 1513 pCurLayoutItem = pNextLayoutItem; | 1511 pCurLayoutItem = pNextLayoutItem; |
| 1514 } | 1512 } |
| 1515 } | 1513 } |
| 1516 void CXFA_LayoutPageMgr::SaveLayoutItem(CXFA_LayoutItem* pParentLayoutItem) { | 1514 void CXFA_LayoutPageMgr::SaveLayoutItem(CXFA_LayoutItem* pParentLayoutItem) { |
| 1517 CXFA_LayoutItem* pNextLayoutItem; | 1515 CXFA_LayoutItem* pNextLayoutItem; |
| 1518 CXFA_LayoutItem* pCurLayoutItem = pParentLayoutItem->m_pFirstChild; | 1516 CXFA_LayoutItem* pCurLayoutItem = pParentLayoutItem->m_pFirstChild; |
| 1519 while (pCurLayoutItem) { | 1517 while (pCurLayoutItem) { |
| 1520 pNextLayoutItem = pCurLayoutItem->m_pNextSibling; | 1518 pNextLayoutItem = pCurLayoutItem->m_pNextSibling; |
| 1521 if (pCurLayoutItem->IsContentLayoutItem()) { | 1519 if (pCurLayoutItem->IsContentLayoutItem()) { |
| 1522 uint32_t dwFlag = pCurLayoutItem->m_pFormNode->GetFlag(); | 1520 uint32_t dwFlag = pCurLayoutItem->m_pFormNode->GetFlag(); |
| 1523 if (dwFlag & (XFA_NODEFLAG_HasRemoved)) { | 1521 if (dwFlag & (XFA_NODEFLAG_HasRemoved)) { |
| 1524 CXFA_FFNotify* pNotify = | 1522 CXFA_FFNotify* pNotify = |
| 1525 m_pTemplatePageSetRoot->GetDocument()->GetParser()->GetNotify(); | 1523 m_pTemplatePageSetRoot->GetDocument()->GetParser()->GetNotify(); |
| 1526 CXFA_LayoutProcessor* pDocLayout = | 1524 CXFA_LayoutProcessor* pDocLayout = |
| 1527 m_pTemplatePageSetRoot->GetDocument()->GetDocLayout(); | 1525 m_pTemplatePageSetRoot->GetDocument()->GetDocLayout(); |
| 1528 if (pCurLayoutItem->m_pFirstChild) { | 1526 if (pCurLayoutItem->m_pFirstChild) { |
| 1529 XFA_SyncRemoveLayoutItem(pCurLayoutItem, pNotify, pDocLayout); | 1527 XFA_SyncRemoveLayoutItem(pCurLayoutItem, pNotify, pDocLayout); |
| 1530 } | 1528 } |
| 1531 pNotify->OnLayoutEvent(pDocLayout, pCurLayoutItem, | 1529 pNotify->OnLayoutItemRemoving(pDocLayout, pCurLayoutItem); |
| 1532 XFA_LAYOUTEVENT_ItemRemoving); | |
| 1533 delete pCurLayoutItem; | 1530 delete pCurLayoutItem; |
| 1534 pCurLayoutItem = pNextLayoutItem; | 1531 pCurLayoutItem = pNextLayoutItem; |
| 1535 continue; | 1532 continue; |
| 1536 } | 1533 } |
| 1537 if (dwFlag & XFA_NODEFLAG_LayoutGeneratedNode) { | 1534 if (dwFlag & XFA_NODEFLAG_LayoutGeneratedNode) { |
| 1538 CXFA_NodeIteratorTemplate<CXFA_Node, CXFA_TraverseStrategy_XFANode> | 1535 CXFA_NodeIteratorTemplate<CXFA_Node, CXFA_TraverseStrategy_XFANode> |
| 1539 sIterator(pCurLayoutItem->m_pFormNode); | 1536 sIterator(pCurLayoutItem->m_pFormNode); |
| 1540 for (CXFA_Node* pNode = sIterator.GetCurrent(); pNode; | 1537 for (CXFA_Node* pNode = sIterator.GetCurrent(); pNode; |
| 1541 pNode = sIterator.MoveToNext()) { | 1538 pNode = sIterator.MoveToNext()) { |
| 1542 pNode->SetFlag(XFA_NODEFLAG_UnusedNode, TRUE, FALSE); | 1539 pNode->SetFlag(XFA_NODEFLAG_UnusedNode, false); |
| 1543 } | 1540 } |
| 1544 } | 1541 } |
| 1545 } | 1542 } |
| 1546 if (pCurLayoutItem->m_pFirstChild) { | 1543 if (pCurLayoutItem->m_pFirstChild) { |
| 1547 SaveLayoutItem(pCurLayoutItem); | 1544 SaveLayoutItem(pCurLayoutItem); |
| 1548 } | 1545 } |
| 1549 pCurLayoutItem->m_pParent = NULL; | 1546 pCurLayoutItem->m_pParent = NULL; |
| 1550 pCurLayoutItem->m_pNextSibling = NULL; | 1547 pCurLayoutItem->m_pNextSibling = NULL; |
| 1551 pCurLayoutItem->m_pFirstChild = NULL; | 1548 pCurLayoutItem->m_pFirstChild = NULL; |
| 1552 if (!pCurLayoutItem->IsContentLayoutItem() && | 1549 if (!pCurLayoutItem->IsContentLayoutItem() && |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1572 !wsOverflowTarget.IsEmpty()) { | 1569 !wsOverflowTarget.IsEmpty()) { |
| 1573 return pCurNode; | 1570 return pCurNode; |
| 1574 } | 1571 } |
| 1575 return NULL; | 1572 return NULL; |
| 1576 } else if (pCurNode->GetClassID() == XFA_ELEMENT_Overflow) { | 1573 } else if (pCurNode->GetClassID() == XFA_ELEMENT_Overflow) { |
| 1577 return pCurNode; | 1574 return pCurNode; |
| 1578 } | 1575 } |
| 1579 } | 1576 } |
| 1580 return NULL; | 1577 return NULL; |
| 1581 } | 1578 } |
| 1579 |
| 1582 void CXFA_LayoutPageMgr::MergePageSetContents() { | 1580 void CXFA_LayoutPageMgr::MergePageSetContents() { |
| 1583 CXFA_Document* pDocument = m_pTemplatePageSetRoot->GetDocument(); | 1581 CXFA_Document* pDocument = m_pTemplatePageSetRoot->GetDocument(); |
| 1584 CXFA_FFNotify* pNotify = pDocument->GetParser()->GetNotify(); | 1582 CXFA_FFNotify* pNotify = pDocument->GetParser()->GetNotify(); |
| 1585 CXFA_LayoutProcessor* pDocLayout = pDocument->GetDocLayout(); | 1583 CXFA_LayoutProcessor* pDocLayout = pDocument->GetDocLayout(); |
| 1586 CXFA_ContainerLayoutItem* pRootLayout = GetRootLayoutItem(); | 1584 CXFA_ContainerLayoutItem* pRootLayout = GetRootLayoutItem(); |
| 1587 { | 1585 { |
| 1588 for (int32_t iIndex = 0; iIndex < pDocument->m_pPendingPageSet.GetSize(); | 1586 for (int32_t iIndex = 0; iIndex < pDocument->m_pPendingPageSet.GetSize(); |
| 1589 iIndex++) { | 1587 iIndex++) { |
| 1590 CXFA_NodeIteratorTemplate<CXFA_Node, CXFA_TraverseStrategy_XFANode> | 1588 CXFA_NodeIteratorTemplate<CXFA_Node, CXFA_TraverseStrategy_XFANode> |
| 1591 sIterator(pDocument->m_pPendingPageSet.GetAt(iIndex)); | 1589 sIterator(pDocument->m_pPendingPageSet.GetAt(iIndex)); |
| 1592 for (CXFA_Node* pNode = sIterator.GetCurrent(); pNode; | 1590 for (CXFA_Node* pNode = sIterator.GetCurrent(); pNode; |
| 1593 pNode = sIterator.MoveToNext()) { | 1591 pNode = sIterator.MoveToNext()) { |
| 1594 if (pNode->IsContainerNode()) { | 1592 if (pNode->IsContainerNode()) { |
| 1595 CXFA_Node* pBindNode = pNode->GetBindData(); | 1593 CXFA_Node* pBindNode = pNode->GetBindData(); |
| 1596 if (pBindNode) { | 1594 if (pBindNode) { |
| 1597 pBindNode->RemoveBindItem(pNode); | 1595 pBindNode->RemoveBindItem(pNode); |
| 1598 pNode->SetObject(XFA_ATTRIBUTE_BindingNode, NULL); | 1596 pNode->SetObject(XFA_ATTRIBUTE_BindingNode, NULL); |
| 1599 } | 1597 } |
| 1600 } | 1598 } |
| 1601 pNode->SetFlag(XFA_NODEFLAG_UnusedNode); | 1599 pNode->SetFlag(XFA_NODEFLAG_UnusedNode, true); |
| 1602 } | 1600 } |
| 1603 } | 1601 } |
| 1604 } | 1602 } |
| 1605 int32_t iIndex = 0; | 1603 int32_t iIndex = 0; |
| 1606 CXFA_Node* pPendingPageSet = NULL; | |
| 1607 for (; pRootLayout; | 1604 for (; pRootLayout; |
| 1608 pRootLayout = (CXFA_ContainerLayoutItem*)pRootLayout->m_pNextSibling) { | 1605 pRootLayout = (CXFA_ContainerLayoutItem*)pRootLayout->m_pNextSibling) { |
| 1609 pPendingPageSet = NULL; | 1606 CXFA_Node* pPendingPageSet = nullptr; |
| 1610 CXFA_NodeIteratorTemplate< | 1607 CXFA_NodeIteratorTemplate< |
| 1611 CXFA_ContainerLayoutItem, | 1608 CXFA_ContainerLayoutItem, |
| 1612 CXFA_TraverseStrategy_ContentAreaContainerLayoutItem> | 1609 CXFA_TraverseStrategy_ContentAreaContainerLayoutItem> |
| 1613 iterator(pRootLayout); | 1610 iterator(pRootLayout); |
| 1614 CXFA_ContainerLayoutItem* pRootPageSetContainerItem = iterator.GetCurrent(); | 1611 CXFA_ContainerLayoutItem* pRootPageSetContainerItem = iterator.GetCurrent(); |
| 1615 ASSERT(pRootPageSetContainerItem->m_pFormNode->GetClassID() == | 1612 ASSERT(pRootPageSetContainerItem->m_pFormNode->GetClassID() == |
| 1616 XFA_ELEMENT_PageSet); | 1613 XFA_ELEMENT_PageSet); |
| 1617 if (iIndex < pDocument->m_pPendingPageSet.GetSize()) { | 1614 if (iIndex < pDocument->m_pPendingPageSet.GetSize()) { |
| 1618 pPendingPageSet = pDocument->m_pPendingPageSet.GetAt(iIndex); | 1615 pPendingPageSet = pDocument->m_pPendingPageSet.GetAt(iIndex); |
| 1619 iIndex++; | 1616 iIndex++; |
| 1620 } | 1617 } |
| 1621 if (!pPendingPageSet) { | 1618 if (!pPendingPageSet) { |
| 1622 if (pRootPageSetContainerItem->m_pFormNode->GetPacketID() == | 1619 if (pRootPageSetContainerItem->m_pFormNode->GetPacketID() == |
| 1623 XFA_XDPPACKET_Template) { | 1620 XFA_XDPPACKET_Template) { |
| 1624 pPendingPageSet = | 1621 pPendingPageSet = |
| 1625 pRootPageSetContainerItem->m_pFormNode->CloneTemplateToForm(FALSE); | 1622 pRootPageSetContainerItem->m_pFormNode->CloneTemplateToForm(FALSE); |
| 1626 } else { | 1623 } else { |
| 1627 pPendingPageSet = pRootPageSetContainerItem->m_pFormNode; | 1624 pPendingPageSet = pRootPageSetContainerItem->m_pFormNode; |
| 1628 } | 1625 } |
| 1629 } | 1626 } |
| 1630 if (pRootPageSetContainerItem->m_pFormNode->GetUserData( | 1627 if (pRootPageSetContainerItem->m_pFormNode->GetUserData( |
| 1631 XFA_LAYOUTITEMKEY) == pRootPageSetContainerItem) { | 1628 XFA_LAYOUTITEMKEY) == pRootPageSetContainerItem) { |
| 1632 pRootPageSetContainerItem->m_pFormNode->SetUserData(XFA_LAYOUTITEMKEY, | 1629 pRootPageSetContainerItem->m_pFormNode->SetUserData(XFA_LAYOUTITEMKEY, |
| 1633 NULL); | 1630 NULL); |
| 1634 } | 1631 } |
| 1635 pRootPageSetContainerItem->m_pFormNode = pPendingPageSet; | 1632 pRootPageSetContainerItem->m_pFormNode = pPendingPageSet; |
| 1636 pPendingPageSet->SetFlag(XFA_NODEFLAG_UnusedNode, FALSE); | 1633 pPendingPageSet->ClearFlag(XFA_NODEFLAG_UnusedNode); |
| 1637 for (CXFA_ContainerLayoutItem* pContainerItem = iterator.MoveToNext(); | 1634 for (CXFA_ContainerLayoutItem* pContainerItem = iterator.MoveToNext(); |
| 1638 pContainerItem; pContainerItem = iterator.MoveToNext()) { | 1635 pContainerItem; pContainerItem = iterator.MoveToNext()) { |
| 1639 CXFA_Node* pNode = pContainerItem->m_pFormNode; | 1636 CXFA_Node* pNode = pContainerItem->m_pFormNode; |
| 1640 if (pNode->GetPacketID() != XFA_XDPPACKET_Template) { | 1637 if (pNode->GetPacketID() != XFA_XDPPACKET_Template) { |
| 1641 continue; | 1638 continue; |
| 1642 } | 1639 } |
| 1643 switch (pNode->GetClassID()) { | 1640 switch (pNode->GetClassID()) { |
| 1644 case XFA_ELEMENT_PageSet: { | 1641 case XFA_ELEMENT_PageSet: { |
| 1645 CXFA_Node* pParentNode = pContainerItem->m_pParent->m_pFormNode; | 1642 CXFA_Node* pParentNode = pContainerItem->m_pParent->m_pFormNode; |
| 1646 pContainerItem->m_pFormNode = XFA_NodeMerge_CloneOrMergeContainer( | 1643 pContainerItem->m_pFormNode = XFA_NodeMerge_CloneOrMergeContainer( |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1672 CXFA_Node* pExistingNode = XFA_DataMerge_FindFormDOMInstance( | 1669 CXFA_Node* pExistingNode = XFA_DataMerge_FindFormDOMInstance( |
| 1673 pDocument, pContainerItem->m_pFormNode->GetClassID(), | 1670 pDocument, pContainerItem->m_pFormNode->GetClassID(), |
| 1674 pContainerItem->m_pFormNode->GetNameHash(), pParentNode); | 1671 pContainerItem->m_pFormNode->GetNameHash(), pParentNode); |
| 1675 CXFA_ContainerIterator sIterator(pExistingNode); | 1672 CXFA_ContainerIterator sIterator(pExistingNode); |
| 1676 for (CXFA_Node* pNode = sIterator.GetCurrent(); pNode; | 1673 for (CXFA_Node* pNode = sIterator.GetCurrent(); pNode; |
| 1677 pNode = sIterator.MoveToNext()) { | 1674 pNode = sIterator.MoveToNext()) { |
| 1678 if (pNode->GetClassID() != XFA_ELEMENT_ContentArea) { | 1675 if (pNode->GetClassID() != XFA_ELEMENT_ContentArea) { |
| 1679 CXFA_LayoutItem* pLayoutItem = static_cast<CXFA_LayoutItem*>( | 1676 CXFA_LayoutItem* pLayoutItem = static_cast<CXFA_LayoutItem*>( |
| 1680 pNode->GetUserData(XFA_LAYOUTITEMKEY)); | 1677 pNode->GetUserData(XFA_LAYOUTITEMKEY)); |
| 1681 if (pLayoutItem) { | 1678 if (pLayoutItem) { |
| 1682 pNotify->OnLayoutEvent(pDocLayout, pLayoutItem, | 1679 pNotify->OnLayoutItemRemoving(pDocLayout, pLayoutItem); |
| 1683 XFA_LAYOUTEVENT_ItemRemoving); | |
| 1684 delete pLayoutItem; | 1680 delete pLayoutItem; |
| 1685 } | 1681 } |
| 1686 } | 1682 } |
| 1687 } | 1683 } |
| 1688 if (pExistingNode) { | 1684 if (pExistingNode) { |
| 1689 pParentNode->RemoveChild(pExistingNode); | 1685 pParentNode->RemoveChild(pExistingNode); |
| 1690 } | 1686 } |
| 1691 } | 1687 } |
| 1692 pContainerItem->m_pOldSubform = pNewSubform; | 1688 pContainerItem->m_pOldSubform = pNewSubform; |
| 1693 } | 1689 } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1713 } | 1709 } |
| 1714 } | 1710 } |
| 1715 if (!pPendingPageSet->GetNodeItem(XFA_NODEITEM_Parent)) { | 1711 if (!pPendingPageSet->GetNodeItem(XFA_NODEITEM_Parent)) { |
| 1716 CXFA_Node* pFormToplevelSubform = | 1712 CXFA_Node* pFormToplevelSubform = |
| 1717 pDocument->GetXFAObject(XFA_HASHCODE_Form) | 1713 pDocument->GetXFAObject(XFA_HASHCODE_Form) |
| 1718 ->AsNode() | 1714 ->AsNode() |
| 1719 ->GetFirstChildByClass(XFA_ELEMENT_Subform); | 1715 ->GetFirstChildByClass(XFA_ELEMENT_Subform); |
| 1720 pFormToplevelSubform->InsertChild(pPendingPageSet); | 1716 pFormToplevelSubform->InsertChild(pPendingPageSet); |
| 1721 } | 1717 } |
| 1722 pDocument->DataMerge_UpdateBindingRelations(pPendingPageSet); | 1718 pDocument->DataMerge_UpdateBindingRelations(pPendingPageSet); |
| 1723 pPendingPageSet->SetFlag(XFA_NODEFLAG_Initialized); | 1719 pPendingPageSet->SetFlag(XFA_NODEFLAG_Initialized, true); |
| 1724 } | 1720 } |
| 1725 pPendingPageSet = GetRootLayoutItem()->m_pFormNode; | 1721 CXFA_Node* pPageSet = GetRootLayoutItem()->m_pFormNode; |
| 1726 while (pPendingPageSet) { | 1722 while (pPageSet) { |
| 1727 CXFA_Node* pNextPendingPageSet = | 1723 CXFA_Node* pNextPageSet = |
| 1728 pPendingPageSet->GetNextSameClassSibling(XFA_ELEMENT_PageSet); | 1724 pPageSet->GetNextSameClassSibling(XFA_ELEMENT_PageSet); |
| 1729 CXFA_NodeIteratorTemplate<CXFA_Node, CXFA_TraverseStrategy_XFANode> | 1725 CXFA_NodeIteratorTemplate<CXFA_Node, CXFA_TraverseStrategy_XFANode> |
| 1730 sIterator(pPendingPageSet); | 1726 sIterator(pPageSet); |
| 1731 CXFA_Node* pNode = sIterator.GetCurrent(); | 1727 CXFA_Node* pNode = sIterator.GetCurrent(); |
| 1732 while (pNode) { | 1728 while (pNode) { |
| 1733 if (pNode->HasFlag(XFA_NODEFLAG_UnusedNode)) { | 1729 if (pNode->HasFlag(XFA_NODEFLAG_UnusedNode)) { |
| 1734 if (pNode->GetObjectType() == XFA_OBJECTTYPE_ContainerNode) { | 1730 if (pNode->GetObjectType() == XFA_OBJECTTYPE_ContainerNode) { |
| 1735 XFA_ELEMENT eCurId = pNode->GetClassID(); | 1731 XFA_ELEMENT eCurId = pNode->GetClassID(); |
| 1736 if (eCurId == XFA_ELEMENT_PageArea || eCurId == XFA_ELEMENT_PageSet) { | 1732 if (eCurId == XFA_ELEMENT_PageArea || eCurId == XFA_ELEMENT_PageSet) { |
| 1737 CXFA_ContainerIterator iteChild(pNode); | 1733 CXFA_ContainerIterator iteChild(pNode); |
| 1738 CXFA_Node* pChildNode = iteChild.MoveToNext(); | 1734 CXFA_Node* pChildNode = iteChild.MoveToNext(); |
| 1739 for (; pChildNode; pChildNode = iteChild.MoveToNext()) { | 1735 for (; pChildNode; pChildNode = iteChild.MoveToNext()) { |
| 1740 CXFA_LayoutItem* pLayoutItem = static_cast<CXFA_LayoutItem*>( | 1736 CXFA_LayoutItem* pLayoutItem = static_cast<CXFA_LayoutItem*>( |
| 1741 pChildNode->GetUserData(XFA_LAYOUTITEMKEY)); | 1737 pChildNode->GetUserData(XFA_LAYOUTITEMKEY)); |
| 1742 if (pLayoutItem) { | 1738 if (pLayoutItem) { |
| 1743 pNotify->OnLayoutEvent(pDocLayout, pLayoutItem, | 1739 pNotify->OnLayoutItemRemoving(pDocLayout, pLayoutItem); |
| 1744 XFA_LAYOUTEVENT_ItemRemoving); | |
| 1745 delete pLayoutItem; | 1740 delete pLayoutItem; |
| 1746 } | 1741 } |
| 1747 } | 1742 } |
| 1748 } else if (eCurId != XFA_ELEMENT_ContentArea) { | 1743 } else if (eCurId != XFA_ELEMENT_ContentArea) { |
| 1749 CXFA_LayoutItem* pLayoutItem = static_cast<CXFA_LayoutItem*>( | 1744 CXFA_LayoutItem* pLayoutItem = static_cast<CXFA_LayoutItem*>( |
| 1750 pNode->GetUserData(XFA_LAYOUTITEMKEY)); | 1745 pNode->GetUserData(XFA_LAYOUTITEMKEY)); |
| 1751 if (pLayoutItem) { | 1746 if (pLayoutItem) { |
| 1752 pNotify->OnLayoutEvent(pDocLayout, pLayoutItem, | 1747 pNotify->OnLayoutItemRemoving(pDocLayout, pLayoutItem); |
| 1753 XFA_LAYOUTEVENT_ItemRemoving); | |
| 1754 delete pLayoutItem; | 1748 delete pLayoutItem; |
| 1755 } | 1749 } |
| 1756 } | 1750 } |
| 1757 CXFA_Node* pNext = sIterator.SkipChildrenAndMoveToNext(); | 1751 CXFA_Node* pNext = sIterator.SkipChildrenAndMoveToNext(); |
| 1758 pNode->GetNodeItem(XFA_NODEITEM_Parent)->RemoveChild(pNode); | 1752 pNode->GetNodeItem(XFA_NODEITEM_Parent)->RemoveChild(pNode); |
| 1759 pNode = pNext; | 1753 pNode = pNext; |
| 1760 } else { | 1754 } else { |
| 1761 pNode->SetFlag(XFA_NODEFLAG_UnusedNode, FALSE); | 1755 pNode->ClearFlag(XFA_NODEFLAG_UnusedNode); |
| 1762 pNode->SetFlag(XFA_NODEFLAG_Initialized); | 1756 pNode->SetFlag(XFA_NODEFLAG_Initialized, true); |
| 1763 pNode = sIterator.MoveToNext(); | 1757 pNode = sIterator.MoveToNext(); |
| 1764 } | 1758 } |
| 1765 } else { | 1759 } else { |
| 1766 pNode->SetFlag(XFA_NODEFLAG_Initialized); | 1760 pNode->SetFlag(XFA_NODEFLAG_Initialized, true); |
| 1767 pNode = sIterator.MoveToNext(); | 1761 pNode = sIterator.MoveToNext(); |
| 1768 } | 1762 } |
| 1769 } | 1763 } |
| 1770 pPendingPageSet = pNextPendingPageSet; | 1764 pPageSet = pNextPageSet; |
| 1771 } | 1765 } |
| 1772 } | 1766 } |
| 1767 |
| 1773 void CXFA_LayoutPageMgr::LayoutPageSetContents() { | 1768 void CXFA_LayoutPageMgr::LayoutPageSetContents() { |
| 1774 CXFA_ContainerLayoutItem* pRootLayoutItem = GetRootLayoutItem(); | 1769 CXFA_ContainerLayoutItem* pRootLayoutItem = GetRootLayoutItem(); |
| 1775 for (; pRootLayoutItem; | 1770 for (; pRootLayoutItem; |
| 1776 pRootLayoutItem = | 1771 pRootLayoutItem = |
| 1777 (CXFA_ContainerLayoutItem*)pRootLayoutItem->m_pNextSibling) { | 1772 (CXFA_ContainerLayoutItem*)pRootLayoutItem->m_pNextSibling) { |
| 1778 CXFA_NodeIteratorTemplate< | 1773 CXFA_NodeIteratorTemplate< |
| 1779 CXFA_ContainerLayoutItem, | 1774 CXFA_ContainerLayoutItem, |
| 1780 CXFA_TraverseStrategy_ContentAreaContainerLayoutItem> | 1775 CXFA_TraverseStrategy_ContentAreaContainerLayoutItem> |
| 1781 iterator(pRootLayoutItem); | 1776 iterator(pRootLayoutItem); |
| 1782 for (CXFA_ContainerLayoutItem* pContainerItem = iterator.GetCurrent(); | 1777 for (CXFA_ContainerLayoutItem* pContainerItem = iterator.GetCurrent(); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1807 pContainerItem->m_pFormNode->GetEnum(XFA_ATTRIBUTE_Presence); | 1802 pContainerItem->m_pFormNode->GetEnum(XFA_ATTRIBUTE_Presence); |
| 1808 if (eAttributeValue == XFA_ATTRIBUTEENUM_Visible || | 1803 if (eAttributeValue == XFA_ATTRIBUTEENUM_Visible || |
| 1809 eAttributeValue == XFA_ATTRIBUTEENUM_Unknown) { | 1804 eAttributeValue == XFA_ATTRIBUTEENUM_Unknown) { |
| 1810 bVisibleItem = TRUE; | 1805 bVisibleItem = TRUE; |
| 1811 } | 1806 } |
| 1812 dwRelevantContainer = | 1807 dwRelevantContainer = |
| 1813 XFA_GetRelevant(pContainerItem->m_pFormNode, dwRelevant); | 1808 XFA_GetRelevant(pContainerItem->m_pFormNode, dwRelevant); |
| 1814 dwStatus = | 1809 dwStatus = |
| 1815 (bVisibleItem ? XFA_LAYOUTSTATUS_Visible : 0) | dwRelevantContainer; | 1810 (bVisibleItem ? XFA_LAYOUTSTATUS_Visible : 0) | dwRelevantContainer; |
| 1816 } | 1811 } |
| 1817 pNotify->OnLayoutEvent(pDocLayout, pContainerItem, XFA_LAYOUTEVENT_ItemAdded, | 1812 pNotify->OnLayoutItemAdded(pDocLayout, pContainerItem, nPageIndex, dwStatus); |
| 1818 (void*)(uintptr_t)nPageIndex, | |
| 1819 (void*)(uintptr_t)dwStatus); | |
| 1820 for (CXFA_LayoutItem* pChild = pContainerItem->m_pFirstChild; pChild; | 1813 for (CXFA_LayoutItem* pChild = pContainerItem->m_pFirstChild; pChild; |
| 1821 pChild = pChild->m_pNextSibling) { | 1814 pChild = pChild->m_pNextSibling) { |
| 1822 if (pChild->IsContentLayoutItem()) { | 1815 if (pChild->IsContentLayoutItem()) { |
| 1823 XFA_SyncContainer(pNotify, pDocLayout, pChild, dwRelevantContainer, | 1816 XFA_SyncContainer(pNotify, pDocLayout, pChild, dwRelevantContainer, |
| 1824 bVisibleItem, nPageIndex); | 1817 bVisibleItem, nPageIndex); |
| 1825 } | 1818 } |
| 1826 } | 1819 } |
| 1827 } | 1820 } |
| 1828 void CXFA_LayoutPageMgr::SyncLayoutData() { | 1821 void CXFA_LayoutPageMgr::SyncLayoutData() { |
| 1829 MergePageSetContents(); | 1822 MergePageSetContents(); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1869 } break; | 1862 } break; |
| 1870 default: | 1863 default: |
| 1871 break; | 1864 break; |
| 1872 } | 1865 } |
| 1873 } | 1866 } |
| 1874 } | 1867 } |
| 1875 int32_t nPage = m_PageArray.GetSize(); | 1868 int32_t nPage = m_PageArray.GetSize(); |
| 1876 for (int32_t i = nPage - 1; i >= m_nAvailPages; i--) { | 1869 for (int32_t i = nPage - 1; i >= m_nAvailPages; i--) { |
| 1877 CXFA_ContainerLayoutItem* pPage = m_PageArray[i]; | 1870 CXFA_ContainerLayoutItem* pPage = m_PageArray[i]; |
| 1878 m_PageArray.RemoveAt(i); | 1871 m_PageArray.RemoveAt(i); |
| 1879 pNotify->OnPageEvent(pPage, XFA_PAGEEVENT_PageRemoved); | 1872 pNotify->OnPageEvent(pPage, XFA_PAGEVIEWEVENT_PostRemoved); |
| 1880 delete pPage; | 1873 delete pPage; |
| 1881 } | 1874 } |
| 1882 ClearRecordList(); | 1875 ClearRecordList(); |
| 1883 } | 1876 } |
| 1884 void XFA_ReleaseLayoutItem_NoPageArea(CXFA_LayoutItem* pLayoutItem) { | 1877 void XFA_ReleaseLayoutItem_NoPageArea(CXFA_LayoutItem* pLayoutItem) { |
| 1885 CXFA_LayoutItem *pNext, *pNode = pLayoutItem->m_pFirstChild; | 1878 CXFA_LayoutItem *pNext, *pNode = pLayoutItem->m_pFirstChild; |
| 1886 while (pNode) { | 1879 while (pNode) { |
| 1887 pNext = pNode->m_pNextSibling; | 1880 pNext = pNode->m_pNextSibling; |
| 1888 pNode->m_pParent = NULL; | 1881 pNode->m_pParent = NULL; |
| 1889 XFA_ReleaseLayoutItem_NoPageArea(pNode); | 1882 XFA_ReleaseLayoutItem_NoPageArea(pNode); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1925 } | 1918 } |
| 1926 pRootLayoutItem = m_pPageSetLayoutItemRoot; | 1919 pRootLayoutItem = m_pPageSetLayoutItemRoot; |
| 1927 CXFA_ContainerLayoutItem* pNextLayout = NULL; | 1920 CXFA_ContainerLayoutItem* pNextLayout = NULL; |
| 1928 for (; pRootLayoutItem; pRootLayoutItem = pNextLayout) { | 1921 for (; pRootLayoutItem; pRootLayoutItem = pNextLayout) { |
| 1929 pNextLayout = (CXFA_ContainerLayoutItem*)pRootLayoutItem->m_pNextSibling; | 1922 pNextLayout = (CXFA_ContainerLayoutItem*)pRootLayoutItem->m_pNextSibling; |
| 1930 SaveLayoutItem(pRootLayoutItem); | 1923 SaveLayoutItem(pRootLayoutItem); |
| 1931 delete pRootLayoutItem; | 1924 delete pRootLayoutItem; |
| 1932 } | 1925 } |
| 1933 m_pPageSetLayoutItemRoot = NULL; | 1926 m_pPageSetLayoutItemRoot = NULL; |
| 1934 } | 1927 } |
| OLD | NEW |