fdo#84938: replace TOOLBOXITEM_ constants with enum

Change-Id: I08c4a456f9e80f70719ca8c3ad5c0f0d2d8282f6
Reviewed-on: https://gerrit.libreoffice.org/12258
Tested-by: LibreOffice gerrit bot <gerrit@libreoffice.org>
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
This commit is contained in:
Noel Grandin
2014-11-04 21:10:34 +02:00
committed by Noel Grandin
parent 705c48d32e
commit 3c58f07680
10 changed files with 52 additions and 52 deletions

View File

@@ -80,7 +80,7 @@ VCLXAccessibleToolBoxItem::VCLXAccessibleToolBoxItem( ToolBox* _pToolBox, sal_In
ToolBoxItemType eType = m_pToolBox->GetItemType( (sal_uInt16)m_nIndexInParent );
switch ( eType )
{
case TOOLBOXITEM_BUTTON :
case ToolBoxItemType::BUTTON :
{
ToolBoxItemBits nBits = m_pToolBox->GetItemBits( m_nItemId );
if (
@@ -99,12 +99,12 @@ VCLXAccessibleToolBoxItem::VCLXAccessibleToolBoxItem( ToolBox* _pToolBox, sal_In
break;
}
case TOOLBOXITEM_SPACE :
case ToolBoxItemType::SPACE :
m_nRole = AccessibleRole::FILLER;
break;
case TOOLBOXITEM_SEPARATOR :
case TOOLBOXITEM_BREAK :
case ToolBoxItemType::SEPARATOR :
case ToolBoxItemType::BREAK :
m_nRole = AccessibleRole::SEPARATOR;
break;

View File

@@ -357,7 +357,7 @@ namespace frm
for ( sal_uInt16 i=0; i<nItemCount; ++i )
{
sal_uInt16 nId = m_pToolbar->GetItemId( i );
if ( ( TOOLBOXITEM_BUTTON == m_pToolbar->GetItemType( i ) ) && !isArtificialItem( nId ) )
if ( ( ToolBoxItemType::BUTTON == m_pToolbar->GetItemType( i ) ) && !isArtificialItem( nId ) )
aFormFeatures.push_back( nId );
}

View File

@@ -242,7 +242,7 @@ void AddonsToolBarManager::FillToolbar( const Sequence< Sequence< PropertyValue
if ( aURL == TOOLBOXITEM_SEPARATOR_STR )
{
sal_uInt16 nCount = m_pToolBar->GetItemCount();
if ( nCount > 0 && ( m_pToolBar->GetItemType( nCount-1 ) != TOOLBOXITEM_SEPARATOR ) && nElements > 0 )
if ( nCount > 0 && ( m_pToolBar->GetItemType( nCount-1 ) != ToolBoxItemType::SEPARATOR ) && nElements > 0 )
{
nElements = 0;
m_pToolBar->InsertSeparator();
@@ -251,7 +251,7 @@ void AddonsToolBarManager::FillToolbar( const Sequence< Sequence< PropertyValue
else
{
sal_uInt16 nCount = m_pToolBar->GetItemCount();
if ( bAppendSeparator && nCount > 0 && ( m_pToolBar->GetItemType( nCount-1 ) != TOOLBOXITEM_SEPARATOR ))
if ( bAppendSeparator && nCount > 0 && ( m_pToolBar->GetItemType( nCount-1 ) != ToolBoxItemType::SEPARATOR ))
{
// We have to append a separator first if the last item is not a separator
m_pToolBar->InsertSeparator();

View File

@@ -1719,7 +1719,7 @@ bool ToolBarManager::MenuItemAllowed( sal_uInt16 ) const
for ( nPos = 0; nPos < m_pToolBar->GetItemCount(); ++nPos )
{
if ( m_pToolBar->GetItemType(nPos) == TOOLBOXITEM_BUTTON )
if ( m_pToolBar->GetItemType(nPos) == ToolBoxItemType::BUTTON )
{
sal_uInt16 nId = m_pToolBar->GetItemId(nPos);
OUString aCommandURL = m_pToolBar->GetItemCommand( nId );

View File

@@ -72,9 +72,7 @@ namespace o3tl
template<> struct typed_flags<ToolBoxItemBits> : is_typed_flags<ToolBoxItemBits, 0x3ff> {};
}
enum ToolBoxItemType { TOOLBOXITEM_DONTKNOW, TOOLBOXITEM_BUTTON,
TOOLBOXITEM_SPACE, TOOLBOXITEM_SEPARATOR,
TOOLBOXITEM_BREAK };
enum class ToolBoxItemType { DONTKNOW, BUTTON, SPACE, SEPARATOR, BREAK };
enum ButtonType { BUTTON_SYMBOL, BUTTON_TEXT, BUTTON_SYMBOLTEXT };

View File

@@ -42,6 +42,7 @@ enum class WindowBorderStyle : sal_Int16;
enum class TimeFieldFormat : sal_Int32;
enum class KeyFuncType : sal_Int32;
enum class MenuItemBits : sal_Int16;
enum class ToolBoxItemType;
struct WriteRcContext
{
@@ -153,6 +154,7 @@ class RscTypCont
inline void SETCONST( RscConst *p1, const char * p2, TimeFieldFormat p3 ) { SETCONST(p1, p2, static_cast<sal_uInt32>(p3)); }
inline void SETCONST( RscConst *p1, const char * p2, MenuItemBits p3 ) { SETCONST(p1, p2, static_cast<sal_uInt32>(p3)); }
inline void SETCONST( RscConst *p1, Atom p2, MenuItemBits p3 ) { SETCONST(p1, p2, static_cast<sal_uInt32>(p3)); }
inline void SETCONST( RscConst *p1, const char * p2, ToolBoxItemType p3 ) { SETCONST(p1, p2, static_cast<sal_uInt32>(p3)); }
RscEnum * InitLangType();
RscEnum * InitFieldUnitsType();
RscEnum * InitTimeFieldFormat();

View File

@@ -1290,10 +1290,10 @@ RscTop * RscTypCont::InitClassToolBoxItem( RscTop * pSuper,
RscEnum * pEnum;
aBaseLst.push_back( pEnum = new RscEnum( pHS->getID( "EnumToolBoxItemType" ), RSC_NOTYPE ) );
SETCONST( pEnum, "TOOLBOXITEM_BUTTON", TOOLBOXITEM_BUTTON );
SETCONST( pEnum, "TOOLBOXITEM_SPACE", TOOLBOXITEM_SPACE );
SETCONST( pEnum, "TOOLBOXITEM_SEPARATOR", TOOLBOXITEM_SEPARATOR );
SETCONST( pEnum, "TOOLBOXITEM_BREAK", TOOLBOXITEM_BREAK );
SETCONST( pEnum, "TOOLBOXITEM_BUTTON", ToolBoxItemType::BUTTON );
SETCONST( pEnum, "TOOLBOXITEM_SPACE", ToolBoxItemType::SPACE );
SETCONST( pEnum, "TOOLBOXITEM_SEPARATOR", ToolBoxItemType::SEPARATOR );
SETCONST( pEnum, "TOOLBOXITEM_BREAK", ToolBoxItemType::BREAK );
// Variable einfuegen
nId = aNmTb.Put( "Type", VARNAME );

View File

@@ -211,7 +211,7 @@ void SfxImageManager_Impl::SetSymbolsSize_Impl( sal_Int16 nNewSymbolsSize )
for ( sal_uInt16 nPos=0; nPos<nCount; nPos++ )
{
sal_uInt16 nId = pBox->GetItemId( nPos );
if ( pBox->GetItemType(nPos) == TOOLBOXITEM_BUTTON )
if ( pBox->GetItemType(nPos) == ToolBoxItemType::BUTTON )
{
pBox->SetItemImage( nId, GetImage( nId, bLarge ) );
SfxStateCache *pCache = SfxViewFrame::Current()->GetBindings().GetStateCache( nId );

View File

@@ -1738,7 +1738,7 @@ bool ToolBox::ImplCalcItem()
it->mbVisibleText = false; // indicates if text will definitely be drawn, influences dropdown pos
if ( it->meType == TOOLBOXITEM_BUTTON )
if ( it->meType == ToolBoxItemType::BUTTON )
{
// check if image and/or text exists
if ( !(it->maImage) )
@@ -1838,18 +1838,18 @@ bool ToolBox::ImplCalcItem()
it->maContentSize.Height() = tmp;
}
}
else if ( it->meType == TOOLBOXITEM_SPACE )
else if ( it->meType == ToolBoxItemType::SPACE )
{
it->maItemSize = Size( nDefWidth, nDefHeight );
it->maContentSize = it->maItemSize;
}
if ( it->meType == TOOLBOXITEM_BUTTON || it->meType == TOOLBOXITEM_SPACE )
if ( it->meType == ToolBoxItemType::BUTTON || it->meType == ToolBoxItemType::SPACE )
{
// add borders
ImplAddButtonBorder( it->maItemSize.Width(), it->maItemSize.Height(), mpData->mbNativeButtons );
if( it->meType == TOOLBOXITEM_BUTTON )
if( it->meType == ToolBoxItemType::BUTTON )
{
long nMinW = std::max(nMinWidth, it->maMinimalItemSize.Width());
long nMinH = std::max(nMinHeight, it->maMinimalItemSize.Height());
@@ -1962,7 +1962,7 @@ sal_uInt16 ToolBox::ImplCalcBreaks( long nWidth, long* pMaxLineWidth, bool bCalc
bBreak = false;
nCurWidth = 0;
if ( it->meType == TOOLBOXITEM_BUTTON || it->meType == TOOLBOXITEM_SPACE )
if ( it->meType == ToolBoxItemType::BUTTON || it->meType == ToolBoxItemType::SPACE )
{
if ( bCalcHorz )
nCurWidth = it->maItemSize.Width();
@@ -1992,14 +1992,14 @@ sal_uInt16 ToolBox::ImplCalcBreaks( long nWidth, long* pMaxLineWidth, bool bCalc
( ( it != lastVisible ) && (nLineWidth+nCurWidth+nMenuWidth > nWidthTotal) && mbScroll ) )
bBreak = true;
}
else if ( it->meType == TOOLBOXITEM_SEPARATOR )
else if ( it->meType == ToolBoxItemType::SEPARATOR )
{
nCurWidth = it->mnSepSize;
if ( !ImplIsFloatingMode() && ( it != lastVisible ) && (nLineWidth+nCurWidth+nMenuWidth > nWidthTotal) )
bBreak = true;
}
// treat breaks as separators, except when using old style toolbars (ie. no menu button)
else if ( (it->meType == TOOLBOXITEM_BREAK) && !IsMenuEnabled() )
else if ( (it->meType == ToolBoxItemType::BREAK) && !IsMenuEnabled() )
bBreak = true;
if ( bBreak )
@@ -2007,7 +2007,7 @@ sal_uInt16 ToolBox::ImplCalcBreaks( long nWidth, long* pMaxLineWidth, bool bCalc
nLines++;
// Add break before the entire group or take group apart?
if ( (it->meType == TOOLBOXITEM_BREAK) ||
if ( (it->meType == ToolBoxItemType::BREAK) ||
(nLineStart == nGroupStart) )
{
if ( nLineWidth > nMaxLineWidth )
@@ -2036,7 +2036,7 @@ sal_uInt16 ToolBox::ImplCalcBreaks( long nWidth, long* pMaxLineWidth, bool bCalc
{
if( ImplIsFloatingMode() || !IsMenuEnabled() ) // no group breaking when being docked single-line
{
if ( (it->meType != TOOLBOXITEM_BUTTON) || bWindow )
if ( (it->meType != ToolBoxItemType::BUTTON) || bWindow )
{
// found separator or break
nLastGroupLineWidth = nLineWidth;
@@ -2141,7 +2141,7 @@ static void lcl_hideDoubleSeparators( std::vector< ImplToolItem >& rItems )
std::vector< ImplToolItem >::iterator it;
for ( it = rItems.begin(); it != rItems.end(); ++it )
{
if ( it->meType == TOOLBOXITEM_SEPARATOR )
if ( it->meType == ToolBoxItemType::SEPARATOR )
{
it->mbVisible = false;
if ( !bLastSep )
@@ -2150,7 +2150,7 @@ static void lcl_hideDoubleSeparators( std::vector< ImplToolItem >& rItems )
std::vector< ImplToolItem >::iterator temp_it;
for ( temp_it = it+1; temp_it != rItems.end(); ++temp_it )
{
if ( ((temp_it->meType == TOOLBOXITEM_BUTTON) &&
if ( ((temp_it->meType == ToolBoxItemType::BUTTON) &&
temp_it->mbVisible) )
{
it->mbVisible = true;
@@ -2985,7 +2985,7 @@ void ToolBox::ImplDrawItem( sal_uInt16 nPos, sal_uInt16 nHighlight, bool bPaint,
// draw separators in flat style only
if ( !bLayout &&
(mnOutStyle & TOOLBOX_STYLE_FLAT) &&
(pItem->meType == TOOLBOXITEM_SEPARATOR) &&
(pItem->meType == ToolBoxItemType::SEPARATOR) &&
nPos > 0
)
{
@@ -2993,7 +2993,7 @@ void ToolBox::ImplDrawItem( sal_uInt16 nPos, sal_uInt16 nHighlight, bool bPaint,
}
// do nothing if item is no button or will be displayed as window
if ( (pItem->meType != TOOLBOXITEM_BUTTON) ||
if ( (pItem->meType != ToolBoxItemType::BUTTON) ||
(pItem->mbShowWindow && !mbCustomizeMode) )
return;
@@ -3567,7 +3567,7 @@ void ToolBox::MouseMove( const MouseEvent& rMEvt )
if ( it->maRect.IsInside( aMousePos ) )
{
// select it if it is a button
if ( it->meType == TOOLBOXITEM_BUTTON )
if ( it->meType == ToolBoxItemType::BUTTON )
{
// if button is disabled, do not
// change it
@@ -3676,7 +3676,7 @@ void ToolBox::MouseMove( const MouseEvent& rMEvt )
{
if ( it->maRect.IsInside( aMousePos ) )
{
if ( (it->meType == TOOLBOXITEM_BUTTON) && it->mbEnabled )
if ( (it->meType == ToolBoxItemType::BUTTON) && it->mbEnabled )
{
if ( !mnOutStyle || (mnOutStyle & TOOLBOX_STYLE_FLAT) )
{
@@ -3780,7 +3780,7 @@ void ToolBox::MouseButtonDown( const MouseEvent& rMEvt )
{
// do nothing if it is a separator or
// if the item has been disabled
if ( (it->meType == TOOLBOXITEM_BUTTON) &&
if ( (it->meType == ToolBoxItemType::BUTTON) &&
(!it->mbShowWindow || mbCustomizeMode) )
nNewPos = i;
@@ -4373,7 +4373,7 @@ void ToolBox::Command( const CommandEvent& rCEvt )
{
// do nothing if it is a separator or
// the item has been disabled
if ( (it->meType == TOOLBOXITEM_BUTTON) &&
if ( (it->meType == ToolBoxItemType::BUTTON) &&
!it->mbShowWindow )
mbCommandDrag = true;
break;
@@ -4762,7 +4762,7 @@ sal_uInt16 ToolBox::ImplCountLineBreaks( const ToolBox *pThis )
std::vector< ImplToolItem >::const_iterator it = ((ToolBox*)pThis)->mpData->m_aItems.begin();
while ( it != ((ToolBox*)pThis)->mpData->m_aItems.end() )
{
if( it->meType == TOOLBOXITEM_BREAK )
if( it->meType == ToolBoxItemType::BREAK )
++nLines;
++it;
}
@@ -4832,7 +4832,7 @@ Size ToolBox::CalcMinimumWindowSizePixel() const
while( it != mpData->m_aItems.end() )
{
pToolBox->CopyItem( *this, it->mnId );
if( (it->meType != TOOLBOXITEM_BUTTON) ||
if( (it->meType != ToolBoxItemType::BUTTON) ||
!it->mbVisible || ImplIsFixedControl( &(*it) ) )
++it;
else
@@ -5246,7 +5246,7 @@ ImplToolItem* ToolBox::ImplGetFirstValidItem( sal_uInt16 nLine )
if( !nLine )
{
// find first useful item
while( it != mpData->m_aItems.end() && ((it->meType != TOOLBOXITEM_BUTTON) ||
while( it != mpData->m_aItems.end() && ((it->meType != ToolBoxItemType::BUTTON) ||
/*!it->mbEnabled ||*/ !it->mbVisible || ImplIsFixedControl( &(*it) )) )
{
++it;
@@ -5360,7 +5360,7 @@ void ToolBox::ImplChangeHighlight( ImplToolItem* pItem, bool bNoGrabFocus )
// check for keyboard accessible items
static bool ImplIsValidItem( const ImplToolItem* pItem, bool bNotClipped )
{
bool bValid = (pItem && pItem->meType == TOOLBOXITEM_BUTTON && pItem->mbVisible && !ImplIsFixedControl( pItem ));
bool bValid = (pItem && pItem->meType == ToolBoxItemType::BUTTON && pItem->mbVisible && !ImplIsFixedControl( pItem ));
if( bValid && bNotClipped && pItem->IsClipped() )
bValid = false;
return bValid;

View File

@@ -91,7 +91,7 @@ void ImplToolItem::init(sal_uInt16 nItemId, ToolBoxItemBits nItemBits,
mnId = nItemId;
mpWindow = NULL;
mpUserData = NULL;
meType = TOOLBOXITEM_BUTTON;
meType = ToolBoxItemType::BUTTON;
mnBits = nItemBits;
meState = TRISTATE_FALSE;
mbEnabled = true;
@@ -210,7 +210,7 @@ Size ImplToolItem::GetSize( bool bHorz, bool bCheckMaxWidth, long maxWidth, cons
Size aSize( rDefaultSize ); // the size of 'standard' toolbox items
// non-standard items are eg windows or buttons with text
if ( (meType == TOOLBOXITEM_BUTTON) || (meType == TOOLBOXITEM_SPACE) )
if ( (meType == ToolBoxItemType::BUTTON) || (meType == ToolBoxItemType::SPACE) )
{
aSize = maItemSize;
@@ -235,7 +235,7 @@ Size ImplToolItem::GetSize( bool bHorz, bool bCheckMaxWidth, long maxWidth, cons
}
}
}
else if ( meType == TOOLBOXITEM_SEPARATOR )
else if ( meType == ToolBoxItemType::SEPARATOR )
{
if ( bHorz )
{
@@ -248,7 +248,7 @@ Size ImplToolItem::GetSize( bool bHorz, bool bCheckMaxWidth, long maxWidth, cons
aSize.Height() = mnSepSize;
}
}
else if ( meType == TOOLBOXITEM_BREAK )
else if ( meType == ToolBoxItemType::BREAK )
{
aSize.Width() = 0;
aSize.Height() = 0;
@@ -259,7 +259,7 @@ Size ImplToolItem::GetSize( bool bHorz, bool bCheckMaxWidth, long maxWidth, cons
void ImplToolItem::DetermineButtonDrawStyle( ButtonType eButtonType, bool& rbImage, bool& rbText ) const
{
if ( meType != TOOLBOXITEM_BUTTON )
if ( meType != ToolBoxItemType::BUTTON )
{
// no button -> draw nothing
rbImage = rbText = false;
@@ -333,12 +333,12 @@ Rectangle ImplToolItem::GetDropDownRect( bool bHorz ) const
bool ImplToolItem::IsClipped() const
{
return ( meType == TOOLBOXITEM_BUTTON && mbVisible && maRect.IsEmpty() );
return ( meType == ToolBoxItemType::BUTTON && mbVisible && maRect.IsEmpty() );
}
bool ImplToolItem::IsItemHidden() const
{
return ( meType == TOOLBOXITEM_BUTTON && !mbVisible );
return ( meType == ToolBoxItemType::BUTTON && !mbVisible );
}
const OUString ToolBox::ImplConvertMenuString( const OUString& rStr )
@@ -531,7 +531,7 @@ void ToolBox::InsertItem( const ResId& rResId, sal_uInt16 nPos )
// if this is a ButtonItem, check ID
bool bNewCalc;
if ( aItem.meType != TOOLBOXITEM_BUTTON )
if ( aItem.meType != ToolBoxItemType::BUTTON )
{
bNewCalc = false;
aItem.mnId = 0;
@@ -646,7 +646,7 @@ void ToolBox::InsertWindow( sal_uInt16 nItemId, vcl::Window* pWindow,
// create item and add to list
ImplToolItem aItem;
aItem.mnId = nItemId;
aItem.meType = TOOLBOXITEM_BUTTON;
aItem.meType = ToolBoxItemType::BUTTON;
aItem.mnBits = nBits;
aItem.mpWindow = pWindow;
mpData->m_aItems.insert( (nPos < mpData->m_aItems.size()) ? mpData->m_aItems.begin()+nPos : mpData->m_aItems.end(), aItem );
@@ -666,7 +666,7 @@ void ToolBox::InsertSpace( sal_uInt16 nPos )
{
// create item and add to list
ImplToolItem aItem;
aItem.meType = TOOLBOXITEM_SPACE;
aItem.meType = ToolBoxItemType::SPACE;
aItem.mbEnabled = false;
mpData->m_aItems.insert( (nPos < mpData->m_aItems.size()) ? mpData->m_aItems.begin()+nPos : mpData->m_aItems.end(), aItem );
mpData->ImplClearLayoutData();
@@ -682,7 +682,7 @@ void ToolBox::InsertSeparator( sal_uInt16 nPos, sal_uInt16 nPixSize )
{
// create item and add to list
ImplToolItem aItem;
aItem.meType = TOOLBOXITEM_SEPARATOR;
aItem.meType = ToolBoxItemType::SEPARATOR;
aItem.mbEnabled = false;
if ( nPixSize )
aItem.mnSepSize = nPixSize;
@@ -700,7 +700,7 @@ void ToolBox::InsertBreak( sal_uInt16 nPos )
{
// create item and add to list
ImplToolItem aItem;
aItem.meType = TOOLBOXITEM_BREAK;
aItem.meType = ToolBoxItemType::BREAK;
aItem.mbEnabled = false;
mpData->m_aItems.insert( (nPos < mpData->m_aItems.size()) ? mpData->m_aItems.begin()+nPos : mpData->m_aItems.end(), aItem );
mpData->ImplClearLayoutData();
@@ -717,7 +717,7 @@ void ToolBox::RemoveItem( sal_uInt16 nPos )
if( nPos < mpData->m_aItems.size() )
{
bool bMustCalc;
if ( mpData->m_aItems[nPos].meType == TOOLBOXITEM_BUTTON )
if ( mpData->m_aItems[nPos].meType == ToolBoxItemType::BUTTON )
bMustCalc = true;
else
bMustCalc = false;
@@ -884,7 +884,7 @@ sal_uInt16 ToolBox::GetItemCount() const
ToolBoxItemType ToolBox::GetItemType( sal_uInt16 nPos ) const
{
return (nPos < mpData->m_aItems.size()) ? mpData->m_aItems[nPos].meType : TOOLBOXITEM_DONTKNOW;
return (nPos < mpData->m_aItems.size()) ? mpData->m_aItems[nPos].meType : ToolBoxItemType::DONTKNOW;
}
sal_uInt16 ToolBox::GetItemPos( sal_uInt16 nItemId ) const
@@ -933,7 +933,7 @@ sal_uInt16 ToolBox::GetItemId( const Point& rPos ) const
// is it this item?
if ( it->maRect.IsInside( rPos ) )
{
if ( it->meType == TOOLBOXITEM_BUTTON )
if ( it->meType == ToolBoxItemType::BUTTON )
return it->mnId;
else
return 0;