editeng/source/editeng/impedit.cxx | 6 +++--- include/vcl/cursor.hxx | 14 ++++++++------ sw/source/core/crsr/viscrs.cxx | 6 +++--- vcl/source/window/cursor.cxx | 16 ++++++++-------- 4 files changed, 22 insertions(+), 20 deletions(-)
New commits: commit 3fd5f8919ec2256c70ff26c14cb9f8065c5cb2f1 Author: Noel Grandin <[email protected]> Date: Thu May 7 17:06:34 2015 +0200 convert CURSOR_DIRECTION constants to scoped enum Change-Id: I444c61d0073b12740b55e316b2bb6e34f59dfe21 Reviewed-on: https://gerrit.libreoffice.org/15675 Tested-by: Jenkins <[email protected]> Reviewed-by: Noel Grandin <[email protected]> diff --git a/editeng/source/editeng/impedit.cxx b/editeng/source/editeng/impedit.cxx index 3d126ba..3f31452 100644 --- a/editeng/source/editeng/impedit.cxx +++ b/editeng/source/editeng/impedit.cxx @@ -942,16 +942,16 @@ void ImpEditView::ShowCursor( bool bGotoCursor, bool bForceVisCursor, sal_uInt16 libreOfficeKitCallback(LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR, sRect.getStr()); } - unsigned char nCursorDir = CURSOR_DIRECTION_NONE; + CursorDirection nCursorDir = CursorDirection::NONE; if ( IsInsertMode() && !aEditSelection.HasRange() && ( pEditEngine->pImpEditEngine->HasDifferentRTLLevels( aPaM.GetNode() ) ) ) { sal_uInt16 nTextPortion = pParaPortion->GetTextPortions().FindPortion( aPaM.GetIndex(), nTextPortionStart, (nShowCursorFlags & GETCRSR_PREFERPORTIONSTART) != 0 ); const TextPortion* pTextPortion = pParaPortion->GetTextPortions()[nTextPortion]; sal_uInt16 nRTLLevel = pTextPortion->GetRightToLeft(); if ( nRTLLevel%2 ) - nCursorDir = CURSOR_DIRECTION_RTL; + nCursorDir = CursorDirection::RTL; else - nCursorDir = CURSOR_DIRECTION_LTR; + nCursorDir = CursorDirection::LTR; } GetCursor()->SetDirection( nCursorDir ); diff --git a/include/vcl/cursor.hxx b/include/vcl/cursor.hxx index c56ef3c..3a1127e 100644 --- a/include/vcl/cursor.hxx +++ b/include/vcl/cursor.hxx @@ -31,9 +31,11 @@ namespace vcl { class Window; } // Cursor styles #define CURSOR_SHADOW ((sal_uInt16)0x0001) -#define CURSOR_DIRECTION_NONE ((unsigned char)0x00) -#define CURSOR_DIRECTION_LTR ((unsigned char)0x01) -#define CURSOR_DIRECTION_RTL ((unsigned char)0x02) + +enum class CursorDirection +{ + NONE, LTR, RTL +}; namespace vcl { @@ -49,7 +51,7 @@ private: short mnOrientation; sal_uInt16 mnStyle; bool mbVisible; - unsigned char mnDirection; + CursorDirection mnDirection; public: SAL_DLLPRIVATE void ImplDraw(); @@ -90,8 +92,8 @@ public: void SetOrientation( short nOrientation = 0 ); short GetOrientation() const { return mnOrientation; } - void SetDirection( unsigned char nDirection = 0 ); - unsigned char GetDirection() const { return mnDirection; } + void SetDirection( CursorDirection nDirection = CursorDirection::NONE ); + CursorDirection GetDirection() const { return mnDirection; } Cursor& operator=( const Cursor& rCursor ); bool operator==( const Cursor& rCursor ) const; diff --git a/sw/source/core/crsr/viscrs.cxx b/sw/source/core/crsr/viscrs.cxx index b30639d..991c554 100644 --- a/sw/source/core/crsr/viscrs.cxx +++ b/sw/source/core/crsr/viscrs.cxx @@ -128,7 +128,7 @@ void SwVisCrsr::_SetPosAndShow() } // check if cursor should show the current cursor bidi level - m_aTxtCrsr.SetDirection( CURSOR_DIRECTION_NONE ); + m_aTxtCrsr.SetDirection( CursorDirection::NONE ); const SwCursor* pTmpCrsr = m_pCrsrShell->_GetCrsr(); if ( pTmpCrsr && !m_pCrsrShell->IsOverwriteCrsr() ) @@ -146,8 +146,8 @@ void SwVisCrsr::_SetPosAndShow() { m_aTxtCrsr.SetDirection( ( pTmpCrsr->GetCrsrBidiLevel() % 2 ) ? - CURSOR_DIRECTION_RTL : - CURSOR_DIRECTION_LTR ); + CursorDirection::RTL : + CursorDirection::LTR ); } if ( pFrm->IsRightToLeft() ) { diff --git a/vcl/source/window/cursor.cxx b/vcl/source/window/cursor.cxx index c313001..bd96802 100644 --- a/vcl/source/window/cursor.cxx +++ b/vcl/source/window/cursor.cxx @@ -35,8 +35,8 @@ struct ImplCursorData Size maPixSize; // Pixel-Size long mnPixSlant; // Pixel-Slant short mnOrientation; // Pixel-Orientation - unsigned char mnDirection; // indicates writing direction - sal_uInt16 mnStyle; // Cursor-Style + CursorDirection mnDirection; // indicates writing direction + sal_uInt16 mnStyle; // Cursor-Style bool mbCurVisible; // Ist Cursor aktuell sichtbar VclPtr<vcl::Window> mpWindow; // Zugeordnetes Windows }; @@ -53,7 +53,7 @@ static void ImplCursorInvert( ImplCursorData* pData ) nInvertStyle = 0; Rectangle aRect( pData->maPixPos, pData->maPixSize ); - if ( pData->mnDirection || pData->mnOrientation || pData->mnPixSlant ) + if ( pData->mnDirection != CursorDirection::NONE || pData->mnOrientation || pData->mnPixSlant ) { Polygon aPoly( aRect ); if( aPoly.GetSize() == 5 ) @@ -72,11 +72,11 @@ static void ImplCursorInvert( ImplCursorData* pData ) } // apply direction flag after slant to use the correct shape - if ( pData->mnDirection ) + if ( pData->mnDirection != CursorDirection::NONE) { Point pAry[7]; int delta = 3*aRect.getWidth()+1; - if( pData->mnDirection == CURSOR_DIRECTION_LTR ) + if( pData->mnDirection == CursorDirection::LTR ) { // left-to-right pAry[0] = aPoly.GetPoint( 0 ); @@ -89,7 +89,7 @@ static void ImplCursorInvert( ImplCursorData* pData ) pAry[5] = aPoly.GetPoint( 3 ); pAry[6] = aPoly.GetPoint( 4 ); } - else if( pData->mnDirection == CURSOR_DIRECTION_RTL ) + else if( pData->mnDirection == CursorDirection::RTL ) { // right-to-left pAry[0] = aPoly.GetPoint( 0 ); @@ -260,7 +260,7 @@ vcl::Cursor::Cursor() mpWindow = NULL; mnSlant = 0; mnOrientation = 0; - mnDirection = 0; + mnDirection = CursorDirection::NONE; mnStyle = 0; mbVisible = false; } @@ -361,7 +361,7 @@ void vcl::Cursor::SetOrientation( short nNewOrientation ) } } -void vcl::Cursor::SetDirection( unsigned char nNewDirection ) +void vcl::Cursor::SetDirection( CursorDirection nNewDirection ) { if ( mnDirection != nNewDirection ) { _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
