summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorArmin Le Grand (Allotropia) <armin.le.grand@me.com>2021-06-10 19:24:04 +0200
committerArmin Le Grand <Armin.Le.Grand@me.com>2021-06-11 09:40:45 +0200
commit552ceeb5c6ccf2573adfd092cc4b2ce214a9c2df (patch)
treee6f7f91789922c087ac5be9d108011b47d045f0e /svx
parent5c3ad59612697cf0afee0f836e9ee77f0920356b (diff)
tdf#130428 remove unnecessary usage of SfxItemState::UNKNOWN
FontworkBar::getState does not need to check for SfxItemState::UNKNOWN at all, actions solely depend on FontWork object being selected. This also greatly simplifies that method. Also, the optimization by passing in a variable to checkForSelectedFontWork and remember if already computed can be removed - also in other places where it had to be given, but was not re-used at all Change-Id: I35b1f36195feb1d645619665d2dd65a84b75b118 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117014 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Reviewed-by: Armin Le Grand <Armin.Le.Grand@me.com>
Diffstat (limited to 'svx')
-rw-r--r--svx/source/toolbars/fontworkbar.cxx64
1 files changed, 15 insertions, 49 deletions
diff --git a/svx/source/toolbars/fontworkbar.cxx b/svx/source/toolbars/fontworkbar.cxx
index 4bb7a769ec05..0f27578eab18 100644
--- a/svx/source/toolbars/fontworkbar.cxx
+++ b/svx/source/toolbars/fontworkbar.cxx
@@ -221,11 +221,8 @@ bool checkForFontWork( SdrObject* pObj )
return bFound;
}
-bool checkForSelectedFontWork( SdrView const * pSdrView, sal_uInt32& nCheckStatus )
+bool checkForSelectedFontWork( SdrView const * pSdrView )
{
- if ( nCheckStatus & 2 )
- return ( nCheckStatus & 1 ) != 0;
-
const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
const size_t nCount = rMarkList.GetMarkCount();
bool bFound = false;
@@ -234,12 +231,8 @@ bool checkForSelectedFontWork( SdrView const * pSdrView, sal_uInt32& nCheckStatu
SdrObject* pObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
bFound = checkForFontWork(pObj);
}
- if ( bFound )
- nCheckStatus |= 1;
- nCheckStatus |= 2;
return bFound;
}
-}
static void impl_execute( SfxRequest const & rReq, SdrCustomShapeGeometryItem& rGeometryItem, SdrObject* pObj )
{
@@ -547,51 +540,24 @@ void FontworkBar::execute( SdrView& rSdrView, SfxRequest const & rReq, SfxBindin
void FontworkBar::getState( SdrView const * pSdrView, SfxItemSet& rSet )
{
- sal_uInt32 nCheckStatus = 0;
-
- if ( rSet.GetItemState( SID_FONTWORK_ALIGNMENT_FLOATER ) != SfxItemState::UNKNOWN )
- {
- if ( !checkForSelectedFontWork( pSdrView, nCheckStatus ) )
- rSet.DisableItem( SID_FONTWORK_ALIGNMENT_FLOATER );
- }
- if ( rSet.GetItemState( SID_FONTWORK_ALIGNMENT ) != SfxItemState::UNKNOWN )
- {
- if ( !checkForSelectedFontWork( pSdrView, nCheckStatus ) )
- rSet.DisableItem( SID_FONTWORK_ALIGNMENT );
- else
- SetAlignmentState( pSdrView, rSet );
- }
- if ( rSet.GetItemState( SID_FONTWORK_CHARACTER_SPACING_FLOATER ) != SfxItemState::UNKNOWN )
+ if ( checkForSelectedFontWork( pSdrView ) )
{
- if ( !checkForSelectedFontWork( pSdrView, nCheckStatus ) )
- rSet.DisableItem( SID_FONTWORK_CHARACTER_SPACING_FLOATER );
+ SetAlignmentState( pSdrView, rSet );
+ SetCharacterSpacingState( pSdrView, rSet );
+ SetKernCharacterPairsState( pSdrView, rSet );
+ SetFontWorkShapeTypeState( pSdrView, rSet );
}
- if ( rSet.GetItemState( SID_FONTWORK_CHARACTER_SPACING ) != SfxItemState::UNKNOWN )
+ else
{
- if ( !checkForSelectedFontWork( pSdrView, nCheckStatus ) )
- rSet.DisableItem( SID_FONTWORK_CHARACTER_SPACING );
- else
- SetCharacterSpacingState( pSdrView, rSet );
- }
- if ( rSet.GetItemState( SID_FONTWORK_KERN_CHARACTER_PAIRS ) != SfxItemState::UNKNOWN )
- {
- if ( !checkForSelectedFontWork( pSdrView, nCheckStatus ) )
- rSet.DisableItem( SID_FONTWORK_KERN_CHARACTER_PAIRS );
- else
- SetKernCharacterPairsState( pSdrView, rSet );
- }
- if ( rSet.GetItemState( SID_FONTWORK_SAME_LETTER_HEIGHTS ) != SfxItemState::UNKNOWN )
- {
- if ( !checkForSelectedFontWork( pSdrView, nCheckStatus ) )
- rSet.DisableItem( SID_FONTWORK_SAME_LETTER_HEIGHTS );
- }
- if ( rSet.GetItemState( SID_FONTWORK_SHAPE_TYPE ) != SfxItemState::UNKNOWN )
- {
- if ( !checkForSelectedFontWork( pSdrView, nCheckStatus ) )
- rSet.DisableItem( SID_FONTWORK_SHAPE_TYPE );
- else
- SetFontWorkShapeTypeState( pSdrView, rSet );
+ rSet.DisableItem( SID_FONTWORK_ALIGNMENT_FLOATER );
+ rSet.DisableItem( SID_FONTWORK_ALIGNMENT );
+ rSet.DisableItem( SID_FONTWORK_CHARACTER_SPACING_FLOATER );
+ rSet.DisableItem( SID_FONTWORK_CHARACTER_SPACING );
+ rSet.DisableItem( SID_FONTWORK_KERN_CHARACTER_PAIRS );
+ rSet.DisableItem( SID_FONTWORK_SAME_LETTER_HEIGHTS );
+ rSet.DisableItem( SID_FONTWORK_SHAPE_TYPE );
}
}
+}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */