diff options
author | Caolán McNamara <caolanm@redhat.com> | 2022-12-15 20:15:45 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2022-12-16 10:23:09 +0000 |
commit | 70e2383eaad96c8a6079613d9924063f41880724 (patch) | |
tree | 26872bdc128940ec90f775260dd1bcc1afb35654 | |
parent | 56e0b27d39e266be49fac93361944878ff763acd (diff) |
misc: check SfxViewFrame::Current()
these ones look potentially worth backporting
Change-Id: Ie01c0b598c3408f4766318267de8438e997dd1a2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144278
Tested-by: Caolán McNamara <caolanm@redhat.com>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | cui/source/customize/CustomNotebookbarGenerator.cxx | 13 | ||||
-rw-r--r-- | desktop/source/lib/init.cxx | 12 |
2 files changed, 16 insertions, 9 deletions
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 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<SvxPageItem> 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<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()); { |