summaryrefslogtreecommitdiff
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
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>
-rw-r--r--include/svx/fontworkbar.hxx2
-rw-r--r--sc/source/ui/view/tabvwsh4.cxx4
-rw-r--r--sd/source/ui/view/ToolBarManager.cxx4
-rw-r--r--svx/source/toolbars/fontworkbar.cxx64
-rw-r--r--sw/source/uibase/shells/drawsh.cxx4
-rw-r--r--sw/source/uibase/wrtsh/wrtsh1.cxx4
6 files changed, 24 insertions, 58 deletions
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;
}