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

Michael Stahl mstahl at redhat.com
Fri Feb 3 17:25:49 UTC 2017


 sw/source/core/doc/docbm.cxx |   36 +++++++++++++++++++++++++-----------
 1 file changed, 25 insertions(+), 11 deletions(-)

New commits:
commit 3a3b4f2b51005eef62a38d43d1dbef4c8201cc5c
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.
    
    Change-Id: I1373337a9c7e6760fdbe5b634a14c63428a2e73c

diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx
index 473047b..0219fd0 100644
--- a/sw/source/core/doc/docbm.cxx
+++ b/sw/source/core/doc/docbm.cxx
@@ -78,7 +78,21 @@ 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()));
+        return ((pCRFirst == nullptr) == (pCRSecond == nullptr))
+                ? false // equal
+                : (pCRFirst != nullptr); // cross-ref sorts *before*
     }
 
     bool lcl_MarkOrderingByEnd(const IDocumentMarkAccess::pMark_t& rpFirst,
commit f6596a35c2d9a8c365bb78e1256a2def57ee1a36
Author: Michael Stahl <mstahl at redhat.com>
Date:   Fri Feb 3 16:48:02 2017 +0100

    sw: make lcl_DebugMarks output more readable, pos. at the start
    
    Change-Id: If9c151faefa3d109af2df7933a275c667880fb75

diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx
index 9b50b03..473047b 100644
--- a/sw/source/core/doc/docbm.cxx
+++ b/sw/source/core/doc/docbm.cxx
@@ -266,28 +266,28 @@ namespace
             [&rName] (IDocumentMarkAccess::pMark_t const& rpMark) { return rpMark->GetName() == rName; } );
     }
 
-    void lcl_DebugMarks(IDocumentMarkAccess::container_t vMarks)
+    void lcl_DebugMarks(IDocumentMarkAccess::container_t const& rMarks)
     {
 #if OSL_DEBUG_LEVEL > 0
-        SAL_INFO("sw.core", vMarks.size() << " Marks");
-        for(IDocumentMarkAccess::iterator_t ppMark = vMarks.begin();
-            ppMark != vMarks.end();
-            ppMark++)
+        SAL_INFO("sw.core", rMarks.size() << " Marks");
+        for (IDocumentMarkAccess::const_iterator_t ppMark = rMarks.begin();
+             ppMark != rMarks.end();
+             ++ppMark)
         {
             IMark* pMark = ppMark->get();
             const SwPosition* const pStPos = &pMark->GetMarkStart();
             const SwPosition* const pEndPos = &pMark->GetMarkEnd();
             SAL_INFO("sw.core",
-                typeid(*pMark).name() << " " <<
-                pMark->GetName() << " " <<
                 pStPos->nNode.GetIndex() << "," <<
                 pStPos->nContent.GetIndex() << " " <<
                 pEndPos->nNode.GetIndex() << "," <<
-                pEndPos->nContent.GetIndex());
+                pEndPos->nContent.GetIndex() << " " <<
+                typeid(*pMark).name() << " " <<
+                pMark->GetName());
         }
 #endif
-        assert(std::is_sorted(vMarks.begin(), vMarks.end(), lcl_MarkOrderingByStart));
-        (void) vMarks;
+        assert(std::is_sorted(rMarks.begin(), rMarks.end(), lcl_MarkOrderingByStart));
+        (void) rMarks;
     };
 }
 


More information about the Libreoffice-commits mailing list