[Libreoffice-commits] .: 3 commits - sfx2/inc sfx2/source sw/source

August Sodora augsod at kemper.freedesktop.org
Mon Jan 16 17:23:50 PST 2012


 sfx2/inc/arrdecl.hxx             |    4 
 sfx2/inc/sfx2/minarray.hxx       |  266 ---------------------------------------
 sfx2/inc/sfx2/minstack.hxx       |   33 ----
 sfx2/source/control/dispatch.cxx |   87 +++++-------
 sw/source/ui/utlui/gloslst.cxx   |   73 ++++------
 5 files changed, 68 insertions(+), 395 deletions(-)

New commits:
commit 4f8efe5ca7e6075acbb8014a221a260f9ab81474
Author: August Sodora <augsod at gmail.com>
Date:   Mon Jan 16 20:21:02 2012 -0500

    Remove *_OBJSTACK, *_OBJARRAY

diff --git a/sfx2/inc/sfx2/minarray.hxx b/sfx2/inc/sfx2/minarray.hxx
index a419588..44df912 100644
--- a/sfx2/inc/sfx2/minarray.hxx
+++ b/sfx2/inc/sfx2/minarray.hxx
@@ -36,272 +36,6 @@
 #include <tools/solar.h>
 #include <tools/debug.hxx>
 
-#define DECL_OBJARRAY( ARR, T, nI, nG ) \
-class ARR\
-{\
-private:\
-    T*   pData;\
-    sal_uInt16  nUsed;\
-    sal_uInt8   nGrow;\
-    sal_uInt8    nUnused;\
-public:\
-    ARR( sal_uInt8 nInitSize = nI, sal_uInt8 nGrowSize = nG );\
-    ARR( const ARR& rOrig );\
-    ~ARR();\
-\
-    ARR& operator= ( const ARR& rOrig );\
-\
-    const T& GetObject( sal_uInt16 nPos ) const; \
-    T& GetObject( sal_uInt16 nPos ); \
-\
-    void Insert( sal_uInt16 nPos, const T& rElem );\
-    void Insert( sal_uInt16 nPos, const T& rElems, sal_uInt16 nLen );\
-    void Append( const T& rElem );\
-\
-    sal_Bool Remove( const T& rElem );\
-    sal_uInt16 Remove( sal_uInt16 nPos, sal_uInt16 nLen );\
-\
-    sal_uInt16 Count() const { return nUsed; }\
-    T* operator*();\
-    const T& operator[]( sal_uInt16 nPos ) const;\
-    T& operator[]( sal_uInt16 nPos );\
-\
-    sal_Bool Contains( const T& rItem ) const;\
-    void Clear() { Remove( 0, Count() ); }\
-};\
-\
-inline void ARR::Insert( sal_uInt16 nPos, const T& rElem )\
-{\
-    Insert( nPos, rElem, 1 );\
-}\
-\
-inline T* ARR::operator*()\
-{\
-    return ( nUsed==0 ? 0 : pData );\
-} \
-inline const T& ARR::operator[]( sal_uInt16 nPos ) const\
-{\
-    DBG_ASSERT( nPos < nUsed, "" ); \
-    return *(pData+nPos);\
-} \
-inline T& ARR::operator [] (sal_uInt16 nPos) \
-{\
-    DBG_ASSERT( nPos < nUsed, "" ); \
-    return *(pData+nPos); \
-} \
-inline const T& ARR::GetObject( sal_uInt16 nPos ) const { return operator[](nPos); } \
-inline T& ARR::GetObject( sal_uInt16 nPos ) { return operator[](nPos); } \
-
-#ifndef _lint
-// String too long
-
-#define IMPL_OBJARRAY( ARR, T ) \
-ARR::ARR( sal_uInt8 nInitSize, sal_uInt8 nGrowSize ): \
-    nUsed(0), \
-    nGrow( nGrowSize ? nGrowSize : 1 ), \
-    nUnused(nInitSize) \
-{ \
-    if ( nInitSize != 0 ) \
-    { \
-        size_t nBytes = nInitSize * sizeof(T); \
-        pData = (T*) new char[ nBytes ]; \
-        memset( pData, 0, nBytes ); \
-    } \
-    else \
-        pData = 0; \
-} \
-\
-ARR::ARR( const ARR& rOrig ) \
-{ \
-    nUsed = rOrig.nUsed; \
-    nGrow = rOrig.nGrow; \
-    nUnused = rOrig.nUnused; \
-\
-    if ( rOrig.pData != 0 ) \
-    { \
-        size_t nBytes = (nUsed + nUnused) * sizeof(T); \
-        pData = (T*) new char [ nBytes ]; \
-        memset( pData, 0, nBytes ); \
-        for ( sal_uInt16 n = 0; n < nUsed; ++n ) \
-            *(pData+n) = *(rOrig.pData+n); \
-    } \
-    else \
-        pData = 0; \
-} \
-\
-ARR::~ARR() \
-{ \
-    for ( sal_uInt16 n = 0; n < nUsed; ++n ) \
-        ( pData+n )->T::~T(); \
-    delete[] (char*) pData;\
-} \
-\
-ARR& ARR::operator= ( const ARR& rOrig )\
-{ \
-    for ( sal_uInt16 n = 0; n < nUsed; ++n ) \
-        ( pData+n )->T::~T(); \
-    delete[] (char*) pData;\
-\
-    nUsed = rOrig.nUsed; \
-    nGrow = rOrig.nGrow; \
-    nUnused = rOrig.nUnused; \
-\
-    if ( rOrig.pData != 0 ) \
-    { \
-        size_t nBytes = (nUsed + nUnused) * sizeof(T); \
-        pData = (T*) new char[ nBytes ]; \
-        memset( pData, 0, nBytes ); \
-        for ( sal_uInt16 n = 0; n < nUsed; ++n ) \
-            *(pData+n) = *(rOrig.pData+n); \
-    } \
-    else \
-        pData = 0; \
-    return *this; \
-} \
-\
-void ARR::Append( const T& aElem ) \
-{ \
-     \
-    if ( nUnused == 0 ) \
-    { \
-        sal_uInt16 nNewSize = (nUsed == 1) ? (nGrow==1 ? 2 : nGrow) : nUsed+nGrow; \
-        size_t nBytes = nNewSize * sizeof(T); \
-        T* pNewData = (T*) new char[ nBytes ]; \
-        memset( pNewData, 0, nBytes ); \
-        if ( pData ) \
-        { \
-            memcpy( pNewData, pData, nUsed * sizeof(T) ); \
-            delete[] (char*) pData;\
-        } \
-        nUnused = (sal_uInt8)(nNewSize-nUsed); \
-        pData = pNewData; \
-    } \
-\
-     \
-    pData[nUsed] = aElem; \
-    ++nUsed; \
-    --nUnused; \
-} \
-\
-sal_uInt16 ARR::Remove( sal_uInt16 nPos, sal_uInt16 nLen ) \
-{ \
-    DBG_ASSERT( (nPos+nLen) < (nUsed+1), "" ); \
-    DBG_ASSERT( nLen > 0, "" ); \
-\
-    nLen = Min( (sal_uInt16)(nUsed-nPos), (sal_uInt16)nLen ); \
-\
-    if ( nLen == 0 ) \
-        return 0; \
-\
-    for ( sal_uInt16 n = nPos; n < (nPos+nLen); ++n ) \
-        ( pData+n )->T::~T(); \
-\
-    if ( (nUsed-nLen) == 0 ) \
-    { \
-        delete[] (char*) pData;\
-        pData = 0; \
-        nUsed = 0; \
-        nUnused = 0; \
-        return nLen; \
-    } \
-\
-    if ( (nUnused+nLen) >= nGrow ) \
-    { \
-        sal_uInt16 nNewUsed = nUsed-nLen; \
-        sal_uInt16 nNewSize = ((nNewUsed+nGrow-1)/nGrow) * nGrow; \
-        DBG_ASSERT( nNewUsed <= nNewSize && nNewUsed+nGrow > nNewSize, \
-                    "shrink size computation failed" ); \
-        size_t nBytes = nNewSize * sizeof(T); \
-        T* pNewData = (T*) new char[ nBytes ]; \
-        memset( pNewData, 0, nBytes ); \
-        if ( nPos > 0 ) \
-            memcpy( pNewData, pData, nPos * sizeof(T) ); \
-        if ( nNewUsed != nPos ) \
-            memcpy(pNewData+nPos, pData+nPos+nLen, (nNewUsed-nPos) * sizeof(T) ); \
-        delete[] (char*) pData;\
-        pData = pNewData; \
-        nUsed = nNewUsed; \
-        nUnused = (sal_uInt8)(nNewSize - nNewUsed); \
-        return nLen; \
-    } \
-\
-     \
-    if ( nUsed-nPos-nLen > 0 ) \
-    { \
-        memmove(pData+nPos, pData+nPos+nLen, (nUsed-nPos-nLen) * sizeof(T));\
-    } \
-    nUsed = nUsed - nLen; \
-    nUnused = sal::static_int_cast< sal_uInt8 >(nUnused + nLen); \
-    return nLen; \
-} \
-\
-sal_Bool ARR::Remove( const T& aElem ) \
-{ \
-    if ( nUsed == 0 ) \
-        return sal_False; \
-\
-    const T *pIter = pData + nUsed - 1; \
-    for ( sal_uInt16 n = 0; n < nUsed; ++n, --pIter ) \
-        if ( *pIter == aElem ) \
-        { \
-            Remove(nUsed-n-1, 1); \
-            return sal_True; \
-        } \
-    return sal_False; \
-} \
-\
-sal_Bool ARR::Contains( const T& rItem ) const \
-{ \
-    if ( !nUsed ) \
-        return sal_False; \
-    for ( sal_uInt16 n = 0; n < nUsed; ++n ) \
-    { \
-        const T& r2ndItem = GetObject(n); \
-        if ( r2ndItem == rItem ) \
-            return sal_True; \
-    } \
-    return sal_False; \
-} \
-\
-void ARR::Insert( sal_uInt16 nPos, const T& rElems, sal_uInt16 nLen ) \
-{ \
-    DBG_ASSERT( nPos <= nUsed, "" ); \
-     \
-    if ( nUnused == 0 ) \
-    { \
-        \
-        /* increase (round up) to the next Grow-limit  */       \
-        sal_uInt16 nNewSize; \
-        for ( nNewSize = nUsed+nGrow; nNewSize < (nUsed + nLen); ++nNewSize ) \
-            /* empty loop */; \
-        size_t nBytes = nNewSize * sizeof(T); \
-        T* pNewData = (T*) new char[ nBytes ]; \
-        memset( pNewData, 0, nBytes ); \
-        \
-        if ( pData ) \
-        { \
-            DBG_ASSERT( nUsed < nNewSize, "" ); \
-            memcpy( pNewData, pData, nUsed * sizeof(T) ); \
-            delete (char*) pData;\
-        } \
-        nUnused = (sal_uInt8)(nNewSize-nUsed); \
-        pData = pNewData; \
-    } \
-\
-     \
-    if ( nPos < nUsed ) \
-    { \
-        memmove(pData+nPos+nLen-1, pData+nPos-1, sizeof(T) * (nUsed-nPos)); \
-    } \
-\
-    memmove(pData+nPos, &rElems, sizeof(T) * nLen); \
-    nUsed = nUsed + nLen; \
-    nUnused = sal::static_int_cast< sal_uInt8 >(nUnused - nLen); \
-}
-
-// _lint
-#endif
-
 class SFX2_DLLPUBLIC SfxPtrArr
 {
 private:
diff --git a/sfx2/inc/sfx2/minstack.hxx b/sfx2/inc/sfx2/minstack.hxx
index 5a64e31..361c304 100644
--- a/sfx2/inc/sfx2/minstack.hxx
+++ b/sfx2/inc/sfx2/minstack.hxx
@@ -30,39 +30,6 @@
 
 #include <sfx2/minarray.hxx>
 
-#define DECL_OBJSTACK( ARR, T, nI, nG ) \
-DECL_OBJARRAY( ARR##arr_, T, nI, nG ); \
-class ARR: private ARR##arr_ \
-{ \
-public: \
-    ARR( sal_uInt8 nInitSize = nI, sal_uInt8 nGrowSize = nG ): \
-        ARR##arr_( nInitSize, nGrowSize ) \
-    {} \
-\
-    ARR( const ARR& rOrig ): \
-        ARR##arr_( rOrig ) \
-    {} \
-\
-    sal_uInt16      Count() const { return ARR##arr_::Count(); } \
-    void        Push( const T& rElem ) { Append( rElem ); } \
-    const T& Top( sal_uInt16 nLevel = 0 ) const \
-                { return (*this)[Count()-nLevel-1]; } \
-    const T& Bottom() const { return (*this)[0]; } \
-    T        Pop(); \
-    void        Clear() { ARR##arr_::Clear(); } \
-    sal_Bool        Contains( const T& rItem ) const \
-                { return ARR##arr_::Contains( rItem ); } \
-}
-
-#define IMPL_OBJSTACK( ARR, T ) \
-IMPL_OBJARRAY( ARR##arr_, T ); \
-\
-T ARR::Pop() \
-{   T aRet = (*this)[Count()-1]; \
-    Remove( Count()-1, 1 ); \
-    return aRet; \
-}
-
 #define DECL_PTRSTACK( ARR, T, nI, nG ) \
 DECL_PTRARRAY( ARR##arr_, T, nI, nG ) \
 class ARR: private ARR##arr_ \
diff --git a/sfx2/source/control/dispatch.cxx b/sfx2/source/control/dispatch.cxx
index 0fc008a..4d3f2d7 100644
--- a/sfx2/source/control/dispatch.cxx
+++ b/sfx2/source/control/dispatch.cxx
@@ -71,6 +71,8 @@
 #include "workwin.hxx"
 #include <rtl/strbuf.hxx>
 
+#include <deque>
+
 namespace css = ::com::sun::star;
 
 //==================================================================
@@ -111,9 +113,6 @@ struct SfxToDo_Impl
     { return pCluster==rWith.pCluster && bPush==rWith.bPush; }
 };
 
-DECL_OBJSTACK(SfxToDoStack_Impl, SfxToDo_Impl, 8, 4);
-IMPL_OBJSTACK(SfxToDoStack_Impl, SfxToDo_Impl);
-
 struct SfxObjectBars_Impl
 {
     sal_uInt32     nResId;  // Resource - and ConfigId of the Toolbox
@@ -135,7 +134,7 @@ struct SfxDispatcher_Impl
     const SfxSlotServer* pCachedServ2;  // penultimate called Message
     SfxShellStack_Impl   aStack;        // active functionality
     Timer                aTimer;        // for Flush
-    SfxToDoStack_Impl    aToDoStack;    // not processed Push/Pop
+    std::deque<SfxToDo_Impl> aToDoStack;    // not processed Push/Pop
     SfxViewFrame*        pFrame;        // NULL or associated Frame
     SfxDispatcher*       pParent;       // AppDispatcher, NULL if possible
     SfxHintPosterRef     xPoster;       // Execute asynchronous
@@ -481,11 +480,11 @@ void SfxDispatcher::Pop
             << (bUntil ? " (up to)" : ""));
 
     // same shell as on top of the to-do stack?
-    if ( pImp->aToDoStack.Count() && pImp->aToDoStack.Top().pCluster == &rShell )
+    if(pImp->aToDoStack.size() && pImp->aToDoStack.front().pCluster == &rShell)
     {
         // cancel inverse actions
-        if ( pImp->aToDoStack.Top().bPush != bPush )
-            pImp->aToDoStack.Pop();
+        if ( pImp->aToDoStack.front().bPush != bPush )
+            pImp->aToDoStack.pop_front();
         else
         {
             DBG_ASSERT( bPush, "SfxInterface pushed more than once" );
@@ -495,7 +494,7 @@ void SfxDispatcher::Pop
     else
     {
         // Remember ::com::sun::star::chaos::Action
-        pImp->aToDoStack.Push( SfxToDo_Impl(bPush, bDelete, bUntil, rShell) );
+        pImp->aToDoStack.push_front( SfxToDo_Impl(bPush, bDelete, bUntil, rShell) );
         if ( bFlushed )
         {
             OSL_TRACE("Unflushed dispatcher!");
@@ -509,7 +508,7 @@ void SfxDispatcher::Pop
         }
     }
 
-    if ( !pSfxApp->IsDowning() && pImp->aToDoStack.Count() )
+    if(!pSfxApp->IsDowning() && !pImp->aToDoStack.empty())
     {
         // No immediate update is requested
         pImp->aTimer.SetTimeout(SFX_FLUSH_TIMEOUT);
@@ -522,7 +521,7 @@ void SfxDispatcher::Pop
         pImp->aTimer.Stop();
 
         // Bindings may wake up again
-        if ( !pImp->aToDoStack.Count() )
+        if(pImp->aToDoStack.empty())
         {
             SfxBindings* pBindings = GetBindings();
             if ( pBindings )
@@ -573,21 +572,20 @@ sal_Bool SfxDispatcher::CheckVirtualStack( const SfxShell& rShell, sal_Bool bDee
     SFX_STACK(SfxDispatcher::CheckVirtualStack);
 
     SfxShellStack_Impl aStack( pImp->aStack );
-    for ( short nToDo = pImp->aToDoStack.Count()-1; nToDo >= 0; --nToDo )
+    for(std::deque<SfxToDo_Impl>::const_reverse_iterator i = pImp->aToDoStack.rbegin(); i != pImp->aToDoStack.rend(); ++i)
     {
-        SfxToDo_Impl aToDo( pImp->aToDoStack.Top(nToDo) );
-        if ( aToDo.bPush )
-            aStack.Push( (SfxShell*) aToDo.pCluster );
+        if(i->bPush)
+            aStack.Push(static_cast<SfxShell*>(i->pCluster));
         else
         {
-            SfxShell* pPopped = 0;
+            SfxShell* pPopped(NULL);
             do
             {
                 DBG_ASSERT( aStack.Count(), "popping from empty stack" );
                 pPopped = aStack.Pop();
             }
-            while ( aToDo.bUntil && pPopped != aToDo.pCluster );
-            DBG_ASSERT( pPopped == aToDo.pCluster, "popping unpushed SfxInterface" );
+            while(i->bUntil && pPopped != i->pCluster);
+            DBG_ASSERT(pPopped == i->pCluster, "popping unpushed SfxInterface");
         }
     }
 
@@ -757,7 +755,7 @@ void SfxDispatcher::DoActivate_Impl( sal_Bool bMDI, SfxViewFrame* /* pOld */ )
         pImp->pFrame->GetFrame().GetWorkWindow_Impl()->HidePopups_Impl( sal_False, sal_False, 1 );
     }
 
-    if ( pImp->aToDoStack.Count() )
+    if(!pImp->aToDoStack.empty())
     {
         // No immediate update is requested
         pImp->aTimer.SetTimeout(SFX_FLUSH_TIMEOUT);
@@ -929,7 +927,7 @@ void SfxDispatcher::_Execute
 
 {
     DBG_ASSERT( !pImp->bFlushing, "recursive call to dispatcher" );
-    DBG_ASSERT( !pImp->aToDoStack.Count(), "unprepared InPlace _Execute" );
+    DBG_ASSERT( pImp->aToDoStack.empty(), "unprepared InPlace _Execute" );
 
     if ( IsLocked( rSlot.GetSlotId() ) )
         return;
@@ -1609,24 +1607,22 @@ void SfxDispatcher::FlushImpl()
     SfxApplication *pSfxApp = SFX_APP();
 
     // Re-build the true stack in the first round
-    SfxToDoStack_Impl aToDoCopy;
+    std::deque<SfxToDo_Impl> aToDoCopy;
     sal_Bool bModify = sal_False;
-    short nToDo;
-    for ( nToDo = pImp->aToDoStack.Count()-1; nToDo >= 0; --nToDo )
+    for(std::deque<SfxToDo_Impl>::reverse_iterator i = pImp->aToDoStack.rbegin(); i != pImp->aToDoStack.rend(); ++i)
     {
         bModify = sal_True;
 
-        SfxToDo_Impl aToDo( pImp->aToDoStack.Top(nToDo) );
-        if ( aToDo.bPush )
+        if(i->bPush)
         {
             // Actually push
-            DBG_ASSERT( !pImp->aStack.Contains( aToDo.pCluster ),
-                        "pushed SfxShell already on stack" );
-            pImp->aStack.Push( aToDo.pCluster );
-            aToDo.pCluster->SetDisableFlags( pImp->nDisableFlags );
+            DBG_ASSERT(!pImp->aStack.Contains(i->pCluster),
+                       "pushed SfxShell already on stack" );
+            pImp->aStack.Push(i->pCluster);
+            i->pCluster->SetDisableFlags(pImp->nDisableFlags);
 
             // Mark the moved shell
-            aToDoCopy.Push( aToDo );
+            aToDoCopy.push_front(*i);
         }
         else
         {
@@ -1638,18 +1634,16 @@ void SfxDispatcher::FlushImpl()
                 DBG_ASSERT( pImp->aStack.Count(), "popping from empty stack" );
                 pPopped = pImp->aStack.Pop();
                 pPopped->SetDisableFlags( 0 );
-                bFound = pPopped == aToDo.pCluster;
+                bFound = (pPopped == i->pCluster);
 
                 // Mark the moved Shell
-                aToDoCopy.Push( SfxToDo_Impl( sal_False, aToDo.bDelete, sal_False, *pPopped) );
+                aToDoCopy.push_front(SfxToDo_Impl(sal_False, i->bDelete, sal_False, *pPopped));
             }
-            while ( aToDo.bUntil && !bFound );
+            while(i->bUntil && !bFound);
             DBG_ASSERT( bFound, "wrong SfxShell popped" );
         }
-
-        if ( nToDo == 0 )
-            pImp->aToDoStack.Clear();
     }
+    pImp->aToDoStack.clear();
 
     // Invalidate bindings, if possible
     if ( !pSfxApp->IsDowning() )
@@ -1669,26 +1663,25 @@ void SfxDispatcher::FlushImpl()
     OSL_TRACE("Successfully flushed dispatcher!");
 
     // Activate the Shells and possible delete them in the 2nd round
-    for ( nToDo = aToDoCopy.Count()-1; nToDo >= 0; --nToDo )
+    for(std::deque<SfxToDo_Impl>::reverse_iterator i = aToDoCopy.rbegin(); i != aToDoCopy.rend(); ++i)
     {
-        SfxToDo_Impl aToDo( aToDoCopy.Top(nToDo) );
-        if ( aToDo.bPush )
+        if(i->bPush)
         {
             if ( pImp->bActive )
-                aToDo.pCluster->DoActivate_Impl(pImp->pFrame, sal_True);
+                i->pCluster->DoActivate_Impl(pImp->pFrame, sal_True);
         }
-        else
-            if ( pImp->bActive )
-                aToDo.pCluster->DoDeactivate_Impl(pImp->pFrame, sal_True);
+        else if ( pImp->bActive )
+                i->pCluster->DoDeactivate_Impl(pImp->pFrame, sal_True);
     }
-    for ( nToDo = aToDoCopy.Count()-1; nToDo >= 0; --nToDo )
+
+    for(std::deque<SfxToDo_Impl>::reverse_iterator i = aToDoCopy.rbegin(); i != aToDoCopy.rend(); ++i)
     {
-        SfxToDo_Impl aToDo( aToDoCopy.Top(nToDo) );
-        if ( aToDo.bDelete ) delete aToDo.pCluster;
+        if(i->bDelete)
+            delete i->pCluster;
     }
-    sal_Bool bAwakeBindings = aToDoCopy.Count() != 0;
+    sal_Bool bAwakeBindings = !aToDoCopy.empty();
     if( bAwakeBindings )
-        aToDoCopy.Clear();
+        aToDoCopy.clear();
 
     // If more changes have occured on the stach when
     // Activate/Deactivate/Delete:
commit d72e62066079c894d7275d60fecf4ef19f9fa01c
Author: August Sodora <augsod at gmail.com>
Date:   Mon Jan 16 18:22:30 2012 -0500

    Remove unused SV_DECL_PTRARR_DEL

diff --git a/sfx2/inc/arrdecl.hxx b/sfx2/inc/arrdecl.hxx
index c7d181e..2d33577 100644
--- a/sfx2/inc/arrdecl.hxx
+++ b/sfx2/inc/arrdecl.hxx
@@ -32,10 +32,6 @@
 #include <sfx2/minarray.hxx>
 #include <vector>
 
-struct CntUpdateResult;
-
-SV_DECL_PTRARR_DEL(CntUpdateResults_Impl, CntUpdateResult*, 4, 4)
-
 class SfxObjectShell;
 SV_DECL_PTRARR( SfxObjectShellArr_Impl, SfxObjectShell*, 4, 4 )
 
commit 104d688af4e34d13631dd37afb659bb8c7da74f0
Author: August Sodora <augsod at gmail.com>
Date:   Mon Jan 16 13:07:00 2012 -0500

    SV_DECL_PTRARR_DEL->std::vector

diff --git a/sw/source/ui/utlui/gloslst.cxx b/sw/source/ui/utlui/gloslst.cxx
index 9e507d8..9ada864 100644
--- a/sw/source/ui/utlui/gloslst.cxx
+++ b/sw/source/ui/utlui/gloslst.cxx
@@ -62,10 +62,6 @@ struct TripleString
     String sShort;
 };
 
-typedef TripleString* TripleStringPtr;
-SV_DECL_PTRARR_DEL( TripleStrings, TripleStringPtr, 0, 4 )
-SV_IMPL_PTRARR( TripleStrings, TripleStringPtr )
-
 class SwGlossDecideDlg : public ModalDialog
 {
     OKButton        aOk;
@@ -107,11 +103,6 @@ IMPL_LINK(SwGlossDecideDlg, SelectHdl, ListBox*, EMPTYARG)
     return 0;
 }
 
-/********************************************************************
-
-********************************************************************/
-
-
 SwGlossaryList::SwGlossaryList() :
     bFilled(sal_False)
 {
@@ -120,11 +111,6 @@ SwGlossaryList::SwGlossaryList() :
     SetTimeout(GLOS_TIMEOUT);
 }
 
-/********************************************************************
-
-********************************************************************/
-
-
 SwGlossaryList::~SwGlossaryList()
 {
     ClearGroups();
@@ -136,42 +122,44 @@ SwGlossaryList::~SwGlossaryList()
  * bei Bedarf nach der richtigen Gruppe gefragt
 ********************************************************************/
 
-
 sal_Bool SwGlossaryList::GetShortName(const String& rLongName,
                                 String& rShortName, String& rGroupName )
 {
     if(!bFilled)
         Update();
 
-    TripleStrings aTripleStrings;
+    std::vector<TripleString> aTripleStrings;
 
     sal_uInt16 nCount = aGroupArr.Count();
     sal_uInt16 nFound = 0;
     for(sal_uInt16 i = 0; i < nCount; i++ )
     {
         AutoTextGroup* pGroup = aGroupArr.GetObject(i);
-        if(!rGroupName.Len() || rGroupName == pGroup->sName)
-            for(sal_uInt16 j = 0; j < pGroup->nCount; j++)
-            {
-                String sLong = pGroup->sLongNames.GetToken(j, STRING_DELIM);
-                if((rLongName == sLong))
-                {
-                    TripleString* pTriple = new TripleString;
-                    pTriple->sGroup = pGroup->sName;
-                    pTriple->sBlock = sLong;
-                    pTriple->sShort = pGroup->sShortNames.GetToken(j, STRING_DELIM);
-                    aTripleStrings.Insert(pTriple, nFound++);
-                }
-            }
+        if(rGroupName.Len() && rGroupName != pGroup->sName)
+            continue;
+
+        for(sal_uInt16 j = 0; j < pGroup->nCount; j++)
+        {
+            String sLong = pGroup->sLongNames.GetToken(j, STRING_DELIM);
+            if(rLongName != sLong)
+                continue;
+
+            TripleString pTriple;
+            pTriple.sGroup = pGroup->sName;
+            pTriple.sBlock = sLong;
+            pTriple.sShort = pGroup->sShortNames.GetToken(j, STRING_DELIM);
+            aTripleStrings.push_back(pTriple);
+            ++nFound;
+        }
     }
 
     sal_Bool bRet = sal_False;
-    nCount = aTripleStrings.Count();
-    if(1 == nCount )
+    nCount = aTripleStrings.size();
+    if(1 == nCount)
     {
-        TripleString* pTriple = aTripleStrings[0];
-        rShortName = pTriple->sShort;
-        rGroupName = pTriple->sGroup;
+        const TripleString& pTriple(aTripleStrings.front());
+        rShortName = pTriple.sShort;
+        rGroupName = pTriple.sGroup;
         bRet = sal_True;
     }
     else if(1 < nCount)
@@ -179,20 +167,20 @@ sal_Bool SwGlossaryList::GetShortName(const String& rLongName,
         SwGlossDecideDlg aDlg(0);
         String sTitle = aDlg.GetText();
         sTitle += ' ';
-        sTitle += aTripleStrings[0]->sBlock;
+        sTitle += aTripleStrings.front().sBlock;
         aDlg.SetText(sTitle);
 
         ListBox& rLB = aDlg.GetListBox();
-        for(sal_uInt16 i = 0; i < nCount; i++ )
-            rLB.InsertEntry(aTripleStrings[i]->sGroup.GetToken(0, GLOS_DELIM));
+        for(std::vector<TripleString>::const_iterator i = aTripleStrings.begin(); i != aTripleStrings.end(); ++i)
+            rLB.InsertEntry(i->sGroup.GetToken(0, GLOS_DELIM));
 
         rLB.SelectEntryPos(0);
         if(RET_OK == aDlg.Execute() &&
             LISTBOX_ENTRY_NOTFOUND != rLB.GetSelectEntryPos())
         {
-            TripleString* pTriple = aTripleStrings[rLB.GetSelectEntryPos()];
-            rShortName = pTriple->sShort;
-            rGroupName = pTriple->sGroup;
+            const TripleString& pTriple(aTripleStrings[rLB.GetSelectEntryPos()]);
+            rShortName = pTriple.sShort;
+            rGroupName = pTriple.sGroup;
             bRet = sal_True;
         }
         else
@@ -201,11 +189,6 @@ sal_Bool SwGlossaryList::GetShortName(const String& rLongName,
     return bRet;
 }
 
-/********************************************************************
-
-********************************************************************/
-
-
 sal_uInt16  SwGlossaryList::GetGroupCount()
 {
     if(!bFilled)


More information about the Libreoffice-commits mailing list