sd/source/ui/view/Outliner.cxx | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-)
New commits: commit 29e06da2b63441f4458c482eae1cd36bd10b4728 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 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 <qui...@gmail.com> Reviewed-by: Tomaž Vajngerl <qui...@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()); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits