diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2023-07-17 19:29:22 +0200 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2023-07-17 20:27:07 +0200 |
commit | 5c97c320338da4bb33ea3cf2479079923d8723e3 (patch) | |
tree | a48e42e13ddffb9036e400bc484744eec36e4207 /svl | |
parent | 77a2fe5a649d089d7c09c5558c42c2ea38116fd7 (diff) |
Simplify a bit
Change-Id: I20e7c1082687d780eded364f2620dd0dcbe831ac
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154532
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'svl')
-rw-r--r-- | svl/source/items/slstitm.cxx | 40 |
1 files changed, 9 insertions, 31 deletions
diff --git a/svl/source/items/slstitm.cxx b/svl/source/items/slstitm.cxx index bf0e37684ba7..02784446ca52 100644 --- a/svl/source/items/slstitm.cxx +++ b/svl/source/items/slstitm.cxx @@ -41,8 +41,7 @@ SfxStringListItem::SfxStringListItem( sal_uInt16 which, const std::vector<OUStri // Therefore the query after the count is commented out if( pList /*!!! && pList->Count() */ ) { - mpList = std::make_shared<std::vector<OUString>>(); - *mpList = *pList; + mpList = std::make_shared<std::vector<OUString>>(*pList); } } @@ -97,26 +96,10 @@ void SfxStringListItem::SetString( const OUString& rStr ) { mpList = std::make_shared<std::vector<OUString>>(); - sal_Int32 nStart = 0; OUString aStr(convertLineEnd(rStr, LINEEND_CR)); - for (;;) - { - const sal_Int32 nDelimPos = aStr.indexOf( '\r', nStart ); - if ( nDelimPos < 0 ) - { - if (nStart<aStr.getLength()) - { - // put last string only if not empty - mpList->push_back(aStr.copy(nStart)); - } - break; - } - - mpList->push_back(aStr.copy(nStart, nDelimPos-nStart)); - - // skip both inserted string and delimiter - nStart = nDelimPos + 1 ; - } + // put last string only if not empty + for (sal_Int32 nStart = 0; nStart >= 0 && nStart < aStr.getLength();) + mpList->push_back(aStr.getToken(0, '\r', nStart)); } @@ -133,19 +116,17 @@ OUString SfxStringListItem::GetString() if (iter == end) break; - aStr.append("\r"); + aStr.append(SAL_NEWLINE_STRING); } } - return convertLineEnd(aStr.makeStringAndClear(), GetSystemLineEnd()); + return aStr.makeStringAndClear(); } void SfxStringListItem::SetStringList( const css::uno::Sequence< OUString >& rList ) { - mpList = std::make_shared<std::vector<OUString>>(); - - // String belongs to the list - comphelper::sequenceToContainer(*mpList, rList); + mpList = std::make_shared<std::vector<OUString>>( + comphelper::sequenceToContainer<std::vector<OUString>>(rList)); } void SfxStringListItem::GetStringList( css::uno::Sequence< OUString >& rList ) const @@ -175,11 +156,8 @@ bool SfxStringListItem::PutValue( const css::uno::Any& rVal, sal_uInt8 ) // virtual bool SfxStringListItem::QueryValue( css::uno::Any& rVal, sal_uInt8 ) const { - // GetString() is not const!!! - SfxStringListItem* pThis = const_cast< SfxStringListItem * >( this ); - css::uno::Sequence< OUString > aStringList; - pThis->GetStringList( aStringList ); + GetStringList( aStringList ); rVal <<= aStringList; return true; } |