[Libreoffice-commits] core.git: sc/inc sc/source

Julien Nabet (via logerrit) logerrit at kemper.freedesktop.org
Mon May 24 19:00:14 UTC 2021


 sc/inc/olinetab.hxx              |    2 +-
 sc/source/core/data/olinetab.cxx |   24 +++++-------------------
 2 files changed, 6 insertions(+), 20 deletions(-)

New commits:
commit 706d423bb12c79f0e6c71b7e38d092d1bdf1c259
Author:     Julien Nabet <serval2412 at yahoo.fr>
AuthorDate: Mon May 24 17:15:32 2021 +0200
Commit:     Julien Nabet <serval2412 at yahoo.fr>
CommitDate: Mon May 24 20:59:25 2021 +0200

    Teach ScOutlineCollection to return an iterator when calling erase, then use it
    
    Hoping C++11 erase method std::map which returns an iterator is now known
    for compiler of every env.
    
    Change-Id: Ie4f87ce234228209257f7025e197fdf53ea7e69d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116066
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
    Reviewed-by: Julien Nabet <serval2412 at yahoo.fr>
    Tested-by: Jenkins

diff --git a/sc/inc/olinetab.hxx b/sc/inc/olinetab.hxx
index d7ee741f56c5..45c4a65a6b9b 100644
--- a/sc/inc/olinetab.hxx
+++ b/sc/inc/olinetab.hxx
@@ -80,7 +80,7 @@ public:
     iterator end();
     const_iterator begin() const;
     const_iterator end() const;
-    void erase(const iterator& pos);
+    iterator erase(const iterator& pos);
     bool empty() const;
 
     iterator FindStart(SCCOLROW nMinStart);
diff --git a/sc/source/core/data/olinetab.cxx b/sc/source/core/data/olinetab.cxx
index ddcc4c4ed6ad..13fc17a7b35f 100644
--- a/sc/source/core/data/olinetab.cxx
+++ b/sc/source/core/data/olinetab.cxx
@@ -126,9 +126,9 @@ ScOutlineCollection::const_iterator ScOutlineCollection::end() const
     return m_Entries.end();
 }
 
-void ScOutlineCollection::erase(const iterator& pos)
+ScOutlineCollection::iterator ScOutlineCollection::erase(const iterator& pos)
 {
-    m_Entries.erase(pos);
+    return m_Entries.erase(pos);
 }
 
 bool ScOutlineCollection::empty() const
@@ -262,11 +262,7 @@ bool ScOutlineArray::Insert(
                         return false;
                     }
                     aCollections[nMoveLevel+1].insert(*pEntry);
-                    size_t nPos = std::distance(rColl.begin(), it);
-                    rColl.erase(it);
-                    it = rColl.begin();
-                    std::advance(it, nPos);
-                    itEnd = rColl.end();
+                    it = rColl.erase(it);
                     if (nMoveLevel == nDepth - 1)
                         bNeedSize = true;
                 }
@@ -345,12 +341,7 @@ void ScOutlineArray::PromoteSub(SCCOLROW nStartPos, SCCOLROW nEndPos, size_t nSt
             {
                 aCollections[nLevel-1].insert(*pEntry);
 
-                // Re-calc iterator positions after the tree gets invalidated
-                size_t nPos = std::distance(rColl.begin(), it);
-                rColl.erase(it);
-                it = rColl.begin();
-                std::advance(it, nPos);
-                itEnd = rColl.end();
+                it = rColl.erase(it);
             }
             else
                 ++it;
@@ -368,12 +359,7 @@ void ScOutlineArray::PromoteSub(SCCOLROW nStartPos, SCCOLROW nEndPos, size_t nSt
             {
                 aCollections[nLevel-1].insert(*pEntry);
 
-                // Re-calc iterator positions after the tree gets invalidated
-                size_t nPos = std::distance(rColl.begin(), it);
-                rColl.erase(it);
-                it = rColl.begin();
-                std::advance(it, nPos);
-                itEnd = rColl.end();
+                it = rColl.erase(it);
             }
             else
                 ++it;


More information about the Libreoffice-commits mailing list