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
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 );
......
......@@ -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;
......
......@@ -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() )
{
......
......@@ -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 )
{
......
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