summaryrefslogtreecommitdiff
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-02 17:33:17 +0000
commitb567278c4aa6e3dee331b60c71eb996babcc9d08 (patch)
treec459be957e7e3146f1854e72e755bcdfdca06743
parentdb686815b41c52598f0952613ff8c6be34b2f0e0 (diff)
editeng: implement SfxUndoAction::GetViewShellId() interface in EditUndo
With this, e.g. inserting a character in a Writer shape text remembers its view shell. Change-Id: Ic82a3f45a66cf622496e3131390d365440dffb3b Reviewed-on: https://gerrit.libreoffice.org/27796 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Jenkins <ci@libreoffice.org>
-rw-r--r--editeng/source/editeng/editundo.cxx11
-rw-r--r--editeng/source/editeng/impedit.cxx5
-rw-r--r--editeng/source/editeng/impedit.hxx1
-rw-r--r--include/editeng/editund2.hxx3
-rw-r--r--sw/qa/extras/tiledrendering/tiledrendering.cxx31
5 files changed, 50 insertions, 1 deletions
diff --git a/editeng/source/editeng/editundo.cxx b/editeng/source/editeng/editundo.cxx
index faea53b4acea..62d7e3fd8808 100644
--- a/editeng/source/editeng/editundo.cxx
+++ b/editeng/source/editeng/editundo.cxx
@@ -118,8 +118,12 @@ bool EditUndoManager::Redo()
}
EditUndo::EditUndo(sal_uInt16 nI, EditEngine* pEE) :
- nId(nI), mpEditEngine(pEE)
+ nId(nI), mnViewShellId(-1), mpEditEngine(pEE)
{
+ const EditView* pEditView = mpEditEngine ? mpEditEngine->GetActiveView() : nullptr;
+ const OutlinerViewShell* pViewShell = pEditView ? pEditView->GetImpEditView()->GetViewShell() : nullptr;
+ if (pViewShell)
+ mnViewShellId = pViewShell->GetViewShellId();
}
EditUndo::~EditUndo()
@@ -147,6 +151,11 @@ OUString EditUndo::GetComment() const
return aComment;
}
+sal_Int32 EditUndo::GetViewShellId() const
+{
+ return mnViewShellId;
+}
+
EditUndoDelContent::EditUndoDelContent(
EditEngine* pEE, ContentNode* pNode, sal_Int32 nPortion) :
EditUndo(EDITUNDO_DELCONTENT, pEE),
diff --git a/editeng/source/editeng/impedit.cxx b/editeng/source/editeng/impedit.cxx
index b3cf78477bbc..13a53acfc0f7 100644
--- a/editeng/source/editeng/impedit.cxx
+++ b/editeng/source/editeng/impedit.cxx
@@ -122,6 +122,11 @@ void ImpEditView::RegisterViewShell(OutlinerViewShell* pViewShell)
mpViewShell = pViewShell;
}
+const OutlinerViewShell* ImpEditView::GetViewShell() const
+{
+ return mpViewShell;
+}
+
void ImpEditView::SetEditSelection( const EditSelection& rEditSelection )
{
// set state before notification
diff --git a/editeng/source/editeng/impedit.hxx b/editeng/source/editeng/impedit.hxx
index 4dd335634195..cc7362e8e809 100644
--- a/editeng/source/editeng/impedit.hxx
+++ b/editeng/source/editeng/impedit.hxx
@@ -369,6 +369,7 @@ public:
/// Informs this edit view about which view shell contains it.
void RegisterViewShell(OutlinerViewShell* pViewShell);
+ const OutlinerViewShell* GetViewShell() const;
bool IsWrongSpelledWord( const EditPaM& rPaM, bool bMarkIfWrong );
OUString SpellIgnoreWord();
diff --git a/include/editeng/editund2.hxx b/include/editeng/editund2.hxx
index 449c4ad54e38..c6914d39e8b2 100644
--- a/include/editeng/editund2.hxx
+++ b/include/editeng/editund2.hxx
@@ -47,6 +47,7 @@ class EDITENG_DLLPUBLIC EditUndo : public SfxUndoAction
{
private:
sal_uInt16 nId;
+ sal_Int32 mnViewShellId;
EditEngine* mpEditEngine;
public:
@@ -60,6 +61,8 @@ public:
virtual bool CanRepeat(SfxRepeatTarget&) const override;
virtual OUString GetComment() const override;
+ /// See SfxUndoAction::GetViewShellId().
+ sal_Int32 GetViewShellId() const override;
virtual sal_uInt16 GetId() const override;
};
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index 79d3e18050dc..cfb1cbed5d79 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -26,6 +26,7 @@
#include <ndtxt.hxx>
#include <wrtsh.hxx>
#include <view.hxx>
+#include <UndoManager.hxx>
#include <sfx2/viewsh.hxx>
#include <sfx2/lokhelper.hxx>
@@ -59,6 +60,7 @@ public:
void testViewLock();
void testTextEditViewInvalidations();
void testUndoInvalidations();
+ void testShapeTextUndoShells();
CPPUNIT_TEST_SUITE(SwTiledRenderingTest);
CPPUNIT_TEST(testRegisterCallback);
@@ -84,6 +86,7 @@ public:
CPPUNIT_TEST(testViewLock);
CPPUNIT_TEST(testTextEditViewInvalidations);
CPPUNIT_TEST(testUndoInvalidations);
+ CPPUNIT_TEST(testShapeTextUndoShells);
CPPUNIT_TEST_SUITE_END();
private:
@@ -890,6 +893,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();