diff options
Diffstat (limited to 'xfa')
-rw-r--r-- | xfa/fxfa/parser/cxfa_layoutpagemgr.cpp | 43 |
1 files changed, 24 insertions, 19 deletions
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<CXFA_ContainerLayoutItem*>(pLayoutItem->m_pFirstChild); - while (pChildItem && pChildItem->GetFormNode()->GetElementType() != - XFA_Element::PageSet) { - pChildItem = - static_cast<CXFA_ContainerLayoutItem*>(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<CXFA_ContainerLayoutItem*>(pLayoutItem->m_pNextSibling); - while (pChildItem && pChildItem->GetFormNode()->GetElementType() != - XFA_Element::PageSet) { - pChildItem = - static_cast<CXFA_ContainerLayoutItem*>(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<CXFA_ContainerLayoutItem*>(pLayoutItem->m_pParent); + return ToContainerLayoutItem(pLayoutItem->m_pParent); } }; +using PageSetIterator = CXFA_NodeIteratorTemplate<CXFA_ContainerLayoutItem, + TraverseStrategy_PageSet>; + 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<CXFA_ContainerLayoutItem*>( pRootPageSetLayoutItem->m_pNextSibling)) { - CXFA_NodeIteratorTemplate<CXFA_ContainerLayoutItem, - PageSetContainerLayoutItem> - sIterator(pRootPageSetLayoutItem); + PageSetIterator sIterator(pRootPageSetLayoutItem); for (CXFA_ContainerLayoutItem* pPageSetLayoutItem = sIterator.GetCurrent(); pPageSetLayoutItem; pPageSetLayoutItem = sIterator.MoveToNext()) { XFA_AttributeEnum ePageRelation = |