sc/source/ui/docshell/docsh.cxx |   23 +++++++++++++----------
 sc/source/ui/view/tabvwsh4.cxx  |    8 ++++----
 2 files changed, 17 insertions(+), 14 deletions(-)

New commits:
commit 47f06e904e7c9ed3d0519694556017ff6899da96
Author:     Noel Grandin <[email protected]>
AuthorDate: Thu Jan 29 16:37:02 2026 +0200
Commit:     Noel Grandin <[email protected]>
CommitDate: Thu Jan 29 18:23:42 2026 +0100

    simplify control flow
    
    Change-Id: Idc328e8f1e89c88834f178870baa8599dcceb3e9
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/198371
    Reviewed-by: Noel Grandin <[email protected]>
    Tested-by: Jenkins

diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx
index e5de7db7bd8d..299778145908 100644
--- a/sc/source/ui/docshell/docsh.cxx
+++ b/sc/source/ui/docshell/docsh.cxx
@@ -825,8 +825,15 @@ void ScDocShell::Notify( SfxBroadcaster&, const SfxHint& 
rHint )
 #endif
 
                     ScViewData* pViewData = GetViewData();
-                    SfxViewShell* pViewShell = pViewData ? 
pViewData->GetViewShell() : nullptr;
-                    SfxViewFrame* pViewFrame = pViewShell ? 
&pViewShell->GetViewFrame() : nullptr;
+                    if (!pViewData)
+                        break;
+                    SfxViewShell* pViewShell = pViewData->GetViewShell();
+                    if (!pViewShell)
+                        break;
+                    SfxViewFrame* pViewFrame = &pViewShell->GetViewFrame();
+                    if (!pViewFrame)
+                        break;
+                    SfxFrame* pFrame = &pViewFrame->GetFrame();
 
                     try
                     {
@@ -848,8 +855,7 @@ void ScDocShell::Notify( SfxBroadcaster&, const SfxHint& 
rHint )
                                 if ( xFactory.is() )
                                 {
                                     uno::Reference< task::XJob > xJob( 
xFactory->createInstanceWithContext( xContext ), uno::UNO_QUERY_THROW );
-                                    SfxFrame* pFrame = ( pViewFrame ? 
&pViewFrame->GetFrame() : nullptr );
-                                    uno::Reference< frame::XController > 
xController = ( pFrame ? pFrame->GetController() : nullptr );
+                                    uno::Reference< frame::XController > 
xController = pFrame->GetController();
                                     uno::Reference< sheet::XSpreadsheetView > 
xSpreadsheetView( xController, uno::UNO_QUERY_THROW );
                                     uno::Sequence< beans::NamedValue > 
aArgsForJob { { u"SpreadsheetView"_ustr, uno::Any( xSpreadsheetView ) } };
                                     xJob->execute( aArgsForJob );
@@ -862,14 +868,11 @@ void ScDocShell::Notify( SfxBroadcaster&, const SfxHint& 
rHint )
                     }
 
                     // Show delayed infobar entries
-                    if (pViewFrame)
+                    for (auto const& r : m_pImpl->mpDelayedInfobarEntry)
                     {
-                        for (auto const& r : m_pImpl->mpDelayedInfobarEntry)
-                        {
-                            pViewFrame->AppendInfoBar(r.msId, 
r.msPrimaryMessage, r.msSecondaryMessage, r.maInfobarType, r.mbShowCloseButton);
-                        }
-                        m_pImpl->mpDelayedInfobarEntry.clear();
+                        pViewFrame->AppendInfoBar(r.msId, r.msPrimaryMessage, 
r.msSecondaryMessage, r.maInfobarType, r.mbShowCloseButton);
                     }
+                    m_pImpl->mpDelayedInfobarEntry.clear();
                 }
                 break;
             case SfxEventHintId::SaveDoc:
commit ca534064c56022dd7bbb4cfdaa9fa658dcb341a9
Author:     Noel Grandin <[email protected]>
AuthorDate: Thu Jan 29 16:33:56 2026 +0200
Commit:     Noel Grandin <[email protected]>
CommitDate: Thu Jan 29 18:23:32 2026 +0100

    use more concrete UNO in ScTabViewShell
    
    Change-Id: Ibd9ce1d7a5cb5a7012c9c99235234ca16818f871
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/198370
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <[email protected]>

diff --git a/sc/source/ui/view/tabvwsh4.cxx b/sc/source/ui/view/tabvwsh4.cxx
index e8526a0e4d70..9431577b5a4b 100644
--- a/sc/source/ui/view/tabvwsh4.cxx
+++ b/sc/source/ui/view/tabvwsh4.cxx
@@ -1867,14 +1867,14 @@ uno::Reference<css::sheet::XSpreadsheet> 
ScTabViewShell::GetRangeWithSheet(css::
     uno::Reference<frame::XController> 
xController(xModel->getCurrentController());
 
     // spreadsheet's extension of com.sun.star.frame.Controller service
-    uno::Reference<sheet::XSpreadsheetView> SpreadsheetDocument(xController, 
uno::UNO_QUERY);
-    uno::Reference<sheet::XSpreadsheet> ActiveSheet = 
SpreadsheetDocument->getActiveSheet();
+    ScTabViewObj* pSpreadsheetDocument = 
dynamic_cast<ScTabViewObj*>(xController.get());
+    assert(pSpreadsheetDocument);
+    uno::Reference<sheet::XSpreadsheet> ActiveSheet = 
pSpreadsheetDocument->getActiveSheet();
 
     if (!bHasUnoArguments)
     {
         // get the selection supplier, extract selection in XSheetCellRange
-        uno::Reference<view::XSelectionSupplier> 
xSelectionSupplier(SpreadsheetDocument, uno::UNO_QUERY);
-        uno::Any Selection = xSelectionSupplier->getSelection();
+        uno::Any Selection = pSpreadsheetDocument->getSelection();
         uno::Reference<sheet::XSheetCellRange> SelectedCellRange;
         Selection >>= SelectedCellRange;
 

Reply via email to