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

Tomaž Vajngerl (via logerrit) logerrit at kemper.freedesktop.org
Tue Jun 2 07:21:35 UTC 2020


 sd/source/ui/view/Outliner.cxx |   18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

New commits:
commit 29e06da2b63441f4458c482eae1cd36bd10b4728
Author:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Wed May 27 14:20:44 2020 +0200
Commit:     Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Tue Jun 2 09:20:59 2020 +0200

    sd: in Outline add getViewShellBase to simplify code
    
    This simplifies constant casting of SfxViewShell::Current to
    sd::ViewShellBase. Instead of doing it in every method, let's
    have a dedicated function for that.
    
    Change-Id: Iadbe446c7edce5df40c2da14e3eee65012dd4d77
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95308
    Tested-by: Tomaž Vajngerl <quikee at gmail.com>
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>

diff --git a/sd/source/ui/view/Outliner.cxx b/sd/source/ui/view/Outliner.cxx
index 7ce6cab0b0a7..0b3080229963 100644
--- a/sd/source/ui/view/Outliner.cxx
+++ b/sd/source/ui/view/Outliner.cxx
@@ -111,6 +111,16 @@ private:
     OutlinerView* mpOutlineView;
 };
 
+namespace
+{
+
+sd::ViewShellBase* getViewShellBase()
+{
+    return dynamic_cast<sd::ViewShellBase*>(SfxViewShell::Current());
+}
+
+} // end anonymous namespace
+
 SdOutliner::SdOutliner( SdDrawDocument* pDoc, OutlinerMode nMode )
     : SdrOutliner( &pDoc->GetItemPool(), nMode ),
       mpImpl(new Implementation()),
@@ -228,7 +238,7 @@ void SdOutliner::PrepareSpelling()
 {
     mbPrepareSpellingPending = false;
 
-    sd::ViewShellBase* pBase = dynamic_cast< sd::ViewShellBase *>( SfxViewShell::Current() );
+    sd::ViewShellBase* pBase = getViewShellBase();
     if (pBase != nullptr)
         SetViewShell (pBase->GetMainViewShell());
     SetRefDevice( SD_MOD()->GetVirtualRefDevice() );
@@ -270,7 +280,7 @@ void SdOutliner::EndSpelling()
     std::shared_ptr<sd::ViewShell> pViewShell (mpWeakViewShell.lock());
     std::shared_ptr<sd::ViewShell> pOldViewShell (pViewShell);
 
-    sd::ViewShellBase* pBase = dynamic_cast< sd::ViewShellBase *>( SfxViewShell::Current() );
+    sd::ViewShellBase* pBase = getViewShellBase();
     if (pBase != nullptr)
         pViewShell = pBase->GetMainViewShell();
     else
@@ -413,7 +423,7 @@ bool SdOutliner::StartSearchAndReplace (const SvxSearchItem* pSearchItem)
     mpDrawDocument->GetDocSh()->SetWaitCursor( true );
     if (mbPrepareSpellingPending)
         PrepareSpelling();
-    sd::ViewShellBase* pBase = dynamic_cast< sd::ViewShellBase *>( SfxViewShell::Current() );
+    sd::ViewShellBase* pBase = getViewShellBase();
     // Determine whether we have to abort the search.  This is necessary
     // when the main view shell does not support searching.
     bool bAbort = false;
@@ -1607,7 +1617,7 @@ void SdOutliner::BeginConversion()
 {
     SetRefDevice( SD_MOD()->GetVirtualRefDevice() );
 
-    sd::ViewShellBase* pBase = dynamic_cast<sd::ViewShellBase*>( SfxViewShell::Current() );
+    sd::ViewShellBase* pBase = getViewShellBase();
     if (pBase != nullptr)
         SetViewShell (pBase->GetMainViewShell());
 


More information about the Libreoffice-commits mailing list