From d017362bc68fe40c4bd79db76614d84aa9be913d Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Mon, 29 Aug 2016 12:32:51 +0200 Subject: [PATCH] sw lok: emit REDLINE_TABLE_ENTRY_MODIFIED when deleting self-added characters This doesn't work out of the box via SwRangeRedline::SetStart/End, because the range of the redline is adjusted when redlining is disabled by sw::DocumentRedlineManager::AppendRedline() when it compresses the insert and delete redlines into a single reduced insert redline, and then the redline is updated implicitly via SwIndex. Change-Id: I4b652348b256df75e4c774ea5f3fdd78f59deb01 Reviewed-on: https://gerrit.libreoffice.org/28454 Reviewed-by: Miklos Vajna Tested-by: Jenkins --- sw/inc/redline.hxx | 2 +- .../extras/tiledrendering/tiledrendering.cxx | 33 ++++++++++++++++++- sw/source/core/doc/DocumentRedlineManager.cxx | 1 + 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/sw/inc/redline.hxx b/sw/inc/redline.hxx index 55d4076d375a..d1dbd528c4d8 100644 --- a/sw/inc/redline.hxx +++ b/sw/inc/redline.hxx @@ -190,7 +190,6 @@ class SW_DLLPUBLIC SwRangeRedline : public SwPaM void CopyToSection(); void DelCopyOfSection(size_t nMyPos); void MoveFromSection(size_t nMyPos); - void MaybeNotifyModification(); public: SwRangeRedline( RedlineType_t eType, const SwPaM& rPam ); @@ -282,6 +281,7 @@ public: bool operator<( const SwRangeRedline& ) const; void dumpAsXml(struct _xmlTextWriter* pWriter) const; + void MaybeNotifyModification(); }; /// Base object for 'Redlines' that are not of 'Ranged' type (like table row insert\delete) diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx index 0df932d2f63e..ab9be3d5fef8 100644 --- a/sw/qa/extras/tiledrendering/tiledrendering.cxx +++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx @@ -69,6 +69,7 @@ public: void testShapeTextUndoGroupShells(); void testTrackChanges(); void testTrackChangesCallback(); + void testRedlineUpdateCallback(); CPPUNIT_TEST_SUITE(SwTiledRenderingTest); CPPUNIT_TEST(testRegisterCallback); @@ -103,6 +104,7 @@ public: CPPUNIT_TEST(testShapeTextUndoGroupShells); CPPUNIT_TEST(testTrackChanges); CPPUNIT_TEST(testTrackChangesCallback); + CPPUNIT_TEST(testRedlineUpdateCallback); CPPUNIT_TEST_SUITE_END(); private: @@ -119,6 +121,7 @@ private: int m_nSelectionAfterSearchResult; int m_nInvalidations; int m_nRedlineTableSizeChanged; + int m_nRedlineTableEntryModified; }; SwTiledRenderingTest::SwTiledRenderingTest() @@ -126,7 +129,8 @@ SwTiledRenderingTest::SwTiledRenderingTest() m_nSelectionBeforeSearchResult(0), m_nSelectionAfterSearchResult(0), m_nInvalidations(0), - m_nRedlineTableSizeChanged(0) + m_nRedlineTableSizeChanged(0), + m_nRedlineTableEntryModified(0) { } @@ -205,6 +209,11 @@ void SwTiledRenderingTest::callbackImpl(int nType, const char* pPayload) ++m_nRedlineTableSizeChanged; } break; + case LOK_CALLBACK_REDLINE_TABLE_ENTRY_MODIFIED: + { + ++m_nRedlineTableEntryModified; + } + break; } } @@ -1199,6 +1208,28 @@ void SwTiledRenderingTest::testTrackChangesCallback() comphelper::LibreOfficeKit::setActive(false); } +void SwTiledRenderingTest::testRedlineUpdateCallback() +{ + // Load a document. + comphelper::LibreOfficeKit::setActive(); + SwXTextDocument* pXTextDocument = createDoc("dummy.fodt"); + SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell(); + pWrtShell->GetSfxViewShell()->registerLibreOfficeKitViewCallback(&SwTiledRenderingTest::callback, this); + + // Turn on track changes, type "xx" and delete the second one. + uno::Reference xPropertySet(mxComponent, uno::UNO_QUERY); + xPropertySet->setPropertyValue("RecordChanges", uno::makeAny(true)); + pWrtShell->Insert("xx"); + m_nRedlineTableEntryModified = 0; + pWrtShell->DelLeft(); + + // Assert that we get exactly one notification about the redline update. + // This was 0, as LOK_CALLBACK_REDLINE_TABLE_ENTRY_MODIFIED wasn't sent. + CPPUNIT_ASSERT_EQUAL(1, m_nRedlineTableEntryModified); + + comphelper::LibreOfficeKit::setActive(false); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SwTiledRenderingTest); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/source/core/doc/DocumentRedlineManager.cxx b/sw/source/core/doc/DocumentRedlineManager.cxx index c879859506d5..267243709fee 100644 --- a/sw/source/core/doc/DocumentRedlineManager.cxx +++ b/sw/source/core/doc/DocumentRedlineManager.cxx @@ -1215,6 +1215,7 @@ bool DocumentRedlineManager::AppendRedline( SwRangeRedline* pNewRedl, bool bCall } delete pNewRedl; pNewRedl = nullptr; + pRedl->MaybeNotifyModification(); break; case POS_OUTSIDE: