sw/qa/extras/ooxmlexport/ooxmlexport5.cxx |    8 ++++++++
 sw/source/core/doc/docbm.cxx              |   15 +++++++++++----
 2 files changed, 19 insertions(+), 4 deletions(-)

New commits:
commit 21b1dd42e9a817ae9b68e9e13ea57ce2491940c6
Author:     Justin Luth <justin.l...@collabora.com>
AuthorDate: Fri Apr 21 11:30:43 2023 -0400
Commit:     Justin Luth <jl...@mail.com>
CommitDate: Tue Apr 25 18:29:34 2023 +0200

    tdf#154956 sw: delete bookmarks at end if whole node is selected
    
    Exposed by LO 7.2.2 commit 4bf04dea9afb30a9395e80b07a81d1908937ee8b
    Author: Michael Stahl on Fri Aug 27 14:38:18 2021 +0200
        tdf#128106 sw: copy bookmarks at start if whole node is copied
    
    Change-Id: I9205463f9beb3704eeb63fe7556103230ba7283d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150772
    Tested-by: Jenkins
    Reviewed-by: Justin Luth <jl...@mail.com>
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>

diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx
index ef1e15eafea5..ceb6bdff9c06 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx
@@ -1357,6 +1357,14 @@ CPPUNIT_TEST_FIXTURE(Test, fdo60957)
     loadAndSave("fdo60957-2.docx");
     xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
     assertXPath(pXmlDoc, "//w:tbl", 2);
+
+    //tdf#154956
+    uno::Reference<text::XBookmarksSupplier> xBookmarksSupplier(mxComponent, 
uno::UNO_QUERY);
+    uno::Reference<container::XIndexAccess> 
xBookmarksByIdx(xBookmarksSupplier->getBookmarks(), uno::UNO_QUERY);
+    uno::Reference<container::XNameAccess> xBookmarksByName = 
xBookmarksSupplier->getBookmarks();
+
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), 
xBookmarksByIdx->getCount());
+    CPPUNIT_ASSERT(xBookmarksByName->hasByName("_GoBack"));
 }
 
 //This has more cells than msword supports, we must balance the
diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx
index e047b2d1e319..ab5e544c2358 100644
--- a/sw/source/core/doc/docbm.cxx
+++ b/sw/source/core/doc/docbm.cxx
@@ -197,10 +197,17 @@ namespace
 
     bool lcl_Lower( const SwPosition& rPos, const SwNode& rNdIdx, 
std::optional<sal_Int32> oContentIdx )
     {
-        return rPos.GetNode() < rNdIdx
-               || ( oContentIdx.has_value()
-                    && rPos.GetNode() == rNdIdx
-                    && rPos.GetContentIndex() < *oContentIdx );
+        if (rPos.GetNode() < rNdIdx)
+            return true;
+
+        if (rPos.GetNode() != rNdIdx || !oContentIdx)
+            return false;
+
+        if (rPos.GetContentIndex() < *oContentIdx)
+            return true;
+
+        // paragraph end selected?
+        return rNdIdx.IsTextNode() && *oContentIdx == 
rNdIdx.GetTextNode()->Len();
     }
 
     bool lcl_MarkOrderingByStart(const ::sw::mark::MarkBase *const pFirst,

Reply via email to