diff options
author | Caolán McNamara <caolanm@redhat.com> | 2012-01-02 10:55:27 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2012-01-05 09:18:19 +0000 |
commit | bacfd2dc4cea1a5d87658ed8592116acd931e000 (patch) | |
tree | d22172a33fdd13a440b6882a28c23ea2d639bbad /sfx2 | |
parent | 6281eb0e0792da0194c07da18296e94dd944b8e5 (diff) |
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
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/appl/appopen.cxx | 10 | ||||
-rw-r--r-- | sfx2/source/appl/childwin.cxx | 5 | ||||
-rw-r--r-- | sfx2/source/appl/newhelp.cxx | 8 | ||||
-rw-r--r-- | sfx2/source/bastyp/sfxhtml.cxx | 3 | ||||
-rw-r--r-- | sfx2/source/dialog/filedlghelper.cxx | 2 | ||||
-rw-r--r-- | sfx2/source/dialog/filtergrouping.cxx | 2 | ||||
-rw-r--r-- | sfx2/source/dialog/srchdlg.cxx | 3 | ||||
-rw-r--r-- | sfx2/source/doc/doctemplates.cxx | 7 | ||||
-rw-r--r-- | sfx2/source/doc/new.cxx | 3 |
9 files changed, 24 insertions, 19 deletions
diff --git a/sfx2/source/appl/appopen.cxx b/sfx2/source/appl/appopen.cxx index 54b9b26e526a..ebb97496004c 100644 --- a/sfx2/source/appl/appopen.cxx +++ b/sfx2/source/appl/appopen.cxx @@ -50,15 +50,15 @@ #include <com/sun/star/container/XNameAccess.hpp> #include <com/sun/star/uno/Sequence.h> #include <com/sun/star/ui/dialogs/TemplateDescription.hpp> -#include <comphelper/processfactory.hxx> #include <cppuhelper/implbase1.hxx> #include <rtl/ustring.hxx> - -#include <comphelper/storagehelper.hxx> -#include <comphelper/synchronousdispatch.hxx> #include <comphelper/configurationhelper.hxx> +#include <comphelper/processfactory.hxx> #include <comphelper/sequenceasvector.hxx> +#include <comphelper/storagehelper.hxx> +#include <comphelper/string.hxx> +#include <comphelper/synchronousdispatch.hxx> #include <vcl/wrkwin.hxx> #include <svl/intitem.hxx> @@ -733,7 +733,7 @@ void SfxApplication::OpenDocExec_Impl( SfxRequest& rReq ) else if ( nSID == SID_OPENTEMPLATE ) { aPath = SvtPathOptions().GetTemplatePath(); - sal_Int32 nTokenCount = aPath.GetTokenCount( ';' ); + sal_Int32 nTokenCount = comphelper::string::getTokenCount(aPath, ';'); aPath = aPath.GetToken( sal::static_int_cast< xub_StrLen >( nTokenCount ? ( nTokenCount - 1 ) : 0 ), diff --git a/sfx2/source/appl/childwin.cxx b/sfx2/source/appl/childwin.cxx index 99c5e3a44f59..8a555d557e96 100644 --- a/sfx2/source/appl/childwin.cxx +++ b/sfx2/source/appl/childwin.cxx @@ -33,6 +33,7 @@ #include <com/sun/star/frame/XController.hpp> #include <com/sun/star/frame/XFrame.hpp> #include <com/sun/star/util/XCloseable.hpp> +#include <comphelper/string.hxx> #include <cppuhelper/implbase1.hxx> #include <sfx2/childwin.hxx> @@ -111,7 +112,7 @@ class DisposeListener : public ::cppu::WeakImplHelper1< ::com::sun::star::lang:: sal_Bool GetPosSizeFromString( const String& rStr, Point& rPos, Size& rSize ) { - if ( rStr.GetTokenCount('/') != 4 ) + if ( comphelper::string::getTokenCount(rStr, '/') != 4 ) return sal_False; xub_StrLen nIdx = 0; @@ -134,7 +135,7 @@ sal_Bool GetSplitSizeFromString( const String& rStr, Size& rSize ) { String aStr = rStr.Copy( nIndex+1 ); - sal_Int32 nCount = aStr.GetTokenCount(';'); + sal_Int32 nCount = comphelper::string::getTokenCount(aStr, ';'); if ( nCount != 2 ) return sal_False; diff --git a/sfx2/source/appl/newhelp.cxx b/sfx2/source/appl/newhelp.cxx index e435e123b848..8bcfb94106db 100644 --- a/sfx2/source/appl/newhelp.cxx +++ b/sfx2/source/appl/newhelp.cxx @@ -1005,9 +1005,9 @@ SearchTabPage_Impl::SearchTabPage_Impl( Window* pParent, SfxHelpIndexWindow_Impl bChecked = ( 1 == aUserData.GetToken(1).ToInt32() ) ? sal_True : sal_False; aScopeCB.Check( bChecked ); - for ( sal_uInt16 i = 2; i < aUserData.GetTokenCount(); ++i ) + for ( sal_uInt16 i = 2; i < comphelper::string::getTokenCount(aUserData, ';'); ++i ) { - String aToken = aUserData.GetToken(i); + String aToken = aUserData.GetToken(i, ';'); aSearchED.InsertEntry( INetURLObject::decode( aToken, '%', INetURLObject::DECODE_WITH_CHARSET ) ); } @@ -2967,7 +2967,7 @@ void SfxHelpWindow_Impl::LoadConfig() if ( aUserItem >>= aTemp ) { aUserData = String( aTemp ); - DBG_ASSERT( aUserData.GetTokenCount() == 6, "invalid user data" ); + DBG_ASSERT( comphelper::string::getTokenCount(aUserData, ';') == 6, "invalid user data" ); sal_uInt16 nIdx = 0; nIndexSize = aUserData.GetToken( 0, ';', nIdx ).ToInt32(); nTextSize = aUserData.GetToken( 0, ';', nIdx ).ToInt32(); @@ -3068,7 +3068,7 @@ IMPL_LINK( SfxHelpWindow_Impl, OpenHdl, SfxHelpIndexWindow_Impl* , EMPTYARG ) { String aId; String aAnchor = String('#'); - if ( aEntry.GetTokenCount( '#' ) == 2 ) + if ( comphelper::string::getTokenCount(aEntry, '#') == 2 ) { aId = aEntry.GetToken( 0, '#' ); aAnchor += aEntry.GetToken( 1, '#' ); diff --git a/sfx2/source/bastyp/sfxhtml.cxx b/sfx2/source/bastyp/sfxhtml.cxx index acf69186d2ac..40758e224de9 100644 --- a/sfx2/source/bastyp/sfxhtml.cxx +++ b/sfx2/source/bastyp/sfxhtml.cxx @@ -47,6 +47,7 @@ #include <sfx2/sfxhtml.hxx> #include <com/sun/star/beans/XPropertyContainer.hpp> +#include <comphelper/string.hxx> #include <vector> @@ -357,7 +358,7 @@ double SfxHTMLParser::GetTableDataOptionsValNum( sal_uInt32& nNumForm, rFormatter.GetFormatForLanguageIfBuiltIn( 0, eParseLang ); double fVal; rFormatter.IsNumberFormat( aValStr, nParseForm, fVal ); - if ( aNumStr.GetTokenCount( ';' ) > 2 ) + if ( comphelper::string::getTokenCount(aNumStr, ';') > 2 ) { eNumLang = (LanguageType)aNumStr.GetToken( 1, ';' ).ToInt32(); xub_StrLen nPos = aNumStr.Search( ';' ); diff --git a/sfx2/source/dialog/filedlghelper.cxx b/sfx2/source/dialog/filedlghelper.cxx index 141b389504d3..25a07e3ea4b6 100644 --- a/sfx2/source/dialog/filedlghelper.cxx +++ b/sfx2/source/dialog/filedlghelper.cxx @@ -1984,7 +1984,7 @@ void FileDialogHelper_Impl::saveConfig() aValue = xDlg->getValue( ExtendedFilePickerElementIds::CHECKBOX_SELECTION, 0 ); sal_Bool bSelection = sal_True; aValue >>= bSelection; - if ( aUserData.GetTokenCount(' ') < 3 ) + if ( comphelper::string::getTokenCount(aUserData, ' ') < 3 ) aUserData.Append(' '); aUserData.SetToken( 2, ' ', String::CreateFromInt32( (sal_Int32) bSelection ) ); bWriteConfig = sal_True; diff --git a/sfx2/source/dialog/filtergrouping.cxx b/sfx2/source/dialog/filtergrouping.cxx index 98e5836fd58a..faaca46166ba 100644 --- a/sfx2/source/dialog/filtergrouping.cxx +++ b/sfx2/source/dialog/filtergrouping.cxx @@ -489,7 +489,7 @@ namespace sfx2 DBG_ASSERT( _rWildCard.GetBuffer()[0] != s_cWildcardSeparator, "AppendWildcardToDescriptor::AppendWildcardToDescriptor: wildcard already separated!" ); - aWildCards.reserve( _rWildCard.GetTokenCount( s_cWildcardSeparator ) ); + aWildCards.reserve( comphelper::string::getTokenCount(_rWildCard, s_cWildcardSeparator) ); const sal_Unicode* pTokenLoop = _rWildCard.GetBuffer(); const sal_Unicode* pTokenLoopEnd = pTokenLoop + _rWildCard.Len(); diff --git a/sfx2/source/dialog/srchdlg.cxx b/sfx2/source/dialog/srchdlg.cxx index fe48b4554fad..5ea75dd7f385 100644 --- a/sfx2/source/dialog/srchdlg.cxx +++ b/sfx2/source/dialog/srchdlg.cxx @@ -28,6 +28,7 @@ #include "srchdlg.hxx" +#include <comphelper/string.hxx> #include "sfx2/sfxresid.hxx" #include <sfx2/sfxuno.hxx> @@ -97,7 +98,7 @@ void SearchDialog::LoadConfig() if ( aUserItem >>= aTemp ) { String sUserData( aTemp ); - DBG_ASSERT( sUserData.GetTokenCount() == 5, "invalid config data" ); + DBG_ASSERT( comphelper::string::getTokenCount(sUserData, ';') == 5, "invalid config data" ); xub_StrLen nIdx = 0; String sSearchText = sUserData.GetToken( 0, ';', nIdx ); m_aWholeWordsBox.Check( sUserData.GetToken( 0, ';', nIdx ).ToInt32() == 1 ); diff --git a/sfx2/source/doc/doctemplates.cxx b/sfx2/source/doc/doctemplates.cxx index 5eb55b5640ed..7dd7338dfe66 100644 --- a/sfx2/source/doc/doctemplates.cxx +++ b/sfx2/source/doc/doctemplates.cxx @@ -37,10 +37,11 @@ #include <tools/resary.hxx> #include <vcl/svapp.hxx> #include <vcl/wrkwin.hxx> -#include <comphelper/sequenceashashmap.hxx> #include <unotools/pathoptions.hxx> -#include <comphelper/processfactory.hxx> #include <comphelper/componentcontext.hxx> +#include <comphelper/processfactory.hxx> +#include <comphelper/sequenceashashmap.hxx> +#include <comphelper/string.hxx> #include <com/sun/star/beans/PropertyAttribute.hpp> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/beans/XPropertySetInfo.hpp> @@ -585,7 +586,7 @@ void SfxDocTplService_Impl::getDirList() // TODO/LATER: let use service, register listener INetURLObject aURL; String aDirs = SvtPathOptions().GetTemplatePath(); - sal_uInt16 nCount = aDirs.GetTokenCount( C_DELIM ); + sal_uInt16 nCount = comphelper::string::getTokenCount(aDirs, C_DELIM); maTemplateDirs = Sequence< OUString >( nCount ); diff --git a/sfx2/source/doc/new.cxx b/sfx2/source/doc/new.cxx index d09978c482e4..94e6326ff54b 100644 --- a/sfx2/source/doc/new.cxx +++ b/sfx2/source/doc/new.cxx @@ -26,6 +26,7 @@ * ************************************************************************/ +#include <comphelper/string.hxx> #include <sfx2/new.hxx> #include <vcl/gdimtf.hxx> #include <vcl/msgbox.hxx> @@ -550,7 +551,7 @@ SfxNewFileDialog_Impl::SfxNewFileDialog_Impl( } String &rExtra = pAntiImplP->GetExtraData(); - sal_uInt16 nTokCount = rExtra.GetTokenCount( '|' ); + sal_Int32 nTokCount = comphelper::string::getTokenCount(rExtra, '|'); if( nTokCount > 0 && nFlags ) MORE_BTN(SetState( rExtra.GetToken( 0, '|' ) == 'Y' )); if( nTokCount > 1 && nFlags ) |