Kaydet (Commit) 3fd5f891 authored tarafından Noel Grandin's avatar Noel Grandin Kaydeden (comit) Noel Grandin

convert CURSOR_DIRECTION constants to scoped enum

Change-Id: I444c61d0073b12740b55e316b2bb6e34f59dfe21
Reviewed-on: https://gerrit.libreoffice.org/15675Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNoel Grandin <noelgrandin@gmail.com>
üst 0c129aa3
...@@ -942,16 +942,16 @@ void ImpEditView::ShowCursor( bool bGotoCursor, bool bForceVisCursor, sal_uInt16 ...@@ -942,16 +942,16 @@ void ImpEditView::ShowCursor( bool bGotoCursor, bool bForceVisCursor, sal_uInt16
libreOfficeKitCallback(LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR, sRect.getStr()); 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() ) ) ) if ( IsInsertMode() && !aEditSelection.HasRange() && ( pEditEngine->pImpEditEngine->HasDifferentRTLLevels( aPaM.GetNode() ) ) )
{ {
sal_uInt16 nTextPortion = pParaPortion->GetTextPortions().FindPortion( aPaM.GetIndex(), nTextPortionStart, (nShowCursorFlags & GETCRSR_PREFERPORTIONSTART) != 0 ); sal_uInt16 nTextPortion = pParaPortion->GetTextPortions().FindPortion( aPaM.GetIndex(), nTextPortionStart, (nShowCursorFlags & GETCRSR_PREFERPORTIONSTART) != 0 );
const TextPortion* pTextPortion = pParaPortion->GetTextPortions()[nTextPortion]; const TextPortion* pTextPortion = pParaPortion->GetTextPortions()[nTextPortion];
sal_uInt16 nRTLLevel = pTextPortion->GetRightToLeft(); sal_uInt16 nRTLLevel = pTextPortion->GetRightToLeft();
if ( nRTLLevel%2 ) if ( nRTLLevel%2 )
nCursorDir = CURSOR_DIRECTION_RTL; nCursorDir = CursorDirection::RTL;
else else
nCursorDir = CURSOR_DIRECTION_LTR; nCursorDir = CursorDirection::LTR;
} }
GetCursor()->SetDirection( nCursorDir ); GetCursor()->SetDirection( nCursorDir );
......
...@@ -31,9 +31,11 @@ namespace vcl { class Window; } ...@@ -31,9 +31,11 @@ namespace vcl { class Window; }
// Cursor styles // Cursor styles
#define CURSOR_SHADOW ((sal_uInt16)0x0001) #define CURSOR_SHADOW ((sal_uInt16)0x0001)
#define CURSOR_DIRECTION_NONE ((unsigned char)0x00)
#define CURSOR_DIRECTION_LTR ((unsigned char)0x01) enum class CursorDirection
#define CURSOR_DIRECTION_RTL ((unsigned char)0x02) {
NONE, LTR, RTL
};
namespace vcl namespace vcl
{ {
...@@ -49,7 +51,7 @@ private: ...@@ -49,7 +51,7 @@ private:
short mnOrientation; short mnOrientation;
sal_uInt16 mnStyle; sal_uInt16 mnStyle;
bool mbVisible; bool mbVisible;
unsigned char mnDirection; CursorDirection mnDirection;
public: public:
SAL_DLLPRIVATE void ImplDraw(); SAL_DLLPRIVATE void ImplDraw();
...@@ -90,8 +92,8 @@ public: ...@@ -90,8 +92,8 @@ public:
void SetOrientation( short nOrientation = 0 ); void SetOrientation( short nOrientation = 0 );
short GetOrientation() const { return mnOrientation; } short GetOrientation() const { return mnOrientation; }
void SetDirection( unsigned char nDirection = 0 ); void SetDirection( CursorDirection nDirection = CursorDirection::NONE );
unsigned char GetDirection() const { return mnDirection; } CursorDirection GetDirection() const { return mnDirection; }
Cursor& operator=( const Cursor& rCursor ); Cursor& operator=( const Cursor& rCursor );
bool operator==( const Cursor& rCursor ) const; bool operator==( const Cursor& rCursor ) const;
......
...@@ -128,7 +128,7 @@ void SwVisCrsr::_SetPosAndShow() ...@@ -128,7 +128,7 @@ void SwVisCrsr::_SetPosAndShow()
} }
// check if cursor should show the current cursor bidi level // 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(); const SwCursor* pTmpCrsr = m_pCrsrShell->_GetCrsr();
if ( pTmpCrsr && !m_pCrsrShell->IsOverwriteCrsr() ) if ( pTmpCrsr && !m_pCrsrShell->IsOverwriteCrsr() )
...@@ -146,8 +146,8 @@ void SwVisCrsr::_SetPosAndShow() ...@@ -146,8 +146,8 @@ void SwVisCrsr::_SetPosAndShow()
{ {
m_aTxtCrsr.SetDirection( m_aTxtCrsr.SetDirection(
( pTmpCrsr->GetCrsrBidiLevel() % 2 ) ? ( pTmpCrsr->GetCrsrBidiLevel() % 2 ) ?
CURSOR_DIRECTION_RTL : CursorDirection::RTL :
CURSOR_DIRECTION_LTR ); CursorDirection::LTR );
} }
if ( pFrm->IsRightToLeft() ) if ( pFrm->IsRightToLeft() )
{ {
......
...@@ -35,7 +35,7 @@ struct ImplCursorData ...@@ -35,7 +35,7 @@ struct ImplCursorData
Size maPixSize; // Pixel-Size Size maPixSize; // Pixel-Size
long mnPixSlant; // Pixel-Slant long mnPixSlant; // Pixel-Slant
short mnOrientation; // Pixel-Orientation short mnOrientation; // Pixel-Orientation
unsigned char mnDirection; // indicates writing direction CursorDirection mnDirection; // indicates writing direction
sal_uInt16 mnStyle; // Cursor-Style sal_uInt16 mnStyle; // Cursor-Style
bool mbCurVisible; // Ist Cursor aktuell sichtbar bool mbCurVisible; // Ist Cursor aktuell sichtbar
VclPtr<vcl::Window> mpWindow; // Zugeordnetes Windows VclPtr<vcl::Window> mpWindow; // Zugeordnetes Windows
...@@ -53,7 +53,7 @@ static void ImplCursorInvert( ImplCursorData* pData ) ...@@ -53,7 +53,7 @@ static void ImplCursorInvert( ImplCursorData* pData )
nInvertStyle = 0; nInvertStyle = 0;
Rectangle aRect( pData->maPixPos, pData->maPixSize ); 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 ); Polygon aPoly( aRect );
if( aPoly.GetSize() == 5 ) if( aPoly.GetSize() == 5 )
...@@ -72,11 +72,11 @@ static void ImplCursorInvert( ImplCursorData* pData ) ...@@ -72,11 +72,11 @@ static void ImplCursorInvert( ImplCursorData* pData )
} }
// apply direction flag after slant to use the correct shape // apply direction flag after slant to use the correct shape
if ( pData->mnDirection ) if ( pData->mnDirection != CursorDirection::NONE)
{ {
Point pAry[7]; Point pAry[7];
int delta = 3*aRect.getWidth()+1; int delta = 3*aRect.getWidth()+1;
if( pData->mnDirection == CURSOR_DIRECTION_LTR ) if( pData->mnDirection == CursorDirection::LTR )
{ {
// left-to-right // left-to-right
pAry[0] = aPoly.GetPoint( 0 ); pAry[0] = aPoly.GetPoint( 0 );
...@@ -89,7 +89,7 @@ static void ImplCursorInvert( ImplCursorData* pData ) ...@@ -89,7 +89,7 @@ static void ImplCursorInvert( ImplCursorData* pData )
pAry[5] = aPoly.GetPoint( 3 ); pAry[5] = aPoly.GetPoint( 3 );
pAry[6] = aPoly.GetPoint( 4 ); pAry[6] = aPoly.GetPoint( 4 );
} }
else if( pData->mnDirection == CURSOR_DIRECTION_RTL ) else if( pData->mnDirection == CursorDirection::RTL )
{ {
// right-to-left // right-to-left
pAry[0] = aPoly.GetPoint( 0 ); pAry[0] = aPoly.GetPoint( 0 );
...@@ -260,7 +260,7 @@ vcl::Cursor::Cursor() ...@@ -260,7 +260,7 @@ vcl::Cursor::Cursor()
mpWindow = NULL; mpWindow = NULL;
mnSlant = 0; mnSlant = 0;
mnOrientation = 0; mnOrientation = 0;
mnDirection = 0; mnDirection = CursorDirection::NONE;
mnStyle = 0; mnStyle = 0;
mbVisible = false; mbVisible = false;
} }
...@@ -361,7 +361,7 @@ void vcl::Cursor::SetOrientation( short nNewOrientation ) ...@@ -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 ) if ( mnDirection != nNewDirection )
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment