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 397 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 1070 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, TRUE, FALSE); |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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->SetFlag(XFA_NODEFLAG_UnusedNode, FALSE); |
1762 pNode->SetFlag(XFA_NODEFLAG_Initialized); | 1756 pNode->SetFlag(XFA_NODEFLAG_Initialized); |
1763 pNode = sIterator.MoveToNext(); | 1757 pNode = sIterator.MoveToNext(); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1807 pContainerItem->m_pFormNode->GetEnum(XFA_ATTRIBUTE_Presence); | 1801 pContainerItem->m_pFormNode->GetEnum(XFA_ATTRIBUTE_Presence); |
1808 if (eAttributeValue == XFA_ATTRIBUTEENUM_Visible || | 1802 if (eAttributeValue == XFA_ATTRIBUTEENUM_Visible || |
1809 eAttributeValue == XFA_ATTRIBUTEENUM_Unknown) { | 1803 eAttributeValue == XFA_ATTRIBUTEENUM_Unknown) { |
1810 bVisibleItem = TRUE; | 1804 bVisibleItem = TRUE; |
1811 } | 1805 } |
1812 dwRelevantContainer = | 1806 dwRelevantContainer = |
1813 XFA_GetRelevant(pContainerItem->m_pFormNode, dwRelevant); | 1807 XFA_GetRelevant(pContainerItem->m_pFormNode, dwRelevant); |
1814 dwStatus = | 1808 dwStatus = |
1815 (bVisibleItem ? XFA_LAYOUTSTATUS_Visible : 0) | dwRelevantContainer; | 1809 (bVisibleItem ? XFA_LAYOUTSTATUS_Visible : 0) | dwRelevantContainer; |
1816 } | 1810 } |
1817 pNotify->OnLayoutEvent(pDocLayout, pContainerItem, XFA_LAYOUTEVENT_ItemAdded, | 1811 pNotify->OnLayoutItemAdd(pDocLayout, pContainerItem, nPageIndex, dwStatus); |
1818 (void*)(uintptr_t)nPageIndex, | |
1819 (void*)(uintptr_t)dwStatus); | |
1820 for (CXFA_LayoutItem* pChild = pContainerItem->m_pFirstChild; pChild; | 1812 for (CXFA_LayoutItem* pChild = pContainerItem->m_pFirstChild; pChild; |
1821 pChild = pChild->m_pNextSibling) { | 1813 pChild = pChild->m_pNextSibling) { |
1822 if (pChild->IsContentLayoutItem()) { | 1814 if (pChild->IsContentLayoutItem()) { |
1823 XFA_SyncContainer(pNotify, pDocLayout, pChild, dwRelevantContainer, | 1815 XFA_SyncContainer(pNotify, pDocLayout, pChild, dwRelevantContainer, |
1824 bVisibleItem, nPageIndex); | 1816 bVisibleItem, nPageIndex); |
1825 } | 1817 } |
1826 } | 1818 } |
1827 } | 1819 } |
1828 void CXFA_LayoutPageMgr::SyncLayoutData() { | 1820 void CXFA_LayoutPageMgr::SyncLayoutData() { |
1829 MergePageSetContents(); | 1821 MergePageSetContents(); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1869 } break; | 1861 } break; |
1870 default: | 1862 default: |
1871 break; | 1863 break; |
1872 } | 1864 } |
1873 } | 1865 } |
1874 } | 1866 } |
1875 int32_t nPage = m_PageArray.GetSize(); | 1867 int32_t nPage = m_PageArray.GetSize(); |
1876 for (int32_t i = nPage - 1; i >= m_nAvailPages; i--) { | 1868 for (int32_t i = nPage - 1; i >= m_nAvailPages; i--) { |
1877 CXFA_ContainerLayoutItem* pPage = m_PageArray[i]; | 1869 CXFA_ContainerLayoutItem* pPage = m_PageArray[i]; |
1878 m_PageArray.RemoveAt(i); | 1870 m_PageArray.RemoveAt(i); |
1879 pNotify->OnPageEvent(pPage, XFA_PAGEEVENT_PageRemoved); | 1871 pNotify->OnPageEvent(pPage, XFA_PAGEVIEWEVENT_PostRemoved); |
1880 delete pPage; | 1872 delete pPage; |
1881 } | 1873 } |
1882 ClearRecordList(); | 1874 ClearRecordList(); |
1883 } | 1875 } |
1884 void XFA_ReleaseLayoutItem_NoPageArea(CXFA_LayoutItem* pLayoutItem) { | 1876 void XFA_ReleaseLayoutItem_NoPageArea(CXFA_LayoutItem* pLayoutItem) { |
1885 CXFA_LayoutItem *pNext, *pNode = pLayoutItem->m_pFirstChild; | 1877 CXFA_LayoutItem *pNext, *pNode = pLayoutItem->m_pFirstChild; |
1886 while (pNode) { | 1878 while (pNode) { |
1887 pNext = pNode->m_pNextSibling; | 1879 pNext = pNode->m_pNextSibling; |
1888 pNode->m_pParent = NULL; | 1880 pNode->m_pParent = NULL; |
1889 XFA_ReleaseLayoutItem_NoPageArea(pNode); | 1881 XFA_ReleaseLayoutItem_NoPageArea(pNode); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1925 } | 1917 } |
1926 pRootLayoutItem = m_pPageSetLayoutItemRoot; | 1918 pRootLayoutItem = m_pPageSetLayoutItemRoot; |
1927 CXFA_ContainerLayoutItem* pNextLayout = NULL; | 1919 CXFA_ContainerLayoutItem* pNextLayout = NULL; |
1928 for (; pRootLayoutItem; pRootLayoutItem = pNextLayout) { | 1920 for (; pRootLayoutItem; pRootLayoutItem = pNextLayout) { |
1929 pNextLayout = (CXFA_ContainerLayoutItem*)pRootLayoutItem->m_pNextSibling; | 1921 pNextLayout = (CXFA_ContainerLayoutItem*)pRootLayoutItem->m_pNextSibling; |
1930 SaveLayoutItem(pRootLayoutItem); | 1922 SaveLayoutItem(pRootLayoutItem); |
1931 delete pRootLayoutItem; | 1923 delete pRootLayoutItem; |
1932 } | 1924 } |
1933 m_pPageSetLayoutItemRoot = NULL; | 1925 m_pPageSetLayoutItemRoot = NULL; |
1934 } | 1926 } |
OLD | NEW |