diff options
author | Matteo Casalin <matteo.casalin@yahoo.com> | 2013-06-13 22:07:41 +0200 |
---|---|---|
committer | Noel Power <noel.power@suse.com> | 2013-06-18 08:11:58 +0000 |
commit | 8956854d8e7294b41e65d5aacbc43e11d1795711 (patch) | |
tree | d9d87ffd48d048ddc46fbb34181c3c2c50243981 /svl/source | |
parent | 66a0713dc9c676182fcd7aa1e21f8dc25c05be5e (diff) |
String to OUString (SfxStringItem and related)
Change-Id: I390413e9ff3efee720a6423fb8695b4c655d7efa
Reviewed-on: https://gerrit.libreoffice.org/4280
Reviewed-by: Noel Power <noel.power@suse.com>
Tested-by: Noel Power <noel.power@suse.com>
Diffstat (limited to 'svl/source')
-rw-r--r-- | svl/source/items/imageitm.cxx | 2 | ||||
-rw-r--r-- | svl/source/items/slstitm.cxx | 68 |
2 files changed, 33 insertions, 37 deletions
diff --git a/svl/source/items/imageitm.cxx b/svl/source/items/imageitm.cxx index 9a127754ed16..bc96af4ad8c0 100644 --- a/svl/source/items/imageitm.cxx +++ b/svl/source/items/imageitm.cxx @@ -25,7 +25,7 @@ TYPEINIT1( SfxImageItem, SfxInt16Item ); struct SfxImageItem_Impl { - String aURL; + OUString aURL; long nAngle; bool bMirrored; int operator == ( const SfxImageItem_Impl& rOther ) const diff --git a/svl/source/items/slstitm.cxx b/svl/source/items/slstitm.cxx index 88abad2c3c84..1aab6904a87e 100644 --- a/svl/source/items/slstitm.cxx +++ b/svl/source/items/slstitm.cxx @@ -36,7 +36,7 @@ class SfxImpStringList { public: sal_uInt16 nRefCount; - std::vector<String> aList; + std::vector<OUString> aList; SfxImpStringList() { nRefCount = 1; } ~SfxImpStringList(); @@ -59,7 +59,7 @@ SfxStringListItem::SfxStringListItem() : //------------------------------------------------------------------------ -SfxStringListItem::SfxStringListItem( sal_uInt16 which, const std::vector<String>* pList ) : +SfxStringListItem::SfxStringListItem( sal_uInt16 which, const std::vector<OUString>* pList ) : SfxPoolItem( which ), pImp(NULL) { @@ -89,12 +89,9 @@ SfxStringListItem::SfxStringListItem( sal_uInt16 which, SvStream& rStream ) : if (pImp) { - long i; - String aStr; - for( i=0; i < nEntryCount; i++ ) + for( sal_Int32 i=0; i < nEntryCount; i++ ) { - aStr = readByteString(rStream); - pImp->aList.push_back(aStr); + pImp->aList.push_back( readByteString(rStream) ); } } } @@ -128,7 +125,7 @@ SfxStringListItem::~SfxStringListItem() //------------------------------------------------------------------------ -std::vector<String>& SfxStringListItem::GetList() +std::vector<OUString>& SfxStringListItem::GetList() { if( !pImp ) pImp = new SfxImpStringList; @@ -136,7 +133,7 @@ std::vector<String>& SfxStringListItem::GetList() return pImp->aList; } -const std::vector<String>& SfxStringListItem::GetList () const +const std::vector<OUString>& SfxStringListItem::GetList () const { return (const_cast< SfxStringListItem * >(this))->GetList(); } @@ -212,7 +209,7 @@ SvStream& SfxStringListItem::Store( SvStream & rStream, sal_uInt16 ) const //------------------------------------------------------------------------ -void SfxStringListItem::SetString( const XubString& rStr ) +void SfxStringListItem::SetString( const OUString& rStr ) { DBG_ASSERT(GetRefCount()==0,"SetString:RefCount!=0"); @@ -222,48 +219,47 @@ void SfxStringListItem::SetString( const XubString& rStr ) pImp->nRefCount--; pImp = new SfxImpStringList; - xub_StrLen nStart = 0; - xub_StrLen nDelimPos; - XubString aStr(convertLineEnd(rStr, LINEEND_CR)); - do + sal_Int32 nStart = 0; + OUString aStr(convertLineEnd(rStr, LINEEND_CR)); + for (;;) { - nDelimPos = aStr.Search( '\r', nStart ); - xub_StrLen nLen; - if ( nDelimPos == STRING_NOTFOUND ) - nLen = 0xffff; - else - nLen = nDelimPos - nStart; - - // String gehoert der Liste - pImp->aList.push_back(aStr.Copy(nStart, nLen)); + const sal_Int32 nDelimPos = aStr.indexOf( '\r', nStart ); + if ( nDelimPos < 0 ) + { + if (nStart<aStr.getLength()) + { + // put last string only if not empty + pImp->aList.push_back(aStr.copy(nStart)); + } + break; + } - nStart += nLen + 1 ; // delimiter ueberspringen - } while( nDelimPos != STRING_NOTFOUND ); + pImp->aList.push_back(aStr.copy(nStart, nDelimPos-nStart)); - // Kein Leerstring am Ende - if (!pImp->aList.empty() && !(pImp->aList.rbegin())->Len()) - pImp->aList.pop_back(); + // skip both inserted string and delimiter + nStart = nDelimPos + 1 ; + } } //------------------------------------------------------------------------ -XubString SfxStringListItem::GetString() +OUString SfxStringListItem::GetString() { - XubString aStr; + OUString aStr; if ( pImp ) { DBG_ASSERT(pImp->nRefCount!=0xffff,"ImpList not valid"); - std::vector<String>::iterator iter; - for (iter = pImp->aList.begin();;) + std::vector<OUString>::iterator iter = pImp->aList.begin(); + for (;;) { aStr += *iter; ++iter; - if (iter != pImp->aList.end()) - aStr += '\r'; - else + if (iter == pImp->aList.end()) break; + + aStr += "\r"; } } return convertLineEnd(aStr, GetSystemLineEnd()); @@ -285,7 +281,7 @@ void SfxStringListItem::SetStringList( const com::sun::star::uno::Sequence< OUSt { // String gehoert der Liste for ( sal_Int32 n = 0; n < rList.getLength(); n++ ) - pImp->aList.push_back(XubString(rList[n])); + pImp->aList.push_back(rList[n]); } } |