From 13df3777e4b6ff7537692b396be67a5fd2b9b001 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 29 Sep 2017 22:03:25 +0200 Subject: sw: SwContentTree: use the helper functions instead of manual checks Change-Id: I93b40f5f5b493688b27747ba8ccb65097638e4e6 --- sw/source/uibase/utlui/content.cxx | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/sw/source/uibase/utlui/content.cxx b/sw/source/uibase/utlui/content.cxx index d78a08e2b5e8..c7df4cc80f9f 100644 --- a/sw/source/uibase/utlui/content.cxx +++ b/sw/source/uibase/utlui/content.cxx @@ -1449,7 +1449,7 @@ bool SwContentTree::Expand( SvTreeListEntry* pParent ) { assert(!m_bIsRoot || dynamic_cast(static_cast(pParent->GetUserData()))); if (!m_bIsRoot - || (static_cast(pParent->GetUserData())->GetTypeId() == CTYPE_CTT && static_cast(pParent->GetUserData())->GetType() == ContentTypeId::OUTLINE) + || (lcl_IsContentType(pParent) && static_cast(pParent->GetUserData())->GetType() == ContentTypeId::OUTLINE) || (m_nRootType == ContentTypeId::OUTLINE)) { if(lcl_IsContentType(pParent)) @@ -1508,7 +1508,7 @@ bool SwContentTree::Collapse( SvTreeListEntry* pParent ) { assert(!m_bIsRoot || dynamic_cast(static_cast(pParent->GetUserData()))); if (!m_bIsRoot - || (static_cast(pParent->GetUserData())->GetTypeId() == CTYPE_CTT && static_cast(pParent->GetUserData())->GetType() == ContentTypeId::OUTLINE) + || (lcl_IsContentType(pParent) && static_cast(pParent->GetUserData())->GetType() == ContentTypeId::OUTLINE) || (m_nRootType == ContentTypeId::OUTLINE)) { if(lcl_IsContentType(pParent)) @@ -2418,8 +2418,7 @@ void SwContentTree::ExecCommand(const OUString& rCmd, bool bOutlineWithChildren) const auto nActLevel = static_cast( pCurrentEntry->GetUserData())->GetOutlineLevel(); pEntry = Next(pEntry); - while (pEntry && CTYPE_CNT == - static_cast(pEntry->GetUserData())->GetTypeId()) + while (pEntry && lcl_IsContent(pEntry)) { assert(dynamic_cast(static_cast(pEntry->GetUserData()))); if (nActLevel >= static_cast(pEntry->GetUserData())->GetOutlineLevel()) @@ -2431,8 +2430,7 @@ void SwContentTree::ExecCommand(const OUString& rCmd, bool bOutlineWithChildren) if (nDir == 1) { // If the last entry is to be moved we're done - if (pEntry && CTYPE_CNT == - static_cast(pEntry->GetUserData())->GetTypeId()) + if (pEntry && lcl_IsContent(pEntry)) { // pEntry now points to the entry following the last // selected entry. @@ -2442,10 +2440,10 @@ void SwContentTree::ExecCommand(const OUString& rCmd, bool bOutlineWithChildren) while (pEntry) { pEntry = Next(pEntry); - assert(pEntry == nullptr || static_cast(pEntry->GetUserData())); + assert(pEntry == nullptr || !lcl_IsContent(pEntry) || dynamic_cast(static_cast(pEntry->GetUserData()))); // nDest++ may only executed if pEntry != 0 if (pEntry && nDest++ && - (CTYPE_CNT != static_cast(pEntry->GetUserData())->GetTypeId() + (!lcl_IsContent(pEntry) || nActLevel >= static_cast(pEntry->GetUserData())->GetOutlineLevel())) { nDest--; @@ -2467,9 +2465,9 @@ void SwContentTree::ExecCommand(const OUString& rCmd, bool bOutlineWithChildren) { nDest--; pEntry = Prev(pEntry); - assert(pEntry == nullptr || static_cast(pEntry->GetUserData())); + assert(pEntry == nullptr || !lcl_IsContent(pEntry) || dynamic_cast(static_cast(pEntry->GetUserData()))); if (pEntry && - (CTYPE_CNT != static_cast(pEntry->GetUserData())->GetTypeId() + (!lcl_IsContent(pEntry) || nActLevel >= static_cast(pEntry->GetUserData())->GetOutlineLevel())) { break; -- cgit