[PATCH] Replace SvULongs with std::vector in sfx2

Maciej Rumianowski maciej.rumianowski at gmail.com
Tue Sep 27 13:04:20 PDT 2011


Bug 38831, replace SvULongs with std::vector in sfx2 and related svtools
---
 sfx2/inc/sfx2/frmhtml.hxx         |    1 -
 sfx2/source/bastyp/frmhtml.cxx    |    4 ----
 sfx2/source/bastyp/sfxhtml.cxx    |   18 ++++++++----------
 sfx2/source/control/dispatch.cxx  |   12 +++++-------
 sfx2/source/doc/docfile.cxx       |   13 ++++++-------
 svtools/inc/svtools/parhtml.hxx   |    4 +---
 svtools/source/svhtml/parhtml.cxx |   21 +++++++--------------
 svx/source/items/clipfmtitem.cxx  |   17 +++++++++--------
 8 files changed, 36 insertions(+), 54 deletions(-)

diff --git a/sfx2/inc/sfx2/frmhtml.hxx b/sfx2/inc/sfx2/frmhtml.hxx
index b365ab9..6f88b43 100644
--- a/sfx2/inc/sfx2/frmhtml.hxx
+++ b/sfx2/inc/sfx2/frmhtml.hxx
@@ -38,7 +38,6 @@
 class SfxFrameHTMLParser;
 class _SfxFrameHTMLContexts;
 class SfxFrameSetObjectShell;
-class SvULongs;
 class SfxMedium;
 namespace svtools { class AsynchronLink; }
 
diff --git a/sfx2/source/bastyp/frmhtml.cxx b/sfx2/source/bastyp/frmhtml.cxx
index 75cd28b..12cbe09 100644
--- a/sfx2/source/bastyp/frmhtml.cxx
+++ b/sfx2/source/bastyp/frmhtml.cxx
@@ -33,10 +33,6 @@
 #include <svtools/htmltokn.h>
 #include <svtools/asynclink.hxx>
 
-#define _SVSTDARR_USHORTS
-#define _SVSTDARR_ULONGS
-#include <svl/svstdarr.hxx>
-
 #include <sfx2/sfx.hrc>
 
 #include <sfx2/frmhtml.hxx>
diff --git a/sfx2/source/bastyp/sfxhtml.cxx b/sfx2/source/bastyp/sfxhtml.cxx
index 002e2ce..a887640 100644
--- a/sfx2/source/bastyp/sfxhtml.cxx
+++ b/sfx2/source/bastyp/sfxhtml.cxx
@@ -42,10 +42,6 @@
 #include <svtools/imapobj.hxx>
 #include <svtools/imappoly.hxx>
 #include <svtools/imaprect.hxx>
-#ifndef _SVSTDARR_ULONGS_DECL
-#define _SVSTDARR_ULONGS
-#include <svl/svstdarr.hxx>
-#endif
 #include <svl/zforlist.hxx>
 #include <rtl/tencinfo.h>
 #include <tools/tenccvt.hxx>
@@ -54,6 +50,8 @@
 
 #include <com/sun/star/beans/XPropertyContainer.hpp>
 
+#include <vector>
+
 
 using namespace ::com::sun::star;
 
@@ -128,7 +126,7 @@ bool SfxHTMLParser::ParseAreaOptions(ImageMap * pImageMap, const String& rBaseUR
     DBG_ASSERT( pImageMap, "ParseAreaOptions: no Image-Map" );
 
     sal_uInt16 nShape = IMAP_OBJ_RECTANGLE;
-    SvULongs aCoords;
+    std::vector<sal_uInt32> aCoords;
     String aName, aHRef, aAlt, aTarget, sEmpty;
     sal_Bool bNoHRef = sal_False;
     SvxMacroTableDtor aMacroTbl;
@@ -147,7 +145,7 @@ bool SfxHTMLParser::ParseAreaOptions(ImageMap * pImageMap, const String& rBaseUR
             rOption.GetEnum( nShape, aAreaShapeOptEnums );
             break;
         case HTML_O_COORDS:
-            rOption.GetNumbers( aCoords, sal_True );
+            rOption.GetNumbers( aCoords, true );
             break;
         case HTML_O_HREF:
             aHRef = INetURLObject::GetAbsURL( rBaseURL, rOption.GetString() );
@@ -195,7 +193,7 @@ IMAPOBJ_SETEVENT:
     switch( nShape )
     {
     case IMAP_OBJ_RECTANGLE:
-        if( aCoords.Count() >=4 )
+        if( aCoords.size() >=4 )
         {
             Rectangle aRec( aCoords[0], aCoords[1],
                             aCoords[2], aCoords[3] );
@@ -207,7 +205,7 @@ IMAPOBJ_SETEVENT:
         }
         break;
     case IMAP_OBJ_CIRCLE:
-        if( aCoords.Count() >=3 )
+        if( aCoords.size() >=3 )
         {
             Point aPoint( aCoords[0], aCoords[1] );
             IMapCircleObject aMapCObj( aPoint, aCoords[2],aHRef, aAlt, String(),
@@ -218,9 +216,9 @@ IMAPOBJ_SETEVENT:
         }
         break;
     case IMAP_OBJ_POLYGON:
-        if( aCoords.Count() >=6 )
+        if( aCoords.size() >=6 )
         {
-            sal_uInt16 nCount = aCoords.Count() / 2;
+            sal_uInt16 nCount = aCoords.size() / 2;
             Polygon aPoly( nCount );
             for( sal_uInt16 i=0; i<nCount; i++ )
                 aPoly[i] = Point( aCoords[2*i], aCoords[2*i+1] );
diff --git a/sfx2/source/control/dispatch.cxx b/sfx2/source/control/dispatch.cxx
index 7072c09..5aa16e1 100644
--- a/sfx2/source/control/dispatch.cxx
+++ b/sfx2/source/control/dispatch.cxx
@@ -43,8 +43,6 @@
 #include <stdarg.h>
 #include <stdlib.h>  // due to bsearch
 
-#define _SVSTDARR_ULONGS
-#include <svl/svstdarr.hxx>
 #include <svtools/helpopt.hxx>
 #include <com/sun/star/frame/XLayoutManager.hpp>
 #include <com/sun/star/beans/XPropertySet.hpp>
@@ -152,7 +150,7 @@ struct SfxDispatcher_Impl
     sal_Bool*       pInCallAliveFlag;   // view the Destructor Stack
     SfxObjectBars_Impl   aObjBars[SFX_OBJECTBAR_MAX];
     SfxObjectBars_Impl   aFixedObjBars[SFX_OBJECTBAR_MAX];
-    SvULongs             aChildWins;
+    std::vector<sal_uInt32> aChildWins;
     sal_uInt16           nActionLevel;  // in EnterAction
     sal_uInt32           nEventId;      // EventId UserEvent
     sal_Bool             bUILocked;     // Update disconnected (no flicker)
@@ -831,11 +829,11 @@ void SfxDispatcher::DoDeactivate_Impl( sal_Bool bMDI, SfxViewFrame* pNew )
             SfxWorkWindow *pWorkWin = pImp->pFrame->GetFrame().GetWorkWindow_Impl();
             if ( pWorkWin )
             {
-                for (sal_uInt16 n=0; n<pImp->aChildWins.Count();)
+                for (size_t n=0; n<pImp->aChildWins.size();)
                 {
                     SfxChildWindow *pWin = pWorkWin->GetChildWindow_Impl( (sal_uInt16) ( pImp->aChildWins[n] & 0xFFFF ) );
                     if (!pWin || (pWin && pWin->GetAlignment() == SFX_ALIGN_NOALIGNMENT))
-                        pImp->aChildWins.Remove(n);
+                        pImp->aChildWins.erase(pImp->aChildWins.begin()+n);
                     else
                         n++;
                 }
@@ -1544,7 +1542,7 @@ void SfxDispatcher::_Update_Impl( sal_Bool bUIActive, sal_Bool bIsMDIApp, sal_Bo
 
     for (sal_uInt16 n=0; n<SFX_OBJECTBAR_MAX; n++)
         pImp->aObjBars[n].nResId = 0;
-    pImp->aChildWins.Remove(0, pImp->aChildWins.Count());
+    pImp->aChildWins.clear();
 
     // bQuiet : own shells aren't considered for UI and SlotServer
     // bNoUI: own Shells aren't considered fors UI
@@ -1646,7 +1644,7 @@ void SfxDispatcher::_Update_Impl( sal_Bool bUIActive, sal_Bool bIsMDIApp, sal_Bo
             if ( bUIActive || bIsActive )
                 pWorkWin->SetChildWindowVisible_Impl( nId, sal_True, nMode );
             if ( bUIActive || bIsActive || !pWorkWin->IsFloating( (sal_uInt16) ( nId & 0xFFFF ) ) )
-                pImp->aChildWins.Insert( nId, pImp->aChildWins.Count());
+                pImp->aChildWins.push_back( nId );
         }
 
         if ( bIsMDIApp || bIsIPOwner )
diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx
index ddeadec..8140cc5 100644
--- a/sfx2/source/doc/docfile.cxx
+++ b/sfx2/source/doc/docfile.cxx
@@ -95,7 +95,6 @@
 #include <cppuhelper/weakref.hxx>
 #include <cppuhelper/implbase1.hxx>
 
-#define _SVSTDARR_ULONGS
 #define _SVSTDARR_STRINGSDTOR
 #include <svl/svstdarr.hxx>
 
@@ -3104,21 +3103,21 @@ sal_uInt16 SfxMedium::AddVersion_Impl( util::RevisionTag& rRevision )
     if ( GetStorage().is() )
     {
         // To determine a unique name for the stream
-        SvULongs aLongs;
+        std::vector<sal_uInt32> aLongs;
         sal_Int32 nLength = pImp->aVersions.getLength();
         for ( sal_Int32 m=0; m<nLength; m++ )
         {
-            sal_uInt32 nVer = (sal_uInt32) String( pImp->aVersions[m].Identifier ).Copy(7).ToInt32();
-            sal_uInt16 n;
-            for ( n=0; n<aLongs.Count(); n++ )
+            sal_uInt32 nVer = static_cast<sal_uInt32>(String( pImp->aVersions[m].Identifier ).Copy(7).ToInt32());
+            size_t n;
+            for ( n=0; n<aLongs.size(); ++n )
                 if ( nVer<aLongs[n] )
                     break;
 
-            aLongs.Insert( nVer, n );
+            aLongs.insert( aLongs.begin()+n, nVer );
         }
 
         sal_uInt16 nKey;
-        for ( nKey=0; nKey<aLongs.Count(); nKey++ )
+        for ( nKey=0; nKey<aLongs.size(); ++nKey )
             if ( aLongs[nKey] > ( sal_uIntPtr ) nKey+1 )
                 break;
 
diff --git a/svtools/inc/svtools/parhtml.hxx b/svtools/inc/svtools/parhtml.hxx
index 627e787..ad228f5 100644
--- a/svtools/inc/svtools/parhtml.hxx
+++ b/svtools/inc/svtools/parhtml.hxx
@@ -32,7 +32,6 @@
 #include "svtools/svtdllapi.h"
 #include <tools/solar.h>
 #include <tools/string.hxx>
-#include <svl/svarray.hxx>
 #include <svtools/svparser.hxx>
 
 #include <boost/ptr_container/ptr_vector.hpp>
@@ -45,7 +44,6 @@ namespace com { namespace sun { namespace star {
 
 class Color;
 class SvNumberFormatter;
-class SvULongs;
 class SvKeyValueIterator;
 
 #define HTMLFONTSZ1_DFLT 7
@@ -115,7 +113,7 @@ public:
 
     sal_uInt32 GetNumber() const;                           // ... als Zahl
     sal_Int32 GetSNumber() const;                           // ... als Zahl
-    void GetNumbers( SvULongs &rLongs,                  // ... als Zahlen
+    void GetNumbers( std::vector<sal_uInt32> &rNumbers,                  // ... als Zahlen
                      bool bSpaceDelim=false ) const;
     void GetColor( Color& ) const;                      // ... als Farbe
 
diff --git a/svtools/source/svhtml/parhtml.cxx b/svtools/source/svhtml/parhtml.cxx
index 770f03b..8ec3503 100644
--- a/svtools/source/svhtml/parhtml.cxx
+++ b/svtools/source/svhtml/parhtml.cxx
@@ -36,10 +36,6 @@
 #include <tools/color.hxx>
 #include <rtl/ustrbuf.hxx>
 #include <rtl/strbuf.hxx>
-#ifndef _SVSTDARR_HXX
-#define _SVSTDARR_ULONGS
-#include <svl/svstdarr.hxx>
-#endif
 
 #include <tools/tenccvt.hxx>
 #include <tools/datetime.hxx>
@@ -176,10 +172,9 @@ sal_Int32 HTMLOption::GetSNumber() const
     return aTmp.ToInt32();
 }
 
-void HTMLOption::GetNumbers( SvULongs &rLongs, bool bSpaceDelim ) const
+void HTMLOption::GetNumbers( std::vector<sal_uInt32> &rNumbers, bool bSpaceDelim ) const
 {
-    if( rLongs.Count() )
-        rLongs.Remove( 0, rLongs.Count() );
+    rNumbers.clear();
 
     if( bSpaceDelim )
     {
@@ -198,14 +193,14 @@ void HTMLOption::GetNumbers( SvULongs &rLongs, bool bSpaceDelim ) const
             }
             else if( bInNum )
             {
-                rLongs.Insert( nNum, rLongs.Count() );
+                rNumbers.push_back( nNum );
                 bInNum = false;
                 nNum = 0;
             }
         }
         if( bInNum )
         {
-            rLongs.Insert( nNum, rLongs.Count() );
+            rNumbers.push_back( nNum );
         }
     }
     else
@@ -222,23 +217,21 @@ void HTMLOption::GetNumbers( SvULongs &rLongs, bool bSpaceDelim ) const
                 nPos++;
 
             if( nPos==aValue.Len() )
-                rLongs.Insert( sal_uLong(0), rLongs.Count() );
+                rNumbers.push_back(0);
             else
             {
                 xub_StrLen nEnd = aValue.Search( (sal_Unicode)',', nPos );
                 if( STRING_NOTFOUND==nEnd )
                 {
                     sal_Int32 nTmp = aValue.Copy(nPos).ToInt32();
-                    rLongs.Insert( nTmp >= 0 ? (sal_uInt32)nTmp : 0,
-                                   rLongs.Count() );
+                    rNumbers.push_back( nTmp >= 0 ? (sal_uInt32)nTmp : 0 );
                     nPos = aValue.Len();
                 }
                 else
                 {
                     sal_Int32 nTmp =
                         aValue.Copy(nPos,nEnd-nPos).ToInt32();
-                    rLongs.Insert( nTmp >= 0 ? (sal_uInt32)nTmp : 0,
-                                   rLongs.Count() );
+                    rNumbers.push_back( nTmp >= 0 ? (sal_uInt32)nTmp : 0 );
                     nPos = nEnd+1;
                 }
             }
diff --git a/svx/source/items/clipfmtitem.cxx b/svx/source/items/clipfmtitem.cxx
index 2f5e1fe..a1dcdf0 100644
--- a/svx/source/items/clipfmtitem.cxx
+++ b/svx/source/items/clipfmtitem.cxx
@@ -29,20 +29,21 @@
 // MARKER(update_precomp.py): autogen include statement, do not remove
 #include "precompiled_svx.hxx"
 
-#define _SVSTDARR_ULONGS
 #define _SVSTDARR_STRINGSDTOR
 
 #include <svl/svstdarr.hxx>
 #include <svx/clipfmtitem.hxx>
 #include <com/sun/star/frame/status/ClipboardFormats.hpp>
 
+#include <vector>
+
 struct SvxClipboardFmtItem_Impl
 {
     SvStringsDtor aFmtNms;
-    SvULongs aFmtIds;
+    std::vector<sal_uIntPtr> aFmtIds;
     static String sEmptyStr;
 
-    SvxClipboardFmtItem_Impl() : aFmtNms( 8, 8 ), aFmtIds( 8, 8 ) {}
+    SvxClipboardFmtItem_Impl() : aFmtNms( 8, 8 ) {}
     SvxClipboardFmtItem_Impl( const SvxClipboardFmtItem_Impl& );
 };
 
@@ -53,7 +54,7 @@ TYPEINIT1_FACTORY( SvxClipboardFmtItem, SfxPoolItem , new  SvxClipboardFmtItem(0
 SvxClipboardFmtItem_Impl::SvxClipboardFmtItem_Impl(
                             const SvxClipboardFmtItem_Impl& rCpy )
 {
-    aFmtIds.Insert( &rCpy.aFmtIds, 0 );
+    std::copy(rCpy.aFmtIds.begin(), rCpy.aFmtIds.end(), aFmtIds.begin());
     for( sal_uInt16 n = 0, nEnd = rCpy.aFmtNms.Count(); n < nEnd; ++n )
     {
         String* pStr = rCpy.aFmtNms[ n ];
@@ -104,7 +105,7 @@ bool SvxClipboardFmtItem::PutValue( const ::com::sun::star::uno::Any& rVal, sal_
     {
         sal_uInt16 nCount = sal_uInt16( aClipFormats.Identifiers.getLength() );
 
-        pImpl->aFmtIds.Remove( 0, pImpl->aFmtIds.Count() );
+        pImpl->aFmtIds.clear();
         pImpl->aFmtNms.Remove( 0, pImpl->aFmtNms.Count() );
         for ( sal_uInt16 n=0; n < nCount; n++ )
             AddClipbrdFormat( sal_uIntPtr( aClipFormats.Identifiers[n] ), aClipFormats.Names[n], n );
@@ -149,7 +150,7 @@ void SvxClipboardFmtItem::AddClipbrdFormat( sal_uIntPtr nId, sal_uInt16 nPos )
         nPos = pImpl->aFmtNms.Count();
     String* pStr = 0;
     pImpl->aFmtNms.Insert( pStr, nPos );
-    pImpl->aFmtIds.Insert( nId, nPos );
+    pImpl->aFmtIds.insert( pImpl->aFmtIds.begin()+nPos, nId );
 }
 
 void SvxClipboardFmtItem::AddClipbrdFormat( sal_uIntPtr nId, const String& rName,
@@ -159,12 +160,12 @@ void SvxClipboardFmtItem::AddClipbrdFormat( sal_uIntPtr nId, const String& rName
         nPos = pImpl->aFmtNms.Count();
     String* pStr = new String( rName );
     pImpl->aFmtNms.Insert( pStr, nPos );
-    pImpl->aFmtIds.Insert( nId, nPos );
+    pImpl->aFmtIds.insert( pImpl->aFmtIds.begin()+nPos, nId );
 }
 
 sal_uInt16 SvxClipboardFmtItem::Count() const
 {
-    return pImpl->aFmtIds.Count();
+    return pImpl->aFmtIds.size();
 }
 
 sal_uIntPtr SvxClipboardFmtItem::GetClipbrdFormatId( sal_uInt16 nPos ) const
-- 
1.7.4.1


--=-ufVCrlk/Bet0s11wA9Ap--



More information about the LibreOffice mailing list