Date: prev next · Thread: first prev next last
2012 Archives by date, by thread · List index


Hi

These patches convert various places from SV_DECL_PTRARR to STL containers.

Patches 18-21 have passed a full make check.

The others have various issues, but I'm posting them since they're the last surviving remnants, and maybe somebody feels like tracking down the bug:

bad-FILTER-Convert-SV_DECL_PTRARR_SORT_DEL_VISIBILITY-SvxMSDffS.patch
gives me a link error when making the SW module which I'm not sure how to solve

bad-SVL-untested-svdde.diff
is untested because it only compiles on windows, and I don't currently have a working windows build box.

bad-SVL-SfxListener.diff
bad-SW-Convert-SV_DECL_PTRARR_SORT_DEL-InsCapOptArr-to-boos.patch
bad-SW-Convert-SV_DECL_PTRARR_SORT-SwSortElements-to-std-ve.patch
bad-SW-NdHints.diff
crashes nowhere near the changed code, so I have no idea what I'm doing wrong


Regards, Noel Grandin

Disclaimer: http://www.peralex.com/disclaimer.html


Attachment: 0020-Convert-SV_DECL_PTRARR_SORT-SwBlockNames-to-o3tl-sor.patch
Description: application/mbox

Attachment: 0021-Convert-SV_DECL_PTRARR_SORT_DEL-_SwRedlineTbl-to-o3t.patch
Description: application/mbox

Attachment: bad-FILTER-Convert-SV_DECL_PTRARR_SORT_DEL_VISIBILITY-SvxMSDffS.patch
Description: application/mbox

diff --git a/svl/inc/svl/brdcst.hxx b/svl/inc/svl/brdcst.hxx
index 007d4c0..5b0e7f1 100644
--- a/svl/inc/svl/brdcst.hxx
+++ b/svl/inc/svl/brdcst.hxx
@@ -21,14 +21,12 @@
 
 #include "svl/svldllapi.h"
 #include <tools/rtti.hxx>
-#include <svl/svarray.hxx>
+#include <vector>
 
 class SfxListener;
 class SfxHint;
 
-#ifndef _SFX_BRDCST_CXX
-typedef SvPtrarr SfxListenerArr_Impl;
-#endif
+typedef std::vector<SfxListener*> SfxListenerArr_Impl;
 
 //-------------------------------------------------------------------------
 
@@ -39,8 +37,8 @@ friend class SfxListener;
     SfxListenerArr_Impl     aListeners;
 
 private:
-    sal_Bool         AddListener( SfxListener& rListener );
-    void                    RemoveListener( SfxListener& rListener );
+    void                    AddListener( SfxListener& rListener );
+    void                    RemoveListener( const SfxListener& rListener );
     const SfxBroadcaster&   operator=(const SfxBroadcaster &); // verboten
 
 protected:
@@ -55,10 +53,10 @@ public:
     virtual                 ~SfxBroadcaster();
 
     void                    Broadcast( const SfxHint &rHint );
-    sal_Bool                    HasListeners() const;
-    sal_uInt16                  GetListenerCount() const { return aListeners.Count(); }
+    bool                    HasListeners() const;
+    sal_uInt16              GetListenerCount() const { return aListeners.size(); }
     SfxListener*            GetListener( sal_uInt16 nNo ) const
-                            { return (SfxListener*) aListeners[nNo]; }
+                            { return aListeners[nNo]; }
 };
 
 #endif
diff --git a/svl/source/notify/brdcst.cxx b/svl/source/notify/brdcst.cxx
index 7cd424b..058aec4 100644
--- a/svl/source/notify/brdcst.cxx
+++ b/svl/source/notify/brdcst.cxx
@@ -24,12 +24,11 @@
 #include <svl/hint.hxx>
 #include <svl/smplhint.hxx>
 #include <svl/lstner.hxx>
+#include <vector>
 
-SV_DECL_PTRARR( SfxListenerArr_Impl, SfxListener*, 0 )
-
-#define _SFX_BRDCST_CXX
 #include <svl/brdcst.hxx>
 
+
 //====================================================================
 DBG_NAME(SfxBroadcaster)
 TYPEINIT0(SfxBroadcaster);
@@ -45,13 +44,13 @@ void SfxBroadcaster::Broadcast( const SfxHint &rHint )
     DBG_CHKTHIS(SfxBroadcaster, 0);
 
     // is anybody to notify?
