convert ToolBoxButtonSize to scoped enum

Change-Id: I365b0e34361eb339b04e5f4792f54eff5bf582a5
This commit is contained in:
Noel Grandin 2016-09-02 13:54:34 +02:00
parent 256654c26f
commit a1cd62bcd5
16 changed files with 80 additions and 74 deletions

View File

@ -767,12 +767,12 @@ bool OfaViewTabPage::FillItemSet( SfxItemSet* )
if( nSidebarSizeLB_InitialSelection != nSidebarSizeLB_NewSelection )
{
// from now on it's modified, even if via auto setting the same size was set as now selected in the LB
sal_Int16 eSet = TOOLBOX_BUTTONSIZE_DONTCARE;
ToolBoxButtonSize eSet = ToolBoxButtonSize::DontCare;
switch( nSidebarSizeLB_NewSelection )
{
case 0: eSet = TOOLBOX_BUTTONSIZE_DONTCARE; break;
case 1: eSet = TOOLBOX_BUTTONSIZE_SMALL; break;
case 2: eSet = TOOLBOX_BUTTONSIZE_LARGE; break;
case 0: eSet = ToolBoxButtonSize::DontCare; break;
case 1: eSet = ToolBoxButtonSize::Small; break;
case 2: eSet = ToolBoxButtonSize::Large; break;
default:
OSL_FAIL( "OfaViewTabPage::FillItemSet(): This state of m_pSidebarIconSizeLB should not be possible!" );
}
@ -783,12 +783,12 @@ bool OfaViewTabPage::FillItemSet( SfxItemSet* )
if( nNotebookbarSizeLB_InitialSelection != nNotebookbarSizeLB_NewSelection )
{
// from now on it's modified, even if via auto setting the same size was set as now selected in the LB
sal_Int16 eSet = TOOLBOX_BUTTONSIZE_DONTCARE;
ToolBoxButtonSize eSet = ToolBoxButtonSize::DontCare;
switch( nNotebookbarSizeLB_NewSelection )
{
case 0: eSet = TOOLBOX_BUTTONSIZE_DONTCARE; break;
case 1: eSet = TOOLBOX_BUTTONSIZE_SMALL; break;
case 2: eSet = TOOLBOX_BUTTONSIZE_LARGE; break;
case 0: eSet = ToolBoxButtonSize::DontCare; break;
case 1: eSet = ToolBoxButtonSize::Small; break;
case 2: eSet = ToolBoxButtonSize::Large; break;
default:
OSL_FAIL( "OfaViewTabPage::FillItemSet(): This state of m_pNotebookbarIconSizeLB should not be possible!" );
}
@ -943,12 +943,20 @@ void OfaViewTabPage::Reset( const SfxItemSet* )
nSizeLB_InitialSelection = ( aMiscOptions.AreCurrentSymbolsLarge() )? 2 : 1;
m_pIconSizeLB->SelectEntryPos( nSizeLB_InitialSelection );
m_pIconSizeLB->SaveValue();
if( aMiscOptions.GetSidebarIconSize() != TOOLBOX_BUTTONSIZE_DONTCARE )
nSidebarSizeLB_InitialSelection = aMiscOptions.GetSidebarIconSize();
if( aMiscOptions.GetSidebarIconSize() == ToolBoxButtonSize::DontCare )
; // do nothing
else if( aMiscOptions.GetSidebarIconSize() == ToolBoxButtonSize::Small )
nSidebarSizeLB_InitialSelection = 1;
else if( aMiscOptions.GetSidebarIconSize() == ToolBoxButtonSize::Large )
nSidebarSizeLB_InitialSelection = 2;
m_pSidebarIconSizeLB->SelectEntryPos( nSidebarSizeLB_InitialSelection );
m_pSidebarIconSizeLB->SaveValue();
if( aMiscOptions.GetNotebookbarIconSize() != TOOLBOX_BUTTONSIZE_DONTCARE )
nNotebookbarSizeLB_InitialSelection = aMiscOptions.GetNotebookbarIconSize();
if( aMiscOptions.GetNotebookbarIconSize() == ToolBoxButtonSize::DontCare )
; // do nothing
else if( aMiscOptions.GetNotebookbarIconSize() == ToolBoxButtonSize::Small )
nNotebookbarSizeLB_InitialSelection = 1;
else if( aMiscOptions.GetNotebookbarIconSize() == ToolBoxButtonSize::Large )
nNotebookbarSizeLB_InitialSelection = 2;
m_pNotebookbarIconSizeLB->SelectEntryPos( nNotebookbarSizeLB_InitialSelection );
m_pNotebookbarIconSizeLB->SaveValue();

View File

@ -188,7 +188,7 @@ void AddonsToolBarManager::RefreshImages()
);
}
}
m_pToolBar->SetToolboxButtonSize( bBigImages ? TOOLBOX_BUTTONSIZE_LARGE : TOOLBOX_BUTTONSIZE_SMALL );
m_pToolBar->SetToolboxButtonSize( bBigImages ? ToolBoxButtonSize::Large : ToolBoxButtonSize::Small );
::Size aSize = m_pToolBar->CalcWindowSizePixel();
m_pToolBar->SetOutputSizePixel( aSize );
}

View File

@ -424,7 +424,7 @@ void SaveToolbarController::updateImage()
if ( !getToolboxId( nId, &pToolBox ) )
return;
bool bLargeIcons = pToolBox->GetToolboxButtonSize() == TOOLBOX_BUTTONSIZE_LARGE;
bool bLargeIcons = pToolBox->GetToolboxButtonSize() == ToolBoxButtonSize::Large;
Image aImage;
if ( m_bReadOnly )

View File

@ -291,7 +291,7 @@ void SubToolBarController::updateImage()
sal_uInt16 nId = 0;
if ( getToolboxId( nId, &pToolBox ) )
{
Image aImage = vcl::CommandInfoProvider::Instance().GetImageForCommand( m_aLastCommand, pToolBox->GetToolboxButtonSize() == TOOLBOX_BUTTONSIZE_LARGE, getFrameInterface() );
Image aImage = vcl::CommandInfoProvider::Instance().GetImageForCommand( m_aLastCommand, pToolBox->GetToolboxButtonSize() == ToolBoxButtonSize::Large, getFrameInterface() );
if ( !!aImage )
pToolBox->SetItemImage( nId, aImage );
}

View File

@ -163,7 +163,7 @@ ToolBarManager::ToolBarManager( const Reference< XComponentContext >& rxContext,
m_pToolBar->SetDoubleClickHdl( LINK( this, ToolBarManager, DoubleClick ) );
m_pToolBar->SetStateChangedHdl( LINK( this, ToolBarManager, StateChanged ) );
m_pToolBar->SetDataChangedHdl( LINK( this, ToolBarManager, DataChanged ) );
m_pToolBar->SetToolboxButtonSize( m_bSmallSymbols ? TOOLBOX_BUTTONSIZE_SMALL : TOOLBOX_BUTTONSIZE_LARGE );
m_pToolBar->SetToolboxButtonSize( m_bSmallSymbols ? ToolBoxButtonSize::Small : ToolBoxButtonSize::Large );
// enables a menu for clipped items and customization
SvtCommandOptions aCmdOptions;
@ -276,7 +276,7 @@ void ToolBarManager::RefreshImages()
SolarMutexGuard g;
bool bBigImages( SvtMiscOptions().AreCurrentSymbolsLarge() );
m_pToolBar->SetToolboxButtonSize( bBigImages ? TOOLBOX_BUTTONSIZE_LARGE : TOOLBOX_BUTTONSIZE_SMALL );
m_pToolBar->SetToolboxButtonSize( bBigImages ? ToolBoxButtonSize::Large : ToolBoxButtonSize::Small );
for ( auto const& it : m_aControllerMap )
{

View File

@ -43,7 +43,7 @@ public:
virtual ~SidebarToolBox();
virtual void dispose() override;
virtual sal_uInt16 GetIconSize() const;
virtual ToolBoxButtonSize GetIconSize() const;
using ToolBox::InsertItem;
virtual void InsertItem(const OUString& rCommand,

View File

@ -35,6 +35,7 @@
*//*-*************************************************************************************************************/
class SvtMiscOptions_Impl;
enum class ToolBoxButtonSize;
/*-************************************************************************************************************
@short collect information about misc group
@ -62,10 +63,10 @@ class SVT_DLLPUBLIC SvtMiscOptions: public utl::detail::Options
sal_Int16 GetSymbolsSize() const;
void SetSymbolsSize( sal_Int16 eSet );
sal_Int16 GetSidebarIconSize() const;
void SetSidebarIconSize( sal_Int16 eSet );
sal_Int16 GetNotebookbarIconSize() const;
void SetNotebookbarIconSize( sal_Int16 eSet );
ToolBoxButtonSize GetSidebarIconSize() const;
void SetSidebarIconSize( ToolBoxButtonSize eSet );
ToolBoxButtonSize GetNotebookbarIconSize() const;
void SetNotebookbarIconSize( ToolBoxButtonSize eSet );
sal_Int16 GetCurrentSymbolsSize() const;
bool AreCurrentSymbolsLarge() const;

View File

@ -60,7 +60,7 @@ namespace o3tl
// small or large force an exact toolbox size for proper alignemnt
// dontcare will let the toolbox decide about its size
enum ToolBoxButtonSize { TOOLBOX_BUTTONSIZE_DONTCARE, TOOLBOX_BUTTONSIZE_SMALL, TOOLBOX_BUTTONSIZE_LARGE };
enum class ToolBoxButtonSize { DontCare, Small, Large };
// ToolBoxLayoutMode::Normal - traditional layout, items are centered in the toolbar
// ToolBoxLayoutMode::LockVert - special mode (currently used for calc input/formula

View File

@ -252,7 +252,7 @@ void DisplayModeController::setToolboxItemImage( sal_uInt16 nImage )
if (getToolboxId( nId, &pToolBox )) {
SdResId resId( nImage );
BitmapEx aBmp( resId );
int targetSize = (pToolBox->GetToolboxButtonSize() == TOOLBOX_BUTTONSIZE_LARGE) ? 32 : 16;
int targetSize = (pToolBox->GetToolboxButtonSize() == ToolBoxButtonSize::Large) ? 32 : 16;
double scale = 1.0f;
Size size = aBmp.GetSizePixel();
if (size.Width() > targetSize)

View File

@ -41,7 +41,7 @@ BigToolBox::BigToolBox(vcl::Window* pParent)
SvtMiscOptions aMiscOptions;
aMiscOptions.RemoveListenerLink(LINK(this, SidebarToolBox, ChangedIconSizeHandler));
SetToolboxButtonSize(TOOLBOX_BUTTONSIZE_LARGE);
SetToolboxButtonSize(ToolBoxButtonSize::Large);
SetButtonType(ButtonType::SYMBOLTEXT);
SetToolBoxTextPosition(ToolBoxTextPosition::Bottom);
}

View File

@ -30,18 +30,12 @@ public:
NotebookbarToolBox(vcl::Window* pParentWindow)
: sfx2::sidebar::SidebarToolBox(pParentWindow)
{
ToolBoxButtonSize eSize = TOOLBOX_BUTTONSIZE_SMALL;
SvtMiscOptions aMiscOptions;
sal_uInt16 nSize = GetIconSize();
if (nSize <= TOOLBOX_BUTTONSIZE_LARGE)
eSize = static_cast<ToolBoxButtonSize>(nSize);
ToolBoxButtonSize eSize = ToolBoxButtonSize::Small;
eSize = GetIconSize();
SetToolboxButtonSize(eSize);
}
virtual sal_uInt16 GetIconSize() const override
virtual ToolBoxButtonSize GetIconSize() const override
{
SvtMiscOptions aMiscOptions;
return aMiscOptions.GetNotebookbarIconSize();

View File

@ -64,14 +64,12 @@ SidebarToolBox::SidebarToolBox (vcl::Window* pParentWindow)
SetBackground(Wallpaper());
SetPaintTransparent(true);
ToolBoxButtonSize eSize = TOOLBOX_BUTTONSIZE_SMALL;
ToolBoxButtonSize eSize = ToolBoxButtonSize::Small;
SvtMiscOptions aMiscOptions;
aMiscOptions.AddListenerLink(LINK(this, SidebarToolBox, ChangedIconSizeHandler));
sal_uInt16 nSize = GetIconSize();
if (nSize <= TOOLBOX_BUTTONSIZE_LARGE)
eSize = static_cast<ToolBoxButtonSize>(nSize);
eSize = GetIconSize();
SetToolboxButtonSize(eSize);
@ -117,7 +115,7 @@ void SidebarToolBox::dispose()
ToolBox::dispose();
}
sal_uInt16 SidebarToolBox::GetIconSize() const
ToolBoxButtonSize SidebarToolBox::GetIconSize() const
{
SvtMiscOptions aMiscOptions;
return aMiscOptions.GetSidebarIconSize();
@ -268,13 +266,9 @@ IMPL_LINK_NOARG_TYPED(SidebarToolBox, ChangedIconSizeHandler, LinkParamNone*, vo
{
SolarMutexGuard g;
ToolBoxButtonSize eSize = TOOLBOX_BUTTONSIZE_SMALL;
ToolBoxButtonSize eSize = GetIconSize();
sal_uInt16 nSize = GetIconSize();
if(nSize <= TOOLBOX_BUTTONSIZE_LARGE)
eSize = static_cast<ToolBoxButtonSize>(nSize);
bool bBigImages(eSize == TOOLBOX_BUTTONSIZE_LARGE);
bool bBigImages(eSize == ToolBoxButtonSize::Large);
SetToolboxButtonSize(eSize);
for (auto const& it : maControllers)

View File

@ -597,7 +597,7 @@ Reference< css::awt::XWindow > SAL_CALL SfxToolBoxControl::createItemWindow( con
bool SfxToolBoxControl::hasBigImages() const
{
return (GetToolBox().GetToolboxButtonSize() == TOOLBOX_BUTTONSIZE_LARGE);
return (GetToolBox().GetToolboxButtonSize() == ToolBoxButtonSize::Large);
}
void SfxToolBoxControl::SetPopupWindow( SfxPopupWindow* pWindow )

View File

@ -31,6 +31,7 @@
#include <svtools/imgdef.hxx>
#include <vcl/svapp.hxx>
#include <vcl/settings.hxx>
#include <vcl/toolbox.hxx>
#include <list>
@ -79,9 +80,9 @@ private:
bool m_bIsPluginsEnabledRO;
sal_Int16 m_nSymbolsSize;
bool m_bIsSymbolsSizeRO;
sal_Int16 m_nSidebarIconSize;
ToolBoxButtonSize m_nSidebarIconSize;
bool m_bIsSidebarIconSizeRO;
sal_Int16 m_nNotebookbarIconSize;
ToolBoxButtonSize m_nNotebookbarIconSize;
bool m_bIsNotebookbarIconSizeRO;
bool m_bIsSymbolsStyleRO;
sal_Int16 m_nToolboxStyle;
@ -154,17 +155,17 @@ public:
inline sal_Int16 GetSymbolsSize()
{ return m_nSymbolsSize; }
inline sal_Int16 GetSidebarIconSize()
inline ToolBoxButtonSize GetSidebarIconSize()
{ return m_nSidebarIconSize; }
inline sal_Int16 GetNotebookbarIconSize()
inline ToolBoxButtonSize GetNotebookbarIconSize()
{ return m_nNotebookbarIconSize; }
void SetSymbolsSize( sal_Int16 nSet );
void SetSidebarIconSize( sal_Int16 nSet );
void SetSidebarIconSize( ToolBoxButtonSize nSet );
void SetNotebookbarIconSize( sal_Int16 nSet );
void SetNotebookbarIconSize( ToolBoxButtonSize nSet );
static OUString GetIconTheme();
@ -243,9 +244,9 @@ SvtMiscOptions_Impl::SvtMiscOptions_Impl()
, m_bIsPluginsEnabledRO( false )
, m_nSymbolsSize( 0 )
, m_bIsSymbolsSizeRO( false )
, m_nSidebarIconSize( 0 )
, m_nSidebarIconSize( ToolBoxButtonSize::DontCare )
, m_bIsSidebarIconSizeRO( false )
, m_nNotebookbarIconSize( 0 )
, m_nNotebookbarIconSize( ToolBoxButtonSize::DontCare )
, m_bIsNotebookbarIconSizeRO( false )
, m_bIsSymbolsStyleRO( false )
, m_nToolboxStyle( 1 )
@ -299,20 +300,24 @@ SvtMiscOptions_Impl::SvtMiscOptions_Impl()
case PROPERTYHANDLE_SIDEBARICONSIZE :
{
if( !(seqValues[nProperty] >>= m_nSidebarIconSize) )
sal_uInt16 nTmp;
if( !(seqValues[nProperty] >>= nTmp) )
{
OSL_FAIL("Wrong type of \"Misc\\SidebarIconSize\"!" );
}
} else
m_nSidebarIconSize = (ToolBoxButtonSize)nTmp;
m_bIsSidebarIconSizeRO = seqRO[nProperty];
break;
}
case PROPERTYHANDLE_NOTEBOOKBARICONSIZE :
{
if( !(seqValues[nProperty] >>= m_nNotebookbarIconSize) )
sal_uInt16 nTmp;
if( !(seqValues[nProperty] >>= nTmp) )
{
OSL_FAIL("Wrong type of \"Misc\\NotebookbarIconSize\"!" );
}
} else
m_nNotebookbarIconSize = (ToolBoxButtonSize)nTmp;
m_bIsNotebookbarIconSizeRO = seqRO[nProperty];
break;
}
@ -447,17 +452,21 @@ void SvtMiscOptions_Impl::Load( const Sequence< OUString >& rPropertyNames )
}
break;
case PROPERTYHANDLE_SIDEBARICONSIZE : {
if( !(seqValues[nProperty] >>= m_nSidebarIconSize) )
sal_uInt16 nTmp;
if( !(seqValues[nProperty] >>= nTmp) )
{
OSL_FAIL("Wrong type of \"Misc\\SidebarIconSize\"!" );
}
} else
m_nSidebarIconSize = (ToolBoxButtonSize)nTmp;
}
break;
case PROPERTYHANDLE_NOTEBOOKBARICONSIZE : {
if( !(seqValues[nProperty] >>= m_nNotebookbarIconSize) )
sal_uInt16 nTmp;
if( !(seqValues[nProperty] >>= nTmp ) )
{
OSL_FAIL("Wrong type of \"Misc\\NotebookbarIconSize\"!" );
}
} else
m_nNotebookbarIconSize = (ToolBoxButtonSize)nTmp;
}
break;
case PROPERTYHANDLE_TOOLBOXSTYLE : {
@ -542,14 +551,14 @@ void SvtMiscOptions_Impl::SetSymbolsSize( sal_Int16 nSet )
CallListeners();
}
void SvtMiscOptions_Impl::SetSidebarIconSize( sal_Int16 nSet )
void SvtMiscOptions_Impl::SetSidebarIconSize( ToolBoxButtonSize nSet )
{
m_nSidebarIconSize = nSet;
SetModified();
CallListeners();
}
void SvtMiscOptions_Impl::SetNotebookbarIconSize( sal_Int16 nSet )
void SvtMiscOptions_Impl::SetNotebookbarIconSize( ToolBoxButtonSize nSet )
{
m_nNotebookbarIconSize = nSet;
SetModified();
@ -626,14 +635,14 @@ void SvtMiscOptions_Impl::ImplCommit()
case PROPERTYHANDLE_SIDEBARICONSIZE :
{
if ( !m_bIsSidebarIconSizeRO )
seqValues[nProperty] <<= m_nSidebarIconSize;
seqValues[nProperty] <<= (sal_uInt16)m_nSidebarIconSize;
break;
}
case PROPERTYHANDLE_NOTEBOOKBARICONSIZE :
{
if ( !m_bIsNotebookbarIconSizeRO )
seqValues[nProperty] <<= m_nNotebookbarIconSize;
seqValues[nProperty] <<= (sal_uInt16)m_nNotebookbarIconSize;
break;
}
@ -787,22 +796,22 @@ void SvtMiscOptions::SetSymbolsSize( sal_Int16 nSet )
m_pImpl->SetSymbolsSize( nSet );
}
sal_Int16 SvtMiscOptions::GetSidebarIconSize() const
ToolBoxButtonSize SvtMiscOptions::GetSidebarIconSize() const
{
return m_pImpl->GetSidebarIconSize();
}
sal_Int16 SvtMiscOptions::GetNotebookbarIconSize() const
ToolBoxButtonSize SvtMiscOptions::GetNotebookbarIconSize() const
{
return m_pImpl->GetNotebookbarIconSize();
}
void SvtMiscOptions::SetSidebarIconSize( sal_Int16 nSet )
void SvtMiscOptions::SetSidebarIconSize( ToolBoxButtonSize nSet )
{
m_pImpl->SetSidebarIconSize( nSet );
}
void SvtMiscOptions::SetNotebookbarIconSize( sal_Int16 nSet )
void SvtMiscOptions::SetNotebookbarIconSize( ToolBoxButtonSize nSet )
{
m_pImpl->SetNotebookbarIconSize( nSet );
}

View File

@ -1982,7 +1982,7 @@ bool ToolBox::ImplCalcItem()
ImplAddButtonBorder( nMaxWidth, nMaxHeight, mpData->mbNativeButtons );
}
if( !ImplIsFloatingMode() && GetToolboxButtonSize() != TOOLBOX_BUTTONSIZE_DONTCARE
if( !ImplIsFloatingMode() && GetToolboxButtonSize() != ToolBoxButtonSize::DontCare
&& ( meTextPosition == ToolBoxTextPosition::Right ) )
{
// make sure all vertical toolbars have the same width and horizontal have the same height

View File

@ -48,7 +48,7 @@ using namespace vcl;
ImplToolBoxPrivateData::ImplToolBoxPrivateData() :
m_pLayoutData( nullptr )
{
meButtonSize = TOOLBOX_BUTTONSIZE_DONTCARE;
meButtonSize = ToolBoxButtonSize::DontCare;
mpMenu = VclPtr<PopupMenu>::Create();
mnEventId = nullptr;
@ -519,7 +519,7 @@ void ToolBox::InsertItem(const OUString& rCommand, const css::uno::Reference<css
OUString aLabel(vcl::CommandInfoProvider::Instance().GetLabelForCommand(rCommand, rFrame));
OUString aTooltip(vcl::CommandInfoProvider::Instance().GetTooltipForCommand(rCommand, rFrame));
Image aImage(vcl::CommandInfoProvider::Instance().GetImageForCommand(
rCommand, (GetToolboxButtonSize() == TOOLBOX_BUTTONSIZE_LARGE), rFrame));
rCommand, (GetToolboxButtonSize() == ToolBoxButtonSize::Large), rFrame));
sal_uInt16 nItemId = GetItemCount() + 1;
InsertItem(nItemId, aImage, aLabel, nBits, nPos);
@ -722,7 +722,7 @@ ToolBoxButtonSize ToolBox::GetToolboxButtonSize() const
Size ToolBox::GetDefaultImageSize() const
{
return GetDefaultImageSize( GetToolboxButtonSize() == TOOLBOX_BUTTONSIZE_LARGE );
return GetDefaultImageSize( GetToolboxButtonSize() == ToolBoxButtonSize::Large );
}
void ToolBox::SetAlign( WindowAlign eNewAlign )