summaryrefslogtreecommitdiff
path: root/sw/source/ui
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 /sw/source/ui
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 'sw/source/ui')
-rw-r--r--sw/source/ui/app/appenv.cxx2
-rw-r--r--sw/source/ui/dbui/createaddresslistdialog.cxx5
-rw-r--r--sw/source/ui/dbui/mailmergechildwindow.cxx5
-rw-r--r--sw/source/ui/dbui/mailmergehelper.cxx7
-rw-r--r--sw/source/ui/dbui/mmoutputpage.cxx6
-rwxr-xr-xsw/source/ui/dochdl/swdtflvr.cxx13
-rw-r--r--sw/source/ui/envelp/envimg.cxx3
-rw-r--r--sw/source/ui/envelp/labelcfg.cxx3
-rw-r--r--sw/source/ui/fldui/fldmgr.cxx5
-rw-r--r--sw/source/ui/index/cntex.cxx3
-rw-r--r--sw/source/ui/index/cnttab.cxx4
-rw-r--r--sw/source/ui/misc/bookmark.cxx2
-rw-r--r--sw/source/ui/misc/glosdoc.cxx2
-rw-r--r--sw/source/ui/misc/glossary.cxx3
-rw-r--r--sw/source/ui/uiview/view.cxx3
-rw-r--r--sw/source/ui/vba/vbaselection.cxx3
16 files changed, 40 insertions, 29 deletions
diff --git a/sw/source/ui/app/appenv.cxx b/sw/source/ui/app/appenv.cxx
index 14ddf487327e..3cf79b4077cf 100644
--- a/sw/source/ui/app/appenv.cxx
+++ b/sw/source/ui/app/appenv.cxx
@@ -119,7 +119,7 @@ String InsertLabEnvText( SwWrtShell& rSh, SwFldMgr& rFldMgr, const String& rText
// Database fields must contain at least 3 points!
String sDBName( sTmpText.Copy( 1, sTmpText.Len() - 2));
- sal_uInt16 nCnt = sDBName.GetTokenCount('.');
+ sal_uInt16 nCnt = comphelper::string::getTokenCount(sDBName, '.');
if (nCnt >= 3)
{
::ReplacePoint(sDBName, sal_True);
diff --git a/sw/source/ui/dbui/createaddresslistdialog.cxx b/sw/source/ui/dbui/createaddresslistdialog.cxx
index 7c2a3eabf9b0..848b91eba95a 100644
--- a/sw/source/ui/dbui/createaddresslistdialog.cxx
+++ b/sw/source/ui/dbui/createaddresslistdialog.cxx
@@ -33,6 +33,7 @@
#include <createaddresslistdialog.hxx>
#include <customizeaddresslistdialog.hxx>
#include <mmconfigitem.hxx>
+#include <comphelper/string.hxx>
#include <vcl/scrbar.hxx>
#include <vcl/msgbox.hxx>
#include <svtools/controldims.hrc>
@@ -416,7 +417,7 @@ SwCreateAddressListDialog::SwCreateAddressListDialog(
if(bRead)
{
//header line
- xub_StrLen nHeaders = sLine.GetTokenCount('\t');
+ xub_StrLen nHeaders = comphelper::string::getTokenCount(sLine, '\t');
xub_StrLen nIndex = 0;
for( xub_StrLen nToken = 0; nToken < nHeaders; ++nToken)
{
@@ -434,7 +435,7 @@ SwCreateAddressListDialog::SwCreateAddressListDialog(
{
::std::vector<OUString> aNewData;
//analyze data line
- xub_StrLen nDataCount = sLine.GetTokenCount('\t');
+ xub_StrLen nDataCount = comphelper::string::getTokenCount(sLine, '\t');
xub_StrLen nIndex = 0;
for( xub_StrLen nToken = 0; nToken < nDataCount; ++nToken)
{
diff --git a/sw/source/ui/dbui/mailmergechildwindow.cxx b/sw/source/ui/dbui/mailmergechildwindow.cxx
index 8ca13c0a97a0..f76e1dd7f831 100644
--- a/sw/source/ui/dbui/mailmergechildwindow.cxx
+++ b/sw/source/ui/dbui/mailmergechildwindow.cxx
@@ -40,6 +40,7 @@
#include <mmoutputpage.hxx>
#include <mmconfigitem.hxx>
#include <comphelper/processfactory.hxx>
+#include <comphelper/string.hxx>
#include "com/sun/star/mail/XSmtpService.hpp"
#include "com/sun/star/mail/MailServiceType.hpp"
#include <rtl/ref.hxx>
@@ -600,7 +601,7 @@ void SwSendMailDialog::IterateMails()
if(pCurrentMailDescriptor->sCC.getLength())
{
String sTokens( pCurrentMailDescriptor->sCC );
- sal_uInt16 nTokens = sTokens.GetTokenCount( ';' );
+ sal_uInt16 nTokens = comphelper::string::getTokenCount(sTokens, ';');
xub_StrLen nPos = 0;
for( sal_uInt16 nToken = 0; nToken < nTokens; ++nToken)
{
@@ -612,7 +613,7 @@ void SwSendMailDialog::IterateMails()
if(pCurrentMailDescriptor->sBCC.getLength())
{
String sTokens( pCurrentMailDescriptor->sBCC );
- sal_uInt16 nTokens = sTokens.GetTokenCount( ';' );
+ sal_uInt16 nTokens = comphelper::string::getTokenCount(sTokens, ';');
xub_StrLen nPos = 0;
for( sal_uInt16 nToken = 0; nToken < nTokens; ++nToken)
{
diff --git a/sw/source/ui/dbui/mailmergehelper.cxx b/sw/source/ui/dbui/mailmergehelper.cxx
index 9f466898a315..13d7705a7181 100644
--- a/sw/source/ui/dbui/mailmergehelper.cxx
+++ b/sw/source/ui/dbui/mailmergehelper.cxx
@@ -43,6 +43,7 @@
#include "com/sun/star/mail/MailServiceProvider.hpp"
#include "com/sun/star/mail/XSmtpService.hpp"
#include <comphelper/processfactory.hxx>
+#include <comphelper/string.hxx>
#include <vcl/msgbox.hxx>
#include <sfx2/passwd.hxx>
@@ -87,10 +88,10 @@ String CallSaveAsDialog(String& rFilter)
bool CheckMailAddress( const ::rtl::OUString& rMailAddress )
{
String sAddress(rMailAddress);
- if(!(sAddress.GetTokenCount('@') == 2))
+ if (!(comphelper::string::getTokenCount(sAddress, '@') == 2))
return false;
sAddress = sAddress.GetToken(1, '@');
- if(sAddress.GetTokenCount('.') < 2)
+ if (comphelper::string::getTokenCount(sAddress, '.') < 2)
return false;
if(sAddress.GetToken( 0, '.').Len() < 2 || sAddress.GetToken( 1, '.').Len() < 2)
return false;
@@ -444,7 +445,7 @@ void SwAddressPreview::DrawText_Impl(
}
sal_Int32 nHeight = GetTextHeight();
String sAddress(rAddress);
- sal_uInt16 nTokens = sAddress.GetTokenCount('\n');
+ sal_uInt16 nTokens = comphelper::string::getTokenCount(sAddress, '\n');
Point aStart = rTopLeft;
//put it away from the border
aStart.Move( 2, 2);
diff --git a/sw/source/ui/dbui/mmoutputpage.cxx b/sw/source/ui/dbui/mmoutputpage.cxx
index 04f7735e065c..ea332d3e4343 100644
--- a/sw/source/ui/dbui/mmoutputpage.cxx
+++ b/sw/source/ui/dbui/mmoutputpage.cxx
@@ -973,7 +973,7 @@ IMPL_LINK(SwMailMergeOutputPage, SendTypeHdl_Impl, ListBox*, pBox)
//do nothing if the user has removed the name - the warning will come early enough
if(sAttach.Len())
{
- xub_StrLen nTokenCount = sAttach.GetTokenCount( '.' );
+ xub_StrLen nTokenCount = comphelper::string::getTokenCount(sAttach, '.');
if( 2 > nTokenCount)
{
sAttach += '.';
@@ -1123,7 +1123,7 @@ IMPL_LINK(SwMailMergeOutputPage, SendDocumentsHdl_Impl, PushButton*, pButton)
if(RET_OK == aQuery.Execute())
{
String sAttach(aQuery.GetValue());
- xub_StrLen nTokenCount = sAttach.GetTokenCount( '.' );
+ xub_StrLen nTokenCount = comphelper::string::getTokenCount(sAttach, '.');
if( 2 > nTokenCount)
{
sAttach += '.';
@@ -1263,7 +1263,7 @@ IMPL_LINK(SwMailMergeOutputPage, SendDocumentsHdl_Impl, PushButton*, pButton)
sBody = m_sBody;
aDesc.sAttachmentURL = aName.GetValue();
String sAttachment(m_aAttachmentED.GetText());
- xub_StrLen nTokenCount = sAttachment.GetTokenCount( '.' );
+ xub_StrLen nTokenCount = comphelper::string::getTokenCount(sAttachment, '.');
if( 2 > nTokenCount)
{
sAttachment += '.';
diff --git a/sw/source/ui/dochdl/swdtflvr.cxx b/sw/source/ui/dochdl/swdtflvr.cxx
index 422e090b06e9..190f3cdce8c7 100755
--- a/sw/source/ui/dochdl/swdtflvr.cxx
+++ b/sw/source/ui/dochdl/swdtflvr.cxx
@@ -40,9 +40,10 @@
#include <svtools/embedtransfer.hxx>
#include <svtools/insdlg.hxx>
#include <unotools/tempfile.hxx>
-#include <comphelper/storagehelper.hxx>
#include <comphelper/processfactory.hxx>
#include <comphelper/servicehelper.hxx>
+#include <comphelper/storagehelper.hxx>
+#include <comphelper/string.hxx>
#include <unotools/ucbstreamhelper.hxx>
#include <sot/filelist.hxx>
#include <svx/svxdlg.hxx>
@@ -2078,15 +2079,15 @@ int SwTransferable::_PasteDDE( TransferableDataHelper& rData,
if( ( rData.HasFormat( SOT_FORMATSTR_ID_SYLK ) ||
rData.HasFormat( SOT_FORMATSTR_ID_SYLK_BIGCAPS ) ) &&
aExpand.Len() &&
- ( 1 < aExpand.GetTokenCount( '\n' ) ||
- aExpand.GetTokenCount( '\t' )) )
+ ( 1 < comphelper::string::getTokenCount(aExpand, '\n') ||
+ comphelper::string::getTokenCount(aExpand, '\t') ) )
{
String sTmp( aExpand );
- xub_StrLen nRows = sTmp.GetTokenCount( '\n' );
+ xub_StrLen nRows = comphelper::string::getTokenCount(sTmp, '\n');
if( nRows )
--nRows;
sTmp = sTmp.GetToken( 0, '\n' );
- xub_StrLen nCols = sTmp.GetTokenCount( '\t' );
+ xub_StrLen nCols = comphelper::string::getTokenCount(sTmp, '\t');
// at least one column & row must be there
if( !nRows || !nCols )
@@ -2101,7 +2102,7 @@ int SwTransferable::_PasteDDE( TransferableDataHelper& rData,
SwInsertTableOptions( tabopts::SPLIT_LAYOUT, 1 ), // TODO MULTIHEADER
pDDETyp, nRows, nCols );
}
- else if( 1 < aExpand.GetTokenCount( '\n' ) )
+ else if( 1 < comphelper::string::getTokenCount(aExpand, '\n') )
{
// multiple paragraphs -> insert a protected section
if( rWrtShell.HasSelection() )
diff --git a/sw/source/ui/envelp/envimg.cxx b/sw/source/ui/envelp/envimg.cxx
index 8b29a9c8795d..a93a84943eab 100644
--- a/sw/source/ui/envelp/envimg.cxx
+++ b/sw/source/ui/envelp/envimg.cxx
@@ -29,6 +29,7 @@
#include <hintids.hxx>
+#include <comphelper/string.hxx>
#include <tools/stream.hxx>
#include <tools/resid.hxx>
#include <sfx2/app.hxx>
@@ -65,7 +66,7 @@ SW_DLLPUBLIC String MakeSender()
String sRet;
String sSenderToken(SW_RES(STR_SENDER_TOKENS));
- xub_StrLen nSttPos = 0, nTokenCount = sSenderToken.GetTokenCount(';');
+ xub_StrLen nSttPos = 0, nTokenCount = comphelper::string::getTokenCount(sSenderToken, ';');
sal_Bool bLastLength = sal_True;
for( xub_StrLen i = 0; i < nTokenCount; i++ )
{
diff --git a/sw/source/ui/envelp/labelcfg.cxx b/sw/source/ui/envelp/labelcfg.cxx
index a2a8fb33134d..d8dc95333717 100644
--- a/sw/source/ui/envelp/labelcfg.cxx
+++ b/sw/source/ui/envelp/labelcfg.cxx
@@ -31,6 +31,7 @@
#include <swtypes.hxx>
#include <labelcfg.hxx>
#include <labimp.hxx>
+#include <comphelper/string.hxx>
#include <unotools/configpathes.hxx>
#include <unomid.h>
@@ -89,7 +90,7 @@ SwLabRec* lcl_CreateSwLabRec(Sequence<Any>& rValues, const OUString& rManufactur
//except for the continuous flag ('C'/'S')
pValues[nProp] >>= sTmp;
String sMeasure(sTmp);
- sal_uInt16 nTokenCount = sMeasure.GetTokenCount(';');
+ sal_uInt16 nTokenCount = comphelper::string::getTokenCount(sMeasure, ';');
for(sal_uInt16 i = 0; i < nTokenCount; i++)
{
String sToken(sMeasure.GetToken(i, ';' ));
diff --git a/sw/source/ui/fldui/fldmgr.cxx b/sw/source/ui/fldui/fldmgr.cxx
index 426f36fe2873..789598b78b19 100644
--- a/sw/source/ui/fldui/fldmgr.cxx
+++ b/sw/source/ui/fldui/fldmgr.cxx
@@ -41,6 +41,7 @@
#include <com/sun/star/uri/XUriReferenceFactory.hpp>
#include <com/sun/star/uri/XVndSunStarScriptUrl.hpp>
#include <comphelper/processfactory.hxx>
+#include <comphelper/string.hxx>
#include <editeng/unolingu.hxx>
#include <unotools/localedatawrapper.hxx>
#include <sfx2/dispatch.hxx>
@@ -1352,7 +1353,7 @@ sal_Bool SwFldMgr::InsertFld( const SwInsertFld_Data& rData )
case TYP_DROPDOWN :
{
pFld = new SwDropDownField(pCurShell->GetFldType( 0, RES_DROPDOWN ));
- xub_StrLen nTokenCount = rData.sPar2.GetTokenCount(DB_DELIM);
+ xub_StrLen nTokenCount = comphelper::string::getTokenCount(rData.sPar2, DB_DELIM);
Sequence<OUString> aEntries(nTokenCount);
OUString* pArray = aEntries.getArray();
for(xub_StrLen nToken = 0; nToken < nTokenCount; nToken++)
@@ -1516,7 +1517,7 @@ void SwFldMgr::UpdateCurFld(sal_uLong nFormat,
break;
case TYP_DROPDOWN:
{
- xub_StrLen nTokenCount = sPar2.GetTokenCount(DB_DELIM);
+ xub_StrLen nTokenCount = comphelper::string::getTokenCount(sPar2, DB_DELIM);
Sequence<OUString> aEntries(nTokenCount);
OUString* pArray = aEntries.getArray();
for(xub_StrLen nToken = 0; nToken < nTokenCount; nToken++)
diff --git a/sw/source/ui/index/cntex.cxx b/sw/source/ui/index/cntex.cxx
index 488a4bdbbae5..19a491d1e235 100644
--- a/sw/source/ui/index/cntex.cxx
+++ b/sw/source/ui/index/cntex.cxx
@@ -49,6 +49,7 @@
#include <com/sun/star/ucb/XCommandEnvironment.hpp>
#include <com/sun/star/ui/dialogs/XFilePicker.hpp>
#include <com/sun/star/ui/dialogs/XFilterManager.hpp>
+#include <comphelper/string.hxx>
#include <wrtsh.hxx>
#include <view.hxx>
#include <cnttab.hxx>
@@ -263,7 +264,7 @@ void SwMultiTOXTabDialog::CreateOrUpdateExample(
String sLevel;
if(bOn)
sLevel = rDesc.GetStyleNames(i);
- sal_uInt16 nStyles = sLevel.GetTokenCount(TOX_STYLE_DELIMITER);
+ sal_uInt16 nStyles = comphelper::string::getTokenCount(sLevel, TOX_STYLE_DELIMITER);
uno::Sequence<OUString> aStyles(nStyles);
OUString* pArr = aStyles.getArray();
for(sal_uInt16 nStyle = 0; nStyle < nStyles; nStyle++)
diff --git a/sw/source/ui/index/cnttab.cxx b/sw/source/ui/index/cnttab.cxx
index c042edafb6e9..59382cb9ce67 100644
--- a/sw/source/ui/index/cnttab.cxx
+++ b/sw/source/ui/index/cnttab.cxx
@@ -30,7 +30,7 @@
#undef SW_DLLIMPLEMENTATION
#endif
-
+#include <comphelper/string.hxx>
#include <rsc/rscsfx.hxx>
#include <vcl/msgbox.hxx>
#include <vcl/help.hxx>
@@ -759,7 +759,7 @@ SwAddStylesDlg_Impl::SwAddStylesDlg_Impl(Window* pParent,
for(i = 0; i < MAXLEVEL; ++i)
{
String sStyles(rStringArr[i]);
- for(sal_uInt16 nToken = 0; nToken < sStyles.GetTokenCount(TOX_STYLE_DELIMITER); nToken++)
+ for(sal_uInt16 nToken = 0; nToken < comphelper::string::getTokenCount(sStyles, TOX_STYLE_DELIMITER); nToken++)
{
String sTmp(sStyles.GetToken(nToken, TOX_STYLE_DELIMITER));
SvLBoxEntry* pEntry = rTLB.InsertEntry(sTmp);
diff --git a/sw/source/ui/misc/bookmark.cxx b/sw/source/ui/misc/bookmark.cxx
index 832c289eb846..075f741cf230 100644
--- a/sw/source/ui/misc/bookmark.cxx
+++ b/sw/source/ui/misc/bookmark.cxx
@@ -194,7 +194,7 @@ sal_uInt16 BookmarkCombo::GetSelEntryPos(sal_uInt16 nPos) const
{
sal_Unicode cSep = GetMultiSelectionSeparator();
- sal_uInt16 nCnt = GetText().GetTokenCount(cSep);
+ sal_uInt16 nCnt = comphelper::string::getTokenCount(GetText(), cSep);
for (; nPos < nCnt; nPos++)
{
diff --git a/sw/source/ui/misc/glosdoc.cxx b/sw/source/ui/misc/glosdoc.cxx
index c012152a03ef..e84455dde29a 100644
--- a/sw/source/ui/misc/glosdoc.cxx
+++ b/sw/source/ui/misc/glosdoc.cxx
@@ -439,7 +439,7 @@ void SwGlossaries::UpdateGlosPath(sal_Bool bFull)
delete *it;
m_aPathArr.clear();
- sal_uInt16 nTokenCount = m_aPath.GetTokenCount(SVT_SEARCHPATH_DELIMITER);
+ sal_uInt16 nTokenCount = comphelper::string::getTokenCount(m_aPath, SVT_SEARCHPATH_DELIMITER);
std::vector<String*> aDirArr;
for( sal_uInt16 i = 0; i < nTokenCount; i++ )
{
diff --git a/sw/source/ui/misc/glossary.cxx b/sw/source/ui/misc/glossary.cxx
index 66c5bea0c9c7..9119645b29dd 100644
--- a/sw/source/ui/misc/glossary.cxx
+++ b/sw/source/ui/misc/glossary.cxx
@@ -51,6 +51,7 @@
#include <unocrsr.hxx>
#include <unotools.hxx>
#include <comphelper/processfactory.hxx>
+#include <comphelper/string.hxx>
#include <ucbhelper/content.hxx>
#include <com/sun/star/ui/dialogs/XFilePicker.hpp>
#include <com/sun/star/ui/dialogs/XFilterManager.hpp>
@@ -667,7 +668,7 @@ IMPL_LINK( SwGlossaryDlg, BibHdl, Button *, EMPTYARG )
//check if at least one glossary path is write enabled
SvtPathOptions aPathOpt;
String sGlosPath( aPathOpt.GetAutoTextPath() );
- sal_uInt16 nPaths = sGlosPath.GetTokenCount(';');
+ sal_uInt16 nPaths = comphelper::string::getTokenCount(sGlosPath, ';');
sal_Bool bIsWritable = sal_False;
for(sal_uInt16 nPath = 0; nPath < nPaths; nPath++)
{
diff --git a/sw/source/ui/uiview/view.cxx b/sw/source/ui/uiview/view.cxx
index b3bbf8755095..738758f9296d 100644
--- a/sw/source/ui/uiview/view.cxx
+++ b/sw/source/ui/uiview/view.cxx
@@ -30,6 +30,7 @@
#include <string>
#include <stdlib.h>
#include <hintids.hxx>
+#include <comphelper/string.hxx>
#include <rtl/logfile.hxx>
#include <vcl/graph.hxx>
#include <vcl/inputctx.hxx>
@@ -1144,7 +1145,7 @@ bool lcl_IsOwnDocument( SwView& rView )
void SwView::ReadUserData( const String &rUserData, sal_Bool bBrowse )
{
- if ( rUserData.GetTokenCount() > 1 &&
+ if ( comphelper::string::getTokenCount(rUserData, ';') > 1 &&
//Fuer Dokumente ohne Layout nur im OnlineLayout oder beim
//Forward/Backward
(!pWrtShell->IsNewLayout() || pWrtShell->GetViewOptions()->getBrowseMode() || bBrowse) )
diff --git a/sw/source/ui/vba/vbaselection.cxx b/sw/source/ui/vba/vbaselection.cxx
index 3b115ad4c7bd..51530eaca059 100644
--- a/sw/source/ui/vba/vbaselection.cxx
+++ b/sw/source/ui/vba/vbaselection.cxx
@@ -35,6 +35,7 @@
#include <com/sun/star/text/XTextTableCursor.hpp>
#include <com/sun/star/text/ControlCharacter.hpp>
#include <com/sun/star/table/XCell.hpp>
+#include <comphelper/string.hxx>
#include <ooo/vba/word/WdUnits.hpp>
#include <ooo/vba/word/WdMovementType.hpp>
#include <ooo/vba/word/WdGoToItem.hpp>
@@ -1002,7 +1003,7 @@ void SwVbaSelection::GetSelectedCellRange( rtl::OUString& sTLName, rtl::OUString
if( xTextTableCursor.is() )
{
String sRange( xTextTableCursor->getRangeName() );
- if( sRange.GetTokenCount(':') > 0 )
+ if( comphelper::string::getTokenCount(sRange, ':') > 0 )
{
sTLName = sRange.GetToken(0, ':');
sBRName = sRange.GetToken(1, ':');