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

Jan Holesovsky kendy at collabora.com
Wed Aug 24 20:27:49 UTC 2016


 sw/source/uibase/docvw/edtwin3.cxx  |   59 ++++++++++++++++++++----------------
 sw/source/uibase/docvw/srcedtw.cxx  |    8 ++--
 sw/source/uibase/ribbar/conrect.cxx |   21 +++++++-----
 3 files changed, 49 insertions(+), 39 deletions(-)

New commits:
commit e139edfa1df7e7353b420be20d298fd2882d9289
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Mon Aug 8 10:32:31 2016 +0200

    Simplify dynamic_cast followed by a static_cast.
    
    Change-Id: I258906a66f83f5b9b63bd034a22bad3648117819

diff --git a/sw/source/uibase/docvw/edtwin3.cxx b/sw/source/uibase/docvw/edtwin3.cxx
index 52c56de..b059ca3 100644
--- a/sw/source/uibase/docvw/edtwin3.cxx
+++ b/sw/source/uibase/docvw/edtwin3.cxx
@@ -40,47 +40,51 @@
 void ScrollMDI( SwViewShell* pVwSh, const SwRect &rRect,
                 sal_uInt16 nRangeX, sal_uInt16 nRangeY)
 {
-    SfxViewShell *pSfxVwSh = pVwSh->GetSfxViewShell();
-    if (pSfxVwSh && dynamic_cast< const SwView *>( pSfxVwSh ) !=  nullptr)
-        static_cast<SwView *>(pSfxVwSh)->Scroll( rRect.SVRect(), nRangeX, nRangeY );
+    SfxViewShell *pSfxViewShell = pVwSh->GetSfxViewShell();
+
+    if (SwView* pSwView = dynamic_cast<SwView *>(pSfxViewShell))
+        pSwView->Scroll(rRect.SVRect(), nRangeX, nRangeY);
 }
 
 // Docmdi - movable
 bool IsScrollMDI( SwViewShell* pVwSh, const SwRect &rRect )
 {
-    SfxViewShell *pSfxVwSh = pVwSh->GetSfxViewShell();
-    if (pSfxVwSh && dynamic_cast< const SwView *>( pSfxVwSh ) !=  nullptr)
-        return static_cast<SwView *>(pSfxVwSh)->IsScroll(rRect.SVRect());
+    SfxViewShell *pSfxViewShell = pVwSh->GetSfxViewShell();
+
+    if (SwView* pSwView = dynamic_cast<SwView *>(pSfxViewShell))
+        return pSwView->IsScroll(rRect.SVRect());
+
     return false;
 }
 
 // Notify for size change
 void SizeNotify(SwViewShell* pVwSh, const Size &rSize)
 {
-    SfxViewShell *pSfxVwSh = pVwSh->GetSfxViewShell();
-    if (pSfxVwSh)
-    {
-        if (dynamic_cast< const SwView *>( pSfxVwSh ) !=  nullptr)
-            static_cast<SwView *>(pSfxVwSh)->DocSzChgd(rSize);
-        else if (dynamic_cast< const SwPagePreview *>( pSfxVwSh ) !=  nullptr)
-            static_cast<SwPagePreview *>(pSfxVwSh)->DocSzChgd( rSize );
-    }
+    SfxViewShell *pSfxViewShell = pVwSh->GetSfxViewShell();
+
+    if (SwView* pSwView = dynamic_cast<SwView *>(pSfxViewShell))
+        pSwView->DocSzChgd(rSize);
+    else if (SwPagePreview* pSwPageView = dynamic_cast<SwPagePreview *>(pSfxViewShell))
+        pSwPageView->DocSzChgd(rSize);
 }
 
 // Notify for page number update
 void PageNumNotify( SwViewShell* pVwSh, sal_uInt16 nPhyNum, sal_uInt16 nVirtNum,
                                                     const OUString& rPgStr)
 {
-    SfxViewShell *pSfxVwSh = pVwSh->GetSfxViewShell();
-    if ( pSfxVwSh && dynamic_cast< const SwView *>( pSfxVwSh ) !=  nullptr &&
-         static_cast<SwView*>(pSfxVwSh)->GetCurShell() )
-            static_cast<SwView *>(pSfxVwSh)->UpdatePageNums(nPhyNum, nVirtNum, rPgStr);
+    SfxViewShell *pSfxViewShell = pVwSh->GetSfxViewShell();
+
+    if (SwView* pSwView = dynamic_cast<SwView *>(pSfxViewShell))
+    {
+        if (pSwView->GetCurShell())
+            pSwView->UpdatePageNums(nPhyNum, nVirtNum, rPgStr);
+    }
 }
 
 void FrameNotify( SwViewShell* pVwSh, FlyMode eMode )
 {
-    if ( dynamic_cast< const SwCursorShell *>( pVwSh ) !=  nullptr )
-        SwBaseShell::SetFrameMode( eMode, static_cast<SwWrtShell*>(pVwSh) );
+    if (SwWrtShell* pWrtShell = dynamic_cast<SwWrtShell *>(pVwSh))
+        SwBaseShell::SetFrameMode(eMode, pWrtShell);
 }
 
 // Notify for page number update
@@ -110,16 +114,19 @@ TableChgMode GetTableChgDefaultMode()
 
 void RepaintPagePreview( SwViewShell* pVwSh, const SwRect& rRect )
 {
-    SfxViewShell *pSfxVwSh = pVwSh->GetSfxViewShell();
-    if (pSfxVwSh && dynamic_cast< const SwPagePreview *>( pSfxVwSh ) !=  nullptr)
-        static_cast<SwPagePreview *>(pSfxVwSh)->RepaintCoreRect( rRect );
+    SfxViewShell *pSfxViewShell = pVwSh->GetSfxViewShell();
+
+    if (SwPagePreview* pSwPagePreview = dynamic_cast<SwPagePreview *>(pSfxViewShell))
+        pSwPagePreview->RepaintCoreRect(rRect);
 }
 
 bool JumpToSwMark( SwViewShell* pVwSh, const OUString& rMark )
 {
-    SfxViewShell *pSfxVwSh = pVwSh->GetSfxViewShell();
-    if( pSfxVwSh && dynamic_cast< const SwView *>( pSfxVwSh ) !=  nullptr )
-        return static_cast<SwView *>(pSfxVwSh)->JumpToSwMark( rMark );
+    SfxViewShell *pSfxViewShell = pVwSh->GetSfxViewShell();
+
+    if (SwView* pSwView = dynamic_cast<SwView *>(pSfxViewShell))
+        return pSwView->JumpToSwMark(rMark);
+
     return false;
 }
 
diff --git a/sw/source/uibase/docvw/srcedtw.cxx b/sw/source/uibase/docvw/srcedtw.cxx
index 749d53c..09741aa 100644
--- a/sw/source/uibase/docvw/srcedtw.cxx
+++ b/sw/source/uibase/docvw/srcedtw.cxx
@@ -742,11 +742,11 @@ void SwSrcEditWindow::ImpDoHighlight( const OUString& rSource, sal_uInt16 nLineO
 
 void SwSrcEditWindow::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
 {
-    if ( !dynamic_cast<const TextHint*>(&rHint) )
+    const TextHint* pTextHint = dynamic_cast<const TextHint*>(&rHint);
+    if (!pTextHint)
         return;
 
-    const TextHint& rTextHint = static_cast<const TextHint&>(rHint);
-    switch (rTextHint.GetId())
+    switch (pTextHint->GetId())
     {
         case TEXT_HINT_VIEWSCROLLED:
             m_pHScrollbar->SetThumbPos( m_pTextView->GetStartDocPos().X() );
@@ -762,7 +762,7 @@ void SwSrcEditWindow::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
 
         case TEXT_HINT_PARAINSERTED:
         case TEXT_HINT_PARACONTENTCHANGED:
-            DoDelayedSyntaxHighlight( (sal_uInt16)rTextHint.GetValue() );
+            DoDelayedSyntaxHighlight(static_cast<sal_uInt16>(pTextHint->GetValue()));
             break;
     }
 }
diff --git a/sw/source/uibase/ribbar/conrect.cxx b/sw/source/uibase/ribbar/conrect.cxx
index 9966394..1446560 100644
--- a/sw/source/uibase/ribbar/conrect.cxx
+++ b/sw/source/uibase/ribbar/conrect.cxx
@@ -95,20 +95,23 @@ bool ConstRectangle::MouseButtonUp(const MouseEvent& rMEvt)
                     pObj->SetMergedItemSetAndBroadcast(aItemSet);
                 }
             }
-            else if(mbVertical && pObj && dynamic_cast< const SdrTextObj *>( pObj ) !=  nullptr)
+            else if(mbVertical)
             {
-                SdrTextObj* pText = static_cast<SdrTextObj*>(pObj);
-                SfxItemSet aSet(pSdrView->GetModel()->GetItemPool());
+                if (SdrTextObj* pText = dynamic_cast<SdrTextObj*>(pObj))
+                {
+                    SfxItemSet aSet(pSdrView->GetModel()->GetItemPool());
 
-                pText->SetVerticalWriting(true);
+                    pText->SetVerticalWriting(true);
 
-                aSet.Put(makeSdrTextAutoGrowWidthItem(true));
-                aSet.Put(makeSdrTextAutoGrowHeightItem(false));
-                aSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_TOP));
-                aSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT));
+                    aSet.Put(makeSdrTextAutoGrowWidthItem(true));
+                    aSet.Put(makeSdrTextAutoGrowHeightItem(false));
+                    aSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_TOP));
+                    aSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT));
 
-                pText->SetMergedItemSet(aSet);
+                    pText->SetMergedItemSet(aSet);
+                }
             }
+
             if( pObj )
             {
                 SdrPageView* pPV = pSdrView->GetSdrPageView();


More information about the Libreoffice-commits mailing list