From 6d04ae0a1cc04141564b2a26da887c6a84d0882c Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Tue, 28 Mar 2017 10:03:00 -0700 Subject: Remove CFX_ArrayTemplate from xfa_layoutpagemgr.cpp Change-Id: I0956ecff82a11376a3d7b9176b4a13ee4e707cc3 Reviewed-on: https://pdfium-review.googlesource.com/3241 Reviewed-by: dsinclair Commit-Queue: dsinclair --- xfa/fxfa/parser/cxfa_layoutpagemgr.cpp | 27 +++++++++++++-------------- xfa/fxfa/parser/cxfa_layoutpagemgr.h | 3 ++- 2 files changed, 15 insertions(+), 15 deletions(-) (limited to 'xfa') diff --git a/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp b/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp index 7b4cf2651a..a0d67d2053 100644 --- a/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp +++ b/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp @@ -553,17 +553,16 @@ CXFA_ContainerRecord* CXFA_LayoutPageMgr::CreateContainerRecord( void CXFA_LayoutPageMgr::AddPageAreaLayoutItem(CXFA_ContainerRecord* pNewRecord, CXFA_Node* pNewPageArea) { CXFA_ContainerLayoutItem* pNewPageAreaLayoutItem = nullptr; - if (m_PageArray.GetSize() > m_nAvailPages) { + if (pdfium::IndexInBounds(m_PageArray, m_nAvailPages)) { CXFA_ContainerLayoutItem* pContainerItem = m_PageArray[m_nAvailPages]; pContainerItem->m_pFormNode = pNewPageArea; m_nAvailPages++; pNewPageAreaLayoutItem = pContainerItem; } else { CXFA_FFNotify* pNotify = pNewPageArea->GetDocument()->GetNotify(); - CXFA_ContainerLayoutItem* pContainerItem = - static_cast( - pNotify->OnCreateLayoutItem(pNewPageArea)); - m_PageArray.Add(pContainerItem); + auto* pContainerItem = static_cast( + pNotify->OnCreateLayoutItem(pNewPageArea)); + m_PageArray.push_back(pContainerItem); m_nAvailPages++; pNotify->OnPageEvent(pContainerItem, XFA_PAGEVIEWEVENT_PostRemoved); pNewPageAreaLayoutItem = pContainerItem; @@ -648,7 +647,7 @@ void CXFA_LayoutPageMgr::FinishPaginatedPageSets() { } } bool bUsable = true; - CFX_ArrayTemplate rgUsedHeights; + std::vector rgUsedHeights; for (CXFA_LayoutItem* pChildLayoutItem = pLastPageAreaLayoutItem->m_pFirstChild; pChildLayoutItem; @@ -668,7 +667,7 @@ void CXFA_LayoutPageMgr::FinishPaginatedPageSets() { fUsedHeight += pContent->m_sSize.height; } } - rgUsedHeights.Add(fUsedHeight); + rgUsedHeights.push_back(fUsedHeight); } int32_t iCurContentAreaIndex = -1; for (CXFA_Node* pContentAreaNode = @@ -724,19 +723,19 @@ void CXFA_LayoutPageMgr::FinishPaginatedPageSets() { } int32_t CXFA_LayoutPageMgr::GetPageCount() const { - return m_PageArray.GetSize(); + return pdfium::CollectionSize(m_PageArray); } CXFA_ContainerLayoutItem* CXFA_LayoutPageMgr::GetPage(int32_t index) const { - if (index < 0 || index >= m_PageArray.GetSize()) + if (!pdfium::IndexInBounds(m_PageArray, index)) return nullptr; return m_PageArray[index]; } int32_t CXFA_LayoutPageMgr::GetPageIndex( const CXFA_ContainerLayoutItem* pPage) const { - // FIXME: Find() method should take const. - return m_PageArray.Find(const_cast(pPage)); + auto it = std::find(m_PageArray.begin(), m_PageArray.end(), pPage); + return it != m_PageArray.end() ? it - m_PageArray.begin() : -1; } bool CXFA_LayoutPageMgr::RunBreak(XFA_Element eBreakType, @@ -1923,10 +1922,10 @@ void CXFA_LayoutPageMgr::SyncLayoutData() { } } - int32_t nPage = m_PageArray.GetSize(); + int32_t nPage = pdfium::CollectionSize(m_PageArray); for (int32_t i = nPage - 1; i >= m_nAvailPages; i--) { CXFA_ContainerLayoutItem* pPage = m_PageArray[i]; - m_PageArray.RemoveAt(i); + m_PageArray.erase(m_PageArray.begin() + i); pNotify->OnPageEvent(pPage, XFA_PAGEVIEWEVENT_PostRemoved); delete pPage; } @@ -1963,7 +1962,7 @@ void CXFA_LayoutPageMgr::PrepareLayout() { m_pPageSetLayoutItemRoot = nullptr; pRootLayoutItem = nullptr; pPageSetFormNode = nullptr; - m_PageArray.RemoveAll(); + m_PageArray.clear(); } while (pPageSetFormNode) { CXFA_Node* pNextPageSet = diff --git a/xfa/fxfa/parser/cxfa_layoutpagemgr.h b/xfa/fxfa/parser/cxfa_layoutpagemgr.h index ae967b55c0..7428374ae0 100644 --- a/xfa/fxfa/parser/cxfa_layoutpagemgr.h +++ b/xfa/fxfa/parser/cxfa_layoutpagemgr.h @@ -10,6 +10,7 @@ #include #include #include +#include #include "xfa/fxfa/parser/xfa_layout_itemlayout.h" @@ -140,7 +141,7 @@ class CXFA_LayoutPageMgr { XFA_ATTRIBUTEENUM m_ePageSetMode; bool m_bCreateOverFlowPage; std::map m_pPageSetMap; - CFX_ArrayTemplate m_PageArray; + std::vector m_PageArray; }; #endif // XFA_FXFA_PARSER_CXFA_LAYOUTPAGEMGR_H_ -- cgit v1.2.3