[Libreoffice-commits] .: svl/inc svl/source

Joseph Powers jpowers at kemper.freedesktop.org
Wed May 18 19:16:30 PDT 2011


 svl/inc/svl/ownlist.hxx     |   27 ++++++++---
 svl/source/misc/ownlist.cxx |  106 +++++++-------------------------------------
 2 files changed, 38 insertions(+), 95 deletions(-)

New commits:
commit c8049b932151199e43b2355227530bd2a61706c7
Author: Joseph Powers <jpowers27 at cox.net>
Date:   Wed May 18 18:57:38 2011 -0700

    Convert SvCommandList from an OwnList to a vector<>

diff --git a/svl/inc/svl/ownlist.hxx b/svl/inc/svl/ownlist.hxx
index cfb13b6..0d228ce 100644
--- a/svl/inc/svl/ownlist.hxx
+++ b/svl/inc/svl/ownlist.hxx
@@ -2,7 +2,7 @@
 /*************************************************************************
  *
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- * 
+ *
  * Copyright 2000, 2010 Oracle and/or its affiliates.
  *
  * OpenOffice.org - a multi-platform office productivity suite
@@ -31,8 +31,8 @@
 
 #include "svl/svldllapi.h"
 #include <tools/stream.hxx>
-#include <tools/ownlist.hxx>
 #include <com/sun/star/uno/Sequence.hxx>
+#include <vector>
 
 namespace com { namespace sun { namespace star {
     namespace beans {
@@ -76,6 +76,8 @@ public:
                     }
 };
 
+typedef ::std::vector< SvCommand > SvCommandList_impl;
+
 //=========================================================================
 class SVL_DLLPUBLIC SvCommandList
 /*	[Beschreibung]
@@ -85,16 +87,29 @@ class SVL_DLLPUBLIC SvCommandList
     in die Liste gestellt.
 */
 {
-                    PRV_SV_DECL_OWNER_LIST(SvCommandList,SvCommand);
-    SvCommand &		Append( const String & rCommand, const String & rArg );
-    sal_Bool			AppendCommands( const String & rCmd, sal_uInt16 * pEaten );
-    String  		GetCommands() const;
+private:
+    SvCommandList_impl  aCommandList;
+
+public:
+    SvCommand&      Append( const String & rCommand, const String & rArg );
+    sal_Bool        AppendCommands( const String & rCmd, sal_uInt16 * pEaten );
+    String          GetCommands() const;
 
     sal_Bool FillFromSequence( const com::sun::star::uno::Sequence < com::sun::star::beans::PropertyValue >& );
     void FillSequence( com::sun::star::uno::Sequence < com::sun::star::beans::PropertyValue >& );
 
     SVL_DLLPUBLIC friend SvStream& operator >> ( SvStream& rStm, SvCommandList & );
     SVL_DLLPUBLIC friend SvStream& operator << ( SvStream&, const SvCommandList & );
+
+    size_t          size() const { return aCommandList.size(); }
+
+    SvCommand       operator[]( size_t i) {
+                        return aCommandList[ i ];
+                    }
+
+    void            clear() {
+                        aCommandList.clear();
+                    }
 };
 
 #endif // _OWNLIST_HXX
