Kaydet (Commit) 4b850b20 authored tarafından László Németh's avatar László Németh

tdf#119824 fix undo/redo of overlapping redlines

Overlapping redlines (introduced by the
commit 9dbf817f
"handle scope of w:pPrChange and w:rPrChange properly"
for showing tracked DOCX paragraph formatting) resulted
losing of tracked deletion, ie. reappearing deleted
content using Redo (reported after fixing the broken
non-visible change tracking with overlapping redlines in
commit 694a6389
"tdf#119019 DOCX track changes: fix invisible delete
and insert").

Change-Id: I63fde7e89afde99cff242968d34cc70455c5c3c2
Reviewed-on: https://gerrit.libreoffice.org/64218
Tested-by: Jenkins
Reviewed-by: 's avatarLászló Németh <nemeth@numbertext.org>
üst 3f88f1a6
......@@ -19,6 +19,7 @@
#include <swdtflvr.hxx>
#include <wrtsh.hxx>
#include <redline.hxx>
#include <UndoManager.hxx>
namespace
{
......@@ -36,6 +37,7 @@ public:
void testTdf108687_tabstop();
void testTdf119571();
void testTdf119019();
void testTdf119824();
CPPUNIT_TEST_SUITE(SwUiWriterTest2);
CPPUNIT_TEST(testRedlineMoveInsertInDelete);
......@@ -45,6 +47,7 @@ public:
CPPUNIT_TEST(testTdf108687_tabstop);
CPPUNIT_TEST(testTdf119571);
CPPUNIT_TEST(testTdf119019);
CPPUNIT_TEST(testTdf119824);
CPPUNIT_TEST_SUITE_END();
private:
......@@ -273,6 +276,7 @@ void SwUiWriterTest2::testTdf119571()
void SwUiWriterTest2::testTdf119019()
{
// check handling of overlapping redlines
load(DATA_DIRECTORY, "tdf119019.docx");
SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
......@@ -304,6 +308,70 @@ void SwUiWriterTest2::testTdf119019()
CPPUNIT_ASSERT(!hasProperty(getRun(getParagraph(2), 1), "RedlineType"));
}
void SwUiWriterTest2::testTdf119824()
{
// check handling of overlapping redlines with Redo
SwDoc* pDoc = createDoc("tdf119019.docx");
SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
CPPUNIT_ASSERT(pTextDoc);
CPPUNIT_ASSERT_EQUAL(OUString("Pellentesque habitant morbi tristique senectus "
"et netus et malesuada fames ac turpis egestas. "
"Proin pharetra nonummy pede. Mauris et orci."),
getParagraph(3)->getString());
CPPUNIT_ASSERT_EQUAL(OUString(""), getRun(getParagraph(3), 1)->getString());
// third paragraph has got a tracked paragraph formatting at this point
CPPUNIT_ASSERT(hasProperty(getRun(getParagraph(3), 1), "RedlineType"));
// and a tracked text deletion at the beginning of the paragraph
CPPUNIT_ASSERT_EQUAL(OUString("Pellentesque habitant morbi tristique senectus "),
getRun(getParagraph(3), 3)->getString());
CPPUNIT_ASSERT_EQUAL(OUString(""), getRun(getParagraph(3), 2)->getString());
CPPUNIT_ASSERT(hasProperty(getRun(getParagraph(3), 2), "RedlineType"));
// delete last word of the third paragraph to remove tracked paragraph formatting
// of this paragraph to track and show word deletion correctly.
SwWrtShell* pWrtShell = pTextDoc->GetDocShell()->GetWrtShell();
pWrtShell->Down(/*bSelect=*/false);
pWrtShell->Down(/*bSelect=*/false);
pWrtShell->Down(/*bSelect=*/false);
pWrtShell->Down(/*bSelect=*/false);
pWrtShell->EndPara(/*bSelect=*/false);
pWrtShell->Left(CRSR_SKIP_CHARS, /*bSelect=*/true, 5, /*bBasicCall=*/false);
rtl::Reference<SwTransferable> pTransfer = new SwTransferable(*pWrtShell);
pTransfer->Cut();
// check tracking of the new text deletion
CPPUNIT_ASSERT_EQUAL(OUString("orci."), getRun(getParagraph(3), 7)->getString());
CPPUNIT_ASSERT_EQUAL(OUString(""), getRun(getParagraph(3), 6)->getString());
CPPUNIT_ASSERT(hasProperty(getRun(getParagraph(3), 6), "RedlineType"));
// make sure that the tracked paragraph formatting is removed (tracked deletion is in the second run)
CPPUNIT_ASSERT_EQUAL(OUString("Pellentesque habitant morbi tristique senectus "),
getRun(getParagraph(3), 2)->getString());
CPPUNIT_ASSERT_EQUAL(OUString(""), getRun(getParagraph(3), 1)->getString());
CPPUNIT_ASSERT(hasProperty(getRun(getParagraph(3), 1), "RedlineType"));
// tdf#119824 check redo
sw::UndoManager& rUndoManager = pDoc->GetUndoManager();
rUndoManager.Undo();
rUndoManager.Undo();
rUndoManager.Redo();
rUndoManager.Redo();
// check again the first tracked text deletion (we lost this before the redo fix)
CPPUNIT_ASSERT_EQUAL(OUString("Pellentesque habitant morbi tristique senectus "),
getRun(getParagraph(3), 2)->getString());
CPPUNIT_ASSERT_EQUAL(OUString(""), getRun(getParagraph(3), 1)->getString());
CPPUNIT_ASSERT(hasProperty(getRun(getParagraph(3), 1), "RedlineType"));
// check redo of the new tracked text deletion
CPPUNIT_ASSERT_EQUAL(OUString("orci."), getRun(getParagraph(3), 7)->getString());
CPPUNIT_ASSERT_EQUAL(OUString(""), getRun(getParagraph(3), 6)->getString());
CPPUNIT_ASSERT(hasProperty(getRun(getParagraph(3), 6), "RedlineType"));
}
CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest2);
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -637,25 +637,39 @@ namespace
++n;
}
for( ; n < rArr.size(); ++n )
// tdf#119824 first we will accept only overlapping paragraph format changes
// in the first loop to avoid potential content changes during Redo
bool bHasParagraphFormatChange = false;
for( int m = 0 ; m < 2 && !bHasParagraphFormatChange; ++m )
{
SwRangeRedline* pTmp = rArr[ n ];
if( pTmp->HasMark() && pTmp->IsVisible() )
for(SwRedlineTable::size_type o = n ; o < rArr.size(); ++o )
{
if( *pTmp->End() <= *pEnd )
{
if( (*fn_AcceptReject)( rArr, n, bCallDelete, nullptr, nullptr ))
nCount++;
}
else
SwRangeRedline* pTmp = rArr[ o ];
if( pTmp->HasMark() && pTmp->IsVisible() )
{
if( *pTmp->Start() < *pEnd )
if( *pTmp->End() <= *pEnd )
{
// Only revoke the partial selection
if( (*fn_AcceptReject)( rArr, n, bCallDelete, pStt, pEnd ))
if( (m > 0 || nsRedlineType_t::REDLINE_PARAGRAPH_FORMAT == pTmp->GetType()) &&
(*fn_AcceptReject)( rArr, o, bCallDelete, nullptr, nullptr ))
{
bHasParagraphFormatChange = true;
nCount++;
}
}
else
{
if( *pTmp->Start() < *pEnd )
{
// Only revoke the partial selection
if( (m > 0 || nsRedlineType_t::REDLINE_PARAGRAPH_FORMAT == pTmp->GetType()) &&
(*fn_AcceptReject)( rArr, o, bCallDelete, pStt, pEnd ))
{
bHasParagraphFormatChange = true;
nCount++;
}
}
break;
}
break;
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment