summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--editeng/source/editeng/editview.cxx7
-rw-r--r--editeng/source/editeng/impedit.cxx17
-rw-r--r--include/editeng/editview.hxx2
-rw-r--r--sw/qa/extras/tiledrendering/tiledrendering.cxx12
-rw-r--r--sw/source/core/crsr/crsrsh.cxx3
5 files changed, 37 insertions, 4 deletions
diff --git a/editeng/source/editeng/editview.cxx b/editeng/source/editeng/editview.cxx
index f7f01f154af5..491507820060 100644
--- a/editeng/source/editeng/editview.cxx
+++ b/editeng/source/editeng/editview.cxx
@@ -1353,4 +1353,11 @@ void EditView::SetCursorLogicPosition(const Point& rPosition, bool bPoint, bool
ShowCursor(/*bGotoCursor=*/false);
}
+void EditView::DrawSelection(OutlinerViewShell* pOtherShell)
+{
+ pImpEditView->RegisterOtherShell(pOtherShell);
+ pImpEditView->DrawSelection();
+ pImpEditView->RegisterOtherShell(nullptr);
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/editeng/source/editeng/impedit.cxx b/editeng/source/editeng/impedit.cxx
index c0d920197a40..b04a4918e5ba 100644
--- a/editeng/source/editeng/impedit.cxx
+++ b/editeng/source/editeng/impedit.cxx
@@ -377,8 +377,8 @@ void ImpEditView::DrawSelection( EditSelection aTmpSel, vcl::Region* pRegion, Ou
aOrigin = pOutWin->GetMapMode().GetOrigin();
OString sRectangle;
- // If we are not in selection mode, then the exported selection should be empty.
- if (pEditEngine->pImpEditEngine->IsInSelectionMode())
+ // If we are not in selection mode, then the exported own selection should be empty.
+ if (pEditEngine->pImpEditEngine->IsInSelectionMode() || mpOtherShell)
{
std::vector<Rectangle> aRectangles;
pRegion->GetRegionRectangles(aRectangles);
@@ -413,8 +413,17 @@ void ImpEditView::DrawSelection( EditSelection aTmpSel, vcl::Region* pRegion, Ou
sRectangle = comphelper::string::join("; ", v);
}
- mpViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_TEXT_SELECTION, sRectangle.getStr());
- mpViewShell->NotifyOtherViews(LOK_CALLBACK_TEXT_VIEW_SELECTION, "selection", sRectangle);
+ if (mpOtherShell)
+ {
+ // An other shell wants to know about our existing selection.
+ if (mpViewShell != mpOtherShell)
+ mpViewShell->NotifyOtherView(mpOtherShell, LOK_CALLBACK_TEXT_VIEW_SELECTION, "selection", sRectangle);
+ }
+ else
+ {
+ mpViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_TEXT_SELECTION, sRectangle.getStr());
+ mpViewShell->NotifyOtherViews(LOK_CALLBACK_TEXT_VIEW_SELECTION, "selection", sRectangle);
+ }
pOutWin->Pop();
}
diff --git a/include/editeng/editview.hxx b/include/editeng/editview.hxx
index df544449a5f3..0f3c2de9bba8 100644
--- a/include/editeng/editview.hxx
+++ b/include/editeng/editview.hxx
@@ -260,6 +260,8 @@ public:
bool bIsParaText );
/// Allows adjusting the point or mark of the selection to a document coordinate.
void SetCursorLogicPosition(const Point& rPosition, bool bPoint, bool bClearMark);
+ /// Trigger selection drawing callback in pOtherShell based on our shell's selection state.
+ void DrawSelection(OutlinerViewShell* pOtherShell);
};
#endif // INCLUDED_EDITENG_EDITVIEW_HXX
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index 0424fea85921..eeef56d816c0 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -1194,16 +1194,28 @@ void SwTiledRenderingTest::testShapeTextUndoGroupShells()
// This was -1: the view shell id for the (top) undo list action wasn't known.
CPPUNIT_ASSERT_EQUAL(nView1, rUndoManager.GetUndoAction()->GetViewShellId());
+ // Create an editeng text selection in the first view.
+ EditView& rEditView = pView->GetTextEditOutlinerView()->GetEditView();
+ pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'x', 0);
+ pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'x', 0);
+ // 0th para, 0th char -> 0th para, 1st char.
+ ESelection aWordSelection(0, 0, 0, 1);
+ rEditView.SetSelection(aWordSelection);
+
// Create a second view, and make sure that the new view sees the same
// cursor position as the old one.
SfxLokHelper::createView();
pXTextDocument->initializeForTiledRendering({});
ViewCallback aView2;
aView2.m_aViewCursor = Rectangle();
+ aView2.m_bViewSelectionSet = false;
SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView2);
// Difference was 935 twips, the new view didn't see the editeng cursor of
// the old one. The new difference should be <1px, but here we deal with twips.
CPPUNIT_ASSERT(std::abs(aView1.m_aOwnCursor.Top() - aView2.m_aViewCursor.Top()) < 10);
+ // This was false, editeng text selection of the first view wasn't noticed
+ // by the second view.
+ CPPUNIT_ASSERT(aView2.m_bViewSelectionSet);
mxComponent->dispose();
mxComponent.clear();
diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx
index fabf1533e3d0..f14f6177178e 100644
--- a/sw/source/core/crsr/crsrsh.cxx
+++ b/sw/source/core/crsr/crsrsh.cxx
@@ -1198,10 +1198,13 @@ void SwCursorShell::NotifyCursor(SfxViewShell* pOtherShell) const
auto pView = const_cast<SdrView*>(GetDrawView());
if (pView->GetTextEditObject())
{
+ // Blinking cursor.
EditView& rEditView = pView->GetTextEditOutlinerView()->GetEditView();
rEditView.RegisterOtherShell(pOtherShell);
rEditView.ShowCursor();
rEditView.RegisterOtherShell(nullptr);
+ // Text selection, if any.
+ rEditView.DrawSelection(pOtherShell);
}
else
{