diff options
author | Noel Grandin <noel@peralex.com> | 2016-05-10 10:06:09 +0200 |
---|---|---|
committer | Noel Grandin <noelgrandin@gmail.com> | 2016-05-10 09:54:00 +0000 |
commit | effde80f670c60986a92ca0f1c5c9922eb17908d (patch) | |
tree | d9757c8e035d53710728e404bf4fb741594c1bb8 | |
parent | 034e481613742e7fc6f9d14c34dd1896bc1ba671 (diff) |
Convert StatusBarItemBits to scoped enum
Change-Id: Ic979d1470052039c4b966edd1d896af31ef55668
Reviewed-on: https://gerrit.libreoffice.org/24826
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
-rw-r--r-- | framework/inc/uielement/statusbarmerger.hxx | 14 | ||||
-rw-r--r-- | framework/source/fwe/xml/statusbardocumenthandler.cxx | 2 | ||||
-rw-r--r-- | framework/source/uielement/statusbaritem.cxx | 14 | ||||
-rw-r--r-- | framework/source/uielement/statusbarmanager.cxx | 22 | ||||
-rw-r--r-- | framework/source/uielement/statusbarmerger.cxx | 12 | ||||
-rw-r--r-- | include/vcl/status.hxx | 30 | ||||
-rw-r--r-- | sfx2/source/statbar/stbitem.cxx | 2 | ||||
-rw-r--r-- | svx/source/dialog/_contdlg.cxx | 2 | ||||
-rw-r--r-- | svx/source/dialog/imapdlg.cxx | 2 | ||||
-rw-r--r-- | vcl/source/window/status.cxx | 32 |
10 files changed, 68 insertions, 64 deletions
diff --git a/framework/inc/uielement/statusbarmerger.hxx b/framework/inc/uielement/statusbarmerger.hxx index d4675fa95c9d..fc296d512be8 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 6219eb184d7a..1640db19d4a1 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 a79e0dd387b3..3c11376ca6b8 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 0e3f094117cc..64ac4247fa2d 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 68ca2c84966e..9459acc8e61b 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 7bb969d898de..e31a6944f938 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 3c34c6013649..4dd498b52a90 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 2b177474e265..aacf82b31d82 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 ccd81fdbb58b..f9d44dc17bbe 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 57a867e75ba9..273e2cc6017f 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(); |