summaryrefslogtreecommitdiff
path: root/cui
diff options
context:
space:
mode:
authorArmin Le Grand (allotropia) <armin.le.grand.extern@allotropia.de>2024-03-22 15:31:14 +0100
committerArmin Le Grand <Armin.Le.Grand@me.com>2024-03-26 14:48:17 +0100
commit2984dd49fb9fb2f8d3d56fba0db34a7b95666ce1 (patch)
tree4f842c7baf6ea8ac3f70d97d315c680c90eae203 /cui
parent1590e2c359fd3b506b8721d99a0054a0bd4dd200 (diff)
ITEM: Use SfxPoolItemHolder in SvxSearchDialog
I replaced that SfxPoolItem* in SearchAttrInfo with a much safer SfxPoolItemHolder and adapted and simplified used code - it does not need to take care of Item lifetime/Cloning itself. That works well. I did not find out why that 'invalid' state is used in the SrchAttrInfoList, but seems to be needed. Thus I keep this for now as it is (it can be all expressed/used using SfxPoolItemHolder, too). Change-Id: I4b769f43128cb2e25153919f7652b2f032393123 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165167 Tested-by: Jenkins Reviewed-by: Armin Le Grand <Armin.Le.Grand@me.com>
Diffstat (limited to 'cui')
-rw-r--r--cui/source/dialogs/srchxtra.cxx25
1 files changed, 10 insertions, 15 deletions
diff --git a/cui/source/dialogs/srchxtra.cxx b/cui/source/dialogs/srchxtra.cxx
index 4c672b9839f2..f8080f537775 100644
--- a/cui/source/dialogs/srchxtra.cxx
+++ b/cui/source/dialogs/srchxtra.cxx
@@ -135,7 +135,7 @@ SvxSearchAttributeDialog::SvxSearchAttributeDialog(weld::Window* pParent,
if ( nSlot == rList[i].nSlot )
{
bFound = true;
- if ( IsInvalidItem( rList[i].pItemPtr ) )
+ if ( IsInvalidItem( rList[i].aItemPtr.getItem() ) )
bChecked = true;
}
}
@@ -167,13 +167,13 @@ SvxSearchAttributeDialog::~SvxSearchAttributeDialog()
IMPL_LINK_NOARG(SvxSearchAttributeDialog, OKHdl, weld::Button&, void)
{
- SearchAttrInfo aInvalidItem;
- aInvalidItem.pItemPtr = INVALID_POOL_ITEM;
+ DBG_ASSERT( SfxObjectShell::Current(), "No DocShell" );
+ SfxItemPool& rPool(SfxObjectShell::Current()->GetPool());
for (int i = 0, nCount = m_xAttrLB->n_children(); i < nCount; ++i)
{
- sal_uInt16 nSlot = m_xAttrLB->get_id(i).toUInt32();
- bool bChecked = m_xAttrLB->get_toggle(i) == TRISTATE_TRUE;
+ const sal_uInt16 nSlot(m_xAttrLB->get_id(i).toUInt32());
+ const bool bChecked(TRISTATE_TRUE == m_xAttrLB->get_toggle(i));
sal_uInt16 j;
for ( j = rList.Count(); j; )
@@ -182,13 +182,9 @@ IMPL_LINK_NOARG(SvxSearchAttributeDialog, OKHdl, weld::Button&, void)
if( rItem.nSlot == nSlot )
{
if( bChecked )
- {
- if( !IsInvalidItem( rItem.pItemPtr ) )
- delete rItem.pItemPtr;
- rItem.pItemPtr = INVALID_POOL_ITEM;
- }
- else if( IsInvalidItem( rItem.pItemPtr ) )
- rItem.pItemPtr = nullptr;
+ rItem.aItemPtr = SfxPoolItemHolder(rPool, INVALID_POOL_ITEM);
+ else if( IsInvalidItem( rItem.aItemPtr.getItem() ) )
+ rItem.aItemPtr = SfxPoolItemHolder();
j = 1;
break;
}
@@ -196,14 +192,13 @@ IMPL_LINK_NOARG(SvxSearchAttributeDialog, OKHdl, weld::Button&, void)
if ( !j && bChecked )
{
- aInvalidItem.nSlot = nSlot;
- rList.Insert( aInvalidItem );
+ rList.Insert( { nSlot, SfxPoolItemHolder(rPool, INVALID_POOL_ITEM) });
}
}
// remove invalid items (pItem == NULL)
for ( sal_uInt16 n = rList.Count(); n; )
- if ( !rList[ --n ].pItemPtr )
+ if ( !rList[ --n ].aItemPtr.getItem() )
rList.Remove( n );
m_xDialog->response(RET_OK);