[Libreoffice-commits] .: 10 commits - cui/source editeng/inc editeng/source filter/inc filter/source o3tl/CppunitTest_o3tl_tests.mk o3tl/Package_inc.mk o3tl/inc o3tl/qa sc/inc sc/source sw/source

Michael Stahl mst at kemper.freedesktop.org
Thu Jul 12 05:14:47 PDT 2012


 cui/source/tabpages/autocdlg.cxx               |   17 +--
 editeng/inc/editeng/svxacorr.hxx               |   15 ++
 editeng/source/misc/SvXMLAutoCorrectExport.cxx |    5 
 editeng/source/misc/SvXMLAutoCorrectImport.cxx |    4 
 editeng/source/misc/svxacorr.cxx               |  105 ++++++------------
 filter/inc/filter/msfilter/msdffimp.hxx        |   35 +++---
 filter/source/msfilter/msdffimp.cxx            |    9 -
 o3tl/CppunitTest_o3tl_tests.mk                 |    1 
 o3tl/Package_inc.mk                            |    1 
 o3tl/inc/o3tl/sorted_vector.hxx                |  140 +++++++++++++++++++++++++
 o3tl/qa/test-sorted_vector.cxx                 |   80 ++++++++++++++
 sc/inc/validat.hxx                             |   25 ++--
 sc/source/core/data/documen2.cxx               |    8 +
 sc/source/core/data/documen4.cxx               |    5 
 sc/source/core/data/global.cxx                 |    6 -
 sc/source/core/data/validat.cxx                |   51 +++------
 sc/source/core/inc/addinlis.hxx                |    4 
 sc/source/core/inc/adiasync.hxx                |   28 ++---
 sc/source/core/tool/addinlis.cxx               |   18 +--
 sc/source/core/tool/adiasync.cxx               |   47 +++-----
 sw/source/filter/ww8/ww8graf.cxx               |   29 ++---
 sw/source/filter/ww8/ww8graf2.cxx              |    5 
 sw/source/filter/ww8/ww8par.cxx                |   32 ++---
 sw/source/filter/ww8/ww8par.hxx                |    4 
 sw/source/ui/utlui/content.cxx                 |   92 ++++++++--------
 25 files changed, 472 insertions(+), 294 deletions(-)

New commits:
commit 96f07eeffc8fc526df9b75a12a33ee7d41a9a099
Author: Michael Stahl <mstahl at redhat.com>
Date:   Thu Jul 12 14:03:27 2012 +0200

    sorted_vector should not inherit public std::vector
    
    Clearly we don't want to expose std::vector<Value>::insert here, and
    neither e.g. push_back.
    
    Change-Id: I89917a23d6d9f36f56474cdc361ba4d513516122

diff --git a/o3tl/inc/o3tl/sorted_vector.hxx b/o3tl/inc/o3tl/sorted_vector.hxx
index 79ede03..c2eebab 100644
--- a/o3tl/inc/o3tl/sorted_vector.hxx
+++ b/o3tl/inc/o3tl/sorted_vector.hxx
@@ -34,7 +34,9 @@ public:
     @tpl Compare comparison method
 */
 template <class Value, class Compare = std::less<Value> >
-class sorted_vector : public std::vector<Value>, private sorted_vector_compare<Value, Compare>
+class sorted_vector
+    : private std::vector<Value>
+    , private sorted_vector_compare<Value, Compare>
 {
 public:
     typedef typename std::vector<Value>::iterator  iterator;
@@ -45,8 +47,10 @@ public:
     using std::vector<Value>::begin;
     using std::vector<Value>::end;
     using std::vector<Value>::clear;
-    using std::vector<Value>::insert;
     using std::vector<Value>::erase;
+    using std::vector<Value>::empty;
+    using std::vector<Value>::size;
+    using std::vector<Value>::operator[];
 
     // MODIFIERS
 
@@ -56,7 +60,7 @@ public:
         iterator it = std::lower_bound( begin(), end(), x, me );
         if( it == end() || less_than(x, *it) )
         {
-            it = insert( it, x );
+            it = std::vector<Value>::insert( it, x );
             return std::make_pair( it, true );
         }
         return std::make_pair( it, false );
commit 81181891c93faee024799991317ac2c451f4c0c4
Author: Noel Grandin <noel at peralex.com>
Date:   Wed Jul 11 13:37:00 2012 +0200

    Convert SV_DECL_PTRARR_SORT_DEL(SwContentArr) to o3tl::sorted_vector
    
    Change-Id: Ia6e4f2b4d1cfb1282dafd376ee56f5fa2e493b26

diff --git a/sw/source/ui/utlui/content.cxx b/sw/source/ui/utlui/content.cxx
index 0b26be5..db0fcd2 100644
--- a/sw/source/ui/utlui/content.cxx
+++ b/sw/source/ui/utlui/content.cxx
@@ -87,6 +87,7 @@
 #include <postithelper.hxx>
 #include <redline.hxx>
 #include <docary.hxx>
+#include <o3tl/sorted_vector.hxx>
 
 #include "swabstdlg.hxx"
 #include "globals.hrc"
@@ -105,9 +106,10 @@ using namespace ::com::sun::star::container;
 
 #define NAVI_BOOKMARK_DELIM     (sal_Unicode)1
 
-typedef SwContent* SwContentPtr;
-SV_DECL_PTRARR_SORT_DEL( SwContentArr, SwContentPtr, 0 )
-SV_IMPL_OP_PTRARR_SORT(SwContentArr, SwContentPtr)
+class SwContentArr : public o3tl::sorted_vector<SwContent*, o3tl::less_ptr_to<SwContent>> {
+public:
+    ~SwContentArr() { DeleteAndDestroyAll(); }
+};
 
 sal_Bool SwContentTree::bIsInDrag = sal_False;
 
@@ -286,10 +288,10 @@ void SwContentType::Init(sal_Bool* pbInvalidateWindow)
             sal_Bool bInvalidate = sal_False;
             if(!pMember)
                 pMember = new SwContentArr;
-            else if(pMember->Count())
+            else if(!pMember->empty())
             {
                 pOldMember = pMember;
-                nOldRegionCount = pOldMember->Count();
+                nOldRegionCount = pOldMember->size();
                 pMember = new SwContentArr;
             }
             const Point aNullPt;
@@ -320,22 +322,22 @@ void SwContentType::Init(sal_Bool* pbInvalidateWindow)
                     if( !pFmt->GetInfo( aAskItem ) &&
                         !aAskItem.pObject )     // not visible
                         pCnt->SetInvisible();
-                    pMember->Insert(pCnt);
+                    pMember->insert(pCnt);
 
-                    sal_uInt16 nPos = pMember->Count() - 1;
+                    sal_uInt16 nPos = pMember->size() - 1;
                     if(nOldRegionCount > nPos &&
-                        (pOldMember->GetObject(nPos))->IsInvisible()
+                        ((*pOldMember)[nPos])->IsInvisible()
                                 != pCnt->IsInvisible())
                             bInvalidate = sal_True;
                 }
             }
-            nMemberCount = pMember->Count();
+            nMemberCount = pMember->size();
             sTypeToken = rtl::OUString::createFromAscii(pMarkToRegion);
             bEdit = sal_True;
             bDelete = sal_False;
             if(pOldMember)
             {
-                pOldMember->DeleteAndDestroy(0, pOldMember->Count());
+                pOldMember->DeleteAndDestroyAll();
                 delete pOldMember;
                 if(pbInvalidateWindow && bInvalidate)
                     *pbInvalidateWindow = sal_True;
@@ -360,8 +362,8 @@ void SwContentType::Init(sal_Bool* pbInvalidateWindow)
             nMemberCount = 0;
             if(!pMember)
                 pMember = new SwContentArr;
-            else if(pMember->Count())
-                pMember->DeleteAndDestroy(0, pMember->Count());
+            else if(!pMember->empty())
+                pMember->DeleteAndDestroyAll();
 
             SwGetINetAttrs aArr;
             nMemberCount = pWrtShell->GetINetAttrs( aArr );
@@ -378,7 +380,7 @@ void SwContentType::Init(sal_Bool* pbInvalidateWindow)
                                         RTL_TEXTENCODING_UTF8 ),
                                     &p->rINetAttr,
                                     n );
-                pMember->Insert( pCnt );
+                pMember->insert( pCnt );
             }
             bEdit = sal_True;
             nOldMemberCount = nMemberCount;
@@ -390,8 +392,8 @@ void SwContentType::Init(sal_Bool* pbInvalidateWindow)
             nMemberCount = 0;
             if(!pMember)
                 pMember = new SwContentArr;
-            else if(pMember->Count())
-                pMember->DeleteAndDestroy(0, pMember->Count());
+            else if(!pMember->empty())
+                pMember->DeleteAndDestroyAll();
 
             SwPostItMgr* aMgr = pWrtShell->GetView().GetPostItMgr();
             if (aMgr)
@@ -411,7 +413,7 @@ void SwContentType::Init(sal_Bool* pbInvalidateWindow)
                                                 sEntry,
                                                 (const SwFmtFld*)aFmtFld,
                                                 nMemberCount);
-                            pMember->Insert(pCnt);
+                            pMember->insert(pCnt);
                             nMemberCount++;
                         }
                     }
@@ -464,8 +466,8 @@ const SwContent* SwContentType::GetMember(sal_uInt16 nIndex)
     {
         FillMemberList();
     }
-    if(nIndex < pMember->Count())
-        return pMember->GetObject(nIndex);
+    if(nIndex < pMember->size())
+        return (*pMember)[nIndex];
     else
         return 0;
 
@@ -488,14 +490,14 @@ void    SwContentType::FillMemberList(sal_Bool* pbLevelOrVisibilityChanged)
     if(pMember && pbLevelOrVisibilityChanged)
     {
         pOldMember = pMember;
-        nOldMemberCount = pOldMember->Count();
+        nOldMemberCount = pOldMember->size();
         pMember = new SwContentArr;
         *pbLevelOrVisibilityChanged = sal_False;
     }
     else if(!pMember)
         pMember = new SwContentArr;
-    else if(pMember->Count())
-        pMember->DeleteAndDestroy(0, pMember->Count());
+    else if(!pMember->empty())
+        pMember->DeleteAndDestroyAll();
     switch(nContentType)
     {
         case CONTENT_TYPE_OUTLINE   :
@@ -516,12 +518,12 @@ void    SwContentType::FillMemberList(sal_Bool* pbLevelOrVisibilityChanged)
                     SwNavigationPI::CleanEntry( aEntry );
                     SwOutlineContent* pCnt = new SwOutlineContent(this, aEntry, i, nLevel,
                                                         pWrtShell->IsOutlineMovable( i ), nPos );
-                    pMember->Insert(pCnt);//, nPos);
+                    pMember->insert(pCnt);//, nPos);
                     // bei gleicher Anzahl und vorhandenem pOldMember wird die
                     // alte mit der neuen OutlinePos verglichen
                     // cast fuer Win16
                     if(nOldMemberCount > (int)nPos &&
-                        ((SwOutlineContent*)pOldMember->GetObject(nPos))->GetOutlineLevel() != nLevel)
+                        ((SwOutlineContent*)(*pOldMember)[nPos])->GetOutlineLevel() != nLevel)
                         *pbLevelOrVisibilityChanged = sal_True;
 
                     nPos++;
@@ -548,10 +550,10 @@ void    SwContentType::FillMemberList(sal_Bool* pbLevelOrVisibilityChanged)
                     !aAskItem.pObject )     // not visible
                     pCnt->SetInvisible();
 
