[Libreoffice-commits] core.git: sw/qa sw/source
László Németh (via logerrit)
logerrit at kemper.freedesktop.org
Thu Jan 14 17:19:13 UTC 2021
sw/qa/extras/uiwriter/data2/tdf39721.fodt | 42 ++++++++++++++++++++++
sw/qa/extras/uiwriter/uiwriter2.cxx | 57 ++++++++++++++++++++++++++++++
sw/source/core/doc/docnum.cxx | 3 +
3 files changed, 101 insertions(+), 1 deletion(-)
New commits:
commit b5ab4836c03e9428aff6a48843f2a054ceff0f85
Author: László Németh <nemeth at numbertext.org>
AuthorDate: Wed Jan 6 18:10:39 2021 +0100
Commit: László Németh <nemeth at numbertext.org>
CommitDate: Thu Jan 14 18:18:36 2021 +0100
tdf#39721 sw change tracking: fix move down
When moving list items by Move Down (see Bullets
and Numbering toolbar) to a non-content node (e.g.
tables, images or end of the document), tracked
deletions of the inserted paragraphs reappeared
as non-deleted text.
Note: disable unit test on Windows because of
a not reproducable problem of the Jenkins build
(moreover, reverting the patch, and modifying the
unit test according to the revert has still resulted
the same problem on the Windows test machine).
Change-Id: I3fb49061a81f832e1070da0f78cf7c5b3bd7d2c3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108888
Tested-by: Jenkins
Reviewed-by: László Németh <nemeth at numbertext.org>
diff --git a/sw/qa/extras/uiwriter/data2/tdf39721.fodt b/sw/qa/extras/uiwriter/data2/tdf39721.fodt
new file mode 100644
index 000000000000..1acf06c5e2a5
--- /dev/null
+++ b/sw/qa/extras/uiwriter/data2/tdf39721.fodt
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<office:document xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:officeooo="http://openoffice.org/2009/office" office:version="1.2" office:mimetype="application/vnd.oasis.opendocument.text" xmlns:dc="http://purl.org/dc/elements/1.1/">
+ <office:styles>
+ <style:style style:name="Standard" style:family="paragraph" style:class="text"/>
+ <style:default-style style:family="paragraph">
+ <style:text-properties fo:language="en" fo:country="US"/>
+ </style:default-style>
+ </office:styles>
+ <office:body>
+ <office:text>
+ <text:tracked-changes text:track-changes="false">
+ <text:changed-region xml:id="ct94454449144064" text:id="ct94454449144064">
+ <text:deletion>
+ <office:change-info>
+ <dc:creator>Unknown Author</dc:creator>
+ <dc:date>2021-01-06T16:18:57</dc:date>
+ </office:change-info>
+ </text:deletion>
+ </text:changed-region>
+ <text:changed-region xml:id="ct94454455394000" text:id="ct94454455394000">
+ <text:deletion>
+ <office:change-info>
+ <dc:creator>Unknown Author</dc:creator>
+ <dc:date>2021-01-06T16:20:17</dc:date>
+ </office:change-info>
+ </text:deletion>
+ </text:changed-region>
+ </text:tracked-changes>
+ <text:list xml:id="list627175737" text:style-name="L3">
+ <text:list-item>
+ <text:p text:style-name="P1">Lorem<text:change-start text:change-id="ct94454449144064"/> ipsu<text:change-end text:change-id="ct94454449144064"/>m</text:p>
+ </text:list-item>
+ <text:list-item>
+ <text:p text:style-name="P1">dol<text:change-start text:change-id="ct94454455394000"/>or <text:change-end text:change-id="ct94454455394000"/>sit</text:p>
+ </text:list-item>
+ <text:list-item>
+ <text:p text:style-name="P1">amet.</text:p>
+ </text:list-item>
+ </text:list>
+ </office:text>
+ </office:body>
+</office:document>
diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx
index 7605d8d5acaf..e745fbf68f0e 100644
--- a/sw/qa/extras/uiwriter/uiwriter2.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter2.cxx
@@ -603,6 +603,63 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf131912)
CPPUNIT_ASSERT_EQUAL(OUString("foo"), pWrtShell->GetCursor()->GetText());
}
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf39721)
+{
+// FIXME: disabled on Windows because of a not reproducable problem (not related to the patch)
+#if !defined(_WIN32)
+ // check move down with redlining
+ load(DATA_DIRECTORY, "tdf39721.fodt");
+
+ SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
+ CPPUNIT_ASSERT(pTextDoc);
+
+ //turn on red-lining and show changes
+ SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc();
+ pDoc->getIDocumentRedlineAccess().SetRedlineFlags(RedlineFlags::On | RedlineFlags::ShowDelete
+ | RedlineFlags::ShowInsert);
+ CPPUNIT_ASSERT_MESSAGE("redlining should be on",
+ pDoc->getIDocumentRedlineAccess().IsRedlineOn());
+ CPPUNIT_ASSERT_MESSAGE(
+ "redlines should be visible",
+ IDocumentRedlineAccess::IsShowChanges(pDoc->getIDocumentRedlineAccess().GetRedlineFlags()));
+
+ // store original text of the document for checking Undo
+ OUString sOrigText(pTextDoc->getText()->getString());
+
+ // first paragraph is "Lorem ipsum" with deleted "m ips"
+ CPPUNIT_ASSERT_EQUAL(OUString("Lorem ipsum"), getParagraph(1)->getString());
+
+ // move down first paragraph with change tracking
+ dispatchCommand(mxComponent, ".uno:MoveDown", {});
+
+ // deletion isn't rejected
+ CPPUNIT_ASSERT_EQUAL(OUString("Loremm"), getParagraph(3)->getString());
+
+ // Undo and repeat it with the second paragraph
+ dispatchCommand(mxComponent, ".uno:Undo", {});
+
+ CPPUNIT_ASSERT_EQUAL(sOrigText, pTextDoc->getText()->getString());
+
+ // second paragraph is "dolor sit" with deleted "lor "
+ CPPUNIT_ASSERT_EQUAL(OUString("dolor sit"), getParagraph(2)->getString());
+
+ // move down second paragraph with change tracking
+ SwWrtShell* pWrtShell = pTextDoc->GetDocShell()->GetWrtShell();
+
+ pWrtShell->Up(/*bSelect=*/false);
+ pWrtShell->Down(/*bSelect=*/false);
+
+ dispatchCommand(mxComponent, ".uno:MoveDown", {});
+
+ // This was "dolor sit" (rejecting tracked deletion)
+ CPPUNIT_ASSERT_EQUAL(OUString("dolsit"), getParagraph(4)->getString());
+
+ dispatchCommand(mxComponent, ".uno:Undo", {});
+
+ CPPUNIT_ASSERT_EQUAL(sOrigText, pTextDoc->getText()->getString());
+#endif
+}
+
CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf54819)
{
load(DATA_DIRECTORY, "tdf54819.fodt");
diff --git a/sw/source/core/doc/docnum.cxx b/sw/source/core/doc/docnum.cxx
index 194ba1e2450e..b0bffd31c205 100644
--- a/sw/source/core/doc/docnum.cxx
+++ b/sw/source/core/doc/docnum.cxx
@@ -2141,6 +2141,7 @@ bool SwDoc::MoveParagraphImpl(SwPaM& rPam, tools::Long const nOffset,
rOrigPam.GetPoint()->nContent.Assign( rOrigPam.GetContentNode(), 0 );
bool bDelLastPara = !aInsPos.nNode.GetNode().IsContentNode();
+ sal_uLong nOrigIdx = aIdx.GetIndex();
/* When copying to a non-content node Copy will
insert a paragraph before that node and insert before
@@ -2195,7 +2196,7 @@ bool SwDoc::MoveParagraphImpl(SwPaM& rPam, tools::Long const nOffset,
{
SwPaM pam(*pRedline, nullptr);
sal_uLong const nCurrentOffset(
- aIdx.GetIndex() + 1 - aPam.Start()->nNode.GetIndex());
+ nOrigIdx - aPam.Start()->nNode.GetIndex());
pam.GetPoint()->nNode += nCurrentOffset;
pam.GetPoint()->nContent.Assign(pam.GetPoint()->nNode.GetNode().GetContentNode(), pam.GetPoint()->nContent.GetIndex());
pam.GetMark()->nNode += nCurrentOffset;
More information about the Libreoffice-commits
mailing list