[Libreoffice-commits] core.git: 16 commits - basic/source cui/source dbaccess/source sw/source vcl/source vcl/unx
Matteo Casalin
matteo.casalin at yahoo.com
Sun Apr 29 20:55:16 UTC 2018
basic/source/basmgr/basmgr.cxx | 36 ++++++++++++++++---------------
cui/source/dialogs/cuifmsearch.cxx | 23 +++++++++++++------
cui/source/options/optjava.cxx | 4 +--
cui/source/tabpages/numpages.cxx | 9 +++++--
dbaccess/source/core/misc/dsntypes.cxx | 23 +++++++++++--------
dbaccess/source/ui/misc/TokenWriter.cxx | 18 ++++++++-------
sw/source/core/unocore/unoidx.cxx | 28 +++++++++---------------
sw/source/ui/index/cntex.cxx | 5 ++--
sw/source/ui/index/cnttab.cxx | 15 ++++++------
sw/source/uibase/envelp/envimg.cxx | 12 +++++-----
sw/source/uibase/envelp/labelcfg.cxx | 10 ++++----
vcl/source/control/combobox.cxx | 13 ++++++-----
vcl/source/filter/FilterConfigItem.cxx | 17 ++++----------
vcl/source/filter/graphicfilter.cxx | 27 ++++++++++++-----------
vcl/unx/gtk/fpicker/SalGtkFilePicker.cxx | 24 ++++++++++++--------
15 files changed, 140 insertions(+), 124 deletions(-)
New commits:
commit 3922602fc3aff254ba1df3e2f193a7f569b8963f
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Sun Apr 29 22:42:33 2018 +0200
Avoid getTokenCount
Change-Id: Iad8a623a219b1e6158a1ec447bdc7853817d2086
diff --git a/sw/source/uibase/envelp/envimg.cxx b/sw/source/uibase/envelp/envimg.cxx
index c09159802628..199b8fcda74a 100644
--- a/sw/source/uibase/envelp/envimg.cxx
+++ b/sw/source/uibase/envelp/envimg.cxx
@@ -18,7 +18,6 @@
*/
#include <hintids.hxx>
-#include <comphelper/string.hxx>
#include <o3tl/any.hxx>
#include <tools/stream.hxx>
#include <sfx2/app.hxx>
@@ -50,13 +49,14 @@ OUString MakeSender()
{
SvtUserOptions& rUserOpt = SW_MOD()->GetUserOptions();
+ const OUString sSenderToken(SwResId(STR_SENDER_TOKENS));
+ if (sSenderToken.isEmpty())
+ return OUString();
+
OUString sRet;
- OUString sSenderToken(SwResId(STR_SENDER_TOKENS));
- sal_Int32 nTokenCount = comphelper::string::getTokenCount(sSenderToken, ';');
sal_Int32 nSttPos = 0;
bool bLastLength = true;
- for( sal_Int32 i = 0; i < nTokenCount; i++ )
- {
+ do {
OUString sToken = sSenderToken.getToken( 0, ';', nSttPos );
if (sToken == "COMPANY")
{
@@ -86,7 +86,7 @@ OUString MakeSender()
sRet += rUserOpt.GetState();
else if (!sToken.isEmpty()) //spaces
sRet += sToken;
- }
+ } while (nSttPos>=0);
return sRet;
}
commit 5f07b58b0904f2d00ea4c1b49296ec0abfbe397c
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Sun Apr 29 22:24:45 2018 +0200
Avoid getTokenCount
Change-Id: Idf94fa126580623c879023b04a2d9cbe54679b21
diff --git a/sw/source/uibase/envelp/labelcfg.cxx b/sw/source/uibase/envelp/labelcfg.cxx
index 808b250a3470..6c6ec6127efc 100644
--- a/sw/source/uibase/envelp/labelcfg.cxx
+++ b/sw/source/uibase/envelp/labelcfg.cxx
@@ -23,7 +23,6 @@
#include <swtypes.hxx>
#include <labelcfg.hxx>
#include <labimp.hxx>
-#include <comphelper/string.hxx>
#include <rtl/bootstrap.hxx>
#include <unotools/configpaths.hxx>
#include <xmlreader/xmlreader.hxx>
@@ -183,12 +182,13 @@ static std::unique_ptr<SwLabRec> lcl_CreateSwLabRec(const OUString& rType, const
pNewRec->m_aType = rType;
//all values are contained as colon-separated 1/100 mm values
//except for the continuous flag ('C'/'S') and nCols, nRows (sal_Int32)
- sal_uInt16 nTokenCount = comphelper::string::getTokenCount(rMeasure, ';');
- for(sal_uInt16 i = 0; i < nTokenCount; i++)
+ sal_Int32 nTok{0};
+ sal_Int32 nIdx{rMeasure.isEmpty() ? -1 : 0};
+ while (nIdx>=0)
{
- OUString sToken(rMeasure.getToken(i, ';' ));
+ const OUString sToken(rMeasure.getToken(0, ';', nIdx));
int nVal = sToken.toInt32();
- switch(i)
+ switch(nTok++)
{
case 0 : pNewRec->m_bCont = sToken[0] == 'C'; break;
case 1 : pNewRec->m_nHDist = convertMm100ToTwip(nVal); break;
commit e7747a338bb3951448a0be2cda1e9ae5eb6cc117
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Sun Apr 29 21:34:26 2018 +0200
Avoid getTokenCount
Previous implementation looped backward from last token,
but just a match seems to be required in order to insert
the associated ComboBox position in a std::set (which does
not care for insertion order).
Change-Id: If92b28a9364e59fca46e728164be41e0755d0977
diff --git a/vcl/source/control/combobox.cxx b/vcl/source/control/combobox.cxx
index 9f8bd524e0e1..d54c628df8a3 100644
--- a/vcl/source/control/combobox.cxx
+++ b/vcl/source/control/combobox.cxx
@@ -89,14 +89,15 @@ struct ComboBox::Impl
static void lcl_GetSelectedEntries( ::std::set< sal_Int32 >& rSelectedPos, const OUString& rText, sal_Unicode cTokenSep, const ImplEntryList* pEntryList )
{
- for (sal_Int32 n = comphelper::string::getTokenCount(rText, cTokenSep); n;)
- {
- OUString aToken = rText.getToken( --n, cTokenSep );
- aToken = comphelper::string::strip(aToken, ' ');
- sal_Int32 nPos = pEntryList->FindEntry( aToken );
+ if (rText.isEmpty())
+ return;
+
+ sal_Int32 nIdx{0};
+ do {
+ const sal_Int32 nPos = pEntryList->FindEntry(comphelper::string::strip(rText.getToken(0, cTokenSep, nIdx), ' '));
if ( nPos != LISTBOX_ENTRY_NOTFOUND )
rSelectedPos.insert( nPos );
- }
+ } while (nIdx>=0);
}
ComboBox::ComboBox(vcl::Window *const pParent, WinBits const nStyle)
commit b7b323a783abd4055b58f9a765615e2ad887bd77
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Sun Apr 29 20:04:32 2018 +0200
Avoid getTokenCount
Change-Id: Ia5070c009012ba4830b05e98e055a14e7e0020b7
diff --git a/vcl/source/filter/FilterConfigItem.cxx b/vcl/source/filter/FilterConfigItem.cxx
index ffdd00a15fe9..170e4b956046 100644
--- a/vcl/source/filter/FilterConfigItem.cxx
+++ b/vcl/source/filter/FilterConfigItem.cxx
@@ -21,7 +21,6 @@
#include <unotools/configmgr.hxx>
#include <comphelper/processfactory.hxx>
-#include <comphelper/string.hxx>
#include <osl/diagnose.h>
#include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/configuration/theDefaultProvider.hpp>
@@ -44,20 +43,14 @@ static bool ImpIsTreeAvailable( Reference< XMultiServiceFactory > const & rXCfgP
bool bAvailable = !rTree.isEmpty();
if ( bAvailable )
{
- using comphelper::string::getTokenCount;
-
- sal_Int32 nTokenCount = getTokenCount(rTree, '/');
- sal_Int32 i = 0;
-
+ sal_Int32 nIdx{0};
if ( rTree[0] == '/' )
- ++i;
- if ( rTree.endsWith("/") )
- --nTokenCount;
+ ++nIdx;
// creation arguments: nodepath
PropertyValue aPathArgument;
aPathArgument.Name = "nodepath";
- aPathArgument.Value <<= rTree.getToken(i++, '/');
+ aPathArgument.Value <<= rTree.getToken(0, '/', nIdx);
Sequence< Any > aArguments( 1 );
aArguments[ 0 ] <<= aPathArgument;
@@ -75,7 +68,7 @@ static bool ImpIsTreeAvailable( Reference< XMultiServiceFactory > const & rXCfgP
}
if ( xReadAccess.is() )
{
- for ( ; bAvailable && ( i < nTokenCount ); i++ )
+ while (bAvailable && nIdx>=0 )
{
Reference< XHierarchicalNameAccess > xHierarchicalNameAccess
( xReadAccess, UNO_QUERY );
@@ -84,7 +77,7 @@ static bool ImpIsTreeAvailable( Reference< XMultiServiceFactory > const & rXCfgP
bAvailable = false;
else
{
- OUString aNode( rTree.getToken(i, '/') );
+ const OUString aNode( rTree.getToken(0, '/', nIdx) );
if ( !xHierarchicalNameAccess->hasByHierarchicalName( aNode ) )
bAvailable = false;
else
commit 1a2ee0ecd5b0cff52922c1d261f7d03a57a52ca0
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Sun Apr 29 17:41:51 2018 +0200
Avoid getTokenCount
Change-Id: Id4a6e669fedf803fc96ce83315dccc61cfb25aed
diff --git a/vcl/source/filter/graphicfilter.cxx b/vcl/source/filter/graphicfilter.cxx
index 43feef35e5e2..91d01a2f46d3 100644
--- a/vcl/source/filter/graphicfilter.cxx
+++ b/vcl/source/filter/graphicfilter.cxx
@@ -75,8 +75,6 @@
#define PMGCHUNG_msOG 0x6d734f47 // Microsoft Office Animated GIF
-using comphelper::string::getTokenCount;
-
typedef ::std::vector< GraphicFilter* > FilterList_impl;
static FilterList_impl* pFilterHdlList = nullptr;
@@ -1597,11 +1595,16 @@ Graphic GraphicFilter::ImportUnloadedGraphic(SvStream& rIStream)
{
ImpFilterLibCacheEntry* pFilter = nullptr;
- // find first filter in filter paths
- sal_Int32 i, nTokenCount = getTokenCount(aFilterPath, ';');
- ImpFilterLibCache &rCache = Cache::get();
- for( i = 0; ( i < nTokenCount ) && ( pFilter == nullptr ); i++ )
- pFilter = rCache.GetFilter(aFilterPath.getToken(i, ';'), aFilterName, aExternalFilterName);
+ if (!aFilterPath.isEmpty())
+ {
+ // find first filter in filter paths
+ ImpFilterLibCache &rCache = Cache::get();
+ sal_Int32 nIdx{0};
+ do {
+ pFilter = rCache.GetFilter(aFilterPath.getToken(0, ';', nIdx), aFilterName, aExternalFilterName);
+ } while (nIdx>=0 && pFilter==nullptr);
+ }
+
if( !pFilter )
nStatus = ERRCODE_GRFILTER_FILTERERROR;
else
@@ -2426,11 +2429,10 @@ ErrCode GraphicFilter::ExportGraphic( const Graphic& rGraphic, const OUString& r
}
else
{
- sal_Int32 i, nTokenCount = getTokenCount(aFilterPath, ';');
- for ( i = 0; i < nTokenCount; i++ )
- {
+ sal_Int32 nIdx{0};
+ do {
#ifndef DISABLE_DYNLOADING
- OUString aPhysicalName( ImpCreateFullFilterPath( aFilterPath.getToken(i, ';'), aFilterName ) );
+ OUString aPhysicalName( ImpCreateFullFilterPath( aFilterPath.getToken(0, ';', nIdx), aFilterName ) );
osl::Module aLibrary( aPhysicalName );
PFilterCall pFunc = nullptr;
@@ -2442,6 +2444,7 @@ ErrCode GraphicFilter::ExportGraphic( const Graphic& rGraphic, const OUString& r
pFunc = reinterpret_cast<PFilterCall>(aLibrary.getFunctionSymbol("etiGraphicExport"));
// Execute dialog in DLL
#else
+ --nIdx; // Just one iteration
PFilterCall pFunc = NULL;
if (aFilterName == "egi")
pFunc = egiGraphicExport;
@@ -2458,7 +2461,7 @@ ErrCode GraphicFilter::ExportGraphic( const Graphic& rGraphic, const OUString& r
}
else
nStatus = ERRCODE_GRFILTER_FILTERERROR;
- }
+ } while (nIdx>=0);
}
}
if( nStatus != ERRCODE_NONE )
commit 2a39163aef4211c9d19cb1faee7f55d3718355b6
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Sun Apr 29 17:15:34 2018 +0200
Rework code to avoid getTokenCount/getToken
Change-Id: I46985c3edda9509f0a014ea351016dce599bda4a
diff --git a/vcl/unx/gtk/fpicker/SalGtkFilePicker.cxx b/vcl/unx/gtk/fpicker/SalGtkFilePicker.cxx
index e499350b12b4..a28af32d3595 100644
--- a/vcl/unx/gtk/fpicker/SalGtkFilePicker.cxx
+++ b/vcl/unx/gtk/fpicker/SalGtkFilePicker.cxx
@@ -41,7 +41,6 @@
#include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
#include <com/sun/star/ui/dialogs/ControlActions.hpp>
#include <com/sun/star/uno/Any.hxx>
-#include <comphelper/string.hxx>
#include <unx/gtk/gtkdata.hxx>
#include <unx/gtk/gtkinst.hxx>
@@ -705,16 +704,23 @@ namespace
bool lcl_matchFilter( const rtl::OUString& rFilter, const rtl::OUString& rExt )
{
- const int nCount = comphelper::string::getTokenCount( rFilter, ';' );
+ const sal_Int32 nBegin = rFilter.indexOf(rExt);
- for ( int n = 0; n != nCount; ++n )
- {
- const rtl::OUString aToken = rFilter.getToken( n, ';' );
- if ( aToken == rExt )
- return true;
- }
+ if (nBegin<0) // not found
+ return false;
- return false;
+ const sal_Unicode cSep{';'};
+
+ // Check if the found occurrence is an exact match: left side
+ if (nBegin>0 && rFilter[nBegin-1]!=cSep)
+ return false;
+
+ // Check if the found occurrence is an exact match: right side
+ const sal_Int32 nEnd = nBegin + rExt.getLength();
+ if (nEnd<rFilter.getLength() && rFilter[nEnd]!=cSep)
+ return false;
+
+ return true;
}
}
commit 132138eeb0d518218d9051744e2092d3340156af
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Sun Apr 29 16:20:46 2018 +0200
Avoid getTokenCount()
Change-Id: I7c58295c8d0eda927dd670ca9cc5537437ed94e6
diff --git a/dbaccess/source/ui/misc/TokenWriter.cxx b/dbaccess/source/ui/misc/TokenWriter.cxx
index e38be526a494..b1a60f2e6646 100644
--- a/dbaccess/source/ui/misc/TokenWriter.cxx
+++ b/dbaccess/source/ui/misc/TokenWriter.cxx
@@ -26,7 +26,6 @@
#include <HtmlReader.hxx>
#include <stringconstants.hxx>
#include <strings.hxx>
-#include <comphelper/string.hxx>
#include <comphelper/types.hxx>
#include <connectivity/dbtools.hxx>
#include <com/sun/star/sdb/DatabaseContext.hpp>
@@ -357,14 +356,17 @@ bool ORTFImportExport::Write()
}
m_pStream->WriteCharPtr( "{\\fonttbl" );
- sal_Int32 nTokenCount = comphelper::string::getTokenCount(aFonts, ';');
- for(sal_Int32 j=0; j<nTokenCount; ++j)
+ if (!aFonts.isEmpty())
{
- m_pStream->WriteCharPtr( "\\f" );
- m_pStream->WriteInt32AsString(j);
- m_pStream->WriteCharPtr( "\\fcharset0\\fnil " );
- m_pStream->WriteCharPtr( aFonts.getToken(j, ';').getStr() );
- m_pStream->WriteChar( ';' );
+ sal_Int32 nIdx{0};
+ sal_Int32 nTok{-1}; // to compensate pre-increment
+ do {
+ m_pStream->WriteCharPtr( "\\f" );
+ m_pStream->WriteInt32AsString(++nTok);
+ m_pStream->WriteCharPtr( "\\fcharset0\\fnil " );
+ m_pStream->WriteCharPtr( aFonts.getToken(0, ';', nIdx).getStr() );
+ m_pStream->WriteChar( ';' );
+ } while (nIdx>=0);
}
m_pStream->WriteChar( '}' ) ;
m_pStream->WriteCharPtr( SAL_NEWLINE_STRING );
commit 5fd03b2693f699c6254128b74b2b8f719c2ba5b0
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Sun Apr 29 12:45:53 2018 +0200
OUString: getLength() ==> isEmpty() when possible
Change-Id: Id35899bf89384557a744ff5828a0ac54ab19328b
diff --git a/dbaccess/source/core/misc/dsntypes.cxx b/dbaccess/source/core/misc/dsntypes.cxx
index 13566183a885..a3ba367f4f9a 100644
--- a/dbaccess/source/core/misc/dsntypes.cxx
+++ b/dbaccess/source/core/misc/dsntypes.cxx
@@ -127,7 +127,7 @@ OUString ODsnTypeCollection::getPrefix(const OUString& _sURL) const
bool ODsnTypeCollection::hasDriver( const sal_Char* _pAsciiPattern ) const
{
OUString sPrefix( getPrefix( OUString::createFromAscii( _pAsciiPattern ) ) );
- return ( sPrefix.getLength() > 0 );
+ return !sPrefix.isEmpty();
}
bool ODsnTypeCollection::isConnectionUrlRequired(const OUString& _sURL) const
@@ -143,7 +143,7 @@ bool ODsnTypeCollection::isConnectionUrlRequired(const OUString& _sURL) const
sOldPattern = dsnPrefix;
}
}
- return sRet.getLength() > 0 && sRet[sRet.getLength()-1] == '*';
+ return !sRet.isEmpty() && sRet[sRet.getLength()-1] == '*';
}
OUString ODsnTypeCollection::getMediaType(const OUString& _sURL) const
@@ -174,7 +174,7 @@ OUString ODsnTypeCollection::getDatasourcePrefixFromMediaType(const OUString& _s
}
}
- if ( !sURL.getLength() && sFallbackURL.getLength() )
+ if ( sURL.isEmpty() && !sFallbackURL.isEmpty() )
sURL = sFallbackURL;
sURL = comphelper::string::stripEnd(sURL, '*');
@@ -202,12 +202,12 @@ void ODsnTypeCollection::extractHostNamePort(const OUString& _rDsn,OUString& _sD
{
lcl_extractHostAndPort(sUrl,_rsHostname,_nPortNumber);
const sal_Int32 nUrlTokens {comphelper::string::getTokenCount(sUrl, ':')};
- if ( !_rsHostname.getLength() && nUrlTokens == 2 )
+ if ( _rsHostname.isEmpty() && nUrlTokens == 2 )
{
_nPortNumber = -1;
_rsHostname = sUrl.getToken(0,':');
}
- if ( _rsHostname.getLength() )
+ if ( !_rsHostname.isEmpty() )
_rsHostname = _rsHostname.getToken(comphelper::string::getTokenCount(_rsHostname, '@') - 1, '@');
_sDatabaseName = sUrl.getToken(nUrlTokens - 1, ':');
}
@@ -221,7 +221,7 @@ void ODsnTypeCollection::extractHostNamePort(const OUString& _rDsn,OUString& _sD
lcl_extractHostAndPort(sUrl,_rsHostname,_nPortNumber);
const sal_Int32 nUrlTokens {comphelper::string::getTokenCount(sUrl, '/')};
- if ( _nPortNumber == -1 && !_rsHostname.getLength() && nUrlTokens == 2 )
+ if ( _nPortNumber == -1 && _rsHostname.isEmpty() && nUrlTokens == 2 )
_rsHostname = sUrl.getToken(0,'/');
_sDatabaseName = sUrl.getToken(nUrlTokens - 1, '/');
}
commit 963bd6c26f272db1bee5331dd337c20db4e11ce7
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Sun Apr 29 12:24:51 2018 +0200
Reduce getTokenCount calls, use getToken with start index
Change-Id: Ie0f82377715fa1ddf570ec1622f40d8b6e9e4715
diff --git a/dbaccess/source/core/misc/dsntypes.cxx b/dbaccess/source/core/misc/dsntypes.cxx
index 7e48dd90fbb7..13566183a885 100644
--- a/dbaccess/source/core/misc/dsntypes.cxx
+++ b/dbaccess/source/core/misc/dsntypes.cxx
@@ -41,8 +41,9 @@ namespace dbaccess
{
if ( comphelper::string::getTokenCount(_sUrl, ':') >= 2 )
{
- _sHostname = _sUrl.getToken(0,':');
- _nPortNumber = _sUrl.getToken(1,':').toInt32();
+ sal_Int32 nPos {0};
+ _sHostname = _sUrl.getToken(0, ':', nPos);
+ _nPortNumber = _sUrl.getToken(0, ':', nPos).toInt32();
}
}
}
@@ -200,14 +201,15 @@ void ODsnTypeCollection::extractHostNamePort(const OUString& _rDsn,OUString& _sD
if ( _rDsn.startsWithIgnoreAsciiCase("jdbc:oracle:thin:") )
{
lcl_extractHostAndPort(sUrl,_rsHostname,_nPortNumber);
- if ( !_rsHostname.getLength() && comphelper::string::getTokenCount(sUrl, ':') == 2 )
+ const sal_Int32 nUrlTokens {comphelper::string::getTokenCount(sUrl, ':')};
+ if ( !_rsHostname.getLength() && nUrlTokens == 2 )
{
_nPortNumber = -1;
_rsHostname = sUrl.getToken(0,':');
}
if ( _rsHostname.getLength() )
_rsHostname = _rsHostname.getToken(comphelper::string::getTokenCount(_rsHostname, '@') - 1, '@');
- _sDatabaseName = sUrl.getToken(comphelper::string::getTokenCount(sUrl, ':') - 1, ':');
+ _sDatabaseName = sUrl.getToken(nUrlTokens - 1, ':');
}
else if ( _rDsn.startsWithIgnoreAsciiCase("sdbc:address:ldap:") )
{
@@ -218,9 +220,10 @@ void ODsnTypeCollection::extractHostNamePort(const OUString& _rDsn,OUString& _sD
{
lcl_extractHostAndPort(sUrl,_rsHostname,_nPortNumber);
- if ( _nPortNumber == -1 && !_rsHostname.getLength() && comphelper::string::getTokenCount(sUrl, '/') == 2 )
+ const sal_Int32 nUrlTokens {comphelper::string::getTokenCount(sUrl, '/')};
+ if ( _nPortNumber == -1 && !_rsHostname.getLength() && nUrlTokens == 2 )
_rsHostname = sUrl.getToken(0,'/');
- _sDatabaseName = sUrl.getToken(comphelper::string::getTokenCount(sUrl, '/') - 1, '/');
+ _sDatabaseName = sUrl.getToken(nUrlTokens - 1, '/');
}
else if ( _rDsn.startsWithIgnoreAsciiCase("sdbc:ado:access:Provider=Microsoft.ACE.OLEDB.12.0;DATA SOURCE=")
|| _rDsn.startsWithIgnoreAsciiCase("sdbc:ado:access:PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=") )
commit 777634169d1b3f264ccb0f01d9d4d9ecdd560d70
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Wed Apr 25 18:44:03 2018 +0200
Avoid comphelper::string::getTokenCount()
Change-Id: Iff326aec62554cd0719e7fe8f2b5871ed5e10bfd
diff --git a/cui/source/tabpages/numpages.cxx b/cui/source/tabpages/numpages.cxx
index ddad7426c78e..3c31e11d4a4b 100644
--- a/cui/source/tabpages/numpages.cxx
+++ b/cui/source/tabpages/numpages.cxx
@@ -76,7 +76,6 @@
#include <unotools/ucbstreamhelper.hxx>
#include <com/sun/star/ucb/SimpleFileAccess.hpp>
#include <rtl/ustring.h>
-#include <comphelper/string.hxx>
#include <vcl/cvtgrf.hxx>
#include <vcl/graphicfilter.hxx>
#include <svx/SvxNumOptionsTabPageHelper.hxx>
@@ -993,8 +992,12 @@ IMPL_LINK_NOARG(SvxBitmapPickTabPage, ClickAddBrowseHdl_Impl, Button*, void)
OUString aUserImageURL = aFileDialog.GetPath();
- sal_Int32 nSub = comphelper::string::getTokenCount( aUserImageURL, '/');
- OUString aFileName = aUserImageURL.getToken( nSub-1 , SEARCHFILENAME_DELIMITER );
+ OUString aFileName;
+ const sal_Int32 nPos {aUserImageURL.lastIndexOf(SEARCHFILENAME_DELIMITER)+1};
+ if (nPos<=0)
+ aFileName = aUserImageURL;
+ else if (nPos<aUserImageURL.getLength())
+ aFileName = aUserImageURL.copy(nPos);
OUString aUserGalleryURL = aPathToken + "/" + aFileName;
INetURLObject aURL( aUserImageURL );
commit 2f6b3fb0f30cd03e5ac60805a922711bdcab77f9
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Wed Apr 25 18:21:46 2018 +0200
Avoid comphelper::string::getTokenCount()
Change-Id: If120460609549c20fde867cc3f2941fc97896421
diff --git a/cui/source/options/optjava.cxx b/cui/source/options/optjava.cxx
index 9940db3014f7..eb81db248417 100644
--- a/cui/source/options/optjava.cxx
+++ b/cui/source/options/optjava.cxx
@@ -1049,14 +1049,14 @@ void SvxJavaClassPathDlg::SetClassPath( const OUString& _rPath )
m_sOldPath = _rPath;
m_pPathList->Clear();
sal_Int32 nIdx = 0;
- sal_Int32 nCount = comphelper::string::getTokenCount(_rPath, CLASSPATH_DELIMITER);
- for ( sal_Int32 i = 0; i < nCount; ++i )
+ do
{
OUString sToken = _rPath.getToken( 0, CLASSPATH_DELIMITER, nIdx );
INetURLObject aURL( sToken, FSysStyle::Detect );
OUString sPath = aURL.getFSysPath( FSysStyle::Detect );
m_pPathList->InsertEntry( sPath, SvFileInformationManager::GetImage( aURL ) );
}
+ while (nIdx>=0);
// select first entry
m_pPathList->SelectEntryPos(0);
SelectHdl_Impl( *m_pPathList );
commit 3de4968948f035db11c381ab18666cac5481a68e
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Wed Apr 25 18:18:39 2018 +0200
Avoid comphelper::string::getTokenCount()
Change-Id: I2aae4f106f783969ede076ce7af14e5946a554ae
diff --git a/basic/source/basmgr/basmgr.cxx b/basic/source/basmgr/basmgr.cxx
index b068db8c63d9..90c15c5edc08 100644
--- a/basic/source/basmgr/basmgr.cxx
+++ b/basic/source/basmgr/basmgr.cxx
@@ -32,7 +32,6 @@
#include <tools/diagnose_ex.h>
#include <basic/sbmod.hxx>
#include <unotools/intlwrapper.hxx>
-#include <comphelper/string.hxx>
#include <o3tl/make_unique.hxx>
#include <basic/sbuno.hxx>
@@ -778,15 +777,16 @@ void BasicManager::LoadOldBasicManager( SotStorage& rStorage )
if ( !aLibs.isEmpty() )
{
INetURLObject aCurStorage( aStorName, INetProtocol::File );
- sal_Int32 nLibs = comphelper::string::getTokenCount(aLibs, LIB_SEP);
- for ( sal_Int32 nLib = 0; nLib < nLibs; nLib++ )
- {
- OUString aLibInfo(aLibs.getToken(nLib, LIB_SEP));
- // TODO: Remove == 2
- DBG_ASSERT( ( comphelper::string::getTokenCount(aLibInfo, LIBINFO_SEP) == 2 ) || ( comphelper::string::getTokenCount(aLibInfo, LIBINFO_SEP) == 3 ), "Invalid Lib-Info!" );
- OUString aLibName( aLibInfo.getToken( 0, LIBINFO_SEP ) );
- OUString aLibAbsStorageName( aLibInfo.getToken( 1, LIBINFO_SEP ) );
- OUString aLibRelStorageName( aLibInfo.getToken( 2, LIBINFO_SEP ) );
+ sal_Int32 nLibPos {0};
+ do {
+ const OUString aLibInfo(aLibs.getToken(0, LIB_SEP, nLibPos));
+ sal_Int32 nInfoPos {0};
+ const OUString aLibName( aLibInfo.getToken( 0, LIBINFO_SEP, nInfoPos ) );
+ DBG_ASSERT( nInfoPos >= 0, "Invalid Lib-Info!" );
+ const OUString aLibAbsStorageName( aLibInfo.getToken( 0, LIBINFO_SEP, nInfoPos ) );
+ // TODO: fail also here if there are no more tokens?
+ const OUString aLibRelStorageName( aLibInfo.getToken( 0, LIBINFO_SEP, nInfoPos ) );
+ DBG_ASSERT( nInfoPos < 0, "Invalid Lib-Info!" );
INetURLObject aLibAbsStorage( aLibAbsStorageName, INetProtocol::File );
INetURLObject aLibRelStorage( aStorName );
@@ -817,7 +817,7 @@ void BasicManager::LoadOldBasicManager( SotStorage& rStorage )
StringErrorInfo* pErrInf = new StringErrorInfo( ERRCODE_BASMGR_LIBLOAD, aStorName, DialogMask::ButtonsOk );
aErrors.emplace_back(*pErrInf, BasicErrorReason::STORAGENOTFOUND);
}
- }
+ } while (nLibPos>=0);
}
}
@@ -1562,17 +1562,19 @@ ErrCode BasicManager::ExecuteMacro( OUString const& i_fullyQualifiedName, OUStri
OUStringBuffer aBuff;
OUString sArgs2 = sArgs.makeStringAndClear();
- sal_Int32 nCount = comphelper::string::getTokenCount(sArgs2, ',');
aBuff.append("(");
- for (sal_Int32 n = 0; n < nCount; ++n)
+ if (!sArgs2.isEmpty())
{
- aBuff.append( "\"" );
- aBuff.append( sArgs2.getToken(n, ',') );
- aBuff.append( "\"" );
- if ( n < nCount - 1 )
+ sal_Int32 nPos {0};
+ for (;;)
{
+ aBuff.append( "\"" );
+ aBuff.append( sArgs2.getToken(0, ',', nPos) );
+ aBuff.append( "\"" );
+ if (nPos<0)
+ break;
aBuff.append( "," );
}
}
commit 209a8d4ab598249baf5304e33a934873cce9f48e
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Wed Apr 25 17:17:23 2018 +0200
Avoid OUString temporaries and bail out early
Change-Id: Ic4c1b2ce68ba992744bd68dece0afc417c22e5cd
diff --git a/sw/source/core/unocore/unoidx.cxx b/sw/source/core/unocore/unoidx.cxx
index b2055a979b59..f2550b36fa23 100644
--- a/sw/source/core/unocore/unoidx.cxx
+++ b/sw/source/core/unocore/unoidx.cxx
@@ -1422,21 +1422,18 @@ OUString SAL_CALL SwXDocumentIndex::getName()
{
SolarMutexGuard g;
- OUString uRet;
SwSectionFormat *const pSectionFormat( m_pImpl->GetSectionFormat() );
if (m_pImpl->m_bIsDescriptor)
{
- uRet = m_pImpl->m_pProps->GetTOXBase().GetTOXName();
+ return m_pImpl->m_pProps->GetTOXBase().GetTOXName();
}
- else if(pSectionFormat)
- {
- uRet = pSectionFormat->GetSection()->GetSectionName();
- }
- else
+
+ if(!pSectionFormat)
{
throw uno::RuntimeException();
}
- return uRet;
+
+ return pSectionFormat->GetSection()->GetSectionName();
}
void SAL_CALL
@@ -1727,21 +1724,18 @@ SwXDocumentIndexMark::getMarkEntry()
{
SolarMutexGuard aGuard;
- OUString sRet;
SwTOXType *const pType = m_pImpl->GetTOXType();
if (pType && m_pImpl->m_pTOXMark)
{
- sRet = m_pImpl->m_pTOXMark->GetAlternativeText();
- }
- else if (m_pImpl->m_bIsDescriptor)
- {
- sRet = m_pImpl->m_sAltText;
+ return m_pImpl->m_pTOXMark->GetAlternativeText();
}
- else
+
+ if (!m_pImpl->m_bIsDescriptor)
{
throw uno::RuntimeException();
}
- return sRet;
+
+ return m_pImpl->m_sAltText;
}
void SAL_CALL
@@ -1932,7 +1926,7 @@ void SwXDocumentIndexMark::Impl::InsertTOXMark(
// thus use a space - is this really the ideal solution?
if (!bMark && rMark.GetAlternativeText().isEmpty())
{
- rMark.SetAlternativeText( OUString(' ') );
+ rMark.SetAlternativeText( " " );
}
const bool bForceExpandHints( !bMark && pTextCursor && pTextCursor->IsAtEndOfMeta() );
commit 4f03fabc4bf02400b961f8f3117ed07bd8ff81f5
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Wed Apr 25 17:15:46 2018 +0200
Avoid comphelper::string::getTokenCount()
Change-Id: I6bc5740d9e2115a09b1b096f120ab3ae19e30d66
diff --git a/sw/source/ui/index/cnttab.cxx b/sw/source/ui/index/cnttab.cxx
index 426ec4c3db2d..79eeb008953c 100644
--- a/sw/source/ui/index/cnttab.cxx
+++ b/sw/source/ui/index/cnttab.cxx
@@ -670,15 +670,14 @@ SwAddStylesDlg_Impl::SwAddStylesDlg_Impl(vcl::Window* pParent,
m_pHeaderTree->GetModel()->SetSortMode(SortAscending);
for (sal_uInt16 i = 0; i < MAXLEVEL; ++i)
{
- OUString sStyles(rStringArr[i]);
- for(sal_Int32 nToken = 0;
- nToken < comphelper::string::getTokenCount(sStyles, TOX_STYLE_DELIMITER);
- ++nToken)
- {
- const OUString sTmp(sStyles.getToken(nToken, TOX_STYLE_DELIMITER));
- SvTreeListEntry* pEntry = m_pHeaderTree->InsertEntry(sTmp);
+ const OUString &rStyles{rStringArr[i]};
+ if (rStyles.isEmpty())
+ continue;
+ sal_Int32 nPos {0};
+ do {
+ SvTreeListEntry* pEntry = m_pHeaderTree->InsertEntry(rStyles.getToken(0, TOX_STYLE_DELIMITER, nPos));
pEntry->SetUserData(reinterpret_cast<void*>(i));
- }
+ } while (nPos>=0);
}
// now the other styles
commit a04b9aa9ed00ac944e168910a22461273f09966a
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Wed Apr 25 17:14:54 2018 +0200
Use getToken with start position
Change-Id: I6c8d928f7b5f0e8abaa2ce2d71096ed2ec666911
diff --git a/sw/source/ui/index/cntex.cxx b/sw/source/ui/index/cntex.cxx
index 9723b18b109c..358bfb6e0094 100644
--- a/sw/source/ui/index/cntex.cxx
+++ b/sw/source/ui/index/cntex.cxx
@@ -214,8 +214,9 @@ void SwMultiTOXTabDialog::CreateOrUpdateExample(
comphelper::string::getTokenCount(sLevel, TOX_STYLE_DELIMITER);
uno::Sequence<OUString> aStyles(nStyles);
OUString* pArr = aStyles.getArray();
- for(sal_Int32 nStyle = 0; nStyle < nStyles; nStyle++)
- pArr[nStyle] = sLevel.getToken(nStyle, TOX_STYLE_DELIMITER);
+ sal_Int32 nPos {0};
+ for(sal_Int32 nStyle = 0; nStyle < nStyles; ++nStyle)
+ pArr[nStyle] = sLevel.getToken(0, TOX_STYLE_DELIMITER, nPos);
uno::Any aAny(&aStyles, cppu::UnoType<uno::Sequence<OUString>>::get());
xAcc->replaceByIndex(i, aAny);
}
commit ee84ba768f9f4228fe09650ab169bd6b3d042962
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Wed Apr 25 17:13:01 2018 +0200
Avoid comphelper::string::getTokenCount()
Change-Id: I0624940d615843bf100c53850c2578f9d0726e13
diff --git a/cui/source/dialogs/cuifmsearch.cxx b/cui/source/dialogs/cuifmsearch.cxx
index cbca9ae7fa3a..749ba6d8af59 100644
--- a/cui/source/dialogs/cuifmsearch.cxx
+++ b/cui/source/dialogs/cuifmsearch.cxx
@@ -249,8 +249,13 @@ void FmSearchDialog::Init(const OUString& strVisibleFields, const OUString& sIni
m_plbPosition->SelectEntryPos(MATCHING_ANYWHERE);
// the field listbox
- for (sal_Int32 i=0; i < comphelper::string::getTokenCount(strVisibleFields, ';'); ++i)
- m_plbField->InsertEntry(strVisibleFields.getToken(i, ';'));
+ if (!strVisibleFields.isEmpty())
+ {
+ sal_Int32 nPos {0};
+ do {
+ m_plbField->InsertEntry(strVisibleFields.getToken(0, ';', nPos));
+ } while (nPos>=0);
+ }
m_pConfig = new FmSearchConfigItem;
@@ -522,14 +527,18 @@ void FmSearchDialog::InitContext(sal_Int16 nContext)
// use the display names if supplied
DBG_ASSERT(comphelper::string::getTokenCount(fmscContext.sFieldDisplayNames, ';') == comphelper::string::getTokenCount(fmscContext.strUsedFields, ';'),
"FmSearchDialog::InitContext : invalid context description supplied !");
- for (sal_Int32 i=0; i < comphelper::string::getTokenCount(fmscContext.sFieldDisplayNames, ';'); ++i)
- m_plbField->InsertEntry(fmscContext.sFieldDisplayNames.getToken(i, ';'));
+ sal_Int32 nPos {0};
+ do {
+ m_plbField->InsertEntry(fmscContext.sFieldDisplayNames.getToken(0, ';', nPos));
+ } while (nPos>=0);
}
- else
+ else if (!fmscContext.strUsedFields.isEmpty())
{
// else use the field names
- for (sal_Int32 i=0; i < comphelper::string::getTokenCount(fmscContext.strUsedFields, ';'); ++i)
- m_plbField->InsertEntry(fmscContext.strUsedFields.getToken(i, ';'));
+ sal_Int32 nPos {0};
+ do {
+ m_plbField->InsertEntry(fmscContext.strUsedFields.getToken(0, ';', nPos));
+ } while (nPos>=0);
}
if (nContext < static_cast<sal_Int32>(m_arrContextFields.size()) && !m_arrContextFields[nContext].isEmpty())
More information about the Libreoffice-commits
mailing list