summaryrefslogtreecommitdiff
path: root/svl
diff options
context:
space:
mode:
authorJoseph Powers <jpowers27@cox.net>2011-05-18 18:57:38 -0700
committerJoseph Powers <jpowers27@cox.net>2011-05-18 19:13:49 -0700
commit1143cf30551e8ce14065a51e1001a92395404348 (patch)
tree777edcd35b513e04da348e281f364f5c424507c5 /svl
parent67410a9bab69c9b1a9ae968eb2307abb4817d93f (diff)
Convert SvCommandList from an OwnList to a vector<>
Diffstat (limited to 'svl')
-rw-r--r--svl/inc/svl/ownlist.hxx23
-rw-r--r--svl/source/misc/ownlist.cxx104
2 files changed, 35 insertions, 92 deletions
diff --git a/svl/inc/svl/ownlist.hxx b/svl/inc/svl/ownlist.hxx
index 9dc31764c53c..6bb9f311119b 100644
--- a/svl/inc/svl/ownlist.hxx
+++ b/svl/inc/svl/ownlist.hxx
@@ -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,9 +87,12 @@ 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 );
+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 >& );
@@ -95,6 +100,16 @@ class SVL_DLLPUBLIC SvCommandList
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 c1edd6761839..0e3fae02ff8e 100644
--- a/svl/source/misc/ownlist.cxx
+++ b/svl/source/misc/ownlist.cxx
@@ -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;
}
}