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>
This commit is contained in:
Miklos Vajna
2016-08-29 12:32:51 +02:00
parent 412f514365
commit d017362bc6
3 changed files with 34 additions and 2 deletions

View File

@@ -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)

View File

@@ -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<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();

View File

@@ -1215,6 +1215,7 @@ bool DocumentRedlineManager::AppendRedline( SwRangeRedline* pNewRedl, bool bCall
}
delete pNewRedl;
pNewRedl = nullptr;
pRedl->MaybeNotifyModification();
break;
case POS_OUTSIDE: