summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/tiledrendering/tiledrendering.cxx48
-rw-r--r--sw/source/core/inc/UndoManager.hxx3
-rw-r--r--sw/source/core/undo/docundo.cxx8
3 files changed, 58 insertions, 1 deletions
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index 91f5f2235901..d6f95df456e7 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -32,6 +32,7 @@
#include <sfx2/viewsh.hxx>
#include <sfx2/bindings.hxx>
#include <sfx2/dispatch.hxx>
+#include <sfx2/viewfrm.hxx>
#include <sfx2/lokhelper.hxx>
#include <redline.hxx>
#include <IDocumentRedlineAccess.hxx>
@@ -94,7 +95,7 @@ public:
void testRedoRepairResult();
void testDisableUndoRepair();
void testAllTrackedChanges();
-
+ void testDocumentRepair();
CPPUNIT_TEST_SUITE(SwTiledRenderingTest);
CPPUNIT_TEST(testRegisterCallback);
@@ -141,6 +142,7 @@ public:
CPPUNIT_TEST(testRedoRepairResult);
CPPUNIT_TEST(testDisableUndoRepair);
CPPUNIT_TEST(testAllTrackedChanges);
+ CPPUNIT_TEST(testDocumentRepair);
CPPUNIT_TEST_SUITE_END();
@@ -1887,6 +1889,50 @@ void SwTiledRenderingTest::testAllTrackedChanges()
comphelper::LibreOfficeKit::setActive(false);
}
+void SwTiledRenderingTest::testDocumentRepair()
+{
+ comphelper::LibreOfficeKit::setActive();
+
+ // Create two views.
+ SwXTextDocument* pXTextDocument = createDoc("dummy.fodt");
+ // view #1
+ SfxViewShell* pView1 = SfxViewShell::Current();
+
+ // view #2
+ SfxLokHelper::createView();
+ SfxViewShell* pView2 = SfxViewShell::Current();
+ int nView2 = SfxLokHelper::getView();
+ CPPUNIT_ASSERT(pView1 != pView2);
+ {
+ std::unique_ptr<SfxPoolItem> pItem1;
+ std::unique_ptr<SfxPoolItem> pItem2;
+ pView1->GetViewFrame()->GetBindings().QueryState(SID_DOC_REPAIR, pItem1);
+ pView2->GetViewFrame()->GetBindings().QueryState(SID_DOC_REPAIR, pItem2);
+ CPPUNIT_ASSERT(dynamic_cast< const SfxBoolItem* >(pItem1.get()));
+ CPPUNIT_ASSERT(dynamic_cast< const SfxBoolItem* >(pItem2.get()));
+ CPPUNIT_ASSERT_EQUAL(false, dynamic_cast< const SfxBoolItem* >(pItem1.get())->GetValue());
+ CPPUNIT_ASSERT_EQUAL(false, dynamic_cast< const SfxBoolItem* >(pItem2.get())->GetValue());
+ }
+
+ // Insert a character in the second view.
+ SfxLokHelper::setView(nView2);
+ pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'u', 0);
+ pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'u', 0);
+ Scheduler::ProcessEventsToIdle();
+ {
+ std::unique_ptr<SfxPoolItem> pItem1;
+ std::unique_ptr<SfxPoolItem> pItem2;
+ pView1->GetViewFrame()->GetBindings().QueryState(SID_DOC_REPAIR, pItem1);
+ pView2->GetViewFrame()->GetBindings().QueryState(SID_DOC_REPAIR, pItem2);
+ CPPUNIT_ASSERT(dynamic_cast< const SfxBoolItem* >(pItem1.get()));
+ CPPUNIT_ASSERT(dynamic_cast< const SfxBoolItem* >(pItem2.get()));
+ CPPUNIT_ASSERT_EQUAL(true, dynamic_cast< const SfxBoolItem* >(pItem1.get())->GetValue());
+ CPPUNIT_ASSERT_EQUAL(true, dynamic_cast< const SfxBoolItem* >(pItem2.get())->GetValue());
+ }
+
+ comphelper::LibreOfficeKit::setActive(false);
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SwTiledRenderingTest);
diff --git a/sw/source/core/inc/UndoManager.hxx b/sw/source/core/inc/UndoManager.hxx
index 6064757c4bc0..b5c2b44e2eab 100644
--- a/sw/source/core/inc/UndoManager.hxx
+++ b/sw/source/core/inc/UndoManager.hxx
@@ -94,6 +94,9 @@ public:
SwNodes & GetUndoNodes();
void SetDocShell(SwDocShell* pDocShell);
+protected:
+ virtual void EmptyActionsChanged() override;
+
private:
IDocumentDrawModelAccess & m_rDrawModelAccess;
IDocumentRedlineAccess & m_rRedlineAccess;
diff --git a/sw/source/core/undo/docundo.cxx b/sw/source/core/undo/docundo.cxx
index 751115d22a59..3f6168b95d6d 100644
--- a/sw/source/core/undo/docundo.cxx
+++ b/sw/source/core/undo/docundo.cxx
@@ -639,6 +639,14 @@ bool UndoManager::Redo()
}
}
+void UndoManager::EmptyActionsChanged()
+{
+ if (m_pDocShell)
+ {
+ m_pDocShell->Broadcast(SfxHint(SfxHintId::DocumentRepair));
+ }
+}
+
/** N.B.: this does _not_ call SdrUndoManager::Repeat because it is not
possible to wrap a list action around it:
calling EnterListAction here will cause SdrUndoManager::Repeat