From 692482b5220b9c54ff6753a47418fba95c9d68f4 Mon Sep 17 00:00:00 2001 From: Michael Weghorn Date: Thu, 17 Sep 2026 14:12:56 +0200 Subject: [PATCH] sfx2: Pass SfxPrinterController's SfxViewShell by ref Switch the SSfxViewShell param for the SfxPrinterController from pointer to reference to make clear it's always non-null. This allows to drop now superfluous null-checks. Change-Id: I49862b6eeffbf7db388520e801a50557205631a9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/211074 Reviewed-by: Michael Weghorn Tested-by: Jenkins --- sfx2/source/view/viewprn.cxx | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/sfx2/source/view/viewprn.cxx b/sfx2/source/view/viewprn.cxx index 8507dbd1fcf0..543340af6b8e 100644 --- a/sfx2/source/view/viewprn.cxx +++ b/sfx2/source/view/viewprn.cxx @@ -90,7 +90,7 @@ public: const Any& i_rViewProp, const Reference< view::XRenderable >& i_xRender, bool i_bApi, bool i_bDirect, - SfxViewShell* pView, + SfxViewShell& rView, const uno::Sequence< beans::PropertyValue >& rProps ); @@ -109,15 +109,15 @@ SfxPrinterController::SfxPrinterController( const VclPtr& i_rPrinter, const Any& i_rViewProp, const Reference< view::XRenderable >& i_xRender, bool i_bApi, bool i_bDirect, - SfxViewShell* pView, + SfxViewShell& rView, const uno::Sequence< beans::PropertyValue >& rProps ) - : PrinterController(i_rPrinter, pView ? pView->GetFrameWeld() : nullptr) + : PrinterController(i_rPrinter, rView.GetFrameWeld()) , maCompleteSelection(std::move( i_Complete )) , maSelection(std::move( i_Selection )) , mxRenderable( i_xRender ) , mpLastPrinter( nullptr ) - , mpViewShell( pView ) + , mpViewShell(&rView) , mpObjectShell(nullptr) , m_bJobStarted( false ) , m_bOrigStatus( false ) @@ -125,12 +125,9 @@ SfxPrinterController::SfxPrinterController( const VclPtr& i_rPrinter, , m_bApi(i_bApi) , m_bTempPrinter( i_rPrinter ) { - if ( mpViewShell ) - { - StartListening( *mpViewShell ); - mpObjectShell = mpViewShell->GetObjectShell(); - StartListening( *mpObjectShell ); - } + StartListening(*mpViewShell); + mpObjectShell = mpViewShell->GetObjectShell(); + StartListening(*mpObjectShell); // initialize extra ui options if( mxRenderable.is() ) @@ -606,16 +603,7 @@ void SfxViewShell::StartPrint( const uno::Sequence < beans::PropertyValue >& rPr } std::shared_ptr xNewController(std::make_shared( - aPrt, - aComplete, - aSelection, - aViewProp, - GetRenderable(), - bIsAPI, - bIsDirect, - this, - rProps - )); + aPrt, aComplete, aSelection, aViewProp, GetRenderable(), bIsAPI, bIsDirect, *this, rProps)); pImpl->m_xPrinterController = xNewController; // When no JobName was specified via com::sun::star::view::PrintOptions::JobName ,