[Libreoffice-commits] core.git: framework/source include/vcl vcl/inc vcl/source

Noel Grandin noel at peralex.com
Tue May 10 09:57:40 UTC 2016


 framework/source/layoutmanager/toolbarlayoutmanager.cxx |    6 ++---
 framework/source/uielement/addonstoolbarmanager.cxx     |    2 -
 framework/source/uielement/toolbarmanager.cxx           |    4 +--
 include/vcl/toolbox.hxx                                 |   17 +++++++++++-----
 vcl/inc/toolbox.h                                       |    4 +--
 vcl/source/window/toolbox.cxx                           |    2 -
 vcl/source/window/toolbox2.cxx                          |   12 +++++------
 7 files changed, 27 insertions(+), 20 deletions(-)

New commits:
commit 57f84e5b1f27a442981602bc428270a5ecb95959
Author: Noel Grandin <noel at peralex.com>
Date:   Tue May 10 10:14:16 2016 +0200

    Convert TOOLBOX_MENUTYPE_ to scoped enum
    
    Change-Id: I8eb25fc274b45b8add04dfc03e4b52f130ad04de
    Reviewed-on: https://gerrit.libreoffice.org/24827
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noelgrandin at gmail.com>

diff --git a/framework/source/layoutmanager/toolbarlayoutmanager.cxx b/framework/source/layoutmanager/toolbarlayoutmanager.cxx
index e264e97..e8779f1 100644
--- a/framework/source/layoutmanager/toolbarlayoutmanager.cxx
+++ b/framework/source/layoutmanager/toolbarlayoutmanager.cxx
@@ -537,11 +537,11 @@ bool ToolbarLayoutManager::createToolbar( const OUString& rResourceURL )
             if ( pWindow && pWindow->GetType() == WINDOW_TOOLBOX )
             {
                 ToolBox* pToolbar = static_cast<ToolBox *>(pWindow);
-                sal_uInt16 nMenuType = pToolbar->GetMenuType();
+                ToolBoxMenuType nMenuType = pToolbar->GetMenuType();
                 if ( aCmdOptions.Lookup( SvtCommandOptions::CMDOPTION_DISABLED, "ConfigureDialog" ))
-                    pToolbar->SetMenuType( nMenuType & ~TOOLBOX_MENUTYPE_CUSTOMIZE );
+                    pToolbar->SetMenuType( nMenuType & ~ToolBoxMenuType::Customize );
                 else
-                    pToolbar->SetMenuType( nMenuType | TOOLBOX_MENUTYPE_CUSTOMIZE );
+                    pToolbar->SetMenuType( nMenuType | ToolBoxMenuType::Customize );
             }
             bNotify = true;
 