-    if ( aListeners.Count() /*! || aGlobListeners.Count() */ )
+    if ( !aListeners.empty() )
     {
         // notify all registered listeners exactly once
-        for ( sal_uInt16 n = 0; n < aListeners.Count(); ++n )
+        for( SfxListenerArr_Impl::iterator it = aListeners.begin(); it != aListeners.end(); ++it )
         {
-            SfxListener* pListener = aListeners[n];
-            if ( pListener )
+            SfxListener* pListener = *it;
+            if( pListener )
                 pListener->Notify( *this, rHint );
         }
     }
@@ -66,10 +65,10 @@ SfxBroadcaster::~SfxBroadcaster()
     Broadcast( SfxSimpleHint(SFX_HINT_DYING) );
 
     // remove all still registered listeners
-    for ( sal_uInt16 nPos = 0; nPos < aListeners.Count(); ++nPos )
+    for( SfxListenerArr_Impl::iterator it = aListeners.begin(); it != aListeners.end(); ++it )
     {
-        SfxListener *pListener = aListeners[nPos];
-        if ( pListener )
+        SfxListener *pListener = *it;
+        if( pListener )
             pListener->RemoveBroadcaster_Impl(*this);
     }
 }
@@ -88,14 +87,14 @@ SfxBroadcaster::SfxBroadcaster()
 // copy ctor of class SfxBroadcaster
 
 
-SfxBroadcaster::SfxBroadcaster( const SfxBroadcaster &rBC )
+SfxBroadcaster::SfxBroadcaster( const SfxBroadcaster &rOther )
 {
     DBG_CTOR(SfxBroadcaster, 0);
 
-    for ( sal_uInt16 n = 0; n < rBC.aListeners.Count(); ++n )
+    for( SfxListenerArr_Impl::const_iterator it = rOther.aListeners.begin(); it != 
rOther.aListeners.end(); ++it )
     {
-        SfxListener *pListener = rBC.aListeners[n];
-        if ( pListener )
+        SfxListener *pListener = (SfxListener *)*it;
+        if( pListener )
             pListener->StartListening( *this );
     }
 }
@@ -104,25 +103,26 @@ SfxBroadcaster::SfxBroadcaster( const SfxBroadcaster &rBC )
 
 // add a new SfxListener to the list
 
-sal_Bool SfxBroadcaster::AddListener( SfxListener& rListener )
+void SfxBroadcaster::AddListener( SfxListener& rListener )
 {
     DBG_CHKTHIS(SfxBroadcaster, 0);
-    const SfxListener *pListener = &rListener;
-    const SfxListener *pNull = 0;
-    sal_uInt16 nFreePos = aListeners.GetPos( pNull );
-    if ( nFreePos < aListeners.Count() )
-        aListeners.GetData()[nFreePos] = pListener;
-    else if ( aListeners.Count() < (USHRT_MAX-1) )
-        aListeners.Insert( pListener, aListeners.Count() );
-    else
+    SfxListener *pListener = &rListener;
+
+    for( SfxListenerArr_Impl::iterator it = aListeners.begin(); it != aListeners.end(); ++it )
     {
-        OSL_FAIL( "array overflow" );
-        return sal_False;
+        if( *it == 0 )
+        {
+          *it = pListener;
+          return;
+        }
     }
 
-    DBG_ASSERT( USHRT_MAX != aListeners.GetPos(pListener),
-                "AddListener failed" );
-    return sal_True;
+    // not really an array overflow, but it's nice to check that someone isn't going bezerk
+    // adding listeners
+    if ( aListeners.size() >= (USHRT_MAX-1) )    
+        OSL_FAIL( "array overflow" );
+
+    aListeners.push_back( pListener );
 }
 
 //--------------------------------------------------------------------
