summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2016-08-16 12:34:12 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-08-17 09:02:03 +0200
commitfeffeb503457c369e7d12b5ce151b6b588192e14 (patch)
treeb837cc9db6544007b47fcf6fc7c14040578c788f
parentf43be1f63880451e74281df89496c377c9395523 (diff)
editeng: introduce OutlinerViewShell::NotifyOtherViews()
This allows notifying other views about e.g. cursor position changes even if SfxLokHelper::notifyOtherViews() is not accessible from editeng. Change-Id: I921e97344ffe562109a221f241e70b3f68ee9aaf Reviewed-on: https://gerrit.libreoffice.org/28162 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Jenkins <ci@libreoffice.org> (cherry picked from commit 77235ac64be61afd707931675fec100c7c50d01c)
-rw-r--r--editeng/source/editeng/editview.cxx8
-rw-r--r--editeng/source/editeng/impedit.cxx2
-rw-r--r--include/editeng/outliner.hxx2
-rw-r--r--include/sfx2/viewsh.hxx2
-rw-r--r--sfx2/source/view/viewsh.cxx6
-rw-r--r--sw/qa/extras/tiledrendering/tiledrendering.cxx43
6 files changed, 61 insertions, 2 deletions
diff --git a/editeng/source/editeng/editview.cxx b/editeng/source/editeng/editview.cxx
index 8dea0b8bb5b5..5d64e4f81b93 100644
--- a/editeng/source/editeng/editview.cxx
+++ b/editeng/source/editeng/editview.cxx
@@ -404,7 +404,9 @@ void EditView::ShowCursor( bool bGotoCursor, bool bForceVisCursor, bool bActivat
if (pImpEditView->mpViewShell && !bActivate)
{
- pImpEditView->mpViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_CURSOR_VISIBLE, OString::boolean(true).getStr());
+ OString aPayload = OString::boolean(true);
+ pImpEditView->mpViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_CURSOR_VISIBLE, aPayload.getStr());
+ pImpEditView->mpViewShell->NotifyOtherViews(LOK_CALLBACK_VIEW_CURSOR_VISIBLE, "visible", aPayload);
}
}
}
@@ -415,7 +417,9 @@ void EditView::HideCursor(bool bDeactivate)
if (pImpEditView->mpViewShell && !bDeactivate)
{
- pImpEditView->mpViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_CURSOR_VISIBLE, OString::boolean(false).getStr());
+ OString aPayload = OString::boolean(false);
+ pImpEditView->mpViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_CURSOR_VISIBLE, aPayload.getStr());
+ pImpEditView->mpViewShell->NotifyOtherViews(LOK_CALLBACK_VIEW_CURSOR_VISIBLE, "visible", aPayload);
}
}
diff --git a/editeng/source/editeng/impedit.cxx b/editeng/source/editeng/impedit.cxx
index 01972d3a8fce..795a82453ef8 100644
--- a/editeng/source/editeng/impedit.cxx
+++ b/editeng/source/editeng/impedit.cxx
@@ -407,6 +407,7 @@ void ImpEditView::DrawSelection( EditSelection aTmpSel, vcl::Region* pRegion, Ou
}
mpViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_TEXT_SELECTION, sRectangle.getStr());
+ mpViewShell->NotifyOtherViews(LOK_CALLBACK_TEXT_VIEW_SELECTION, "selection", sRectangle);
pOutWin->Pop();
}
@@ -1004,6 +1005,7 @@ void ImpEditView::ShowCursor( bool bGotoCursor, bool bForceVisCursor )
OString sRect = aRect.toString();
mpViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR, sRect.getStr());
+ mpViewShell->NotifyOtherViews(LOK_CALLBACK_INVALIDATE_VIEW_CURSOR, "rectangle", sRect);
}
CursorDirection nCursorDir = CursorDirection::NONE;
diff --git a/include/editeng/outliner.hxx b/include/editeng/outliner.hxx
index 52383ac10b5a..171b8d04ceef 100644
--- a/include/editeng/outliner.hxx
+++ b/include/editeng/outliner.hxx
@@ -382,6 +382,8 @@ class SAL_NO_VTABLE SAL_DLLPUBLIC_RTTI OutlinerViewShell
public:
virtual void libreOfficeKitViewCallback(int nType, const char* pPayload) const = 0;
virtual sal_uInt32 GetViewShellId() const = 0;
+ /// Wrapper around SfxLokHelper::notifyOtherViews().
+ virtual void NotifyOtherViews(int nType, const OString& rKey, const OString& rPayload) = 0;
protected:
~OutlinerViewShell() throw () {}
diff --git a/include/sfx2/viewsh.hxx b/include/sfx2/viewsh.hxx
index 03b696c559a6..e4b21a22a439 100644
--- a/include/sfx2/viewsh.hxx
+++ b/include/sfx2/viewsh.hxx
@@ -336,6 +336,8 @@ public:
virtual void dumpAsXml(struct _xmlTextWriter* pWriter) const;
/// See OutlinerViewShell::GetViewShellId().
sal_uInt32 GetViewShellId() const override;
+ /// See OutlinerViewShell::NotifyOtherViews().
+ void NotifyOtherViews(int nType, const OString& rKey, const OString& rPayload) override;
};
diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx
index c8ce31afa57a..e7110998fef3 100644
--- a/sfx2/source/view/viewsh.cxx
+++ b/sfx2/source/view/viewsh.cxx
@@ -81,6 +81,7 @@
#include "workwin.hxx"
#include <sfx2/objface.hxx>
#include <sfx2/docfilt.hxx>
+#include <sfx2/lokhelper.hxx>
#include "openuriexternally.hxx"
#include <shellimpl.hxx>
@@ -1657,6 +1658,11 @@ sal_uInt32 SfxViewShell::GetViewShellId() const
return pImp->m_nViewShellId;
}
+void SfxViewShell::NotifyOtherViews(int nType, const OString& rKey, const OString& rPayload)
+{
+ SfxLokHelper::notifyOtherViews(this, nType, rKey, rPayload);
+}
+
void SfxViewShell::dumpAsXml(xmlTextWriterPtr pWriter) const
{
xmlTextWriterStartElement(pWriter, BAD_CAST("sfxViewShell"));
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index 72f6f1c3bcef..ce99ddc9e3de 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -55,6 +55,7 @@ public:
void testPageDownInvalidation();
void testPartHash();
void testViewCursors();
+ void testShapeViewCursors();
void testMissingInvalidation();
void testViewCursorVisibility();
void testViewCursorCleanup();
@@ -86,6 +87,7 @@ public:
CPPUNIT_TEST(testPageDownInvalidation);
CPPUNIT_TEST(testPartHash);
CPPUNIT_TEST(testViewCursors);
+ CPPUNIT_TEST(testShapeViewCursors);
CPPUNIT_TEST(testMissingInvalidation);
CPPUNIT_TEST(testViewCursorVisibility);
CPPUNIT_TEST(testViewCursorCleanup);
@@ -736,6 +738,47 @@ void SwTiledRenderingTest::testViewCursors()
comphelper::LibreOfficeKit::setActive(false);
}
+void SwTiledRenderingTest::testShapeViewCursors()
+{
+ comphelper::LibreOfficeKit::setActive();
+
+ // Load a document and create a view, so we have 2 ones.
+ SwXTextDocument* pXTextDocument = createDoc("shape.fodt");
+ ViewCallback aView1;
+ SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView1);
+ SfxLokHelper::createView();
+ ViewCallback aView2;
+ pXTextDocument->initializeForTiledRendering(uno::Sequence<beans::PropertyValue>());
+ SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView2);
+ SwWrtShell* pWrtShell2 = pXTextDocument->GetDocShell()->GetWrtShell();
+
+ // Start shape text in the second view.
+ SdrPage* pPage = pWrtShell2->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0);
+ SdrObject* pObject = pPage->GetObj(0);
+ SdrView* pView = pWrtShell2->GetDrawView();
+ pWrtShell2->GetView().BeginTextEdit(pObject, pView->GetSdrPageView(), pWrtShell2->GetWin());
+ pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'x', 0);
+ pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'x', 0);
+
+ // Press a key in the second view, while the first one observes this.
+ aView1.m_bOwnCursorInvalidated = false;
+ aView1.m_bViewCursorInvalidated = false;
+ aView2.m_bOwnCursorInvalidated = false;
+ aView2.m_bViewCursorInvalidated = false;
+ pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'y', 0);
+ pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'y', 0);
+ // Make sure that aView1 gets a view-only cursor notification, while
+ // aView2 gets a real cursor notification.
+ CPPUNIT_ASSERT(!aView1.m_bOwnCursorInvalidated);
+ CPPUNIT_ASSERT(aView1.m_bViewCursorInvalidated);
+ CPPUNIT_ASSERT(aView2.m_bOwnCursorInvalidated);
+ CPPUNIT_ASSERT(!aView2.m_bViewCursorInvalidated);
+ mxComponent->dispose();
+ mxComponent.clear();
+
+ comphelper::LibreOfficeKit::setActive(false);
+}
+
void SwTiledRenderingTest::testViewCursorVisibility()
{
comphelper::LibreOfficeKit::setActive();