summaryrefslogtreecommitdiff
path: root/editeng
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2016-11-23 09:19:10 +0200
committerAshod Nakashian <ashod.nakashian@collabora.co.uk>2017-12-18 01:07:58 -0500
commit8245ba5d50743b84ab8f96cf1c92332cd750bf70 (patch)
tree031650e6509afd89cb614404b4906cc090f356b8 /editeng
parentbca532c363d54830efb1c5c783c6f6a00f37d011 (diff)
convert GETCRSR constants to o3tl::typed_flags
Change-Id: Ia367d9a1b73d6c5b7a7989da45af0f002c43413c (cherry picked from commit 1a4cb47b27c059d92b4e94b249ca3974b72b35da) (cherry picked from commit a8f5b38aae184341d8ce217188cd85d282feea29)
Diffstat (limited to 'editeng')
-rw-r--r--editeng/source/editeng/editeng.cxx10
-rw-r--r--editeng/source/editeng/editview.cxx2
-rw-r--r--editeng/source/editeng/impedit.cxx20
-rw-r--r--editeng/source/editeng/impedit.hxx42
-rw-r--r--editeng/source/editeng/impedit2.cxx22
5 files changed, 53 insertions, 43 deletions
diff --git a/editeng/source/editeng/editeng.cxx b/editeng/source/editeng/editeng.cxx
index ac0d6321ce28..6b41b3105800 100644
--- a/editeng/source/editeng/editeng.cxx
+++ b/editeng/source/editeng/editeng.cxx
@@ -963,7 +963,7 @@ bool EditEngine::PostKeyEvent( const KeyEvent& rKeyEvent, EditView* pEditView, v
bool bAllowIdle = true;
bool bReadOnly = pEditView->IsReadOnly();
- sal_uInt16 nNewCursorFlags = 0;
+ GetCursorFlags nNewCursorFlags = GetCursorFlags::NONE;
bool bSetCursorFlags = true;
EditSelection aCurSel( pEditView->pImpEditView->GetEditSelection() );
@@ -1096,9 +1096,9 @@ bool EditEngine::PostKeyEvent( const KeyEvent& rKeyEvent, EditView* pEditView, v
bMoved = true;
if ( nCode == KEY_HOME )
- nNewCursorFlags |= GETCRSR_STARTOFLINE;
+ nNewCursorFlags |= GetCursorFlags::StartOfLine;
else if ( nCode == KEY_END )
- nNewCursorFlags |= GETCRSR_ENDOFLINE;
+ nNewCursorFlags |= GetCursorFlags::EndOfLine;
}
#if OSL_DEBUG_LEVEL > 1
@@ -2388,8 +2388,8 @@ Rectangle EditEngine::GetCharacterBounds( const EPosition& rPos ) const
// Check against index, not paragraph
if ( pNode && ( rPos.nIndex < pNode->Len() ) )
{
- aBounds = pImpEditEngine->PaMtoEditCursor( EditPaM( pNode, rPos.nIndex ), GETCRSR_TXTONLY );
- Rectangle aR2 = pImpEditEngine->PaMtoEditCursor( EditPaM( pNode, rPos.nIndex+1 ), GETCRSR_TXTONLY|GETCRSR_ENDOFLINE );
+ aBounds = pImpEditEngine->PaMtoEditCursor( EditPaM( pNode, rPos.nIndex ), GetCursorFlags::TextOnly );
+ Rectangle aR2 = pImpEditEngine->PaMtoEditCursor( EditPaM( pNode, rPos.nIndex+1 ), GetCursorFlags::TextOnly|GetCursorFlags::EndOfLine );
if ( aR2.Right() > aBounds.Right() )
aBounds.Right() = aR2.Right();
}
diff --git a/editeng/source/editeng/editview.cxx b/editeng/source/editeng/editview.cxx
index c2fe60245d8e..bb9093c3904d 100644
--- a/editeng/source/editeng/editview.cxx
+++ b/editeng/source/editeng/editview.cxx
@@ -971,7 +971,7 @@ void EditView::ExecuteSpellPopup( const Point& rPosPixel, Link<SpellCallbackInfo
aPopupMenu->RemoveDisabledEntries( true, true );
- Rectangle aTempRect = pImpEditView->pEditEngine->pImpEditEngine->PaMtoEditCursor( aPaM, GETCRSR_TXTONLY );
+ Rectangle aTempRect = pImpEditView->pEditEngine->pImpEditEngine->PaMtoEditCursor( aPaM, GetCursorFlags::TextOnly );
Point aScreenPos = pImpEditView->GetWindowPos( aTempRect.TopLeft() );
aScreenPos = pImpEditView->GetWindow()->OutputToScreenPixel( aScreenPos );
aTempRect = pImpEditView->GetWindow()->LogicToPixel( Rectangle(aScreenPos, aTempRect.GetSize() ));
diff --git a/editeng/source/editeng/impedit.cxx b/editeng/source/editeng/impedit.cxx
index 795447296b20..eec47351b8e9 100644
--- a/editeng/source/editeng/impedit.cxx
+++ b/editeng/source/editeng/impedit.cxx
@@ -82,7 +82,7 @@ ImpEditView::ImpEditView( EditView* pView, EditEngine* pEng, vcl::Window* pWindo
mpViewShell = nullptr;
mpOtherShell = nullptr;
nScrollDiffX = 0;
- nExtraCursorFlags = 0;
+ nExtraCursorFlags = GetCursorFlags::NONE;
nCursorBidiLevel = CURSOR_BIDILEVEL_DONTKNOW;
pCursor = nullptr;
pDragAndDropInfo = nullptr;
@@ -848,7 +848,7 @@ void ImpEditView::ShowCursor( bool bGotoCursor, bool bForceVisCursor )
const ParaPortion* pParaPortion = pEditEngine->GetParaPortions()[nPara];
- sal_uInt16 nShowCursorFlags = nExtraCursorFlags | GETCRSR_TXTONLY;
+ GetCursorFlags nShowCursorFlags = nExtraCursorFlags | GetCursorFlags::TextOnly;
// Use CursorBidiLevel 0/1 in meaning of
// 0: prefer portion end, normal mode
@@ -856,7 +856,7 @@ void ImpEditView::ShowCursor( bool bGotoCursor, bool bForceVisCursor )
if ( ( GetCursorBidiLevel() != CURSOR_BIDILEVEL_DONTKNOW ) && GetCursorBidiLevel() )
{
- nShowCursorFlags |= GETCRSR_PREFERPORTIONSTART;
+ nShowCursorFlags |= GetCursorFlags::PreferPortionStart;
}
Rectangle aEditCursor = pEditEngine->pImpEditEngine->PaMtoEditCursor( aPaM, nShowCursorFlags );
@@ -865,7 +865,7 @@ void ImpEditView::ShowCursor( bool bGotoCursor, bool bForceVisCursor )
if ( aPaM.GetNode()->Len() && ( aPaM.GetIndex() < aPaM.GetNode()->Len() ) )
{
// If we are behind a portion, and the next portion has other direction, we must change position...
- aEditCursor.Left() = aEditCursor.Right() = pEditEngine->pImpEditEngine->PaMtoEditCursor( aPaM, GETCRSR_TXTONLY|GETCRSR_PREFERPORTIONSTART ).Left();
+ aEditCursor.Left() = aEditCursor.Right() = pEditEngine->pImpEditEngine->PaMtoEditCursor( aPaM, GetCursorFlags::TextOnly|GetCursorFlags::PreferPortionStart ).Left();
sal_Int32 nTextPortion = pParaPortion->GetTextPortions().FindPortion( aPaM.GetIndex(), nTextPortionStart, true );
const TextPortion& rTextPortion = pParaPortion->GetTextPortions()[nTextPortion];
@@ -876,9 +876,9 @@ void ImpEditView::ShowCursor( bool bGotoCursor, bool bForceVisCursor )
else
{
EditPaM aNext = pEditEngine->CursorRight( aPaM );
- Rectangle aTmpRect = pEditEngine->pImpEditEngine->PaMtoEditCursor( aNext, GETCRSR_TXTONLY );
+ Rectangle aTmpRect = pEditEngine->pImpEditEngine->PaMtoEditCursor( aNext, GetCursorFlags::TextOnly );
if ( aTmpRect.Top() != aEditCursor.Top() )
- aTmpRect = pEditEngine->pImpEditEngine->PaMtoEditCursor( aNext, GETCRSR_TXTONLY|GETCRSR_ENDOFLINE );
+ aTmpRect = pEditEngine->pImpEditEngine->PaMtoEditCursor( aNext, GetCursorFlags::TextOnly|GetCursorFlags::EndOfLine );
aEditCursor.Right() = aTmpRect.Left();
}
}
@@ -1079,7 +1079,7 @@ void ImpEditView::ShowCursor( bool bGotoCursor, bool bForceVisCursor )
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 );
+ sal_uInt16 nTextPortion = pParaPortion->GetTextPortions().FindPortion( aPaM.GetIndex(), nTextPortionStart, bool(nShowCursorFlags & GetCursorFlags::PreferPortionStart) );
const TextPortion& rTextPortion = pParaPortion->GetTextPortions()[nTextPortion];
if (rTextPortion.IsRightToLeft())
nCursorDir = CursorDirection::RTL;
@@ -1301,7 +1301,7 @@ bool ImpEditView::MouseButtonUp( const MouseEvent& rMouseEvent )
}
nTravelXPos = TRAVEL_X_DONTKNOW;
nCursorBidiLevel = CURSOR_BIDILEVEL_DONTKNOW;
- nExtraCursorFlags = 0;
+ nExtraCursorFlags = GetCursorFlags::NONE;
bClickedInSelection = false;
if ( rMouseEvent.IsMiddle() && !bReadOnly &&
@@ -1329,8 +1329,8 @@ bool ImpEditView::MouseButtonDown( const MouseEvent& rMouseEvent )
pEditEngine->CheckIdleFormatter(); // If fast typing and mouse button downs
if ( pEditEngine->GetInternalEditStatus().NotifyCursorMovements() )
pEditEngine->GetInternalEditStatus().GetPrevParagraph() = pEditEngine->GetEditDoc().GetPos( GetEditSelection().Max().GetNode() );
- nTravelXPos = TRAVEL_X_DONTKNOW;
- nExtraCursorFlags = 0;
+ nTravelXPos = TRAVEL_X_DONTKNOW;
+ nExtraCursorFlags = GetCursorFlags::NONE;
nCursorBidiLevel = CURSOR_BIDILEVEL_DONTKNOW;
bClickedInSelection = IsSelectionAtPoint( rMouseEvent.GetPosPixel() );
return pEditEngine->pImpEditEngine->MouseButtonDown( rMouseEvent, GetEditViewPtr() );
diff --git a/editeng/source/editeng/impedit.hxx b/editeng/source/editeng/impedit.hxx
index 10ca1447bead..ac6dd36da9f5 100644
--- a/editeng/source/editeng/impedit.hxx
+++ b/editeng/source/editeng/impedit.hxx
@@ -56,23 +56,11 @@
#include <i18nlangtag/lang.h>
#include <rtl/ref.hxx>
#include <LibreOfficeKit/LibreOfficeKitTypes.h>
+#include <o3tl/typed_flags_set.hxx>
#include <memory>
#include <vector>
-#define DEL_LEFT 1
-#define DEL_RIGHT 2
-#define TRAVEL_X_DONTKNOW 0xFFFFFFFF
-#define CURSOR_BIDILEVEL_DONTKNOW 0xFFFF
-#define MAXCHARSINPARA 0x3FFF-CHARPOSGROW // Max 16K, because WYSIWYG array
-
-#define GETCRSR_TXTONLY 0x0001
-#define GETCRSR_STARTOFLINE 0x0002
-#define GETCRSR_ENDOFLINE 0x0004
-#define GETCRSR_PREFERPORTIONSTART 0x0008
-
-#define LINE_SEP '\x0A'
-
class EditView;
class EditEngine;
class OutlinerSearchable;
@@ -103,6 +91,28 @@ namespace editeng {
struct MisspellRanges;
}
+#define DEL_LEFT 1
+#define DEL_RIGHT 2
+#define TRAVEL_X_DONTKNOW 0xFFFFFFFF
+#define CURSOR_BIDILEVEL_DONTKNOW 0xFFFF
+#define MAXCHARSINPARA 0x3FFF-CHARPOSGROW // Max 16K, because WYSIWYG array
+#define LINE_SEP '\x0A'
+
+#define ATTRSPECIAL_WHOLEWORD 1
+#define ATTRSPECIAL_EDGE 2
+
+enum class GetCursorFlags {
+ NONE = 0x0000,
+ TextOnly = 0x0001,
+ StartOfLine = 0x0002,
+ EndOfLine = 0x0004,
+ PreferPortionStart = 0x0008,
+};
+namespace o3tl {
+ template<> struct typed_flags<GetCursorFlags> : is_typed_flags<GetCursorFlags, 0x0f> {};
+}
+
+
struct DragAndDropInfo
{
Rectangle aCurCursor;
@@ -238,7 +248,7 @@ private:
long nInvMore;
EVControlBits nControl;
sal_uInt32 nTravelXPos;
- sal_uInt16 nExtraCursorFlags;
+ GetCursorFlags nExtraCursorFlags;
sal_uInt16 nCursorBidiLevel;
sal_uInt16 nScrollDiffX;
bool bReadOnly;
@@ -835,8 +845,8 @@ public:
bool HasParaAttrib( sal_Int32 nPara, sal_uInt16 nWhich ) const;
const SfxPoolItem& GetParaAttrib( sal_Int32 nPara, sal_uInt16 nWhich ) const;
- Rectangle PaMtoEditCursor( EditPaM aPaM, sal_uInt16 nFlags = 0 );
- Rectangle GetEditCursor( ParaPortion* pPortion, sal_Int32 nIndex, sal_uInt16 nFlags = 0 );
+ Rectangle PaMtoEditCursor( EditPaM aPaM, GetCursorFlags nFlags = GetCursorFlags::NONE );
+ Rectangle GetEditCursor( ParaPortion* pPortion, sal_Int32 nIndex, GetCursorFlags nFlags = GetCursorFlags::NONE );
bool IsModified() const { return aEditDoc.IsModified(); }
void SetModifyFlag( bool b ) { aEditDoc.SetModified( b ); }
diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx
index bc8b2f39f37f..c862c9896440 100644
--- a/editeng/source/editeng/impedit2.cxx
+++ b/editeng/source/editeng/impedit2.cxx
@@ -481,7 +481,7 @@ void ImpEditEngine::Command( const CommandEvent& rCEvt, EditView* pView )
const EditLine& rLine = pParaPortion->GetLines()[nLine];
if ( nInputEnd > rLine.GetEnd() )
nInputEnd = rLine.GetEnd();
- Rectangle aR2 = PaMtoEditCursor( EditPaM( aPaM.GetNode(), nInputEnd ), GETCRSR_ENDOFLINE );
+ Rectangle aR2 = PaMtoEditCursor( EditPaM( aPaM.GetNode(), nInputEnd ), GetCursorFlags::EndOfLine );
Rectangle aRect = pView->GetImpEditView()->GetWindowPos( aR1 );
pView->GetWindow()->SetCursorRect( &aRect, aR2.Left()-aR1.Right() );
}
@@ -917,7 +917,7 @@ EditPaM ImpEditEngine::CursorVisualStartEnd( EditView* pEditView, const EditPaM&
const EditLine& rLine = pParaPortion->GetLines()[nLine];
bool bEmptyLine = rLine.GetStart() == rLine.GetEnd();
- pEditView->pImpEditView->nExtraCursorFlags = 0;
+ pEditView->pImpEditView->nExtraCursorFlags = GetCursorFlags::NONE;
if ( !bEmptyLine )
{
@@ -972,7 +972,7 @@ EditPaM ImpEditEngine::CursorVisualLeftRight( EditView* pEditView, const EditPaM
const EditLine& rLine = pParaPortion->GetLines()[nLine];
bool bEmptyLine = rLine.GetStart() == rLine.GetEnd();
- pEditView->pImpEditView->nExtraCursorFlags = 0;
+ pEditView->pImpEditView->nExtraCursorFlags = GetCursorFlags::NONE;
bool bParaRTL = IsRightToLeft( nPara );
@@ -2967,7 +2967,7 @@ EditPaM ImpEditEngine::InsertLineBreak(const EditSelection& aCurSel)
// Helper functions
-Rectangle ImpEditEngine::PaMtoEditCursor( EditPaM aPaM, sal_uInt16 nFlags )
+Rectangle ImpEditEngine::PaMtoEditCursor( EditPaM aPaM, GetCursorFlags nFlags )
{
OSL_ENSURE( GetUpdateMode(), "Must not be reached when Update=FALSE: PaMtoEditCursor" );
@@ -4117,13 +4117,13 @@ void ImpEditEngine::CalcHeight( ParaPortion* pPortion )
}
}
-Rectangle ImpEditEngine::GetEditCursor( ParaPortion* pPortion, sal_Int32 nIndex, sal_uInt16 nFlags )
+Rectangle ImpEditEngine::GetEditCursor( ParaPortion* pPortion, sal_Int32 nIndex, GetCursorFlags nFlags )
{
OSL_ENSURE( pPortion->IsVisible(), "Why GetEditCursor() for an invisible paragraph?" );
OSL_ENSURE( IsFormatted() || GetTextRanger(), "GetEditCursor: Not formatted" );
/*
- GETCRSR_ENDOFLINE: If after the last character of a wrapped line, remaining
+ GetCursorFlags::EndOfLine: If after the last character of a wrapped line, remaining
at the end of the line, not the beginning of the next one.
Purpose: - END => really after the last character
- Selection....
@@ -4141,7 +4141,7 @@ Rectangle ImpEditEngine::GetEditCursor( ParaPortion* pPortion, sal_Int32 nIndex,
if (nLineCount == 0)
return Rectangle();
const EditLine* pLine = nullptr;
- bool bEOL = ( nFlags & GETCRSR_ENDOFLINE ) != 0;
+ bool bEOL( nFlags & GetCursorFlags::EndOfLine );
for (sal_Int32 nLine = 0; nLine < nLineCount; ++nLine)
{
const EditLine& rTmpLine = pPortion->GetLines()[nLine];
@@ -4176,24 +4176,24 @@ Rectangle ImpEditEngine::GetEditCursor( ParaPortion* pPortion, sal_Int32 nIndex,
// Search within the line...
long nX;
- if ( ( nIndex == pLine->GetStart() ) && ( nFlags & GETCRSR_STARTOFLINE ) )
+ if ( ( nIndex == pLine->GetStart() ) && ( nFlags & GetCursorFlags::StartOfLine ) )
{
Range aXRange = GetLineXPosStartEnd( pPortion, pLine );
nX = !IsRightToLeft( GetEditDoc().GetPos( pPortion->GetNode() ) ) ? aXRange.Min() : aXRange.Max();
}
- else if ( ( nIndex == pLine->GetEnd() ) && ( nFlags & GETCRSR_ENDOFLINE ) )
+ else if ( ( nIndex == pLine->GetEnd() ) && ( nFlags & GetCursorFlags::EndOfLine ) )
{
Range aXRange = GetLineXPosStartEnd( pPortion, pLine );
nX = !IsRightToLeft( GetEditDoc().GetPos( pPortion->GetNode() ) ) ? aXRange.Max() : aXRange.Min();
}
else
{
- nX = GetXPos( pPortion, pLine, nIndex, ( nFlags & GETCRSR_PREFERPORTIONSTART ) != 0 );
+ nX = GetXPos( pPortion, pLine, nIndex, bool( nFlags & GetCursorFlags::PreferPortionStart ) );
}
aEditCursor.Left() = aEditCursor.Right() = nX;
- if ( nFlags & GETCRSR_TXTONLY )
+ if ( nFlags & GetCursorFlags::TextOnly )
aEditCursor.Top() = aEditCursor.Bottom() - pLine->GetTxtHeight() + 1;
else
aEditCursor.Top() = aEditCursor.Bottom() - std::min( pLine->GetTxtHeight(), pLine->GetHeight() ) + 1;