[Libreoffice-commits] core.git: Branch 'libreoffice-5-3' - sw/source

Michael Stahl mstahl at redhat.com
Tue Feb 7 08:44:13 UTC 2017


 sw/source/core/doc/docbm.cxx |   18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

New commits:
commit e48a474f9f9b5f213811b39c157800ab29e5d345
Author: Michael Stahl <mstahl at redhat.com>
Date:   Fri Feb 3 17:58:05 2017 +0100

    sw: fix assertion on exporting novell633099-1.doc to DOC
    
    This asserts because MarkManager::m_vAllMarks is not sorted.
    
    info:sw.core:32273:1:sw/source/core/doc/docbm.cxx:286: 1493,39 1493,39 N2sw4mark8BookmarkE _Source_Device_Configuration
    info:sw.core:32273:1:sw/source/core/doc/docbm.cxx:286: 1493,39 1493,39 N2sw4mark8BookmarkE _Deploying_the_Connector
    info:sw.core:32273:1:sw/source/core/doc/docbm.cxx:286: 1493,39 1493,39 N2sw4mark8BookmarkE _Setting_up_Connection
    info:sw.core:32273:1:sw/source/core/doc/docbm.cxx:286: 1493,39 1493,39 N2sw4mark8BookmarkE _Testing_the_Audit
    info:sw.core:32273:1:sw/source/core/doc/docbm.cxx:286: 1493,0 1493,0 N2sw4mark23CrossRefHeadingBookmarkE __RefHeading___Toc270687978
    
    This happens while called from SwRangeRedline::MoveFromSection; the
    target paragraph has some normal bookmarks and a CrossRefBookmark
    all at index 0 before, but the move messes up the sorting.
    
    The reason is that SwIndexReg::Update() has a special case HACK to avoid
    adjusting the content index of CrossRefBookmark away from 0.
    
    Prevent the problem by tweaking the bookmark sort function to always
    sort CrossRefBookmark before other marks in the paragraph.
    
    (cherry picked from commit 3a3b4f2b51005eef62a38d43d1dbef4c8201cc5c)
    
    loplugin:simplifybool
    (cherry picked from commit ad2935eee6640a5ee09d0b21c7c1f83dbfcd4c58)
    
    Change-Id: I1373337a9c7e6760fdbe5b634a14c63428a2e73c
    Reviewed-on: https://gerrit.libreoffice.org/33971
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>

diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx
index 07bf110..4fd53d0 100644
--- a/sw/source/core/doc/docbm.cxx
+++ b/sw/source/core/doc/docbm.cxx
@@ -78,7 +78,23 @@ namespace
     bool lcl_MarkOrderingByStart(const IDocumentMarkAccess::pMark_t& rpFirst,
         const IDocumentMarkAccess::pMark_t& rpSecond)
     {
-        return rpFirst->GetMarkStart() < rpSecond->GetMarkStart();
+        auto const& rFirstStart(rpFirst->GetMarkStart());
+        auto const& rSecondStart(rpSecond->GetMarkStart());
+        if (rFirstStart.nNode != rSecondStart.nNode)
+        {
+            return rFirstStart.nNode < rSecondStart.nNode;
+        }
+        if (rFirstStart.nContent != 0 || rSecondStart.nContent != 0)
+        {
+            return rFirstStart.nContent < rSecondStart.nContent;
+        }
+        auto *const pCRFirst (dynamic_cast<::sw::mark::CrossRefBookmark const*>(rpFirst.get()));
+        auto *const pCRSecond(dynamic_cast<::sw::mark::CrossRefBookmark const*>(rpSecond.get()));
+        if ((pCRFirst == nullptr) == (pCRSecond == nullptr))
+        {
+            return false; // equal
+        }
+        return pCRFirst != nullptr; // cross-ref sorts *before*
     }
 
     bool lcl_MarkOrderingByEnd(const IDocumentMarkAccess::pMark_t& rpFirst,


More information about the Libreoffice-commits mailing list