diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2016-11-23 09:19:10 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2016-11-23 09:34:19 +0200 |
commit | 1a4cb47b27c059d92b4e94b249ca3974b72b35da (patch) | |
tree | 922966b91340f4f3b0423e6d6c38a0247c65ec69 /editeng | |
parent | bc83fcc98e2380d3ab7acfa2826b64525e711f72 (diff) |
convert GETCRSR constants to o3tl::typed_flags
Change-Id: Ia367d9a1b73d6c5b7a7989da45af0f002c43413c
Diffstat (limited to 'editeng')
-rw-r--r-- | editeng/source/editeng/editeng.cxx | 10 | ||||
-rw-r--r-- | editeng/source/editeng/editview.cxx | 2 | ||||
-rw-r--r-- | editeng/source/editeng/impedit.cxx | 20 | ||||
-rw-r--r-- | editeng/source/editeng/impedit.hxx | 42 | ||||
-rw-r--r-- | editeng/source/editeng/impedit2.cxx | 22 |
5 files changed, 53 insertions, 43 deletions
diff --git a/editeng/source/editeng/editeng.cxx b/editeng/source/editeng/editeng.cxx index c151c679dda2..11912f671343 100644 --- a/editeng/source/editeng/editeng.cxx +++ b/editeng/source/editeng/editeng.cxx @@ -958,7 +958,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() ); @@ -1091,9 +1091,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 @@ -2367,8 +2367,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 2d0ace84e1b9..732f774eaff3 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 eeacfe0bdb4c..1b8349b3dc62 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; @@ -816,7 +816,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 @@ -824,7 +824,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 ); @@ -833,7 +833,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]; @@ -844,9 +844,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(); } } @@ -1036,7 +1036,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; @@ -1237,7 +1237,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 && @@ -1265,8 +1265,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 5cb4febd90a1..2909167a8f0f 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; @@ -234,7 +244,7 @@ private: long nInvMore; EVControlBits nControl; sal_uInt32 nTravelXPos; - sal_uInt16 nExtraCursorFlags; + GetCursorFlags nExtraCursorFlags; sal_uInt16 nCursorBidiLevel; sal_uInt16 nScrollDiffX; bool bReadOnly; @@ -829,8 +839,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 4de0042675fc..43934f21000e 100644 --- a/editeng/source/editeng/impedit2.cxx +++ b/editeng/source/editeng/impedit2.cxx @@ -490,7 +490,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() ); } @@ -924,7 +924,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 ) { @@ -979,7 +979,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 ); @@ -2972,7 +2972,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" ); @@ -4113,13 +4113,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.... @@ -4137,7 +4137,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]; @@ -4172,24 +4172,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; |