[Libreoffice-commits] core.git: 2 commits - svx/inc svx/source

Noel Grandin noel at peralex.com
Mon May 16 06:41:58 UTC 2016


 svx/inc/galbrws2.hxx                       |   15 ++++++++++-----
 svx/source/form/fmcontrolbordermanager.cxx |   24 ++++++++++++------------
 svx/source/form/formcontroller.cxx         |    6 +++---
 svx/source/gallery2/galbrws2.cxx           |   14 +++++++-------
 svx/source/gallery2/galctrl.cxx            |    8 ++++----
 svx/source/inc/fmcontrolbordermanager.hxx  |   22 +++++++++++++---------
 6 files changed, 49 insertions(+), 40 deletions(-)

New commits:
commit 34178c86ce4439e39464084d1a17ac07f330a0e9
Author: Noel Grandin <noel at peralex.com>
Date:   Fri May 13 14:23:36 2016 +0200

    convert GALLERY_ITEM to scoped enum
    
    Change-Id: I7b3b2b72baf58cd7713418ea36d6a2fe6e0e12e9
    Reviewed-on: https://gerrit.libreoffice.org/24962
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noelgrandin at gmail.com>

diff --git a/svx/inc/galbrws2.hxx b/svx/inc/galbrws2.hxx
index c0556f8..dd3d0b0 100644
--- a/svx/inc/galbrws2.hxx
+++ b/svx/inc/galbrws2.hxx
@@ -53,10 +53,15 @@ enum GalleryBrowserTravel
     GALLERYBROWSERTRAVEL_NEXT = 4
 };
 
-
-#define GALLERY_ITEM_THEMENAME  0x00000001
-#define GALLERY_ITEM_TITLE      0x00000002
-#define GALLERY_ITEM_PATH       0x00000004
+enum class GalleryItemFlags {
+    ThemeName  = 0x0001,
+    Title      = 0x0002,
+    Path       = 0x0004
+};
+namespace o3tl
+{
+    template<> struct typed_flags<GalleryItemFlags> : is_typed_flags<GalleryItemFlags, 0x0007> {};
+}
 
 
 class GalleryToolBox : public ToolBox
@@ -132,7 +137,7 @@ private:
 
 public:
 
-    static OUString     GetItemText( const GalleryTheme& rTheme, const SgaObject& rObj, sal_uIntPtr nItemTextFlags );
+    static OUString     GetItemText( const GalleryTheme& rTheme, const SgaObject& rObj, GalleryItemFlags nItemTextFlags );
 
 public:
 
diff --git a/svx/source/gallery2/galbrws2.cxx b/svx/source/gallery2/galbrws2.cxx
index d9e7ca0..d942ba6 100644
--- a/svx/source/gallery2/galbrws2.cxx
+++ b/svx/source/gallery2/galbrws2.cxx
@@ -1173,7 +1173,7 @@ void GalleryBrowser2::Execute( sal_uInt16 nId )
 
                 if( pObj )
                 {
-                    const OUString  aOldTitle( GetItemText( *mpCurTheme, *pObj, GALLERY_ITEM_TITLE ) );
+                    const OUString  aOldTitle( GetItemText( *mpCurTheme, *pObj, GalleryItemFlags::Title ) );
 
                     SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
                     if(pFact)
@@ -1235,19 +1235,19 @@ void GalleryBrowser2::Execute( sal_uInt16 nId )
     }
 }
 
-OUString GalleryBrowser2::GetItemText( const GalleryTheme& rTheme, const SgaObject& rObj, sal_uIntPtr nItemTextFlags )
+OUString GalleryBrowser2::GetItemText( const GalleryTheme& rTheme, const SgaObject& rObj, GalleryItemFlags nItemTextFlags )
 {
     OUString          aRet;
 
     const INetURLObject& aURL(rObj.GetURL());
 
-    if( nItemTextFlags & GALLERY_ITEM_THEMENAME )
+    if( nItemTextFlags & GalleryItemFlags::ThemeName )
     {
         aRet += rTheme.GetName();
         aRet += " - ";
     }
 
-    if( nItemTextFlags & GALLERY_ITEM_TITLE )
+    if( nItemTextFlags & GalleryItemFlags::Title )
     {
         OUString aTitle( rObj.GetTitle() );
 
@@ -1263,16 +1263,16 @@ OUString GalleryBrowser2::GetItemText( const GalleryTheme& rTheme, const SgaObje
         aRet += aTitle;
     }
 
-    if( nItemTextFlags & GALLERY_ITEM_PATH )
+    if( nItemTextFlags & GalleryItemFlags::Path )
     {
         const OUString aPath( aURL.getFSysPath( INetURLObject::FSYS_DETECT ) );
 
-        if( !aPath.isEmpty() && ( nItemTextFlags & GALLERY_ITEM_TITLE ) )
+        if( !aPath.isEmpty() && ( nItemTextFlags & GalleryItemFlags::Title ) )
             aRet += " (";
 
         aRet += aURL.getFSysPath( INetURLObject::FSYS_DETECT );
 
-        if( !aPath.isEmpty() && ( nItemTextFlags & GALLERY_ITEM_TITLE ) )
+        if( !aPath.isEmpty() && ( nItemTextFlags & GalleryItemFlags::Title ) )
             aRet += ")";
     }
 
diff --git a/svx/source/gallery2/galctrl.cxx b/svx/source/gallery2/galctrl.cxx
index 22714c9..e543637 100644
--- a/svx/source/gallery2/galctrl.cxx
+++ b/svx/source/gallery2/galctrl.cxx
@@ -332,7 +332,7 @@ void GalleryIconView::UserDraw(const UserDrawEvent& rUDEvt)
             if(pObj)
             {
                 aBitmapEx = pObj->createPreviewBitmapEx(aSize);
-                aItemTextTitle = GalleryBrowser2::GetItemText(*mpTheme, *pObj, GALLERY_ITEM_TITLE);
+                aItemTextTitle = GalleryBrowser2::GetItemText(*mpTheme, *pObj, GalleryItemFlags::Title);
 
                 mpTheme->SetPreviewBitmapExAndStrings(nId - 1, aBitmapEx, aSize, aItemTextTitle, aItemTextPath);
                 GalleryTheme::ReleaseObject(pObj);
@@ -450,7 +450,7 @@ OUString GalleryListView::GetCellText(long _nRow, sal_uInt16 /*nColumnId*/) cons
 
         if( pObj )
         {
-            sRet = GalleryBrowser2::GetItemText( *mpTheme, *pObj, GALLERY_ITEM_TITLE );
+            sRet = GalleryBrowser2::GetItemText( *mpTheme, *pObj, GalleryItemFlags::Title );
             GalleryTheme::ReleaseObject( pObj );
         }
     }
@@ -515,8 +515,8 @@ void GalleryListView::PaintField(vcl::RenderContext& rDev, const Rectangle& rRec
             if(pObj)
             {
                 aBitmapEx = pObj->createPreviewBitmapEx(aSize);
-                aItemTextTitle = GalleryBrowser2::GetItemText(*mpTheme, *pObj, GALLERY_ITEM_TITLE);
-                aItemTextPath = GalleryBrowser2::GetItemText(*mpTheme, *pObj, GALLERY_ITEM_PATH);
+                aItemTextTitle = GalleryBrowser2::GetItemText(*mpTheme, *pObj, GalleryItemFlags::Title);
+                aItemTextPath = GalleryBrowser2::GetItemText(*mpTheme, *pObj, GalleryItemFlags::Path);
 
                 mpTheme->SetPreviewBitmapExAndStrings(mnCurRow, aBitmapEx, aSize, aItemTextTitle, aItemTextPath);
                 GalleryTheme::ReleaseObject(pObj);
commit 58944b5c6e49023d93f08e9e18eaa47f445dc5f8
Author: Noel Grandin <noel at peralex.com>
Date:   Fri May 13 14:18:26 2016 +0200

    convert CONTROL_STATUS to scoped enum
    
    Change-Id: I1639b7f0f0a735fd97f5bce6ff018dd7d8eb5726
    Reviewed-on: https://gerrit.libreoffice.org/24961
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noelgrandin at gmail.com>

diff --git a/svx/source/form/fmcontrolbordermanager.cxx b/svx/source/form/fmcontrolbordermanager.cxx
index 649d320..7e7a5a0 100644
--- a/svx/source/form/fmcontrolbordermanager.cxx
+++ b/svx/source/form/fmcontrolbordermanager.cxx
@@ -135,16 +135,16 @@ namespace svxform
 
     ControlStatus ControlBorderManager::getControlStatus( const Reference< XControl >& _rxControl )
     {
-        ControlStatus nStatus = CONTROL_STATUS_NONE;
+        ControlStatus nStatus = ControlStatus::NONE;
 
         if ( _rxControl.get() == m_aFocusControl.xControl.get() )
-            nStatus |= CONTROL_STATUS_FOCUSED;
+            nStatus |= ControlStatus::Focused;
 
         if ( _rxControl.get() == m_aMouseHoverControl.xControl.get() )
-            nStatus |= CONTROL_STATUS_MOUSE_HOVER;
+            nStatus |= ControlStatus::MouseHover;
 
         if ( m_aInvalidControls.find( ControlData( _rxControl ) ) != m_aInvalidControls.end() )
-            nStatus |= CONTROL_STATUS_INVALID;
+            nStatus |= ControlStatus::Invalid;
 
         return nStatus;
     }
@@ -153,15 +153,15 @@ namespace svxform
     sal_Int32 ControlBorderManager::getControlColorByStatus( ControlStatus _nStatus )
     {
         // "invalid" is ranked highest
-        if ( _nStatus & CONTROL_STATUS_INVALID )
+        if ( _nStatus & ControlStatus::Invalid )
             return m_nInvalidColor;
 
         // then, "focused" is more important than ...
-        if ( _nStatus & CONTROL_STATUS_FOCUSED )
+        if ( _nStatus & ControlStatus::Focused )
             return m_nFocusColor;
 
         // ... "mouse over"
-        if ( _nStatus & CONTROL_STATUS_MOUSE_HOVER )
+        if ( _nStatus & ControlStatus::MouseHover )
             return m_nMouseHoveColor;
 
         OSL_FAIL( "ControlBorderManager::getControlColorByStatus: invalid status!" );
@@ -175,10 +175,10 @@ namespace svxform
 
         ControlStatus nStatus = getControlStatus( _rxControl );
         BorderDescriptor aBorder;
-        aBorder.nBorderType =   ( nStatus == CONTROL_STATUS_NONE )
+        aBorder.nBorderType =   ( nStatus == ControlStatus::NONE )
                             ?   _rFallback.nBorderType
                             :   VisualEffect::FLAT;
-        aBorder.nBorderColor =   ( nStatus == CONTROL_STATUS_NONE )
+        aBorder.nBorderColor =   ( nStatus == ControlStatus::NONE )
                              ?   _rFallback.nBorderColor
                              :   getControlColorByStatus( nStatus );
         setBorder( _rxPeer, aBorder );
@@ -286,13 +286,13 @@ namespace svxform
     {
         switch ( _nStatus )
         {
-        case CONTROL_STATUS_FOCUSED:
+        case ControlStatus::Focused:
             m_nFocusColor = _nColor;
             break;
-        case CONTROL_STATUS_MOUSE_HOVER:
+        case ControlStatus::MouseHover:
             m_nMouseHoveColor = _nColor;
             break;
-        case CONTROL_STATUS_INVALID:
+        case ControlStatus::Invalid:
             m_nInvalidColor = _nColor;
             break;
         default:
diff --git a/svx/source/form/formcontroller.cxx b/svx/source/form/formcontroller.cxx
index 3072c39..40cd718 100644
--- a/svx/source/form/formcontroller.cxx
+++ b/svx/source/form/formcontroller.cxx
@@ -1921,11 +1921,11 @@ void FormController::setModel(const Reference< XTabControllerModel > & Model) th
 
                 sal_Int32 nColor = 0;
                 if ( xModelProps->getPropertyValue( FM_PROP_CONTROL_BORDER_COLOR_FOCUS ) >>= nColor )
-                    m_pControlBorderManager->setStatusColor( CONTROL_STATUS_FOCUSED, nColor );
+                    m_pControlBorderManager->setStatusColor( ControlStatus::Focused, nColor );
                 if ( xModelProps->getPropertyValue( FM_PROP_CONTROL_BORDER_COLOR_MOUSE ) >>= nColor )
-                    m_pControlBorderManager->setStatusColor( CONTROL_STATUS_MOUSE_HOVER, nColor );
+                    m_pControlBorderManager->setStatusColor( ControlStatus::MouseHover, nColor );
                 if ( xModelProps->getPropertyValue( FM_PROP_CONTROL_BORDER_COLOR_INVALID ) >>= nColor )
-                    m_pControlBorderManager->setStatusColor( CONTROL_STATUS_INVALID, nColor );
+                    m_pControlBorderManager->setStatusColor( ControlStatus::Invalid, nColor );
             }
         }
     }
diff --git a/svx/source/inc/fmcontrolbordermanager.hxx b/svx/source/inc/fmcontrolbordermanager.hxx
index c5d5471..c46e41d 100644
--- a/svx/source/inc/fmcontrolbordermanager.hxx
+++ b/svx/source/inc/fmcontrolbordermanager.hxx
@@ -25,6 +25,7 @@
 #include <com/sun/star/awt/XControl.hpp>
 #include <com/sun/star/awt/XVclWindowPeer.hpp>
 #include <comphelper/stl_types.hxx>
+#include <o3tl/typed_flags_set.hxx>
 
 #include <set>
 
@@ -32,18 +33,21 @@ namespace com { namespace sun { namespace star { namespace form { namespace vali
     class XValidatableFormComponent;
 } } } } }
 
+enum class ControlStatus {
+    NONE        = 0x00,
+    Focused     = 0x01,
+    MouseHover  = 0x02,
+    Invalid     = 0x04
+};
+namespace o3tl {
+    template<> struct typed_flags<ControlStatus> : is_typed_flags<ControlStatus, 0x07> {};
+}
+
 
 namespace svxform
 {
 
 
-    typedef sal_Int16 ControlStatus;
-
-    #define CONTROL_STATUS_NONE         0x00
-    #define CONTROL_STATUS_FOCUSED      0x01
-    #define CONTROL_STATUS_MOUSE_HOVER  0x02
-    #define CONTROL_STATUS_INVALID      0x04
-
     struct BorderDescriptor
     {
         sal_Int16   nBorderType;
@@ -147,7 +151,7 @@ namespace svxform
 
         /** sets a color to be used for a given status
             @param _nStatus
-                the status which the color should be applied for. Must not be CONTROL_STATUS_NONE
+                the status which the color should be applied for. Must not be ControlStatus::NONE
             @param _nColor
                 the color to apply for the given status
         */
@@ -200,7 +204,7 @@ namespace svxform
                 the peer of the control, to be passed herein for optimization the caller usually needs it, anyway).
                 Must not be <NULL/>
             @param _rFallback
-                the color/type to use when the control has the status CONTROL_STATUS_NONE
+                the color/type to use when the control has the status ControlStatus::NONE
         */
         void            updateBorderStyle(
                             const css::uno::Reference< css::awt::XControl >& _rxControl,


More information about the Libreoffice-commits mailing list