sw/source/ui/fldui/fldtdlg.cxx | 7 ++++- sw/source/ui/index/swuiidxmrk.cxx | 15 ++++++++---- sw/source/uibase/app/docst.cxx | 3 +- sw/source/uibase/envelp/syncbtn.cxx | 3 +- sw/source/uibase/ribbar/workctrl.cxx | 14 +++++++---- sw/source/uibase/shells/translatehelper.cxx | 2 - sw/source/uibase/sidebar/PageOrientationControl.cxx | 25 +++++++++++--------- 7 files changed, 44 insertions(+), 25 deletions(-)
New commits: commit 223c5b7fe5e2a967f8b6067ba435410b57faa49a Author: Caolán McNamara <[email protected]> AuthorDate: Thu Dec 15 16:48:09 2022 +0000 Commit: Xisco Fauli <[email protected]> CommitDate: Fri Dec 16 07:54:12 2022 +0000 sw: check SfxViewFrame::Current() these ones looks potentially worth backporting Change-Id: I294fa029b53fa9d43cb738f07278301e2a06c210 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144254 Tested-by: Jenkins Reviewed-by: Xisco Fauli <[email protected]> diff --git a/sw/source/ui/fldui/fldtdlg.cxx b/sw/source/ui/fldui/fldtdlg.cxx index a3886591a4c2..3c83365a206f 100644 --- a/sw/source/ui/fldui/fldtdlg.cxx +++ b/sw/source/ui/fldui/fldtdlg.cxx @@ -180,8 +180,11 @@ void SwFieldDlg::ReInitDlg() if (bNewMode != m_bHtmlMode) { - SfxViewFrame::Current()->GetDispatcher()-> - Execute(FN_INSERT_FIELD, SfxCallMode::ASYNCHRON|SfxCallMode::RECORD); + if (SfxViewFrame* pViewFrm = SfxViewFrame::Current()) + { + pViewFrm->GetDispatcher()-> + Execute(FN_INSERT_FIELD, SfxCallMode::ASYNCHRON|SfxCallMode::RECORD); + } Close(); } diff --git a/sw/source/ui/index/swuiidxmrk.cxx b/sw/source/ui/index/swuiidxmrk.cxx index 8166b4713c7e..fe3fa2b67282 100644 --- a/sw/source/ui/index/swuiidxmrk.cxx +++ b/sw/source/ui/index/swuiidxmrk.cxx @@ -686,8 +686,11 @@ IMPL_LINK_NOARG(SwIndexMarkPane, CloseHdl, weld::Button&, void) { if (m_bNewMark) { - SfxViewFrame::Current()->GetDispatcher()->Execute(FN_INSERT_IDX_ENTRY_DLG, - SfxCallMode::ASYNCHRON|SfxCallMode::RECORD); + if (SfxViewFrame* pViewFrm = SfxViewFrame::Current()) + { + pViewFrm->GetDispatcher()->Execute(FN_INSERT_IDX_ENTRY_DLG, + SfxCallMode::ASYNCHRON|SfxCallMode::RECORD); + } } else { @@ -819,7 +822,8 @@ IMPL_LINK_NOARG(SwIndexMarkPane, DelHdl, weld::Button&, void) else { CloseHdl(*m_xCloseBT); - SfxViewFrame::Current()->GetBindings().Invalidate(FN_EDIT_IDX_ENTRY_DLG); + if (SfxViewFrame* pViewFrm = SfxViewFrame::Current()) + pViewFrm->GetBindings().Invalidate(FN_EDIT_IDX_ENTRY_DLG); } } @@ -1218,8 +1222,11 @@ IMPL_LINK_NOARG(SwAuthorMarkPane, CloseHdl, weld::Button&, void) { if(m_bNewEntry) { - SfxViewFrame::Current()->GetDispatcher()->Execute(FN_INSERT_AUTH_ENTRY_DLG, + if (SfxViewFrame* pViewFrm = SfxViewFrame::Current()) + { + pViewFrm->GetDispatcher()->Execute(FN_INSERT_AUTH_ENTRY_DLG, SfxCallMode::ASYNCHRON|SfxCallMode::RECORD); + } } else { diff --git a/sw/source/uibase/app/docst.cxx b/sw/source/uibase/app/docst.cxx index baa2a4ca74ef..f13b90b70af6 100644 --- a/sw/source/uibase/app/docst.cxx +++ b/sw/source/uibase/app/docst.cxx @@ -1186,7 +1186,8 @@ SfxStyleFamily SwDocShell::ApplyStyles(const OUString &rName, SfxStyleFamily nFa const SwNumRule* pNumRule = pStyle->GetNumRule(); if (pNumRule->GetName() == SwResId(STR_POOLNUMRULE_NOLIST)) { - SfxViewFrame::Current()->GetDispatcher()->Execute(FN_NUM_BULLET_OFF); + if (SfxViewFrame* pViewFrm = SfxViewFrame::Current()) + pViewFrm->GetDispatcher()->Execute(FN_NUM_BULLET_OFF); break; } const OUString sListIdForStyle =pNumRule->GetDefaultListId(); diff --git a/sw/source/uibase/envelp/syncbtn.cxx b/sw/source/uibase/envelp/syncbtn.cxx index 0b61ff8a6c72..0b30c494b044 100644 --- a/sw/source/uibase/envelp/syncbtn.cxx +++ b/sw/source/uibase/envelp/syncbtn.cxx @@ -80,7 +80,8 @@ SwSyncBtnDlg::~SwSyncBtnDlg() IMPL_STATIC_LINK_NOARG(SwSyncBtnDlg, BtnHdl, weld::Button&, void) { - SfxViewFrame::Current()->GetDispatcher()->Execute(FN_UPDATE_ALL_LINKS, SfxCallMode::ASYNCHRON); + if (SfxViewFrame* pViewFrm = SfxViewFrame::Current()) + pViewFrm->GetDispatcher()->Execute(FN_UPDATE_ALL_LINKS, SfxCallMode::ASYNCHRON); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/ribbar/workctrl.cxx b/sw/source/uibase/ribbar/workctrl.cxx index 8d7338281a42..53c747e478ed 100644 --- a/sw/source/uibase/ribbar/workctrl.cxx +++ b/sw/source/uibase/ribbar/workctrl.cxx @@ -420,10 +420,11 @@ void SwZoomBox_Impl::Select() m_xWidget->set_entry_text(m_xWidget->get_saved_value()); } - SfxObjectShell* pCurrentShell = SfxObjectShell::Current(); - - pCurrentShell->GetDispatcher()->ExecuteList(SID_ATTR_ZOOM, - SfxCallMode::ASYNCHRON, { &aZoom }); + if (SfxObjectShell* pCurrentShell = SfxObjectShell::Current()) + { + pCurrentShell->GetDispatcher()->ExecuteList(SID_ATTR_ZOOM, + SfxCallMode::ASYNCHRON, { &aZoom }); + } } ReleaseFocus(); } @@ -619,11 +620,14 @@ IMPL_STATIC_LINK(NavElementBox_Base, SelectHdl, weld::ComboBox&, rComboBox, void { if (!rComboBox.changed_by_direct_pick()) // only when picked from the list return; + SfxViewFrame* pViewFrm = SfxViewFrame::Current(); + if (!pViewFrm) + return; SfxUInt32Item aParam(FN_NAV_ELEMENT, rComboBox.get_active_id().toUInt32()); const SfxPoolItem* aArgs[2]; aArgs[0] = &aParam; aArgs[1] = nullptr; - SfxDispatcher* pDispatch = SfxViewFrame::Current()->GetBindings().GetDispatcher(); + SfxDispatcher* pDispatch = pViewFrm->GetBindings().GetDispatcher(); pDispatch->Execute(FN_NAV_ELEMENT, SfxCallMode::SYNCHRON, aArgs); } diff --git a/sw/source/uibase/shells/translatehelper.cxx b/sw/source/uibase/shells/translatehelper.cxx index e57a1cc96cdc..8933d22db27f 100644 --- a/sw/source/uibase/shells/translatehelper.cxx +++ b/sw/source/uibase/shells/translatehelper.cxx @@ -129,7 +129,7 @@ void TranslateDocumentCancellable(SwWrtShell& rWrtSh, const TranslateAPIConfig& } SfxViewFrame* pFrame = SfxViewFrame::Current(); - uno::Reference<frame::XFrame> xFrame = pFrame->GetFrame().GetFrameInterface(); + uno::Reference<frame::XFrame> xFrame(pFrame ? pFrame->GetFrame().GetFrameInterface() : nullptr); uno::Reference<task::XStatusIndicatorFactory> xProgressFactory(xFrame, uno::UNO_QUERY); uno::Reference<task::XStatusIndicator> xStatusIndicator; diff --git a/sw/source/uibase/sidebar/PageOrientationControl.cxx b/sw/source/uibase/sidebar/PageOrientationControl.cxx index 7f512d25516a..b123273ff3dc 100644 --- a/sw/source/uibase/sidebar/PageOrientationControl.cxx +++ b/sw/source/uibase/sidebar/PageOrientationControl.cxx @@ -78,7 +78,8 @@ void PageOrientationControl::ExecuteMarginLRChange( { mpPageLRMarginItem->SetLeft( nPageLeftMargin ); mpPageLRMarginItem->SetRight( nPageRightMargin ); - SfxViewShell::Current()->GetDispatcher()->ExecuteList(SID_ATTR_PAGE_LRSPACE, + if (SfxViewFrame* pViewFrm = SfxViewFrame::Current()) + pViewFrm->GetDispatcher()->ExecuteList(SID_ATTR_PAGE_LRSPACE, SfxCallMode::RECORD, { mpPageLRMarginItem.get() }); } @@ -88,20 +89,25 @@ void PageOrientationControl::ExecuteMarginULChange( { mpPageULMarginItem->SetUpper( nPageTopMargin ); mpPageULMarginItem->SetLower( nPageBottomMargin ); - SfxViewShell::Current()->GetDispatcher()->ExecuteList(SID_ATTR_PAGE_ULSPACE, + if (SfxViewFrame* pViewFrm = SfxViewFrame::Current()) + pViewFrm->GetDispatcher()->ExecuteList(SID_ATTR_PAGE_ULSPACE, SfxCallMode::RECORD, { mpPageULMarginItem.get() }); } void PageOrientationControl::ExecuteOrientationChange( const bool bLandscape ) { + SfxViewFrame* pViewFrm = SfxViewFrame::Current(); + if (!pViewFrm) + return; + 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); mpPageSizeItem.reset( pSizeItem->Clone() ); // Prevent accidental toggling of page orientation @@ -113,11 +119,11 @@ void PageOrientationControl::ExecuteOrientationChange( const bool bLandscape ) } const SvxLongLRSpaceItem* pLRSpaceItem; - SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState(SID_ATTR_PAGE_LRSPACE, pLRSpaceItem); + pViewFrm->GetBindings().GetDispatcher()->QueryState(SID_ATTR_PAGE_LRSPACE, pLRSpaceItem); mpPageLRMarginItem.reset( pLRSpaceItem->Clone() ); const SvxLongULSpaceItem* pULSpaceItem; - SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState(SID_ATTR_PAGE_ULSPACE, pULSpaceItem); + pViewFrm->GetBindings().GetDispatcher()->QueryState(SID_ATTR_PAGE_ULSPACE, pULSpaceItem); mpPageULMarginItem.reset( pULSpaceItem->Clone() ); { @@ -130,11 +136,8 @@ void PageOrientationControl::ExecuteOrientationChange( const bool bLandscape ) mpPageSizeItem->SetSize(Size(nRotatedWidth, nRotatedHeight)); // apply changed attributes - if (SfxViewShell::Current()) - { - SfxViewShell::Current()->GetDispatcher()->ExecuteList(SID_ATTR_PAGE_SIZE, - SfxCallMode::RECORD, { mpPageSizeItem.get(), mpPageItem.get() }); - } + pViewFrm->GetDispatcher()->ExecuteList(SID_ATTR_PAGE_SIZE, + SfxCallMode::RECORD, { mpPageSizeItem.get(), mpPageItem.get() }); } // check, if margin values still fit to the changed page size.
