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

Noel Grandin noel at peralex.com
Tue May 10 09:54:28 UTC 2016


 framework/inc/uielement/statusbarmerger.hxx           |   14 +++----
 framework/source/fwe/xml/statusbardocumenthandler.cxx |    2 -
 framework/source/uielement/statusbaritem.cxx          |   14 +++----
 framework/source/uielement/statusbarmanager.cxx       |   22 ++++++------
 framework/source/uielement/statusbarmerger.cxx        |   12 +++---
 include/vcl/status.hxx                                |   30 +++++++++-------
 sfx2/source/statbar/stbitem.cxx                       |    2 -
 svx/source/dialog/_contdlg.cxx                        |    2 -
 svx/source/dialog/imapdlg.cxx                         |    2 -
 vcl/source/window/status.cxx                          |   32 +++++++++---------
 10 files changed, 68 insertions(+), 64 deletions(-)

New commits:
commit effde80f670c60986a92ca0f1c5c9922eb17908d
Author: Noel Grandin <noel at peralex.com>
Date:   Tue May 10 10:06:09 2016 +0200

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

diff --git a/framework/inc/uielement/statusbarmerger.hxx b/framework/inc/uielement/statusbarmerger.hxx
index d4675fa..fc296d5 100644
--- a/framework/inc/uielement/statusbarmerger.hxx
+++ b/framework/inc/uielement/statusbarmerger.hxx
@@ -28,17 +28,17 @@ namespace framework
 
 struct AddonStatusbarItemData
 {
-    rtl::OUString aLabel;
-    sal_uInt16    nItemBits;
+    rtl::OUString     aLabel;
+    StatusBarItemBits nItemBits;
 };
 
 struct AddonStatusbarItem
 {
-    rtl::OUString aCommandURL;
-    rtl::OUString aLabel;
-    rtl::OUString aContext;
-    sal_uInt16    nItemBits;
-    sal_Int16     nWidth;
+    rtl::OUString     aCommandURL;
+    rtl::OUString     aLabel;
+    rtl::OUString     aContext;
+    StatusBarItemBits nItemBits;
+    sal_Int16         nWidth;
 };
 
 typedef ::std::vector< AddonStatusbarItem > AddonStatusbarItemContainer;
diff --git a/framework/source/fwe/xml/statusbardocumenthandler.cxx b/framework/source/fwe/xml/statusbardocumenthandler.cxx
index 6219eb1..1640db1 100644
--- a/framework/source/fwe/xml/statusbardocumenthandler.cxx
+++ b/framework/source/fwe/xml/statusbardocumenthandler.cxx
@@ -602,7 +602,7 @@ throw ( SAXException, RuntimeException )
                              ATTRIBUTE_ALIGN_LEFT );
     }
 
