Kaydet (Commit) 27e8eb73 authored tarafından Noel Grandin's avatar Noel Grandin

convert SV_ITEMSTATE constants to SvItemState scoped enum

Change-Id: I7d7d516f37cbb5e28a842bbc6bff54916d450dbb
üst 90dc63a8
......@@ -516,7 +516,7 @@ SvButtonState SvxFontSubstCheckListBox::GetCheckButtonState( SvTreeListEntry* pE
if (pItem->GetType() == SV_ITEM_ID_LBOXBUTTON)
{
sal_uInt16 nButtonFlags = pItem->GetButtonFlags();
SvItemStateFlags nButtonFlags = pItem->GetButtonFlags();
eState = pCheckButtonData->ConvertToButtonState( nButtonFlags );
}
......
......@@ -214,7 +214,7 @@ bool OfaMSFilterTabPage2::FillItemSet( SfxItemSet* )
SvLBoxButton* pItem = static_cast<SvLBoxButton*>(pEntry->GetItem( nCol ));
if (pItem && pItem->GetType() == SV_ITEM_ID_LBOXBUTTON)
{
sal_uInt16 nButtonFlags = pItem->GetButtonFlags();
SvItemStateFlags nButtonFlags = pItem->GetButtonFlags();
bCheck = SV_BUTTON_CHECKED ==
pCheckButtonData->ConvertToButtonState( nButtonFlags );
......@@ -397,7 +397,7 @@ SvButtonState OfaMSFilterTabPage2::MSFltrSimpleTable::GetCheckButtonState(
if (pItem->GetType() == SV_ITEM_ID_LBOXBUTTON)
{
sal_uInt16 nButtonFlags = pItem->GetButtonFlags();
SvItemStateFlags nButtonFlags = pItem->GetButtonFlags();
eState = pCheckButtonData->ConvertToButtonState( nButtonFlags );
}
......
......@@ -791,7 +791,7 @@ SvButtonState OfaACorrCheckListBox::GetCheckButtonState( SvTreeListEntry* pEntry
if (pItem->GetType() == SV_ITEM_ID_LBOXBUTTON)
{
sal_uInt16 nButtonFlags = pItem->GetButtonFlags();
SvItemStateFlags nButtonFlags = pItem->GetButtonFlags();
eState = pCheckButtonData->ConvertToButtonState( nButtonFlags );
}
......
......@@ -25,6 +25,7 @@
#include <tools/link.hxx>
#include <vcl/image.hxx>
#include <svtools/treelistbox.hxx>
#include <o3tl/typed_flags_set.hxx>
class SvTreeListEntry;
......@@ -40,6 +41,19 @@ enum class SvBmp
STATICIMAGE = 6
};
enum class SvItemStateFlags
{
NONE = 0x00,
UNCHECKED = 0x01,
CHECKED = 0x02,
TRISTATE = 0x04,
HILIGHTED = 0x08
};
namespace o3tl
{
template<> struct typed_flags<SvItemStateFlags> : is_typed_flags<SvItemStateFlags, 0x0f> {};
}
struct SvLBoxButtonData_Impl;
class SVT_DLLPUBLIC SvLBoxButtonData
......@@ -63,7 +77,7 @@ public:
~SvLBoxButtonData();
SvBmp GetIndex( sal_uInt16 nItemState );
SvBmp GetIndex( SvItemStateFlags nItemState );
long Width();
long Height();
void SetLink( const Link& rLink) { aLink=rLink; }
......@@ -72,8 +86,8 @@ public:
// as buttons are not derived from LinkHdl
void CallLink();
void StoreButtonState( SvTreeListEntry* pEntry, sal_uInt16 nItemFlags );
SvButtonState ConvertToButtonState( sal_uInt16 nItemFlags ) const;
void StoreButtonState( SvTreeListEntry* pEntry, SvItemStateFlags nItemFlags );
SvButtonState ConvertToButtonState( SvItemStateFlags nItemFlags ) const;
SvButtonState GetActButtonState() const { return eState; }
......@@ -126,18 +140,12 @@ public:
};
#define SV_ITEMSTATE_UNCHECKED 0x0001
#define SV_ITEMSTATE_CHECKED 0x0002
#define SV_ITEMSTATE_TRISTATE 0x0004
#define SV_ITEMSTATE_HILIGHTED 0x0008
#define SV_STATE_MASK 0xFFF8 // for deletion of UNCHECKED,CHECKED,TRISTATE
class SVT_DLLPUBLIC SvLBoxButton : public SvLBoxItem
{
bool isVis;
SvLBoxButtonData* pData;
SvLBoxButtonKind eKind;
sal_uInt16 nItemFlags;
SvItemStateFlags nItemFlags;
void ImplAdjustBoxSize( Size& io_rCtrlSize, ControlType i_eType, vcl::Window* pParent );
public:
......@@ -158,11 +166,11 @@ public:
const Point& rPos, SvTreeListBox& rOutDev, const SvViewDataEntry* pView, const SvTreeListEntry* pEntry) SAL_OVERRIDE;
virtual SvLBoxItem* Create() const SAL_OVERRIDE;
virtual void Clone( SvLBoxItem* pSource ) SAL_OVERRIDE;
sal_uInt16 GetButtonFlags() const { return nItemFlags; }
bool IsStateChecked() const { return (nItemFlags & SV_ITEMSTATE_CHECKED)!=0; }
bool IsStateUnchecked() const { return (nItemFlags & SV_ITEMSTATE_UNCHECKED)!=0; }
bool IsStateTristate() const { return (nItemFlags & SV_ITEMSTATE_TRISTATE)!=0; }
bool IsStateHilighted() const { return (nItemFlags & SV_ITEMSTATE_HILIGHTED)!=0; }
SvItemStateFlags GetButtonFlags() const { return nItemFlags; }
bool IsStateChecked() const { return bool(nItemFlags & SvItemStateFlags::CHECKED); }
bool IsStateUnchecked() const { return bool(nItemFlags & SvItemStateFlags::UNCHECKED); }
bool IsStateTristate() const { return bool(nItemFlags & SvItemStateFlags::TRISTATE); }
bool IsStateHilighted() const { return bool(nItemFlags & SvItemStateFlags::HILIGHTED); }
void SetStateChecked();
void SetStateUnchecked();
void SetStateTristate();
......@@ -178,25 +186,25 @@ public:
inline void SvLBoxButton::SetStateChecked()
{
nItemFlags &= SV_STATE_MASK;
nItemFlags |= SV_ITEMSTATE_CHECKED;
nItemFlags &= SvItemStateFlags::HILIGHTED;
nItemFlags |= SvItemStateFlags::CHECKED;
}
inline void SvLBoxButton::SetStateUnchecked()
{
nItemFlags &= SV_STATE_MASK;
nItemFlags |= SV_ITEMSTATE_UNCHECKED;
nItemFlags &= SvItemStateFlags::HILIGHTED;
nItemFlags |= SvItemStateFlags::UNCHECKED;
}
inline void SvLBoxButton::SetStateTristate()
{
nItemFlags &= SV_STATE_MASK;
nItemFlags |= SV_ITEMSTATE_TRISTATE;
nItemFlags &= SvItemStateFlags::HILIGHTED;
nItemFlags |= SvItemStateFlags::TRISTATE;
}
inline void SvLBoxButton::SetStateHilighted( bool bHilight )
{
if ( bHilight )
nItemFlags |= SV_ITEMSTATE_HILIGHTED;
nItemFlags |= SvItemStateFlags::HILIGHTED;
else
nItemFlags &= ~SV_ITEMSTATE_HILIGHTED;
nItemFlags &= ~SvItemStateFlags::HILIGHTED;
}
......
......@@ -76,27 +76,23 @@ void SvLBoxButtonData::CallLink()
aLink.Call( this );
}
SvBmp SvLBoxButtonData::GetIndex( sal_uInt16 nItemState )
SvBmp SvLBoxButtonData::GetIndex( SvItemStateFlags nItemState )
{
nItemState &= 0x000F;
SvBmp nIdx;
switch( nItemState )
{
case SV_ITEMSTATE_UNCHECKED:
nIdx = SvBmp::UNCHECKED; break;
case SV_ITEMSTATE_CHECKED:
nIdx = SvBmp::CHECKED; break;
case SV_ITEMSTATE_TRISTATE:
nIdx = SvBmp::TRISTATE; break;
case SV_ITEMSTATE_UNCHECKED | SV_ITEMSTATE_HILIGHTED:
nIdx = SvBmp::HIUNCHECKED; break;
case SV_ITEMSTATE_CHECKED | SV_ITEMSTATE_HILIGHTED:
nIdx = SvBmp::HICHECKED; break;
case SV_ITEMSTATE_TRISTATE | SV_ITEMSTATE_HILIGHTED:
nIdx = SvBmp::HITRISTATE; break;
default:
nIdx = SvBmp::UNCHECKED;
}
if (nItemState == SvItemStateFlags::UNCHECKED)
nIdx = SvBmp::UNCHECKED;
else if (nItemState == SvItemStateFlags::CHECKED)
nIdx = SvBmp::CHECKED;
else if (nItemState == SvItemStateFlags::TRISTATE)
nIdx = SvBmp::TRISTATE;
else if (nItemState == (SvItemStateFlags::UNCHECKED | SvItemStateFlags::HILIGHTED))
nIdx = SvBmp::HIUNCHECKED;
else if (nItemState == (SvItemStateFlags::CHECKED | SvItemStateFlags::HILIGHTED))
nIdx = SvBmp::HICHECKED;
else if (nItemState == (SvItemStateFlags::TRISTATE | SvItemStateFlags::HILIGHTED))
nIdx = SvBmp::HITRISTATE;
else
nIdx = SvBmp::UNCHECKED;
return nIdx;
}
......@@ -109,26 +105,24 @@ void SvLBoxButtonData::SetWidthAndHeight()
}
void SvLBoxButtonData::StoreButtonState( SvTreeListEntry* pActEntry, sal_uInt16 nItemFlags )
void SvLBoxButtonData::StoreButtonState( SvTreeListEntry* pActEntry, SvItemStateFlags nItemFlags )
{
pImpl->pEntry = pActEntry;
eState = ConvertToButtonState( nItemFlags );
}
SvButtonState SvLBoxButtonData::ConvertToButtonState( sal_uInt16 nItemFlags ) const
SvButtonState SvLBoxButtonData::ConvertToButtonState( SvItemStateFlags nItemFlags ) const
{
nItemFlags &= (SV_ITEMSTATE_UNCHECKED |
SV_ITEMSTATE_CHECKED |
SV_ITEMSTATE_TRISTATE);
nItemFlags &= (SvItemStateFlags::UNCHECKED |
SvItemStateFlags::CHECKED |
SvItemStateFlags::TRISTATE);
switch( nItemFlags )
{
case SV_ITEMSTATE_UNCHECKED:
case SvItemStateFlags::UNCHECKED:
return SV_BUTTON_UNCHECKED;
case SV_ITEMSTATE_CHECKED:
case SvItemStateFlags::CHECKED:
return SV_BUTTON_CHECKED;
case SV_ITEMSTATE_TRISTATE:
case SvItemStateFlags::TRISTATE:
return SV_BUTTON_TRISTATE;
default:
return SV_BUTTON_UNCHECKED;
......@@ -305,7 +299,7 @@ SvLBoxButton::SvLBoxButton( SvTreeListEntry* pEntry, SvLBoxButtonKind eTheKind,
, isVis(true)
, pData(pBData)
, eKind(eTheKind)
, nItemFlags(0)
, nItemFlags(SvItemStateFlags::NONE)
{
SetStateUnchecked();
}
......@@ -315,7 +309,7 @@ SvLBoxButton::SvLBoxButton()
, isVis(false)
, pData(0)
, eKind(SvLBoxButtonKind_enabledCheckbox)
, nItemFlags(0)
, nItemFlags(SvItemStateFlags::NONE)
{
SetStateUnchecked();
}
......
......@@ -554,7 +554,7 @@ bool SvHeaderTabListBox::IsItemChecked( SvTreeListEntry* pEntry, sal_uInt16 nCol
if (pItem && pItem->GetType() == SV_ITEM_ID_LBOXBUTTON)
{
sal_uInt16 nButtonFlags = pItem->GetButtonFlags();
SvItemStateFlags nButtonFlags = pItem->GetButtonFlags();
eState = pCheckButtonData->ConvertToButtonState( nButtonFlags );
}
......@@ -686,7 +686,7 @@ bool SvHeaderTabListBox::IsCellCheckBox( long _nRow, sal_uInt16 _nColumn, TriSta
if (pItem && pItem->GetType() == SV_ITEM_ID_LBOXBUTTON)
{
bRet = true;
_rState = ( ( pItem->GetButtonFlags() & SV_ITEMSTATE_UNCHECKED ) == 0 )
_rState = ( ( pItem->GetButtonFlags() & SvItemStateFlags::UNCHECKED ) == SvItemStateFlags::NONE )
? TRISTATE_TRUE : TRISTATE_FALSE;
}
}
......
......@@ -2006,7 +2006,7 @@ SvButtonState SvTreeListBox::GetCheckButtonState( SvTreeListEntry* pEntry ) cons
SvLBoxButton* pItem = static_cast<SvLBoxButton*>(pEntry->GetFirstItem(SV_ITEM_ID_LBOXBUTTON));
if(!pItem)
return SV_BUTTON_TRISTATE;
sal_uInt16 nButtonFlags = pItem->GetButtonFlags();
SvItemStateFlags nButtonFlags = pItem->GetButtonFlags();
eState = pCheckButtonData->ConvertToButtonState( nButtonFlags );
}
return eState;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment