diff options
author | Armin Le Grand (allotropia) <armin.le.grand.extern@allotropia.de> | 2024-01-22 19:18:32 +0100 |
---|---|---|
committer | Armin Le Grand <Armin.Le.Grand@me.com> | 2024-01-23 10:30:59 +0100 |
commit | 38072fd7eb7d53237efbe0d8bacc7db1c4f3131c (patch) | |
tree | f46f20f947a37013fb0539ff235216bae149d443 /sfx2/source/control | |
parent | db4cb7cee82615973d1be9fd631c1317f1da5820 (diff) |
ITEM: Solve SfxVoidItem(0) situation
An instance of SfxVoidItem(0) was used to signal
the SfxItemState::DISABLED. This was done not only
using WhichID == 0, but using isVoidItem() at the
SfxPoolItem. Unfortunately this mixes up with usages
of SfxVoidItems, mostly for UI stuff/Slots.
This also means that all the time an SfxVoidItem
had to be cloned/delete when when added/removed
from ItemSet or ItemHolder. Much more action than
e.g. for INVALID_POOL_ITEM which we already use
by havong just a simple ptr to a single static
instance of an Item. Disabled should do the same
thing.
Unfortunately also the functionality was mixed
with non-SfxItemState::DISABLED purposes and these
were very hard to be separated.
But the current solution works now after some
quirks doing that. It even oes no more need the
isVoidItem() flag at the SfxPoolItem.
Change-Id: I99f03db144f541ae4ea35f3775b3b3d58a375a81
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162414
Tested-by: Jenkins
Reviewed-by: Armin Le Grand <Armin.Le.Grand@me.com>
Diffstat (limited to 'sfx2/source/control')
-rw-r--r-- | sfx2/source/control/bindings.cxx | 3 | ||||
-rw-r--r-- | sfx2/source/control/ctrlitem.cxx | 2 | ||||
-rw-r--r-- | sfx2/source/control/dispatch.cxx | 4 | ||||
-rw-r--r-- | sfx2/source/control/shell.cxx | 2 | ||||
-rw-r--r-- | sfx2/source/control/statcach.cxx | 6 | ||||
-rw-r--r-- | sfx2/source/control/unoctitm.cxx | 6 |
6 files changed, 12 insertions, 11 deletions
diff --git a/sfx2/source/control/bindings.cxx b/sfx2/source/control/bindings.cxx index 5a318d11b77a..549a9fc45e67 100644 --- a/sfx2/source/control/bindings.cxx +++ b/sfx2/source/control/bindings.cxx @@ -1203,8 +1203,7 @@ void SfxBindings::UpdateControllers_Impl SfxItemPool::IsSlot(rFound.nWhichId) ) { // no Status or Default but without Pool - SfxVoidItem aVoid(0); - rCache.SetState( SfxItemState::UNKNOWN, &aVoid ); + rCache.SetState( SfxItemState::UNKNOWN, DISABLED_POOL_ITEM ); } else if ( SfxItemState::DISABLED == eState ) rCache.SetState(SfxItemState::DISABLED, nullptr); diff --git a/sfx2/source/control/ctrlitem.cxx b/sfx2/source/control/ctrlitem.cxx index 9a8c6e0203a2..82ee78cb5dde 100644 --- a/sfx2/source/control/ctrlitem.cxx +++ b/sfx2/source/control/ctrlitem.cxx @@ -293,7 +293,7 @@ SfxItemState SfxControllerItem::GetItemState ? SfxItemState::DISABLED : IsInvalidItem(pState) ? SfxItemState::DONTCARE - : pState->isVoidItem() && !pState->Which() + : IsDisabledItem(pState) ? SfxItemState::UNKNOWN : SfxItemState::DEFAULT; } diff --git a/sfx2/source/control/dispatch.cxx b/sfx2/source/control/dispatch.cxx index a73fd763cd18..3b52f7ae322e 100644 --- a/sfx2/source/control/dispatch.cxx +++ b/sfx2/source/control/dispatch.cxx @@ -1696,7 +1696,7 @@ bool SfxDispatcher::FillState_(const SfxSlotServer& rSvr, SfxItemSet& rState, pItem; pItem = aIter.NextItem() ) { - if ( !IsInvalidItem(pItem) && !pItem->isVoidItem() ) + if ( !IsInvalidItem(pItem) && !IsDisabledItem(pItem) ) { sal_uInt16 nSlotId = rState.GetPool()->GetSlotId(pItem->Which()); SAL_INFO_IF( @@ -1997,7 +1997,7 @@ SfxItemState SfxDispatcher::QueryState( sal_uInt16 nSID, css::uno::Any& rAny ) else { css::uno::Any aState; - if ( !aItem.getItem()->isVoidItem() ) + if ( !IsDisabledItem(aItem.getItem()) ) { sal_uInt16 nSubId( 0 ); SfxItemPool& rPool = pShell->GetPool(); diff --git a/sfx2/source/control/shell.cxx b/sfx2/source/control/shell.cxx index 4d0ae2d66b85..4f4ba99ce3ee 100644 --- a/sfx2/source/control/shell.cxx +++ b/sfx2/source/control/shell.cxx @@ -515,7 +515,7 @@ SfxPoolItemHolder SfxShell::GetSlotState { if ( pStateSet ) pStateSet->ClearItem(nSlotId); - return SfxPoolItemHolder(rPool, new SfxVoidItem(0), true); + return SfxPoolItemHolder(rPool, DISABLED_POOL_ITEM); } // bItemStateSet && eState >= SfxItemState::DEFAULT diff --git a/sfx2/source/control/statcach.cxx b/sfx2/source/control/statcach.cxx index 2346333fd06a..7ce4f11e3ff2 100644 --- a/sfx2/source/control/statcach.cxx +++ b/sfx2/source/control/statcach.cxx @@ -82,6 +82,7 @@ void SAL_CALL BindDispatch_Impl::statusChanged( const css::frame::FeatureStateE std::unique_ptr<SfxPoolItem> pItem; sal_uInt16 nId = pCache->GetId(); SfxItemState eState = SfxItemState::DISABLED; + const SfxPoolItem* pArg(nullptr); if ( !aStatus.IsEnabled ) { // default @@ -128,18 +129,19 @@ void SAL_CALL BindDispatch_Impl::statusChanged( const css::frame::FeatureStateE else pItem.reset( new SfxVoidItem( nId ) ); } + pArg = pItem.get(); } else { // DONTCARE status - pItem.reset( new SfxVoidItem(0) ); + pArg = DISABLED_POOL_ITEM; eState = SfxItemState::UNKNOWN; } for ( SfxControllerItem *pCtrl = pCache->GetItemLink(); pCtrl; pCtrl = pCtrl->GetItemLink() ) - pCtrl->StateChangedAtToolBoxControl( nId, eState, pItem.get() ); + pCtrl->StateChangedAtToolBoxControl( nId, eState, pArg ); } } diff --git a/sfx2/source/control/unoctitm.cxx b/sfx2/source/control/unoctitm.cxx index cd50e70231e7..f138eca95af6 100644 --- a/sfx2/source/control/unoctitm.cxx +++ b/sfx2/source/control/unoctitm.cxx @@ -670,7 +670,7 @@ void SfxDispatchController_Impl::dispatch( const css::util::URL& aURL, { if (const SfxBoolItem* pBoolItem = dynamic_cast<const SfxBoolItem*>(aItem.getItem())) bSuccess = pBoolItem->GetValue(); - else if ( !aItem.getItem()->isVoidItem() ) + else if ( !IsDisabledItem(aItem.getItem()) ) bSuccess = true; // all other types are true } // else bSuccess = false look to line 664 it is false @@ -733,7 +733,7 @@ void SfxDispatchController_Impl::dispatch( const css::util::URL& aURL, aEvent.State = css::frame::DispatchResultState::FAILURE; aEvent.Source = static_cast<css::frame::XDispatch*>(pDispatch); - if ( bSuccess && aItem && !aItem.getItem()->isVoidItem() ) + if ( bSuccess && aItem && !IsDisabledItem(aItem.getItem()) ) { sal_uInt16 nSubId( 0 ); if ( eMapUnit == MapUnit::MapTwip ) @@ -834,7 +834,7 @@ void SfxDispatchController_Impl::StateChanged( sal_uInt16 nSID, SfxItemState eSt return; css::uno::Any aState; - if ( ( eState >= SfxItemState::DEFAULT ) && pState && !IsInvalidItem( pState ) && !pState->isVoidItem() ) + if ( ( eState >= SfxItemState::DEFAULT ) && pState && !IsInvalidItem( pState ) && !IsDisabledItem(pState) ) { // Retrieve metric from pool to have correct sub ID when calling QueryValue sal_uInt16 nSubId( 0 ); |