-    // style ( SIB_IN is default )
+    // style ( StatusBarItemBits::In is default )
     if ( nStyle & ItemStyle::DRAW_FLAT )
     {
         pList->AddAttribute( m_aXMLStatusBarNS + ATTRIBUTE_STYLE,
diff --git a/framework/source/uielement/statusbaritem.cxx b/framework/source/uielement/statusbaritem.cxx
index a79e0dd..3c11376 100644
--- a/framework/source/uielement/statusbaritem.cxx
+++ b/framework/source/uielement/statusbaritem.cxx
@@ -33,28 +33,28 @@ namespace framework
 
 namespace
 {
-sal_uInt16 impl_convertItemBitsToItemStyle( sal_Int16 nItemBits )
+sal_uInt16 impl_convertItemBitsToItemStyle( StatusBarItemBits nItemBits )
 {
     sal_uInt16 nStyle( 0 );
 
-    if ( ( nItemBits & SIB_RIGHT ) == SIB_RIGHT )
+    if ( nItemBits & StatusBarItemBits::Right )
         nStyle |= ItemStyle::ALIGN_RIGHT;
-    else if ( ( nItemBits & SIB_LEFT ) == SIB_LEFT )
+    else if ( nItemBits & StatusBarItemBits::Left )
         nStyle |= ItemStyle::ALIGN_LEFT;
     else
         nStyle |= ItemStyle::ALIGN_CENTER;
 
-    if ( ( nItemBits & SIB_FLAT ) == SIB_FLAT )
+    if ( nItemBits & StatusBarItemBits::Flat )
         nStyle |= ItemStyle::DRAW_FLAT;
-    else if ( ( nItemBits & SIB_OUT ) == SIB_OUT )
+    else if ( nItemBits & StatusBarItemBits::Out )
         nStyle |= ItemStyle::DRAW_OUT3D;
     else
         nStyle |= ItemStyle::DRAW_IN3D;
 
-    if ( ( nItemBits & SIB_AUTOSIZE ) == SIB_AUTOSIZE )
+    if ( nItemBits & StatusBarItemBits::AutoSize )
         nStyle |= ItemStyle::AUTO_SIZE;
 
-    if ( ( nItemBits & SIB_USERDRAW ) == SIB_USERDRAW )
+    if ( nItemBits & StatusBarItemBits::UserDraw )
         nStyle |= ItemStyle::OWNER_DRAW;
 
     return nStyle;
diff --git a/framework/source/uielement/statusbarmanager.cxx b/framework/source/uielement/statusbarmanager.cxx
index 0e3f094..64ac424 100644
--- a/framework/source/uielement/statusbarmanager.cxx
+++ b/framework/source/uielement/statusbarmanager.cxx
@@ -100,28 +100,28 @@ struct lcl_RemoveController : public std::unary_function< typename MAP::value_ty
     }
 };
 
-sal_uInt16 impl_convertItemStyleToItemBits( sal_Int16 nStyle )
+StatusBarItemBits impl_convertItemStyleToItemBits( sal_Int16 nStyle )
 {
-    sal_uInt16 nItemBits( 0 );
+    StatusBarItemBits nItemBits( StatusBarItemBits::NONE );
 
     if (( nStyle & css::ui::ItemStyle::ALIGN_RIGHT ) == css::ui::ItemStyle::ALIGN_RIGHT )
-        nItemBits |= SIB_RIGHT;
+        nItemBits |= StatusBarItemBits::Right;
     else if ( nStyle & css::ui::ItemStyle::ALIGN_LEFT )
-        nItemBits |= SIB_LEFT;
+        nItemBits |= StatusBarItemBits::Left;
     else
-        nItemBits |= SIB_CENTER;
+        nItemBits |= StatusBarItemBits::Center;
 
     if (( nStyle & css::ui::ItemStyle::DRAW_FLAT ) == css::ui::ItemStyle::DRAW_FLAT )
-        nItemBits |= SIB_FLAT;
+        nItemBits |= StatusBarItemBits::Flat;
     else if ( nStyle & css::ui::ItemStyle::DRAW_OUT3D )
-        nItemBits |= SIB_OUT;
+        nItemBits |= StatusBarItemBits::Out;
     else
-        nItemBits |= SIB_IN;
+        nItemBits |= StatusBarItemBits::In;
 
     if (( nStyle & css::ui::ItemStyle::AUTO_SIZE ) == css::ui::ItemStyle::AUTO_SIZE )
-        nItemBits |= SIB_AUTOSIZE;
+        nItemBits |= StatusBarItemBits::AutoSize;
     if ( nStyle & css::ui::ItemStyle::OWNER_DRAW )
-        nItemBits |= SIB_USERDRAW;
+        nItemBits |= StatusBarItemBits::UserDraw;
 
     return nItemBits;
 }
@@ -469,7 +469,7 @@ void StatusBarManager::FillStatusBar( const uno::Reference< container::XIndexAcc
                 if (( nType == css::ui::ItemType::DEFAULT ) && !aCommandURL.isEmpty() )
                 {
                     OUString aString( vcl::CommandInfoProvider::Instance().GetLabelForCommand(aCommandURL, m_xFrame));
-                    sal_uInt16        nItemBits( impl_convertItemStyleToItemBits( nStyle ));
+                    StatusBarItemBits nItemBits( impl_convertItemStyleToItemBits( nStyle ));
 
                     m_pStatusBar->InsertItem( nId, nWidth, nItemBits, nOffset );
                     m_pStatusBar->SetItemCommand( nId, aCommandURL );
diff --git a/framework/source/uielement/statusbarmerger.cxx b/framework/source/uielement/statusbarmerger.cxx
index 68ca2c8..9459acc 100644
--- a/framework/source/uielement/statusbarmerger.cxx
+++ b/framework/source/uielement/statusbarmerger.cxx
@@ -78,18 +78,18 @@ void lcl_ConvertSequenceToValues(
         }
     }
 
-    sal_uInt16 nItemBits(0);
+    StatusBarItemBits nItemBits(StatusBarItemBits::NONE);
     if ( bAutoSize )
-        nItemBits |= SIB_AUTOSIZE;
+        nItemBits |= StatusBarItemBits::AutoSize;
     if ( bOwnerDraw )
-        nItemBits |= SIB_USERDRAW;
+        nItemBits |= StatusBarItemBits::UserDraw;
     if ( sAlignment == STATUSBAR_ALIGN_CENTER )
-        nItemBits |= SIB_CENTER;
+        nItemBits |= StatusBarItemBits::Center;
     else if ( sAlignment == STATUSBAR_ALIGN_RIGHT )
-        nItemBits |= SIB_RIGHT;
+        nItemBits |= StatusBarItemBits::Right;
     else
         // if unset, defaults to left alignment
-        nItemBits |= SIB_LEFT;
+        nItemBits |= StatusBarItemBits::Left;
     rItem.nItemBits = nItemBits;
 }
 
diff --git a/include/vcl/status.hxx b/include/vcl/status.hxx
index 7bb969d..e31a694 100644
--- a/include/vcl/status.hxx
+++ b/include/vcl/status.hxx
@@ -23,6 +23,7 @@
 #include <tools/solar.h>
 #include <vcl/dllapi.h>
 #include <vcl/window.hxx>
+#include <o3tl/typed_flags_set.hxx>
 #include <vector>
 
 struct ImplStatusItem;
@@ -35,18 +36,21 @@ void VCL_DLLPUBLIC DrawProgress(vcl::Window* pWindow, vcl::RenderContext& rRende
                                 const Rectangle& rFramePosSize);
 
 
-typedef sal_uInt16 StatusBarItemBits;
-
-
-#define SIB_LEFT                    ((StatusBarItemBits)0x0001)
-#define SIB_CENTER                  ((StatusBarItemBits)0x0002)
-#define SIB_RIGHT                   ((StatusBarItemBits)0x0004)
-#define SIB_IN                      ((StatusBarItemBits)0x0008)
-#define SIB_OUT                     ((StatusBarItemBits)0x0010)
-#define SIB_FLAT                    ((StatusBarItemBits)0x0020)
-#define SIB_AUTOSIZE                ((StatusBarItemBits)0x0040)
-#define SIB_USERDRAW                ((StatusBarItemBits)0x0080)
-
+enum class StatusBarItemBits {
+    NONE            = 0x0000,
+    Left            = 0x0001,
+    Center          = 0x0002,
+    Right           = 0x0004,
+    In              = 0x0008,
+    Out             = 0x0010,
+    Flat            = 0x0020,
+    AutoSize        = 0x0040,
+    UserDraw        = 0x0080,
+};
+namespace o3tl
+{
+    template<> struct typed_flags<StatusBarItemBits> : is_typed_flags<StatusBarItemBits, 0x00ff> {};
+}
 
 #define STATUSBAR_APPEND            ((sal_uInt16)0xFFFF)
 #define STATUSBAR_ITEM_NOTFOUND     ((sal_uInt16)0xFFFF)
@@ -118,7 +122,7 @@ public:
     virtual void        UserDraw( const UserDrawEvent& rUDEvt );
 
     void                InsertItem( sal_uInt16 nItemId, sal_uLong nWidth,
-                                    StatusBarItemBits nBits = SIB_CENTER | SIB_IN,
+                                    StatusBarItemBits nBits = StatusBarItemBits::Center | StatusBarItemBits::In,
                                     long nOffset = STATUSBAR_OFFSET,
                                     sal_uInt16 nPos = STATUSBAR_APPEND );
     void                RemoveItem( sal_uInt16 nItemId );
diff --git a/sfx2/source/statbar/stbitem.cxx b/sfx2/source/statbar/stbitem.cxx
index 3c34c60..4dd498b 100644
--- a/sfx2/source/statbar/stbitem.cxx
+++ b/sfx2/source/statbar/stbitem.cxx
@@ -561,7 +561,7 @@ void SfxStatusBarControl::Paint
 /*  [Description]
 
     This virtual method is called to paint the contents if the field
-    at hand is marked with SIB_USERDRAW. The output must be obtained
+    at hand is marked with StatusBarItemBits::UserDraw. The output must be obtained
     within the Rectangle of rUDEvt.GetRect() by the OutputDevice
     given by rUDEvt.GetDevice().
 
diff --git a/svx/source/dialog/_contdlg.cxx b/svx/source/dialog/_contdlg.cxx
index 2b17747..aacf82b 100644
--- a/svx/source/dialog/_contdlg.cxx
+++ b/svx/source/dialog/_contdlg.cxx
@@ -279,7 +279,7 @@ SvxSuperContourDlg::SvxSuperContourDlg(SfxBindings *_pBindings, SfxChildWindow *
 
     SetMinOutputSizePixel( aLastSize = GetOutputSizePixel() );
 
-    m_pStbStatus->InsertItem( 1, 130, SIB_LEFT | SIB_IN | SIB_AUTOSIZE );
+    m_pStbStatus->InsertItem( 1, 130, StatusBarItemBits::Left | StatusBarItemBits::In | StatusBarItemBits::AutoSize );
     m_pStbStatus->InsertItem( 2, 10 + GetTextWidth( " 9999,99 cm / 9999,99 cm " ) );
     m_pStbStatus->InsertItem( 3, 10 + GetTextWidth( " 9999,99 cm x 9999,99 cm " ) );
     m_pStbStatus->InsertItem( 4, 20 );
diff --git a/svx/source/dialog/imapdlg.cxx b/svx/source/dialog/imapdlg.cxx
index ccd81fd..f9d44dc 100644
--- a/svx/source/dialog/imapdlg.cxx
+++ b/svx/source/dialog/imapdlg.cxx
@@ -191,7 +191,7 @@ SvxIMapDlg::SvxIMapDlg(SfxBindings *_pBindings, SfxChildWindow *pCW, vcl::Window
 
     SetMinOutputSizePixel( aLastSize = GetOutputSizePixel() );
 
-    m_pStbStatus->InsertItem( 1, 130, SIB_LEFT | SIB_IN | SIB_AUTOSIZE );
+    m_pStbStatus->InsertItem( 1, 130, StatusBarItemBits::Left | StatusBarItemBits::In | StatusBarItemBits::AutoSize );
     m_pStbStatus->InsertItem( 2, 10 + GetTextWidth( " 9999,99 cm / 9999,99 cm " ) );
     m_pStbStatus->InsertItem( 3, 10 + GetTextWidth( " 9999,99 cm x 9999,99 cm " ) );
 
diff --git a/vcl/source/window/status.cxx b/vcl/source/window/status.cxx
index 57a867e..273e2cc 100644
--- a/vcl/source/window/status.cxx
+++ b/vcl/source/window/status.cxx
@@ -88,7 +88,7 @@ inline long ImplCalcProgessWidth( sal_uInt16 nMax, long nSize )
 }
 
 static Point ImplGetItemTextPos( const Size& rRectSize, const Size& rTextSize,
-                                 sal_uInt16 nStyle )
+                                 StatusBarItemBits nStyle )
 {
     long nX;
     long nY;
@@ -96,11 +96,11 @@ static Point ImplGetItemTextPos( const Size& rRectSize, const Size& rTextSize,
     if( delta + rTextSize.Width() > rRectSize.Width() )
         delta = 0;
 
-    if ( nStyle & SIB_LEFT )
+    if ( nStyle & StatusBarItemBits::Left )
         nX = delta;
-    else if ( nStyle & SIB_RIGHT )
+    else if ( nStyle & StatusBarItemBits::Right )
         nX = rRectSize.Width()-rTextSize.Width()-delta;
-    else // SIB_CENTER
+    else // StatusBarItemBits::Center
         nX = (rRectSize.Width()-rTextSize.Width())/2;
     nY = (rRectSize.Height()-rTextSize.Height())/2 + 1;
     return Point( nX, nY );
@@ -239,7 +239,7 @@ void StatusBar::ImplFormat()
         pItem = (*mpItemList)[ i ];
         if ( pItem->mbVisible )
         {
-            if ( pItem->mnBits & SIB_AUTOSIZE ) {
+            if ( pItem->mnBits & StatusBarItemBits::AutoSize ) {
                 nAutoSizeItems++;
             }
 
@@ -280,7 +280,7 @@ void StatusBar::ImplFormat()
     for ( size_t i = 0, n = mpItemList->size(); i < n; ++i ) {
         pItem = (*mpItemList)[ i ];
         if ( pItem->mbVisible ) {
-            if ( pItem->mnBits & SIB_AUTOSIZE ) {
+            if ( pItem->mnBits & StatusBarItemBits::AutoSize ) {
                 pItem->mnExtraWidth = nExtraWidth;
                 if ( nExtraWidth2 ) {
                     pItem->mnExtraWidth++;
@@ -396,7 +396,7 @@ void StatusBar::ImplDrawItem(vcl::RenderContext& rRenderContext, bool bOffScreen
     }
 
     // call DrawItem if necessary
-    if (pItem->mnBits & SIB_USERDRAW)
+    if (pItem->mnBits & StatusBarItemBits::UserDraw)
     {
         if (bOffScreen)
         {
@@ -422,11 +422,11 @@ void StatusBar::ImplDrawItem(vcl::RenderContext& rRenderContext, bool bOffScreen
     // show frame
     if (mpImplData->mbDrawItemFrames)
     {
-        if (!(pItem->mnBits & SIB_FLAT))
+        if (!(pItem->mnBits & StatusBarItemBits::Flat))
         {
             DrawFrameStyle nStyle;
 
-            if (pItem->mnBits & SIB_IN)
+            if (pItem->mnBits & StatusBarItemBits::In)
                 nStyle = DrawFrameStyle::In;
             else
                 nStyle = DrawFrameStyle::Out;
@@ -906,10 +906,10 @@ void StatusBar::InsertItem( sal_uInt16 nItemId, sal_uLong nWidth,
                 "StatusBar::InsertItem(): ItemId already exists" );
 
     // default: IN and CENTER
-    if ( !(nBits & (SIB_IN | SIB_OUT | SIB_FLAT)) )
-        nBits |= SIB_IN;
-    if ( !(nBits & (SIB_LEFT | SIB_RIGHT | SIB_CENTER)) )
-        nBits |= SIB_CENTER;
+    if ( !(nBits & (StatusBarItemBits::In | StatusBarItemBits::Out | StatusBarItemBits::Flat)) )
+        nBits |= StatusBarItemBits::In;
+    if ( !(nBits & (StatusBarItemBits::Left | StatusBarItemBits::Right | StatusBarItemBits::Center)) )
+        nBits |= StatusBarItemBits::Center;
 
     // create item
     if (mbAdjustHiDPI && GetDPIScaleFactor() != 1)
@@ -1129,7 +1129,7 @@ StatusBarItemBits StatusBar::GetItemBits( sal_uInt16 nItemId ) const
     if ( nPos != STATUSBAR_ITEM_NOTFOUND )
         return (*mpItemList)[ nPos ]->mnBits;
 
-    return 0;
+    return StatusBarItemBits::NONE;
 }
 
 long StatusBar::GetItemOffset( sal_uInt16 nItemId ) const
@@ -1219,7 +1219,7 @@ void StatusBar::SetItemData( sal_uInt16 nItemId, void* pNewData )
         pItem->mpUserData = pNewData;
 
         // call Draw-Item if it's a User-Item
-        if ( (pItem->mnBits & SIB_USERDRAW) && pItem->mbVisible &&
+        if ( (pItem->mnBits & StatusBarItemBits::UserDraw) && pItem->mbVisible &&
              !mbFormat && ImplIsItemUpdate() )
         {
             Update();
@@ -1250,7 +1250,7 @@ void StatusBar::RedrawItem(sal_uInt16 nItemId)
         return;
 
     ImplStatusItem* pItem = (*mpItemList)[ nPos ];
-    if (pItem && (pItem->mnBits & SIB_USERDRAW) &&
+    if (pItem && (pItem->mnBits & StatusBarItemBits::UserDraw) &&
         pItem->mbVisible && ImplIsItemUpdate())
     {
         Update();


More information about the Libreoffice-commits mailing list