sw/qa/extras/layout/data/tdf54819.fodt | 9 +++++++++ sw/qa/extras/layout/layout2.cxx | 32 ++++++++++++++++++++++++++++++++ sw/source/core/doc/docredln.cxx | 2 +- 3 files changed, 42 insertions(+), 1 deletion(-)
New commits: commit a2d9b270ce8537ebb59de50ebd07697fe9aa191b Author: László Németh <nem...@numbertext.org> AuthorDate: Mon Jan 31 14:37:37 2022 +0100 Commit: László Németh <nem...@numbertext.org> CommitDate: Tue Feb 1 11:22:00 2022 +0100 tdf#146964 sw layout: fix reappearing deletion in Hide Changes mode at moving text. Test: in Hide Changes mode, move the selected text by cutting and pasting it with change tracking. Before the fix, hidden deletion reappeared again (only clicking on Show Changes and Hide Changes again fixed the layout). Regression from commit f51fa7534421a195a58b4a737a2e836d8c25ba81 "tdf#145718 sw, DOCX import: complete tracked text moving" Change-Id: Ia86f570bd634dd513fdbb93a83a929fd0ba4e273 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129223 Tested-by: László Németh <nem...@numbertext.org> Reviewed-by: László Németh <nem...@numbertext.org> diff --git a/sw/qa/extras/layout/data/tdf54819.fodt b/sw/qa/extras/layout/data/tdf54819.fodt new file mode 100644 index 000000000000..f9a8e9d0b698 --- /dev/null +++ b/sw/qa/extras/layout/data/tdf54819.fodt @@ -0,0 +1,9 @@ +<?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:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:config="urn:oas is:names:tc:opendocument:xmlns:config:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rpt="http://openoffice.org/2005/report" xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:grddl="http://www.w3.org/2003/g/data-view#" xmlns:officeooo="http://openoffice.org/2009/office" xmlns:tableooo="http://openoffice.org/2009/table" xmlns:drawooo="http://openoffice.org/2010/draw" xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0" xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" xmlns:formx="urn:openoffice:names: experimental:ooxml-odf-interop:xmlns:form:1.0" xmlns:css3t="http://www.w3.org/TR/css3-text/" office:version="1.2" office:mimetype="application/vnd.oasis.opendocument.text"> + <office:body> + <office:text> + <text:h>Lorem ipsum</text:h> + <text:p>dolor sit amet.</text:p> + </office:text> + </office:body> +</office:document> diff --git a/sw/qa/extras/layout/layout2.cxx b/sw/qa/extras/layout/layout2.cxx index d833800c9fae..ee66a69d8632 100644 --- a/sw/qa/extras/layout/layout2.cxx +++ b/sw/qa/extras/layout/layout2.cxx @@ -20,6 +20,7 @@ #include <rootfrm.hxx> #include <wrtsh.hxx> #include <IDocumentLayoutAccess.hxx> +#include <IDocumentRedlineAccess.hxx> #include <frameformats.hxx> #include <unotextrange.hxx> #include <fmtanchr.hxx> @@ -415,6 +416,37 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf145225_RedlineMovingWithBadInsertio CPPUNIT_ASSERT_EQUAL(static_cast<SwRedlineTable::size_type>(3), pEditShell->GetRedlineCount()); } +CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf146964_ReappearingMovedTextInHideChangesMode) +{ + SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "tdf54819.fodt"); + SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); + CPPUNIT_ASSERT(pTextDoc); + + // enable Record Changes + dispatchCommand(mxComponent, ".uno:TrackChanges", {}); + CPPUNIT_ASSERT_MESSAGE("redlining should be on", + pDoc->getIDocumentRedlineAccess().IsRedlineOn()); + + // set Hide Changes mode + dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); + SwWrtShell* pWrtShell = pTextDoc->GetDocShell()->GetWrtShell(); + SwRootFrame* pLayout(pWrtShell->GetLayout()); + CPPUNIT_ASSERT(pLayout->IsHideRedlines()); + + // delete and paste the deleted word again during Track Changes + dispatchCommand(mxComponent, ".uno:WordRightSel", {}); + dispatchCommand(mxComponent, ".uno:Cut", {}); + dispatchCommand(mxComponent, ".uno:Paste", {}); + + SwEditShell* const pEditShell(pDoc->GetEditShell()); + CPPUNIT_ASSERT_EQUAL(static_cast<SwRedlineTable::size_type>(2), pEditShell->GetRedlineCount()); + + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + CPPUNIT_ASSERT(pXmlDoc); + // This was "Lorem Lorem ipsum" (reappearing deletion in Hide Changes mode) + assertXPath(pXmlDoc, "/root/page/body/txt[1]/Text", "Portion", "Lorem ipsum"); +} + CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf125300) { SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "tdf125300.docx"); diff --git a/sw/source/core/doc/docredln.cxx b/sw/source/core/doc/docredln.cxx index cb6fb4f3302c..c6d469678fa3 100644 --- a/sw/source/core/doc/docredln.cxx +++ b/sw/source/core/doc/docredln.cxx @@ -829,7 +829,7 @@ bool SwRedlineTable::isMoved( size_type rPos ) const { pRedline->SetMoved(); pPair->SetMoved(); - pPair->InvalidateRange(SwRangeRedline::Invalidation::Remove); + pPair->InvalidateRange(SwRangeRedline::Invalidation::Add); bRet = true; }