summaryrefslogtreecommitdiff
path: root/editeng
diff options
context:
space:
mode:
authorArmin Le Grand <Armin.Le.Grand@cib.de>2017-08-06 00:26:35 +0200
committerArmin Le Grand <Armin.Le.Grand@cib.de>2017-08-10 15:17:58 +0200
commit4d3f92aa18d3419f861986a610e618c8f09b6ae2 (patch)
tree1e6b5ba5f6ea164968a7e3f78d2631a3ba2549a9 /editeng
parentf06b48a5dddab20fd1bbf9b5f3e8543593f5e590 (diff)
editviewoverlay: EditViewSelection reorganized
The Selection visualization in EditVierw is organized to use XOR for visualization, thus DrawSelection is used e.g. before and after changes to the Selection. Ensured athat all changers of selection have to use SetEditSelection by making return of GetEditSelection const. This allows to use a central and safe SelectionChanged which is needed for alternatives of Selection visualization. Change-Id: I994553f3be6b58fd595aa500922d8d1d8ddd36d4
Diffstat (limited to 'editeng')
-rw-r--r--editeng/source/editeng/editeng.cxx10
-rw-r--r--editeng/source/editeng/editundo.cxx4
-rw-r--r--editeng/source/editeng/editview.cxx42
-rw-r--r--editeng/source/editeng/impedit.cxx90
-rw-r--r--editeng/source/editeng/impedit.hxx11
-rw-r--r--editeng/source/editeng/impedit2.cxx42
-rw-r--r--editeng/source/editeng/impedit3.cxx4
-rw-r--r--editeng/source/editeng/impedit4.cxx28
8 files changed, 134 insertions, 97 deletions
diff --git a/editeng/source/editeng/editeng.cxx b/editeng/source/editeng/editeng.cxx
index 63fce03390de..024b66a91fda 100644
--- a/editeng/source/editeng/editeng.cxx
+++ b/editeng/source/editeng/editeng.cxx
@@ -637,7 +637,7 @@ ESelection EditEngine::GetWord( const ESelection& rSelection, sal_uInt16 nWordTy
return pE->pImpEditEngine->CreateESel( aSel );
}
-void EditEngine::CursorMoved(ContentNode* pPrevNode)
+void EditEngine::CursorMoved(const ContentNode* pPrevNode)
{
pImpEditEngine->CursorMoved(pPrevNode);
}
@@ -1173,7 +1173,7 @@ bool EditEngine::PostKeyEvent( const KeyEvent& rKeyEvent, EditView* pEditView, v
break;
}
- pEditView->pImpEditView->DrawSelection();
+ pEditView->pImpEditView->DrawSelectionXOR();
pImpEditEngine->UndoActionStart( EDITUNDO_DELETE );
aCurSel = pImpEditEngine->DeleteLeftOrRight( aCurSel, nDel, nMode );
pImpEditEngine->UndoActionEnd();
@@ -1213,7 +1213,7 @@ bool EditEngine::PostKeyEvent( const KeyEvent& rKeyEvent, EditView* pEditView, v
{
if ( !bReadOnly )
{
- pEditView->pImpEditView->DrawSelection();
+ pEditView->pImpEditView->DrawSelectionXOR();
if ( !rKeyEvent.GetKeyCode().IsMod1() && !rKeyEvent.GetKeyCode().IsMod2() )
{
pImpEditEngine->UndoActionStart( EDITUNDO_INSERT );
@@ -1268,7 +1268,7 @@ bool EditEngine::PostKeyEvent( const KeyEvent& rKeyEvent, EditView* pEditView, v
if ( !bReadOnly && IsSimpleCharInput( rKeyEvent ) )
{
sal_Unicode nCharCode = rKeyEvent.GetCharCode();
- pEditView->pImpEditView->DrawSelection();
+ pEditView->pImpEditView->DrawSelectionXOR();
// Autocorrection?
SvxAutoCorrect* pAutoCorrect = SvxAutoCorrCfg::Get().GetAutoCorrect();
if ( ( pImpEditEngine->GetStatus().DoAutoCorrect() ) &&
@@ -1363,7 +1363,7 @@ bool EditEngine::PostKeyEvent( const KeyEvent& rKeyEvent, EditView* pEditView, v
pEditView->pImpEditView->SetEditSelection( aCurSel );
if (comphelper::LibreOfficeKit::isActive())
{
- pEditView->pImpEditView->DrawSelection();
+ pEditView->pImpEditView->DrawSelectionXOR();
}
pImpEditEngine->UpdateSelections();
diff --git a/editeng/source/editeng/editundo.cxx b/editeng/source/editeng/editundo.cxx
index ca074815d6d4..40ba68926516 100644
--- a/editeng/source/editeng/editundo.cxx
+++ b/editeng/source/editeng/editundo.cxx
@@ -66,7 +66,7 @@ bool EditUndoManager::Undo()
}
}
- mpEditEngine->GetActiveView()->GetImpEditView()->DrawSelection(); // Remove the old selection
+ mpEditEngine->GetActiveView()->GetImpEditView()->DrawSelectionXOR(); // Remove the old selection
mpEditEngine->SetUndoMode( true );
bool bDone = SfxUndoManager::Undo();
@@ -101,7 +101,7 @@ bool EditUndoManager::Redo()
}
}
- mpEditEngine->GetActiveView()->GetImpEditView()->DrawSelection(); // Remove the old selection
+ mpEditEngine->GetActiveView()->GetImpEditView()->DrawSelectionXOR(); // Remove the old selection
mpEditEngine->SetUndoMode( true );
bool bDone = SfxUndoManager::Redo();
diff --git a/editeng/source/editeng/editview.cxx b/editeng/source/editeng/editview.cxx
index db7ff1951767..b74f76e35001 100644
--- a/editeng/source/editeng/editview.cxx
+++ b/editeng/source/editeng/editview.cxx
@@ -256,7 +256,7 @@ void EditView::SetSelection( const ESelection& rESel )
// manipulates the selection:
if ( !pImpEditView->GetEditSelection().HasRange() )
{
- ContentNode* pNode = pImpEditView->GetEditSelection().Max().GetNode();
+ const ContentNode* pNode = pImpEditView->GetEditSelection().Max().GetNode();
pImpEditView->pEditEngine->CursorMoved( pNode );
}
EditSelection aNewSelection( pImpEditView->pEditEngine->pImpEditEngine->ConvertSelection(
@@ -281,9 +281,9 @@ void EditView::SetSelection( const ESelection& rESel )
aNewSelection.Max() = EditPaM( pNode, pNode->Len() );
}
- pImpEditView->DrawSelection();
+ pImpEditView->DrawSelectionXOR();
pImpEditView->SetEditSelection( aNewSelection );
- pImpEditView->DrawSelection();
+ pImpEditView->DrawSelectionXOR();
bool bGotoCursor = pImpEditView->DoAutoScroll();
ShowCursor( bGotoCursor );
}
@@ -318,7 +318,7 @@ SvtScriptType EditView::GetSelectedScriptType() const
void EditView::GetSelectionRectangles(std::vector<tools::Rectangle>& rLogicRects) const
{
- return pImpEditView->GetSelectionRectangles(rLogicRects);
+ return pImpEditView->GetSelectionRectangles(pImpEditView->GetEditSelection(), rLogicRects);
}
void EditView::Paint( const tools::Rectangle& rRect, OutputDevice* pTargetDevice )
@@ -413,7 +413,7 @@ void EditView::InsertText( const OUString& rStr, bool bSelect )
{
EditEngine* pEE = pImpEditView->pEditEngine;
- pImpEditView->DrawSelection();
+ pImpEditView->DrawSelectionXOR();
EditPaM aPaM1;
if ( bSelect )
@@ -512,7 +512,7 @@ void EditView::SetAttribs( const SfxItemSet& rSet )
{
DBG_ASSERT( !pImpEditView->aEditSelection.IsInvalid(), "Blind Selection in ...." );
- pImpEditView->DrawSelection();
+ pImpEditView->DrawSelectionXOR();
pImpEditView->pEditEngine->SetAttribs( pImpEditView->GetEditSelection(), rSet, SetAttribsMode::WholeWord );
pImpEditView->pEditEngine->FormatAndUpdate( this );
}
@@ -520,7 +520,7 @@ void EditView::SetAttribs( const SfxItemSet& rSet )
void EditView::RemoveAttribsKeepLanguages( bool bRemoveParaAttribs )
{
- pImpEditView->DrawSelection();
+ pImpEditView->DrawSelectionXOR();
pImpEditView->pEditEngine->UndoActionStart( EDITUNDO_RESETATTRIBS );
EditSelection aSelection( pImpEditView->GetEditSelection() );
@@ -540,7 +540,7 @@ void EditView::RemoveAttribsKeepLanguages( bool bRemoveParaAttribs )
void EditView::RemoveAttribs( bool bRemoveParaAttribs, sal_uInt16 nWhich )
{
- pImpEditView->DrawSelection();
+ pImpEditView->DrawSelectionXOR();
pImpEditView->pEditEngine->UndoActionStart( EDITUNDO_RESETATTRIBS );
pImpEditView->pEditEngine->RemoveCharAttribs( pImpEditView->GetEditSelection(), bRemoveParaAttribs, nWhich );
pImpEditView->pEditEngine->UndoActionEnd();
@@ -574,7 +574,7 @@ void EditView::Redo()
ErrCode EditView::Read( SvStream& rInput, EETextFormat eFormat, SvKeyValueIterator* pHTTPHeaderAttrs )
{
EditSelection aOldSel( pImpEditView->GetEditSelection() );
- pImpEditView->DrawSelection();
+ pImpEditView->DrawSelectionXOR();
pImpEditView->pEditEngine->pImpEditEngine->UndoActionStart( EDITUNDO_READ );
EditPaM aEndPaM = pImpEditView->pEditEngine->pImpEditEngine->Read( rInput, "", eFormat, aOldSel, pHTTPHeaderAttrs );
pImpEditView->pEditEngine->pImpEditEngine->UndoActionEnd();
@@ -690,7 +690,7 @@ EditTextObject* EditView::CreateTextObject()
void EditView::InsertText( const EditTextObject& rTextObject )
{
- pImpEditView->DrawSelection();
+ pImpEditView->DrawSelectionXOR();
pImpEditView->pEditEngine->UndoActionStart( EDITUNDO_INSERT );
EditSelection aTextSel( pImpEditView->pEditEngine->InsertText( rTextObject, pImpEditView->GetEditSelection() ) );
@@ -773,9 +773,9 @@ void EditView::TransliterateText( TransliterationFlags nTransliterationMode )
EditSelection aNewSel = pImpEditView->pEditEngine->TransliterateText( pImpEditView->GetEditSelection(), nTransliterationMode );
if ( aNewSel != aOldSel )
{
- pImpEditView->DrawSelection();
+ pImpEditView->DrawSelectionXOR();
pImpEditView->SetEditSelection( aNewSel );
- pImpEditView->DrawSelection();
+ pImpEditView->DrawSelectionXOR();
}
}
@@ -783,7 +783,7 @@ void EditView::CompleteAutoCorrect( vcl::Window const * pFrameWin )
{
if ( !pImpEditView->HasSelection() && pImpEditView->pEditEngine->pImpEditEngine->GetStatus().DoAutoCorrect() )
{
- pImpEditView->DrawSelection();
+ pImpEditView->DrawSelectionXOR();
EditSelection aSel = pImpEditView->GetEditSelection();
aSel = pImpEditView->pEditEngine->EndOfWord( aSel.Max() );
aSel = pImpEditView->pEditEngine->pImpEditEngine->AutoCorrect( aSel, 0, !IsInsertMode(), pFrameWin );
@@ -1073,9 +1073,9 @@ void EditView::ExecuteSpellPopup( const Point& rPosPixel, Link<SpellCallbackInfo
{
// Set Cursor before word...
EditPaM aCursor = pImpEditView->GetEditSelection().Min();
- pImpEditView->DrawSelection();
+ pImpEditView->DrawSelectionXOR();
pImpEditView->SetEditSelection( EditSelection( aCursor, aCursor ) );
- pImpEditView->DrawSelection();
+ pImpEditView->DrawSelectionXOR();
// Crashes when no SfxApp
pImpEditView->pEditEngine->pImpEditEngine->Spell( this, false );
}
@@ -1144,17 +1144,17 @@ void EditView::ExecuteSpellPopup( const Point& rPosPixel, Link<SpellCallbackInfo
void EditView::SelectCurrentWord( sal_Int16 nWordType )
{
EditSelection aCurSel( pImpEditView->GetEditSelection() );
- pImpEditView->DrawSelection();
+ pImpEditView->DrawSelectionXOR();
aCurSel = pImpEditView->pEditEngine->SelectWord(aCurSel.Max(), nWordType);
pImpEditView->SetEditSelection( aCurSel );
- pImpEditView->DrawSelection();
+ pImpEditView->DrawSelectionXOR();
ShowCursor( true, false );
}
void EditView::InsertField( const SvxFieldItem& rFld )
{
EditEngine* pEE = pImpEditView->pEditEngine;
- pImpEditView->DrawSelection();
+ pImpEditView->DrawSelectionXOR();
pEE->UndoActionStart( EDITUNDO_INSERT );
EditPaM aPaM( pEE->InsertField( pImpEditView->GetEditSelection(), rFld ) );
pEE->UndoActionEnd();
@@ -1442,16 +1442,16 @@ void EditView::SetCursorLogicPosition(const Point& rPosition, bool bPoint, bool
if (pImpEditView->GetEditSelection().Min() != aSelection.Min())
pImpEditView->pEditEngine->CursorMoved(pImpEditView->GetEditSelection().Min().GetNode());
- pImpEditView->DrawSelection(aSelection);
+ pImpEditView->DrawSelectionXOR(aSelection);
if (pImpEditView->GetEditSelection() != aSelection)
pImpEditView->SetEditSelection(aSelection);
ShowCursor(/*bGotoCursor=*/false);
}
-void EditView::DrawSelection(OutlinerViewShell* pOtherShell)
+void EditView::DrawSelectionXOR(OutlinerViewShell* pOtherShell)
{
pImpEditView->RegisterOtherShell(pOtherShell);
- pImpEditView->DrawSelection();
+ pImpEditView->DrawSelectionXOR();
pImpEditView->RegisterOtherShell(nullptr);
}
diff --git a/editeng/source/editeng/impedit.cxx b/editeng/source/editeng/impedit.cxx
index fc8ee6745a3a..48a6f1397af3 100644
--- a/editeng/source/editeng/impedit.cxx
+++ b/editeng/source/editeng/impedit.cxx
@@ -91,6 +91,8 @@ ImpEditView::ImpEditView( EditView* pView, EditEngine* pEng, vcl::Window* pWindo
aEditSelection.Min() = pEng->GetEditDoc().GetStartPaM();
aEditSelection.Max() = pEng->GetEditDoc().GetEndPaM();
+
+ SelectionChanged();
}
ImpEditView::~ImpEditView()
@@ -131,6 +133,8 @@ void ImpEditView::SetEditSelection( const EditSelection& rEditSelection )
// set state before notification
aEditSelection = rEditSelection;
+ SelectionChanged();
+
if (comphelper::LibreOfficeKit::isActive())
// Tiled rendering: selections are only painted when we are in selection mode.
pEditEngine->SetInSelectionMode(aEditSelection.HasRange());
@@ -184,19 +188,20 @@ void lcl_translateTwips(vcl::Window const & rParent, vcl::Window& rChild)
}
}
-void ImpEditView::DrawSelection( EditSelection aTmpSel, vcl::Region* pRegion, OutputDevice* pTargetDevice )
+// EditView never had a central/secure place to react on SelectionChange since
+// Selection was changed in many places, often by not using SetEditSelection()
+// but (mis)using GetEditSelection() and manipulating this non-const return
+// value. Sorted this out now to have such a place, this is needed for safely
+// change/update the Selection visualization for enhanced mechanisms
+void ImpEditView::SelectionChanged()
{
- if (hasEditViewCallbacks() && !pRegion)
+ if (hasEditViewCallbacks())
{
- // when we have an own mechanism for painting EditViews, collect the Selection
- // in a basegfx::B2DRange vector and hand over. To do so, call GetSelectionRectangles
- // which recursively calls ImpEditView::DrawSelection, but with nullptr != pRegion
std::vector<tools::Rectangle> aLogicRects;
std::vector<basegfx::B2DRange> aLogicRanges;
- OutputDevice* pTarget = pTargetDevice ? pTargetDevice : pOutWin;
- const Point aPixel(pTarget ? pTarget->LogicToPixel(Point(1, 1)) : Point(1, 1));
+ const Size aLogicPixel(pOutWin ? pOutWin->PixelToLogic(Size(1, 1)) : Size(1, 1));
- GetSelectionRectangles(aLogicRects);
+ GetSelectionRectangles(GetEditSelection(), aLogicRects);
for (const auto& aRect : aLogicRects)
{
@@ -205,12 +210,27 @@ void ImpEditView::DrawSelection( EditSelection aTmpSel, vcl::Region* pRegion, Ou
aLogicRanges.push_back(
basegfx::B2DRange(
aRect.Left(), aRect.Top(),
- aRect.Right() + aPixel.X(), aRect.Bottom() + aPixel.Y()));
+ aRect.Right() + aLogicPixel.Width(), aRect.Bottom() + aLogicPixel.Height()));
}
// use callback to tell about change in selection visualisation
mpEditViewCallbacks->EditViewSelectionChange(aLogicRanges);
+ }
+}
+// renamed from DrawSelection to DrawSelectionXOR to better reflect what this
+// method was used for: Paint Selection in XOR, change it and again paint it in XOR.
+// This can be safely assumed due to the EditView only being capable of painting the
+// selection in XOR until today.
+// This also means that all places calling DrawSelectionXOR are thoroughly weighted
+// and choosen to make this fragile XOR-paint water-proof and thus contain some
+// information in this sense.
+// Someone thankfully expanded it to collect the SelectionRectangles when called with
+// the Region*, see GetSelectionRectangles below.
+void ImpEditView::DrawSelectionXOR( EditSelection aTmpSel, vcl::Region* pRegion, OutputDevice* pTargetDevice )
+{
+ if (hasEditViewCallbacks() && !pRegion)
+ {
// we are done, do *not* visualize self
return;
}
@@ -262,7 +282,7 @@ void ImpEditView::DrawSelection( EditSelection aTmpSel, vcl::Region* pRegion, Ou
pPolyPoly = new tools::PolyPolygon;
}
- DBG_ASSERT( !pEditEngine->IsIdleFormatterActive(), "DrawSelection: Not formatted!" );
+ DBG_ASSERT( !pEditEngine->IsIdleFormatterActive(), "DrawSelectionXOR: Not formatted!" );
aTmpSel.Adjust( pEditEngine->GetEditDoc() );
ContentNode* pStartNode = aTmpSel.Min().GetNode();
@@ -351,7 +371,7 @@ void ImpEditView::DrawSelection( EditSelection aTmpSel, vcl::Region* pRegion, Ou
if ( nTmpEndIndex > nEndIndex )
nTmpEndIndex = nEndIndex;
- DBG_ASSERT( nTmpEndIndex > nTmpStartIndex, "DrawSelection, Start >= End?" );
+ DBG_ASSERT( nTmpEndIndex > nTmpStartIndex, "DrawSelectionXOR, Start >= End?" );
long nX1 = pEditEngine->GetXPos(pTmpPortion, &rLine, nTmpStartIndex, true);
long nX2 = pEditEngine->GetXPos(pTmpPortion, &rLine, nTmpEndIndex);
@@ -477,10 +497,10 @@ void ImpEditView::DrawSelection( EditSelection aTmpSel, vcl::Region* pRegion, Ou
}
}
-void ImpEditView::GetSelectionRectangles(std::vector<tools::Rectangle>& rLogicRects)
+void ImpEditView::GetSelectionRectangles(EditSelection aTmpSel, std::vector<tools::Rectangle>& rLogicRects)
{
vcl::Region aRegion;
- DrawSelection(aEditSelection, &aRegion);
+ DrawSelectionXOR(aTmpSel, &aRegion);
aRegion.GetRegionRectangles(rLogicRects);
}
@@ -627,9 +647,9 @@ void ImpEditView::SetSelectionMode( EESelectionMode eNewMode )
{
if ( eSelectionMode != eNewMode )
{
- DrawSelection();
+ DrawSelectionXOR();
eSelectionMode = eNewMode;
- DrawSelection(); // redraw
+ DrawSelectionXOR(); // redraw
}
}
@@ -1397,9 +1417,9 @@ bool ImpEditView::IsWrongSpelledWord( const EditPaM& rPaM, bool bMarkIfWrong )
bIsWrong = rPaM.GetNode()->GetWrongList()->HasWrong( aSel.Min().GetIndex(), aSel.Max().GetIndex() );
if ( bIsWrong && bMarkIfWrong )
{
- DrawSelection();
+ DrawSelectionXOR();
SetEditSelection( aSel );
- DrawSelection();
+ DrawSelectionXOR();
}
}
return bIsWrong;
@@ -1420,9 +1440,9 @@ OUString ImpEditView::SpellIgnoreWord()
{
aWord = pEditEngine->pImpEditEngine->GetSelected( GetEditSelection() );
// And deselect
- DrawSelection();
+ DrawSelectionXOR();
SetEditSelection( EditSelection( aPaM, aPaM ) );
- DrawSelection();
+ DrawSelectionXOR();
}
if ( !aWord.isEmpty() )
@@ -1446,7 +1466,7 @@ OUString ImpEditView::SpellIgnoreWord()
void ImpEditView::DeleteSelected()
{
- DrawSelection();
+ DrawSelectionXOR();
pEditEngine->pImpEditEngine->UndoActionStart( EDITUNDO_DELETE );
@@ -1585,7 +1605,7 @@ void ImpEditView::Paste( css::uno::Reference< css::datatransfer::clipboard::XCli
EditSelection aSel( GetEditSelection() );
if ( aSel.HasRange() )
{
- DrawSelection();
+ DrawSelectionXOR();
aSel = pEditEngine->DeleteSelection(aSel);
}
@@ -1669,18 +1689,20 @@ bool ImpEditView::IsInSelection( const EditPaM& rPaM )
void ImpEditView::CreateAnchor()
{
pEditEngine->SetInSelectionMode(true);
- GetEditSelection().Min() = GetEditSelection().Max();
+ EditSelection aNewSelection(GetEditSelection());
+ aNewSelection.Min() = aNewSelection.Max();
+ SetEditSelection(aNewSelection);
+ // const_cast<EditPaM&>(GetEditSelection().Min()) = GetEditSelection().Max();
}
void ImpEditView::DeselectAll()
{
pEditEngine->SetInSelectionMode(false);
- DrawSelection();
- GetEditSelection().Min() = GetEditSelection().Max();
-
- // Selection is empty, still need to draw it due to new forward selection
- // functionality. When without that, nothing will be drawn (since it's empty)
- DrawSelection();
+ DrawSelectionXOR();
+ EditSelection aNewSelection(GetEditSelection());
+ aNewSelection.Min() = aNewSelection.Max();
+ SetEditSelection(aNewSelection);
+ // const_cast<EditPaM&>(GetEditSelection().Min()) = GetEditSelection().Max();
}
bool ImpEditView::IsSelectionAtPoint( const Point& rPosPixel )
@@ -1741,7 +1763,7 @@ bool ImpEditView::SetCursorAtPoint( const Point& rPointPixel )
}
else
{
- DrawSelection( aTmpNewSel );
+ DrawSelectionXOR( aTmpNewSel );
}
// set changed text selection
@@ -1849,8 +1871,8 @@ void ImpEditView::dragGestureRecognized(const css::datatransfer::dnd::DragGestur
pDragAndDropInfo->pField = pField;
ContentNode* pNode = pEditEngine->GetEditDoc().GetObject( nPara );
aCopySel = EditSelection( EditPaM( pNode, nPos ), EditPaM( pNode, nPos+1 ) );
- GetEditSelection() = aCopySel;
- DrawSelection();
+ SetEditSelection(aCopySel);
+ DrawSelectionXOR();
bool bGotoCursor = DoAutoScroll();
ShowCursor( bGotoCursor, /*bForceCursor=*/false );
}
@@ -1963,7 +1985,7 @@ void ImpEditView::dragDropEnd( const css::datatransfer::dnd::DragSourceDropEvent
}
}
- DrawSelection();
+ DrawSelectionXOR();
EditSelection aDelSel( pEditEngine->pImpEditEngine->CreateSel( aToBeDelSel ) );
DBG_ASSERT( !aDelSel.DbgIsBuggy( pEditEngine->GetEditDoc() ), "ToBeDel is buggy!" );
pEditEngine->DeleteSelection(aDelSel);
@@ -1973,7 +1995,7 @@ void ImpEditView::dragDropEnd( const css::datatransfer::dnd::DragSourceDropEvent
SetEditSelection( pEditEngine->pImpEditEngine->CreateSel( aNewSel ) );
}
pEditEngine->pImpEditEngine->FormatAndUpdate( pEditEngine->pImpEditEngine->GetActiveView() );
- DrawSelection();
+ DrawSelectionXOR();
}
else
{
@@ -2024,7 +2046,7 @@ void ImpEditView::drop( const css::datatransfer::dnd::DropTargetDropEvent& rDTDE
{
bChanges = true;
// remove Selection ...
- DrawSelection();
+ DrawSelectionXOR();
EditPaM aPaM( pDragAndDropInfo->aDropDest );
PasteOrDropInfos aPasteOrDropInfos;
diff --git a/editeng/source/editeng/impedit.hxx b/editeng/source/editeng/impedit.hxx
index 89cf8947d7c8..3c1d2e78a0c6 100644
--- a/editeng/source/editeng/impedit.hxx
+++ b/editeng/source/editeng/impedit.hxx
@@ -335,13 +335,14 @@ public:
long GetVisDocBottom() const { return aVisDocStartPos.Y() + ( !IsVertical() ? aOutArea.GetHeight() : aOutArea.GetWidth() ); }
tools::Rectangle GetVisDocArea() const;
- EditSelection& GetEditSelection() { return aEditSelection; }
+ const EditSelection& GetEditSelection() { return aEditSelection; }
void SetEditSelection( const EditSelection& rEditSelection );
bool HasSelection() const { return aEditSelection.HasRange(); }
- void DrawSelection() { DrawSelection( aEditSelection ); }
- void DrawSelection( EditSelection, vcl::Region* pRegion = nullptr, OutputDevice* pTargetDevice = nullptr );
- void GetSelectionRectangles(std::vector<tools::Rectangle>& rLogicRects);
+ void SelectionChanged();
+ void DrawSelectionXOR() { DrawSelectionXOR( aEditSelection ); }
+ void DrawSelectionXOR( EditSelection, vcl::Region* pRegion = nullptr, OutputDevice* pTargetDevice = nullptr );
+ void GetSelectionRectangles(EditSelection aTmpSel, std::vector<tools::Rectangle>& rLogicRects);
vcl::Window* GetWindow() const { return pOutWin; }
@@ -541,7 +542,7 @@ private:
// Methods...
- void CursorMoved( ContentNode* pPrevNode );
+ void CursorMoved( const ContentNode* pPrevNode );
void ParaAttribsChanged( ContentNode const * pNode );
void TextModified();
void CalcHeight( ParaPortion* pPortion );
diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx
index 7884d4ff887a..992913c03525 100644
--- a/editeng/source/editeng/impedit2.cxx
+++ b/editeng/source/editeng/impedit2.cxx
@@ -329,9 +329,9 @@ bool ImpEditEngine::MouseButtonDown( const MouseEvent& rMEvt, EditView* pView )
aSelEngine.CursorPosChanging( true, false );
EditSelection aNewSelection( SelectWord( aCurSel ) );
- pView->pImpEditView->DrawSelection();
+ pView->pImpEditView->DrawSelectionXOR();
pView->pImpEditView->SetEditSelection( aNewSelection );
- pView->pImpEditView->DrawSelection();
+ pView->pImpEditView->DrawSelectionXOR();
pView->ShowCursor();
}
else if ( rMEvt.GetClicks() == 3 )
@@ -342,9 +342,9 @@ bool ImpEditEngine::MouseButtonDown( const MouseEvent& rMEvt, EditView* pView )
EditSelection aNewSelection( aCurSel );
aNewSelection.Min().SetIndex( 0 );
aNewSelection.Max().SetIndex( aCurSel.Min().GetNode()->Len() );
- pView->pImpEditView->DrawSelection();
+ pView->pImpEditView->DrawSelectionXOR();
pView->pImpEditView->SetEditSelection( aNewSelection );
- pView->pImpEditView->DrawSelection();
+ pView->pImpEditView->DrawSelectionXOR();
pView->ShowCursor();
}
}
@@ -709,11 +709,13 @@ const SfxItemSet& ImpEditEngine::GetEmptyItemSet()
// MISC
-void ImpEditEngine::CursorMoved( ContentNode* pPrevNode )
+void ImpEditEngine::CursorMoved( const ContentNode* pPrevNode )
{
// Delete empty attributes, but only if paragraph is not empty!
- if ( pPrevNode->GetCharAttribs().HasEmptyAttribs() && pPrevNode->Len() )
- pPrevNode->GetCharAttribs().DeleteEmptyAttribs( aEditDoc.GetItemPool() );
+ if (pPrevNode->GetCharAttribs().HasEmptyAttribs() && pPrevNode->Len())
+ {
+ const_cast<ContentNode*>(pPrevNode)->GetCharAttribs().DeleteEmptyAttribs(aEditDoc.GetItemPool());
+ }
}
void ImpEditEngine::TextModified()
@@ -913,15 +915,27 @@ EditSelection ImpEditEngine::MoveCursor( const KeyEvent& rKeyEvent, EditView* pE
aSelEngine.SetCurView( pEditView );
aSelEngine.CursorPosChanging( bKeyModifySelection, aTranslatedKeyEvent.GetKeyCode().IsMod1() );
EditPaM aOldEnd( pEditView->pImpEditView->GetEditSelection().Max() );
- pEditView->pImpEditView->GetEditSelection().Max() = aPaM;
+
+ {
+ EditSelection aNewSelection(pEditView->pImpEditView->GetEditSelection());
+ aNewSelection.Max() = aPaM;
+ pEditView->pImpEditView->SetEditSelection(aNewSelection);
+ // const_cast<EditPaM&>(pEditView->pImpEditView->GetEditSelection().Max()) = aPaM;
+ }
+
if ( bKeyModifySelection )
{
// Then the selection is expanded ... or the whole selection is painted in case of tiled rendering.
EditSelection aTmpNewSel( comphelper::LibreOfficeKit::isActive() ? pEditView->pImpEditView->GetEditSelection().Min() : aOldEnd, aPaM );
- pEditView->pImpEditView->DrawSelection( aTmpNewSel );
+ pEditView->pImpEditView->DrawSelectionXOR( aTmpNewSel );
}
else
- pEditView->pImpEditView->GetEditSelection().Min() = aPaM;
+ {
+ EditSelection aNewSelection(pEditView->pImpEditView->GetEditSelection());
+ aNewSelection.Min() = aPaM;
+ pEditView->pImpEditView->SetEditSelection(aNewSelection);
+ // const_cast<EditPaM&>(pEditView->pImpEditView->GetEditSelection().Min()) = aPaM;
+ }
return pEditView->pImpEditView->GetEditSelection();
}
@@ -3428,12 +3442,12 @@ void ImpEditEngine::SetActiveView( EditView* pView )
return;
if ( pActiveView && pActiveView->HasSelection() )
- pActiveView->pImpEditView->DrawSelection();
+ pActiveView->pImpEditView->DrawSelectionXOR();
pActiveView = pView;
if ( pActiveView && pActiveView->HasSelection() )
- pActiveView->pImpEditView->DrawSelection();
+ pActiveView->pImpEditView->DrawSelectionXOR();
// NN: Quick fix for #78668#:
// When editing of a cell in Calc is ended, the edit engine is not deleted,
@@ -4292,7 +4306,7 @@ void ImpEditEngine::IndentBlock( EditView* pEditView, bool bRight )
aNewSel.nEndPos = 0;
}
- pEditView->pImpEditView->DrawSelection();
+ pEditView->pImpEditView->DrawSelectionXOR();
pEditView->pImpEditView->SetEditSelection(
pEditView->pImpEditView->GetEditSelection().Max() );
UndoActionStart( bRight ? EDITUNDO_INDENTBLOCK : EDITUNDO_UNINDENTBLOCK );
@@ -4328,7 +4342,7 @@ void ImpEditEngine::IndentBlock( EditView* pEditView, bool bRight )
if ( pLastNode->Len() < aNewSel.nEndPos )
aNewSel.nEndPos = pLastNode->Len();
pEditView->pImpEditView->SetEditSelection( CreateSel( aNewSel ) );
- pEditView->pImpEditView->DrawSelection();
+ pEditView->pImpEditView->DrawSelectionXOR();
pEditView->pImpEditView->ShowCursor( false, true );
}
}
diff --git a/editeng/source/editeng/impedit3.cxx b/editeng/source/editeng/impedit3.cxx
index e07312e4aa05..f46e14e0f0dd 100644
--- a/editeng/source/editeng/impedit3.cxx
+++ b/editeng/source/editeng/impedit3.cxx
@@ -3848,10 +3848,10 @@ void ImpEditEngine::Paint( ImpEditView* pView, const tools::Rectangle& rRect, Ou
else
pTarget->SetClipRegion();
- // In case of tiled rendering pass a region to DrawSelection(), so that
+ // In case of tiled rendering pass a region to DrawSelectionXOR(), so that
// selection callbacks are not emitted during every repaint.
vcl::Region aRegion;
- pView->DrawSelection(pView->GetEditSelection(), comphelper::LibreOfficeKit::isActive() ? &aRegion : nullptr, pTarget);
+ pView->DrawSelectionXOR(pView->GetEditSelection(), comphelper::LibreOfficeKit::isActive() ? &aRegion : nullptr, pTarget);
}
void ImpEditEngine::InsertContent( ContentNode* pNode, sal_Int32 nPos )
diff --git a/editeng/source/editeng/impedit4.cxx b/editeng/source/editeng/impedit4.cxx
index f4aba7df76aa..926949c77a65 100644
--- a/editeng/source/editeng/impedit4.cxx
+++ b/editeng/source/editeng/impedit4.cxx
@@ -1476,12 +1476,12 @@ EESpellState ImpEditEngine::Spell( EditView* pEditView, bool bMultipleDoc )
if ( !bMultipleDoc )
{
- pEditView->pImpEditView->DrawSelection();
+ pEditView->pImpEditView->DrawSelectionXOR();
if ( aCurSel.Max().GetIndex() > aCurSel.Max().GetNode()->Len() )
aCurSel.Max().SetIndex( aCurSel.Max().GetNode()->Len() );
aCurSel.Min() = aCurSel.Max();
pEditView->pImpEditView->SetEditSelection( aCurSel );
- pEditView->pImpEditView->DrawSelection();
+ pEditView->pImpEditView->DrawSelectionXOR();
pEditView->ShowCursor( true, false );
}
EESpellState eState = pSpellInfo->eState;
@@ -1599,12 +1599,12 @@ void ImpEditEngine::Convert( EditView* pEditView,
if ( !bMultipleDoc )
{
- pEditView->pImpEditView->DrawSelection();
+ pEditView->pImpEditView->DrawSelectionXOR();
if ( aCurSel.Max().GetIndex() > aCurSel.Max().GetNode()->Len() )
aCurSel.Max().SetIndex( aCurSel.Max().GetNode()->Len() );
aCurSel.Min() = aCurSel.Max();
pEditView->pImpEditView->SetEditSelection( aCurSel );
- pEditView->pImpEditView->DrawSelection();
+ pEditView->pImpEditView->DrawSelectionXOR();
pEditView->ShowCursor( true, false );
}
delete pConvInfo;
@@ -1802,9 +1802,9 @@ void ImpEditEngine::ImpConvert( OUString &rConvTxt, LanguageType &rConvTxtLang,
pConvInfo->aConvContinue = CreateEPaM( aCurSel.Max() );
}
- pEditView->pImpEditView->DrawSelection();
+ pEditView->pImpEditView->DrawSelectionXOR();
pEditView->pImpEditView->SetEditSelection( aCurSel );
- pEditView->pImpEditView->DrawSelection();
+ pEditView->pImpEditView->DrawSelectionXOR();
pEditView->ShowCursor( true, false );
rConvTxt = aRes;
@@ -1872,9 +1872,9 @@ Reference< XSpellAlternatives > ImpEditEngine::ImpSpell( EditView* pEditView )
pSpellInfo->eState = EESpellState::ErrorFound;
}
- pEditView->pImpEditView->DrawSelection();
+ pEditView->pImpEditView->DrawSelectionXOR();
pEditView->pImpEditView->SetEditSelection( aCurSel );
- pEditView->pImpEditView->DrawSelection();
+ pEditView->pImpEditView->DrawSelectionXOR();
pEditView->ShowCursor( true, false );
return xSpellAlt;
}
@@ -2464,9 +2464,9 @@ EESpellState ImpEditEngine::StartThesaurus( EditView* pEditView )
if (xDlg->Execute() == RET_OK)
{
// Replace Word...
- pEditView->pImpEditView->DrawSelection();
+ pEditView->pImpEditView->DrawSelectionXOR();
pEditView->pImpEditView->SetEditSelection( aCurSel );
- pEditView->pImpEditView->DrawSelection();
+ pEditView->pImpEditView->DrawSelectionXOR();
pEditView->InsertText(xDlg->GetWord());
pEditView->ShowCursor(true, false);
}
@@ -2506,7 +2506,7 @@ sal_Int32 ImpEditEngine::StartSearchAndReplace( EditView* pEditView, const SvxSe
SvxSearchItem aTmpItem( rSearchItem );
aTmpItem.SetBackward( false );
- pEditView->pImpEditView->DrawSelection();
+ pEditView->pImpEditView->DrawSelectionXOR();
aCurSel.Adjust( aEditDoc );
EditPaM aStartPaM = aTmpItem.GetSelection() ? aCurSel.Min() : aEditDoc.GetStartPaM();
@@ -2531,7 +2531,7 @@ sal_Int32 ImpEditEngine::StartSearchAndReplace( EditView* pEditView, const SvxSe
}
else
{
- pEditView->pImpEditView->DrawSelection();
+ pEditView->pImpEditView->DrawSelectionXOR();
pEditView->ShowCursor( true, false );
}
}
@@ -2554,7 +2554,7 @@ bool ImpEditEngine::Search( const SvxSearchItem& rSearchItem, EditView* pEditVie
bFound = ImpSearch( rSearchItem, aSel, aStartPaM, aFoundSel );
}
- pEditView->pImpEditView->DrawSelection();
+ pEditView->pImpEditView->DrawSelectionXOR();
if ( bFound )
{
// First, set the minimum, so the whole word is in the visible range.
@@ -2565,7 +2565,7 @@ bool ImpEditEngine::Search( const SvxSearchItem& rSearchItem, EditView* pEditVie
else
pEditView->pImpEditView->SetEditSelection( aSel.Max() );
- pEditView->pImpEditView->DrawSelection();
+ pEditView->pImpEditView->DrawSelectionXOR();
pEditView->ShowCursor( true, false );
return bFound;
}