summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2016-08-02 17:52:44 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-08-03 11:41:57 +0200
commit7e89f1ec496c51bf183437ad097c6ed33365b8d3 (patch)
tree6305a4c7c3e25e3953bb38844acfc62ab3e2999e /sw
parent3745f16b3139a45d93d694d22a3ca210480012fb (diff)
editeng: implement SfxUndoAction::GetViewShellId() interface in EditUndo
With this, e.g. inserting a character in a Writer shape text remembers its view shell. Reviewed-on: https://gerrit.libreoffice.org/27796 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Jenkins <ci@libreoffice.org> (cherry picked from commit b567278c4aa6e3dee331b60c71eb996babcc9d08) Change-Id: Ic82a3f45a66cf622496e3131390d365440dffb3b
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/tiledrendering/tiledrendering.cxx31
1 files changed, 31 insertions, 0 deletions
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index 6d65a8e25bb0..e4f95d8106be 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -27,6 +27,7 @@
#include <ndtxt.hxx>
#include <wrtsh.hxx>
#include <view.hxx>
+#include <UndoManager.hxx>
#include <sfx2/viewsh.hxx>
#include <sfx2/lokhelper.hxx>
@@ -60,6 +61,7 @@ public:
void testViewLock();
void testTextEditViewInvalidations();
void testUndoInvalidations();
+ void testShapeTextUndoShells();
CPPUNIT_TEST_SUITE(SwTiledRenderingTest);
CPPUNIT_TEST(testRegisterCallback);
@@ -85,6 +87,7 @@ public:
CPPUNIT_TEST(testViewLock);
CPPUNIT_TEST(testTextEditViewInvalidations);
CPPUNIT_TEST(testUndoInvalidations);
+ CPPUNIT_TEST(testShapeTextUndoShells);
CPPUNIT_TEST_SUITE_END();
private:
@@ -891,6 +894,34 @@ void SwTiledRenderingTest::testUndoInvalidations()
comphelper::LibreOfficeKit::setActive(false);
}
+void SwTiledRenderingTest::testShapeTextUndoShells()
+{
+ // Load a document and create a view.
+ comphelper::LibreOfficeKit::setActive();
+ SwXTextDocument* pXTextDocument = createDoc("shape.fodt");
+ sal_Int32 nView1 = SfxLokHelper::getView();
+
+ // Begin text edit.
+ 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);
+
+ // Make sure that the undo item remembers who created it.
+ SwDoc* pDoc = pXTextDocument->GetDocShell()->GetDoc();
+ sw::UndoManager& rUndoManager = pDoc->GetUndoManager();
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), rUndoManager.GetUndoActionCount());
+ // This was -1: the view shell id for the undo action wasn't known.
+ CPPUNIT_ASSERT_EQUAL(nView1, rUndoManager.GetUndoAction()->GetViewShellId());
+
+ mxComponent->dispose();
+ mxComponent.clear();
+ comphelper::LibreOfficeKit::setActive(false);
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SwTiledRenderingTest);
CPPUNIT_PLUGIN_IMPLEMENT();