diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-07-26 11:02:38 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-07-26 10:34:07 +0000 |
commit | 9d91d371e92548c7f75a7d0155eecaf3769fdee6 (patch) | |
tree | 64741e1461c7eada1eb1be6c37600daebd7b4e1c | |
parent | bfb8b56e1d8e1241045b435c42856f5606faad4f (diff) |
svx lok: draw text edits in all views
Use case: a document has a shape with text, and two views. If one view
starts to edit the shape text, the model text is hidden (via
TextHierarchyEditPrimitive2D), and the in-progress text was painted
directly only in the view that edits it. The remaining views presented
the shape as if it had no text. This commit addresses the subset of this
use case when the views are already created and they already show the
same draw page.
Fix the problem by looking for other views showing the same draw page,
create a view of the text edit for them, and paint them in all views
after the own text edit is painted.
There is not much LOK-specific in this code, except that some extra code
would be needed to not paint the blinking cursor of the text edit in
other views, and then it could be enabled in the non-LOK case as well.
Change-Id: Ib3096a3369fa56663ee209794e102090d362de66
Reviewed-on: https://gerrit.libreoffice.org/27535
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Jenkins <ci@libreoffice.org>
-rw-r--r-- | svx/source/svdraw/svdedxv.cxx | 26 | ||||
-rw-r--r-- | svx/source/svdraw/svdpntv.cxx | 21 | ||||
-rw-r--r-- | sw/qa/extras/tiledrendering/tiledrendering.cxx | 35 |
3 files changed, 82 insertions, 0 deletions
diff --git a/svx/source/svdraw/svdedxv.cxx b/svx/source/svdraw/svdedxv.cxx index ab5416fbbd7d..9a4588060b71 100644 --- a/svx/source/svdraw/svdedxv.cxx +++ b/svx/source/svdraw/svdedxv.cxx @@ -64,6 +64,7 @@ #include <drawinglayer/processor2d/processor2dtools.hxx> #include <comphelper/lok.hxx> #include <sfx2/viewsh.hxx> +#include <svx/svdviter.hxx> #include <memory> @@ -813,6 +814,31 @@ bool SdrObjEditView::SdrBeginTextEdit( pTextEditOutliner->InsertView(pOutlView, (sal_uInt16)i); } } + + if (comphelper::LibreOfficeKit::isActive()) + { + // Register an outliner view for all other sdr views that + // show the same page, so that when the text edit changes, + // all interested windows get an invalidation. + SdrViewIter aIter(pObj->GetPage()); + for (SdrView* pView = aIter.FirstView(); pView; pView = aIter.NextView()) + { + if (pView == this) + continue; + + for(sal_uInt32 nViewPaintWindow = 0; nViewPaintWindow < pView->PaintWindowCount(); ++nViewPaintWindow) + { + SdrPaintWindow* pPaintWindow = pView->GetPaintWindow(nViewPaintWindow); + OutputDevice& rOutDev = pPaintWindow->GetOutputDevice(); + + if(&rOutDev != pWin && OUTDEV_WINDOW == rOutDev.GetOutDevType()) + { + OutlinerView* pOutlView = ImpMakeOutlinerView(static_cast<vcl::Window*>(&rOutDev), !bEmpty, nullptr); + pTextEditOutliner->InsertView(pOutlView); + } + } + } + } } pTextEditOutlinerView->ShowCursor(); diff --git a/svx/source/svdraw/svdpntv.cxx b/svx/source/svdraw/svdpntv.cxx index 1b5a20af652f..8b6dbdbd0806 100644 --- a/svx/source/svdraw/svdpntv.cxx +++ b/svx/source/svdraw/svdpntv.cxx @@ -60,6 +60,7 @@ #include <drawinglayer/primitive2d/metafileprimitive2d.hxx> #include <basegfx/matrix/b2dhommatrixtools.hxx> #include <comphelper/lok.hxx> +#include <svx/svdviter.hxx> using namespace ::com::sun::star; @@ -740,6 +741,26 @@ void SdrPaintView::EndCompleteRedraw(SdrPaintWindow& rPaintWindow, bool bPaintFo static_cast< SdrView* >(this)->TextEditDrawing(rPaintWindow); } + if (comphelper::LibreOfficeKit::isActive()) + { + // Look for active text edits in other views showing the same page, + // and show them as well. + if (SdrPageView* pPageView = GetSdrPageView()) + { + SdrViewIter aIter(pPageView->GetPage()); + for (SdrView* pView = aIter.FirstView(); pView; pView = aIter.NextView()) + { + if (pView == this) + continue; + + if (pView->IsTextEdit() && pView->GetSdrPageView()) + { + static_cast<SdrView*>(pView)->TextEditDrawing(rPaintWindow); + } + } + } + } + // draw Overlay, also to PreRender device if exists rPaintWindow.DrawOverlay(rPaintWindow.GetRedrawRegion()); diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx index 6c6854976e50..82d87f4f87f7 100644 --- a/sw/qa/extras/tiledrendering/tiledrendering.cxx +++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx @@ -57,6 +57,7 @@ public: void testViewCursorVisibility(); void testViewCursorCleanup(); void testViewLock(); + void testTextEditViewInvalidations(); CPPUNIT_TEST_SUITE(SwTiledRenderingTest); CPPUNIT_TEST(testRegisterCallback); @@ -80,6 +81,7 @@ public: CPPUNIT_TEST(testViewCursorVisibility); CPPUNIT_TEST(testViewCursorCleanup); CPPUNIT_TEST(testViewLock); + CPPUNIT_TEST(testTextEditViewInvalidations); CPPUNIT_TEST_SUITE_END(); private: @@ -819,6 +821,39 @@ void SwTiledRenderingTest::testViewLock() comphelper::LibreOfficeKit::setActive(false); } +void SwTiledRenderingTest::testTextEditViewInvalidations() +{ + // Load a document that has a shape and create two views. + comphelper::LibreOfficeKit::setActive(); + SwXTextDocument* pXTextDocument = createDoc("shape.fodt"); + ViewCallback aView1; + SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView1); + SfxLokHelper::createView(); + pXTextDocument->initializeForTiledRendering(uno::Sequence<beans::PropertyValue>()); + ViewCallback aView2; + SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView2); + + // Begin text edit in the second view. + SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell(); + SdrPage* pPage = pWrtShell->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0); + SdrObject* pObject = pPage->GetObj(0); + SdrView* pView = pWrtShell->GetDrawView(); + pWrtShell->GetView().BeginTextEdit(pObject, pView->GetSdrPageView(), pWrtShell->GetWin()); + pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'x', 0); + pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'x', 0); + + // Assert that both views are invalidated when pressing a key while in text edit. + aView1.m_bTilesInvalidated = false; + pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'y', 0); + pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'y', 0); + CPPUNIT_ASSERT(aView1.m_bTilesInvalidated); + + pWrtShell->EndTextEdit(); + mxComponent->dispose(); + mxComponent.clear(); + comphelper::LibreOfficeKit::setActive(false); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SwTiledRenderingTest); CPPUNIT_PLUGIN_IMPLEMENT(); |