[Libreoffice-commits] core.git: 2 commits - sw/source

Caolán McNamara caolanm at redhat.com
Wed Feb 1 10:11:51 UTC 2017


 sw/source/uibase/utlui/content.cxx |  128 +++++++++++++++++--------------------
 1 file changed, 61 insertions(+), 67 deletions(-)

New commits:
commit dfdd01d12226cfbd9b9d2618bd9da71191bfc4b9
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Wed Feb 1 10:08:47 2017 +0000

    with navigator in sidebar, press space, crash
    
    because root entries have UserData of type SwContentType while children have
    UserData of type SwContent (both inherit from SwTypeNumber)
    
    Change-Id: Iab7a4caaca5dfdae16aa4f6ede565e26aa4c73c9

diff --git a/sw/source/uibase/utlui/content.cxx b/sw/source/uibase/utlui/content.cxx
index d1eba7a..302b46a 100644
--- a/sw/source/uibase/utlui/content.cxx
+++ b/sw/source/uibase/utlui/content.cxx
@@ -2762,10 +2762,9 @@ void SwContentTree::KeyInput(const KeyEvent& rEvent)
                     m_pActiveShell->GetView().GetViewFrame()->GetWindow().ToTop();
                 }
 
-                assert(dynamic_cast<SwContent*>(static_cast<SwTypeNumber*>(pEntry->GetUserData())));
-                SwContent* pCnt = static_cast<SwContent*>(pEntry->GetUserData());
+                SwContent* pCnt = dynamic_cast<SwContent*>(static_cast<SwTypeNumber*>(pEntry->GetUserData()));
 
-                if (pCnt->GetParent()->GetType() == ContentTypeId::DRAWOBJECT)
+                if (pCnt && pCnt->GetParent()->GetType() == ContentTypeId::DRAWOBJECT)
                 {
                     SdrView* pDrawView = m_pActiveShell->GetDrawView();
                     if (pDrawView)
commit 567cd9043c09e42d8521a6b81545994ae4539beb
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Wed Feb 1 10:06:53 2017 +0000

    turn switch with one case into if
    
    Change-Id: I413f195bb5571eb536e948a7e9ffb982b3619e65

diff --git a/sw/source/uibase/utlui/content.cxx b/sw/source/uibase/utlui/content.cxx
index fb66dea..d1eba7a 100644
--- a/sw/source/uibase/utlui/content.cxx
+++ b/sw/source/uibase/utlui/content.cxx
@@ -2765,84 +2765,79 @@ void SwContentTree::KeyInput(const KeyEvent& rEvent)
                 assert(dynamic_cast<SwContent*>(static_cast<SwTypeNumber*>(pEntry->GetUserData())));
                 SwContent* pCnt = static_cast<SwContent*>(pEntry->GetUserData());
 
-                switch(pCnt->GetParent()->GetType())
+                if (pCnt->GetParent()->GetType() == ContentTypeId::DRAWOBJECT)
                 {
-                    case ContentTypeId::DRAWOBJECT:
+                    SdrView* pDrawView = m_pActiveShell->GetDrawView();
+                    if (pDrawView)
                     {
-                        SdrView* pDrawView = m_pActiveShell->GetDrawView();
-                        if (pDrawView)
-                        {
-                            pDrawView->SdrEndTextEdit();//Change from "EndTextEdit" to "SdrEndTextEdit" for acc migration
+                        pDrawView->SdrEndTextEdit();//Change from "EndTextEdit" to "SdrEndTextEdit" for acc migration
 
-                            SwDrawModel* pDrawModel = m_pActiveShell->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel();
-                            SdrPage* pPage = pDrawModel->GetPage(0);
-                            const size_t nCount = pPage->GetObjCount();
-                            bool hasObjectMarked = false;
+                        SwDrawModel* pDrawModel = m_pActiveShell->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel();
+                        SdrPage* pPage = pDrawModel->GetPage(0);
+                        const size_t nCount = pPage->GetObjCount();
+                        bool hasObjectMarked = false;
 
-                            SdrObject* pObject = nullptr;
-                            pObject = GetDrawingObjectsByContent( pCnt );
-                            if( pObject )
+                        SdrObject* pObject = nullptr;
+                        pObject = GetDrawingObjectsByContent( pCnt );
+                        if( pObject )
+                        {
+                            SdrPageView* pPV = pDrawView->GetSdrPageView/*GetPageViewPvNum*/(/*0*/);
+                            if( pPV )
                             {
-                                SdrPageView* pPV = pDrawView->GetSdrPageView/*GetPageViewPvNum*/(/*0*/);
-                                if( pPV )
-                                {
-                                    bool bUnMark = pDrawView->IsObjMarked(pObject);
-                                    pDrawView->MarkObj( pObject, pPV, bUnMark);
+                                bool bUnMark = pDrawView->IsObjMarked(pObject);
+                                pDrawView->MarkObj( pObject, pPV, bUnMark);
 
-                                }
                             }
-                            for( size_t i=0; i<nCount; ++i )
+                        }
+                        for( size_t i=0; i<nCount; ++i )
+                        {
+                            SdrObject* pTemp = pPage->GetObj(i);
+                            bool bMark = pDrawView->IsObjMarked(pTemp);
+                            switch( pTemp->GetObjIdentifier() )
                             {
-                                SdrObject* pTemp = pPage->GetObj(i);
-                                bool bMark = pDrawView->IsObjMarked(pTemp);
-                                switch( pTemp->GetObjIdentifier() )
-                                {
-                                    case OBJ_GRUP:
-                                    case OBJ_TEXT:
-                                    case OBJ_TEXTEXT:
-                                    case OBJ_wegFITTEXT:
-                                    case OBJ_LINE:
-                                    case OBJ_RECT:
-                                    case OBJ_CIRC:
-                                    case OBJ_SECT:
-                                    case OBJ_CARC:
-                                    case OBJ_CCUT:
-                                    case OBJ_POLY:
-                                    case OBJ_PLIN:
-                                    case OBJ_PATHLINE:
-                                    case OBJ_PATHFILL:
-                                    case OBJ_FREELINE:
-                                    case OBJ_FREEFILL:
-                                    case OBJ_PATHPOLY:
-                                    case OBJ_PATHPLIN:
-                                    case OBJ_CAPTION:
-                                    case OBJ_CUSTOMSHAPE:
-                                        if( bMark )
-                                            hasObjectMarked = true;
-                                        break;
-                                    default:
-                                        if ( bMark )
+                                case OBJ_GRUP:
+                                case OBJ_TEXT:
+                                case OBJ_TEXTEXT:
+                                case OBJ_wegFITTEXT:
+                                case OBJ_LINE:
+                                case OBJ_RECT:
+                                case OBJ_CIRC:
+                                case OBJ_SECT:
+                                case OBJ_CARC:
+                                case OBJ_CCUT:
+                                case OBJ_POLY:
+                                case OBJ_PLIN:
+                                case OBJ_PATHLINE:
+                                case OBJ_PATHFILL:
+                                case OBJ_FREELINE:
+                                case OBJ_FREEFILL:
+                                case OBJ_PATHPOLY:
+                                case OBJ_PATHPLIN:
+                                case OBJ_CAPTION:
+                                case OBJ_CUSTOMSHAPE:
+                                    if( bMark )
+                                        hasObjectMarked = true;
+                                    break;
+                                default:
+                                    if ( bMark )
+                                    {
+                                        SdrPageView* pPV = pDrawView->GetSdrPageView/*GetPageViewPvNum*/(/*0*/);
+                                        if (pPV)
                                         {
-                                            SdrPageView* pPV = pDrawView->GetSdrPageView/*GetPageViewPvNum*/(/*0*/);
-                                            if (pPV)
-                                            {
-                                                pDrawView->MarkObj(pTemp, pPV, true);
-                                            }
+                                            pDrawView->MarkObj(pTemp, pPV, true);
                                         }
-                                }
-                                //mod end
-                            }
-                            if ( !hasObjectMarked )
-                            {
-                                SwEditWin& rEditWindow = m_pActiveShell->GetView().GetEditWin();
-                                vcl::KeyCode tempKeycode( KEY_ESCAPE );
-                                KeyEvent rKEvt( 0 , tempKeycode );
-                                static_cast<vcl::Window*>(&rEditWindow)->KeyInput( rKEvt );
+                                    }
                             }
+                            //mod end
+                        }
+                        if ( !hasObjectMarked )
+                        {
+                            SwEditWin& rEditWindow = m_pActiveShell->GetView().GetEditWin();
+                            vcl::KeyCode tempKeycode( KEY_ESCAPE );
+                            KeyEvent rKEvt( 0 , tempKeycode );
+                            static_cast<vcl::Window*>(&rEditWindow)->KeyInput( rKEvt );
                         }
                     }
-                    break;
-                    default: break;
                 }
 
                 m_bViewHasChanged = true;


More information about the Libreoffice-commits mailing list