sw/qa/extras/unowriter/data/one-change.fodt |   19 ++++++++++++
 sw/qa/extras/unowriter/unowriter.cxx        |   41 ++++++++++++++++++++++++++++
 sw/source/core/unocore/unoredline.cxx       |    2 -
 3 files changed, 61 insertions(+), 1 deletion(-)

New commits:
commit a278fc9f957a4eef77b1e90c79679274ee34ba7c
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Mon Jun 16 13:42:32 2025 +0500
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Tue Jun 17 08:58:35 2025 +0200

    Make sure that "RedlineStart" and "RedlineEnd" point to correct points
    
    Looks like it could be the other way round, using GetPoint/GetMark.
    
    Change-Id: Iae95470a5877bdb8eaf05a65db18819dacd26ad4
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/186553
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/186577
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>

diff --git a/sw/qa/extras/unowriter/data/one-change.fodt 
b/sw/qa/extras/unowriter/data/one-change.fodt
new file mode 100644
index 000000000000..f1b0a822a6b8
--- /dev/null
+++ b/sw/qa/extras/unowriter/data/one-change.fodt
@@ -0,0 +1,19 @@
+<?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" 
office:version="1.4" office:mimetype="application/vnd.oasis.opendocument.text">
+ <office:body>
+  <office:text>
+   <text:tracked-changes text:track-changes="false">
+    <text:changed-region xml:id="ct2378399014640" text:id="ct2378399014640">
+     <text:deletion>
+      <office:change-info>
+       <dc:creator>Mike</dc:creator>
+       <dc:date>2025-06-16T14:08:27</dc:date>
+      </office:change-info>
+     </text:deletion>
+    </text:changed-region>
+   </text:tracked-changes>
+   <text:p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum 
consequat mi quis pretium semper. Proin luctus orci ac neque venenatis, quis 
commodo dolor posuere. Curabitur dignissim sapien quis cursus egestas. 
<text:change-start text:change-id="ct2378399014640"/>Donec<text:change-end 
text:change-id="ct2378399014640"/> blandit auctor arcu, nec pellentesque eros 
molestie eget. In consectetur aliquam hendrerit. Sed cursus mauris vitae ligula 
pellentesque, non pellentesque urna aliquet. Fusce placerat mauris enim, nec 
rutrum purus semper vel. Praesent tincidunt neque eu pellentesque pharetra. 
Fusce pellentesque est orci.</text:p>
+  </office:text>
+ </office:body>
+</office:document>
\ No newline at end of file
diff --git a/sw/qa/extras/unowriter/unowriter.cxx 
b/sw/qa/extras/unowriter/unowriter.cxx
index 4618fd6bb362..186e613cbc9b 100644
--- a/sw/qa/extras/unowriter/unowriter.cxx
+++ b/sw/qa/extras/unowriter/unowriter.cxx
@@ -1560,6 +1560,47 @@ CPPUNIT_TEST_FIXTURE(SwUnoWriter, testTdf164921)
     }
 }
 
+CPPUNIT_TEST_FIXTURE(SwUnoWriter, testRedlineStartEnd)
+{
+    // Given a document with a single tracked change, a removal of the word 
"Donec":
+    createSwDoc("one-change.fodt");
+
+    auto xRedlinesSupplier = 
mxComponent.queryThrow<document::XRedlinesSupplier>();
+    auto xRedlines = xRedlinesSupplier->getRedlines();
+    CPPUNIT_ASSERT(xRedlines);
+    auto xEnumeration = xRedlines->createEnumeration();
+    CPPUNIT_ASSERT(xEnumeration);
+    CPPUNIT_ASSERT(xEnumeration->hasMoreElements());
+    auto xRedline = xEnumeration->nextElement().query<beans::XPropertySet>();
+    CPPUNIT_ASSERT(xRedline);
+
+    // Check that "RedlineStart" and "RedlineEnd" point to start resp. end of 
the redline range:
+    {
+        auto xTextRange
+            = 
xRedline->getPropertyValue(u"RedlineStart"_ustr).queryThrow<text::XTextRange>();
+        auto xCursor = 
xTextRange->getText()->createTextCursorByRange(xTextRange);
+        CPPUNIT_ASSERT(xCursor);
+        xCursor->goLeft(10, /*bExpand*/ true);
+        // Without the fix, this failed with
+        // - Expected:  egestas.
+        // - Actual  : tas. Donec
+        CPPUNIT_ASSERT_EQUAL(u" egestas. "_ustr, xCursor->getString());
+    }
+    {
+        auto xTextRange
+            = 
xRedline->getPropertyValue(u"RedlineEnd"_ustr).queryThrow<text::XTextRange>();
+        auto xCursor = 
xTextRange->getText()->createTextCursorByRange(xTextRange);
+        CPPUNIT_ASSERT(xCursor);
+        xCursor->goRight(9, /*bExpand*/ true);
+        // Without the fix, this failed with
+        // - Expected:  blandit
+        // - Actual  : Donec bla
+        CPPUNIT_ASSERT_EQUAL(u" blandit "_ustr, xCursor->getString());
+    }
+
+    CPPUNIT_ASSERT(!xEnumeration->hasMoreElements());
+}
+
 } // end of anonymous namespace
 CPPUNIT_PLUGIN_IMPLEMENT();
 
diff --git a/sw/source/core/unocore/unoredline.cxx 
b/sw/source/core/unocore/unoredline.cxx
index b6517587d006..c0cf0d334f13 100644
--- a/sw/source/core/unocore/unoredline.cxx
+++ b/sw/source/core/unocore/unoredline.cxx
@@ -421,7 +421,7 @@ uno::Any SwXRedline::getPropertyValue( const OUString& 
rPropertyName )
         rPropertyName == UNO_NAME_REDLINE_END)
     {
         uno::Reference<XInterface> xRet;
-        SwPosition* pPoint = bStart ? m_pRedline->GetPoint() : 
m_pRedline->GetMark();
+        SwPosition* pPoint = bStart ? m_pRedline->Start() : m_pRedline->End();
         switch (pPoint->GetNode().GetNodeType())
         {
             case SwNodeType::Section:

Reply via email to