@@ -140,10 +140,9 @@ void SfxBroadcaster::ListenersGone()
 
 void SfxBroadcaster::Forward(SfxBroadcaster& rBC, const SfxHint& rHint)
 {
-    const sal_uInt16 nCount = aListeners.Count();
-    for ( sal_uInt16 i = 0; i < nCount; ++i )
+    for( SfxListenerArr_Impl::iterator it = aListeners.begin(); it != aListeners.end(); ++it )
     {
-        SfxListener *pListener = aListeners[i];
+        SfxListener *pListener = *it;
         if ( pListener )
             pListener->Notify( rBC, rHint );
     }
@@ -153,25 +152,31 @@ void SfxBroadcaster::Forward(SfxBroadcaster& rBC, const SfxHint& rHint)
 
 // remove one SfxListener from the list
 
-void SfxBroadcaster::RemoveListener( SfxListener& rListener )
+void SfxBroadcaster::RemoveListener( const SfxListener& rListener )
 {
     {DBG_CHKTHIS(SfxBroadcaster, 0);}
-    const SfxListener *pListener = &rListener;
-    sal_uInt16 nPos = aListeners.GetPos(pListener);
-    DBG_ASSERT( nPos != USHRT_MAX, "RemoveListener: Listener unknown" );
-    aListeners.GetData()[nPos] = 0;
-    if ( !HasListeners() )
-        ListenersGone();
+
+    // search from the end, its more likely to be there
+    for( SfxListenerArr_Impl::reverse_iterator it = aListeners.rbegin(); it != aListeners.rend(); 
++it )
+    {
+        SfxListener *pListener = *it;
+        if( pListener == &rListener )
+        {
+            *it = 0;
+            if ( !HasListeners() )
+                ListenersGone();
+            return;
+        }
+    }
+
+    DBG_ASSERT( false, "RemoveListener: Listener unknown" );
 }
 
 //--------------------------------------------------------------------
 
-sal_Bool SfxBroadcaster::HasListeners() const
+bool SfxBroadcaster::HasListeners() const
 {
-    for ( sal_uInt16 n = 0; n < aListeners.Count(); ++n )
-        if ( aListeners.GetObject(n) != 0 )
-            return sal_True;
-    return sal_False;
+    return !aListeners.empty();
 }
 
 //--------------------------------------------------------------------
diff --git a/svl/source/notify/lstner.cxx b/svl/source/notify/lstner.cxx
index 5d3d6b8..79a9dc5 100644
--- a/svl/source/notify/lstner.cxx
+++ b/svl/source/notify/lstner.cxx
@@ -85,13 +85,11 @@ sal_Bool SfxListener::StartListening( SfxBroadcaster& rBroadcaster, sal_Bool bPr
 
     if ( !bPreventDups || !IsListening( rBroadcaster ) )
     {
-        if ( rBroadcaster.AddListener(*this) )
-        {
-            aBCs.push_back( &rBroadcaster );
+        rBroadcaster.AddListener(*this);
+        aBCs.push_back( &rBroadcaster );
 
-            DBG_ASSERT( IsListening(rBroadcaster), "StartListening failed" );
-            return sal_True;
-        }
+        DBG_ASSERT( IsListening(rBroadcaster), "StartListening failed" );
+        return sal_True;
 
     }
     return sal_False;
diff --git a/svl/source/svdde/ddesvr.cxx b/svl/source/svdde/ddesvr.cxx
index 0e4dbd1..809df16 100644
--- a/svl/source/svdde/ddesvr.cxx
+++ b/svl/source/svdde/ddesvr.cxx
@@ -23,9 +23,9 @@
 #include <algorithm>
 #include <comphelper/string.hxx>
 #include <svl/svdde.hxx>
-#include <svl/svarray.hxx>
 #include <tools/debug.hxx>
 #include <osl/thread.h>
+#include <o3tl/sorted_vector.hxx>
 
 enum DdeItemType
 {
@@ -41,8 +41,7 @@ struct DdeItemImpData
     DdeItemImpData( sal_uLong nH ) : nHCnv( nH ), nCnt( 1 ) {}
 };
 
-SV_DECL_VARARR( DdeItemImp, DdeItemImpData, 1 )
-SV_IMPL_VARARR( DdeItemImp, DdeItemImpData )
+typedef std::vector<DdeItemImpData> DdeItemImp;
 
 // --- DdeInternat::SvrCallback() ----------------------------------
 
@@ -864,7 +863,7 @@ void DdeItem::IncMonitor( sal_uLong nHCnv )
     }
     else
     {
-        for( sal_uInt16 n = pImpData->Count(); n; )
+        for( sal_uInt16 n = pImpData->size(); n; )
             if( (*pImpData)[ --n ].nHCnv == nHCnv )
             {
                 ++(*pImpData)[ n ].nHCnv;
@@ -872,7 +871,7 @@ void DdeItem::IncMonitor( sal_uLong nHCnv )
             }
     }
 
-    pImpData->Insert( DdeItemImpData( nHCnv ), pImpData->Count() );
+    pImpData->push_back( DdeItemImpData( nHCnv ) );
 }
 
 // --- DdeItem::DecMonitor() ------------------------------------------
