From bacfd2dc4cea1a5d87658ed8592116acd931e000 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Mon, 2 Jan 2012 10:55:27 +0000 Subject: add a comphelper::string::getTokenCount suitable for conversion from [Byte]String::GetTokenCount converted low-hanging variants to rtl::O[UString]::getToken loops added unit test --- svx/inc/svx/gallery1.hxx | 4 ++-- svx/inc/svx/simptabl.hxx | 2 +- svx/source/dialog/simptabl.cxx | 16 ++++++++-------- svx/source/form/fmobj.cxx | 11 +++++++---- svx/source/form/fmshimp.cxx | 7 ++++--- svx/source/form/fmsrcimp.cxx | 9 +++++---- svx/source/gallery2/galbrws2.cxx | 4 ++-- svx/source/gallery2/gallery1.cxx | 13 +++++++------ svx/source/gallery2/galmisc.cxx | 5 +++-- svx/source/gallery2/galobj.cxx | 3 ++- svx/source/xml/xmlgrhlp.cxx | 5 +++-- 11 files changed, 44 insertions(+), 35 deletions(-) (limited to 'svx') diff --git a/svx/inc/svx/gallery1.hxx b/svx/inc/svx/gallery1.hxx index de6ebc684a32..aad41fa28341 100644 --- a/svx/inc/svx/gallery1.hxx +++ b/svx/inc/svx/gallery1.hxx @@ -139,7 +139,7 @@ private: sal_uIntPtr nLastFileNumber; sal_Bool bMultiPath; - void ImplLoad( const String& rMultiPath ); + void ImplLoad( const rtl::OUString& rMultiPath ); void ImplLoadSubDirs( const INetURLObject& rBaseURL, sal_Bool& rbIsReadOnly ); void ImplLoadImports(); void ImplWriteImportList(); @@ -151,7 +151,7 @@ private: GalleryTheme* ImplGetCachedTheme( const GalleryThemeEntry* pThemeEntry ); void ImplDeleteCachedTheme( GalleryTheme* pTheme ); - SVX_DLLPUBLIC Gallery( const String& rMultiPath ); + SVX_DLLPUBLIC Gallery( const rtl::OUString& rMultiPath ); SVX_DLLPUBLIC ~Gallery(); public: diff --git a/svx/inc/svx/simptabl.hxx b/svx/inc/svx/simptabl.hxx index 9867707a80ed..c192458be2c8 100644 --- a/svx/inc/svx/simptabl.hxx +++ b/svx/inc/svx/simptabl.hxx @@ -106,7 +106,7 @@ public: void UpdateViewSize(); - void InsertHeaderEntry(const XubString& rText, + void InsertHeaderEntry(const rtl::OUString& rText, sal_uInt16 nCol=HEADERBAR_APPEND, HeaderBarItemBits nBits = HIB_STDSTYLE); diff --git a/svx/source/dialog/simptabl.cxx b/svx/source/dialog/simptabl.cxx index 7acf8cb2eef8..c9fae16aca3a 100644 --- a/svx/source/dialog/simptabl.cxx +++ b/svx/source/dialog/simptabl.cxx @@ -229,23 +229,23 @@ void SvxSimpleTable::Paint( const Rectangle& rRect ) } bPaintFlag=sal_True; } -void SvxSimpleTable::InsertHeaderEntry(const XubString& rText,sal_uInt16 nCol, - HeaderBarItemBits nBits) +void SvxSimpleTable::InsertHeaderEntry(const rtl::OUString& rText, + sal_uInt16 nCol, HeaderBarItemBits nBits) { - xub_StrLen nEnd = rText.Search( sal_Unicode( '\t' ) ); - if( nEnd == STRING_NOTFOUND ) + sal_Int32 nEnd = rText.indexOf( sal_Unicode( '\t' ) ); + if( nEnd == -1 ) { aHeaderBar.InsertItem(nHeaderItemId++, rText, 0, nBits, nCol); } else { - xub_StrLen nCount = rText.GetTokenCount( sal_Unicode( '\t' ) ); - - for( xub_StrLen i=0; i= 0 ); } SetTabs(); } diff --git a/svx/source/form/fmobj.cxx b/svx/source/form/fmobj.cxx index 206deda01fd1..c185be6ec6f2 100644 --- a/svx/source/form/fmobj.cxx +++ b/svx/source/form/fmobj.cxx @@ -432,7 +432,7 @@ FmFormObj& FmFormObj::operator= (const FmFormObj& rObj) //------------------------------------------------------------------ namespace { - String lcl_getFormComponentAccessPath(const Reference< XInterface >& _xElement, Reference< XInterface >& _rTopLevelElement) + rtl::OUString lcl_getFormComponentAccessPath(const Reference< XInterface >& _xElement, Reference< XInterface >& _rTopLevelElement) { Reference< ::com::sun::star::form::XFormComponent> xChild(_xElement, UNO_QUERY); Reference< ::com::sun::star::container::XIndexAccess> xParent; @@ -471,7 +471,7 @@ namespace Reference< XInterface > FmFormObj::ensureModelEnv(const Reference< XInterface > & _rSourceContainer, const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer > _rTopLevelDestContainer) { Reference< XInterface > xTopLevelSouce; - String sAccessPath = lcl_getFormComponentAccessPath(_rSourceContainer, xTopLevelSouce); + rtl::OUString sAccessPath = lcl_getFormComponentAccessPath(_rSourceContainer, xTopLevelSouce); if (!xTopLevelSouce.is()) // somthing went wrong, maybe _rSourceContainer isn't part of a valid forms hierarchy return Reference< XInterface > (); @@ -480,9 +480,11 @@ Reference< XInterface > FmFormObj::ensureModelEnv(const Reference< XInterface > Reference< XIndexContainer > xSourceContainer(xTopLevelSouce, UNO_QUERY); DBG_ASSERT(xSourceContainer.is(), "FmFormObj::ensureModelEnv : the top level source is invalid !"); - for (xub_StrLen i=0; igetCount(), "FmFormObj::ensureModelEnv : invalid access path !"); @@ -604,6 +606,7 @@ Reference< XInterface > FmFormObj::ensureModelEnv(const Reference< XInterface > xSourceContainer = Reference< XIndexContainer > (xSourceForm, UNO_QUERY); DBG_ASSERT(xDestContainer.is() && xSourceContainer.is(), "FmFormObj::ensureModelEnv : invalid container !"); } + while ( nTokIndex >= 0 ); return Reference< XInterface > (xDestContainer, UNO_QUERY); } diff --git a/svx/source/form/fmshimp.cxx b/svx/source/form/fmshimp.cxx index 04751bb2d40d..9c6d3a5767b2 100644 --- a/svx/source/form/fmshimp.cxx +++ b/svx/source/form/fmshimp.cxx @@ -93,6 +93,7 @@ #include #include #include +#include #include #include #include @@ -424,10 +425,10 @@ namespace const Type* pCurrentListeners = pCurrentArray->getConstArray(); for (j=0; jgetLength(); ++j, ++pCurrentListeners) { - UniString aListener = (*pCurrentListeners).getTypeName(); - xub_StrLen nTokens = aListener.GetTokenCount('.'); + rtl::OUString aListener = (*pCurrentListeners).getTypeName(); + sal_Int32 nTokens = comphelper::string::getTokenCount(aListener, '.'); if (nTokens) - aListener = aListener.GetToken(nTokens - 1, '.'); + aListener = comphelper::string::getToken(aListener, nTokens - 1, '.'); if (aListener == pCurrent->ListenerType.getStr()) // the current ScriptEventDescriptor doesn't match the current listeners class diff --git a/svx/source/form/fmsrcimp.cxx b/svx/source/form/fmsrcimp.cxx index b4df4ed97cdb..419f419606d2 100644 --- a/svx/source/form/fmsrcimp.cxx +++ b/svx/source/form/fmsrcimp.cxx @@ -886,11 +886,11 @@ void FmSearchEngine::Init(const ::rtl::OUString& sVisibleFields) ::rtl::OUString sCurrentField; - UniString sVis(sVisibleFields.getStr()); - xub_StrLen nLen = sVis.GetTokenCount(); - for (xub_StrLen i=0; i= 0 ); } catch (const Exception&) { diff --git a/svx/source/gallery2/galbrws2.cxx b/svx/source/gallery2/galbrws2.cxx index d1a554ba9e72..46311b3ea560 100644 --- a/svx/source/gallery2/galbrws2.cxx +++ b/svx/source/gallery2/galbrws2.cxx @@ -27,7 +27,7 @@ ************************************************************************/ - +#include #include #include #include @@ -1123,7 +1123,7 @@ String GalleryBrowser2::GetItemText( const GalleryTheme& rTheme, const SgaObject if( !aTitle.Len() ) { aTitle = aURL.GetMainURL( INetURLObject::DECODE_UNAMBIGUOUS ); - aTitle = aTitle.GetToken( aTitle.GetTokenCount( '/' ) - 1, '/' ); + aTitle = aTitle.GetToken( comphelper::string::getTokenCount(aTitle, '/') - 1, '/' ); } aRet += aTitle; diff --git a/svx/source/gallery2/gallery1.cxx b/svx/source/gallery2/gallery1.cxx index 2170c1f218f1..7a26e0dee8c5 100644 --- a/svx/source/gallery2/gallery1.cxx +++ b/svx/source/gallery2/gallery1.cxx @@ -27,6 +27,7 @@ ************************************************************************/ +#include #include #include #include @@ -178,7 +179,7 @@ public: // - Gallery - // ----------- -Gallery::Gallery( const String& rMultiPath ) +Gallery::Gallery( const rtl::OUString& rMultiPath ) : nReadTextEncoding ( osl_getThreadTextEncoding() ) , nLastFileNumber ( 0 ) , bMultiPath ( sal_False ) @@ -221,9 +222,9 @@ Gallery* Gallery::GetGalleryInstance() // ------------------------------------------------------------------------ -void Gallery::ImplLoad( const String& rMultiPath ) +void Gallery::ImplLoad( const rtl::OUString& rMultiPath ) { - const sal_uInt16 nTokenCount = rMultiPath.GetTokenCount( ';' ); + const sal_Int32 nTokenCount = comphelper::string::getTokenCount(rMultiPath, ';'); sal_Bool bIsReadOnlyDir; bMultiPath = ( nTokenCount > 0 ); @@ -236,11 +237,11 @@ void Gallery::ImplLoad( const String& rMultiPath ) if( bMultiPath ) { - aRelURL = INetURLObject( rMultiPath.GetToken( 0, ';' ) ); + aRelURL = INetURLObject( comphelper::string::getToken(rMultiPath, 0, ';') ); - for( sal_uInt16 i = 0UL; i < nTokenCount; i++ ) + for( sal_Int32 i = 0; i < nTokenCount; ++i ) { - aCurURL = INetURLObject(rMultiPath.GetToken( i, ';' )); + aCurURL = INetURLObject(comphelper::string::getToken(rMultiPath, i, ';')); ImplLoadSubDirs( aCurURL, bIsReadOnlyDir ); diff --git a/svx/source/gallery2/galmisc.cxx b/svx/source/gallery2/galmisc.cxx index 79602e003265..aa4c1ee74629 100644 --- a/svx/source/gallery2/galmisc.cxx +++ b/svx/source/gallery2/galmisc.cxx @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -232,7 +233,7 @@ String GetReducedString( const INetURLObject& rURL, sal_uIntPtr nMaxLen ) { String aReduced( rURL.GetMainURL( INetURLObject::DECODE_UNAMBIGUOUS ) ); - aReduced = aReduced.GetToken( aReduced.GetTokenCount( '/' ) - 1, '/' ); + aReduced = aReduced.GetToken( comphelper::string::getTokenCount(aReduced, '/') - 1, '/' ); if( INET_PROT_PRIV_SOFFICE != rURL.GetProtocol() ) { @@ -261,7 +262,7 @@ String GetSvDrawStreamNameFromURL( const INetURLObject& rSvDrawObjURL ) String aRet; if( rSvDrawObjURL.GetProtocol() == INET_PROT_PRIV_SOFFICE && - String(rSvDrawObjURL.GetMainURL( INetURLObject::NO_DECODE )).GetTokenCount( '/' ) == 3 ) + comphelper::string::getTokenCount(rSvDrawObjURL.GetMainURL( INetURLObject::NO_DECODE ), '/') == 3 ) { aRet = String(rSvDrawObjURL.GetMainURL( INetURLObject::NO_DECODE )).GetToken( 2, '/' ); } diff --git a/svx/source/gallery2/galobj.cxx b/svx/source/gallery2/galobj.cxx index 9bfa16ba489a..f0db928d3824 100644 --- a/svx/source/gallery2/galobj.cxx +++ b/svx/source/gallery2/galobj.cxx @@ -32,6 +32,7 @@ #include #include +#include #include #include @@ -196,7 +197,7 @@ const String SgaObject::GetTitle() const String aReturnValue( aTitle ); if ( !getenv( "GALLERY_SHOW_PRIVATE_TITLE" ) ) { - if ( aReturnValue.GetTokenCount( ':' ) == 3 ) + if ( comphelper::string::getTokenCount(aReturnValue, ':') == 3 ) { String aPrivateInd ( aReturnValue.GetToken( 0, ':' ) ); String aResourceName( aReturnValue.GetToken( 1, ':' ) ); diff --git a/svx/source/xml/xmlgrhlp.cxx b/svx/source/xml/xmlgrhlp.cxx index 3d615199d431..0a3d332fbda6 100644 --- a/svx/source/xml/xmlgrhlp.cxx +++ b/svx/source/xml/xmlgrhlp.cxx @@ -26,6 +26,7 @@ * ************************************************************************/ +#include #include #include #include @@ -431,8 +432,8 @@ sal_Bool SvXMLGraphicHelper::ImplGetStreamNames( const ::rtl::OUString& rURLStr, if( aURLStr.Len() ) { - aURLStr = aURLStr.GetToken( aURLStr.GetTokenCount( ':' ) - 1, ':' ); - const sal_uInt32 nTokenCount = aURLStr.GetTokenCount( '/' ); + aURLStr = aURLStr.GetToken( comphelper::string::getTokenCount(aURLStr, ':') - 1, ':' ); + const sal_uInt32 nTokenCount = comphelper::string::getTokenCount(aURLStr, '/'); if( 1 == nTokenCount ) { -- cgit