sd/source/ui/view/Outliner.cxx | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-)
New commits: commit 7824545abeb308a89c08aa98e20901df05934625 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Wed May 27 14:20:44 2020 +0200 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Tue Jun 9 15:19:10 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 <qui...@gmail.com> Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> (cherry picked from commit 29e06da2b63441f4458c482eae1cd36bd10b4728) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95919 diff --git a/sd/source/ui/view/Outliner.cxx b/sd/source/ui/view/Outliner.cxx index e77e60c5d305..e98c1bde5795 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; @@ -1618,7 +1628,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()); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits