From 70e2383eaad96c8a6079613d9924063f41880724 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Thu, 15 Dec 2022 20:15:45 +0000 Subject: misc: check SfxViewFrame::Current() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit these ones look potentially worth backporting Change-Id: Ie01c0b598c3408f4766318267de8438e997dd1a2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144278 Tested-by: Caolán McNamara Reviewed-by: Caolán McNamara --- desktop/source/lib/init.cxx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'desktop') diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 19937da00d6d..22efa304865a 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -792,6 +792,10 @@ void ExecuteMarginULChange( // Main function which toggles page orientation of the Writer doc. Needed by ToggleOrientation void ExecuteOrientationChange() { + SfxViewFrame* pViewFrm = SfxViewFrame::Current(); + if (!pViewFrm) + return; + std::unique_ptr pPageItem(new SvxPageItem(SID_ATTR_PAGE)); // 1mm in twips rounded @@ -799,22 +803,22 @@ void ExecuteOrientationChange() constexpr tools::Long MINBODY = o3tl::toTwips(1, o3tl::Length::mm); css::uno::Reference< css::document::XUndoManager > mxUndoManager( - getUndoManager( SfxViewFrame::Current()->GetFrame().GetFrameInterface() ) ); + getUndoManager( pViewFrm->GetFrame().GetFrameInterface() ) ); if ( mxUndoManager.is() ) mxUndoManager->enterUndoContext( "" ); const SvxSizeItem* pSizeItem; - SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState(SID_ATTR_PAGE_SIZE, pSizeItem); + pViewFrm->GetBindings().GetDispatcher()->QueryState(SID_ATTR_PAGE_SIZE, pSizeItem); std::unique_ptr pPageSizeItem(pSizeItem->Clone()); const SvxLongLRSpaceItem* pLRSpaceItem; - SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState(SID_ATTR_PAGE_LRSPACE, pLRSpaceItem); + pViewFrm->GetBindings().GetDispatcher()->QueryState(SID_ATTR_PAGE_LRSPACE, pLRSpaceItem); std::unique_ptr pPageLRMarginItem(pLRSpaceItem->Clone()); const SvxLongULSpaceItem* pULSpaceItem; - SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState(SID_ATTR_PAGE_ULSPACE, pULSpaceItem); + pViewFrm->GetBindings().GetDispatcher()->QueryState(SID_ATTR_PAGE_ULSPACE, pULSpaceItem); std::unique_ptr pPageULMarginItem(pULSpaceItem->Clone()); { -- cgit