[Libreoffice-commits] core.git: sfx2/source
Armin Le Grand (Allotropia) (via logerrit)
logerrit at kemper.freedesktop.org
Fri Jun 11 14:59:26 UTC 2021
sfx2/source/control/shell.cxx | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
New commits:
commit 3b46c3068af26d6be65cfe309c751e310a22d129
Author: Armin Le Grand (Allotropia) <armin.le.grand at me.com>
AuthorDate: Fri Jun 11 11:07:16 2021 +0200
Commit: Armin Le Grand <Armin.Le.Grand at me.com>
CommitDate: Fri Jun 11 16:58:40 2021 +0200
tdf#130428 remove unnecessary usage of SfxItemState::UNKNOWN
Another place where SfxItemState was used as placeholder
Change-Id: I54e549db50b7485024a305eb39fda848cbed6b78
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117036
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
Reviewed-by: Armin Le Grand <Armin.Le.Grand at me.com>
Tested-by: Jenkins
diff --git a/sfx2/source/control/shell.cxx b/sfx2/source/control/shell.cxx
index 795f25f708aa..78639a958a4f 100644
--- a/sfx2/source/control/shell.cxx
+++ b/sfx2/source/control/shell.cxx
@@ -452,7 +452,8 @@ const SfxPoolItem* SfxShell::GetSlotState
// Get Slot on the given Interface
if ( !pIF )
pIF = GetInterface();
- SfxItemState eState = SfxItemState::UNKNOWN;
+ SfxItemState eState(SfxItemState::DEFAULT);
+ bool bItemStateSet(false);
SfxItemPool &rPool = GetPool();
const SfxSlot* pSlot = nullptr;
@@ -467,13 +468,14 @@ const SfxPoolItem* SfxShell::GetSlotState
// Get Item and Item status
const SfxPoolItem *pItem = nullptr;
SfxItemSet aSet( rPool, {{nSlotId, nSlotId}} ); // else pItem dies too soon
- if ( pSlot )
+ if ( nullptr != pSlot )
{
// Call Status method
SfxStateFunc pFunc = pSlot->GetStateFnc();
if ( pFunc )
(*pFunc)( this, aSet );
eState = aSet.GetItemState( nSlotId, true, &pItem );
+ bItemStateSet = true;
// get default Item if possible
if ( eState == SfxItemState::DEFAULT )
@@ -484,24 +486,22 @@ const SfxPoolItem* SfxShell::GetSlotState
eState = SfxItemState::DONTCARE;
}
}
- else
- eState = SfxItemState::UNKNOWN;
// Evaluate Item and item status and possibly maintain them in pStateSet
std::unique_ptr<SfxPoolItem> pRetItem;
- if ( eState <= SfxItemState::DISABLED )
+ if ( !bItemStateSet || eState <= SfxItemState::DISABLED )
{
if ( pStateSet )
pStateSet->DisableItem(nSlotId);
return nullptr;
}
- else if ( eState == SfxItemState::DONTCARE )
+ else if ( bItemStateSet && eState == SfxItemState::DONTCARE )
{
if ( pStateSet )
pStateSet->ClearItem(nSlotId);
pRetItem.reset( new SfxVoidItem(0) );
}
- else
+ else // bItemStateSet && eState >= SfxItemState::DEFAULT
{
if ( pStateSet && pStateSet->Put( *pItem ) )
return &pStateSet->Get( pItem->Which() );
More information about the Libreoffice-commits
mailing list