diff --git a/svl/source/misc/ownlist.cxx b/svl/source/misc/ownlist.cxx
index ee0d18e..65f6e47 100644
--- a/svl/source/misc/ownlist.cxx
+++ b/svl/source/misc/ownlist.cxx
@@ -2,7 +2,7 @@
 /*************************************************************************
  *
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- * 
+ *
  * Copyright 2000, 2010 Oracle and/or its affiliates.
  *
  * OpenOffice.org - a multi-platform office productivity suite
@@ -39,8 +39,6 @@ using namespace com::sun::star;
 //=========================================================================
 //============== SvCommandList ============================================
 //=========================================================================
-PRV_SV_IMPL_OWNER_LIST(SvCommandList,SvCommand)
-
 
 static String parseString(const String & rCmd, sal_uInt16 * pIndex)
 {
@@ -110,78 +108,11 @@ sal_Bool SvCommandList::AppendCommands
             value = (rCmd.GetChar(index) == '\"') ? parseString(rCmd, &index) : parseWord(rCmd, &index);
         }
 
-        SvCommand * pCmd = new SvCommand(name, value);
-        aTypes.Insert(pCmd, LIST_APPEND);
+        aCommandList.push_back( SvCommand(name, value));
     }
 
     *pEaten = index;
 
-//  	sal_uInt16 nPos = 0;
-//  	while( nPos < rCmd.Len() )
-//  	{
-//  		// ein Zeichen ? Dann faengt hier eine Option an
-//    		if( isalpha( rCmd[nPos] ) )
-//  		{
-//  			String aValue;
-//  			sal_uInt16 nStt = nPos;
-//  			register char c;
-
-//  			while( nPos < rCmd.Len() &&
-//  					( isalnum(c=rCmd[nPos]) || '-'==c || '.'==c ) )
-//  				nPos++;
-
-//  			String aToken( rCmd.Copy( nStt, nPos-nStt ) );
-
-//  			while( nPos < rCmd.Len() &&
-//  					( !String::IsPrintable( (c=rCmd[nPos]),
-//  					RTL_TEXTENCODING_MS_1252 ) || isspace(c) ) )
-//  				nPos++;
-
-//  			// hat die Option auch einen Wert?
-//  			if( nPos!=rCmd.Len() && '='==c )
-//  			{
-//  				nPos++;
-
-//  				while( nPos < rCmd.Len() &&
-//  					 	( !String::IsPrintable( (c=rCmd[nPos]),
-//  						RTL_TEXTENCODING_MS_1252 ) || isspace(c) ) )
-//  					nPos++;
-
-//  				if( nPos != rCmd.Len() )
-//  				{
-//  					sal_uInt16 nLen = 0;
-//  					nStt = nPos;
-//  					if( '"' == c )
-//  					{
-//  						nPos++; nStt++;
-//  						while( nPos < rCmd.Len() &&
-//  					    	 	'"' != rCmd[nPos] )
-//  							nPos++, nLen++;
-//  						if( nPos!=rCmd.Len() )
-//  							nPos++;
-//  					}
-//  					else
-//  						// hier sind wir etwas laxer als der
-//  						// Standard und erlauben alles druckbare
-//  						while( nPos < rCmd.Len() &&
-//  		 				    	String::IsPrintable( (c=rCmd[nPos]),
-//  								RTL_TEXTENCODING_MS_1252 ) &&
-//  								!isspace( c ) )
-//  							nPos++, nLen++;
-
-//  					if( nLen )
-//  						aValue = rCmd( nStt, nLen );
-//  				}
-//  			}
-
-//  			SvCommand * pCmd = new SvCommand( aToken, aValue );
-//  		    aTypes.Insert( pCmd, LIST_APPEND );
-//  		}
-//  		else
-//  			// white space un unerwartete Zeichen ignorieren wie
-//  			nPos++;
-//  	}
-//  	*pEaten = nPos;
     return sal_True;
 }
 
@@ -199,16 +130,16 @@ String SvCommandList::GetCommands() const
 */
 {
     String aRet;
-    for( sal_uLong i = 0; i < aTypes.Count(); i++ )
+    for( sal_uLong i = 0; i < aCommandList.size(); i++ )
     {
         if( i != 0 )
             aRet += ' ';
-        SvCommand * pCmd = (SvCommand *)aTypes.GetObject( i );
-        aRet += pCmd->GetCommand();
-        if( pCmd->GetArgument().Len() )
+        SvCommand aCmd = aCommandList[ i ];
+        aRet += aCmd.GetCommand();
+        if( aCmd.GetArgument().Len() )
         {
             aRet.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "=\"" ) );
-            aRet += pCmd->GetArgument();
+            aRet += aCmd.GetArgument();
             aRet.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "\"" ) );
         }
     }
@@ -231,9 +162,8 @@ SvCommand & SvCommandList::Append
     SvCommand &		Das erteugte Objekt wird zur"uckgegeben.
 */
 {
-    SvCommand * pCmd = new SvCommand( rCommand, rArg );
-    aTypes.Insert( pCmd, LIST_APPEND );
-    return *pCmd;
+    aCommandList.push_back( SvCommand( rCommand, rArg ) );
+    return aCommandList.back();
 }
 
 //=========================================================================
@@ -259,9 +189,9 @@ SvStream & operator >>
     {
         while( nCount-- )
         {
-            SvCommand * pCmd = new SvCommand();
-            rStm >> *pCmd;
-            rThis.aTypes.Insert( pCmd, LIST_APPEND );
+            SvCommand aCmd;
+            rStm >> aCmd;
+            rThis.aCommandList.push_back( aCmd );
         }
     }
     return rStm;
@@ -284,13 +214,12 @@ SvStream & operator <<
     SvStream &		Der "ubergebene Stream.
 */
 {
-    sal_uInt32 nCount = rThis.aTypes.Count();
+    sal_uInt32 nCount = rThis.aCommandList.size();
     rStm << nCount;
 
     for( sal_uInt32 i = 0; i < nCount; i++ )
     {
-        SvCommand * pCmd = (SvCommand *)rThis.aTypes.GetObject( i );
-        rStm << *pCmd;
+        rStm << rThis.aCommandList[ i ];
     }
     return rStm;
 }
@@ -314,14 +243,13 @@ sal_Bool SvCommandList::FillFromSequence( const com::sun::star::uno::Sequence <
 
 void SvCommandList::FillSequence( com::sun::star::uno::Sequence < com::sun::star::beans::PropertyValue >& aCommandSequence )
 {
-    const sal_Int32 nCount = Count();
+    const sal_Int32 nCount = aCommandList.size();
     aCommandSequence.realloc( nCount );
     for( sal_Int32 nIndex = 0; nIndex < nCount; nIndex++ )
     {
-        const SvCommand& rCommand = (*this)[ nIndex ];
-        aCommandSequence[nIndex].Name = rCommand.GetCommand();
+        aCommandSequence[nIndex].Name = aCommandList[ nIndex ].GetCommand();
         aCommandSequence[nIndex].Handle = -1;
-        aCommandSequence[nIndex].Value = uno::makeAny( ::rtl::OUString( rCommand.GetArgument() ) );
+        aCommandSequence[nIndex].Value = uno::makeAny( ::rtl::OUString( aCommandList[ nIndex ].GetArgument() ) );
         aCommandSequence[nIndex].State = beans::PropertyState_DIRECT_VALUE;
     }
 }


More information about the Libreoffice-commits mailing list