summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2016-08-29 12:32:51 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-08-30 09:49:53 +0200
commit078831670df5ed26b4b7bab4461b0abb7b465b67 (patch)
treefc5d6c011caba1f5279f83efd1de704cd0be6602
parentdea74fbbe14e04968a215ffcf2acb54ec24b708e (diff)
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 <vmiklos@collabora.co.uk> Tested-by: Jenkins <ci@libreoffice.org> (cherry picked from commit d017362bc68fe40c4bd79db76614d84aa9be913d)
-rw-r--r--sw/inc/redline.hxx2
-rw-r--r--sw/qa/extras/tiledrendering/tiledrendering.cxx33
-rw-r--r--sw/source/core/doc/DocumentRedlineManager.cxx1
3 files changed, 34 insertions, 2 deletions
diff --git a/sw/inc/redline.hxx b/sw/inc/redline.hxx
index b30e631a0c09..e51f25fe2a44 100644
--- a/sw/inc/redline.hxx
+++ b/sw/inc/redline.hxx
@@ -192,7 +192,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 );
@@ -289,6 +288,7 @@ public:
bool operator==( const SwRangeRedline& ) const;
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 e5d6f240e1d4..1eda2ad59fb2 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -70,6 +70,7 @@ public:
void testShapeTextUndoGroupShells();
void testTrackChanges();
void testTrackChangesCallback();
+ void testRedlineUpdateCallback();
CPPUNIT_TEST_SUITE(SwTiledRenderingTest);
CPPUNIT_TEST(testRegisterCallback);
@@ -104,6 +105,7 @@ public:
CPPUNIT_TEST(testShapeTextUndoGroupShells);
CPPUNIT_TEST(testTrackChanges);
CPPUNIT_TEST(testTrackChangesCallback);
+ CPPUNIT_TEST(testRedlineUpdateCallback);
CPPUNIT_TEST_SUITE_END();
private:
@@ -120,6 +122,7 @@ private:
int m_nSelectionAfterSearchResult;
int m_nInvalidations;
int m_nRedlineTableSizeChanged;
+ int m_nRedlineTableEntryModified;
};
SwTiledRenderingTest::SwTiledRenderingTest()
@@ -127,7 +130,8 @@ SwTiledRenderingTest::SwTiledRenderingTest()
m_nSelectionBeforeSearchResult(0),
m_nSelectionAfterSearchResult(0),
m_nInvalidations(0),
- m_nRedlineTableSizeChanged(0)
+ m_nRedlineTableSizeChanged(0),
+ m_nRedlineTableEntryModified(0)
{
}
@@ -206,6 +210,11 @@ void SwTiledRenderingTest::callbackImpl(int nType, const char* pPayload)
++m_nRedlineTableSizeChanged;
}
break;
+ case LOK_CALLBACK_REDLINE_TABLE_ENTRY_MODIFIED:
+ {
+ ++m_nRedlineTableEntryModified;
+ }
+ break;
}
}
@@ -1200,6 +1209,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<beans::XPropertySet> 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 34fe092cf226..ed98e0c1f799 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: