From bdb27b21bfe44a3a0bbc7df115fd91dffde30cd4 Mon Sep 17 00:00:00 2001 From: Michael Weghorn Date: Tue, 21 Jul 2026 15:54:16 +0200 Subject: [PATCH] sc: Pass ScTabViewShell::CreateRefDialogController's SfxBindings param by ref ... instead of by pointer. This makes clear it's always non-null. Methods/Constructors called from within ScTabViewShell::CreateRefDialogController could be adjusted in a similar way in the future. Change-Id: If32a02ccef02d7e74927991c7e96b288d3b80390 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/208402 Reviewed-by: Michael Weghorn Tested-by: Jenkins --- sc/source/ui/inc/ChildWindowWrapper.hxx | 2 +- sc/source/ui/inc/tabvwsh.hxx | 2 +- sc/source/ui/view/reffact.cxx | 4 +- sc/source/ui/view/tabvwshc.cxx | 123 ++++++++++++++---------- 4 files changed, 77 insertions(+), 54 deletions(-) diff --git a/sc/source/ui/inc/ChildWindowWrapper.hxx b/sc/source/ui/inc/ChildWindowWrapper.hxx index 7f216c18de29..334289f1511b 100644 --- a/sc/source/ui/inc/ChildWindowWrapper.hxx +++ b/sc/source/ui/inc/ChildWindowWrapper.hxx @@ -32,7 +32,7 @@ public: if (pViewShell) SetController(pViewShell->CreateRefDialogController( - &rBindings, this, rInfo, pParentP->GetFrameWeld(), WindowID)); + rBindings, this, rInfo, pParentP->GetFrameWeld(), WindowID)); if (pViewShell && !GetController()) pViewShell->GetViewFrame().SetChildWindow( nId, false ); diff --git a/sc/source/ui/inc/tabvwsh.hxx b/sc/source/ui/inc/tabvwsh.hxx index 8e02f3e22042..c1fe4e40495c 100644 --- a/sc/source/ui/inc/tabvwsh.hxx +++ b/sc/source/ui/inc/tabvwsh.hxx @@ -393,7 +393,7 @@ public: SAL_RET_MAYBENULL SC_DLLPUBLIC static ScTabViewShell* GetActiveViewShell(); std::shared_ptr - CreateRefDialogController(SfxBindings* pB, SfxChildWindow* pCW, SfxChildWinInfo& rInfo, + CreateRefDialogController(SfxBindings& rBindings, SfxChildWindow* pCW, SfxChildWinInfo& rInfo, weld::Window* pParent, sal_uInt16 nSlotId); void UpdateOleZoom(); diff --git a/sc/source/ui/view/reffact.cxx b/sc/source/ui/view/reffact.cxx index a99cc5831acd..5f8bb5b9fa2a 100644 --- a/sc/source/ui/view/reffact.cxx +++ b/sc/source/ui/view/reffact.cxx @@ -80,7 +80,7 @@ ScTabViewShell* lcl_GetTabViewShell(const SfxBindings& rBindings); pViewShell = dynamic_cast(SfxViewShell::Current()); \ OSL_ENSURE(pViewShell, "missing view shell :-("); \ SetController(pViewShell ? pViewShell->CreateRefDialogController( \ - &rBindings, this, rInfo, pParentP->GetFrameWeld(), sid) \ + rBindings, this, rInfo, pParentP->GetFrameWeld(), sid) \ : nullptr); \ if (pViewShell && !GetController()) \ pViewShell->GetViewFrame().SetChildWindow(nId, false); \ @@ -152,7 +152,7 @@ ScSimpleRefDlgWrapper::ScSimpleRefDlgWrapper(vcl::Window* pParentP, sal_uInt16 n if (bAutoReOpen && pViewShell) SetController(pViewShell->CreateRefDialogController( - &rBindings, this, rInfo, pParentP->GetFrameWeld(), WID_SIMPLE_REF)); + rBindings, this, rInfo, pParentP->GetFrameWeld(), WID_SIMPLE_REF)); if (!GetController()) { diff --git a/sc/source/ui/view/tabvwshc.cxx b/sc/source/ui/view/tabvwshc.cxx index 19d64438b80f..43f34661f673 100644 --- a/sc/source/ui/view/tabvwshc.cxx +++ b/sc/source/ui/view/tabvwshc.cxx @@ -117,7 +117,7 @@ void ScTabViewShell::SwitchBetweenRefDialogs(SfxModelessDialogController* pDialo } std::shared_ptr -ScTabViewShell::CreateRefDialogController(SfxBindings* pB, SfxChildWindow* pCW, +ScTabViewShell::CreateRefDialogController(SfxBindings& rBindings, SfxChildWindow* pCW, SfxChildWinInfo& rInfo, weld::Window* pParent, sal_uInt16 nSlotId) { @@ -149,43 +149,50 @@ ScTabViewShell::CreateRefDialogController(SfxBindings* pB, SfxChildWindow* pCW, switch( nSlotId ) { case SID_CORRELATION_DIALOG: - xResult = std::make_shared(pB, pCW, pParent, GetViewData()); + xResult + = std::make_shared(&rBindings, pCW, pParent, GetViewData()); break; case SID_SAMPLING_DIALOG: - xResult = std::make_shared(pB, pCW, pParent, GetViewData()); + xResult = std::make_shared(&rBindings, pCW, pParent, GetViewData()); break; case SID_DESCRIPTIVE_STATISTICS_DIALOG: - xResult = std::make_shared(pB, pCW, pParent, GetViewData()); + xResult = std::make_shared(&rBindings, pCW, pParent, + GetViewData()); break; case SID_ANALYSIS_OF_VARIANCE_DIALOG: - xResult = std::make_shared(pB, pCW, pParent, GetViewData()); + xResult = std::make_shared(&rBindings, pCW, pParent, + GetViewData()); break; case SID_COVARIANCE_DIALOG: - xResult = std::make_shared(pB, pCW, pParent, GetViewData()); + xResult = std::make_shared(&rBindings, pCW, pParent, GetViewData()); break; case SID_EXPONENTIAL_SMOOTHING_DIALOG: - xResult = std::make_shared(pB, pCW, pParent, GetViewData()); + xResult = std::make_shared(&rBindings, pCW, pParent, + GetViewData()); break; case SID_MOVING_AVERAGE_DIALOG: - xResult = std::make_shared(pB, pCW, pParent, GetViewData()); + xResult + = std::make_shared(&rBindings, pCW, pParent, GetViewData()); break; case SID_REGRESSION_DIALOG: - xResult = std::make_shared(pB, pCW, pParent, GetViewData()); + xResult = std::make_shared(&rBindings, pCW, pParent, GetViewData()); break; case SID_FTEST_DIALOG: - xResult = std::make_shared(pB, pCW, pParent, GetViewData()); + xResult = std::make_shared(&rBindings, pCW, pParent, GetViewData()); break; case SID_TTEST_DIALOG: - xResult = std::make_shared(pB, pCW, pParent, GetViewData()); + xResult = std::make_shared(&rBindings, pCW, pParent, GetViewData()); break; case SID_ZTEST_DIALOG: - xResult = std::make_shared(pB, pCW, pParent, GetViewData()); + xResult = std::make_shared(&rBindings, pCW, pParent, GetViewData()); break; case SID_CHI_SQUARE_TEST_DIALOG: - xResult = std::make_shared(pB, pCW, pParent, GetViewData()); + xResult + = std::make_shared(&rBindings, pCW, pParent, GetViewData()); break; case SID_FOURIER_ANALYSIS_DIALOG: - xResult = std::make_shared(pB, pCW, pParent, GetViewData()); + xResult = std::make_shared(&rBindings, pCW, pParent, + GetViewData()); break; case WID_SIMPLE_REF: { @@ -193,24 +200,25 @@ ScTabViewShell::CreateRefDialogController(SfxBindings* pB, SfxChildWindow* pCW, ScViewData& rViewData = GetViewData(); rViewData.SetRefTabNo( rViewData.CurrentTabForData() ); - xResult = std::make_shared(pB, pCW, pParent); + xResult = std::make_shared(&rBindings, pCW, pParent); break; } case FID_DEFINE_NAME: { if (!mbInSwitch) { - xResult = std::make_shared(pB, pCW, pParent, GetViewData(), - ScAddress( GetViewData().GetCurX(), - GetViewData().GetCurY(), - GetViewData().CurrentTabForData() ) ); + xResult = std::make_shared(&rBindings, pCW, pParent, GetViewData(), + ScAddress(GetViewData().GetCurX(), + GetViewData().GetCurY(), + GetViewData().CurrentTabForData())); } else { - xResult = std::make_shared( pB, pCW, pParent, GetViewData(), - ScAddress( GetViewData().GetCurX(), - GetViewData().GetCurY(), - GetViewData().CurrentTabForData() ), &m_RangeMap); + xResult = std::make_shared(&rBindings, pCW, pParent, GetViewData(), + ScAddress(GetViewData().GetCurX(), + GetViewData().GetCurY(), + GetViewData().CurrentTabForData()), + &m_RangeMap); static_cast(xResult.get())->SetEntry(maName, maScope); mbInSwitch = false; } @@ -222,10 +230,11 @@ ScTabViewShell::CreateRefDialogController(SfxBindings* pB, SfxChildWindow* pCW, { std::map aRangeMap; rDoc.GetRangeNameMap(aRangeMap); - xResult = std::make_shared(pB, pCW, pParent, GetViewData(), std::move(aRangeMap), - ScAddress(GetViewData().GetCurX(), - GetViewData().GetCurY(), - GetViewData().CurrentTabForData()), true); + xResult = std::make_shared( + &rBindings, pCW, pParent, GetViewData(), std::move(aRangeMap), + ScAddress(GetViewData().GetCurX(), GetViewData().GetCurY(), + GetViewData().CurrentTabForData()), + true); } else { @@ -234,31 +243,35 @@ ScTabViewShell::CreateRefDialogController(SfxBindings* pB, SfxChildWindow* pCW, { aRangeMap.insert(std::pair(itr.first, &itr.second)); } - xResult = std::make_shared(pB, pCW, pParent, GetViewData(), std::move(aRangeMap), - ScAddress(GetViewData().GetCurX(), - GetViewData().GetCurY(), - GetViewData().CurrentTabForData()), false); + xResult = std::make_shared( + &rBindings, pCW, pParent, GetViewData(), std::move(aRangeMap), + ScAddress(GetViewData().GetCurX(), GetViewData().GetCurY(), + GetViewData().CurrentTabForData()), + false); } break; } case SID_RANDOM_NUMBER_GENERATOR_DIALOG: - xResult = std::make_shared(pB, pCW, pParent, GetViewData()); + xResult = std::make_shared(&rBindings, pCW, pParent, + GetViewData()); break; case SID_SPARKLINE_DIALOG: { - xResult = std::make_shared(pB, pCW, pParent, GetViewData()); + xResult + = std::make_shared(&rBindings, pCW, pParent, GetViewData()); break; } case SID_SPARKLINE_DATA_RANGE_DIALOG: { - xResult = std::make_shared(pB, pCW, pParent, GetViewData()); + xResult = std::make_shared(&rBindings, pCW, pParent, + GetViewData()); break; } case SID_DEFINE_DBNAME: { // when called for an existing range, then mark GetDBData( true, SC_DB_OLD ); - xResult = std::make_shared(pB, pCW, pParent, GetViewData()); + xResult = std::make_shared(&rBindings, pCW, pParent, GetViewData()); break; } case SID_INSERT_CALCTABLE: @@ -268,14 +281,15 @@ ScTabViewShell::CreateRefDialogController(SfxBindings* pB, SfxChildWindow* pCW, if ( !rMark.IsMarked() && !rMark.IsMultiMarked() ) MarkDataArea( false ); - xResult = std::make_shared(pB, pCW, pParent, GetViewData()); + xResult = std::make_shared(&rBindings, pCW, pParent, GetViewData()); break; } case SID_OPENDLG_EDIT_PRINTAREA: - xResult = std::make_shared(pB, pCW, pParent, GetViewData()); + xResult = std::make_shared(&rBindings, pCW, pParent, GetViewData()); break; case SID_DEFINE_COLROWNAMERANGES: - xResult = std::make_shared(pB, pCW, pParent, GetViewData()); + xResult + = std::make_shared(&rBindings, pCW, pParent, GetViewData()); break; case SID_OPENDLG_SOLVE: { @@ -283,7 +297,8 @@ ScTabViewShell::CreateRefDialogController(SfxBindings* pB, SfxChildWindow* pCW, ScAddress aCurPos( rViewData.GetCurX(), rViewData.GetCurY(), rViewData.CurrentTabForData()); - xResult = std::make_shared(pB, pCW, pParent, &rViewData.GetDocument(), aCurPos); + xResult = std::make_shared(&rBindings, pCW, pParent, + &rViewData.GetDocument(), aCurPos); break; } case SID_OPENDLG_TABOP: @@ -293,7 +308,8 @@ ScTabViewShell::CreateRefDialogController(SfxBindings* pB, SfxChildWindow* pCW, rViewData.GetCurY(), rViewData.CurrentTabForData()); - xResult = std::make_shared(pB, pCW, pParent, &rViewData.GetDocument(), aCurPos); + xResult = std::make_shared(&rBindings, pCW, pParent, + &rViewData.GetDocument(), aCurPos); break; } case SID_OPENDLG_CONSOLIDATE: @@ -329,12 +345,13 @@ ScTabViewShell::CreateRefDialogController(SfxBindings* pB, SfxChildWindow* pCW, { aArgSet.Put( ScConsolidateItem( SCITEM_CONSOLIDATEDATA, pDlgData ) ); } - xResult = std::make_shared(pB, pCW, pParent, aArgSet); + xResult = std::make_shared(&rBindings, pCW, pParent, aArgSet); break; } case SID_EASY_CONDITIONAL_FORMAT_DIALOG: { - xResult = std::make_shared(pB, pCW, pParent, GetViewData()); + xResult = std::make_shared(&rBindings, pCW, pParent, + GetViewData()); break; } case SID_FILTER: @@ -356,7 +373,8 @@ ScTabViewShell::CreateRefDialogController(SfxBindings* pB, SfxChildWindow* pCW, // mark current sheet (due to RefInput in dialog) GetViewData().SetRefTabNo( GetViewData().CurrentTabForData() ); - xResult = std::make_shared(pB, pCW, pParent, GetViewData(), aArgSet); + xResult = std::make_shared(&rBindings, pCW, pParent, GetViewData(), + aArgSet); } break; } @@ -385,7 +403,8 @@ ScTabViewShell::CreateRefDialogController(SfxBindings* pB, SfxChildWindow* pCW, // mark current sheet (due to RefInput in dialog) GetViewData().SetRefTabNo( GetViewData().CurrentTabForData() ); - xResult = std::make_shared(pB, pCW, pParent, GetViewData(), aArgSet); + xResult = std::make_shared(&rBindings, pCW, pParent, + GetViewData(), aArgSet); } break; } @@ -393,18 +412,19 @@ ScTabViewShell::CreateRefDialogController(SfxBindings* pB, SfxChildWindow* pCW, { ScViewData& rViewData = GetViewData(); ScAddress aCurPos( rViewData.GetCurX(), rViewData.GetCurY(), rViewData.CurrentTabForData()); - xResult = std::make_shared(pB, pCW, pParent, rViewData.GetDocShell(), aCurPos); + xResult = std::make_shared(&rBindings, pCW, pParent, + rViewData.GetDocShell(), aCurPos); break; } case FID_CHG_SHOW: { // dialog checks, what is in the cell - xResult = std::make_shared(pB, pCW, pParent, GetViewData()); + xResult = std::make_shared(&rBindings, pCW, pParent, GetViewData()); break; } case SID_MANAGE_XML_SOURCE: { - xResult = std::make_shared(pB, pCW, pParent, rDoc); + xResult = std::make_shared(&rBindings, pCW, pParent, rDoc); break; } case SID_OPENDLG_PIVOTTABLE: @@ -417,7 +437,8 @@ ScTabViewShell::CreateRefDialogController(SfxBindings* pB, SfxChildWindow* pCW, ScViewData& rViewData = GetViewData(); rViewData.SetRefTabNo( rViewData.CurrentTabForData() ); ScDPObject* pObj = rDoc.GetDPAtCursor(rViewData.GetCurX(), rViewData.GetCurY(), rViewData.CurrentTabForData()); - xResult = std::make_shared(pB, pCW, pParent, rViewData, pDialogDPObject.get(), pObj == nullptr); + xResult = std::make_shared( + &rBindings, pCW, pParent, rViewData, pDialogDPObject.get(), pObj == nullptr); } break; @@ -425,7 +446,8 @@ ScTabViewShell::CreateRefDialogController(SfxBindings* pB, SfxChildWindow* pCW, case SID_OPENDLG_FUNCTION: { // dialog checks, what is in the cell - xResult = std::make_shared(pB, pCW, pParent, GetViewData(), ScGlobal::GetStarCalcFunctionMgr()); + xResult = std::make_shared(&rBindings, pCW, pParent, GetViewData(), + ScGlobal::GetStarCalcFunctionMgr()); break; } case WID_CONDFRMT_REF: @@ -438,7 +460,8 @@ ScTabViewShell::CreateRefDialogController(SfxBindings* pB, SfxChildWindow* pCW, ScViewData& rViewData = GetViewData(); rViewData.SetRefTabNo( rViewData.CurrentTabForData() ); - xResult = std::make_shared(pB, pCW, pParent, rViewData, rDlgData); + xResult = std::make_shared(&rBindings, pCW, pParent, rViewData, + rDlgData); // Remove the DialogData stored by Conditional Format Manager Dialog. setScCondFormatDlgData(nullptr);