summaryrefslogtreecommitdiff
path: root/sw/source
diff options
context:
space:
mode:
authorArmin Le Grand (allotropia) <armin.le.grand.extern@allotropia.de>2023-12-20 19:42:28 +0100
committerArmin Le Grand <Armin.Le.Grand@me.com>2023-12-21 21:13:55 +0100
commit789a737ac92c4f2b0eb9820b99c43cc8253c8b29 (patch)
treebc167ec04de29e63168844be973f59980fa36ac2 /sw/source
parent3430a2c639a9f714259f9d319515464a653d21ab (diff)
Remove DeleteItemOnIdlex
There are some CrashReports in 7.6 which have DeleteItemOnIdle on the stack, but there is nothing reproducable. So I took a look... I first thought it's a MCGR regression, due to classes on the stack. But the Item involved is just random, can happen with any Item. Then I thought it may have to do with ITEM refactorings, but it happens with DeleteItemOnIdle involved, so also not the case. I already saw DeleteItemOnIdle when doing these and qualified as 'hack' in the way. already It is only on Windows and DeleteItemOnIdle is involved. This again (took a deeper look now) is an old hack to keep an SfxPoolItem 'alive' for some 'time'. For that, it triggers an async reschedule which then deletes the Item when being called. If the Item will be used after that is pure coincidence - seems to work in most cases. It seems as if for Windows the timing slightly changed for some scenarios, so a reschedule is too early. This can happen with this hack anytime. DeleteItemOnIdle is used in scenarios where SfxPoolItem* is e.g. returned, but is *not* anchored, so e.g. not member of an SfxItemSet. Or in short: Lifetime is not safe. DeleteItemOnIdle exists since 1st import, but was changed to AsyncEvent ca. 4 months ago (see 57145acf9ec47c23e307b7a5c0029d21d937cc35), so that may have caused it. It is possible that these errors happen on Windows since then. Before something more complicated was used to delete it late, but surely also not really safe. Due to ITEM refactor I have the knowledge/tooling to solve this. It will not be a 1-5 lines fix, but it is a hack and in the way for further ITEM refactor anyways. What we have nowadays is a SfxPoolItemHolder -> it's like an SfxItemSet for a single Item. It safely holds/ controls the lifetime of an SfxPoolItem. It is already used in quite some places. It helps to solve many hacks, also the ones putting Items directly to the Pool - due to there never was an alternative for that. In principle the ItemPool/ItemSet/Item paradigm was never complete without SfxPoolItemHolder. Thus I started to fix that (and remove that hack for good, sooo many changes over the years, sigh), but as said is not straightforward. Will have to change retvals of involved stuff to SfxPoolItemHolder - it's just two pointers and designed to be copied (one is a Pool, needed to cleanup when destructing). CopyConstruct/destroy just counts the RefCnt up/down, so cheap. 1st version compiling, let's check on gerrit... Corrected one error in QueryState for securitypage, also added some security features/asserts. Change-Id: Ida49fd35ca88ead84b11d93e18b978cb9e395090 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161083 Tested-by: Jenkins Reviewed-by: Armin Le Grand <Armin.Le.Grand@me.com>
Diffstat (limited to 'sw/source')
-rw-r--r--sw/source/core/doc/docglbl.cxx3
-rw-r--r--sw/source/ui/fldui/fldtdlg.cxx6
-rw-r--r--sw/source/uibase/app/apphdl.cxx14
-rw-r--r--sw/source/uibase/app/docsh2.cxx9
-rw-r--r--sw/source/uibase/dialog/watermarkdialog.cxx6
-rw-r--r--sw/source/uibase/misc/glshell.cxx7
-rw-r--r--sw/source/uibase/misc/redlndlg.cxx3
-rw-r--r--sw/source/uibase/shells/annotsh.cxx6
-rw-r--r--sw/source/uibase/shells/drwtxtex.cxx6
-rw-r--r--sw/source/uibase/sidebar/PageColumnControl.cxx5
-rw-r--r--sw/source/uibase/sidebar/PageFooterPanel.cxx1
-rw-r--r--sw/source/uibase/sidebar/PageHeaderPanel.cxx1
-rw-r--r--sw/source/uibase/sidebar/PageMarginControl.cxx22
-rw-r--r--sw/source/uibase/sidebar/PageOrientationControl.cxx16
-rw-r--r--sw/source/uibase/sidebar/PageSizeControl.cxx22
-rw-r--r--sw/source/uibase/sidebar/WrapPropertyPanel.cxx1
-rw-r--r--sw/source/uibase/uiview/srcview.cxx3
-rw-r--r--sw/source/uibase/uiview/view.cxx6
-rw-r--r--sw/source/uibase/uiview/viewstat.cxx14
-rw-r--r--sw/source/uibase/uno/unomodule.cxx4
-rw-r--r--sw/source/uibase/uno/unotxvw.cxx8
-rw-r--r--sw/source/uibase/utlui/glbltree.cxx13
22 files changed, 100 insertions, 76 deletions
diff --git a/sw/source/core/doc/docglbl.cxx b/sw/source/core/doc/docglbl.cxx
index 6a87836d75e8..56f78b66cb9a 100644
--- a/sw/source/core/doc/docglbl.cxx
+++ b/sw/source/core/doc/docglbl.cxx
@@ -506,7 +506,8 @@ bool SwDoc::SplitDoc( sal_uInt16 eDocType, const OUString& rPath, bool bOutline,
aReq.AppendItem( SfxBoolItem( SID_SAVETO, true ) );
if(pFilter)
aReq.AppendItem( SfxStringItem( SID_FILTER_NAME, pFilter->GetName() ) );
- const SfxBoolItem *pRet = static_cast<const SfxBoolItem*>(mpDocShell->ExecuteSlot( aReq ));
+ const SfxPoolItemHolder& rResult(mpDocShell->ExecuteSlot(aReq));
+ const SfxBoolItem *pRet(static_cast<const SfxBoolItem*>(rResult.getItem()));
return pRet && pRet->GetValue();
}
diff --git a/sw/source/ui/fldui/fldtdlg.cxx b/sw/source/ui/fldui/fldtdlg.cxx
index 93e0e1f761af..8c20586167e7 100644
--- a/sw/source/ui/fldui/fldtdlg.cxx
+++ b/sw/source/ui/fldui/fldtdlg.cxx
@@ -113,10 +113,10 @@ void SwFieldDlg::Close()
{
if (m_bClosing)
return;
- const SfxPoolItem* pResult = m_pBindings->GetDispatcher()->
+ const SfxPoolItemHolder aResult(m_pBindings->GetDispatcher()->
Execute(m_bDataBaseMode ? FN_INSERT_FIELD_DATA_ONLY : FN_INSERT_FIELD,
- SfxCallMode::SYNCHRON|SfxCallMode::RECORD);
- if (!pResult)
+ SfxCallMode::SYNCHRON|SfxCallMode::RECORD));
+ if (nullptr == aResult.getItem())
{
// If Execute action did fail for whatever reason, this means that request
// to close did fail or wasn't delivered to SwTextShell::ExecField().
diff --git a/sw/source/uibase/app/apphdl.cxx b/sw/source/uibase/app/apphdl.cxx
index cfb431092064..bca9d20dbd59 100644
--- a/sw/source/uibase/app/apphdl.cxx
+++ b/sw/source/uibase/app/apphdl.cxx
@@ -312,10 +312,11 @@ SwView* lcl_LoadDoc(SwView* pView, const OUString& rURL)
SfxStringItem aTargetFrameName( SID_TARGETNAME, "_blank" );
SfxBoolItem aHidden( SID_HIDDEN, true );
SfxStringItem aReferer(SID_REFERER, pView->GetDocShell()->GetTitle());
- const SfxObjectItem* pItem = static_cast<const SfxObjectItem*>(
+ const SfxPoolItemHolder aResult(
pView->GetViewFrame().GetDispatcher()->ExecuteList(SID_OPENDOC,
- SfxCallMode::SYNCHRON,
- { &aURL, &aHidden, &aReferer, &aTargetFrameName }));
+ SfxCallMode::SYNCHRON,
+ { &aURL, &aHidden, &aReferer, &aTargetFrameName }));
+ const SfxObjectItem* pItem(static_cast<const SfxObjectItem*>(aResult.getItem()));
SfxShell* pShell = pItem ? pItem->GetShell() : nullptr;
if(pShell)
@@ -338,9 +339,10 @@ SwView* lcl_LoadDoc(SwView* pView, const OUString& rURL)
else
{
SfxStringItem aFactory(SID_NEWDOCDIRECT, SwDocShell::Factory().GetFilterContainer()->GetName());
- const SfxFrameItem* pItem = static_cast<const SfxFrameItem*>(
- pView->GetViewFrame().GetDispatcher()->ExecuteList(
- SID_NEWDOCDIRECT, SfxCallMode::SYNCHRON, { &aFactory }));
+ const SfxPoolItemHolder aResult(pView->GetViewFrame().GetDispatcher()->ExecuteList(
+ SID_NEWDOCDIRECT,
+ SfxCallMode::SYNCHRON, { &aFactory }));
+ const SfxFrameItem* pItem(static_cast<const SfxFrameItem*>(aResult.getItem()));
SfxFrame* pFrame = pItem ? pItem->GetFrame() : nullptr;
SfxViewFrame* pViewFrame = pFrame ? pFrame->GetCurrentViewFrame() : nullptr;
pNewView = pViewFrame ? dynamic_cast<SwView*>( pViewFrame->GetViewShell() ) : nullptr;
diff --git a/sw/source/uibase/app/docsh2.cxx b/sw/source/uibase/app/docsh2.cxx
index 9e3e7317bf9d..47c8a3ec651a 100644
--- a/sw/source/uibase/app/docsh2.cxx
+++ b/sw/source/uibase/app/docsh2.cxx
@@ -683,10 +683,11 @@ void SwDocShell::Execute(SfxRequest& rReq)
OUString sPath = aDlgHelper.GetPath();
SfxStringItem aName(SID_FILE_NAME, sPath);
SfxStringItem aFilter(SID_FILTER_NAME, pHtmlFlt->GetName());
- const SfxBoolItem* pBool = static_cast<const SfxBoolItem*>(
- rViewFrame.GetDispatcher()->ExecuteList(
- SID_SAVEASDOC, SfxCallMode::SYNCHRON,
- { &aName, &aFilter }));
+ const SfxPoolItemHolder aResult(
+ rViewFrame.GetDispatcher()->ExecuteList(
+ SID_SAVEASDOC, SfxCallMode::SYNCHRON,
+ { &aName, &aFilter }));
+ const SfxBoolItem* pBool(static_cast<const SfxBoolItem*>(aResult.getItem()));
if(!pBool || !pBool->GetValue())
break;
}
diff --git a/sw/source/uibase/dialog/watermarkdialog.cxx b/sw/source/uibase/dialog/watermarkdialog.cxx
index 37e7ff0ed1f8..413d20f28415 100644
--- a/sw/source/uibase/dialog/watermarkdialog.cxx
+++ b/sw/source/uibase/dialog/watermarkdialog.cxx
@@ -21,6 +21,7 @@
#include <svtools/ctrltool.hxx>
#include <comphelper/lok.hxx>
#include <sfx2/viewsh.hxx>
+#include <svl/itemset.hxx>
#define IS_MOBILE (comphelper::LibreOfficeKit::isActive() && SfxViewShell::Current() && SfxViewShell::Current()->isLOKMobilePhone())
@@ -78,8 +79,9 @@ void SwWatermarkDialog::InitFields()
m_xOKButton->connect_clicked(LINK(this, SwWatermarkDialog, OKButtonHdl));
// Get watermark properties
- const SfxWatermarkItem* pWatermark;
- SfxItemState eState = m_rBindings.GetDispatcher()->QueryState( SID_WATERMARK, pWatermark );
+ SfxPoolItemHolder aResult;
+ const SfxItemState eState(m_rBindings.GetDispatcher()->QueryState(SID_WATERMARK, aResult));
+ const SfxWatermarkItem* pWatermark(static_cast<const SfxWatermarkItem*>(aResult.getItem()));
if( !(eState >= SfxItemState::DEFAULT && pWatermark && pWatermark->Which() == SID_WATERMARK))
return;
diff --git a/sw/source/uibase/misc/glshell.cxx b/sw/source/uibase/misc/glshell.cxx
index aece4e8c18b8..59ede231e820 100644
--- a/sw/source/uibase/misc/glshell.cxx
+++ b/sw/source/uibase/misc/glshell.cxx
@@ -78,9 +78,10 @@ static void lcl_Execute( SwDocShell& rSh, SfxRequest& rReq )
}
else
{
- const SfxBoolItem* pRes = static_cast< const SfxBoolItem* >(
- rSh.ExecuteSlot( rReq,
- rSh.SfxObjectShell::GetInterface() ));
+ const SfxPoolItemHolder& rResult(
+ rSh.ExecuteSlot(rReq,
+ rSh.SfxObjectShell::GetInterface()));
+ const SfxBoolItem* pRes(static_cast< const SfxBoolItem* >(rResult.getItem()));
if( pRes->GetValue() )
rSh.GetDoc()->getIDocumentState().ResetModified();
}
diff --git a/sw/source/uibase/misc/redlndlg.cxx b/sw/source/uibase/misc/redlndlg.cxx
index 532ea120ca2a..0461276140e5 100644
--- a/sw/source/uibase/misc/redlndlg.cxx
+++ b/sw/source/uibase/misc/redlndlg.cxx
@@ -1157,7 +1157,8 @@ IMPL_LINK_NOARG(SwRedlineAcceptDlg, UndoHdl, SvxTPView*, void)
{
pView->GetViewFrame().GetDispatcher()->
Execute(SID_UNDO, SfxCallMode::SYNCHRON);
- m_pTPView->EnableUndo(pView->GetSlotState(SID_UNDO) != nullptr);
+ const SfxPoolItemHolder aResult(pView->GetSlotState(SID_UNDO));
+ m_pTPView->EnableUndo(nullptr != aResult.getItem());
}
Activate();
diff --git a/sw/source/uibase/shells/annotsh.cxx b/sw/source/uibase/shells/annotsh.cxx
index 4c6d5becc5f0..5c9ed82b4114 100644
--- a/sw/source/uibase/shells/annotsh.cxx
+++ b/sw/source/uibase/shells/annotsh.cxx
@@ -800,9 +800,9 @@ void SwAnnotationShell::GetState(SfxItemSet& rSet)
}
case SID_AUTOSPELL_CHECK:
{
- const SfxPoolItem* pState = m_rView.GetSlotState(nWhich);
- if (pState)
- rSet.Put(SfxBoolItem(nWhich, static_cast<const SfxBoolItem*>(pState)->GetValue()));
+ const SfxPoolItemHolder aResult(m_rView.GetSlotState(nWhich));
+ if (nullptr != aResult.getItem())
+ rSet.Put(SfxBoolItem(nWhich, static_cast<const SfxBoolItem*>(aResult.getItem())->GetValue()));
else
rSet.DisableItem( nWhich );
break;
diff --git a/sw/source/uibase/shells/drwtxtex.cxx b/sw/source/uibase/shells/drwtxtex.cxx
index a94016747ee8..4d8dd6304e92 100644
--- a/sw/source/uibase/shells/drwtxtex.cxx
+++ b/sw/source/uibase/shells/drwtxtex.cxx
@@ -1000,9 +1000,9 @@ void SwDrawTextShell::GetDrawTextCtrlState(SfxItemSet& rSet)
case SID_ATTR_CHAR_STRIKEOUT: nEEWhich = EE_CHAR_STRIKEOUT;break;
case SID_AUTOSPELL_CHECK:
{
- const SfxPoolItem* pState = m_rView.GetSlotState(nWhich);
- if (pState)
- rSet.Put(SfxBoolItem(nWhich, static_cast<const SfxBoolItem*>(pState)->GetValue()));
+ const SfxPoolItemHolder aResult(m_rView.GetSlotState(nWhich));
+ if (nullptr != aResult.getItem())
+ rSet.Put(SfxBoolItem(nWhich, static_cast<const SfxBoolItem*>(aResult.getItem())->GetValue()));
else
rSet.DisableItem( nWhich );
break;
diff --git a/sw/source/uibase/sidebar/PageColumnControl.cxx b/sw/source/uibase/sidebar/PageColumnControl.cxx
index bc8d45d2e46b..6afb22a81928 100644
--- a/sw/source/uibase/sidebar/PageColumnControl.cxx
+++ b/sw/source/uibase/sidebar/PageColumnControl.cxx
@@ -39,8 +39,9 @@ PageColumnControl::PageColumnControl(PageColumnPopup* pControl, weld::Widget* pP
bool bLandscape = false;
if (SfxViewFrame* pViewFrm = SfxViewFrame::Current())
{
- const SvxPageItem *pPageItem;
- pViewFrm->GetBindings().GetDispatcher()->QueryState( SID_ATTR_PAGE, pPageItem );
+ SfxPoolItemHolder aResult;
+ pViewFrm->GetBindings().GetDispatcher()->QueryState(SID_ATTR_PAGE, aResult);
+ const SvxPageItem* pPageItem(static_cast<const SvxPageItem*>(aResult.getItem()));
bLandscape = pPageItem->IsLandscape();
}
diff --git a/sw/source/uibase/sidebar/PageFooterPanel.cxx b/sw/source/uibase/sidebar/PageFooterPanel.cxx
index 5d177bdb27ab..1a2f049dcee5 100644
--- a/sw/source/uibase/sidebar/PageFooterPanel.cxx
+++ b/sw/source/uibase/sidebar/PageFooterPanel.cxx
@@ -19,6 +19,7 @@
#include <sal/config.h>
#include <svl/intitem.hxx>
#include <svl/eitem.hxx>
+#include <svl/itemset.hxx>
#include <svx/dlgutil.hxx>
#include <svx/rulritem.hxx>
#include <svx/svdtrans.hxx>
diff --git a/sw/source/uibase/sidebar/PageHeaderPanel.cxx b/sw/source/uibase/sidebar/PageHeaderPanel.cxx
index d799247adbc1..e0706f9c7698 100644
--- a/sw/source/uibase/sidebar/PageHeaderPanel.cxx
+++ b/sw/source/uibase/sidebar/PageHeaderPanel.cxx
@@ -19,6 +19,7 @@
#include <sal/config.h>
#include <svl/intitem.hxx>
#include <svl/eitem.hxx>
+#include <svl/itemset.hxx>
#include <svx/dlgutil.hxx>
#include <svx/rulritem.hxx>
#include <svx/svdtrans.hxx>
diff --git a/sw/source/uibase/sidebar/PageMarginControl.cxx b/sw/source/uibase/sidebar/PageMarginControl.cxx
index 06e073a75c24..2b9bb36cd72f 100644
--- a/sw/source/uibase/sidebar/PageMarginControl.cxx
+++ b/sw/source/uibase/sidebar/PageMarginControl.cxx
@@ -55,8 +55,9 @@ namespace
{
if (SfxViewFrame* pViewFrm = SfxViewFrame::Current())
{
- const SfxUInt16Item* pItem = nullptr;
- SfxItemState eState = pViewFrm->GetBindings().GetDispatcher()->QueryState(SID_ATTR_METRIC, pItem);
+ SfxPoolItemHolder aResult;
+ const SfxItemState eState(pViewFrm->GetBindings().GetDispatcher()->QueryState(SID_ATTR_METRIC, aResult));
+ const SfxUInt16Item* pItem(static_cast<const SfxUInt16Item*>(aResult.getItem()));
if (pItem && eState >= SfxItemState::DEFAULT)
return static_cast<FieldUnit>(pItem->GetValue());
}
@@ -128,13 +129,20 @@ PageMarginControl::PageMarginControl(PageMarginPopup* pControl, weld::Widget* pP
const SvxLongULSpaceItem* pULItem = nullptr;
if (SfxViewFrame* pViewFrm = SfxViewFrame::Current())
{
- const SvxPageItem* pPageItem;
- pViewFrm->GetBindings().GetDispatcher()->QueryState( SID_ATTR_PAGE, pPageItem );
+ SfxPoolItemHolder aResult;
+ pViewFrm->GetBindings().GetDispatcher()->QueryState(SID_ATTR_PAGE, aResult);
+ const SvxPageItem* pPageItem(static_cast<const SvxPageItem*>(aResult.getItem()));
bLandscape = pPageItem->IsLandscape();
m_bMirrored = pPageItem->GetPageUsage() == SvxPageUsage::Mirror;
- 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 );
+
+ pViewFrm->GetBindings().GetDispatcher()->QueryState(SID_ATTR_PAGE_SIZE, aResult);
+ pSize = static_cast<const SvxSizeItem*>(aResult.getItem());
+
+ pViewFrm->GetBindings().GetDispatcher()->QueryState(SID_ATTR_PAGE_LRSPACE, aResult);
+ pLRItem = static_cast<const SvxLongLRSpaceItem*>(aResult.getItem());
+
+ pViewFrm->GetBindings().GetDispatcher()->QueryState(SID_ATTR_PAGE_ULSPACE, aResult);
+ pULItem = static_cast<const SvxLongULSpaceItem*>(aResult.getItem());
}
if ( pLRItem )
diff --git a/sw/source/uibase/sidebar/PageOrientationControl.cxx b/sw/source/uibase/sidebar/PageOrientationControl.cxx
index b123273ff3dc..6f0a45d2686b 100644
--- a/sw/source/uibase/sidebar/PageOrientationControl.cxx
+++ b/sw/source/uibase/sidebar/PageOrientationControl.cxx
@@ -106,9 +106,9 @@ void PageOrientationControl::ExecuteOrientationChange( const bool bLandscape )
if ( mxUndoManager.is() )
mxUndoManager->enterUndoContext( "" );
- const SvxSizeItem* pSizeItem;
- pViewFrm->GetBindings().GetDispatcher()->QueryState(SID_ATTR_PAGE_SIZE, pSizeItem);
- mpPageSizeItem.reset( pSizeItem->Clone() );
+ SfxPoolItemHolder aResult;
+ pViewFrm->GetBindings().GetDispatcher()->QueryState(SID_ATTR_PAGE_SIZE, aResult);
+ mpPageSizeItem.reset(static_cast<const SvxSizeItem*>(aResult.getItem())->Clone());
// Prevent accidental toggling of page orientation
if ((mpPageSizeItem->GetWidth() > mpPageSizeItem->GetHeight()) == bLandscape)
@@ -118,13 +118,11 @@ void PageOrientationControl::ExecuteOrientationChange( const bool bLandscape )
return;
}
- const SvxLongLRSpaceItem* pLRSpaceItem;
- pViewFrm->GetBindings().GetDispatcher()->QueryState(SID_ATTR_PAGE_LRSPACE, pLRSpaceItem);
- mpPageLRMarginItem.reset( pLRSpaceItem->Clone() );
+ pViewFrm->GetBindings().GetDispatcher()->QueryState(SID_ATTR_PAGE_LRSPACE, aResult);
+ mpPageLRMarginItem.reset(static_cast<const SvxLongLRSpaceItem*>(aResult.getItem())->Clone());
- const SvxLongULSpaceItem* pULSpaceItem;
- pViewFrm->GetBindings().GetDispatcher()->QueryState(SID_ATTR_PAGE_ULSPACE, pULSpaceItem);
- mpPageULMarginItem.reset( pULSpaceItem->Clone() );
+ pViewFrm->GetBindings().GetDispatcher()->QueryState(SID_ATTR_PAGE_ULSPACE, aResult);
+ mpPageULMarginItem.reset(static_cast<const SvxLongULSpaceItem*>(aResult.getItem())->Clone());
{
// set new page orientation
diff --git a/sw/source/uibase/sidebar/PageSizeControl.cxx b/sw/source/uibase/sidebar/PageSizeControl.cxx
index a85848ad753d..4ea5995c098f 100644
--- a/sw/source/uibase/sidebar/PageSizeControl.cxx
+++ b/sw/source/uibase/sidebar/PageSizeControl.cxx
@@ -45,10 +45,12 @@ namespace
{
FieldUnit lcl_GetFieldUnit()
{
- const SfxUInt16Item* pItem = nullptr;
if (SfxViewFrame* pViewFrm = SfxViewFrame::Current())
{
- SfxItemState eState = pViewFrm->GetBindings().GetDispatcher()->QueryState(SID_ATTR_METRIC, pItem);
+ SfxPoolItemHolder aResult;
+ const SfxItemState eState(pViewFrm->GetBindings().GetDispatcher()->QueryState(SID_ATTR_METRIC, aResult));
+ const SfxUInt16Item* pItem(static_cast<const SfxUInt16Item*>(aResult.getItem()));
+
if (pItem && eState >= SfxItemState::DEFAULT)
return static_cast<FieldUnit>(pItem->GetValue());
}
@@ -114,13 +116,14 @@ PageSizeControl::PageSizeControl(PageSizePopup* pControl, weld::Widget* pParent)
}
bool bLandscape = false;
- const SvxSizeItem* pSize = nullptr;
+ const SvxSizeItem* pSize(nullptr);
if (SfxViewFrame* pViewFrm = SfxViewFrame::Current())
{
- const SvxPageItem* pPageItem;
- pViewFrm->GetBindings().GetDispatcher()->QueryState( SID_ATTR_PAGE, pPageItem );
- bLandscape = pPageItem->IsLandscape();
- pViewFrm->GetBindings().GetDispatcher()->QueryState( SID_ATTR_PAGE_SIZE, pSize );
+ SfxPoolItemHolder aResult;
+ pViewFrm->GetBindings().GetDispatcher()->QueryState(SID_ATTR_PAGE, aResult );
+ bLandscape = static_cast<const SvxPageItem*>(aResult.getItem())->IsLandscape();
+ pViewFrm->GetBindings().GetDispatcher()->QueryState(SID_ATTR_PAGE_SIZE, aResult);
+ pSize = static_cast<const SvxSizeItem*>(aResult.getItem());
}
const LocaleDataWrapper& localeDataWrapper = Application::GetSettings().GetLocaleDataWrapper();
@@ -189,13 +192,14 @@ PageSizeControl::~PageSizeControl()
void PageSizeControl::ExecuteSizeChange( const Paper ePaper )
{
bool bLandscape = false;
- const SvxPageItem *pItem;
MapUnit eUnit = lcl_GetUnit();
SfxViewFrame* pViewFrm = SfxViewFrame::Current();
if (!pViewFrm)
return;
- pViewFrm->GetBindings().GetDispatcher()->QueryState( SID_ATTR_PAGE, pItem );
+ SfxPoolItemHolder aResult;
+ pViewFrm->GetBindings().GetDispatcher()->QueryState(SID_ATTR_PAGE, aResult);
+ const SvxPageItem* pItem(static_cast<const SvxPageItem*>(aResult.getItem()));
bLandscape = pItem->IsLandscape();
SvxSizeItem aPageSizeItem(SID_ATTR_PAGE_SIZE);
diff --git a/sw/source/uibase/sidebar/WrapPropertyPanel.cxx b/sw/source/uibase/sidebar/WrapPropertyPanel.cxx
index ef7990729f87..8f38a161ffce 100644
--- a/sw/source/uibase/sidebar/WrapPropertyPanel.cxx
+++ b/sw/source/uibase/sidebar/WrapPropertyPanel.cxx
@@ -26,6 +26,7 @@
#include <sfx2/dispatch.hxx>
#include <editeng/lrspitem.hxx>
#include <editeng/ulspitem.hxx>
+#include <svl/itemset.hxx>
#include <hintids.hxx>
#include <strings.hrc>
#include <uitool.hxx>
diff --git a/sw/source/uibase/uiview/srcview.cxx b/sw/source/uibase/uiview/srcview.cxx
index e1ba8d7e9e21..563dd0b46859 100644
--- a/sw/source/uibase/uiview/srcview.cxx
+++ b/sw/source/uibase/uiview/srcview.cxx
@@ -311,7 +311,8 @@ void SwSrcView::Execute(SfxRequest& rReq)
pMed = pDocShell->GetMedium();
else
{
- const SfxBoolItem* pItem = static_cast<const SfxBoolItem*>(pDocShell->ExecuteSlot(rReq, pDocShell->GetInterface()));
+ const SfxPoolItemHolder& rResult(pDocShell->ExecuteSlot(rReq, pDocShell->GetInterface()));
+ const SfxBoolItem* pItem(static_cast<const SfxBoolItem*>(rResult.getItem()));
if(pItem && pItem->GetValue())
pMed = pDocShell->GetMedium();
}
diff --git a/sw/source/uibase/uiview/view.cxx b/sw/source/uibase/uiview/view.cxx
index 76d6e0bbc064..ab8da1cc2d44 100644
--- a/sw/source/uibase/uiview/view.cxx
+++ b/sw/source/uibase/uiview/view.cxx
@@ -613,11 +613,11 @@ void SwView::CheckReadonlyState()
SfxDispatcher &rDis = GetDispatcher();
// To be able to recognize if it is already disabled!
SfxItemState eStateRO, eStateProtAll;
- const SfxPoolItem *pItem;
+ SfxPoolItemHolder aResult;
// Query the status from a slot which is only known to us.
// Otherwise the slot is known from other; like the BasicIde
- eStateRO = rDis.QueryState( FN_INSERT_BOOKMARK, pItem );
- eStateProtAll = rDis.QueryState( FN_EDIT_REGION, pItem );
+ eStateRO = rDis.QueryState(FN_INSERT_BOOKMARK, aResult);
+ eStateProtAll = rDis.QueryState(FN_EDIT_REGION, aResult);
bool bChgd = false;
if ( !m_pWrtShell->IsCursorReadonly() )
diff --git a/sw/source/uibase/uiview/viewstat.cxx b/sw/source/uibase/uiview/viewstat.cxx
index 5be5651dc9d8..3c624274f4c5 100644
--- a/sw/source/uibase/uiview/viewstat.cxx
+++ b/sw/source/uibase/uiview/viewstat.cxx
@@ -262,9 +262,9 @@ void SwView::GetState(SfxItemSet &rSet)
if( !m_pShell )
SelectShell();
- const SfxPoolItem* pState = m_pShell->GetSlotState(SID_UNDO);
- if(pState)
- rSet.Put(*pState);
+ const SfxPoolItemHolder aResult(m_pShell->GetSlotState(SID_UNDO));
+ if(nullptr != aResult.getItem())
+ rSet.Put(*aResult.getItem());
else
rSet.DisableItem(nWhich);
}
@@ -570,14 +570,14 @@ void SwView::GetState(SfxItemSet &rSet)
}
}
//these slots are either re-mapped to text or object alignment
- const SfxPoolItem* pState = nullptr;
+ SfxPoolItemHolder aResult;
if(nAlias)
- GetViewFrame().GetDispatcher()->QueryState( nAlias, pState );
- if(pState)
+ GetViewFrame().GetDispatcher()->QueryState(nAlias, aResult);
+ if(nullptr != aResult.getItem())
{
if (!(m_nSelectionType & SelectionType::DrawObject))
{
- rSet.Put(pState->CloneSetWhich(nWhich));
+ rSet.Put(aResult.getItem()->CloneSetWhich(nWhich));
}
}
else
diff --git a/sw/source/uibase/uno/unomodule.cxx b/sw/source/uibase/uno/unomodule.cxx
index da821aece71a..478502c4fe5d 100644
--- a/sw/source/uibase/uno/unomodule.cxx
+++ b/sw/source/uibase/uno/unomodule.cxx
@@ -68,8 +68,8 @@ void SAL_CALL SwUnoModule::dispatchWithNotification( const util::URL& aURL, cons
aInternalSet.Put(SfxUnoFrameItem(SID_FILLFRAME, xCurrentFrame));
aReq.SetInternalArgs_Impl(aInternalSet);
- const SfxPoolItem* pResult = SW_MOD()->ExecuteSlot( aReq );
- if ( pResult )
+ const SfxPoolItemHolder& rResult(SW_MOD()->ExecuteSlot(aReq));
+ if (nullptr != rResult.getItem())
aState = frame::DispatchResultState::SUCCESS;
else
aState = frame::DispatchResultState::FAILURE;
diff --git a/sw/source/uibase/uno/unotxvw.cxx b/sw/source/uibase/uno/unotxvw.cxx
index b14419a933f5..43f2c7a62c82 100644
--- a/sw/source/uibase/uno/unotxvw.cxx
+++ b/sw/source/uibase/uno/unotxvw.cxx
@@ -1230,8 +1230,8 @@ sal_Bool SwXTextViewCursor::screenDown()
SfxRequest aReq(FN_PAGEDOWN, SfxCallMode::SLOT, m_pView->GetPool());
m_pView->Execute(aReq);
- const SfxPoolItem* pRet = aReq.GetReturnValue();
- bRet = pRet && static_cast<const SfxBoolItem*>(pRet)->GetValue();
+ const SfxPoolItemHolder& rResult(aReq.GetReturnValue());
+ bRet = nullptr != rResult.getItem() && static_cast<const SfxBoolItem*>(rResult.getItem())->GetValue();
return bRet;
}
@@ -1245,8 +1245,8 @@ sal_Bool SwXTextViewCursor::screenUp()
SfxRequest aReq(FN_PAGEUP, SfxCallMode::SLOT, m_pView->GetPool());
m_pView->Execute(aReq);
- const SfxPoolItem* pRet = aReq.GetReturnValue();
- bRet = pRet && static_cast<const SfxBoolItem*>(pRet)->GetValue();
+ const SfxPoolItemHolder& rResult(aReq.GetReturnValue());
+ bRet = nullptr != rResult.getItem() && static_cast<const SfxBoolItem*>(rResult.getItem())->GetValue();
return bRet;
}
diff --git a/sw/source/uibase/utlui/glbltree.cxx b/sw/source/uibase/utlui/glbltree.cxx
index 5625be8cdc05..448f2655727a 100644
--- a/sw/source/uibase/utlui/glbltree.cxx
+++ b/sw/source/uibase/utlui/glbltree.cxx
@@ -704,18 +704,19 @@ void SwGlobalTree::ExecuteContextMenuAction(std::u16string_view rSelectedPopupEn
SfxStringItem aFactory(SID_NEWDOCDIRECT,
SwDocShell::Factory().GetFilterContainer()->GetName());
- const SfxFrameItem* pItem = static_cast<const SfxFrameItem*>(
- rDispatch.ExecuteList(SID_NEWDOCDIRECT,
- SfxCallMode::SYNCHRON, { &aFactory }));
+ SfxPoolItemHolder aResult(
+ rDispatch.ExecuteList(SID_NEWDOCDIRECT,
+ SfxCallMode::SYNCHRON, { &aFactory }));
+ const SfxFrameItem* pItem(static_cast<const SfxFrameItem*>(aResult.getItem()));
// save at
SfxFrame* pFrame = pItem ? pItem->GetFrame() : nullptr;
SfxViewFrame* pViewFrame = pFrame ? pFrame->GetCurrentViewFrame() : nullptr;
if (pViewFrame)
{
- const SfxBoolItem* pBool = static_cast<const SfxBoolItem*>(
- pViewFrame->GetDispatcher()->Execute(
- SID_SAVEASDOC, SfxCallMode::SYNCHRON ));
+ aResult = pViewFrame->GetDispatcher()->Execute(
+ SID_SAVEASDOC, SfxCallMode::SYNCHRON );
+ const SfxBoolItem* pBool(static_cast<const SfxBoolItem*>(aResult.getItem()));
SfxObjectShell& rObj = *pViewFrame->GetObjectShell();
const SfxMedium* pMedium = rObj.GetMedium();
OUString sNewFile(pMedium->GetURLObject().GetMainURL(INetURLObject::DecodeMechanism::ToIUri));