From 56094c50c0da84258e6d4348a860e588114e590d Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Wed, 1 Aug 2018 16:30:14 +0000 Subject: Rename PageSetContainerLayoutItem to TraverseStrategy_PageSet. Provides consistency with the naming of other traverse strategies. Fix dubious casting inside the strategy. Change-Id: Ic96b1922ae1dc601a37c8c3b3dd0f118ab6b2eea Reviewed-on: https://pdfium-review.googlesource.com/39210 Reviewed-by: Lei Zhang Commit-Queue: Tom Sepez --- xfa/fxfa/parser/cxfa_layoutpagemgr.cpp | 43 +++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 19 deletions(-) (limited to 'xfa') diff --git a/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp b/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp index 411ad24e45..d1106ffae6 100644 --- a/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp +++ b/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp @@ -34,41 +34,48 @@ namespace { -class PageSetContainerLayoutItem { +class TraverseStrategy_PageSet { public: static CXFA_ContainerLayoutItem* GetFirstChild( CXFA_ContainerLayoutItem* pLayoutItem) { if (pLayoutItem->GetFormNode()->GetElementType() != XFA_Element::PageSet) return nullptr; - CXFA_ContainerLayoutItem* pChildItem = - static_cast(pLayoutItem->m_pFirstChild); - while (pChildItem && pChildItem->GetFormNode()->GetElementType() != - XFA_Element::PageSet) { - pChildItem = - static_cast(pChildItem->m_pNextSibling); + for (CXFA_LayoutItem* pChildItem = pLayoutItem->m_pFirstChild; pChildItem; + pChildItem = pChildItem->m_pNextSibling) { + CXFA_ContainerLayoutItem* pContainer = + pChildItem->AsContainerLayoutItem(); + if (pContainer && + pContainer->GetFormNode()->GetElementType() == XFA_Element::PageSet) { + return pContainer; + } } - return pChildItem; + return nullptr; } static CXFA_ContainerLayoutItem* GetNextSibling( CXFA_ContainerLayoutItem* pLayoutItem) { - CXFA_ContainerLayoutItem* pChildItem = - static_cast(pLayoutItem->m_pNextSibling); - while (pChildItem && pChildItem->GetFormNode()->GetElementType() != - XFA_Element::PageSet) { - pChildItem = - static_cast(pChildItem->m_pNextSibling); + for (CXFA_LayoutItem* pChildItem = pLayoutItem->m_pNextSibling; pChildItem; + pChildItem = pChildItem->m_pNextSibling) { + CXFA_ContainerLayoutItem* pContainer = + pChildItem->AsContainerLayoutItem(); + if (pContainer && + pContainer->GetFormNode()->GetElementType() == XFA_Element::PageSet) { + return pContainer; + } } - return pChildItem; + return nullptr; } static CXFA_ContainerLayoutItem* GetParent( CXFA_ContainerLayoutItem* pLayoutItem) { - return static_cast(pLayoutItem->m_pParent); + return ToContainerLayoutItem(pLayoutItem->m_pParent); } }; +using PageSetIterator = CXFA_NodeIteratorTemplate; + uint32_t GetRelevant(CXFA_Node* pFormItem, uint32_t dwParentRelvant) { uint32_t dwRelevant = XFA_WidgetStatus_Viewable | XFA_WidgetStatus_Printable; WideString wsRelevant = @@ -613,9 +620,7 @@ void CXFA_LayoutPageMgr::FinishPaginatedPageSets() { for (; pRootPageSetLayoutItem; pRootPageSetLayoutItem = static_cast( pRootPageSetLayoutItem->m_pNextSibling)) { - CXFA_NodeIteratorTemplate - sIterator(pRootPageSetLayoutItem); + PageSetIterator sIterator(pRootPageSetLayoutItem); for (CXFA_ContainerLayoutItem* pPageSetLayoutItem = sIterator.GetCurrent(); pPageSetLayoutItem; pPageSetLayoutItem = sIterator.MoveToNext()) { XFA_AttributeEnum ePageRelation = -- cgit v1.2.3