include/svx/fontworkbar.hxx | 2 sc/source/ui/view/tabvwsh4.cxx | 4 - sd/source/ui/view/ToolBarManager.cxx | 4 - svx/source/sidebar/paragraph/ParaLineSpacingControl.cxx | 14 ++- svx/source/toolbars/fontworkbar.cxx | 64 +++------------- sw/source/uibase/shells/drawsh.cxx | 4 - sw/source/uibase/wrtsh/wrtsh1.cxx | 4 - 7 files changed, 32 insertions(+), 64 deletions(-)
New commits: commit 2baf6f654244a67715e4b3d86c49144ce6b5dd13 Author: Armin Le Grand (Allotropia) <armin.le.gr...@me.com> AuthorDate: Thu Jun 10 21:03:01 2021 +0200 Commit: Armin Le Grand <armin.le.gr...@me.com> CommitDate: Fri Jun 11 09:41:03 2021 +0200 tdf#130428 remove unnecessary usage of SfxItemState::UNKNOWN ParaLineSpacingControl::Initialize() is another place where SfxItemState::UNKNOWN was just used as a placeholder for a non-set SfxItemState (aka could not be queried) Change-Id: I95ad01579e5aa4c86ace619e2201481742297c2b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117016 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> Reviewed-by: Armin Le Grand <armin.le.gr...@me.com> diff --git a/svx/source/sidebar/paragraph/ParaLineSpacingControl.cxx b/svx/source/sidebar/paragraph/ParaLineSpacingControl.cxx index bbd0b74de631..9a7b69b1a51d 100644 --- a/svx/source/sidebar/paragraph/ParaLineSpacingControl.cxx +++ b/svx/source/sidebar/paragraph/ParaLineSpacingControl.cxx @@ -124,14 +124,16 @@ void ParaLineSpacingControl::Initialize() { const SfxPoolItem* pItem(nullptr); SfxViewFrame* pCurrent = SfxViewFrame::Current(); - SfxItemState eState = pCurrent ? pCurrent->GetBindings().GetDispatcher()->QueryState(SID_ATTR_PARA_LINESPACE, pItem) : SfxItemState::UNKNOWN; - - const SvxLineSpacingItem* currSPItem = static_cast<const SvxLineSpacingItem*>(pItem); + const bool bItemStateSet(nullptr != pCurrent); + const SfxItemState eState(bItemStateSet + ? pCurrent->GetBindings().GetDispatcher()->QueryState(SID_ATTR_PARA_LINESPACE, pItem) + : SfxItemState::DEFAULT); mxLineDist->set_sensitive(true); - if( eState >= SfxItemState::DEFAULT ) + if( bItemStateSet && (eState == SfxItemState::DEFAULT || eState == SfxItemState::SET) ) { + const SvxLineSpacingItem* currSPItem = static_cast<const SvxLineSpacingItem*>(pItem); MapUnit eUnit = pCurrent->GetPool().GetMetric(currSPItem->Which()); meLNSpaceUnit = eUnit; @@ -201,7 +203,7 @@ void ParaLineSpacingControl::Initialize() break; } } - else if( eState == SfxItemState::DISABLED ) + else if( bItemStateSet && eState == SfxItemState::DISABLED ) { mxLineDist->set_sensitive(false); mxLineDistLabel->set_sensitive(false); @@ -209,7 +211,7 @@ void ParaLineSpacingControl::Initialize() mpActLineDistFld->set_text(""); } - else + else // !bItemStateSet || eState == SfxItemState::DONTCARE || eState == SfxItemState::UNKNOWN { mxLineDistLabel->set_sensitive(false); mpActLineDistFld->set_sensitive(false); commit 552ceeb5c6ccf2573adfd092cc4b2ce214a9c2df Author: Armin Le Grand (Allotropia) <armin.le.gr...@me.com> AuthorDate: Thu Jun 10 19:24:04 2021 +0200 Commit: Armin Le Grand <armin.le.gr...@me.com> CommitDate: Fri Jun 11 09:40:45 2021 +0200 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.gran...@collabora.co.uk> Reviewed-by: Armin Le Grand <armin.le.gr...@me.com> diff --git a/include/svx/fontworkbar.hxx b/include/svx/fontworkbar.hxx index 33c67e8f051b..67c34c05e560 100644 --- a/include/svx/fontworkbar.hxx +++ b/include/svx/fontworkbar.hxx @@ -32,7 +32,7 @@ class SdrObject; namespace svx { -bool SVXCORE_DLLPUBLIC checkForSelectedFontWork(SdrView const* pSdrView, sal_uInt32& nCheckStatus); +bool SVXCORE_DLLPUBLIC checkForSelectedFontWork(SdrView const* pSdrView); bool SVXCORE_DLLPUBLIC checkForFontWork(SdrObject* pObj); class SAL_WARN_UNUSED SVXCORE_DLLPUBLIC FontworkBar final : public SfxShell diff --git a/sc/source/ui/view/tabvwsh4.cxx b/sc/source/ui/view/tabvwsh4.cxx index 0707b7038409..f8f22b49b7ae 100644 --- a/sc/source/ui/view/tabvwsh4.cxx +++ b/sc/source/ui/view/tabvwsh4.cxx @@ -835,9 +835,9 @@ void ScTabViewShell::SetCurSubShell(ObjectSelectionType eOST, bool bForce) pExtrusionBarShell.reset( new svx::ExtrusionBar(this) ); AddSubShell( *pExtrusionBarShell ); } - sal_uInt32 nCheckStatus = 0; + if (svx::checkForSelectedFontWork( - GetScDrawView(), nCheckStatus )) { + GetScDrawView() )) { if (pFontworkBarShell == nullptr) pFontworkBarShell.reset( new svx::FontworkBar(this) ); AddSubShell( *pFontworkBarShell ); diff --git a/sd/source/ui/view/ToolBarManager.cxx b/sd/source/ui/view/ToolBarManager.cxx index 413199c0e7d3..78dc658584df 100644 --- a/sd/source/ui/view/ToolBarManager.cxx +++ b/sd/source/ui/view/ToolBarManager.cxx @@ -1098,8 +1098,8 @@ void ToolBarRules::SelectionHasChanged ( // be activated. if (svx::checkForSelectedCustomShapes(pView, true /* bOnlyExtruded */ )) mpToolBarManager->AddToolBarShell(ToolBarManager::ToolBarGroup::Function, ToolbarId::Svx_Extrusion_Bar); - sal_uInt32 nCheckStatus = 0; - if (svx::checkForSelectedFontWork(pView, nCheckStatus)) + + if (svx::checkForSelectedFontWork(pView)) mpToolBarManager->AddToolBarShell(ToolBarManager::ToolBarGroup::Function, ToolbarId::Svx_Fontwork_Bar); // Switch on additional context-sensitive tool bars. 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: */ diff --git a/sw/source/uibase/shells/drawsh.cxx b/sw/source/uibase/shells/drawsh.cxx index bd1e50e26871..80b8c1eee379 100644 --- a/sw/source/uibase/shells/drawsh.cxx +++ b/sw/source/uibase/shells/drawsh.cxx @@ -545,8 +545,8 @@ SwDrawShell::SwDrawShell(SwView &_rView) : SwWrtShell &rSh = GetShell(); SdrView* pDrView = rSh.GetDrawView(); - sal_uInt32 nCheckStatus = 0; - if (pDrView && svx::checkForSelectedFontWork(pDrView, nCheckStatus)) + + if (pDrView && svx::checkForSelectedFontWork(pDrView)) eContext = vcl::EnumContext::Context::DrawFontwork; SfxShell::SetContextName(vcl::EnumContext::GetContextName(eContext)); diff --git a/sw/source/uibase/wrtsh/wrtsh1.cxx b/sw/source/uibase/wrtsh/wrtsh1.cxx index d32a6154146d..4eb96467fc80 100644 --- a/sw/source/uibase/wrtsh/wrtsh1.cxx +++ b/sw/source/uibase/wrtsh/wrtsh1.cxx @@ -1465,8 +1465,8 @@ SelectionType SwWrtShell::GetSelectionType() const { nCnt |= SelectionType::ExtrudedCustomShape; } - sal_uInt32 nCheckStatus = 0; - if (svx::checkForSelectedFontWork( GetDrawView(), nCheckStatus )) + + if (svx::checkForSelectedFontWork( GetDrawView() )) { nCnt |= SelectionType::FontWork; } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits