sw/qa/extras/uiwriter/data/tdf142130.fodt | 37 ++++++++++++++++++++++++++++ sw/qa/extras/uiwriter/uiwriter2.cxx | 39 ++++++++++++++++++++++++++++++ sw/source/core/text/porlay.cxx | 6 +--- sw/source/core/text/redlnitr.cxx | 4 +-- sw/source/core/text/redlnitr.hxx | 3 +- 5 files changed, 82 insertions(+), 7 deletions(-)
New commits: commit 4c4c8acd4329b28fab8680454c033e43d49362af Author: László Németh <nem...@numbertext.org> AuthorDate: Fri May 7 17:01:10 2021 +0200 Commit: Balazs Varga <varga.bala...@nisz.hu> CommitDate: Thu Oct 21 10:23:27 2021 +0200 tdf#142130 sw track changes: fix crossing out of neighboring images Normal images got crossing out from the next deleted images. Fix it by using only the start position of the image in CheckLine() instead of the 1-character length range of the anchor point. Note: add unit test also for tdf#78864. Follow-up to commit d845b91bcc6eb885c55494d4d4fab4ec09577e1d (tdf#78864 sw track changes: cross out deleted images). Change-Id: I8894e625d479adea4b1003f55f24f292064ed7ba Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115255 Tested-by: Jenkins Reviewed-by: László Németh <nem...@numbertext.org> (cherry picked from commit b11287cda0ce308f5fddac4c0877718fec7c70a5) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123968 Tested-by: Balazs Varga <varga.bala...@nisz.hu> Reviewed-by: Balazs Varga <varga.bala...@nisz.hu> diff --git a/sw/qa/extras/uiwriter/data/tdf142130.fodt b/sw/qa/extras/uiwriter/data/tdf142130.fodt new file mode 100644 index 000000000000..1bc26e6acf22 --- /dev/null +++ b/sw/qa/extras/uiwriter/data/tdf142130.fodt @@ -0,0 +1,37 @@ +<?xml version="1.0" encoding="UTF-8"?> +<office:document xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" office:version="1.3" office:mimetype="application/vnd.oasis.opendocument.text"> + <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="ct94146400887392" text:id="ct94146400887392"> + <text:deletion> + <office:change-info> + <dc:creator>X</dc:creator> + <dc:date>2021-05-07T17:32:23</dc:date> + </office:change-info> + </text:deletion> + </text:changed-region> + </text:tracked-changes> + <text:p text:style-name="Standard"><draw:frame text:anchor-type="as-char" svg:width="7.276cm" svg:height="4.842cm" draw:z-index="0"><draw:image draw:mime-type="image/png"> + <office:binary-data>iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAABmJLR0QA/wD/AP+gvaeTAAAA + CXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH5QUGCg8pr2vxSAAAAB1pVFh0Q29tbWVudAAA + AAAAQ3JlYXRlZCB3aXRoIEdJTVBkLmUHAAAADElEQVQI12N4stkEAARKAcxTwEa2AAAAAElF + TkSuQmCC + </office:binary-data> + </draw:image> + </draw:frame><text:change-start text:change-id="ct94146400887392"/><draw:frame text:anchor-type="as-char" svg:width="10.663cm" svg:height="5.415cm" draw:z-index="1"><draw:image draw:mime-type="image/png"> + <office:binary-data>iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAAAAAA6fptVAAAAAmJLR0QA/4ePzL8AAAAJcEhZ + cwAACxMAAAsTAQCanBgAAAAHdElNRQflBQYKGR4LTuGQAAAACklEQVQI12M4DwAA0QDQfVbA + HQAAAABJRU5ErkJggg== + </office:binary-data> + </draw:image> + </draw:frame><text:change-end text:change-id="ct94146400887392"/></text:p> + </office:text> + </office:body> +</office:document> diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx index 29bbb8dbb7ba..259687baf470 100644 --- a/sw/qa/extras/uiwriter/uiwriter2.cxx +++ b/sw/qa/extras/uiwriter/uiwriter2.cxx @@ -2141,6 +2141,45 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf137771) CPPUNIT_ASSERT(!pWrtShell->GetViewOptions()->IsShowChangesInMargin()); } +CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf142130) +{ + load(DATA_DIRECTORY, "tdf142130.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())); + + // Dump the rendering of the first page as an XML file. + SwDocShell* pShell = pTextDoc->GetDocShell(); + std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); + MetafileXmlDump dumper; + xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); + CPPUNIT_ASSERT(pXmlDoc); + + // This was 6 (crossing out of the first, not deleted image) + // (4 lines = 2 lines for crossing out of the second image, 2 lines for the + // vertical lines before the two lines) + assertXPath(pXmlDoc, "/metafile/push/push/push/line", 4); + + // reject deletion of the second image + IDocumentRedlineAccess& rIDRA(pDoc->getIDocumentRedlineAccess()); + rIDRA.AcceptAllRedline(false); + + xMetaFile = pShell->GetPreviewMetaFile(); + xmlDocUniquePtr pXmlDoc2 = dumpAndParse(dumper, *xMetaFile); + // no crossing out and vertical redlines + assertXPath(pXmlDoc2, "/metafile/push/push/push/line", 0); +} + CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf139120) { SwDoc* pDoc = createDoc("tdf54819.fodt"); diff --git a/sw/source/core/text/porlay.cxx b/sw/source/core/text/porlay.cxx index 8c070715a79b..74cd12b372a6 100644 --- a/sw/source/core/text/porlay.cxx +++ b/sw/source/core/text/porlay.cxx @@ -646,11 +646,9 @@ void SwLineLayout::CalcLine( SwTextFormatter &rLine, SwTextFormatInfo &rInf ) enum RedlineType eRedlineEnd; std::pair<SwTextNode const*, sal_Int32> const flyStart( rInf.GetTextFrame()->MapViewToModel(nPorSttIdx)); - std::pair<SwTextNode const*, sal_Int32> const flyEnd( - rInf.GetTextFrame()->MapViewToModel(nPorSttIdx + pPos->GetLen())); bool bHasFlyRedline = rLine.GetRedln()->CheckLine(flyStart.first->GetIndex(), - flyStart.second, flyEnd.first->GetIndex(), flyEnd.second, sRedlineText, - bHasRedlineEnd, eRedlineEnd); + flyStart.second, flyStart.first->GetIndex(), flyStart.second, sRedlineText, + bHasRedlineEnd, eRedlineEnd, /*bFullLine=*/false); bDeleted = bHasFlyRedline && eRedlineEnd == RedlineType::Delete; } static_cast<SwFlyCntPortion*>(pPos)->SetDeleted(bDeleted); diff --git a/sw/source/core/text/redlnitr.cxx b/sw/source/core/text/redlnitr.cxx index a56142dff8f1..0428122bf6b0 100644 --- a/sw/source/core/text/redlnitr.cxx +++ b/sw/source/core/text/redlnitr.cxx @@ -940,13 +940,13 @@ bool SwRedlineItr::ChkSpecialUnderline_() const bool SwRedlineItr::CheckLine( sal_uLong const nStartNode, sal_Int32 const nChkStart, sal_uLong const nEndNode, sal_Int32 nChkEnd, OUString& rRedlineText, - bool& bRedlineEnd, RedlineType& eRedlineEnd) + bool& bRedlineEnd, RedlineType& eRedlineEnd, bool bFullLine) { // note: previously this would return true in the (!m_bShow && m_pExt) // case, but surely that was a bug? if (m_nFirst == SwRedlineTable::npos || m_eMode != Mode::Show) return false; - if( nChkEnd == nChkStart ) // empty lines look one char further + if( nChkEnd == nChkStart && bFullLine ) // empty lines look one char further ++nChkEnd; sal_Int32 nOldStart = m_nStart; sal_Int32 nOldEnd = m_nEnd; diff --git a/sw/source/core/text/redlnitr.hxx b/sw/source/core/text/redlnitr.hxx index 1623a31aacc2..0ba22030edbe 100644 --- a/sw/source/core/text/redlnitr.hxx +++ b/sw/source/core/text/redlnitr.hxx @@ -119,7 +119,8 @@ public: bool ChkSpecialUnderline() const { return IsOn() && ChkSpecialUnderline_(); } bool CheckLine(sal_uLong nStartNode, sal_Int32 nChkStart, sal_uLong nEndNode, - sal_Int32 nChkEnd, OUString& rRedlineText, bool& bRedlineEnd, RedlineType& eRedlineEnd); + sal_Int32 nChkEnd, OUString& rRedlineText, bool& bRedlineEnd, + RedlineType& eRedlineEnd, bool bFullLine = true); bool LeaveExtend(SwFont& rFnt, sal_uLong const nNode, sal_Int32 const nNew) { return m_pExt->Leave(rFnt, nNode, nNew); } bool ExtOn() {