diff --git a/framework/source/uielement/addonstoolbarmanager.cxx b/framework/source/uielement/addonstoolbarmanager.cxx
index 0154bdd..fe3aadc 100644
--- a/framework/source/uielement/addonstoolbarmanager.cxx
+++ b/framework/source/uielement/addonstoolbarmanager.cxx
@@ -80,7 +80,7 @@ AddonsToolBarManager::AddonsToolBarManager( const Reference< XComponentContext >
                                 ToolBox* pToolBar ) :
     ToolBarManager( rxContext, rFrame, rResourceName, pToolBar )
 {
-    m_pToolBar->SetMenuType( TOOLBOX_MENUTYPE_CLIPPEDITEMS );
+    m_pToolBar->SetMenuType( ToolBoxMenuType::ClippedItems );
     m_pToolBar->SetSelectHdl( LINK( this, AddonsToolBarManager, Select) );
     m_pToolBar->SetClickHdl( LINK( this, AddonsToolBarManager, Click ) );
     m_pToolBar->SetDoubleClickHdl( LINK( this, AddonsToolBarManager, DoubleClick ) );
diff --git a/framework/source/uielement/toolbarmanager.cxx b/framework/source/uielement/toolbarmanager.cxx
index 1a6eaca..4eb6877 100644
--- a/framework/source/uielement/toolbarmanager.cxx
+++ b/framework/source/uielement/toolbarmanager.cxx
@@ -167,9 +167,9 @@ ToolBarManager::ToolBarManager( const Reference< XComponentContext >& rxContext,
 
     // enables a menu for clipped items and customization
     SvtCommandOptions aCmdOptions;
-    sal_uInt16 nMenuType = TOOLBOX_MENUTYPE_CLIPPEDITEMS;
+    ToolBoxMenuType nMenuType = ToolBoxMenuType::ClippedItems;
     if ( !aCmdOptions.Lookup( SvtCommandOptions::CMDOPTION_DISABLED, "CreateDialog"))
-         nMenuType |= TOOLBOX_MENUTYPE_CUSTOMIZE;
+         nMenuType |= ToolBoxMenuType::Customize;
 
     m_pToolBar->SetCommandHdl( LINK( this, ToolBarManager, Command ) );
     m_pToolBar->SetMenuType( nMenuType );
diff --git a/include/vcl/toolbox.hxx b/include/vcl/toolbox.hxx
index d559c59..408964f 100644
--- a/include/vcl/toolbox.hxx
+++ b/include/vcl/toolbox.hxx
@@ -25,6 +25,7 @@
 #include <vcl/dllapi.h>
 #include <vcl/dockwin.hxx>
 #include <vcl/image.hxx>
+#include <o3tl/typed_flags_set.hxx>
 #include <vector>
 
 #include <com/sun/star/frame/XFrame.hpp>
@@ -47,9 +48,15 @@ class  PopupMenu;
 #define TOOLBOX_MENUITEM_START      ((sal_uInt16)0x1000)
 
 // defines for the menubutton
-#define TOOLBOX_MENUTYPE_NONE           ((sal_uInt16)0x0000)    // no menu at all, scrolling by spin buttons
-#define TOOLBOX_MENUTYPE_CLIPPEDITEMS   ((sal_uInt16)0x0001)    // menu will contain "more" indicator
-#define TOOLBOX_MENUTYPE_CUSTOMIZE      ((sal_uInt16)0x0002)    // menu will contain "customization" and "more" indicator
+enum class ToolBoxMenuType {
+    NONE           = 0x0000,    // no menu at all, scrolling by spin buttons
+    ClippedItems   = 0x0001,    // menu will contain "more" indicator
+    Customize      = 0x0002     // menu will contain "customization" and "more" indicator
+};
+namespace o3tl
+{
+    template<> struct typed_flags<ToolBoxMenuType> : is_typed_flags<ToolBoxMenuType, 0x0003> {};
+}
 
 // small or large force an exact toolbox size for proper alignemnt
 // dontcare will let the toolbox decide about its size
@@ -477,8 +484,8 @@ public:
     //       the private toolbox items will only use item ids starting from TOOLBOX_MENUITEM_START
     // to allow for customization of the menu the coresponding handler is called
     // when the menu button was clicked and before the menu is executed
-    void                SetMenuType( sal_uInt16 aType = TOOLBOX_MENUTYPE_CUSTOMIZE );
-    sal_uInt16          GetMenuType() const;
+    void                SetMenuType( ToolBoxMenuType aType = ToolBoxMenuType::Customize );
+    ToolBoxMenuType     GetMenuType() const;
     bool                IsMenuEnabled() const;
     PopupMenu*          GetMenu() const;
     void                UpdateCustomMenu();
diff --git a/vcl/inc/toolbox.h b/vcl/inc/toolbox.h
index 5ecd438..2f412bf 100644
--- a/vcl/inc/toolbox.h
+++ b/vcl/inc/toolbox.h
@@ -133,8 +133,8 @@ struct ImplToolBoxPrivateData
     ToolBoxButtonSize   meButtonSize;
 
     // the optional custom menu
-    PopupMenu*  mpMenu;
-    sal_uInt16      maMenuType;
+    PopupMenu*      mpMenu;
+    ToolBoxMenuType maMenuType;
     ImplSVEvent *   mnEventId;
 
     // called when menu button is clicked and before the popup menu is executed
diff --git a/vcl/source/window/toolbox.cxx b/vcl/source/window/toolbox.cxx
index 09d3523..4fa7eca 100644
--- a/vcl/source/window/toolbox.cxx
+++ b/vcl/source/window/toolbox.cxx
@@ -881,7 +881,7 @@ void ToolBox::ImplSetMinMaxFloatSize( ToolBox *pThis )
     {
         pWrapper->SetMinOutputSizePixel( aMinSize );
         pWrapper->SetMaxOutputSizePixel( aMaxSize );
-        pWrapper->ShowTitleButton( TitleButton::Menu, ( pThis->GetMenuType() & TOOLBOX_MENUTYPE_CUSTOMIZE) != 0 );
+        pWrapper->ShowTitleButton( TitleButton::Menu, bool( pThis->GetMenuType() & ToolBoxMenuType::Customize) );
     }
     else
     {
diff --git a/vcl/source/window/toolbox2.cxx b/vcl/source/window/toolbox2.cxx
index 83a5176..7a93e50 100644
--- a/vcl/source/window/toolbox2.cxx
+++ b/vcl/source/window/toolbox2.cxx
@@ -53,7 +53,7 @@ ImplToolBoxPrivateData::ImplToolBoxPrivateData() :
     mpMenu = new PopupMenu();
     mnEventId = nullptr;
 
-    maMenuType = TOOLBOX_MENUTYPE_NONE;
+    maMenuType = ToolBoxMenuType::NONE;
     maMenubuttonItem.maItemSize = Size( TB_MENUBUTTON_SIZE+TB_MENUBUTTON_OFFSET, TB_MENUBUTTON_SIZE+TB_MENUBUTTON_OFFSET );
     maMenubuttonItem.meState = TRISTATE_FALSE;
     mnMenuButtonWidth = TB_MENUBUTTON_SIZE;
@@ -1737,7 +1737,7 @@ void ToolBox::SetDropdownClickHdl( const Link<ToolBox *, void>& rLink )
     }
 }
 
-void ToolBox::SetMenuType( sal_uInt16 aType )
+void ToolBox::SetMenuType( ToolBoxMenuType aType )
 {
     if( aType != mpData->maMenuType )
     {
@@ -1747,7 +1747,7 @@ void ToolBox::SetMenuType( sal_uInt16 aType )
             // the menu button may have to be moved into the decoration which changes the layout
             ImplDockingWindowWrapper *pWrapper = ImplGetDockingManager()->GetDockingWindowWrapper( this );
             if( pWrapper )
-                pWrapper->ShowTitleButton( TitleButton::Menu, ( aType & TOOLBOX_MENUTYPE_CUSTOMIZE) != 0 );
+                pWrapper->ShowTitleButton( TitleButton::Menu, bool( aType & ToolBoxMenuType::Customize) );
 
             mbFormat = true;
             ImplFormat();
@@ -1762,14 +1762,14 @@ void ToolBox::SetMenuType( sal_uInt16 aType )
     }
 }
 
-sal_uInt16 ToolBox::GetMenuType() const
+ToolBoxMenuType ToolBox::GetMenuType() const
 {
     return mpData->maMenuType;
 }
 
 bool ToolBox::IsMenuEnabled() const
 {
-    return mpData->maMenuType != TOOLBOX_MENUTYPE_NONE;
+    return mpData->maMenuType != ToolBoxMenuType::NONE;
 }
 
 PopupMenu* ToolBox::GetMenu() const
@@ -1894,7 +1894,7 @@ void ToolBox::ImplExecuteCustomMenu()
 {
     if( IsMenuEnabled() )
     {
-        if( GetMenuType() & TOOLBOX_MENUTYPE_CUSTOMIZE )
+        if( GetMenuType() & ToolBoxMenuType::Customize )
             // call button handler to allow for menu customization
             mpData->maMenuButtonHdl.Call( this );
 


More information about the Libreoffice-commits mailing list