editeng/source/editeng/editview.cxx | 7 +++++++ editeng/source/editeng/impedit.cxx | 17 +++++++++++++---- include/editeng/editview.hxx | 2 ++ sw/qa/extras/tiledrendering/tiledrendering.cxx | 12 ++++++++++++ sw/source/core/crsr/crsrsh.cxx | 3 +++ 5 files changed, 37 insertions(+), 4 deletions(-)
New commits: commit 2ea385a54b53797ab3960869012f3ce3268eab2c Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Tue Sep 13 16:49:03 2016 +0200 sw draw text: emit LOK_CALLBACK_TEXT_VIEW_SELECTION from registerCallback() With this, in case the first view has an active text edit selection and a new view is created, then the text selection is instantly visible in the second view, even if the first view's text selection does not change later. Change-Id: I3255febd5d65d6576ddbc57cf96836bdf0b06a72 diff --git a/editeng/source/editeng/editview.cxx b/editeng/source/editeng/editview.cxx index f7f01f1..4915078 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 c0d9201..b04a491 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 df54444..0f3c2de 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 0424fea..eeef56d 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 fabf153..f14f617 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 { _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits