cui/source/customize/CustomNotebookbarGenerator.cxx | 13 ++++++++----- desktop/source/lib/init.cxx | 12 ++++++++---- 2 files changed, 16 insertions(+), 9 deletions(-)
New commits: commit 7f773612d8554a2a9131c94582359a837d0c4f7b Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Thu Dec 15 20:15:45 2022 +0000 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Fri Dec 16 19:46:17 2022 +0000 misc: check SfxViewFrame::Current() these ones look potentially worth backporting Change-Id: Ie01c0b598c3408f4766318267de8438e997dd1a2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144261 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> (cherry picked from commit a36bcfc15c8287b99702be064aae93e9632e9aa0) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144297 Reviewed-by: Michael Stahl <michael.st...@allotropia.de> Reviewed-by: Caolán McNamara <caol...@redhat.com> Tested-by: Caolán McNamara <caol...@redhat.com> diff --git a/cui/source/customize/CustomNotebookbarGenerator.cxx b/cui/source/customize/CustomNotebookbarGenerator.cxx index 9fb71562160a..bae85525ebd6 100644 --- a/cui/source/customize/CustomNotebookbarGenerator.cxx +++ b/cui/source/customize/CustomNotebookbarGenerator.cxx @@ -74,11 +74,14 @@ static OUString lcl_getAppName(vcl::EnumContext::Application eApp) static OUString getAppNameRegistryPath() { vcl::EnumContext::Application eApp = vcl::EnumContext::Application::Any; - const Reference<frame::XFrame>& xFrame - = SfxViewFrame::Current()->GetFrame().GetFrameInterface(); - const Reference<frame::XModuleManager> xModuleManager - = frame::ModuleManager::create(::comphelper::getProcessComponentContext()); - eApp = vcl::EnumContext::GetApplicationEnum(xModuleManager->identify(xFrame)); + + if (SfxViewFrame* pViewFrame = SfxViewFrame::Current()) + { + const Reference<frame::XFrame>& xFrame = pViewFrame->GetFrame().GetFrameInterface(); + const Reference<frame::XModuleManager> xModuleManager + = frame::ModuleManager::create(::comphelper::getProcessComponentContext()); + eApp = vcl::EnumContext::GetApplicationEnum(xModuleManager->identify(xFrame)); + } OUString sAppName(lcl_getAppName(eApp)); return "org.openoffice.Office.UI.ToolbarMode/Applications/" + sAppName; diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 52fd35a23104..ee35a421a6c8 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -761,6 +761,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<SvxPageItem> pPageItem(new SvxPageItem(SID_ATTR_PAGE)); // 1mm in twips rounded @@ -768,22 +772,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<SvxSizeItem> 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<SvxLongLRSpaceItem> 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<SvxLongULSpaceItem> pPageULMarginItem(pULSpaceItem->Clone()); {