diff options
author | Armin Le Grand (allotropia) <armin.le.grand.extern@allotropia.de> | 2023-09-10 20:35:26 +0200 |
---|---|---|
committer | Armin Le Grand <Armin.Le.Grand@me.com> | 2023-09-11 12:59:53 +0200 |
commit | 5f7a3126fcad1b490b6e1ef6775b31bac99f3c18 (patch) | |
tree | eb8f01846d98f9e0c22fbeab5223f12204202d62 /sfx2 | |
parent | dfd890c414352b1abab62d6a38bf45561bb874ab (diff) |
ITEM: Diverse further changes/cleanups/preparation
Added a counter for SfxItemSet usages, similar to the
already added one for SfxPoolItems to allow quick info
about evtl. problems/drawbacks of changes.
Replaced enum SfxItemKind in favour of settable boolean flags
directly at SfxPoolItem. These are organized as bitfield, do
not need more space as the enum and allow to be set separately
and multiple ones at the same time.
Flags for PoolDefault/StaticDefault/DeleteOnIdle use this now
and are quickly accessible booleans. It is not a problem that
theoretically the flags for PoolDefault/StaticDefault could now
both be set - this is internal to SfxItem stuff and not accessible
from normal code, so can be managed.
Added for debug build a bitfield boolean m_bDeleted
that will be set in the SfxPoolItem destructor. Of course
it's usability will depend on the freed space not yet being
re-used, but will hopefully help in the debugger to detect
reasons for failure (would have helped at least me before).
Added for replacement of virtual method IsVoidItem() another
bitfield bool m_bIsVoidItem that is set in the constructors
of SfxVoidItem. Also had to add some constructors to do that
which were defaulted before. This is mainly because the base
class SfxPoolItem does *not* have a copy-constructor that
copies the members (flags/RefCnt/WhichID) and we should keep
that 'indirect reset' when Cloning. isVoidItem() is now a simple
boolean member access - the bitfield does the needed masking.
This spares one entry in the virtual function table of
SfxPoolItem which is derived more than 500 times.
Used the results of the experiment at
https://gerrit.libreoffice.org/c/core/+/156774 to change
some accesses to IsVoidItem() to use SfxItemState instead.
This is for preparation of splitting up the two usages of
SfxVoidItems, see commit text in the experiment.
If this shows problems in the future those six places documented
there may have to be changed back to use the new isVoidItem(),
but should also check the ptr this time to be non-zero.
Removed SFX_ITEMS_SPECIAL that is no more used anywhere.
Change-Id: Ib687ca2362d72a4651c75aee0c67029088f68947
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156805
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Jenkins
Reviewed-by: Armin Le Grand <Armin.Le.Grand@me.com>
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/control/ctrlitem.cxx | 2 | ||||
-rw-r--r-- | sfx2/source/control/dispatch.cxx | 4 | ||||
-rw-r--r-- | sfx2/source/control/itemdel.cxx | 2 | ||||
-rw-r--r-- | sfx2/source/control/unoctitm.cxx | 6 | ||||
-rw-r--r-- | sfx2/source/doc/objxtor.cxx | 2 | ||||
-rw-r--r-- | sfx2/source/statbar/stbitem.cxx | 2 | ||||
-rw-r--r-- | sfx2/source/toolbox/tbxitem.cxx | 2 |
7 files changed, 10 insertions, 10 deletions
diff --git a/sfx2/source/control/ctrlitem.cxx b/sfx2/source/control/ctrlitem.cxx index 21618056469a..9a8c6e0203a2 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() + : pState->isVoidItem() && !pState->Which() ? SfxItemState::UNKNOWN : SfxItemState::DEFAULT; } diff --git a/sfx2/source/control/dispatch.cxx b/sfx2/source/control/dispatch.cxx index af57a5e3ab2f..c047f854a810 100644 --- a/sfx2/source/control/dispatch.cxx +++ b/sfx2/source/control/dispatch.cxx @@ -1694,7 +1694,7 @@ bool SfxDispatcher::FillState_(const SfxSlotServer& rSvr, SfxItemSet& rState, pItem; pItem = aIter.NextItem() ) { - if ( !IsInvalidItem(pItem) && !pItem->IsVoidItem() ) + if ( !IsInvalidItem(pItem) && !pItem->isVoidItem() ) { sal_uInt16 nSlotId = rState.GetPool()->GetSlotId(pItem->Which()); SAL_INFO_IF( @@ -1995,7 +1995,7 @@ SfxItemState SfxDispatcher::QueryState( sal_uInt16 nSID, css::uno::Any& rAny ) else { css::uno::Any aState; - if ( !pItem->IsVoidItem() ) + if ( !pItem->isVoidItem() ) { sal_uInt16 nSubId( 0 ); SfxItemPool& rPool = pShell->GetPool(); diff --git a/sfx2/source/control/itemdel.cxx b/sfx2/source/control/itemdel.cxx index c96a9d0f4ba3..ce6f4e1b9303 100644 --- a/sfx2/source/control/itemdel.cxx +++ b/sfx2/source/control/itemdel.cxx @@ -31,7 +31,7 @@ class SfxItemDisruptor_Impl public: static void DeleteItemOnIdle(std::unique_ptr<SfxPoolItem> pItem) { - pItem->SetKind(SfxItemKind::DeleteOnIdle); + pItem->setDeleteOnIdle(); Application::PostUserEvent(LINK(nullptr, SfxItemDisruptor_Impl, Delete), pItem.release()); // coverity[leaked_storage] - pDisruptor takes care of its own destruction at idle time } diff --git a/sfx2/source/control/unoctitm.cxx b/sfx2/source/control/unoctitm.cxx index 9b75d0a51118..89e94caff794 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*>(pItem)) bSuccess = pBoolItem->GetValue(); - else if ( !pItem->IsVoidItem() ) + else if ( !pItem->isVoidItem() ) 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 && pItem && !pItem->IsVoidItem() ) + if ( bSuccess && pItem && !pItem->isVoidItem() ) { 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 ) && !pState->isVoidItem() ) { // Retrieve metric from pool to have correct sub ID when calling QueryValue sal_uInt16 nSubId( 0 ); diff --git a/sfx2/source/doc/objxtor.cxx b/sfx2/source/doc/objxtor.cxx index 917935d907d1..8c3029edd128 100644 --- a/sfx2/source/doc/objxtor.cxx +++ b/sfx2/source/doc/objxtor.cxx @@ -587,7 +587,7 @@ bool SfxObjectShell::PrepareClose pPoolItem = pFrame->GetBindings().ExecuteSynchron( SID_SAVEDOC, ppArgs ); } - if ( !pPoolItem || pPoolItem->IsVoidItem() ) + if ( !pPoolItem || pPoolItem->isVoidItem() ) return false; if ( auto pBoolItem = dynamic_cast< const SfxBoolItem *>( pPoolItem ) ) if ( !pBoolItem->GetValue() ) diff --git a/sfx2/source/statbar/stbitem.cxx b/sfx2/source/statbar/stbitem.cxx index 2387557d6ba9..6e9ee1bcaa95 100644 --- a/sfx2/source/statbar/stbitem.cxx +++ b/sfx2/source/statbar/stbitem.cxx @@ -376,7 +376,7 @@ void SfxStatusBarControl::StateChangedAtStatusBarControl pBar->SetItemText( nSID, pStr->GetValue() ); else { - DBG_ASSERT( eState != SfxItemState::DEFAULT || pState->IsVoidItem(), + DBG_ASSERT( eState != SfxItemState::DEFAULT || pState->isVoidItem(), "wrong SfxPoolItem subclass in SfxStatusBarControl" ); pBar->SetItemText( nSID, OUString() ); } diff --git a/sfx2/source/toolbox/tbxitem.cxx b/sfx2/source/toolbox/tbxitem.cxx index f355806aaa00..bf01be5e1921 100644 --- a/sfx2/source/toolbox/tbxitem.cxx +++ b/sfx2/source/toolbox/tbxitem.cxx @@ -234,7 +234,7 @@ SfxItemState SfxToolBoxControl::GetItemState( ? SfxItemState::DISABLED : IsInvalidItem(pState) ? SfxItemState::DONTCARE - : pState->IsVoidItem() && !pState->Which() + : pState->isVoidItem() && !pState->Which() ? SfxItemState::UNKNOWN : SfxItemState::DEFAULT; } |