[Libreoffice-commits] core.git: editeng/source sw/qa
Miklos Vajna
vmiklos at collabora.co.uk
Tue Aug 2 18:58:28 UTC 2016
editeng/source/editeng/impedit.hxx | 2 +
editeng/source/editeng/impedit5.cxx | 16 ++++++++++--
sw/qa/extras/tiledrendering/tiledrendering.cxx | 32 +++++++++++++++++++++++++
3 files changed, 48 insertions(+), 2 deletions(-)
New commits:
commit c86e89c5bb040786193f7b8bba8516ffa706a14a
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Tue Aug 2 19:35:05 2016 +0200
editeng: track view shells in SfxListUndoActions
This is needed for e.g. tracking deletions by backspace in Writer shape
text.
Change-Id: I6f873872566313096c2c57f4a13ac2f1db67e77d
Reviewed-on: https://gerrit.libreoffice.org/27807
Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
Tested-by: Jenkins <ci at libreoffice.org>
diff --git a/editeng/source/editeng/impedit.hxx b/editeng/source/editeng/impedit.hxx
index cc7362e..f74d05a 100644
--- a/editeng/source/editeng/impedit.hxx
+++ b/editeng/source/editeng/impedit.hxx
@@ -685,6 +685,8 @@ private:
void ImplUpdateOverflowingLineNum( sal_uInt32, sal_uInt32, sal_uInt32 );
SpellInfo * CreateSpellInfo( bool bMultipleDocs );
+ /// Obtains a view shell ID from the active EditView.
+ sal_Int32 CreateViewShellId();
ImpEditEngine(EditEngine* pEditEngine, SfxItemPool* pPool);
void InitDoc(bool bKeepParaAttribs);
diff --git a/editeng/source/editeng/impedit5.cxx b/editeng/source/editeng/impedit5.cxx
index 4dc34fc..e360c0a 100644
--- a/editeng/source/editeng/impedit5.cxx
+++ b/editeng/source/editeng/impedit5.cxx
@@ -222,11 +222,23 @@ EditUndoSetAttribs* ImpEditEngine::CreateAttribUndo( EditSelection aSel, const S
return pUndo;
}
+sal_Int32 ImpEditEngine::CreateViewShellId()
+{
+ sal_Int32 nRet = -1;
+
+ const EditView* pEditView = pEditEngine ? pEditEngine->GetActiveView() : nullptr;
+ const OutlinerViewShell* pViewShell = pEditView ? pEditView->GetImpEditView()->GetViewShell() : nullptr;
+ if (pViewShell)
+ nRet = pViewShell->GetViewShellId();
+
+ return nRet;
+}
+
void ImpEditEngine::UndoActionStart( sal_uInt16 nId, const ESelection& aSel )
{
if ( IsUndoEnabled() && !IsInUndo() )
{
- GetUndoManager().EnterListAction( GetEditEnginePtr()->GetUndoComment( nId ), OUString(), nId, -1 );
+ GetUndoManager().EnterListAction( GetEditEnginePtr()->GetUndoComment( nId ), OUString(), nId, CreateViewShellId() );
DBG_ASSERT( !pUndoMarkSelection, "UndoAction SelectionMarker?" );
pUndoMarkSelection = new ESelection( aSel );
}
@@ -236,7 +248,7 @@ void ImpEditEngine::UndoActionStart( sal_uInt16 nId )
{
if ( IsUndoEnabled() && !IsInUndo() )
{
- GetUndoManager().EnterListAction( GetEditEnginePtr()->GetUndoComment( nId ), OUString(), nId, -1 );
+ GetUndoManager().EnterListAction( GetEditEnginePtr()->GetUndoComment( nId ), OUString(), nId, CreateViewShellId() );
DBG_ASSERT( !pUndoMarkSelection, "UndoAction SelectionMarker?" );
}
}
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index cfb1cbe..b2b97bd 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -61,6 +61,7 @@ public:
void testTextEditViewInvalidations();
void testUndoInvalidations();
void testShapeTextUndoShells();
+ void testShapeTextUndoGroupShells();
CPPUNIT_TEST_SUITE(SwTiledRenderingTest);
CPPUNIT_TEST(testRegisterCallback);
@@ -87,6 +88,7 @@ public:
CPPUNIT_TEST(testTextEditViewInvalidations);
CPPUNIT_TEST(testUndoInvalidations);
CPPUNIT_TEST(testShapeTextUndoShells);
+ CPPUNIT_TEST(testShapeTextUndoGroupShells);
CPPUNIT_TEST_SUITE_END();
private:
@@ -921,6 +923,36 @@ void SwTiledRenderingTest::testShapeTextUndoShells()
comphelper::LibreOfficeKit::setActive(false);
}
+void SwTiledRenderingTest::testShapeTextUndoGroupShells()
+{
+ // 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);
+ pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, awt::Key::BACKSPACE);
+ pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::BACKSPACE);
+
+ // 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>(2), rUndoManager.GetUndoActionCount());
+ // This was -1: the view shell id for the (top) undo list 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();
More information about the Libreoffice-commits
mailing list