summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorArmin Le Grand (allotropia) <armin.le.grand.extern@allotropia.de>2024-01-22 19:18:32 +0100
committerArmin Le Grand <Armin.Le.Grand@me.com>2024-01-23 10:30:59 +0100
commit38072fd7eb7d53237efbe0d8bacc7db1c4f3131c (patch)
treef46f20f947a37013fb0539ff235216bae149d443 /sw
parentdb4cb7cee82615973d1be9fd631c1317f1da5820 (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 'sw')
-rw-r--r--sw/source/core/attr/swatrset.cxx10
-rw-r--r--sw/source/uibase/docvw/romenu.cxx2
2 files changed, 6 insertions, 6 deletions
diff --git a/sw/source/core/attr/swatrset.cxx b/sw/source/core/attr/swatrset.cxx
index 09c04b43f635..6e52f4af3d51 100644
--- a/sw/source/core/attr/swatrset.cxx
+++ b/sw/source/core/attr/swatrset.cxx
@@ -105,8 +105,8 @@ void SwAttrSet::changeCallback(const SfxPoolItem* pOld, const SfxPoolItem* pNew)
if (nullptr != pOld)
{
- // do not handle if an invalid item is involved
- if (IsInvalidItem(pOld))
+ // do not handle if an invalid or disabled item is involved
+ if (IsInvalidItem(pOld) || IsDisabledItem(pOld))
return;
// get WhichID from pOld
@@ -115,8 +115,8 @@ void SwAttrSet::changeCallback(const SfxPoolItem* pOld, const SfxPoolItem* pNew)
if (nullptr != pNew)
{
- // do not handle if an invalid item is involved
- if (IsInvalidItem(pNew))
+ // do not handle if an invalid or disabled item is involved
+ if (IsInvalidItem(pNew) || IsDisabledItem(pNew))
return;
if (0 == nWhich)
@@ -127,7 +127,7 @@ void SwAttrSet::changeCallback(const SfxPoolItem* pOld, const SfxPoolItem* pNew)
}
// all given items are valid. If we got no WhichID != 0 then
- // pOld == pNew == nullptr or SfxVoidItem(0) and we have no
+ // pOld == pNew == nullptr or IsDisabledItem and we have no
// valid input. Also not needed if !IsWhich (aka > SFX_WHICH_MAX)
if (0 == nWhich || !SfxItemPool::IsWhich(nWhich))
return;
diff --git a/sw/source/uibase/docvw/romenu.cxx b/sw/source/uibase/docvw/romenu.cxx
index 05d352f181c3..bcbe76f9ef39 100644
--- a/sw/source/uibase/docvw/romenu.cxx
+++ b/sw/source/uibase/docvw/romenu.cxx
@@ -60,7 +60,7 @@ void SwReadOnlyPopup::Check( sal_uInt16 nMID, sal_uInt16 nSID, SfxDispatcher con
m_xMenu->EnableItem(nMID);
if (_pItem)
{
- m_xMenu->CheckItem(nMID, !_pItem->isVoidItem() &&
+ m_xMenu->CheckItem(nMID, !IsDisabledItem(_pItem.get()) &&
dynamic_cast< const SfxBoolItem *>( _pItem.get() ) != nullptr &&
static_cast<SfxBoolItem*>(_pItem.get())->GetValue());
//remove full screen entry when not in full screen mode