sd/source/ui/animations/CustomAnimationPane.cxx |    4 ++--
 sd/source/ui/annotations/annotationmanager.cxx  |   14 ++++++++------
 sd/source/ui/func/fusearch.cxx                  |    5 +++--
 sd/source/ui/table/TableDesignPane.cxx          |   18 ++++++++++++------
 sd/source/ui/view/DocumentRenderer.cxx          |    2 +-
 sd/source/ui/view/Outliner.cxx                  |    5 +++--
 sd/source/ui/view/ViewShellBase.cxx             |    4 ++--
 sd/source/ui/view/viewshe2.cxx                  |    4 ++--
 8 files changed, 33 insertions(+), 23 deletions(-)

New commits:
commit 1e0ba98adf0123aed4a0f9a208d1b132a6d2b7ab
Author:     Noel Grandin <noelgran...@gmail.com>
AuthorDate: Tue Aug 27 19:10:28 2024 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Wed Aug 28 07:34:05 2024 +0200

    GetMainViewShell is not trivial
    
    Change-Id: I86eec22a6ebb8957d983f63d37bf11b8bfa1a2bb
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172475
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>
    Tested-by: Jenkins

diff --git a/sd/source/ui/animations/CustomAnimationPane.cxx 
b/sd/source/ui/animations/CustomAnimationPane.cxx
index a6fa4bad98dd..7db1fd0bb925 100644
--- a/sd/source/ui/animations/CustomAnimationPane.cxx
+++ b/sd/source/ui/animations/CustomAnimationPane.cxx
@@ -289,9 +289,9 @@ IMPL_LINK(CustomAnimationPane,EventMultiplexerListener,
             // At this moment the controller may not yet been set at model
             // or ViewShellBase.  Take it from the view shell passed with
             // the event.
-            if (mrBase.GetMainViewShell() != nullptr)
+            if (auto pMainViewShell = mrBase.GetMainViewShell().get())
             {
-                if( mrBase.GetMainViewShell()->GetShellType() == 
ViewShell::ST_IMPRESS )
+                if( pMainViewShell->GetShellType() == ViewShell::ST_IMPRESS )
                 {
                     mxView = mrBase.GetDrawController();
                     onSelectionChanged();
diff --git a/sd/source/ui/annotations/annotationmanager.cxx 
b/sd/source/ui/annotations/annotationmanager.cxx
index cada3c0c29ad..d3d70d45badb 100644
--- a/sd/source/ui/annotations/annotationmanager.cxx
+++ b/sd/source/ui/annotations/annotationmanager.cxx
@@ -119,16 +119,18 @@ SfxItemPool* GetAnnotationPool()
 
 static SfxBindings* getBindings( ViewShellBase const & rBase )
 {
-    if( rBase.GetMainViewShell() && rBase.GetMainViewShell()->GetViewFrame() )
-        return &rBase.GetMainViewShell()->GetViewFrame()->GetBindings();
+    auto pMainViewShell = rBase.GetMainViewShell().get();
+    if( pMainViewShell && pMainViewShell->GetViewFrame() )
+        return &pMainViewShell->GetViewFrame()->GetBindings();
 
     return nullptr;
 }
 
 static SfxDispatcher* getDispatcher( ViewShellBase const & rBase )
 {
-    if( rBase.GetMainViewShell() && rBase.GetMainViewShell()->GetViewFrame() )
-        return rBase.GetMainViewShell()->GetViewFrame()->GetDispatcher();
+    auto pMainViewShell = rBase.GetMainViewShell().get();
+    if( pMainViewShell && pMainViewShell->GetViewFrame() )
+        return pMainViewShell->GetViewFrame()->GetDispatcher();
 
     return nullptr;
 }
@@ -1260,8 +1262,8 @@ SdPage* AnnotationManagerImpl::GetNextPage( SdPage const 
* pPage, bool bForward
 
 SdPage* AnnotationManagerImpl::GetCurrentPage()
 {
-    if (mrBase.GetMainViewShell())
-        return mrBase.GetMainViewShell()->getCurrentPage();
+    if (auto pMainViewShell = mrBase.GetMainViewShell().get())
+        return pMainViewShell->getCurrentPage();
     return nullptr;
 }
 
diff --git a/sd/source/ui/func/fusearch.cxx b/sd/source/ui/func/fusearch.cxx
index 4856dd20bece..d038e59f3a74 100644
--- a/sd/source/ui/func/fusearch.cxx
+++ b/sd/source/ui/func/fusearch.cxx
@@ -81,12 +81,13 @@ void FuSearch::DoExecute( SfxRequest& )
     }
     else if ( dynamic_cast< const NotesPanelViewShell *>( mpViewShell ) !=  
nullptr )
     {
-        if( mpViewShell->GetViewShellBase().GetMainViewShell()->GetShellType() 
== ViewShell::ST_OUTLINE )
+        ViewShell::ShellType nShellType = 
mpViewShell->GetViewShellBase().GetMainViewShell()->GetShellType();
+        if( nShellType == ViewShell::ST_OUTLINE )
         {
             m_bOwnOutliner = false;
             m_pSdOutliner = mpDoc->GetOutliner();
         }
-        if( mpViewShell->GetViewShellBase().GetMainViewShell()->GetShellType() 
== ViewShell::ST_IMPRESS )
+        if( nShellType == ViewShell::ST_IMPRESS )
         {
             m_bOwnOutliner = true;
             m_pSdOutliner = new SdOutliner( mpDoc, OutlinerMode::TextObject );
diff --git a/sd/source/ui/table/TableDesignPane.cxx 
b/sd/source/ui/table/TableDesignPane.cxx
index dcac6a380874..1cbdfc8a629b 100644
--- a/sd/source/ui/table/TableDesignPane.cxx
+++ b/sd/source/ui/table/TableDesignPane.cxx
@@ -416,18 +416,24 @@ void TableDesignWidget::EditStyle(const OUString& 
rCommand)
 
 static SfxBindings* getBindings( ViewShellBase const & rBase )
 {
-    if( rBase.GetMainViewShell() && rBase.GetMainViewShell()->GetViewFrame() )
-        return &rBase.GetMainViewShell()->GetViewFrame()->GetBindings();
-    else
+    auto pViewShell = rBase.GetMainViewShell().get();
+    if( !pViewShell )
+        return nullptr;
+    auto pViewFrame = pViewShell->GetViewFrame();
+    if( !pViewFrame )
         return nullptr;
+    return &pViewFrame->GetBindings();
 }
 
 static SfxDispatcher* getDispatcher( ViewShellBase const & rBase )
 {
-    if( rBase.GetMainViewShell() && rBase.GetMainViewShell()->GetViewFrame() )
-        return rBase.GetMainViewShell()->GetViewFrame()->GetDispatcher();
-    else
+    auto pViewShell = rBase.GetMainViewShell().get();
+    if( !pViewShell )
+        return nullptr;
+    auto pViewFrame = pViewShell->GetViewFrame();
+    if( !pViewFrame )
         return nullptr;
+    return pViewFrame->GetDispatcher();
 }
 
 IMPL_LINK_NOARG(TableDesignWidget, implValueSetHdl, ValueSet*, void)
diff --git a/sd/source/ui/view/DocumentRenderer.cxx 
b/sd/source/ui/view/DocumentRenderer.cxx
index 502df8396306..e062b79259f3 100644
--- a/sd/source/ui/view/DocumentRenderer.cxx
+++ b/sd/source/ui/view/DocumentRenderer.cxx
@@ -1256,7 +1256,7 @@ public:
         assert(pDocument!=nullptr);
 
         std::shared_ptr<DrawViewShell> pDrawViewShell(
-            
std::dynamic_pointer_cast<DrawViewShell>(mrBase.GetMainViewShell()));
+            std::dynamic_pointer_cast<DrawViewShell>(pViewShell));
 
         if (!mpPrintView)
             mpPrintView.reset(new DrawView(mrBase.GetDocShell(), &rPrinter, 
nullptr));
diff --git a/sd/source/ui/view/Outliner.cxx b/sd/source/ui/view/Outliner.cxx
index 8f33f1edbde7..9aa7b6e516bc 100644
--- a/sd/source/ui/view/Outliner.cxx
+++ b/sd/source/ui/view/Outliner.cxx
@@ -1763,8 +1763,9 @@ void SdOutliner::EnterEditMode (bool bGrabFocus)
 
         if (pOverridingViewShell)
         {
-            
getViewShellBase()->GetMainViewShell()->GetParentWindow()->GrabFocus();
-            
getViewShellBase()->GetMainViewShell()->GetContentWindow()->GrabFocus();
+            auto pMainViewShell = getViewShellBase()->GetMainViewShell().get();
+            pMainViewShell->GetParentWindow()->GrabFocus();
+            pMainViewShell->GetContentWindow()->GrabFocus();
             bGrabFocus = true;
         }
 
diff --git a/sd/source/ui/view/ViewShellBase.cxx 
b/sd/source/ui/view/ViewShellBase.cxx
index 17d17835245c..f3f80a6e3631 100644
--- a/sd/source/ui/view/ViewShellBase.cxx
+++ b/sd/source/ui/view/ViewShellBase.cxx
@@ -1497,9 +1497,9 @@ void CurrentPageSetter::operator() (bool)
 {
     FrameView* pFrameView = nullptr;
 
-    if (mrBase.GetMainViewShell() != nullptr)
+    if (auto pViewShell = mrBase.GetMainViewShell().get())
     {
-        pFrameView = mrBase.GetMainViewShell()->GetFrameView();
+        pFrameView = pViewShell->GetFrameView();
     }
 
     if (pFrameView==nullptr)
diff --git a/sd/source/ui/view/viewshe2.cxx b/sd/source/ui/view/viewshe2.cxx
index e669afd65dbe..71c152461286 100644
--- a/sd/source/ui/view/viewshe2.cxx
+++ b/sd/source/ui/view/viewshe2.cxx
@@ -951,8 +951,8 @@ void ViewShell::WriteUserDataSequence ( css::uno::Sequence 
< css::beans::Propert
     // usually be the called view shell, but to be on the safe side we call
     // the main view shell explicitly.
     SfxInterfaceId nViewID (IMPRESS_FACTORY_ID);
-    if (GetViewShellBase().GetMainViewShell() != nullptr)
-        nViewID = GetViewShellBase().GetMainViewShell()->mpImpl->GetViewId();
+    if (auto pViewShell = GetViewShellBase().GetMainViewShell().get())
+        nViewID = pViewShell->mpImpl->GetViewId();
     pSequence[nIndex].Name = sUNO_View_ViewId;
     pSequence[nIndex].Value <<= "view" + OUString::number( 
static_cast<sal_uInt16>(nViewID));
 

Reply via email to