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>
This commit is contained in:
@@ -118,8 +118,12 @@ bool EditUndoManager::Redo()
|
|||||||
}
|
}
|
||||||
|
|
||||||
EditUndo::EditUndo(sal_uInt16 nI, EditEngine* pEE) :
|
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()
|
EditUndo::~EditUndo()
|
||||||
@@ -147,6 +151,11 @@ OUString EditUndo::GetComment() const
|
|||||||
return aComment;
|
return aComment;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sal_Int32 EditUndo::GetViewShellId() const
|
||||||
|
{
|
||||||
|
return mnViewShellId;
|
||||||
|
}
|
||||||
|
|
||||||
EditUndoDelContent::EditUndoDelContent(
|
EditUndoDelContent::EditUndoDelContent(
|
||||||
EditEngine* pEE, ContentNode* pNode, sal_Int32 nPortion) :
|
EditEngine* pEE, ContentNode* pNode, sal_Int32 nPortion) :
|
||||||
EditUndo(EDITUNDO_DELCONTENT, pEE),
|
EditUndo(EDITUNDO_DELCONTENT, pEE),
|
||||||
|
@@ -122,6 +122,11 @@ void ImpEditView::RegisterViewShell(OutlinerViewShell* pViewShell)
|
|||||||
mpViewShell = pViewShell;
|
mpViewShell = pViewShell;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const OutlinerViewShell* ImpEditView::GetViewShell() const
|
||||||
|
{
|
||||||
|
return mpViewShell;
|
||||||
|
}
|
||||||
|
|
||||||
void ImpEditView::SetEditSelection( const EditSelection& rEditSelection )
|
void ImpEditView::SetEditSelection( const EditSelection& rEditSelection )
|
||||||
{
|
{
|
||||||
// set state before notification
|
// set state before notification
|
||||||
|
@@ -369,6 +369,7 @@ public:
|
|||||||
|
|
||||||
/// Informs this edit view about which view shell contains it.
|
/// Informs this edit view about which view shell contains it.
|
||||||
void RegisterViewShell(OutlinerViewShell* pViewShell);
|
void RegisterViewShell(OutlinerViewShell* pViewShell);
|
||||||
|
const OutlinerViewShell* GetViewShell() const;
|
||||||
|
|
||||||
bool IsWrongSpelledWord( const EditPaM& rPaM, bool bMarkIfWrong );
|
bool IsWrongSpelledWord( const EditPaM& rPaM, bool bMarkIfWrong );
|
||||||
OUString SpellIgnoreWord();
|
OUString SpellIgnoreWord();
|
||||||
|
@@ -47,6 +47,7 @@ class EDITENG_DLLPUBLIC EditUndo : public SfxUndoAction
|
|||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
sal_uInt16 nId;
|
sal_uInt16 nId;
|
||||||
|
sal_Int32 mnViewShellId;
|
||||||
EditEngine* mpEditEngine;
|
EditEngine* mpEditEngine;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -60,6 +61,8 @@ public:
|
|||||||
|
|
||||||
virtual bool CanRepeat(SfxRepeatTarget&) const override;
|
virtual bool CanRepeat(SfxRepeatTarget&) const override;
|
||||||
virtual OUString GetComment() const override;
|
virtual OUString GetComment() const override;
|
||||||
|
/// See SfxUndoAction::GetViewShellId().
|
||||||
|
sal_Int32 GetViewShellId() const override;
|
||||||
virtual sal_uInt16 GetId() const override;
|
virtual sal_uInt16 GetId() const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -26,6 +26,7 @@
|
|||||||
#include <ndtxt.hxx>
|
#include <ndtxt.hxx>
|
||||||
#include <wrtsh.hxx>
|
#include <wrtsh.hxx>
|
||||||
#include <view.hxx>
|
#include <view.hxx>
|
||||||
|
#include <UndoManager.hxx>
|
||||||
#include <sfx2/viewsh.hxx>
|
#include <sfx2/viewsh.hxx>
|
||||||
#include <sfx2/lokhelper.hxx>
|
#include <sfx2/lokhelper.hxx>
|
||||||
|
|
||||||
@@ -59,6 +60,7 @@ public:
|
|||||||
void testViewLock();
|
void testViewLock();
|
||||||
void testTextEditViewInvalidations();
|
void testTextEditViewInvalidations();
|
||||||
void testUndoInvalidations();
|
void testUndoInvalidations();
|
||||||
|
void testShapeTextUndoShells();
|
||||||
|
|
||||||
CPPUNIT_TEST_SUITE(SwTiledRenderingTest);
|
CPPUNIT_TEST_SUITE(SwTiledRenderingTest);
|
||||||
CPPUNIT_TEST(testRegisterCallback);
|
CPPUNIT_TEST(testRegisterCallback);
|
||||||
@@ -84,6 +86,7 @@ public:
|
|||||||
CPPUNIT_TEST(testViewLock);
|
CPPUNIT_TEST(testViewLock);
|
||||||
CPPUNIT_TEST(testTextEditViewInvalidations);
|
CPPUNIT_TEST(testTextEditViewInvalidations);
|
||||||
CPPUNIT_TEST(testUndoInvalidations);
|
CPPUNIT_TEST(testUndoInvalidations);
|
||||||
|
CPPUNIT_TEST(testShapeTextUndoShells);
|
||||||
CPPUNIT_TEST_SUITE_END();
|
CPPUNIT_TEST_SUITE_END();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -890,6 +893,34 @@ void SwTiledRenderingTest::testUndoInvalidations()
|
|||||||
comphelper::LibreOfficeKit::setActive(false);
|
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_TEST_SUITE_REGISTRATION(SwTiledRenderingTest);
|
||||||
|
|
||||||
CPPUNIT_PLUGIN_IMPLEMENT();
|
CPPUNIT_PLUGIN_IMPLEMENT();
|
||||||
|
Reference in New Issue
Block a user