-                pMember->Insert(pCnt);
+                pMember->insert(pCnt);
 
                 if(nOldMemberCount > (int)i &&
-                    (pOldMember->GetObject(i))->IsInvisible() != pCnt->IsInvisible())
+                    (*pOldMember)[i]->IsInvisible() != pCnt->IsInvisible())
                         *pbLevelOrVisibilityChanged = sal_True;
             }
         }
@@ -593,9 +595,9 @@ void    SwContentType::FillMemberList(sal_Bool* pbLevelOrVisibilityChanged)
                 if( !pFrmFmt->GetInfo( aAskItem ) &&
                     !aAskItem.pObject )     // not visible
                     pCnt->SetInvisible();
-                pMember->Insert(pCnt);
+                pMember->insert(pCnt);
                 if(nOldMemberCount > (int)i &&
-                    (pOldMember->GetObject(i))->IsInvisible() != pCnt->IsInvisible())
+                    (*pOldMember)[i]->IsInvisible() != pCnt->IsInvisible())
                         *pbLevelOrVisibilityChanged = sal_True;
             }
         }
@@ -612,7 +614,7 @@ void    SwContentType::FillMemberList(sal_Bool* pbLevelOrVisibilityChanged)
                     const String& rBkmName = ppBookmark->get()->GetName();
                     //nYPos von 0 -> text::Bookmarks werden nach Alphabet sortiert
                     SwContent* pCnt = new SwContent(this, rBkmName, 0);
-                    pMember->Insert(pCnt);
+                    pMember->insert(pCnt);
                 }
             }
         }
@@ -645,16 +647,16 @@ void    SwContentType::FillMemberList(sal_Bool* pbLevelOrVisibilityChanged)
                     if( !pFmt->GetInfo( aAskItem ) &&
                         !aAskItem.pObject )     // not visible
                         pCnt->SetInvisible();
-                    pMember->Insert(pCnt);
+                    pMember->insert(pCnt);
 
-                    sal_uInt16 nPos = pMember->Count() - 1;
+                    sal_uInt16 nPos = pMember->size() - 1;
                     if(nOldMemberCount > nPos &&
-                        (pOldMember->GetObject(nPos))->IsInvisible()
+                        (*pOldMember)[nPos]->IsInvisible()
                                 != pCnt->IsInvisible())
                             *pbLevelOrVisibilityChanged = sal_True;
                 }
             }
-            nMemberCount = pMember->Count();
+            nMemberCount = pMember->size();
         }
         break;
         case CONTENT_TYPE_REFERENCE:
@@ -666,7 +668,7 @@ void    SwContentType::FillMemberList(sal_Bool* pbLevelOrVisibilityChanged)
             {
                 //Referenzen nach Alphabet sortiert
                 SwContent* pCnt = new SwContent(this, *i, 0);
-                pMember->Insert(pCnt);
+                pMember->insert(pCnt);
             }
         }
         break;
@@ -687,7 +689,7 @@ void    SwContentType::FillMemberList(sal_Bool* pbLevelOrVisibilityChanged)
                                         RTL_TEXTENCODING_UTF8 ),
                                     &p->rINetAttr,
                                     n );
-                pMember->Insert( pCnt );
+                pMember->insert( pCnt );
             }
         }
         break;
@@ -707,10 +709,10 @@ void    SwContentType::FillMemberList(sal_Bool* pbLevelOrVisibilityChanged)
                     !aAskItem.pObject )     // not visible
                     pCnt->SetInvisible();
 
-                pMember->Insert( pCnt );
-                sal_uInt16 nPos = pMember->Count() - 1;
+                pMember->insert( pCnt );
+                sal_uInt16 nPos = pMember->size() - 1;
                 if(nOldMemberCount > nPos &&
-                    (pOldMember->GetObject(nPos))->IsInvisible()
+                    (*pOldMember)[nPos]->IsInvisible()
                             != pCnt->IsInvisible())
                         *pbLevelOrVisibilityChanged = sal_True;
             }
@@ -721,8 +723,8 @@ void    SwContentType::FillMemberList(sal_Bool* pbLevelOrVisibilityChanged)
             nMemberCount = 0;
             if(!pMember)
                 pMember = new SwContentArr;
-            else if(pMember->Count())
-                pMember->DeleteAndDestroy(0, pMember->Count());
+            else if(!pMember->empty())
+                pMember->DeleteAndDestroyAll();
             SwPostItMgr* aMgr = pWrtShell->GetView().GetPostItMgr();
             if (aMgr)
             {
@@ -741,7 +743,7 @@ void    SwContentType::FillMemberList(sal_Bool* pbLevelOrVisibilityChanged)
                                                 sEntry,
                                                 (const SwFmtFld*)aFmtFld,
                                                 nMemberCount);
-                            pMember->Insert(pCnt);
+                            pMember->insert(pCnt);
                             nMemberCount++;
                         }
                     }
@@ -754,8 +756,8 @@ void    SwContentType::FillMemberList(sal_Bool* pbLevelOrVisibilityChanged)
             nMemberCount = 0;
             if(!pMember)
                 pMember = new SwContentArr;
-            else if(pMember->Count())
-                pMember->DeleteAndDestroy(0, pMember->Count());
+            else if(!pMember->empty())
+                pMember->DeleteAndDestroyAll();
 
             IDocumentDrawModelAccess* pIDDMA = pWrtShell->getIDocumentDrawModelAccess();
             SdrModel* pModel = pIDDMA->GetDrawModel();
@@ -780,10 +782,10 @@ void    SwContentType::FillMemberList(sal_Bool* pbLevelOrVisibilityChanged)
                                             nYPos);
                         if(!pIDDMA->IsVisibleLayerId(pTemp->GetLayer()))
                             pCnt->SetInvisible();
-                        pMember->Insert(pCnt);
+                        pMember->insert(pCnt);
                         nMemberCount++;
                         if(nOldMemberCount > (int)i &&
-                            (pOldMember->GetObject((sal_uInt16)i))->IsInvisible() != pCnt->IsInvisible())
+                            (*pOldMember)[i]->IsInvisible() != pCnt->IsInvisible() )
                                 *pbLevelOrVisibilityChanged = sal_True;
                     }
                 }
@@ -793,7 +795,7 @@ void    SwContentType::FillMemberList(sal_Bool* pbLevelOrVisibilityChanged)
     }
     bDataValid = sal_True;
     if(pOldMember)
-        pOldMember->DeleteAndDestroy(0, pOldMember->Count());
+        pOldMember->DeleteAndDestroyAll();
 
 }
 
commit 8b98a0c3a117ff3deb0f7b30d6cfd13906296c4b
Author: Noel Grandin <noel at peralex.com>
Date:   Wed Jul 11 13:35:21 2012 +0200

    Create a template container class for sorted vector
    
    We use this kind of container a lot, so creating a single
    implementation makes sense.
    
    Change-Id: I67ead58becd7d2a287812145c11d93ab1c593c0f

diff --git a/o3tl/CppunitTest_o3tl_tests.mk b/o3tl/CppunitTest_o3tl_tests.mk
index 464a5e7..29e1ff8 100644
--- a/o3tl/CppunitTest_o3tl_tests.mk
+++ b/o3tl/CppunitTest_o3tl_tests.mk
@@ -41,6 +41,7 @@ $(eval $(call gb_CppunitTest_add_exception_objects,o3tl_tests,\
 	o3tl/qa/test-heap_ptr \
 	o3tl/qa/test-range \
 	o3tl/qa/test-vector_pool \
+	o3tl/qa/test-sorted_vector \
 ))
 
 # vim: set noet sw=4:
