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/PageColumnControl.cxx | 12 ++--- sw/source/uibase/sidebar/PageMarginControl.cxx | 42 +++++++++----------- sw/source/uibase/sidebar/PageOrientationControl.cxx | 25 ++++++----- sw/source/uibase/sidebar/PageSizeControl.cxx | 32 ++++++--------- sw/source/uibase/uiview/viewsrch.cxx | 6 +- sw/source/uibase/utlui/bookctrl.cxx | 6 ++ 12 files changed, 91 insertions(+), 76 deletions(-)
New commits: commit 3867cb55ddf1bfdefdb7d7a198b275793efb9ed1 Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Thu Dec 15 16:48:09 2022 +0000 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Thu Dec 15 21:30:38 2022 +0000 sw: check SfxViewFrame::Current() these ones looks potentially worth backporting Change-Id: I294fa029b53fa9d43cb738f07278301e2a06c210 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144245 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caol...@redhat.com> 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 3669db6c52f2..f70662f8c73d 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. commit 54aa8993baba2a9463a5b412c6c7575efa89bb67 Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Thu Dec 15 16:40:53 2022 +0000 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Thu Dec 15 21:30:31 2022 +0000 sw: check SfxViewFrame::Current() SfxViewFrame::Current() is a festering wound, these ones look like they were safe anyway, so no need to backport. But with enough checked static analysis will kick in to flag new unchecked ones. Change-Id: I359d71bda2ad1f8f720fae1f87a13eae94bb763c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144244 Tested-by: Caolán McNamara <caol...@redhat.com> Reviewed-by: Caolán McNamara <caol...@redhat.com> diff --git a/sw/source/uibase/sidebar/PageColumnControl.cxx b/sw/source/uibase/sidebar/PageColumnControl.cxx index 18d4ef4248d1..bc8d45d2e46b 100644 --- a/sw/source/uibase/sidebar/PageColumnControl.cxx +++ b/sw/source/uibase/sidebar/PageColumnControl.cxx @@ -37,10 +37,10 @@ PageColumnControl::PageColumnControl(PageColumnPopup* pControl, weld::Widget* pP , m_xControl(pControl) { bool bLandscape = false; - if ( SfxViewFrame::Current() ) + if (SfxViewFrame* pViewFrm = SfxViewFrame::Current()) { const SvxPageItem *pPageItem; - SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState( SID_ATTR_PAGE, pPageItem ); + pViewFrm->GetBindings().GetDispatcher()->QueryState( SID_ATTR_PAGE, pPageItem ); bLandscape = pPageItem->IsLandscape(); } @@ -89,8 +89,8 @@ void PageColumnControl::ExecuteColumnChange( const sal_uInt16 nColumnType ) { SfxInt16Item aPageColumnTypeItem(SID_ATTR_PAGE_COLUMN); aPageColumnTypeItem.SetValue( nColumnType ); - if ( SfxViewFrame::Current() ) - SfxViewFrame::Current()->GetBindings().GetDispatcher()->ExecuteList(SID_ATTR_PAGE_COLUMN, + if (SfxViewFrame* pViewFrm = SfxViewFrame::Current()) + pViewFrm->GetBindings().GetDispatcher()->ExecuteList(SID_ATTR_PAGE_COLUMN, SfxCallMode::RECORD, { &aPageColumnTypeItem }); } @@ -112,8 +112,8 @@ IMPL_LINK( PageColumnControl, ColumnButtonClickHdl_Impl, weld::Button&, rButton, IMPL_LINK_NOARG( PageColumnControl, MoreButtonClickHdl_Impl, weld::Button&, void ) { - if ( SfxViewFrame::Current() ) - SfxViewFrame::Current()->GetBindings().GetDispatcher()->Execute( FN_FORMAT_PAGE_COLUMN_DLG, SfxCallMode::ASYNCHRON ); + if (SfxViewFrame* pViewFrm = SfxViewFrame::Current()) + pViewFrm->GetBindings().GetDispatcher()->Execute( FN_FORMAT_PAGE_COLUMN_DLG, SfxCallMode::ASYNCHRON ); m_xControl->EndPopupMode(); } diff --git a/sw/source/uibase/sidebar/PageMarginControl.cxx b/sw/source/uibase/sidebar/PageMarginControl.cxx index f6e0caa727bc..217c6f7d7fa7 100644 --- a/sw/source/uibase/sidebar/PageMarginControl.cxx +++ b/sw/source/uibase/sidebar/PageMarginControl.cxx @@ -53,19 +53,14 @@ namespace { FieldUnit lcl_GetFieldUnit() { - FieldUnit eUnit = FieldUnit::INCH; - const SfxUInt16Item* pItem = nullptr; - SfxItemState eState = SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState( SID_ATTR_METRIC, pItem ); - if ( pItem && eState >= SfxItemState::DEFAULT ) + if (SfxViewFrame* pViewFrm = SfxViewFrame::Current()) { - eUnit = static_cast<FieldUnit>(pItem->GetValue()); + const SfxUInt16Item* pItem = nullptr; + SfxItemState eState = pViewFrm->GetBindings().GetDispatcher()->QueryState(SID_ATTR_METRIC, pItem); + if (pItem && eState >= SfxItemState::DEFAULT) + return static_cast<FieldUnit>(pItem->GetValue()); } - else - { - return SfxModule::GetCurrentFieldUnit(); - } - - return eUnit; + return SfxModule::GetCurrentFieldUnit(); } MapUnit lcl_GetUnit() @@ -130,15 +125,15 @@ PageMarginControl::PageMarginControl(PageMarginPopup* pControl, weld::Widget* pP const SvxSizeItem* pSize = nullptr; const SvxLongLRSpaceItem* pLRItem = nullptr; const SvxLongULSpaceItem* pULItem = nullptr; - if ( SfxViewFrame::Current() ) + if (SfxViewFrame* pViewFrm = SfxViewFrame::Current()) { const SvxPageItem* pPageItem; - SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState( SID_ATTR_PAGE, pPageItem ); + pViewFrm->GetBindings().GetDispatcher()->QueryState( SID_ATTR_PAGE, pPageItem ); bLandscape = pPageItem->IsLandscape(); m_bMirrored = pPageItem->GetPageUsage() == SvxPageUsage::Mirror; - SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState( SID_ATTR_PAGE_SIZE, pSize ); - SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState( SID_ATTR_PAGE_LRSPACE, pLRItem ); - SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState( SID_ATTR_PAGE_ULSPACE, pULItem ); + pViewFrm->GetBindings().GetDispatcher()->QueryState( SID_ATTR_PAGE_SIZE, pSize ); + pViewFrm->GetBindings().GetDispatcher()->QueryState( SID_ATTR_PAGE_LRSPACE, pLRItem ); + pViewFrm->GetBindings().GetDispatcher()->QueryState( SID_ATTR_PAGE_ULSPACE, pULItem ); } if ( pLRItem ) @@ -398,7 +393,8 @@ IMPL_LINK( PageMarginControl, SelectMarginHdl, weld::Button&, rControl, void ) if ( !bApplyNewPageMargins ) return; - const css::uno::Reference< css::document::XUndoManager > xUndoManager( getUndoManager( SfxViewFrame::Current()->GetFrame().GetFrameInterface() ) ); + SfxViewFrame* pViewFrm = SfxViewFrame::Current(); + const css::uno::Reference<css::document::XUndoManager> xUndoManager(pViewFrm ? getUndoManager(pViewFrm->GetFrame().GetFrameInterface()) : nullptr); if ( xUndoManager.is() ) xUndoManager->enterUndoContext( "" ); @@ -421,12 +417,12 @@ void PageMarginControl::ExecuteMarginLRChange( const tools::Long nPageLeftMargin, const tools::Long nPageRightMargin ) { - if ( SfxViewFrame::Current() ) + if (SfxViewFrame* pViewFrm = SfxViewFrame::Current()) { SvxLongLRSpaceItem aPageLRMarginItem( 0, 0, SID_ATTR_PAGE_LRSPACE ); aPageLRMarginItem.SetLeft( nPageLeftMargin ); aPageLRMarginItem.SetRight( nPageRightMargin ); - SfxViewFrame::Current()->GetBindings().GetDispatcher()->ExecuteList( SID_ATTR_PAGE_LRSPACE, + pViewFrm->GetBindings().GetDispatcher()->ExecuteList( SID_ATTR_PAGE_LRSPACE, SfxCallMode::RECORD, { &aPageLRMarginItem } ); } } @@ -435,23 +431,23 @@ void PageMarginControl::ExecuteMarginULChange( const tools::Long nPageTopMargin, const tools::Long nPageBottomMargin ) { - if ( SfxViewFrame::Current() ) + if (SfxViewFrame* pViewFrm = SfxViewFrame::Current()) { SvxLongULSpaceItem aPageULMarginItem( 0, 0, SID_ATTR_PAGE_ULSPACE ); aPageULMarginItem.SetUpper( nPageTopMargin ); aPageULMarginItem.SetLower( nPageBottomMargin ); - SfxViewFrame::Current()->GetBindings().GetDispatcher()->ExecuteList( SID_ATTR_PAGE_ULSPACE, + pViewFrm->GetBindings().GetDispatcher()->ExecuteList( SID_ATTR_PAGE_ULSPACE, SfxCallMode::RECORD, { &aPageULMarginItem } ); } } void PageMarginControl::ExecutePageLayoutChange( const bool bMirrored ) { - if ( SfxViewFrame::Current() ) + if (SfxViewFrame* pViewFrm = SfxViewFrame::Current()) { SvxPageItem aPageItem( SID_ATTR_PAGE ); aPageItem.SetPageUsage( bMirrored ? SvxPageUsage::Mirror : SvxPageUsage::All ); - SfxViewFrame::Current()->GetBindings().GetDispatcher()->ExecuteList( SID_ATTR_PAGE, + pViewFrm->GetBindings().GetDispatcher()->ExecuteList( SID_ATTR_PAGE, SfxCallMode::RECORD, { &aPageItem } ); } } diff --git a/sw/source/uibase/sidebar/PageSizeControl.cxx b/sw/source/uibase/sidebar/PageSizeControl.cxx index 85c41ae80689..211ebece9e5e 100644 --- a/sw/source/uibase/sidebar/PageSizeControl.cxx +++ b/sw/source/uibase/sidebar/PageSizeControl.cxx @@ -45,19 +45,14 @@ namespace { FieldUnit lcl_GetFieldUnit() { - FieldUnit eUnit = FieldUnit::INCH; const SfxUInt16Item* pItem = nullptr; - SfxItemState eState = SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState( SID_ATTR_METRIC, pItem ); - if ( pItem && eState >= SfxItemState::DEFAULT ) + if (SfxViewFrame* pViewFrm = SfxViewFrame::Current()) { - eUnit = static_cast<FieldUnit>(pItem->GetValue()); + SfxItemState eState = pViewFrm->GetBindings().GetDispatcher()->QueryState(SID_ATTR_METRIC, pItem); + if (pItem && eState >= SfxItemState::DEFAULT) + return static_cast<FieldUnit>(pItem->GetValue()); } - else - { - return SfxModule::GetCurrentFieldUnit(); - } - - return eUnit; + return SfxModule::GetCurrentFieldUnit(); } MapUnit lcl_GetUnit() @@ -120,12 +115,12 @@ PageSizeControl::PageSizeControl(PageSizePopup* pControl, weld::Widget* pParent) bool bLandscape = false; const SvxSizeItem* pSize = nullptr; - if ( SfxViewFrame::Current() ) + if (SfxViewFrame* pViewFrm = SfxViewFrame::Current()) { const SvxPageItem* pPageItem; - SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState( SID_ATTR_PAGE, pPageItem ); + pViewFrm->GetBindings().GetDispatcher()->QueryState( SID_ATTR_PAGE, pPageItem ); bLandscape = pPageItem->IsLandscape(); - SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState( SID_ATTR_PAGE_SIZE, pSize ); + pViewFrm->GetBindings().GetDispatcher()->QueryState( SID_ATTR_PAGE_SIZE, pSize ); } const LocaleDataWrapper& localeDataWrapper = Application::GetSettings().GetLocaleDataWrapper(); @@ -195,10 +190,11 @@ void PageSizeControl::ExecuteSizeChange( const Paper ePaper ) bool bLandscape = false; const SvxPageItem *pItem; MapUnit eUnit = lcl_GetUnit(); - if ( !SfxViewFrame::Current() ) + SfxViewFrame* pViewFrm = SfxViewFrame::Current(); + if (!pViewFrm) return; - SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState( SID_ATTR_PAGE, pItem ); + pViewFrm->GetBindings().GetDispatcher()->QueryState( SID_ATTR_PAGE, pItem ); bLandscape = pItem->IsLandscape(); SvxSizeItem aPageSizeItem(SID_ATTR_PAGE_SIZE); @@ -209,7 +205,7 @@ void PageSizeControl::ExecuteSizeChange( const Paper ePaper ) } aPageSizeItem.SetSize( aPageSize ); - SfxViewFrame::Current()->GetDispatcher()->ExecuteList(SID_ATTR_PAGE_SIZE, + pViewFrm->GetDispatcher()->ExecuteList(SID_ATTR_PAGE_SIZE, SfxCallMode::RECORD, { &aPageSizeItem }); } @@ -226,8 +222,8 @@ IMPL_LINK_NOARG(PageSizeControl, ImplSizeHdl, ValueSet*, void) IMPL_LINK_NOARG(PageSizeControl, MoreButtonClickHdl_Impl, weld::Button&, void) { - if ( SfxViewFrame::Current() ) - SfxViewFrame::Current()->GetDispatcher()->Execute( FN_FORMAT_PAGE_SETTING_DLG, SfxCallMode::ASYNCHRON ); + if (SfxViewFrame* pViewFrm = SfxViewFrame::Current()) + pViewFrm->GetDispatcher()->Execute( FN_FORMAT_PAGE_SETTING_DLG, SfxCallMode::ASYNCHRON ); mxControl->EndPopupMode(); } diff --git a/sw/source/uibase/uiview/viewsrch.cxx b/sw/source/uibase/uiview/viewsrch.cxx index 269bce441ed8..4125f1b17343 100644 --- a/sw/source/uibase/uiview/viewsrch.cxx +++ b/sw/source/uibase/uiview/viewsrch.cxx @@ -830,10 +830,10 @@ SvxSearchDialog* SwView::GetSearchDialog() { #if HAVE_FEATURE_DESKTOP const sal_uInt16 nId = SvxSearchDialogWrapper::GetChildWindowId(); - SfxViewFrame* pFrame = SfxViewFrame::Current(); - if (!pFrame) + SfxViewFrame* pViewFrm = SfxViewFrame::Current(); + if (!pViewFrm) return nullptr; - SvxSearchDialogWrapper *pWrp = static_cast<SvxSearchDialogWrapper*>(pFrame->GetChildWindow(nId)); + SvxSearchDialogWrapper *pWrp = static_cast<SvxSearchDialogWrapper*>(pViewFrm->GetChildWindow(nId)); if (!pWrp) return nullptr; return pWrp->getDialog(); diff --git a/sw/source/uibase/utlui/bookctrl.cxx b/sw/source/uibase/utlui/bookctrl.cxx index 77567198257c..4cd9029fd339 100644 --- a/sw/source/uibase/utlui/bookctrl.cxx +++ b/sw/source/uibase/utlui/bookctrl.cxx @@ -75,6 +75,10 @@ void SwBookmarkControl::Command( const CommandEvent& rCEvt ) if( !(pWrtShell && pWrtShell->getIDocumentMarkAccess()->getAllMarksCount() > 0) ) return; + SfxViewFrame* pViewFrm = SfxViewFrame::Current(); + if (!pViewFrm) + return; + std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(nullptr, "modules/swriter/ui/bookmarkmenu.ui")); std::unique_ptr<weld::Menu> xPopup(xBuilder->weld_menu("menu")); @@ -99,7 +103,7 @@ void SwBookmarkControl::Command( const CommandEvent& rCEvt ) if (!sResult.isEmpty()) { SfxUInt16Item aBookmark( FN_STAT_BOOKMARK, aBookmarkIdx[sResult.toUInt32()] ); - SfxViewFrame::Current()->GetDispatcher()->ExecuteList(FN_STAT_BOOKMARK, + pViewFrm->GetDispatcher()->ExecuteList(FN_STAT_BOOKMARK, SfxCallMode::ASYNCHRON|SfxCallMode::RECORD, { &aBookmark }); }