@@ -881,14 +880,14 @@ void DdeItem::DecMonitor( sal_uLong nHCnv )
 {
     if( pImpData )
     {
-        DdeItemImpData* pData = (DdeItemImpData*)pImpData->GetData();
-        for( sal_uInt16 n = pImpData->Count(); n; --n, ++pData )
+        for( sal_uInt16 n = 0; n < pImpData->size(); ++n )
+            DdeItemImpData* pData = &(*pImpData)[n];
             if( pData->nHCnv == nHCnv )
             {
                 if( !pData->nCnt || !--pData->nCnt )
                 {
-                    if( 1 < pImpData->Count() )
-                        pImpData->Remove( pImpData->Count() - n );
+                    if( 1 < pImpData->size() )
+                        pImpData->erase( n );
                     else
                     {
                         delete pImpData, pImpData = 0;
@@ -907,7 +906,7 @@ short DdeItem::GetLinks()
 {
     short nCnt = 0;
     if( pImpData )
-        for( sal_uInt16 n = pImpData->Count(); n; )
+        for( sal_uInt16 n = pImpData->size(); n; )
             nCnt = nCnt + (*pImpData)[ --n ].nCnt;
     return nCnt;
 }

Attachment: bad-SW-Convert-SV_DECL_PTRARR_SORT_DEL-InsCapOptArr-to-boos.patch
Description: application/mbox

Attachment: bad-SW-Convert-SV_DECL_PTRARR_SORT-SwSortElements-to-std-ve.patch
Description: application/mbox

diff --git a/sw/inc/ndhints.hxx b/sw/inc/ndhints.hxx
index 6f0d896..75df3f7 100644
--- a/sw/inc/ndhints.hxx
+++ b/sw/inc/ndhints.hxx
@@ -29,8 +29,8 @@
 #define _NDHINTS_HXX
 
 
-#include <svl/svarray.hxx>
 #include <tools/mempool.hxx>
+#include <o3tl/sorted_vector.hxx>
 
 #include "swtypes.hxx"
 
@@ -71,9 +71,17 @@ MakeRedlineTxtAttr( SwDoc & rDoc, SfxPoolItem& rAttr );
 
  // Class SwpHtStart/End
 
+struct CompareSwpHtStart
+{
+    bool operator()(SwTxtAttr* const lhs, SwTxtAttr* const rhs) const;
+};
+class SwpHtStart : public o3tl::sorted_vector<SwTxtAttr*, CompareSwpHtStart> {};
 
-SV_DECL_PTRARR_SORT(SwpHtStart,SwTxtAttr*,1)
-SV_DECL_PTRARR_SORT(SwpHtEnd,SwTxtAttr*,1)
+struct CompareSwpHtEnd
+{
+    bool operator()(SwTxtAttr* const lhs, SwTxtAttr* const rhs) const;
+};
+class SwpHtEnd : public o3tl::sorted_vector<SwTxtAttr*, CompareSwpHtEnd> {};
 
 // Class SwpHintsArr
 
@@ -102,18 +110,17 @@ public:
     inline       SwTxtAttr * GetEnd  ( const sal_uInt16 nPos )
         { return m_HintEnds  [nPos]; }
 
-    inline sal_uInt16 GetEndCount()   const { return m_HintEnds  .Count(); }
-    inline sal_uInt16 GetStartCount() const { return m_HintStarts.Count(); }
+    inline sal_uInt16 GetEndCount()   const { return m_HintEnds  .size(); }
+    inline sal_uInt16 GetStartCount() const { return m_HintStarts.size(); }
 
     inline sal_uInt16 GetStartOf( const SwTxtAttr *pHt ) const;
-    inline sal_uInt16 GetPos( const SwTxtAttr *pHt ) const
-        { return m_HintStarts.GetPos( pHt ); }
+    sal_uInt16 GetPos( const SwTxtAttr *pHt ) const;
 
     inline SwTxtAttr * GetTextHint( const sal_uInt16 nIdx )
         { return GetStart(nIdx); }
     inline const SwTxtAttr * operator[]( const sal_uInt16 nIdx ) const
         { return m_HintStarts[nIdx]; }
-    inline sal_uInt16 Count() const { return m_HintStarts.Count(); }
+    inline sal_uInt16 Count() const { return m_HintStarts.size(); }
 
 #ifdef DBG_UTIL
     bool Check() const;
@@ -205,12 +212,12 @@ SvStream &operator<<(SvStream &aS, const SwpHints &rHints); //$ ostream
 
 inline sal_uInt16 SwpHintsArray::GetStartOf( const SwTxtAttr *pHt ) const
 {
-    sal_uInt16 nPos;
-    if ( !m_HintStarts.Seek_Entry( pHt, &nPos ) )
+    SwpHtStart::const_iterator it = m_HintStarts.find( (SwTxtAttr*)pHt );
+    if ( it == m_HintStarts.end() )
     {
-        nPos = USHRT_MAX;
+        return USHRT_MAX;
     }
-    return nPos;
+    return it - m_HintStarts.begin();
 }
 
 inline SwTxtAttr *SwpHintsArray::Cut( const sal_uInt16 nPosInStart )
diff --git a/sw/source/core/text/redlnitr.cxx b/sw/source/core/text/redlnitr.cxx
index 621930e..ede99bf 100644
--- a/sw/source/core/text/redlnitr.cxx
+++ b/sw/source/core/text/redlnitr.cxx
@@ -275,7 +275,7 @@ short SwRedlineItr::_Seek( SwFont& rFnt, xub_StrLen nNew, xub_StrLen nOld )
                                 const_cast<SwDoc&>(rDoc),
                                 *const_cast<SfxPoolItem*>(pItem) );
                             pAttr->SetPriorityAttr( sal_True );
-                            aHints.C40_INSERT( SwTxtAttr, pAttr, aHints.Count());
+                            aHints.insert( pAttr );
                             rAttrHandler.PushAndChg( *pAttr, rFnt );
                             if( RES_CHRATR_COLOR == nWhich )
                                 rFnt.SetNoCol( sal_True );
@@ -338,10 +338,10 @@ void SwRedlineItr::_Clear( SwFont* pFnt )
 {
     OSL_ENSURE( bOn, "SwRedlineItr::Clear: Off?" );
     bOn = sal_False;
-    while( aHints.Count() )
+    while( !aHints.empty() )
     {
         SwTxtAttr *pPos = aHints[ 0 ];
-        aHints.Remove(0);
+        aHints.erase((size_t)0);
         if( pFnt )
             rAttrHandler.PopAndChg( *pPos, *pFnt );
         else
@@ -377,7 +377,7 @@ sal_Bool SwRedlineItr::_ChkSpecialUnderline() const
     // Wenn die Unterstreichung oder das Escapement vom Redling kommt,
     // wenden wir immer das SpecialUnderlining, d.h. die Unterstreichung
     // unter der Grundlinie an.
-    for( MSHORT i = 0; i < aHints.Count(); ++i )
+    for( MSHORT i = 0; i < aHints.size(); ++i )
     {
         MSHORT nWhich = aHints[i]->Which();
         if( RES_CHRATR_UNDERLINE == nWhich ||
diff --git a/sw/source/core/text/redlnitr.hxx b/sw/source/core/text/redlnitr.hxx
index 8cbc117..6d84d12 100644
--- a/sw/source/core/text/redlnitr.hxx
+++ b/sw/source/core/text/redlnitr.hxx
@@ -66,7 +66,7 @@ public:
 
 class SwRedlineItr
 {
-    SwpHtStart_SAR aHints;
+    SwpHtStart aHints;
     const SwDoc& rDoc;
     const SwTxtNode& rNd;
     SwAttrHandler& rAttrHandler;
diff --git a/sw/source/core/txtnode/ndhints.cxx b/sw/source/core/txtnode/ndhints.cxx
index 8b495c2..0d3f6eb 100644
--- a/sw/source/core/txtnode/ndhints.cxx
+++ b/sw/source/core/txtnode/ndhints.cxx
@@ -36,9 +36,6 @@
 #endif
 
 
-_SV_IMPL_SORTAR_ALG( SwpHtStart, SwTxtAttr* )
-_SV_IMPL_SORTAR_ALG( SwpHtEnd, SwTxtAttr* )
-
 inline void DumpHints(const SwpHtStart &, const SwpHtEnd &) { }
 
 /*************************************************************************
@@ -129,76 +126,14 @@ static sal_Bool lcl_IsLessEnd( const SwTxtAttr &rHt1, const SwTxtAttr &rHt2 )
     return ( nHt1 < nHt2 );
 }
 
-/*************************************************************************
- *                      SwpHtStart::Seek_Entry()
- *************************************************************************/
-
-sal_Bool SwpHtStart::Seek_Entry( const SwTxtAttr *pElement, sal_uInt16 *pPos ) const
+bool CompareSwpHtStart::operator()(SwTxtAttr* const lhs, SwTxtAttr* const rhs) const
 {
-    sal_uInt16 nOben = Count(), nMitte, nUnten = 0;
-    if( nOben > 0 )
-    {
-        nOben--;
-        while( nUnten <= nOben )
-        {
-            nMitte = nUnten + ( nOben - nUnten ) / 2;
-            const SwTxtAttr *pMitte = (*this)[nMitte];
-            if( IsEqual( *pMitte, *pElement ) )
-            {
-                *pPos = nMitte;
-                return sal_True;
-            }
-            else
-                if( lcl_IsLessStart( *pMitte, *pElement ) )
-                    nUnten = nMitte + 1;
-                else
-                    if( nMitte == 0 )
-                    {
-                        *pPos = nUnten;
-                        return sal_False;
-                    }
-                    else
-                        nOben = nMitte - 1;
-        }
-    }
-    *pPos = nUnten;
-    return sal_False;
+  return lcl_IsLessStart( *lhs, *rhs );
 }
 
-/*************************************************************************
- *                      SwpHtEnd::Seek_Entry()
- *************************************************************************/
-
-sal_Bool SwpHtEnd::Seek_Entry( const SwTxtAttr *pElement, sal_uInt16 *pPos ) const
+bool CompareSwpHtEnd::operator()(SwTxtAttr* const lhs, SwTxtAttr* const rhs) const
 {
-    sal_uInt16 nOben = Count(), nMitte, nUnten = 0;
-    if( nOben > 0 )
-    {
-        nOben--;
-        while( nUnten <= nOben )
-        {
-            nMitte = nUnten + ( nOben - nUnten ) / 2;
-            const SwTxtAttr *pMitte = (*this)[nMitte];
-            if( IsEqual( *pMitte, *pElement ) )
-            {
-                *pPos = nMitte;
-                return sal_True;
-            }
-            else
-                if( lcl_IsLessEnd( *pMitte, *pElement ) )
-                    nUnten = nMitte + 1;
-                else
-                    if( nMitte == 0 )
-                    {
-                        *pPos = nUnten;
-                        return sal_False;
-                    }
-                    else
-                        nOben = nMitte - 1;
-        }
-    }
-    *pPos = nUnten;
-    return sal_False;
+  return lcl_IsLessEnd( *lhs, *rhs );
 }
 
 /*************************************************************************
@@ -209,27 +144,32 @@ void SwpHintsArray::Insert( const SwTxtAttr *pHt )
 {
     Resort();
 #if OSL_DEBUG_LEVEL > 0
-    sal_uInt16 nPos;
-    OSL_ENSURE(!m_HintStarts.Seek_Entry( pHt, &nPos ),
+    OSL_ENSURE(m_HintStarts.find( (SwTxtAttr*)pHt ) == m_HintStarts.end(),
             "Insert: hint already in HtStart");
-    OSL_ENSURE(!m_HintEnds.Seek_Entry( pHt, &nPos ),
+    OSL_ENSURE(m_HintEnds.find( (SwTxtAttr*)pHt ) == m_HintEnds.end(),
             "Insert: hint already in HtEnd");
 #endif
-    m_HintStarts.Insert( pHt );
-    m_HintEnds.Insert( pHt );
+    m_HintStarts.insert( (SwTxtAttr*)pHt );
+    m_HintEnds.insert( (SwTxtAttr*)pHt );
 }
 
 void SwpHintsArray::DeleteAtPos( const sal_uInt16 nPos )
 {
     // optimization: nPos is the position in the Starts array
-    const SwTxtAttr *pHt = m_HintStarts[ nPos ];
-    m_HintStarts.Remove( nPos );
+    SwTxtAttr *pHt = m_HintStarts[ nPos ];
+    m_HintStarts.erase( m_HintStarts.begin() + nPos );
 
     Resort();
 
-    sal_uInt16 nEndPos;
-    m_HintEnds.Seek_Entry( pHt, &nEndPos );
-    m_HintEnds.Remove( nEndPos );
+    m_HintEnds.erase( pHt );
+}
+
+sal_uInt16 SwpHintsArray::GetPos( const SwTxtAttr *pHt ) const
+{
+    SwpHtStart::const_iterator it = m_HintStarts.find( (SwTxtAttr*)pHt );
+    if( it == m_HintStarts.end() )
+        return USHRT_MAX;
+    return it - m_HintStarts.begin();
 }
 
 #ifdef DBG_UTIL
@@ -250,7 +190,7 @@ void SwpHintsArray::DeleteAtPos( const sal_uInt16 nPos )
 bool SwpHintsArray::Check() const
 {
     // 1) gleiche Anzahl in beiden Arrays
-    CHECK_ERR( m_HintStarts.Count() == m_HintEnds.Count(),
+    CHECK_ERR( m_HintStarts.size() == m_HintEnds.size(),
         "HintsCheck: wrong sizes" );
     xub_StrLen nLastStart = 0;
     xub_StrLen nLastEnd   = 0;
@@ -298,13 +238,13 @@ bool SwpHintsArray::Check() const
         // --- Ueberkreuzungen ---
 
         // 5) gleiche Pointer in beiden Arrays
-        if( !m_HintStarts.Seek_Entry( pHt, &nIdx ) )
+        if( m_HintStarts.find( (SwTxtAttr*)pHt ) == m_HintStarts.end() )
             nIdx = STRING_LEN;
 
         CHECK_ERR( STRING_LEN != nIdx, "HintsCheck: no GetStartOf" );
 
         // 6) gleiche Pointer in beiden Arrays
-        if( !m_HintEnds.Seek_Entry( pHt, &nIdx ) )
+        if( m_HintEnds.find( (SwTxtAttr*)pHt ) == m_HintEnds.end() )
             nIdx = STRING_LEN;
 
         CHECK_ERR( STRING_LEN != nIdx, "HintsCheck: no GetEndOf" );
@@ -390,13 +330,13 @@ bool SwpHintsArray::Resort()
     const SwTxtAttr *pLast = 0;
     sal_uInt16 i;
 
-    for ( i = 0; i < m_HintStarts.Count(); ++i )
+    for ( i = 0; i < m_HintStarts.size(); ++i )
     {
-        const SwTxtAttr *pHt = m_HintStarts[i];
+        SwTxtAttr *pHt = m_HintStarts[i];
         if( pLast && !lcl_IsLessStart( *pLast, *pHt ) )
         {
-            m_HintStarts.Remove( i );
-            m_HintStarts.Insert( pHt );
+            m_HintStarts.erase( m_HintStarts.begin() + i );
+            m_HintStarts.insert( pHt );
             pHt = m_HintStarts[i];
             if ( pHt != pLast )
                 --i;
@@ -406,13 +346,13 @@ bool SwpHintsArray::Resort()
     }
 
     pLast = 0;
-    for ( i = 0; i < m_HintEnds.Count(); ++i )
+    for ( i = 0; i < m_HintEnds.size(); ++i )
     {
-        const SwTxtAttr *pHt = m_HintEnds[i];
+        SwTxtAttr *pHt = m_HintEnds[i];
         if( pLast && !lcl_IsLessEnd( *pLast, *pHt ) )
         {
-            m_HintEnds.Remove( i );
-            m_HintEnds.Insert( pHt );
+            m_HintEnds.erase( m_HintEnds.begin() + i );
+            m_HintEnds.insert( pHt );
             pHt = m_HintEnds[i]; // normalerweise == pLast
             // Wenn die Unordnung etwas groesser ist (24200),
             // muessen wir Position i erneut vergleichen.

Attachment: 0018-Convert-SV_DECL_VARARR_SORT-_CpyTabFrms-to-o3tl-sort.patch
Description: application/mbox

Attachment: 0019-Convert-SV_DECL_VARARR_SORT-_MergePos-to-o3tl-sorted.patch
Description: application/mbox


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.