[Libreoffice-commits] core.git: sw/qa sw/source

László Németh (via logerrit) logerrit at kemper.freedesktop.org
Mon Nov 16 17:36:50 UTC 2020


 sw/qa/extras/uiwriter/uiwriter2.cxx |   44 ++++++++++++++++++++++++++++++++++++
 sw/source/core/text/redlnitr.cxx    |    2 -
 2 files changed, 45 insertions(+), 1 deletion(-)

New commits:
commit d129e1785e541f217d4f6547faec87b9fa772019
Author:     László Németh <nemeth at numbertext.org>
AuthorDate: Mon Nov 16 13:01:32 2020 +0100
Commit:     László Németh <nemeth at numbertext.org>
CommitDate: Mon Nov 16 18:36:10 2020 +0100

    tdf#137771 sw ChangesInMargin: fix end of paragraph
    
    Deletions at the end of the paragraph weren't shown
    on margin, including the vertical "Changed line" mark.
    
    Change-Id: I2b79d1619cca891feab2f99eedad79ba330e75b9
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105931
    Tested-by: Jenkins
    Reviewed-by: László Németh <nemeth at numbertext.org>

diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx
index dccf9de83c70..a14a16a49edb 100644
--- a/sw/qa/extras/uiwriter/uiwriter2.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter2.cxx
@@ -1976,6 +1976,50 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf52391)
     CPPUNIT_ASSERT_EQUAL(OUString("Portion1Portion2"), xRun->getString());
 }
 
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf137771)
+{
+    load(DATA_DIRECTORY, "tdf132160.odt");
+
+    SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
+    CPPUNIT_ASSERT(pTextDoc);
+
+    // switch on "Show changes in margin" mode
+    dispatchCommand(mxComponent, ".uno:ShowChangesInMargin", {});
+
+    SwWrtShell* const pWrtShell = pTextDoc->GetDocShell()->GetWrtShell();
+    CPPUNIT_ASSERT(pWrtShell->GetViewOptions()->IsShowChangesInMargin());
+
+    // delete a word at the end of the paragraph.
+    dispatchCommand(mxComponent, ".uno:GotoEndOfPara", {});
+    for (int i = 0; i < 6; ++i)
+    {
+        dispatchCommand(mxComponent, ".uno:SwBackspace", {});
+    }
+
+    CPPUNIT_ASSERT(getParagraph(1)->getString().endsWith("to be "));
+
+    // 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 12 (missing vertical redline mark)
+    assertXPath(pXmlDoc, "/metafile/push/push/push/line", 13);
+
+    // This was the content of the next <text> (missing deletion on margin)
+    assertXPathContent(pXmlDoc, "/metafile/push/push/push/textarray[16]/text", " saved.");
+
+    // this would crash due to bad redline range
+    dispatchCommand(mxComponent, ".uno:Undo", {});
+    CPPUNIT_ASSERT(getParagraph(1)->getString().endsWith("to be saved."));
+
+    // switch off "Show changes in margin" mode
+    dispatchCommand(mxComponent, ".uno:ShowChangesInMargin", {});
+    CPPUNIT_ASSERT(!pWrtShell->GetViewOptions()->IsShowChangesInMargin());
+}
+
 CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf126206)
 {
     load(DATA_DIRECTORY, "tdf126206.docx");
diff --git a/sw/source/core/text/redlnitr.cxx b/sw/source/core/text/redlnitr.cxx
index 4a6157581810..3286661251af 100644
--- a/sw/source/core/text/redlnitr.cxx
+++ b/sw/source/core/text/redlnitr.cxx
@@ -827,7 +827,7 @@ bool SwRedlineItr::CheckLine(
         pRedline->CalcStartEnd( m_nNdIdx, m_nStart, m_nEnd );
         if (nChkEnd < m_nStart)
             break;
-        if (nChkStart <= m_nEnd && (nChkEnd > m_nStart || COMPLETE_STRING == m_nEnd))
+        if (nChkStart <= m_nEnd && (nChkEnd >= m_nStart || COMPLETE_STRING == m_nEnd))
         {
             bRet = true;
             if ( rRedlineText.isEmpty() && pRedline->GetType() == RedlineType::Delete )


More information about the Libreoffice-commits mailing list