diff --git a/o3tl/Package_inc.mk b/o3tl/Package_inc.mk
index 088c289..b4a6575 100644
--- a/o3tl/Package_inc.mk
+++ b/o3tl/Package_inc.mk
@@ -33,5 +33,6 @@ $(eval $(call gb_Package_add_file,o3tl_inc,inc/o3tl/heap_ptr.hxx,o3tl/heap_ptr.h
 $(eval $(call gb_Package_add_file,o3tl_inc,inc/o3tl/lazy_update.hxx,o3tl/lazy_update.hxx))
 $(eval $(call gb_Package_add_file,o3tl_inc,inc/o3tl/range.hxx,o3tl/range.hxx))
 $(eval $(call gb_Package_add_file,o3tl_inc,inc/o3tl/vector_pool.hxx,o3tl/vector_pool.hxx))
+$(eval $(call gb_Package_add_file,o3tl_inc,inc/o3tl/sorted_vector.hxx,o3tl/sorted_vector.hxx))
 
 # vim: set noet sw=4:
diff --git a/o3tl/inc/o3tl/sorted_vector.hxx b/o3tl/inc/o3tl/sorted_vector.hxx
new file mode 100644
index 0000000..79ede03
--- /dev/null
+++ b/o3tl/inc/o3tl/sorted_vector.hxx
@@ -0,0 +1,136 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef INCLUDED_O3TL_SORTED_VECTOR_HXX
+#define INCLUDED_O3TL_SORTED_VECTOR_HXX
+
+#include <vector>
+#include <functional>
+#include <algorithm>
+
+namespace o3tl
+{
+
+/** Helper template */
+template <class Value, class Compare>
+class sorted_vector_compare : public Compare
+{
+public:
+    bool operator()(const Value& lhs, const Value& rhs) const
+    {
+        return Compare::operator()(lhs, rhs);
+    }
+};
+
+/** Represents a sorted vector of values.
+
+    @tpl Value class of item to be stored in container
+    @tpl Compare comparison method
+*/
+template <class Value, class Compare = std::less<Value> >
+class sorted_vector : public std::vector<Value>, private sorted_vector_compare<Value, Compare>
+{
+public:
+    typedef typename std::vector<Value>::iterator  iterator;
+    typedef typename std::vector<Value>::const_iterator  const_iterator;
+    typedef typename std::vector<Value>::size_type  size_type;
+    typedef sorted_vector_compare<Value, Compare> MyCompare;
+
+    using std::vector<Value>::begin;
+    using std::vector<Value>::end;
+    using std::vector<Value>::clear;
+    using std::vector<Value>::insert;
+    using std::vector<Value>::erase;
+
+    // MODIFIERS
+
+    std::pair<iterator,bool> insert( const Value& x )
+    {
+        const MyCompare& me = *this;
+        iterator it = std::lower_bound( begin(), end(), x, me );
+        if( it == end() || less_than(x, *it) )
+        {
+            it = insert( it, x );
+            return std::make_pair( it, true );
+        }
+        return std::make_pair( it, false );
+    }
+
+    size_type erase( const Value& x )
+    {
+        iterator it = find(x);
+        if( it != end() )
+        {
+            erase( it );
+            return 1;
+        }
+        return 0;
+    }
+
+    // OPERATIONS
+
+    /* Searches the container for an element with a value of x
+     * and returns an iterator to it if found, otherwise it returns an
+     * iterator to sorted_vector::end (the element past the end of the container).
+     */
+    const_iterator find( const Value& x ) const
+    {
+        const MyCompare& me = *this;
+        const_iterator it = std::lower_bound( begin(), end(), x, me );
+        if( it == end() || less_than(x, *it) )
+        {
+            return end();
+        }
+        return it;
+    }
+    iterator find( const Value& x )
+    {
+        const MyCompare& me = *this;
+        iterator it = std::lower_bound( begin(), end(), x, me );
+        if( it == end() || less_than(x, *it) )
+        {
+            return end();
+        }
+        return it;
+    }
+
+    /* Clear() elements in the vector, and free them one by one. */
+    void DeleteAndDestroyAll()
+    {
+        for( const_iterator it = begin(); it != end(); ++it )
+            delete *it;
+        clear();
+    }
+
+private:
+    /** just makes the code easier to read */
+    bool less_than(const Value& lhs, const Value& rhs) const
+    {
+        const MyCompare& me = *this;
+        return me.operator()(lhs, rhs);
+    }
+};
+
+
+/** Implements an ordering function over a pointer, where the comparison uses the < operator on the pointed-to types.
+    Very useful for the cases where we put pointers to objects inside a sorted_vector.
+*/
+template <class T> struct less_ptr_to : public std::binary_function <T*,T*,bool>
+{
+    bool operator() ( T* const& lhs, T* const& rhs ) const
+    {
+        return (*lhs) < (*rhs);
+    }
+};
+
+
+}   // namespace o3tl
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/o3tl/qa/test-sorted_vector.cxx b/o3tl/qa/test-sorted_vector.cxx
new file mode 100644
index 0000000..11732bd
--- /dev/null
+++ b/o3tl/qa/test-sorted_vector.cxx
@@ -0,0 +1,80 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include "cppunit/TestAssert.h"
+#include "cppunit/TestFixture.h"
+#include "cppunit/extensions/HelperMacros.h"
+
+#include <o3tl/sorted_vector.hxx>
+
+using namespace ::o3tl;
+
+
+// helper class
+class SwContent
+{
+public:
+    int x;
+
+    SwContent(int x_) : x(x_) {}
+
+    bool operator<( const SwContent &rCmp) const
+    {
+        return x < rCmp.x;
+    }
+};
+
+class sorted_vector_test : public CppUnit::TestFixture
+{
+public:
+    void testBasics()
+    {
+        o3tl::sorted_vector<SwContent*, o3tl::less_ptr_to<SwContent> > aVec;
+        SwContent *p1 = new SwContent(1);
+        SwContent *p2 = new SwContent(2);
+        SwContent *p3 = new SwContent(3);
+        SwContent *p4 = new SwContent(4);
+
+        CPPUNIT_ASSERT( aVec.insert(p3).second );
+        CPPUNIT_ASSERT( aVec.insert(p1).second );
+        CPPUNIT_ASSERT( !aVec.insert(p3).second );
+
+        CPPUNIT_ASSERT( aVec.size() == 2 );
+
+        CPPUNIT_ASSERT( aVec[0] == p1 );
+        CPPUNIT_ASSERT( aVec[1] == p3 );
+
+        CPPUNIT_ASSERT( aVec.find(p1) != aVec.end() );
+        CPPUNIT_ASSERT( aVec.find(p1) - aVec.begin() == 0 );
+        CPPUNIT_ASSERT( aVec.find(p3) != aVec.end() );
+        CPPUNIT_ASSERT( aVec.find(p3) - aVec.begin() == 1 );
+        CPPUNIT_ASSERT( aVec.find(p2) == aVec.end() );
+        CPPUNIT_ASSERT( aVec.find(p4) == aVec.end() );
+
+        CPPUNIT_ASSERT( aVec.erase(p1) == 1 );
+        CPPUNIT_ASSERT( aVec.size() == 1 );
+        CPPUNIT_ASSERT( aVec.erase(p2) == 0 );
+
+        aVec.DeleteAndDestroyAll();
+    }
+
+
+    // Change the following lines only, if you add, remove or rename
+    // member functions of the current class,
+    // because these macros are need by auto register mechanism.
+
+    CPPUNIT_TEST_SUITE(sorted_vector_test);
+    CPPUNIT_TEST(testBasics);
+    CPPUNIT_TEST_SUITE_END();
+};
+
+// -----------------------------------------------------------------------------
+CPPUNIT_TEST_SUITE_REGISTRATION(sorted_vector_test);
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 46a02d0ebf0babfa4027483ad7dc3958b725e698
Author: Noel Grandin <noel at peralex.com>
Date:   Tue Jul 10 14:29:46 2012 +0200

    Convert SV_DECL_PTRARR_SORT_DEL_VISIBILITY(SvxAutocorrWordList) to std::set
    
    Change-Id: I31783eecc28cdc6f4d8c40841302d5338a2cd7be

diff --git a/cui/source/tabpages/autocdlg.cxx b/cui/source/tabpages/autocdlg.cxx
index 2172115..94a5c7f 100644
--- a/cui/source/tabpages/autocdlg.cxx
+++ b/cui/source/tabpages/autocdlg.cxx
@@ -1011,16 +1011,15 @@ sal_Bool OfaAutocorrReplacePage::FillItemSet( SfxItemSet& )
         if(eCurLang != eLang) // the current language is treated later
         {
             SvxAutocorrWordList* pWordList = pAutoCorrect->LoadAutocorrWordList(eCurLang);
-            sal_uInt16 nWordListCount = pWordList->Count();
             sal_uInt16 nDoubleStringArrayCount = rDoubleStringArray.size();
             sal_uInt16 nPos = nDoubleStringArrayCount;
             sal_uInt16 nLastPos = nPos;
             // 1st run: delete or change entries:
 
 
-            for( sal_uInt16 nWordListPos = nWordListCount; nWordListPos; nWordListPos-- )
+            for( SvxAutocorrWordList::reverse_iterator it2 = pWordList->rbegin(); it2 != pWordList->rend(); ++it2 )
             {
-                SvxAutocorrWordPtr pWordPtr = pWordList->GetObject(nWordListPos - 1);
+                SvxAutocorrWord* pWordPtr = *it2;
                 String sEntry(pWordPtr->GetShort());
                 // formatted text is only in Writer
                 sal_Bool bFound = !bSWriter && !pWordPtr->IsTextOnly();
@@ -1069,7 +1068,6 @@ sal_Bool OfaAutocorrReplacePage::FillItemSet( SfxItemSet& )
     aDoubleStringTable.clear();
     // and now the current selection
     SvxAutocorrWordList* pWordList = pAutoCorrect->LoadAutocorrWordList(eLang);
-    sal_uInt16 nWordListCount = pWordList->Count();
     sal_uInt16 nListBoxCount = (sal_uInt16)aReplaceTLB.GetEntryCount();
 
     aReplaceTLB.SetUpdateMode(sal_False);
@@ -1077,10 +1075,9 @@ sal_Bool OfaAutocorrReplacePage::FillItemSet( SfxItemSet& )
     sal_uInt16 nLastListBoxPos = nListBoxPos;
     // 1st run: delete or change entries:
 
-    sal_uInt16 i;
-    for( i = nWordListCount; i; i-- )
+    for( SvxAutocorrWordList::reverse_iterator it = pWordList->rbegin(); it != pWordList->rend(); ++it )
     {
-        SvxAutocorrWordPtr pWordPtr = pWordList->GetObject(i- 1);
+        SvxAutocorrWord* pWordPtr = *it;
         String sEntry(pWordPtr->GetShort());
         // formatted text is only in Writer
         sal_Bool bFound = !bSWriter && !pWordPtr->IsTextOnly();
@@ -1113,7 +1110,7 @@ sal_Bool OfaAutocorrReplacePage::FillItemSet( SfxItemSet& )
 
     }
     nListBoxCount = (sal_uInt16)aReplaceTLB.GetEntryCount();
-    for(i = 0; i < nListBoxCount; i++ )
+    for( sal_uInt16 i = 0; i < nListBoxCount; i++ )
     {
         // now there should only be new entries left
         SvLBoxEntry*  pEntry = aReplaceTLB.GetEntry( i );
@@ -1194,9 +1191,9 @@ void OfaAutocorrReplacePage::RefillReplaceBox(sal_Bool bFromReset,
         SvxAutoCorrect* pAutoCorrect = SvxAutoCorrCfg::Get().GetAutoCorrect();
         SvxAutocorrWordList* pWordList = pAutoCorrect->LoadAutocorrWordList(eLang);
         aReplaceTLB.SetUpdateMode(sal_False);
-        for(sal_uInt16 i = 0; i < pWordList->Count(); i++)
+        for( SvxAutocorrWordList::iterator it = pWordList->begin(); it != pWordList->end(); ++it )
         {
-            SvxAutocorrWordPtr pWordPtr = pWordList->GetObject(i);
+            SvxAutocorrWord* pWordPtr = *it;
             sal_Bool bTextOnly = pWordPtr->IsTextOnly();
             // formatted text is only in Writer
             if(bSWriter || bTextOnly)
diff --git a/editeng/inc/editeng/svxacorr.hxx b/editeng/inc/editeng/svxacorr.hxx
index 51de329..71d67c9 100644
--- a/editeng/inc/editeng/svxacorr.hxx
+++ b/editeng/inc/editeng/svxacorr.hxx
@@ -31,7 +31,6 @@
 
 #include <com/sun/star/embed/XStorage.hpp>
 #include <tools/rtti.hxx>
-#include <svl/svarray.hxx>
 #include <i18npool/lang.h>
 #include <tools/time.hxx>
 #include <tools/date.hxx>
@@ -40,6 +39,7 @@
 #include "editeng/editengdllapi.h"
 
 #include <map>
+#include <set>
 #include <boost/ptr_container/ptr_map.hpp>
 
 class CharClass;
@@ -128,8 +128,17 @@ public:
     sal_Bool IsTextOnly() const                         { return bIsTxtOnly; }
 };
 
-typedef SvxAutocorrWord* SvxAutocorrWordPtr;
-SV_DECL_PTRARR_SORT_DEL_VISIBILITY( SvxAutocorrWordList, SvxAutocorrWordPtr, 10, EDITENG_DLLPUBLIC)
+struct CompareSvxAutocorrWordList
+{
+  bool operator()( SvxAutocorrWord* const& lhs, SvxAutocorrWord* const& rhs ) const;
+};
+class EDITENG_DLLPUBLIC SvxAutocorrWordList : public std::set<SvxAutocorrWord*, CompareSvxAutocorrWordList>
+{
+public:
+    // free any objects still in the set
+    ~SvxAutocorrWordList();
+    void DeleteAndDestroyAll();
+};
 
 class EDITENG_DLLPUBLIC SvxAutoCorrectLanguageLists
 {
diff --git a/editeng/source/misc/SvXMLAutoCorrectExport.cxx b/editeng/source/misc/SvXMLAutoCorrectExport.cxx
index 8538f87..6719b39 100644
--- a/editeng/source/misc/SvXMLAutoCorrectExport.cxx
+++ b/editeng/source/misc/SvXMLAutoCorrectExport.cxx
@@ -61,10 +61,9 @@ sal_uInt32 SvXMLAutoCorrectExport::exportDoc(enum XMLTokenEnum /*eClass*/)
                    _GetNamespaceMap().GetNameByKey ( XML_NAMESPACE_BLOCKLIST ) );
     {
         SvXMLElementExport aRoot (*this, XML_NAMESPACE_BLOCKLIST, XML_BLOCK_LIST, sal_True, sal_True);
-        sal_uInt16 nBlocks= pAutocorr_List->Count();
-        for ( sal_uInt16 i = 0; i < nBlocks; i++)
+        for ( SvxAutocorrWordList::iterator it = pAutocorr_List->begin(); it != pAutocorr_List->end(); ++it )
         {
-            SvxAutocorrWord* p = pAutocorr_List->GetObject(i);
+            SvxAutocorrWord* p = *it;
 
             AddAttribute( XML_NAMESPACE_BLOCKLIST,
                           XML_ABBREVIATED_NAME,
diff --git a/editeng/source/misc/SvXMLAutoCorrectImport.cxx b/editeng/source/misc/SvXMLAutoCorrectImport.cxx
index 16b604d..0f520b4 100644
--- a/editeng/source/misc/SvXMLAutoCorrectImport.cxx
+++ b/editeng/source/misc/SvXMLAutoCorrectImport.cxx
@@ -145,9 +145,9 @@ SvXMLWordContext::SvXMLWordContext(
             bOnlyTxt = sal_True;
         }
     }
-    SvxAutocorrWordPtr pNew = new SvxAutocorrWord( sWrong, sRight, bOnlyTxt );
+    SvxAutocorrWord* pNew = new SvxAutocorrWord( sWrong, sRight, bOnlyTxt );
 
-    if( !rLocalRef.pAutocorr_List->Insert( pNew ) )
+    if( !rLocalRef.pAutocorr_List->insert( pNew ).second )
         delete pNew;
 }
 
diff --git a/editeng/source/misc/svxacorr.cxx b/editeng/source/misc/svxacorr.cxx
index 66b817e..31a1cda 100644
--- a/editeng/source/misc/svxacorr.cxx
+++ b/editeng/source/misc/svxacorr.cxx
@@ -103,7 +103,6 @@ static const sal_Char sImplWordChars[] = "-'";
 
 void EncryptBlockName_Imp( String& rName );
 
-_SV_IMPL_SORTAR_ALG( SvxAutocorrWordList, SvxAutocorrWordPtr )
 TYPEINIT0(SvxAutoCorrect)
 
 typedef SvxAutoCorrectLanguageLists* SvxAutoCorrectLanguageListsPtr;
@@ -219,62 +218,11 @@ static CollatorWrapper& GetCollatorWrapper()
 }
 
 
-void SvxAutocorrWordList::DeleteAndDestroy( sal_uInt16 nP, sal_uInt16 nL )
-{
-    if( nL )
-    {
-        OSL_ENSURE( nP < nA && nP + nL <= nA, "ERR_VAR_DEL" );
-        for( sal_uInt16 n=nP; n < nP + nL; n++ )
-            delete *((SvxAutocorrWordPtr*)pData+n);
-        SvPtrarr::Remove( nP, nL );
-    }
-}
-
-
 // Keep the list sorted ...
-sal_Bool SvxAutocorrWordList::Seek_Entry( const SvxAutocorrWordPtr aE, sal_uInt16* pP ) const
+bool CompareSvxAutocorrWordList::operator()( SvxAutocorrWord* const& lhs, SvxAutocorrWord* const& rhs ) const
 {
-    register sal_uInt16 nO  = SvxAutocorrWordList_SAR::Count(),
-            nM,
-            nU = 0;
-
-    if( nO > 0 )
-    {
-        CollatorWrapper& rCmp = ::GetCollatorWrapper();
-        nO--;
-
-        // quick check of the end of the list
-        if (rCmp.compareString( aE->GetShort(),
-                                (*((SvxAutocorrWordPtr*)pData + nO))->GetShort() ) > 0)
-        {
-            if( pP ) *pP = nO + 1;
-            return sal_False;
-        }
-
-        // Incredibly crude sort algorithm, should use some partitioning search.
-        while( nU <= nO )
-        {
-            nM = nU + ( nO - nU ) / 2;
-            long nCmp = rCmp.compareString( aE->GetShort(),
-                        (*((SvxAutocorrWordPtr*)pData + nM))->GetShort() );
-            if( 0 == nCmp )
-            {
-                if( pP ) *pP = nM;
-                return sal_True;
-            }
-            else if( 0 < nCmp )
-                nU = nM + 1;
-            else if( nM == 0 )
-            {
-                if( pP ) *pP = nU;
-                return sal_False;
-            }
-            else
-                nO = nM - 1;
-        }
-    }
-    if( pP ) *pP = nU;
-    return sal_False;
+    CollatorWrapper& rCmp = ::GetCollatorWrapper();
+    return rCmp.compareString( lhs->GetShort(), rhs->GetShort() ) < 0;
 }
 
 static void lcl_ClearTable(boost::ptr_map<LanguageType, SvxAutoCorrectLanguageLists>& rLangTable)
@@ -1710,9 +1658,9 @@ static const SvxAutocorrWord* lcl_SearchWordsInList(
 {
     const SvxAutocorrWordList* pAutoCorrWordList = pList->GetAutocorrWordList();
     TransliterationWrapper& rCmp = GetIgnoreTranslWrapper();
-    for( xub_StrLen nPos = 0; nPos < pAutoCorrWordList->Count(); ++nPos )
+    for( SvxAutocorrWordList::iterator it = pAutoCorrWordList->begin(); it != pAutoCorrWordList->end(); ++it )
     {
-        const SvxAutocorrWord* pFnd = (*pAutoCorrWordList)[ nPos ];
+        const SvxAutocorrWord* pFnd = *it;
         const String& rChk = pFnd->GetShort();
         if( nEndPos >= rChk.Len() )
         {
@@ -2157,9 +2105,9 @@ void SvxAutoCorrectLanguageLists::SaveExceptList_Imp(
 SvxAutocorrWordList* SvxAutoCorrectLanguageLists::LoadAutocorrWordList()
 {
     if( pAutocorr_List )
-        pAutocorr_List->DeleteAndDestroy( 0, pAutocorr_List->Count() );
+        pAutocorr_List->DeleteAndDestroyAll();
     else
-        pAutocorr_List = new SvxAutocorrWordList( 16 );
+        pAutocorr_List = new SvxAutocorrWordList();
 
     try
     {
@@ -2208,7 +2156,7 @@ void SvxAutoCorrectLanguageLists::SetAutocorrWordList( SvxAutocorrWordList* pLis
     if( !pAutocorr_List )
     {
         OSL_ENSURE( !this, "No valid list" );
-        pAutocorr_List = new SvxAutocorrWordList( 16 );
+        pAutocorr_List = new SvxAutocorrWordList();
     }
     nFlags |= ChgWordLstLoad;
 }
@@ -2473,7 +2421,7 @@ void SvxAutoCorrectLanguageLists::MakeUserStorage_Impl()
 sal_Bool SvxAutoCorrectLanguageLists::MakeBlocklist_Imp( SvStorage& rStg )
 {
     String sStrmName( pXMLImplAutocorr_ListStr, RTL_TEXTENCODING_MS_1252 );
-    sal_Bool bRet = sal_True, bRemove = !pAutocorr_List || !pAutocorr_List->Count();
+    sal_Bool bRet = sal_True, bRemove = !pAutocorr_List || pAutocorr_List->empty();
     if( !bRemove )
     {
         SvStorageStreamRef refList = rStg.OpenSotStream( sStrmName,
@@ -2550,11 +2498,11 @@ sal_Bool SvxAutoCorrectLanguageLists::PutText( const String& rShort,
     // Update the word list
     if( bRet )
     {
-        sal_uInt16 nPos;
         SvxAutocorrWord* pNew = new SvxAutocorrWord( rShort, rLong, sal_True );
-        if( pAutocorr_List->Seek_Entry( pNew, &nPos ) )
+        SvxAutocorrWordList::iterator it = pAutocorr_List->find( pNew );
+        if( it != pAutocorr_List->end() )
         {
-            if( !(*pAutocorr_List)[ nPos ]->IsTextOnly() )
+            if( !(*it)->IsTextOnly() )
             {
                 // Still have to remove the Storage
                 String sStgNm( rShort );
@@ -2566,10 +2514,11 @@ sal_Bool SvxAutoCorrectLanguageLists::PutText( const String& rShort,
                 if( xStg->IsContained( sStgNm ) )
                     xStg->Remove( sStgNm );
             }
-            pAutocorr_List->DeleteAndDestroy( nPos );
+            delete *it;
+            pAutocorr_List->erase( it );
         }
 
-        if( pAutocorr_List->Insert( pNew ) )
+        if( pAutocorr_List->insert( pNew ).second )
         {
             bRet = MakeBlocklist_Imp( *xStg );
             xStg = 0;
@@ -2603,7 +2552,7 @@ sal_Bool SvxAutoCorrectLanguageLists::PutText( const String& rShort,
         if( bRet )
         {
             SvxAutocorrWord* pNew = new SvxAutocorrWord( rShort, sLong, sal_False );
-            if( pAutocorr_List->Insert( pNew ) )
+            if( pAutocorr_List->insert( pNew ).second )
             {
                 SotStorageRef xStor = new SotStorage( sUserAutoCorrFile, STREAM_READWRITE, sal_True );
                 MakeBlocklist_Imp( *xStor );
@@ -2631,11 +2580,11 @@ sal_Bool SvxAutoCorrectLanguageLists::DeleteText( const String& rShort )
     sal_Bool bRet = xStg.Is() && SVSTREAM_OK == xStg->GetError();
     if( bRet )
     {
-        sal_uInt16 nPos;
         SvxAutocorrWord aTmp( rShort, rShort );
-        if( pAutocorr_List->Seek_Entry( &aTmp, &nPos ) )
+        SvxAutocorrWordList::iterator it = pAutocorr_List->find( &aTmp );
+        if( it != pAutocorr_List->end() )
         {
-            SvxAutocorrWord* pFnd = (*pAutocorr_List)[ nPos ];
+            SvxAutocorrWord* pFnd = *it;
             if( !pFnd->IsTextOnly() )
             {
                 String aName( rShort );
@@ -2651,7 +2600,8 @@ sal_Bool SvxAutoCorrectLanguageLists::DeleteText( const String& rShort )
 
             }
             // Update the word list
-            pAutocorr_List->DeleteAndDestroy( nPos );
+            delete pFnd;
+            pAutocorr_List->erase( it );
             MakeBlocklist_Imp( *xStg );
             xStg = 0;
         }
@@ -2661,4 +2611,17 @@ sal_Bool SvxAutoCorrectLanguageLists::DeleteText( const String& rShort )
     return bRet;
 }
 
+SvxAutocorrWordList::~SvxAutocorrWordList()
+{
+    DeleteAndDestroyAll();
+}
+
+void SvxAutocorrWordList::DeleteAndDestroyAll()
+{
+    for( const_iterator it = begin(); it != end(); ++it )
+        delete *it;
+    clear();
+}
+
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 1384ccd692a80f78458a7b7cd818bbd010007bab
Author: Noel Grandin <noel at peralex.com>
Date:   Tue Jul 10 10:00:08 2012 +0200

    Convert SV_DECL_PTRARR_SORT_VISIBILITY(SvxMSDffShapeTxBxSort) to std::set
    
    Change-Id: I94b2cccff386ccf331ca670df17d7a738e026879

diff --git a/filter/inc/filter/msfilter/msdffimp.hxx b/filter/inc/filter/msfilter/msdffimp.hxx
index 1626671..24137ad 100644
--- a/filter/inc/filter/msfilter/msdffimp.hxx
+++ b/filter/inc/filter/msfilter/msdffimp.hxx
@@ -190,9 +190,8 @@ public:
     ~SvxMSDffShapeOrders();
 };
 
-// the following two will be sorted explicitly:
+// the following will be sorted explicitly:
 SV_DECL_PTRARR_SORT_DEL_VISIBILITY( SvxMSDffShapeInfos, SvxMSDffShapeInfo_Ptr, 16, MSFILTER_DLLPUBLIC )
-SV_DECL_PTRARR_SORT_VISIBILITY( SvxMSDffShapeTxBxSort, SvxMSDffShapeOrder*, 16, MSFILTER_DLLPUBLIC )
 
 #define SVXMSDFF_SETTINGS_CROP_BITMAPS      1
 #define SVXMSDFF_SETTINGS_IMPORT_PPT        2
@@ -864,12 +863,20 @@ struct SvxMSDffShapeOrder
     SvxMSDffShapeOrder( sal_uLong nId ):
         nShapeId( nId ), nTxBxComp( 0 ), pFly( 0 ), nHdFtSection( 0 ), pObj( 0 ){}
 
-    sal_Bool operator==( const SvxMSDffShapeOrder& rEntry ) const
+    bool operator==( const SvxMSDffShapeOrder& rEntry ) const
     { return (nTxBxComp == rEntry.nTxBxComp); }
-    sal_Bool operator<( const SvxMSDffShapeOrder& rEntry ) const
+    bool operator<( const SvxMSDffShapeOrder& rEntry ) const
     { return (nTxBxComp < rEntry.nTxBxComp); }
 };
 
+// the following will be sorted explicitly:
+struct CompareSvxMSDffShapeTxBxSort
+{
+  bool operator()( SvxMSDffShapeOrder* const& lhs, SvxMSDffShapeOrder* const& rhs ) const { return (*lhs)<(*rhs); }
+};
+class MSFILTER_DLLPUBLIC SvxMSDffShapeTxBxSort : public std::set<SvxMSDffShapeOrder*,CompareSvxMSDffShapeTxBxSort> {};
+
+
 #endif
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/filter/source/msfilter/msdffimp.cxx b/filter/source/msfilter/msdffimp.cxx
index 0effc0c..d29e0db 100644
--- a/filter/source/msfilter/msdffimp.cxx
+++ b/filter/source/msfilter/msdffimp.cxx
@@ -5720,8 +5720,6 @@ void SvxMSDffManager::RemoveFromShapeOrder( SdrObject* pObject ) const
 
 SV_IMPL_OP_PTRARR_SORT( SvxMSDffShapeInfos,     SvxMSDffShapeInfo_Ptr   );
 
-SV_IMPL_OP_PTRARR_SORT( SvxMSDffShapeTxBxSort,  SvxMSDffShapeOrder*  );
-
 
 //---------------------------------------------------------------------------
 //  exported class: Public Methods
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index ee8219c..5c8abf3 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -4595,40 +4595,40 @@ sal_uLong SwWW8ImplReader::CoreLoad(WW8Glossary *pGloss, const SwPosition &rPos)
 
         for (sal_uInt16 nShapeNum=0; nShapeNum < nShapeCount; nShapeNum++)
         {
-            const SvxMSDffShapeOrder *pOrder =
+            SvxMSDffShapeOrder *pOrder =
                 (*pMSDffManager->GetShapeOrders())[nShapeNum];
             // Pointer in neues Sort-Array einfuegen
             if (pOrder->nTxBxComp && pOrder->pFly)
-                aTxBxSort.Insert(pOrder);
+                aTxBxSort.insert(pOrder);
         }
         // zu verkettende Rahmen jetzt verketten
-        sal_uInt16 nTxBxCount = aTxBxSort.Count();
-        if( nTxBxCount )
+        if( !aTxBxSort.empty() )
         {
             SwFmtChain aChain;
-            for (sal_uInt16 nTxBxNum=0; nTxBxNum < nTxBxCount; nTxBxNum++)
+            for( SvxMSDffShapeTxBxSort::iterator it = aTxBxSort.begin(); it != aTxBxSort.end(); ++it )
             {
-                SvxMSDffShapeOrder *pOrder =
-                    aTxBxSort.GetObject(nTxBxNum);
+                SvxMSDffShapeOrder *pOrder = *it;
 
                 // Fly-Frame-Formate initialisieren
                 SwFlyFrmFmt* pFlyFmt     = pOrder->pFly;
                 SwFlyFrmFmt* pNextFlyFmt = 0;
                 SwFlyFrmFmt* pPrevFlyFmt = 0;
                 // ggfs. Nachfolger ermitteln
-                if( 1+nTxBxNum < nTxBxCount )
+                SvxMSDffShapeTxBxSort::iterator tmpIter1 = it;
+                tmpIter1++;
+                if( tmpIter1 != aTxBxSort.end() )
                 {
-                    SvxMSDffShapeOrder *pNextOrder =
-                        aTxBxSort.GetObject(nTxBxNum+1);
+                    SvxMSDffShapeOrder *pNextOrder = *tmpIter1;
                     if ((0xFFFF0000 & pOrder->nTxBxComp)
                            == (0xFFFF0000 & pNextOrder->nTxBxComp))
                         pNextFlyFmt = pNextOrder->pFly;
                 }
                 // ggfs. Vorgaenger ermitteln
-                if( nTxBxNum )
+                if( it != aTxBxSort.begin() )
                 {
-                    SvxMSDffShapeOrder *pPrevOrder =
-                        aTxBxSort.GetObject(nTxBxNum-1);
+                    SvxMSDffShapeTxBxSort::iterator tmpIter2 = it;
+                    tmpIter2--;
+                    SvxMSDffShapeOrder *pPrevOrder = *tmpIter2;
                     if ((0xFFFF0000 & pOrder->nTxBxComp)
                            == (0xFFFF0000 & pPrevOrder->nTxBxComp))
                         pPrevFlyFmt = pPrevOrder->pFly;
commit 8edb5996089a24c6eb0509a7ee4d108a23203752
Author: Michael Stahl <mstahl at redhat.com>
Date:   Thu Jul 12 13:41:19 2012 +0200

    fix previous STL conversion commit:
    
    the MSDffImportRecords now leaks memory, so use a boost::ptr_set
    instead, that also doesn't seem to need a special comparator class.
    
    Change-Id: I52935205a57cfb03f439d83401b80b1bf69ede47

diff --git a/filter/inc/filter/msfilter/msdffimp.hxx b/filter/inc/filter/msfilter/msdffimp.hxx
index 7c7bc7d..1626671 100644
--- a/filter/inc/filter/msfilter/msdffimp.hxx
+++ b/filter/inc/filter/msfilter/msdffimp.hxx
@@ -45,6 +45,7 @@
 #include <vector>
 #include <set>
 #include <boost/ptr_container/ptr_vector.hpp>
+#include <boost/ptr_container/ptr_set.hpp>
 
 class Graphic;
 class SvStream;
@@ -329,11 +330,9 @@ private:
 };
 
 /** list of all SvxMSDffImportRec instances of/for a group */
-struct CompareMSDffImportRecords
-{
-  bool operator()( SvxMSDffImportRec* const& lhs, SvxMSDffImportRec* const& rhs ) const { return (*lhs)<(*rhs); }
-};
-class MSFILTER_DLLPUBLIC MSDffImportRecords : public std::set<SvxMSDffImportRec*,CompareMSDffImportRecords> {};
+class MSFILTER_DLLPUBLIC MSDffImportRecords
+    : public ::boost::ptr_set<SvxMSDffImportRec>
+{};
 
 /** block of parameters for import/export for a single call of
     ImportObjAtCurrentStreamPos() */
diff --git a/sw/source/filter/ww8/ww8graf.cxx b/sw/source/filter/ww8/ww8graf.cxx
index 48cf3f2..60c3357 100644
--- a/sw/source/filter/ww8/ww8graf.cxx
+++ b/sw/source/filter/ww8/ww8graf.cxx
@@ -2016,7 +2016,8 @@ void SwWW8ImplReader::MapWrapIntoFlyFmt(SvxMSDffImportRec* pRecord,
     }
 }
 
-void SwWW8ImplReader::SetAttributesAtGrfNode( SvxMSDffImportRec* pRecord,
+void
+SwWW8ImplReader::SetAttributesAtGrfNode(SvxMSDffImportRec const*const pRecord,
     SwFrmFmt *pFlyFmt, WW8_FSPA *pF )
 {
     const SwNodeIndex* pIdx = pFlyFmt->GetCntnt(false).GetCntntIdx();
@@ -2560,13 +2561,14 @@ SwFrmFmt* SwWW8ImplReader::Read_GrafLayer( long nGrafAnchorCp )
         Get the record for top level object, so we can get the word anchoring
         and wrapping information for it.
     */
-    for (MSDffImportRecords::const_iterator it = aData.begin(); it != aData.end(); ++it )
+    for (MSDffImportRecords::iterator it = aData.begin();
+            it != aData.end(); ++it)
     {
-        pRecord = *it;
-        if (pRecord && pRecord->pObj == pObject)
+        if (it->pObj == pObject)
+        {
+            pRecord = &*it;
             break;
-        else
-            pRecord = 0;
+        }
     }
 
     OSL_ENSURE(pRecord, "how did that happen?");
@@ -2661,10 +2663,11 @@ SwFrmFmt* SwWW8ImplReader::Read_GrafLayer( long nGrafAnchorCp )
             */
             if (!aData.empty())
             {
-                for (MSDffImportRecords::const_iterator it = aData.begin(); it != aData.end(); ++it)
+                for (MSDffImportRecords::iterator it = aData.begin();
+                        it != aData.end(); ++it)
                 {
-                    pRecord = *it;
-                    if (pRecord && pRecord->pObj && pRecord->aTextId.nTxBxS)
+                    pRecord = &*it;
+                    if (pRecord->pObj && pRecord->aTextId.nTxBxS)
                     { // #i52825# pRetFrmFmt can be NULL
                         pRetFrmFmt = MungeTextIntoDrawBox(pRecord->pObj,
                             pRecord, nGrafAnchorCp, pRetFrmFmt);
diff --git a/sw/source/filter/ww8/ww8graf2.cxx b/sw/source/filter/ww8/ww8graf2.cxx
index d4565a4..0bafbd2 100644
--- a/sw/source/filter/ww8/ww8graf2.cxx
+++ b/sw/source/filter/ww8/ww8graf2.cxx
@@ -562,7 +562,8 @@ SwFrmFmt* SwWW8ImplReader::ImportGraf(SdrTextObj* pTextObj,
                 SfxItemSet aAttrSet( rDoc.GetAttrPool(), RES_FRMATR_BEGIN,
                     RES_FRMATR_END-1 );
 
-                SvxMSDffImportRec *pRecord = (1 == aData.size()) ? *aData.begin() : 0;
+                SvxMSDffImportRec const*const pRecord = (1 == aData.size())
+                    ? &*aData.begin() : 0;
 
                 if( pRecord )
                 {
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index 7e9de09..ee8219c 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -3680,10 +3680,8 @@ void wwSectionManager::SetSegmentToPageDesc(const wwSection &rSection,
         SdrObject* pObject = 0;
         if (mrReader.pMSDffManager->GetShape(0x401, pObject, aData))
         {
-            SvxMSDffImportRec * pRec = *aData.begin();
-
             // Only handle shape if it is a background shape
-            if ((pRec->nFlags & 0x400) != 0)
+            if ((aData.begin()->nFlags & 0x400) != 0)
             {
                 SfxItemSet aSet(rFmt.GetAttrSet());
                 mrReader.MatchSdrItemsIntoFlySet(pObject, aSet, mso_lineSimple,
diff --git a/sw/source/filter/ww8/ww8par.hxx b/sw/source/filter/ww8/ww8par.hxx
index e2cc680..dde6d15 100644
--- a/sw/source/filter/ww8/ww8par.hxx
+++ b/sw/source/filter/ww8/ww8par.hxx
@@ -1322,8 +1322,8 @@ private:
         SvxULSpaceItem &rUL);
     void MapWrapIntoFlyFmt(SvxMSDffImportRec* pRecord, SwFrmFmt* pFlyFmt);
 
-    void SetAttributesAtGrfNode( SvxMSDffImportRec* pRecord, SwFrmFmt *pFlyFmt,
-        WW8_FSPA *pF );
+    void SetAttributesAtGrfNode(SvxMSDffImportRec const* pRecord,
+            SwFrmFmt *pFlyFmt, WW8_FSPA *pF);
 
     bool IsDropCap();
     bool IsListOrDropcap() { return (!pAktItemSet  || bDropCap); };
commit c98829262fdfcd86e8e8c233319ece566af0b9c0
Author: Noel Grandin <noel at peralex.com>
Date:   Tue Jul 10 09:17:59 2012 +0200

    Convert SV_DECL_PTRARR_SORT_DEL_VISIBILITY(MSDffImportRecords) to std::set
    
    Change-Id: I92d280f4e95a3d29851e73a955935b44966f5d03

diff --git a/filter/inc/filter/msfilter/msdffimp.hxx b/filter/inc/filter/msfilter/msdffimp.hxx
index ebfc993..7c7bc7d 100644
--- a/filter/inc/filter/msfilter/msdffimp.hxx
+++ b/filter/inc/filter/msfilter/msdffimp.hxx
@@ -43,6 +43,7 @@
 #include <filter/msfilter/msfilterdllapi.h>
 #include <sot/storage.hxx>
 #include <vector>
+#include <set>
 #include <boost/ptr_container/ptr_vector.hpp>
 
 class Graphic;
@@ -318,19 +319,21 @@ struct MSFILTER_DLLPUBLIC SvxMSDffImportRec
     SvxMSDffImportRec(const SvxMSDffImportRec& rCopy);
     ~SvxMSDffImportRec();
 
-    sal_Bool operator==( const SvxMSDffImportRec& rEntry ) const
+    bool operator==( const SvxMSDffImportRec& rEntry ) const
     {   return nShapeId == rEntry.nShapeId; }
-    sal_Bool operator<( const SvxMSDffImportRec& rEntry ) const
+    bool operator<( const SvxMSDffImportRec& rEntry ) const
     {   return nShapeId < rEntry.nShapeId;  }
 
 private:
     SvxMSDffImportRec &operator=(const SvxMSDffImportRec&);
 };
 
-typedef SvxMSDffImportRec* MSDffImportRec_Ptr;
-
 /** list of all SvxMSDffImportRec instances of/for a group */
-SV_DECL_PTRARR_SORT_DEL_VISIBILITY( MSDffImportRecords, MSDffImportRec_Ptr, 16, MSFILTER_DLLPUBLIC )
+struct CompareMSDffImportRecords
+{
+  bool operator()( SvxMSDffImportRec* const& lhs, SvxMSDffImportRec* const& rhs ) const { return (*lhs)<(*rhs); }
+};
+class MSFILTER_DLLPUBLIC MSDffImportRecords : public std::set<SvxMSDffImportRec*,CompareMSDffImportRecords> {};
 
 /** block of parameters for import/export for a single call of
     ImportObjAtCurrentStreamPos() */
@@ -348,10 +351,10 @@ struct SvxMSDffImportData
         { aNewRect = Rectangle(left, top, right, bottom); }
     sal_Bool HasParRect() const { return aParentRect.IsEmpty(); }
     sal_Bool HasNewRect() const { return aNewRect.IsEmpty()   ; }
-    sal_Bool HasRecords() const { return 0 != aRecords.Count(); }
-    sal_uInt16 GetRecCount() const { return aRecords.Count();  }
-    SvxMSDffImportRec*  GetRecord(sal_uInt16 iRecord) const
-        { return aRecords.GetObject( iRecord ); }
+    bool empty() const { return aRecords.empty(); }
+    size_t size() const { return aRecords.size(); }
+    MSDffImportRecords::const_iterator begin() const { return aRecords.begin();  }
+    MSDffImportRecords::const_iterator end() const { return aRecords.end();  }
 };
 
 struct DffObjData
diff --git a/filter/source/msfilter/msdffimp.cxx b/filter/source/msfilter/msdffimp.cxx
index 152d65e..0effc0c 100644
--- a/filter/source/msfilter/msdffimp.cxx
+++ b/filter/source/msfilter/msdffimp.cxx
@@ -5624,7 +5624,7 @@ SdrObject* SvxMSDffManager::ProcessObj(SvStream& rSt,
             if( pOrgObj )
             {
                 pImpRec->pObj = pOrgObj;
-                rImportData.aRecords.Insert( pImpRec );
+                rImportData.aRecords.insert( pImpRec );
             }
 
             if( pTextObj && (pOrgObj != pTextObj) )
@@ -5632,7 +5632,7 @@ SdrObject* SvxMSDffManager::ProcessObj(SvStream& rSt,
                 // Modify ShapeId (must be unique)
                 pImpRec->nShapeId |= 0x8000000;
                 pTextImpRec->pObj = pTextObj;
-                rImportData.aRecords.Insert( pTextImpRec );
+                rImportData.aRecords.insert( pTextImpRec );
             }
 
             // Eintrag in Z-Order-Liste um Zeiger auf dieses Objekt ergaenzen
@@ -5723,9 +5723,6 @@ SV_IMPL_OP_PTRARR_SORT( SvxMSDffShapeInfos,     SvxMSDffShapeInfo_Ptr   );
 SV_IMPL_OP_PTRARR_SORT( SvxMSDffShapeTxBxSort,  SvxMSDffShapeOrder*  );
 
 
-// Liste aller SvxMSDffImportRec fuer eine Gruppe
-SV_IMPL_OP_PTRARR_SORT(MSDffImportRecords, MSDffImportRec_Ptr)
-
 //---------------------------------------------------------------------------
 //  exported class: Public Methods
 //---------------------------------------------------------------------------
diff --git a/sw/source/filter/ww8/ww8graf.cxx b/sw/source/filter/ww8/ww8graf.cxx
index a85e498..48cf3f2 100644
--- a/sw/source/filter/ww8/ww8graf.cxx
+++ b/sw/source/filter/ww8/ww8graf.cxx
@@ -2549,10 +2549,10 @@ SwFrmFmt* SwWW8ImplReader::Read_GrafLayer( long nGrafAnchorCp )
     // eingelesenes Objekt (kann eine ganze Gruppe sein) jetzt korrekt
     // positionieren usw.
 
-    OSL_ENSURE(!((aData.GetRecCount() != 1) && bReplaceable),
+    OSL_ENSURE(!((aData.size() != 1) && bReplaceable),
         "Replaceable drawing with > 1 entries ?");
 
-    if (aData.GetRecCount() != 1)
+    if (aData.size() != 1)
         bReplaceable = false;
 
     SvxMSDffImportRec* pRecord = 0;
@@ -2560,10 +2560,9 @@ SwFrmFmt* SwWW8ImplReader::Read_GrafLayer( long nGrafAnchorCp )
         Get the record for top level object, so we can get the word anchoring
         and wrapping information for it.
     */
-    sal_uInt16 nRecCount = aData.GetRecCount();
-    for (sal_uInt16 nTxbx=0; nTxbx < nRecCount; ++nTxbx )
+    for (MSDffImportRecords::const_iterator it = aData.begin(); it != aData.end(); ++it )
     {
-        pRecord = aData.GetRecord( nTxbx );
+        pRecord = *it;
         if (pRecord && pRecord->pObj == pObject)
             break;
         else
@@ -2660,12 +2659,11 @@ SwFrmFmt* SwWW8ImplReader::Read_GrafLayer( long nGrafAnchorCp )
             /*
                 Insert text if necessary into textboxes contained in groups.
             */
-            if (aData.HasRecords())
+            if (!aData.empty())
             {
-                sal_uInt16 nCount = aData.GetRecCount();
-                for (sal_uInt16 nTxbx=0; nTxbx < nCount; ++nTxbx)
+                for (MSDffImportRecords::const_iterator it = aData.begin(); it != aData.end(); ++it)
                 {
-                    pRecord = aData.GetRecord(nTxbx);
+                    pRecord = *it;
                     if (pRecord && pRecord->pObj && pRecord->aTextId.nTxBxS)
                     { // #i52825# pRetFrmFmt can be NULL
                         pRetFrmFmt = MungeTextIntoDrawBox(pRecord->pObj,
diff --git a/sw/source/filter/ww8/ww8graf2.cxx b/sw/source/filter/ww8/ww8graf2.cxx
index a11c00e..d4565a4 100644
--- a/sw/source/filter/ww8/ww8graf2.cxx
+++ b/sw/source/filter/ww8/ww8graf2.cxx
@@ -562,9 +562,7 @@ SwFrmFmt* SwWW8ImplReader::ImportGraf(SdrTextObj* pTextObj,
                 SfxItemSet aAttrSet( rDoc.GetAttrPool(), RES_FRMATR_BEGIN,
                     RES_FRMATR_END-1 );
 
-                SvxMSDffImportRec *pRecord =
-                    (aData.HasRecords() && (1 == aData.GetRecCount() ) ) ?
-                    aData.GetRecord( 0 ) : 0;
+                SvxMSDffImportRec *pRecord = (1 == aData.size()) ? *aData.begin() : 0;
 
                 if( pRecord )
                 {
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index f813a10..7e9de09 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -859,7 +859,7 @@ SdrObject* SwMSDffManager::ProcessObj(SvStream& rSt,
         {
             // Import-Record-Liste ergaenzen
             pImpRec->pObj = pObj;
-            rImportData.aRecords.Insert( pImpRec );
+            rImportData.aRecords.insert( pImpRec );
 
             // Eintrag in Z-Order-Liste um Zeiger auf dieses Objekt ergaenzen
             /*Only store objects which are not deep inside the tree*/
@@ -3680,7 +3680,7 @@ void wwSectionManager::SetSegmentToPageDesc(const wwSection &rSection,
         SdrObject* pObject = 0;
         if (mrReader.pMSDffManager->GetShape(0x401, pObject, aData))
         {
-            SvxMSDffImportRec * pRec = aData.GetRecord(0);
+            SvxMSDffImportRec * pRec = *aData.begin();
 
             // Only handle shape if it is a background shape
             if ((pRec->nFlags & 0x400) != 0)
commit 8cfdbe66c1973cec801a466209291aecc80650c6
Author: Noel Grandin <noel at peralex.com>
Date:   Mon Jul 9 16:53:50 2012 +0200

    Convert SV_DECL_PTRARR_SORT(ScValidationEntries_Impl) to std::set
    
    Change-Id: I2ccd12b8e9516f59a39db7c9a123b2b76a0b6c28

diff --git a/sc/inc/validat.hxx b/sc/inc/validat.hxx
index b8a661f..8272988 100644
--- a/sc/inc/validat.hxx
+++ b/sc/inc/validat.hxx
@@ -151,10 +151,10 @@ public:
 
     sal_Bool            EqualEntries( const ScValidationData& r ) const;    // for undo
 
-    //  sort (using PTRARR) by index
+    //  sort (using std::set) by index
     //  operator== only for sorting
-    sal_Bool operator ==( const ScValidationData& r ) const { return nKey == r.nKey; }
-    sal_Bool operator < ( const ScValidationData& r ) const { return nKey <  r.nKey; }
+    bool operator ==( const ScValidationData& r ) const { return nKey == r.nKey; }
+    bool operator < ( const ScValidationData& r ) const { return nKey <  r.nKey; }
 
 private:
     /** Tries to fill the passed collection with list validation entries.
@@ -180,20 +180,21 @@ private:
 //  list of contitions:
 //
 
-typedef ScValidationData* ScValidationDataPtr;
-
-SV_DECL_PTRARR_SORT(ScValidationEntries_Impl, ScValidationDataPtr, SC_COND_GROW)
+struct CompareScValidationDataPtr
+{
+  bool operator()( ScValidationData* const& lhs, ScValidationData* const& rhs ) const { return (*lhs)<(*rhs); }
+};
 
-class ScValidationDataList : public ScValidationEntries_Impl
+class ScValidationDataList : public std::set<ScValidationData*, CompareScValidationDataPtr>
 {
 public:
-        ScValidationDataList() {}
-        ScValidationDataList(const ScValidationDataList& rList);
-        ScValidationDataList(ScDocument* pNewDoc, const ScValidationDataList& rList);
-        ~ScValidationDataList() {}
+    ScValidationDataList() {}
+    ScValidationDataList(const ScValidationDataList& rList);
+    ScValidationDataList(ScDocument* pNewDoc, const ScValidationDataList& rList);
+    ~ScValidationDataList() {}
 
     void    InsertNew( ScValidationData* pNew )
-                { if (!Insert(pNew)) delete pNew; }
+                { if (!insert(pNew).second) delete pNew; }
 
     ScValidationData* GetData( sal_uInt32 nKey );
 
diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx
index 6b3aa3c..d537c35 100644
--- a/sc/source/core/data/documen2.cxx
+++ b/sc/source/core/data/documen2.cxx
@@ -409,7 +409,9 @@ ScDocument::~ScDocument()
 
     if (pValidationList)
     {
-        pValidationList->DeleteAndDestroy( 0, pValidationList->Count() );
+        for( ScValidationDataList::iterator it = pValidationList->begin(); it != pValidationList->end(); ++it )
+            delete *it;
+        pValidationList->clear();
         DELETEZ(pValidationList);
     }
     delete pRangeName;
@@ -452,7 +454,9 @@ void ScDocument::InitClipPtrs( ScDocument* pSourceDoc )
 
     if (pValidationList)
     {
-        pValidationList->DeleteAndDestroy( 0, pValidationList->Count() );
+        for(ScValidationDataList::iterator it = pValidationList->begin(); it != pValidationList->end(); ++it )
+            delete *it;
+        pValidationList->clear();
         DELETEZ(pValidationList);
     }
 
diff --git a/sc/source/core/data/documen4.cxx b/sc/source/core/data/documen4.cxx
index 8eca485..41e058a 100644
--- a/sc/source/core/data/documen4.cxx
+++ b/sc/source/core/data/documen4.cxx
@@ -612,10 +612,9 @@ sal_uLong ScDocument::AddValidationEntry( const ScValidationData& rNew )
         pValidationList = new ScValidationDataList;
 
     sal_uLong nMax = 0;
-    sal_uInt16 nCount = pValidationList->Count();
-    for (sal_uInt16 i=0; i<nCount; i++)
+    for( ScValidationDataList::iterator it = pValidationList->begin(); it != pValidationList->end(); ++it )
     {
-        const ScValidationData* pData = (*pValidationList)[i];
+        const ScValidationData* pData = *it;
         sal_uLong nKey = pData->GetKey();
         if ( pData->EqualEntries( rNew ) )
             return nKey;
diff --git a/sc/source/core/data/validat.cxx b/sc/source/core/data/validat.cxx
index c4cb917..f41adff 100644
--- a/sc/source/core/data/validat.cxx
+++ b/sc/source/core/data/validat.cxx
@@ -54,11 +54,6 @@
 #include <memory>
 
 using namespace formula;
-//------------------------------------------------------------------------
-
-SV_IMPL_OP_PTRARR_SORT( ScValidationEntries_Impl, ScValidationDataPtr );
-
-//------------------------------------------------------------------------
 
 //
 //  Eintrag fuer Gueltigkeit (es gibt nur eine Bedingung)
@@ -885,14 +880,12 @@ bool ScValidationData::IsListValid( ScBaseCell* pCell, const ScAddress& rPos ) c
 // ============================================================================
 
 ScValidationDataList::ScValidationDataList(const ScValidationDataList& rList) :
-    ScValidationEntries_Impl()
+    std::set<ScValidationData*, CompareScValidationDataPtr>()
 {
     //  fuer Ref-Undo - echte Kopie mit neuen Tokens!
 
-    sal_uInt16 nCount = rList.Count();
-
-    for (sal_uInt16 i=0; i<nCount; i++)
-        InsertNew( rList[i]->Clone() );
+    for( iterator it = rList.begin(); it != rList.end(); ++it )
+        InsertNew( (*it)->Clone() );
 
     //!     sortierte Eintraege aus rList schneller einfuegen ???
 }
@@ -902,10 +895,8 @@ ScValidationDataList::ScValidationDataList(ScDocument* pNewDoc,
 {
     //  fuer neues Dokument - echte Kopie mit neuen Tokens!
 
-    sal_uInt16 nCount = rList.Count();
-
-    for (sal_uInt16 i=0; i<nCount; i++)
-        InsertNew( rList[i]->Clone(pNewDoc) );
+    for( iterator it = rList.begin(); it != rList.end(); ++it )
+        InsertNew( (*it)->Clone(pNewDoc) );
 
     //!     sortierte Eintraege aus rList schneller einfuegen ???
 }
@@ -914,10 +905,9 @@ ScValidationData* ScValidationDataList::GetData( sal_uInt32 nKey )
 {
     //! binaer suchen
 
-    sal_uInt16 nCount = Count();
-    for (sal_uInt16 i=0; i<nCount; i++)
-        if ((*this)[i]->GetKey() == nKey)
-            return (*this)[i];
+    for( iterator it = begin(); it != end(); ++it )
+        if( (*it)->GetKey() == nKey )
+            return *it;
 
     OSL_FAIL("ScValidationDataList: Eintrag nicht gefunden");
     return NULL;
@@ -925,35 +915,32 @@ ScValidationData* ScValidationDataList::GetData( sal_uInt32 nKey )
 
 void ScValidationDataList::CompileXML()
 {
-    sal_uInt16 nCount = Count();
-    for (sal_uInt16 i=0; i<nCount; i++)
-        (*this)[i]->CompileXML();
+    for( iterator it = begin(); it != end(); ++it )
+        (*it)->CompileXML();
 }
 
 void ScValidationDataList::UpdateReference( UpdateRefMode eUpdateRefMode,
                                 const ScRange& rRange, SCsCOL nDx, SCsROW nDy, SCsTAB nDz )
 {
-    sal_uInt16 nCount = Count();
-    for (sal_uInt16 i=0; i<nCount; i++)
-        (*this)[i]->UpdateReference( eUpdateRefMode, rRange, nDx, nDy, nDz);
+    for( iterator it = begin(); it != end(); ++it )
+        (*it)->UpdateReference( eUpdateRefMode, rRange, nDx, nDy, nDz);
 }
 
 void ScValidationDataList::UpdateMoveTab( SCTAB nOldPos, SCTAB nNewPos )
 {
-    sal_uInt16 nCount = Count();
-    for (sal_uInt16 i=0; i<nCount; i++)
-        (*this)[i]->UpdateMoveTab( nOldPos, nNewPos );
+    for( iterator it = begin(); it != end(); ++it )
+        (*it)->UpdateMoveTab( nOldPos, nNewPos );
 }
 
 sal_Bool ScValidationDataList::operator==( const ScValidationDataList& r ) const
 {
     // fuer Ref-Undo - interne Variablen werden nicht verglichen
 
-    sal_uInt16 nCount = Count();
-    sal_Bool bEqual = ( nCount == r.Count() );
-    for (sal_uInt16 i=0; i<nCount && bEqual; i++)           // Eintraege sind sortiert
-        if ( !(*this)[i]->EqualEntries(*r[i]) )         // Eintraege unterschiedlich ?
-            bEqual = false;
+    sal_uInt16 nCount = size();
+    sal_Bool bEqual = ( nCount == r.size() );
+    for( const_iterator it1 = begin(), it2 = r.begin(); it1 != end() && bEqual; ++it1, ++it2 ) // Eintraege sind sortiert
+        if ( !(*it1)->EqualEntries(**it2) )         // Eintraege unterschiedlich ?
+            bEqual = sal_False;
 
     return bEqual;
 }
commit 38b0ec8519c8692251c8973c724ef2097f12eefa
Author: Noel Grandin <noel at peralex.com>
Date:   Mon Jul 9 16:32:39 2012 +0200

    Convert SV_DECL_PTRARR_SORT(ScAddInAsyncs) to std::set
    
    Change-Id: I08959c0de113264aaa7b1ca8c4f3124b2177d30f

diff --git a/sc/source/core/data/global.cxx b/sc/source/core/data/global.cxx
index 08310e7..4d269a1 100644
--- a/sc/source/core/data/global.cxx
+++ b/sc/source/core/data/global.cxx
@@ -643,7 +643,11 @@ void ScGlobal::InitTextHeight(SfxItemPool* pPool)
 void ScGlobal::Clear()
 {
     // asyncs _vor_ ExitExternalFunc zerstoeren!
-    theAddInAsyncTbl.DeleteAndDestroy( 0, theAddInAsyncTbl.Count() );
+    for( ScAddInAsyncs::iterator it = theAddInAsyncTbl.begin(); it != theAddInAsyncTbl.end(); ++it )
+    {
+        delete *it;
+    }
+    theAddInAsyncTbl.clear();
     ExitExternalFunc();
     DELETEZ(pAutoFormat);
     DELETEZ(pSearchItem);
diff --git a/sc/source/core/inc/adiasync.hxx b/sc/source/core/inc/adiasync.hxx
index 62cc2e7..54625c8 100644
--- a/sc/source/core/inc/adiasync.hxx
+++ b/sc/source/core/inc/adiasync.hxx
@@ -30,7 +30,6 @@
 #define SC_ADIASYNC_HXX
 
 #include <svl/broadcast.hxx>
-#include <svl/svarray.hxx>
 #include <set>
 
 #include "callform.hxx"
@@ -40,11 +39,6 @@ void CALLTYPE ScAddInAsyncCallBack( double& nHandle, void* pData );
 }
 
 
-class ScAddInAsync;
-typedef ScAddInAsync* ScAddInAsyncPtr;
-SV_DECL_PTRARR_SORT( ScAddInAsyncs, ScAddInAsyncPtr, 4 )
-extern ScAddInAsyncs theAddInAsyncTbl;  // in adiasync.cxx
-
 class ScDocument;
 class ScAddInDocs : public std::set<ScDocument*> {};
 
@@ -83,10 +77,18 @@ public:
     void            AddDocument( ScDocument* pDoc ) { pDocs->insert( pDoc ); }
 
     // Vergleichsoperatoren fuer PtrArrSort
-    sal_Bool operator < ( const ScAddInAsync& r ) { return nHandle <  r.nHandle; }
-    sal_Bool operator ==( const ScAddInAsync& r ) { return nHandle == r.nHandle; }
+    bool operator< ( const ScAddInAsync& r ) const { return nHandle <  r.nHandle; }
+    bool operator==( const ScAddInAsync& r ) const { return nHandle == r.nHandle; }
 };
 
+struct CompareScAddInAsync
+{
+  bool operator()( ScAddInAsync* const& lhs, ScAddInAsync* const& rhs ) const { return (*lhs)<(*rhs); }
+};
+class ScAddInAsyncs : public std::set<ScAddInAsync*, CompareScAddInAsync> {};
+
+extern ScAddInAsyncs theAddInAsyncTbl;  // in adiasync.cxx
+
 
 
 #endif
diff --git a/sc/source/core/tool/adiasync.cxx b/sc/source/core/tool/adiasync.cxx
index b484885..ddfd0ce 100644
--- a/sc/source/core/tool/adiasync.cxx
+++ b/sc/source/core/tool/adiasync.cxx
@@ -42,8 +42,6 @@ ScAddInAsyncs theAddInAsyncTbl;
 static ScAddInAsync aSeekObj;
 
 
-SV_IMPL_OP_PTRARR_SORT( ScAddInAsyncs, ScAddInAsyncPtr );
-
 extern "C" {
 void CALLTYPE ScAddInAsyncCallBack( double& nHandle, void* pData )
 {
@@ -71,7 +69,7 @@ ScAddInAsync::ScAddInAsync(sal_uLong nHandleP, FuncData* pFuncData, ScDocument*
 {
     pDocs = new ScAddInDocs();
     pDocs->insert( pDoc );
-    theAddInAsyncTbl.Insert( this );
+    theAddInAsyncTbl.insert( this );
 }
 
 
@@ -93,11 +91,11 @@ ScAddInAsync::~ScAddInAsync()
 
 ScAddInAsync* ScAddInAsync::Get( sal_uLong nHandleP )
 {
-    sal_uInt16 nPos;
     ScAddInAsync* pRet = 0;
     aSeekObj.nHandle = nHandleP;
-    if ( theAddInAsyncTbl.Seek_Entry( &aSeekObj, &nPos ) )
-        pRet = theAddInAsyncTbl[ nPos ];
+    ScAddInAsyncs::iterator it = theAddInAsyncTbl.find( &aSeekObj );
+    if ( it != theAddInAsyncTbl.end() )
+        pRet = *it;
     aSeekObj.nHandle = 0;
     return pRet;
 }
@@ -113,7 +111,7 @@ void ScAddInAsync::CallBack( sal_uLong nHandleP, void* pData )
     if ( !p->HasListeners() )
     {
         // nicht im dTor wg. theAddInAsyncTbl.DeleteAndDestroy in ScGlobal::Clear
-        theAddInAsyncTbl.Remove( p );
+        theAddInAsyncTbl.erase( p );
         delete p;
         return ;
     }
@@ -147,25 +145,20 @@ void ScAddInAsync::CallBack( sal_uLong nHandleP, void* pData )
 
 void ScAddInAsync::RemoveDocument( ScDocument* pDocumentP )
 {
-    sal_uInt16 nPos = theAddInAsyncTbl.Count();
-    if ( nPos )
+    if ( !theAddInAsyncTbl.empty() )
     {
-        const ScAddInAsync** ppAsync =
-            (const ScAddInAsync**) theAddInAsyncTbl.GetData() + nPos - 1;
-        for ( ; nPos-- >0; ppAsync-- )
+        for( ScAddInAsyncs::reverse_iterator iter1 = theAddInAsyncTbl.rbegin(); iter1 != theAddInAsyncTbl.rend(); ++iter1 )
         {   // rueckwaerts wg. Pointer-Aufrueckerei im Array
-            ScAddInDocs* p = ((ScAddInAsync*)*ppAsync)->pDocs;
+            ScAddInAsync* pAsync = *iter1;
+            ScAddInDocs* p = pAsync->pDocs;
             ScAddInDocs::iterator iter2 = p->find( pDocumentP );
             if( iter2 != p->end() )
             {
                 p->erase( iter2 );
                 if ( p->empty() )
                 {   // dieses AddIn wird nicht mehr benutzt
-                    ScAddInAsync* pAsync = (ScAddInAsync*)*ppAsync;
-                    theAddInAsyncTbl.Remove( nPos );
+                    theAddInAsyncTbl.erase( --(iter1.base()) );
                     delete pAsync;
-                    ppAsync = (const ScAddInAsync**) theAddInAsyncTbl.GetData()
-                        + nPos;
                 }
             }
         }
commit aa3a9f917f97ee87bfa5c6269bca1bff15542dbb
Author: Noel Grandin <noel at peralex.com>
Date:   Mon Jul 9 16:02:05 2012 +0200

    Convert SV_DECL_PTRARR_SORT(ScAddInDocs) to std::set
    
    Change-Id: If9faa49b3d3fc36f36db4a7cc6ab82f8af54935a

diff --git a/sc/source/core/inc/addinlis.hxx b/sc/source/core/inc/addinlis.hxx
index 401a1ee..a8ac4dc 100644
--- a/sc/source/core/inc/addinlis.hxx
+++ b/sc/source/core/inc/addinlis.hxx
@@ -67,10 +67,10 @@ public:
     static void RemoveDocument( ScDocument* pDocument );
 
     bool HasDocument( ScDocument* pDoc ) const
-         { return pDocs->Seek_Entry( pDoc ); }
+         { return pDocs->find( pDoc ) != pDocs->end(); }
 
     void AddDocument( ScDocument* pDoc )
-         { pDocs->Insert( pDoc ); }
+         { pDocs->insert( pDoc ); }
 
     const com::sun::star::uno::Any& GetResult() const
           { return aResult; }
diff --git a/sc/source/core/inc/adiasync.hxx b/sc/source/core/inc/adiasync.hxx
index cfb3c21..62cc2e7 100644
--- a/sc/source/core/inc/adiasync.hxx
+++ b/sc/source/core/inc/adiasync.hxx
@@ -31,6 +31,7 @@
 
 #include <svl/broadcast.hxx>
 #include <svl/svarray.hxx>
+#include <set>
 
 #include "callform.hxx"
 
@@ -45,8 +46,7 @@ SV_DECL_PTRARR_SORT( ScAddInAsyncs, ScAddInAsyncPtr, 4 )
 extern ScAddInAsyncs theAddInAsyncTbl;  // in adiasync.cxx
 
 class ScDocument;
-typedef ScDocument* ScAddInDocPtr;
-SV_DECL_PTRARR_SORT( ScAddInDocs, ScAddInDocPtr, 1 )
+class ScAddInDocs : public std::set<ScDocument*> {};
 
 class String;
 
@@ -78,9 +78,9 @@ public:
     ParamType       GetType() const         { return meType; }
     double          GetValue() const        { return nVal; }
     const String&   GetString() const       { return *pStr; }
-    sal_Bool            HasDocument( ScDocument* pDoc ) const
-                        { return pDocs->Seek_Entry( pDoc ); }
-    void            AddDocument( ScDocument* pDoc ) { pDocs->Insert( pDoc ); }
+    bool            HasDocument( ScDocument* pDoc ) const
+                        { return pDocs->find( pDoc ) != pDocs->end(); }
+    void            AddDocument( ScDocument* pDoc ) { pDocs->insert( pDoc ); }
 
     // Vergleichsoperatoren fuer PtrArrSort
     sal_Bool operator < ( const ScAddInAsync& r ) { return nHandle <  r.nHandle; }
diff --git a/sc/source/core/tool/addinlis.cxx b/sc/source/core/tool/addinlis.cxx
index 42b7407..ea83480 100644
--- a/sc/source/core/tool/addinlis.cxx
+++ b/sc/source/core/tool/addinlis.cxx
@@ -59,8 +59,8 @@ ScAddInListener* ScAddInListener::CreateListener(
 ScAddInListener::ScAddInListener( uno::Reference<sheet::XVolatileResult> xVR, ScDocument* pDoc ) :
     xVolRes( xVR )
 {
-    pDocs = new ScAddInDocs( 1 );
-    pDocs->Insert( pDoc );
+    pDocs = new ScAddInDocs();
+    pDocs->insert( pDoc );
 }
 
 ScAddInListener::~ScAddInListener()
@@ -91,11 +91,11 @@ void ScAddInListener::RemoveDocument( ScDocument* pDocumentP )
     while(iter != aAllListeners.end())
     {
         ScAddInDocs* p = (*iter)->pDocs;
-        sal_uInt16 nFoundPos;
-        if ( p->Seek_Entry( pDocumentP, &nFoundPos ) )
+        ScAddInDocs::iterator iter2 = p->find( pDocumentP );
+        if( iter2 != p->end() )
         {
-            p->Remove( nFoundPos );
-            if ( p->Count() == 0 )
+            p->erase( iter2 );
+            if ( p->empty() )
             {
                 if ( (*iter)->xVolRes.is() )
                     (*iter)->xVolRes->removeResultListener( *iter );
@@ -126,11 +126,9 @@ void SAL_CALL ScAddInListener::modified( const ::com::sun::star::sheet::ResultEv
 
     Broadcast( ScHint( SC_HINT_DATACHANGED, ScAddress(), NULL ) );
 
-    const ScDocument** ppDoc = (const ScDocument**) pDocs->GetData();
-    sal_uInt16 nCount = pDocs->Count();
-    for ( sal_uInt16 j=0; j<nCount; j++, ppDoc++ )
+    for ( ScAddInDocs::iterator it = pDocs->begin(); it != pDocs->end(); ++it )
     {
-        ScDocument* pDoc = (ScDocument*)*ppDoc;
+        ScDocument* pDoc = *it;
         pDoc->TrackFormulas();
         pDoc->GetDocumentShell()->Broadcast( SfxSimpleHint( FID_DATACHANGED ) );
     }
diff --git a/sc/source/core/tool/adiasync.cxx b/sc/source/core/tool/adiasync.cxx
index e30bca9..b484885 100644
--- a/sc/source/core/tool/adiasync.cxx
+++ b/sc/source/core/tool/adiasync.cxx
@@ -44,8 +44,6 @@ static ScAddInAsync aSeekObj;
 
 SV_IMPL_OP_PTRARR_SORT( ScAddInAsyncs, ScAddInAsyncPtr );
 
-SV_IMPL_PTRARR_SORT( ScAddInDocs, ScAddInDocPtr );
-
 extern "C" {
 void CALLTYPE ScAddInAsyncCallBack( double& nHandle, void* pData )
 {
@@ -71,8 +69,8 @@ ScAddInAsync::ScAddInAsync(sal_uLong nHandleP, FuncData* pFuncData, ScDocument*
     meType(pFuncData->GetAsyncType()),
     bValid( false )
 {
-    pDocs = new ScAddInDocs( 1 );
-    pDocs->Insert( pDoc );
+    pDocs = new ScAddInDocs();
+    pDocs->insert( pDoc );
     theAddInAsyncTbl.Insert( this );
 }
 
@@ -137,11 +135,9 @@ void ScAddInAsync::CallBack( sal_uLong nHandleP, void* pData )
     p->bValid = sal_True;
     p->Broadcast( ScHint( SC_HINT_DATACHANGED, ScAddress(), NULL ) );
 
-    const ScDocument** ppDoc = (const ScDocument**) p->pDocs->GetData();
-    sal_uInt16 nCount = p->pDocs->Count();
-    for ( sal_uInt16 j=0; j<nCount; j++, ppDoc++ )
+    for ( ScAddInDocs::iterator it = p->pDocs->begin(); it != p->pDocs->end(); ++it )
     {
-        ScDocument* pDoc = (ScDocument*)*ppDoc;
+        ScDocument* pDoc = *it;
         pDoc->TrackFormulas();
         pDoc->GetDocumentShell()->Broadcast( SfxSimpleHint( FID_DATACHANGED ) );
     }
@@ -159,11 +155,11 @@ void ScAddInAsync::RemoveDocument( ScDocument* pDocumentP )
         for ( ; nPos-- >0; ppAsync-- )
         {   // rueckwaerts wg. Pointer-Aufrueckerei im Array
             ScAddInDocs* p = ((ScAddInAsync*)*ppAsync)->pDocs;
-            sal_uInt16 nFoundPos;
-            if ( p->Seek_Entry( pDocumentP, &nFoundPos ) )
+            ScAddInDocs::iterator iter2 = p->find( pDocumentP );
+            if( iter2 != p->end() )
             {
-                p->Remove( nFoundPos );
-                if ( p->Count() == 0 )
+                p->erase( iter2 );
+                if ( p->empty() )
                 {   // dieses AddIn wird nicht mehr benutzt
                     ScAddInAsync* pAsync = (ScAddInAsync*)*ppAsync;
                     theAddInAsyncTbl.Remove( nPos );


More information about the Libreoffice-commits mailing list