sw/source/uibase/utlui/content.cxx |   22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)

New commits:
commit 13df3777e4b6ff7537692b396be67a5fd2b9b001
Author: Michael Stahl <[email protected]>
Date:   Fri Sep 29 22:03:25 2017 +0200

    sw: SwContentTree: use the helper functions instead of manual checks
    
    Change-Id: I93b40f5f5b493688b27747ba8ccb65097638e4e6

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<SwTypeNumber*>(static_cast<SwTypeNumber*>(pParent->GetUserData())));
     if (!m_bIsRoot
-        || (static_cast<SwTypeNumber*>(pParent->GetUserData())->GetTypeId() == 
CTYPE_CTT && static_cast<SwContentType*>(pParent->GetUserData())->GetType() == 
ContentTypeId::OUTLINE)
+        || (lcl_IsContentType(pParent) && 
static_cast<SwContentType*>(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<SwTypeNumber*>(static_cast<SwTypeNumber*>(pParent->GetUserData())));
     if (!m_bIsRoot
-        || (static_cast<SwTypeNumber*>(pParent->GetUserData())->GetTypeId() == 
CTYPE_CTT && static_cast<SwContentType*>(pParent->GetUserData())->GetType() == 
ContentTypeId::OUTLINE)
+        || (lcl_IsContentType(pParent) && 
static_cast<SwContentType*>(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<SwOutlineContent*>(
                         pCurrentEntry->GetUserData())->GetOutlineLevel();
                 pEntry = Next(pEntry);
-                while (pEntry && CTYPE_CNT ==
-                    
static_cast<SwTypeNumber*>(pEntry->GetUserData())->GetTypeId())
+                while (pEntry && lcl_IsContent(pEntry))
                 {
                     
assert(dynamic_cast<SwOutlineContent*>(static_cast<SwTypeNumber*>(pEntry->GetUserData())));
                     if (nActLevel >= 
static_cast<SwOutlineContent*>(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<SwTypeNumber*>(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<SwTypeNumber*>(pEntry->GetUserData()));
+                            assert(pEntry == nullptr || !lcl_IsContent(pEntry) 
|| 
dynamic_cast<SwOutlineContent*>(static_cast<SwTypeNumber*>(pEntry->GetUserData())));
                             // nDest++ may only executed if pEntry != 0
                             if (pEntry && nDest++ &&
-                                (CTYPE_CNT != 
static_cast<SwTypeNumber*>(pEntry->GetUserData())->GetTypeId()
+                                (!lcl_IsContent(pEntry)
                                  || nActLevel >= 
static_cast<SwOutlineContent*>(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<SwTypeNumber*>(pEntry->GetUserData()));
+                        assert(pEntry == nullptr || !lcl_IsContent(pEntry) || 
dynamic_cast<SwOutlineContent*>(static_cast<SwTypeNumber*>(pEntry->GetUserData())));
                         if (pEntry &&
-                            (CTYPE_CNT != 
static_cast<SwTypeNumber*>(pEntry->GetUserData())->GetTypeId()
+                            (!lcl_IsContent(pEntry)
                              || nActLevel >= 
static_cast<SwOutlineContent*>(pEntry->GetUserData())->GetOutlineLevel()))
                         {
                             break;
commit 8b2619177c16058ae9994d5e39f04a813bacd061
Author: Michael Stahl <[email protected]>
Date:   Fri Sep 29 21:37:25 2017 +0200

    tdf#112732 sw: fix conditions in SwContentTree::ExecCommand()
    
    It has to be checked first that it's a CTYPE_CNT because otherwise
    it's not a SwOutlineContent.
    
    The assertion also didn't match the actual requirement.
    
    Change-Id: I7fc3a6410f5de1e6b4c18965fff9bd9700562ed1

diff --git a/sw/source/uibase/utlui/content.cxx 
b/sw/source/uibase/utlui/content.cxx
index 2c9301d212eb..d78a08e2b5e8 100644
--- a/sw/source/uibase/utlui/content.cxx
+++ b/sw/source/uibase/utlui/content.cxx
@@ -2442,11 +2442,11 @@ void SwContentTree::ExecCommand(const OUString& rCmd, 
bool bOutlineWithChildren)
                         while (pEntry)
                         {
                             pEntry = Next(pEntry);
-                            assert(pEntry == nullptr || 
dynamic_cast<SwOutlineContent*>(static_cast<SwTypeNumber*>(pEntry->GetUserData())));
+                            assert(pEntry == nullptr || 
static_cast<SwTypeNumber*>(pEntry->GetUserData()));
                             // nDest++ may only executed if pEntry != 0
                             if (pEntry && nDest++ &&
-                                (nActLevel >= 
static_cast<SwOutlineContent*>(pEntry->GetUserData())->GetOutlineLevel() ||
-                                 CTYPE_CNT != 
static_cast<SwTypeNumber*>(pEntry->GetUserData())->GetTypeId()))
+                                (CTYPE_CNT != 
static_cast<SwTypeNumber*>(pEntry->GetUserData())->GetTypeId()
+                                 || nActLevel >= 
static_cast<SwOutlineContent*>(pEntry->GetUserData())->GetOutlineLevel()))
                             {
                                 nDest--;
                                 break;
@@ -2467,10 +2467,10 @@ void SwContentTree::ExecCommand(const OUString& rCmd, 
bool bOutlineWithChildren)
                     {
                         nDest--;
                         pEntry = Prev(pEntry);
-                        assert(pEntry == nullptr || 
dynamic_cast<SwOutlineContent*>(static_cast<SwTypeNumber*>(pEntry->GetUserData())));
+                        assert(pEntry == nullptr || 
static_cast<SwTypeNumber*>(pEntry->GetUserData()));
                         if (pEntry &&
-                            (nActLevel >= 
static_cast<SwOutlineContent*>(pEntry->GetUserData())->GetOutlineLevel() ||
-                             CTYPE_CNT != 
static_cast<SwTypeNumber*>(pEntry->GetUserData())->GetTypeId()))
+                            (CTYPE_CNT != 
static_cast<SwTypeNumber*>(pEntry->GetUserData())->GetTypeId()
+                             || nActLevel >= 
static_cast<SwOutlineContent*>(pEntry->GetUserData())->GetOutlineLevel()))
                         {
                             break;
                         }
_______________________________________________
Libreoffice-commits mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to