[Libreoffice-commits] core.git: cui/source include/o3tl o3tl/qa sc/source sw/source

Jan-Marek Glogowski (via logerrit) logerrit at kemper.freedesktop.org
Wed Dec 23 10:45:37 UTC 2020


 cui/source/tabpages/autocdlg.cxx |    8 ++++----
 include/o3tl/sorted_vector.hxx   |    2 +-
 o3tl/qa/test-sorted_vector.cxx   |    4 ++--
 sc/source/core/data/attarray.cxx |    2 +-
 sw/source/core/doc/acmplwrd.cxx  |   11 +++++------
 sw/source/core/doc/docfld.cxx    |    2 +-
 sw/source/core/doc/docredln.cxx  |    2 +-
 sw/source/core/docnode/nodes.cxx |    4 ++--
 8 files changed, 17 insertions(+), 18 deletions(-)

New commits:
commit 2e0b757e62536281f61b8d37987378646a246fcb
Author:     Jan-Marek Glogowski <glogow at fbihome.de>
AuthorDate: Tue Dec 22 18:59:43 2020 +0100
Commit:     Jan-Marek Glogowski <glogow at fbihome.de>
CommitDate: Wed Dec 23 11:44:47 2020 +0100

    Rename sorted_vector::erase(size_t) to erase_at
    
    emscripten clang fails with:
    
    sc/source/core/data/attarray.cxx:378:44: \
        error: call to member function 'erase' is ambiguous
                            aNewCondFormatData.erase(nIndex);
                            ~~~~~~~~~~~~~~~~~~~^~~~~
    include/o3tl/sorted_vector.hxx:86:15: note: candidate function
        size_type erase( const Value& x )
                  ^
    include/o3tl/sorted_vector.hxx:97:10: note: candidate function
        void erase( size_t index )
    
    This looks like a compiler error, but if the vector contained
    size_t values, this would also be ambiguous to begin with. So
    this just renames erase(size_t) to erase_at.
    
    And instead of a 2nd find in the failing code, after copying
    the vector, it mow uses std::distance to remove the item.
    
    Change-Id: I7d03ff32352a1890cc01ca241452c0f00d6a9302
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108212
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
    Reviewed-by: Jan-Marek Glogowski <glogow at fbihome.de>

diff --git a/cui/source/tabpages/autocdlg.cxx b/cui/source/tabpages/autocdlg.cxx
index 9b5ff2e30418..380d61123330 100644
--- a/cui/source/tabpages/autocdlg.cxx
+++ b/cui/source/tabpages/autocdlg.cxx
@@ -1270,7 +1270,7 @@ bool OfaAutocorrExceptPage::FillItemSet( SfxItemSet*  )
 
                     if( !lcl_FindInArray(rArrays.aDoubleCapsStrings, aString))
                     {
-                      pWrdList->erase(i);
+                      pWrdList->erase_at(i);
                     }
                 }
 
@@ -1292,7 +1292,7 @@ bool OfaAutocorrExceptPage::FillItemSet( SfxItemSet*  )
                     OUString aString = (*pCplList)[ --i ];
                     if( !lcl_FindInArray(rArrays.aAbbrevStrings, aString))
                     {
-                        pCplList->erase(i);
+                        pCplList->erase_at(i);
                     }
                 }
 
@@ -1318,7 +1318,7 @@ bool OfaAutocorrExceptPage::FillItemSet( SfxItemSet*  )
             OUString aString = (*pWrdList)[ --i ];
             if (m_xDoubleCapsLB->find_text(aString) == -1)
             {
-                pWrdList->erase(i);
+                pWrdList->erase_at(i);
             }
         }
         nCount = m_xDoubleCapsLB->n_children();
@@ -1339,7 +1339,7 @@ bool OfaAutocorrExceptPage::FillItemSet( SfxItemSet*  )
             OUString aString = (*pCplList)[ --i ];
             if (m_xAbbrevLB->find_text(aString) == -1)
             {
-                pCplList->erase(i);
+                pCplList->erase_at(i);
             }
         }
         sal_Int32 nAbbrevCount = m_xAbbrevLB->n_children();
diff --git a/include/o3tl/sorted_vector.hxx b/include/o3tl/sorted_vector.hxx
index 508fe61cc03e..2bd8b7273a9a 100644
--- a/include/o3tl/sorted_vector.hxx
+++ b/include/o3tl/sorted_vector.hxx
@@ -94,7 +94,7 @@ public:
         return 0;
     }
 
-    void erase( size_t index )
+    void erase_at(size_t index)
     {
         m_vector.erase(m_vector.begin() + index);
     }
diff --git a/o3tl/qa/test-sorted_vector.cxx b/o3tl/qa/test-sorted_vector.cxx
index 8b335040ee84..c7fdb0c0455d 100644
--- a/o3tl/qa/test-sorted_vector.cxx
+++ b/o3tl/qa/test-sorted_vector.cxx
@@ -98,7 +98,7 @@ public:
         CPPUNIT_ASSERT_EQUAL( static_cast<size_t>(1), aVec.erase(p1) );
         CPPUNIT_ASSERT_EQUAL( static_cast<size_t>(2), aVec.size() );
 
-        aVec.erase(1);
+        aVec.erase_at(1);
         CPPUNIT_ASSERT_EQUAL( static_cast<size_t>(1), aVec.size() );
 
         CPPUNIT_ASSERT_EQUAL( static_cast<size_t>(0), aVec.erase(p4.get()) );
@@ -222,7 +222,7 @@ public:
         CPPUNIT_ASSERT_EQUAL( static_cast<size_t>(1), aVec.erase(p1.get()) );
         CPPUNIT_ASSERT_EQUAL( static_cast<size_t>(2), aVec.size() );
 
-        aVec.erase(1);
+        aVec.erase_at(1);
         CPPUNIT_ASSERT_EQUAL( static_cast<size_t>(1), aVec.size() );
 
         CPPUNIT_ASSERT_EQUAL( static_cast<size_t>(0), aVec.erase(p4.get()) );
diff --git a/sc/source/core/data/attarray.cxx b/sc/source/core/data/attarray.cxx
index c9fd30332c83..a44f00243ce4 100644
--- a/sc/source/core/data/attarray.cxx
+++ b/sc/source/core/data/attarray.cxx
@@ -375,7 +375,7 @@ void ScAttrArray::RemoveCondFormat( SCROW nStartRow, SCROW nEndRow, sal_uInt32 n
                     if(itr != rCondFormatData.end())
                     {
                         ScCondFormatIndexes aNewCondFormatData(rCondFormatData);
-                        aNewCondFormatData.erase(nIndex);
+                        aNewCondFormatData.erase_at(std::distance(rCondFormatData.begin(), itr));
                         ScCondFormatItem aItem( std::move(aNewCondFormatData) );
                         pPatternAttr->GetItemSet().Put( aItem );
                         SetPatternArea( nTempStartRow, nTempEndRow, std::move(pPatternAttr), true );
diff --git a/sw/source/core/doc/acmplwrd.cxx b/sw/source/core/doc/acmplwrd.cxx
index 3aa05a5f579a..08f796270a3e 100644
--- a/sw/source/core/doc/acmplwrd.cxx
+++ b/sw/source/core/doc/acmplwrd.cxx
@@ -291,11 +291,10 @@ void SwAutoCompleteWord::SetMaxCount(
         SwAutoCompleteStringPtrDeque::size_type nLRUIndex = nNewMax-1;
         while (nNewMax < m_WordList.size() && nLRUIndex < m_aLRUList.size())
         {
-            editeng::SortedAutoCompleteStrings::const_iterator it =
-                m_WordList.find(m_aLRUList[ nLRUIndex++ ]);
+            auto it = m_WordList.find(m_aLRUList[nLRUIndex++]);
             OSL_ENSURE( m_WordList.end() != it, "String not found" );
             editeng::IAutoCompleteString *const pDel = *it;
-            m_WordList.erase(it - m_WordList.begin());
+            m_WordList.erase(it);
             delete pDel;
         }
         m_aLRUList.erase( m_aLRUList.begin() + nNewMax - 1, m_aLRUList.end() );
@@ -313,7 +312,7 @@ void SwAutoCompleteWord::SetMinWordLen( sal_uInt16 n )
             {
                 SwAutoCompleteString *const pDel =
                     dynamic_cast<SwAutoCompleteString*>(m_WordList[nPos]);
-                m_WordList.erase(nPos);
+                m_WordList.erase_at(nPos);
 
                 SwAutoCompleteStringPtrDeque::iterator it = std::find( m_aLRUList.begin(), m_aLRUList.end(), pDel );
                 OSL_ENSURE( m_aLRUList.end() != it, "String not found" );
@@ -351,7 +350,7 @@ void SwAutoCompleteWord::CheckChangedList(
         {
             SwAutoCompleteString *const pDel =
                 dynamic_cast<SwAutoCompleteString*>(m_WordList[nMyPos]);
-            m_WordList.erase(nMyPos);
+            m_WordList.erase_at(nMyPos);
             SwAutoCompleteStringPtrDeque::iterator it = std::find( m_aLRUList.begin(), m_aLRUList.end(), pDel );
             OSL_ENSURE( m_aLRUList.end() != it, "String not found" );
             m_aLRUList.erase( it );
@@ -390,7 +389,7 @@ void SwAutoCompleteWord::DocumentDying(const SwDoc& rDoc)
         SwAutoCompleteString *const pCurrent = dynamic_cast<SwAutoCompleteString*>(m_WordList[nPos - 1]);
         if(pCurrent && pCurrent->RemoveDocument(rDoc) && bDelete)
         {
-            m_WordList.erase(nPos - 1);
+            m_WordList.erase_at(nPos - 1);
             SwAutoCompleteStringPtrDeque::iterator it = std::find( m_aLRUList.begin(), m_aLRUList.end(), pCurrent );
             OSL_ENSURE( m_aLRUList.end() != it, "word not found in LRU list" );
             m_aLRUList.erase( it );
diff --git a/sw/source/core/doc/docfld.cxx b/sw/source/core/doc/docfld.cxx
index 68b6df983e4a..eecfc42fc1ab 100644
--- a/sw/source/core/doc/docfld.cxx
+++ b/sw/source/core/doc/docfld.cxx
@@ -784,7 +784,7 @@ void SwDocUpdateField::InsDelFieldInFieldLst( bool bIns, const SwTextField& rFie
         {
             if (&rField == (*m_pFieldSortList)[n]->GetPointer())
             {
-                m_pFieldSortList->erase(n);
+                m_pFieldSortList->erase_at(n);
                 n--; // one field can occur multiple times
             }
         }
diff --git a/sw/source/core/doc/docredln.cxx b/sw/source/core/doc/docredln.cxx
index 354aa058d9ed..207ed07dd95c 100644
--- a/sw/source/core/doc/docredln.cxx
+++ b/sw/source/core/doc/docredln.cxx
@@ -635,7 +635,7 @@ void SwRedlineTable::DeleteAndDestroyAll()
     while (!maVector.empty())
     {
         auto const pRedline = maVector.back();
-        maVector.erase(maVector.size() - 1);
+        maVector.erase_at(maVector.size() - 1);
         LOKRedlineNotification(RedlineNotification::Remove, pRedline);
         delete pRedline;
     }
diff --git a/sw/source/core/docnode/nodes.cxx b/sw/source/core/docnode/nodes.cxx
index a7a2078b2091..7a1d2bd07491 100644
--- a/sw/source/core/docnode/nodes.cxx
+++ b/sw/source/core/docnode/nodes.cxx
@@ -1131,7 +1131,7 @@ void SwNodes::Delete(const SwNodeIndex &rIndex, sal_uLong nNodes)
                                 m_pOutlineNodes->Seek_Entry( pNd, &nIdxPos ))
                         {
                             // remove outline indices
-                            m_pOutlineNodes->erase(nIdxPos);
+                            m_pOutlineNodes->erase_at(nIdxPos);
                             bUpdateOutline = true;
                         }
                         pTextNode->InvalidateNumRule();
@@ -1359,7 +1359,7 @@ void SwNodes::DelNodes( const SwNodeIndex & rStart, sal_uLong nCnt )
                 SwOutlineNodes::size_type nIdxPos;
                 if( m_pOutlineNodes->Seek_Entry( pNd, &nIdxPos ))
                 {
-                    m_pOutlineNodes->erase(nIdxPos);
+                    m_pOutlineNodes->erase_at(nIdxPos);
                     bUpdateNum = 1;
                 }
             }


More information about the Libreoffice-commits mailing list