sfx2/source/control/shell.cxx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
New commits: commit 3b46c3068af26d6be65cfe309c751e310a22d129 Author: Armin Le Grand (Allotropia) <[email protected]> AuthorDate: Fri Jun 11 11:07:16 2021 +0200 Commit: Armin Le Grand <[email protected]> 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 <[email protected]> Reviewed-by: Armin Le Grand <[email protected]> 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() ); _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
