summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2016-09-23 12:53:02 +0200
committerNoel Grandin <noel@peralex.com>2016-09-26 08:29:38 +0200
commit0e740b9b07cd3f7b03c875f9a0bfda251bae6cfe (patch)
treeb1be05c5e4c3e30a0f865f075cbed1a32eb9c280
parentdc578a3b80868e43b2abb46f258751124ecb6d35 (diff)
convert ITEMCONN_ constants to scoped enum
Remove unused enum values. Which means that these methods simplify to constant values: ItemConnectionBase::GetEnableState() -> TRISTATE_INDET ItemConnectionBase::IsActive() -> true so inline those values. Which means that ControlWrapperBase::ModifyControl is always called with a first parameter of TRISTATE_INDET, so drop that first parameter. Change-Id: I6d63b63b2f15faad2336665f60e7239e35b74e47
-rw-r--r--cui/source/tabpages/align.cxx32
-rw-r--r--cui/source/tabpages/border.cxx4
-rw-r--r--cui/source/tabpages/borderconn.cxx6
-rw-r--r--include/sfx2/controlwrapper.hxx10
-rw-r--r--include/sfx2/itemconnect.hxx54
-rw-r--r--sfx2/source/dialog/itemconnect.cxx30
6 files changed, 54 insertions, 82 deletions
diff --git a/cui/source/tabpages/align.cxx b/cui/source/tabpages/align.cxx
index c5cf4d2f27fa..98653e3c3aab 100644
--- a/cui/source/tabpages/align.cxx
+++ b/cui/source/tabpages/align.cxx
@@ -215,23 +215,23 @@ AlignmentTabPage::AlignmentTabPage( vcl::Window* pParent, const SfxItemSet& rCor
// This page needs ExchangeSupport.
SetExchangeSupport();
- AddItemConnection( new HorJustConnection( SID_ATTR_ALIGN_HOR_JUSTIFY, *m_pLbHorAlign, s_pHorJustMap, sfx::ITEMCONN_HIDE_UNKNOWN ) );
- AddItemConnection( new sfx::DummyItemConnection( SID_ATTR_ALIGN_INDENT, *m_pFtIndent, sfx::ITEMCONN_HIDE_UNKNOWN ) );
- AddItemConnection( new sfx::MetricConnection<sfx::UInt16ItemWrapper>( SID_ATTR_ALIGN_INDENT, *m_pEdIndent, FUNIT_TWIP, sfx::ITEMCONN_HIDE_UNKNOWN ) );
- AddItemConnection( new sfx::DummyItemConnection( SID_ATTR_ALIGN_VER_JUSTIFY, *m_pFtVerAlign, sfx::ITEMCONN_HIDE_UNKNOWN ) );
- AddItemConnection( new VerJustConnection( SID_ATTR_ALIGN_VER_JUSTIFY, *m_pLbVerAlign, s_pVerJustMap, sfx::ITEMCONN_HIDE_UNKNOWN ) );
- AddItemConnection( new DialControlConnection( SID_ATTR_ALIGN_DEGREES, *m_pCtrlDial, sfx::ITEMCONN_HIDE_UNKNOWN ) );
- AddItemConnection( new sfx::DummyItemConnection( SID_ATTR_ALIGN_DEGREES, *m_pFtRotate, sfx::ITEMCONN_HIDE_UNKNOWN ) );
- AddItemConnection( new sfx::DummyItemConnection( SID_ATTR_ALIGN_LOCKPOS, *m_pFtRefEdge, sfx::ITEMCONN_HIDE_UNKNOWN ) );
- AddItemConnection( new RotateModeConnection( SID_ATTR_ALIGN_LOCKPOS, *m_pVsRefEdge, s_pRotateModeMap, sfx::ITEMCONN_HIDE_UNKNOWN ) );
+ AddItemConnection( new HorJustConnection( SID_ATTR_ALIGN_HOR_JUSTIFY, *m_pLbHorAlign, s_pHorJustMap, ItemConnFlags::HideUnknown ) );
+ AddItemConnection( new sfx::DummyItemConnection( SID_ATTR_ALIGN_INDENT, *m_pFtIndent, ItemConnFlags::HideUnknown ) );
+ AddItemConnection( new sfx::MetricConnection<sfx::UInt16ItemWrapper>( SID_ATTR_ALIGN_INDENT, *m_pEdIndent, FUNIT_TWIP, ItemConnFlags::HideUnknown ) );
+ AddItemConnection( new sfx::DummyItemConnection( SID_ATTR_ALIGN_VER_JUSTIFY, *m_pFtVerAlign, ItemConnFlags::HideUnknown ) );
+ AddItemConnection( new VerJustConnection( SID_ATTR_ALIGN_VER_JUSTIFY, *m_pLbVerAlign, s_pVerJustMap, ItemConnFlags::HideUnknown ) );
+ AddItemConnection( new DialControlConnection( SID_ATTR_ALIGN_DEGREES, *m_pCtrlDial, ItemConnFlags::HideUnknown ) );
+ AddItemConnection( new sfx::DummyItemConnection( SID_ATTR_ALIGN_DEGREES, *m_pFtRotate, ItemConnFlags::HideUnknown ) );
+ AddItemConnection( new sfx::DummyItemConnection( SID_ATTR_ALIGN_LOCKPOS, *m_pFtRefEdge, ItemConnFlags::HideUnknown ) );
+ AddItemConnection( new RotateModeConnection( SID_ATTR_ALIGN_LOCKPOS, *m_pVsRefEdge, s_pRotateModeMap, ItemConnFlags::HideUnknown ) );
AddItemConnection( new OrientStackedConnection( SID_ATTR_ALIGN_STACKED, *m_pOrientHlp ) );
- AddItemConnection( new sfx::DummyItemConnection( SID_ATTR_ALIGN_STACKED, *m_pCbStacked, sfx::ITEMCONN_HIDE_UNKNOWN ) );
- AddItemConnection( new sfx::CheckBoxConnection( SID_ATTR_ALIGN_ASIANVERTICAL, *m_pCbAsianMode, sfx::ITEMCONN_HIDE_UNKNOWN ) );
- AddItemConnection( new sfx::CheckBoxConnection( SID_ATTR_ALIGN_LINEBREAK, *m_pBtnWrap, sfx::ITEMCONN_HIDE_UNKNOWN ) );
- AddItemConnection( new sfx::CheckBoxConnection( SID_ATTR_ALIGN_HYPHENATION, *m_pBtnHyphen, sfx::ITEMCONN_HIDE_UNKNOWN ) );
- AddItemConnection( new sfx::CheckBoxConnection( SID_ATTR_ALIGN_SHRINKTOFIT, *m_pBtnShrink, sfx::ITEMCONN_HIDE_UNKNOWN ) );
- AddItemConnection( new sfx::DummyItemConnection( SID_ATTR_FRAMEDIRECTION, *m_pBoxDirection, sfx::ITEMCONN_HIDE_UNKNOWN ) );
- AddItemConnection( new FrameDirListBoxConnection( SID_ATTR_FRAMEDIRECTION, *m_pLbFrameDir, sfx::ITEMCONN_HIDE_UNKNOWN ) );
+ AddItemConnection( new sfx::DummyItemConnection( SID_ATTR_ALIGN_STACKED, *m_pCbStacked, ItemConnFlags::HideUnknown ) );
+ AddItemConnection( new sfx::CheckBoxConnection( SID_ATTR_ALIGN_ASIANVERTICAL, *m_pCbAsianMode, ItemConnFlags::HideUnknown ) );
+ AddItemConnection( new sfx::CheckBoxConnection( SID_ATTR_ALIGN_LINEBREAK, *m_pBtnWrap, ItemConnFlags::HideUnknown ) );
+ AddItemConnection( new sfx::CheckBoxConnection( SID_ATTR_ALIGN_HYPHENATION, *m_pBtnHyphen, ItemConnFlags::HideUnknown ) );
+ AddItemConnection( new sfx::CheckBoxConnection( SID_ATTR_ALIGN_SHRINKTOFIT, *m_pBtnShrink, ItemConnFlags::HideUnknown ) );
+ AddItemConnection( new sfx::DummyItemConnection( SID_ATTR_FRAMEDIRECTION, *m_pBoxDirection, ItemConnFlags::HideUnknown ) );
+ AddItemConnection( new FrameDirListBoxConnection( SID_ATTR_FRAMEDIRECTION, *m_pLbFrameDir, ItemConnFlags::HideUnknown ) );
}
diff --git a/cui/source/tabpages/border.cxx b/cui/source/tabpages/border.cxx
index baf52c3c3d23..e66d30cd38e9 100644
--- a/cui/source/tabpages/border.cxx
+++ b/cui/source/tabpages/border.cxx
@@ -342,10 +342,10 @@ SvxBorderTabPage::SvxBorderTabPage(vcl::Window* pParent, const SfxItemSet& rCore
// #i43593# - item connection doesn't work for Writer,
// because the Writer item sets contain these items
// checkbox "Merge with next paragraph" only visible for Writer dialog format.paragraph
- AddItemConnection( new sfx::CheckBoxConnection( SID_ATTR_BORDER_CONNECT, *m_pMergeWithNextCB, sfx::ITEMCONN_DEFAULT ) );
+ AddItemConnection( new sfx::CheckBoxConnection( SID_ATTR_BORDER_CONNECT, *m_pMergeWithNextCB, ItemConnFlags::NONE ) );
m_pMergeWithNextCB->Hide();
// checkbox "Merge adjacent line styles" only visible for Writer dialog format.table
- AddItemConnection( new sfx::CheckBoxConnection( SID_SW_COLLAPSING_BORDERS, *m_pMergeAdjacentBordersCB, sfx::ITEMCONN_DEFAULT ) );
+ AddItemConnection( new sfx::CheckBoxConnection( SID_SW_COLLAPSING_BORDERS, *m_pMergeAdjacentBordersCB, ItemConnFlags::NONE ) );
m_pMergeAdjacentBordersCB->Hide();
if( pDocSh )
diff --git a/cui/source/tabpages/borderconn.cxx b/cui/source/tabpages/borderconn.cxx
index a3049990bde9..5aec14626802 100644
--- a/cui/source/tabpages/borderconn.cxx
+++ b/cui/source/tabpages/borderconn.cxx
@@ -170,7 +170,7 @@ public:
MarginConnection::MarginConnection( const SfxItemSet& rItemSet,
MetricField& rMfLeft, MetricField& rMfRight, MetricField& rMfTop, MetricField& rMfBottom ) :
- ItemControlConnectionType( SID_ATTR_ALIGN_MARGIN, new MarginControlsWrapper( rMfLeft, rMfRight, rMfTop, rMfBottom ), sfx::ITEMCONN_DEFAULT )
+ ItemControlConnectionType( SID_ATTR_ALIGN_MARGIN, new MarginControlsWrapper( rMfLeft, rMfRight, rMfTop, rMfBottom ), ItemConnFlags::NONE )
{
mxCtrlWrp->SetDefaultValue( maItemWrp.GetDefaultItem( rItemSet ) );
}
@@ -255,7 +255,7 @@ public:
ShadowConnection::ShadowConnection( const SfxItemSet& rItemSet,
ValueSet& rVsPos, MetricField& rMfSize, ColorListBox& rLbColor ) :
- ItemControlConnectionType( SID_ATTR_BORDER_SHADOW, new ShadowControlsWrapper( rVsPos, rMfSize, rLbColor ), sfx::ITEMCONN_DEFAULT )
+ ItemControlConnectionType( SID_ATTR_BORDER_SHADOW, new ShadowControlsWrapper( rVsPos, rMfSize, rLbColor ), ItemConnFlags::NONE )
{
mxCtrlWrp->SetDefaultValue( maItemWrp.GetDefaultItem( rItemSet ) );
}
@@ -264,7 +264,7 @@ ShadowConnection::ShadowConnection( const SfxItemSet& rItemSet,
sfx::ItemConnectionBase* CreateFrameLineConnection( sal_uInt16 nSlot,
FrameSelector& rFrameSel, FrameBorderType eBorder )
{
- return new sfx::ItemControlConnection< LineItemWrapper, FrameSelectorWrapper >( nSlot, new FrameSelectorWrapper( rFrameSel, eBorder ), sfx::ITEMCONN_DEFAULT );
+ return new sfx::ItemControlConnection< LineItemWrapper, FrameSelectorWrapper >( nSlot, new FrameSelectorWrapper( rFrameSel, eBorder ), ItemConnFlags::NONE );
}
sfx::ItemConnectionBase* CreateMarginConnection( const SfxItemSet& rItemSet,
diff --git a/include/sfx2/controlwrapper.hxx b/include/sfx2/controlwrapper.hxx
index e2d5b55b2ee3..079258dbfc1a 100644
--- a/include/sfx2/controlwrapper.hxx
+++ b/include/sfx2/controlwrapper.hxx
@@ -148,7 +148,7 @@ public:
/** Derived classes enable, disable, show, or hide control(s).
@descr Will do nothing, if the corresponding parameter is TRISTATE_INDET. */
- virtual void ModifyControl( TriState eEnable, TriState eShow ) = 0;
+ virtual void ModifyControl( TriState eShow ) = 0;
/** Derived classes return true if the control is in "don't know" state. */
virtual bool IsControlDontKnow() const = 0;
@@ -194,7 +194,7 @@ public:
/** Enables, disables, shows, or hides the control.
@descr Does nothing, if the corresponding parameter is TRISTATE_INDET. */
- virtual void ModifyControl( TriState eEnable, TriState eShow ) override;
+ virtual void ModifyControl( TriState eShow ) override;
/** Derived classes return the value the control contains. */
virtual ValueT GetControlValue() const = 0;
@@ -374,7 +374,7 @@ public:
void RegisterControlWrapper( ControlWrapperBase& rWrapper );
/** Enables, disables, shows, or hides the registered controls. */
- virtual void ModifyControl( TriState eEnable, TriState eShow ) override;
+ virtual void ModifyControl( TriState eShow ) override;
/** Returns true if all registered controls are in "don't know" state. */
virtual bool IsControlDontKnow() const override;
@@ -469,10 +469,8 @@ PosT PosValueMapper< PosT, ValueT >::GetPosFromValue( ValueT nValue ) const
template< typename ControlT, typename ValueT >
-inline void SingleControlWrapper< ControlT, ValueT >::ModifyControl( TriState eEnable, TriState eShow )
+inline void SingleControlWrapper< ControlT, ValueT >::ModifyControl( TriState eShow )
{
- if( eEnable != TRISTATE_INDET )
- mrControl.Enable( eEnable == TRISTATE_TRUE );
if( eShow != TRISTATE_INDET )
mrControl.Show( eShow == TRISTATE_TRUE );
}
diff --git a/include/sfx2/itemconnect.hxx b/include/sfx2/itemconnect.hxx
index 95a9e5509f39..a60d4531038d 100644
--- a/include/sfx2/itemconnect.hxx
+++ b/include/sfx2/itemconnect.hxx
@@ -21,35 +21,26 @@
#define INCLUDED_SFX2_ITEMCONNECT_HXX
#include <sal/config.h>
+#include <o3tl/typed_flags_set.hxx>
#include <sfx2/dllapi.h>
-
-#include <memory>
-
#include <sfx2/itemwrapper.hxx>
#include <sfx2/controlwrapper.hxx>
+#include <memory>
-namespace sfx {
-
-typedef int ItemConnFlags;
+enum class ItemConnFlags
+{
/** No special state for the connection. */
-const ItemConnFlags ITEMCONN_NONE = 0x0000;
-
-/** Connection is inactive - virtual functions will not be called. */
-const ItemConnFlags ITEMCONN_INACTIVE = 0x0001;
-
-/** Enable control(s), if the item is known. */
-const ItemConnFlags ITEMCONN_ENABLE_KNOWN = 0x0010;
-/** Disable control(s), if the item is unknown. */
-const ItemConnFlags ITEMCONN_DISABLE_UNKNOWN = 0x0020;
-/** Show control(s), if the item is known. */
-const ItemConnFlags ITEMCONN_SHOW_KNOWN = 0x0040;
+ NONE = 0x0000,
/** Hide control(s), if the item is unknown. */
-const ItemConnFlags ITEMCONN_HIDE_UNKNOWN = 0x0080;
-
-/** Default value for constructors. */
-const ItemConnFlags ITEMCONN_DEFAULT = ITEMCONN_NONE;
+ HideUnknown = 0x0001,
+};
+namespace o3tl
+{
+ template<> struct typed_flags<ItemConnFlags> : is_typed_flags<ItemConnFlags, 0x0001> {};
+}
+namespace sfx {
// Base connection classes
@@ -180,9 +171,6 @@ class SFX2_DLLPUBLIC ItemConnectionBase
public:
virtual ~ItemConnectionBase();
- /** Returns true if this connection is active. */
- bool IsActive() const;
-
/** Calls the virtual ApplyFlags() function, if connection is active. */
void DoApplyFlags( const SfxItemSet* pItemSet );
/** Calls the virtual Reset() function, if connection is active. */
@@ -191,7 +179,7 @@ public:
bool DoFillItemSet( SfxItemSet& rDestSet, const SfxItemSet& rOldSet );
protected:
- explicit ItemConnectionBase( ItemConnFlags nFlags = ITEMCONN_DEFAULT );
+ explicit ItemConnectionBase( ItemConnFlags nFlags = ItemConnFlags::NONE );
/** Derived classes implement actions according to current flags here. */
virtual void ApplyFlags( const SfxItemSet* pItemSet ) = 0;
@@ -200,8 +188,6 @@ protected:
/** Derived classes implement filling item sets from controls here. */
virtual bool FillItemSet( SfxItemSet& rDestSet, const SfxItemSet& rOldSet ) = 0;
- /** Returns whether to enable a control, according to current flags. */
- TriState GetEnableState( bool bKnown ) const;
/** Returns whether to show a control, according to current flags. */
TriState GetShowState( bool bKnown ) const;
@@ -236,13 +222,13 @@ public:
/** Receives pointer to a newly created control wrapper.
@descr Takes ownership of the control wrapper. */
explicit ItemControlConnection( sal_uInt16 nSlot, ControlWrpT* pNewCtrlWrp,
- ItemConnFlags nFlags = ITEMCONN_DEFAULT );
+ ItemConnFlags nFlags = ItemConnFlags::NONE );
/** Convenience constructor. Receives reference to a control directly.
@descr May only be used, if ControlWrpT::ControlWrpT( ControlType& )
constructor exists. */
explicit ItemControlConnection( sal_uInt16 nSlot, ControlType& rControl,
- ItemConnFlags nFlags = ITEMCONN_DEFAULT );
+ ItemConnFlags nFlags = ItemConnFlags::NONE );
virtual ~ItemControlConnection() override;
@@ -274,7 +260,7 @@ class SFX2_DLLPUBLIC DummyItemConnection:
{
public:
explicit DummyItemConnection( sal_uInt16 nSlot, vcl::Window& rWindow,
- ItemConnFlags nFlags = ITEMCONN_DEFAULT );
+ ItemConnFlags nFlags = ItemConnFlags::NONE );
protected:
virtual void ApplyFlags( const SfxItemSet* pItemSet ) override;
@@ -309,7 +295,7 @@ public:
typedef typename ItemControlConnectionType::ControlWrapperType MetricFieldWrapperType;
explicit MetricConnection( sal_uInt16 nSlot, MetricField& rField,
- FieldUnit eItemUnit = FUNIT_NONE, ItemConnFlags nFlags = ITEMCONN_DEFAULT );
+ FieldUnit eItemUnit = FUNIT_NONE, ItemConnFlags nFlags = ItemConnFlags::NONE );
};
@@ -334,7 +320,7 @@ public:
typedef typename ListBoxWrapperType::MapEntryType MapEntryType;
explicit ListBoxConnection( sal_uInt16 nSlot, ListBox& rListBox,
- const MapEntryType* pMap = nullptr, ItemConnFlags nFlags = ITEMCONN_DEFAULT );
+ const MapEntryType* pMap = nullptr, ItemConnFlags nFlags = ItemConnFlags::NONE );
};
@@ -359,7 +345,7 @@ public:
typedef typename ValueSetWrapperType::MapEntryType MapEntryType;
explicit ValueSetConnection( sal_uInt16 nSlot, ValueSet& rValueSet,
- const MapEntryType* pMap = nullptr, ItemConnFlags nFlags = ITEMCONN_DEFAULT );
+ const MapEntryType* pMap = nullptr, ItemConnFlags nFlags = ItemConnFlags::NONE );
};
@@ -428,7 +414,7 @@ template< typename ItemWrpT, typename ControlWrpT >
void ItemControlConnection< ItemWrpT, ControlWrpT >::ApplyFlags( const SfxItemSet* pItemSet )
{
bool bKnown = ItemWrapperHelper::IsKnownItem( *pItemSet, maItemWrp.GetSlotId() );
- mxCtrlWrp->ModifyControl( GetEnableState( bKnown ), GetShowState( bKnown ) );
+ mxCtrlWrp->ModifyControl( GetShowState( bKnown ) );
}
template< typename ItemWrpT, typename ControlWrpT >
diff --git a/sfx2/source/dialog/itemconnect.cxx b/sfx2/source/dialog/itemconnect.cxx
index 3335f78d9080..f07e55131814 100644
--- a/sfx2/source/dialog/itemconnect.cxx
+++ b/sfx2/source/dialog/itemconnect.cxx
@@ -30,9 +30,9 @@ namespace sfx {
namespace {
-TriState lclConvertToTriState( bool bKnown, bool bIsKnownFlag, bool bIsUnknownFlag )
+TriState lclConvertToTriState( bool bKnown, bool bIsUnknownFlag )
{
- return (bKnown && bIsKnownFlag) ? TRISTATE_TRUE : ((!bKnown && bIsUnknownFlag) ? TRISTATE_FALSE : TRISTATE_INDET);
+ return (!bKnown && bIsUnknownFlag) ? TRISTATE_FALSE : TRISTATE_INDET;
}
} // namespace
@@ -181,10 +181,10 @@ void MultiControlWrapperHelper::RegisterControlWrapper( ControlWrapperBase& rWra
mxImpl->maVec.push_back( &rWrapper );
}
-void MultiControlWrapperHelper::ModifyControl( TriState eEnable, TriState eShow )
+void MultiControlWrapperHelper::ModifyControl( TriState eShow )
{
for( ControlWrpVec::iterator aIt = mxImpl->maVec.begin(), aEnd = mxImpl->maVec.end(); aIt != aEnd; ++aIt )
- (*aIt)->ModifyControl( eEnable, eShow );
+ (*aIt)->ModifyControl( eShow );
}
bool MultiControlWrapperHelper::IsControlDontKnow() const
@@ -214,36 +214,24 @@ ItemConnectionBase::~ItemConnectionBase()
{
}
-bool ItemConnectionBase::IsActive() const
-{
- return !(mnFlags & ITEMCONN_INACTIVE);
-}
-
void ItemConnectionBase::DoApplyFlags( const SfxItemSet* pItemSet )
{
- if( IsActive() )
- ApplyFlags( pItemSet );
+ ApplyFlags( pItemSet );
}
void ItemConnectionBase::DoReset( const SfxItemSet* pItemSet )
{
- if( IsActive() )
- Reset( pItemSet );
+ Reset( pItemSet );
}
bool ItemConnectionBase::DoFillItemSet( SfxItemSet& rDestSet, const SfxItemSet& rOldSet )
{
- return IsActive() && FillItemSet( rDestSet, rOldSet );
-}
-
-TriState ItemConnectionBase::GetEnableState( bool bKnown ) const
-{
- return lclConvertToTriState( bKnown, (mnFlags & ITEMCONN_ENABLE_KNOWN) != 0, (mnFlags & ITEMCONN_DISABLE_UNKNOWN) != 0 );
+ return FillItemSet( rDestSet, rOldSet );
}
TriState ItemConnectionBase::GetShowState( bool bKnown ) const
{
- return lclConvertToTriState( bKnown, (mnFlags & ITEMCONN_SHOW_KNOWN) != 0, (mnFlags & ITEMCONN_HIDE_UNKNOWN) != 0 );
+ return lclConvertToTriState( bKnown, bool(mnFlags & ItemConnFlags::HideUnknown) );
}
@@ -260,7 +248,7 @@ DummyItemConnection::DummyItemConnection( sal_uInt16 nSlot, vcl::Window& rWindow
void DummyItemConnection::ApplyFlags( const SfxItemSet* pItemSet )
{
bool bKnown = ItemWrapperHelper::IsKnownItem( *pItemSet, mnSlot );
- ModifyControl( GetEnableState( bKnown ), GetShowState( bKnown ) );
+ ModifyControl( GetShowState( bKnown ) );
}
void DummyItemConnection::Reset( const SfxItemSet* )