summaryrefslogtreecommitdiff
path: root/cui
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2012-01-02 10:55:27 +0000
committerCaolán McNamara <caolanm@redhat.com>2012-01-05 09:18:19 +0000
commitbacfd2dc4cea1a5d87658ed8592116acd931e000 (patch)
treed22172a33fdd13a440b6882a28c23ea2d639bbad /cui
parent6281eb0e0792da0194c07da18296e94dd944b8e5 (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 'cui')
-rw-r--r--cui/source/customize/cfgutil.cxx7
-rw-r--r--cui/source/dialogs/cuicharmap.cxx8
-rw-r--r--cui/source/dialogs/cuifmsearch.cxx21
-rw-r--r--cui/source/dialogs/multipat.cxx3
-rw-r--r--cui/source/dialogs/plfilter.cxx3
-rw-r--r--cui/source/options/optjava.cxx3
-rw-r--r--cui/source/options/optpath.cxx15
-rw-r--r--cui/source/tabpages/labdlg.cxx6
-rw-r--r--cui/source/tabpages/macroass.cxx3
9 files changed, 40 insertions, 29 deletions
diff --git a/cui/source/customize/cfgutil.cxx b/cui/source/customize/cfgutil.cxx
index 123088b82a2e..0c45efb1941a 100644
--- a/cui/source/customize/cfgutil.cxx
+++ b/cui/source/customize/cfgutil.cxx
@@ -58,11 +58,12 @@
#include "cuires.hrc"
#include <sfx2/app.hxx>
#include <sfx2/minfitem.hxx>
-#include <comphelper/processfactory.hxx>
#include <comphelper/documentinfo.hxx>
+#include <comphelper/processfactory.hxx>
+#include <comphelper/sequenceashashmap.hxx>
+#include <comphelper/string.hxx>
#include <svtools/imagemgr.hxx>
#include <rtl/ustrbuf.hxx>
-#include <comphelper/sequenceashashmap.hxx>
#include <unotools/configmgr.hxx>
#include "dialmgr.hxx"
#include <svl/stritem.hxx>
@@ -1204,7 +1205,7 @@ void SfxConfigGroupListBox_Impl::SelectMacro( const String& rBasic,
aBasicName += ' ';
aBasicName += pImp->m_sMacros;
String aLib, aModule, aMethod;
- sal_uInt16 nCount = rMacro.GetTokenCount('.');
+ sal_uInt16 nCount = comphelper::string::getTokenCount(rMacro, '.');
aMethod = rMacro.GetToken( nCount-1, '.' );
if ( nCount > 2 )
{
diff --git a/cui/source/dialogs/cuicharmap.cxx b/cui/source/dialogs/cuicharmap.cxx
index 777851cce643..21b3836807e2 100644
--- a/cui/source/dialogs/cuicharmap.cxx
+++ b/cui/source/dialogs/cuicharmap.cxx
@@ -292,7 +292,7 @@ SvxCharMapData::SvxCharMapData( SfxModalDialog* pDialog, sal_Bool bOne_, ResMgr*
aDeleteBtn.Hide();
}
- String aDefStr( aFont.GetName() );
+ rtl::OUString aDefStr( aFont.GetName() );
String aLastName;
int nCount = mpDialog->GetDevFontCount();
for ( int i = 0; i < nCount; i++ )
@@ -311,9 +311,10 @@ SvxCharMapData::SvxCharMapData( SfxModalDialog* pDialog, sal_Bool bOne_, ResMgr*
bool bFound = (aFontLB.GetEntryPos( aDefStr ) == LISTBOX_ENTRY_NOTFOUND );
if( !bFound )
{
- for ( xub_StrLen i = 0; i < aDefStr.GetTokenCount(); ++i )
+ sal_Int32 nIndex = 0;
+ do
{
- String aToken = aDefStr.GetToken(i);
+ rtl::OUString aToken = aDefStr.getToken(0, ';', nIndex);
if ( aFontLB.GetEntryPos( aToken ) != LISTBOX_ENTRY_NOTFOUND )
{
aDefStr = aToken;
@@ -321,6 +322,7 @@ SvxCharMapData::SvxCharMapData( SfxModalDialog* pDialog, sal_Bool bOne_, ResMgr*
break;
}
}
+ while ( nIndex >= 0 );
}
if ( bFound )
diff --git a/cui/source/dialogs/cuifmsearch.cxx b/cui/source/dialogs/cuifmsearch.cxx
index b4556cccdf3e..ac5fd9e824c3 100644
--- a/cui/source/dialogs/cuifmsearch.cxx
+++ b/cui/source/dialogs/cuifmsearch.cxx
@@ -44,6 +44,7 @@
#include <svl/cjkoptions.hxx>
#include <com/sun/star/i18n/TransliterationModules.hpp>
#include <comphelper/processfactory.hxx>
+#include <comphelper/string.hxx>
#include <svx/svxdlg.hxx>
#include <sal/macros.h>
@@ -139,7 +140,7 @@ FmSearchDialog::FmSearchDialog(Window* pParent, const UniString& sInitialText, c
fmscInitial.nContext = nInitialContext;
m_lnkContextSupplier.Call(&fmscInitial);
DBG_ASSERT(fmscInitial.xCursor.is(), "FmSearchDialog::FmSearchDialog : invalid data supplied by ContextSupplier !");
- DBG_ASSERT(fmscInitial.strUsedFields.GetTokenCount(';') == (xub_StrLen)fmscInitial.arrFields.size(),
+ DBG_ASSERT(comphelper::string::getTokenCount(fmscInitial.strUsedFields, ';') == (xub_StrLen)fmscInitial.arrFields.size(),
"FmSearchDialog::FmSearchDialog : invalid data supplied by ContextSupplied !");
#if (OSL_DEBUG_LEVEL > 1) || defined DBG_UTIL
for (sal_Int32 i=0; i<(sal_Int32)fmscInitial.arrFields.size(); ++i)
@@ -189,7 +190,7 @@ FmSearchDialog::FmSearchDialog(Window* pParent, const UniString& sInitialText, c
if (fmscInitial.sFieldDisplayNames.Len() != 0)
{ // use the display names if supplied
- DBG_ASSERT(fmscInitial.sFieldDisplayNames.GetTokenCount() == fmscInitial.strUsedFields.GetTokenCount(),
+ DBG_ASSERT(comphelper::string::getTokenCount(fmscInitial.sFieldDisplayNames, ';') == comphelper::string::getTokenCount(fmscInitial.strUsedFields, ';'),
"FmSearchDialog::FmSearchDialog : invalid initial context description !");
Init(fmscInitial.sFieldDisplayNames, sInitialText);
}
@@ -278,8 +279,8 @@ void FmSearchDialog::Init(const UniString& strVisibleFields, const UniString& sI
m_lbPosition.SelectEntryPos(MATCHING_ANYWHERE);
// the field listbox
- for (sal_uInt16 i=0; i<strVisibleFields.GetTokenCount(';'); ++i)
- m_lbField.InsertEntry(strVisibleFields.GetToken(i, ';'));
+ for (sal_Int32 i=0; i < comphelper::string::getTokenCount(strVisibleFields, ';'); ++i)
+ m_lbField.InsertEntry(comphelper::string::getToken(strVisibleFields, i, ';'));
m_pConfig = new FmSearchConfigItem;
@@ -575,15 +576,17 @@ void FmSearchDialog::InitContext(sal_Int16 nContext)
if (fmscContext.sFieldDisplayNames.Len() != 0)
{
// use the display names if supplied
- DBG_ASSERT(fmscContext.sFieldDisplayNames.GetTokenCount() == fmscContext.strUsedFields.GetTokenCount(),
+ DBG_ASSERT(comphelper::string::getTokenCount(fmscContext.sFieldDisplayNames, ';') == comphelper::string::getTokenCount(fmscContext.strUsedFields, ';'),
"FmSearchDialog::InitContext : invalid context description supplied !");
- for (xub_StrLen i=0; i<fmscContext.sFieldDisplayNames.GetTokenCount(); ++i)
- m_lbField.InsertEntry(fmscContext.sFieldDisplayNames.GetToken(i));
+ for (sal_Int32 i=0; i < comphelper::string::getTokenCount(fmscContext.sFieldDisplayNames, ';'); ++i)
+ m_lbField.InsertEntry(comphelper::string::getToken(fmscContext.sFieldDisplayNames, i, ';'));
}
else
+ {
// else use the field names
- for (xub_StrLen i=0; i<fmscContext.strUsedFields.GetTokenCount(); ++i)
- m_lbField.InsertEntry(fmscContext.strUsedFields.GetToken(i));
+ for (sal_Int32 i=0; i < comphelper::string::getTokenCount(fmscContext.strUsedFields, ';'); ++i)
+ m_lbField.InsertEntry(comphelper::string::getToken(fmscContext.strUsedFields, i, ';'));
+ }
if (nContext < (sal_Int32)m_arrContextFields.size() && m_arrContextFields[nContext].Len())
{
diff --git a/cui/source/dialogs/multipat.cxx b/cui/source/dialogs/multipat.cxx
index 08d8bc7d77e0..2a02a180314b 100644
--- a/cui/source/dialogs/multipat.cxx
+++ b/cui/source/dialogs/multipat.cxx
@@ -38,6 +38,7 @@
#include "multipat.hrc"
#include <cuires.hrc>
#include <comphelper/processfactory.hxx>
+#include <comphelper/string.hxx>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/ui/dialogs/XFolderPicker.hpp>
#include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
@@ -283,7 +284,7 @@ String SvxMultiPathDialog::GetPath() const
void SvxMultiPathDialog::SetPath( const String& rPath )
{
sal_Unicode cDelim = pImpl->bIsClassPathMode ? CLASSPATH_DELIMITER : SVT_SEARCHPATH_DELIMITER;
- sal_uInt16 nPos, nCount = rPath.GetTokenCount( cDelim );
+ sal_uInt16 nPos, nCount = comphelper::string::getTokenCount(rPath, cDelim);
for ( sal_uInt16 i = 0; i < nCount; ++i )
{
diff --git a/cui/source/dialogs/plfilter.cxx b/cui/source/dialogs/plfilter.cxx
index f1bd7f744377..bc4c4804a4c3 100644
--- a/cui/source/dialogs/plfilter.cxx
+++ b/cui/source/dialogs/plfilter.cxx
@@ -29,6 +29,7 @@
#include <set>
#include <map>
#include <comphelper/processfactory.hxx>
+#include <comphelper/string.hxx>
#include <tools/debug.hxx>
#include <vcl/stdtext.hxx>
@@ -76,7 +77,7 @@ void fillNetscapePluginFilters( Sequence< rtl::OUString >& rPluginNames, Sequenc
StrSet& rTypes = aMap[ rDescr.Description ];
String aExtension( rDescr.Extension );
- for ( sal_uInt16 nCnt = aExtension.GetTokenCount( ';' ); nCnt--; )
+ for ( sal_uInt16 nCnt = comphelper::string::getTokenCount(aExtension, ';'); nCnt--; )
{
// no default plugins anymore
String aExt( aExtension.GetToken( nCnt, ';' ) );
diff --git a/cui/source/options/optjava.cxx b/cui/source/options/optjava.cxx
index 733d9eea6310..a32869e42652 100644
--- a/cui/source/options/optjava.cxx
+++ b/cui/source/options/optjava.cxx
@@ -43,6 +43,7 @@
#include <svtools/imagemgr.hxx>
#include <sfx2/filedlghelper.hxx>
#include <comphelper/processfactory.hxx>
+#include <comphelper/string.hxx>
#include <ucbhelper/contentbroker.hxx>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
@@ -1061,7 +1062,7 @@ void SvxJavaClassPathDlg::SetClassPath( const String& _rPath )
m_sOldPath = _rPath;
m_aPathList.Clear();
xub_StrLen i, nIdx = 0;
- xub_StrLen nCount = _rPath.GetTokenCount( CLASSPATH_DELIMITER );
+ xub_StrLen nCount = comphelper::string::getTokenCount(_rPath, CLASSPATH_DELIMITER);
for ( i = 0; i < nCount; ++i )
{
String sToken = _rPath.GetToken( 0, CLASSPATH_DELIMITER, nIdx );
diff --git a/cui/source/options/optpath.cxx b/cui/source/options/optpath.cxx
index c6b87d000bcd..58a37b106a8b 100644
--- a/cui/source/options/optpath.cxx
+++ b/cui/source/options/optpath.cxx
@@ -51,8 +51,9 @@
#include "optpath.hrc"
#include <cuires.hrc>
#include "helpid.hrc"
-#include <comphelper/processfactory.hxx>
#include <comphelper/configurationhelper.hxx>
+#include <comphelper/processfactory.hxx>
+#include <comphelper/string.hxx>
#include <com/sun/star/uno/Exception.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/beans/PropertyAttribute.hpp>
@@ -158,7 +159,7 @@ static String getCfgName_Impl( sal_uInt16 _nHandle )
String Convert_Impl( const String& rValue )
{
char cDelim = MULTIPATH_DELIMITER;
- sal_uInt16 nCount = rValue.GetTokenCount( cDelim );
+ sal_uInt16 nCount = comphelper::string::getTokenCount(rValue, cDelim);
String aReturn;
for ( sal_uInt16 i=0; i<nCount ; ++i )
{
@@ -437,8 +438,8 @@ IMPL_LINK( SvxPathTabPage, StandardHdl_Impl, PushButton *, EMPTYARG )
GetPathList( pPathImpl->nRealId, sInternal, sUser, sWritable, bReadOnly );
sal_uInt16 i;
- sal_uInt16 nOldCount = aOldPath.GetTokenCount( MULTIPATH_DELIMITER );
- sal_uInt16 nIntCount = sInternal.GetTokenCount( MULTIPATH_DELIMITER );
+ sal_uInt16 nOldCount = comphelper::string::getTokenCount(aOldPath, MULTIPATH_DELIMITER);
+ sal_uInt16 nIntCount = comphelper::string::getTokenCount(sInternal, MULTIPATH_DELIMITER);
for ( i = 0; i < nOldCount; ++i )
{
bool bFound = false;
@@ -457,7 +458,7 @@ IMPL_LINK( SvxPathTabPage, StandardHdl_Impl, PushButton *, EMPTYARG )
}
String sUserPath, sWritablePath;
- nOldCount = sTemp.GetTokenCount( MULTIPATH_DELIMITER );
+ nOldCount = comphelper::string::getTokenCount(sTemp, MULTIPATH_DELIMITER);
for ( i = 0; nOldCount > 0 && i < nOldCount - 1; ++i )
{
if ( sUserPath.Len() > 0 )
@@ -590,7 +591,7 @@ IMPL_LINK( SvxPathTabPage, PathHdl_Impl, PushButton *, EMPTYARG )
String sFullPath;
String sNewPath = pMultiDlg->GetPath();
char cDelim = MULTIPATH_DELIMITER;
- sal_uInt16 nCount = sNewPath.GetTokenCount( cDelim );
+ sal_uInt16 nCount = comphelper::string::getTokenCount(sNewPath, cDelim);
if ( nCount > 0 )
{
sal_uInt16 i = 0;
@@ -824,7 +825,7 @@ void SvxPathTabPage::SetPathList(
{
// save user paths
char cDelim = MULTIPATH_DELIMITER;
- sal_uInt16 nCount = _rUserPath.GetTokenCount( cDelim );
+ sal_uInt16 nCount = comphelper::string::getTokenCount(_rUserPath, cDelim);
Sequence< ::rtl::OUString > aPathSeq( nCount );
::rtl::OUString* pArray = aPathSeq.getArray();
for ( sal_uInt16 i = 0; i < nCount; ++i )
diff --git a/cui/source/tabpages/labdlg.cxx b/cui/source/tabpages/labdlg.cxx
index 7177dcfb716d..b56d494fdcd8 100644
--- a/cui/source/tabpages/labdlg.cxx
+++ b/cui/source/tabpages/labdlg.cxx
@@ -26,7 +26,7 @@
*
************************************************************************/
-// include ---------------------------------------------------------------
+#include <comphelper/string.hxx>
#include <tools/shl.hxx>
#include <sfx2/app.hxx>
#include <sfx2/module.hxx>
@@ -424,7 +424,7 @@ void SvxCaptionTabPage::SetupAnsatz_Impl( sal_uInt16 nType )
case AZ_HORIZONTAL:
aLB_ANSATZ_REL.Clear();
- nCnt = aStrHorzList.GetTokenCount();
+ nCnt = comphelper::string::getTokenCount(aStrHorzList, ';');
for( nIdx=0 ; nIdx<nCnt ; nIdx++ )
aLB_ANSATZ_REL.InsertEntry( aStrHorzList.GetToken(nIdx) );
aLB_ANSATZ_REL.SelectEntryPos( nAnsatzRelPos );
@@ -438,7 +438,7 @@ void SvxCaptionTabPage::SetupAnsatz_Impl( sal_uInt16 nType )
case AZ_VERTIKAL:
aLB_ANSATZ_REL.Clear();
- nCnt = aStrVertList.GetTokenCount();
+ nCnt = comphelper::string::getTokenCount(aStrVertList, ';');
for( nIdx=0 ; nIdx<nCnt ; nIdx++ )
aLB_ANSATZ_REL.InsertEntry( aStrVertList.GetToken(nIdx) );
aLB_ANSATZ_REL.SelectEntryPos( nAnsatzRelPos );
diff --git a/cui/source/tabpages/macroass.cxx b/cui/source/tabpages/macroass.cxx
index 2084b64da970..b160def086ed 100644
--- a/cui/source/tabpages/macroass.cxx
+++ b/cui/source/tabpages/macroass.cxx
@@ -33,6 +33,7 @@
#include "macroass.hxx"
#include <basic/basmgr.hxx>
+#include <comphelper/string.hxx>
#include <dialmgr.hxx>
#include <svx/dialogs.hrc>
#define _SVSTDARR_STRINGSDTOR
@@ -134,7 +135,7 @@ String ConvertToUIName_Impl( SvxMacro *pMacro )
String aEntry;
if ( ! pMacro->GetLanguage().EqualsAscii("JavaScript") )
{
- sal_uInt16 nCount = aName.GetTokenCount('.');
+ sal_uInt16 nCount = comphelper::string::getTokenCount(aName, '.');
aEntry = aName.GetToken( nCount-1, '.' );
if ( nCount > 2 )
{