summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArmin Le Grand (allotropia) <armin.le.grand.extern@allotropia.de>2024-05-07 13:59:18 +0200
committerAdolfo Jayme Barrientos <fitojb@ubuntu.com>2024-05-16 00:42:49 +0200
commit01bdb97829d103d06175fb50746ddeefddbaa3b3 (patch)
tree9ee2c892a87e425401df11de874a8c495df3a48a
parente16c06e4d069216d65bf43bcb9e12c85d5505ba0 (diff)
tdf#160906 use SfxPoolItemHolder
to avoid handling already deleted SfxPoolItems. Change-Id: I1f1f8f93cae8db7f7c8df66c2c7f3c02b59a39c3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167274 Reviewed-by: Armin Le Grand <Armin.Le.Grand@me.com> Tested-by: Jenkins Signed-off-by: Xisco Fauli <xiscofauli@libreoffice.org> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167376 Reviewed-by: Adolfo Jayme Barrientos <fitojb@ubuntu.com>
-rw-r--r--forms/source/richtext/parametrizedattributedispatcher.cxx14
-rw-r--r--forms/source/richtext/parametrizedattributedispatcher.hxx6
-rw-r--r--forms/source/richtext/specialdispatchers.cxx14
-rw-r--r--forms/source/richtext/specialdispatchers.hxx2
4 files changed, 21 insertions, 15 deletions
diff --git a/forms/source/richtext/parametrizedattributedispatcher.cxx b/forms/source/richtext/parametrizedattributedispatcher.cxx
index d6666e2b0262..bc226decd83e 100644
--- a/forms/source/richtext/parametrizedattributedispatcher.cxx
+++ b/forms/source/richtext/parametrizedattributedispatcher.cxx
@@ -89,7 +89,7 @@ namespace frm
}
- const SfxPoolItem* OParametrizedAttributeDispatcher::convertDispatchArgsToItem( const Sequence< PropertyValue >& _rArguments )
+ SfxPoolItemHolder OParametrizedAttributeDispatcher::convertDispatchArgsToItem( const Sequence< PropertyValue >& _rArguments )
{
// get the real slot id. This may differ from our attribute id: for instance, both
// SID_ATTR_CHAR_HEIGHT and SID_ATTR_CHAR_LATIN_HEIGHT are mapped to the same which id
@@ -98,16 +98,16 @@ namespace frm
SfxAllItemSet aParameterSet( getEditView()->GetEmptyItemSet() );
TransformParameters( nSlotId, _rArguments, aParameterSet );
- const SfxPoolItem* pArgument = nullptr;
if ( aParameterSet.Count() )
{
OSL_ENSURE( aParameterSet.Count() == 1, "OParametrizedAttributeDispatcher::convertDispatchArgsToItem: Arguments which form more than 1 item? How this?" );
WhichId nAttributeWhich = aParameterSet.GetPool()->GetWhich( nSlotId );
- pArgument = aParameterSet.GetItem( nAttributeWhich );
- OSL_ENSURE( pArgument, "OParametrizedAttributeDispatcher::convertDispatchArgsToItem: suspicious: there were arguments, but they're not for my slot!" );
+ SfxPoolItemHolder aArgument(*aParameterSet.GetPool(), aParameterSet.GetItem(nAttributeWhich));
+ OSL_ENSURE( aArgument.getItem(), "OParametrizedAttributeDispatcher::convertDispatchArgsToItem: suspicious: there were arguments, but they're not for my slot!" );
+ return aArgument;
}
- return pArgument;
+ return SfxPoolItemHolder();
}
@@ -117,8 +117,8 @@ namespace frm
OSL_ENSURE( _rURL.Complete == getFeatureURL().Complete, "OParametrizedAttributeDispatcher::dispatch: invalid URL!" );
if ( m_pMasterDispatcher )
{
- const SfxPoolItem* pConvertedArgument = convertDispatchArgsToItem( _rArguments );
- m_pMasterDispatcher->executeAttribute( m_nAttributeId, pConvertedArgument );
+ const SfxPoolItemHolder aConvertedArgument(convertDispatchArgsToItem(_rArguments));
+ m_pMasterDispatcher->executeAttribute(m_nAttributeId, aConvertedArgument.getItem());
}
}
diff --git a/forms/source/richtext/parametrizedattributedispatcher.hxx b/forms/source/richtext/parametrizedattributedispatcher.hxx
index 69844731612e..8a68486c131b 100644
--- a/forms/source/richtext/parametrizedattributedispatcher.hxx
+++ b/forms/source/richtext/parametrizedattributedispatcher.hxx
@@ -21,7 +21,7 @@
#include "attributedispatcher.hxx"
-class SfxPoolItem;
+class SfxPoolItemHolder;
namespace frm
{
@@ -47,10 +47,10 @@ namespace frm
protected:
// own overridables
- /** convert the arguments as got in a XDispatch::dispatch call into an SfxPoolItem, which can
+ /** convert the arguments as got in a XDispatch::dispatch call into an SfxPoolItemHolder, which can
be used with a IMultiAttributeDispatcher::executeAttribute
*/
- virtual const SfxPoolItem* convertDispatchArgsToItem(
+ virtual SfxPoolItemHolder convertDispatchArgsToItem(
const css::uno::Sequence< css::beans::PropertyValue >& _rArguments );
};
diff --git a/forms/source/richtext/specialdispatchers.cxx b/forms/source/richtext/specialdispatchers.cxx
index d75e06590fc2..ab01cd9eb608 100644
--- a/forms/source/richtext/specialdispatchers.cxx
+++ b/forms/source/richtext/specialdispatchers.cxx
@@ -23,6 +23,7 @@
#include <editeng/editview.hxx>
#include <editeng/scriptspaceitem.hxx>
#include <osl/diagnose.h>
+#include <svl/itemset.hxx>
namespace frm
@@ -140,7 +141,7 @@ namespace frm
}
- const SfxPoolItem* OAsianFontLayoutDispatcher::convertDispatchArgsToItem( const Sequence< PropertyValue >& _rArguments )
+ SfxPoolItemHolder OAsianFontLayoutDispatcher::convertDispatchArgsToItem( const Sequence< PropertyValue >& _rArguments )
{
// look for the "Enable" parameter
const PropertyValue* pLookup = _rArguments.getConstArray();
@@ -155,13 +156,18 @@ namespace frm
{
bool bEnable = true;
OSL_VERIFY( pLookup->Value >>= bEnable );
+
if ( m_nAttributeId == sal_uInt16(SID_ATTR_PARA_SCRIPTSPACE) )
- return new SvxScriptSpaceItem( bEnable, static_cast<WhichId>(m_nAttributeId) );
- return new SfxBoolItem( static_cast<WhichId>(m_nAttributeId), bEnable );
+ return SfxPoolItemHolder(
+ *getEditView()->GetEmptyItemSet().GetPool(),
+ new SvxScriptSpaceItem(bEnable, static_cast<WhichId>(m_nAttributeId)));
+ return SfxPoolItemHolder(
+ *getEditView()->GetEmptyItemSet().GetPool(),
+ new SfxBoolItem(static_cast<WhichId>(m_nAttributeId), bEnable));
}
OSL_FAIL( "OAsianFontLayoutDispatcher::convertDispatchArgsToItem: did not find the one and only argument!" );
- return nullptr;
+ return SfxPoolItemHolder();
}
diff --git a/forms/source/richtext/specialdispatchers.hxx b/forms/source/richtext/specialdispatchers.hxx
index 9b4bfa1b7939..cca2b75ccac6 100644
--- a/forms/source/richtext/specialdispatchers.hxx
+++ b/forms/source/richtext/specialdispatchers.hxx
@@ -80,7 +80,7 @@ namespace frm
protected:
// OParametrizedAttributeDispatcher
- virtual const SfxPoolItem* convertDispatchArgsToItem(
+ virtual SfxPoolItemHolder convertDispatchArgsToItem(
const css::uno::Sequence< css::beans::PropertyValue >& _rArguments ) override;
};