summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2016-07-26 11:02:38 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-07-27 10:49:54 +0200
commit1a90cfa9cb478a4a4cca9b2fbee4ba5c20b35d52 (patch)
treeb9924f050df9343eb08dec41c502c355c032f291
parenta6e4d41bab2469c1b36384b6384a99287bffb926 (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> (cherry picked from commit 9d91d371e92548c7f75a7d0155eecaf3769fdee6)
-rw-r--r--svx/source/svdraw/svdedxv.cxx26
-rw-r--r--svx/source/svdraw/svdpntv.cxx21
-rw-r--r--sw/qa/extras/tiledrendering/tiledrendering.cxx35
3 files changed, 82 insertions, 0 deletions
diff --git a/svx/source/svdraw/svdedxv.cxx b/svx/source/svdraw/svdedxv.cxx
index ac38317c1d81..6467463e5a03 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>
@@ -814,6 +815,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 acdd00388a21..78fd41f45e74 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;
@@ -749,6 +750,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 9c7ae3399031..5a379bd3b10d 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -58,6 +58,7 @@ public:
void testViewCursorVisibility();
void testViewCursorCleanup();
void testViewLock();
+ void testTextEditViewInvalidations();
CPPUNIT_TEST_SUITE(SwTiledRenderingTest);
CPPUNIT_TEST(testRegisterCallback);
@@ -81,6 +82,7 @@ public:
CPPUNIT_TEST(testViewCursorVisibility);
CPPUNIT_TEST(testViewCursorCleanup);
CPPUNIT_TEST(testViewLock);
+ CPPUNIT_TEST(testTextEditViewInvalidations);
CPPUNIT_TEST_SUITE_END();
private:
@@ -820,6 +822,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();