[Libreoffice-commits] core.git: 17 commits - sfx2/source svtools/source svx/source sw/source
Matteo Casalin
matteo.casalin at yahoo.com
Sat Jun 30 21:01:02 UTC 2018
sfx2/source/appl/newhelp.cxx | 28 ++++++++++--------------
svtools/source/config/printoptions.cxx | 6 -----
svtools/source/misc/imap2.cxx | 6 +----
svx/source/form/fmshimp.cxx | 5 +---
svx/source/gallery2/galbrws2.cxx | 3 --
svx/source/gallery2/gallery1.cxx | 20 ++++++++++-------
svx/source/gallery2/galmisc.cxx | 2 -
svx/source/xml/xmlgrhlp.cxx | 30 ++++++++++----------------
sw/source/core/unocore/unochart.cxx | 17 +++++++++-----
sw/source/core/unocore/unofield.cxx | 3 --
sw/source/filter/html/htmlforw.cxx | 19 +++++++++++++---
sw/source/filter/ww8/docxattributeoutput.cxx | 9 +++----
sw/source/ui/dbui/createaddresslistdialog.cxx | 13 ++++-------
13 files changed, 79 insertions(+), 82 deletions(-)
New commits:
commit 6050f9cf7b39e4d7073e1e54109e436b43dfa519
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Sat Jun 30 17:03:25 2018 +0200
Reduce number of operations on OUString
Change-Id: I5d65dd36981e6d75f0e3c0e3f00e1964d1249887
diff --git a/sfx2/source/appl/newhelp.cxx b/sfx2/source/appl/newhelp.cxx
index 0ac8ef38b41b..2d3c73a8d493 100644
--- a/sfx2/source/appl/newhelp.cxx
+++ b/sfx2/source/appl/newhelp.cxx
@@ -954,24 +954,19 @@ SearchTabPage_Impl::~SearchTabPage_Impl()
void SearchTabPage_Impl::dispose()
{
SvtViewOptions aViewOpt( EViewType::TabPage, CONFIGNAME_SEARCHPAGE );
- sal_Int32 nChecked = m_pFullWordsCB->IsChecked() ? 1 : 0;
- OUString aUserData = OUString::number( nChecked );
- aUserData += ";";
- nChecked = m_pScopeCB->IsChecked() ? 1 : 0;
- aUserData += OUString::number( nChecked );
- aUserData += ";";
+ OUString aUserData =
+ OUString::number( m_pFullWordsCB->IsChecked() ? 1 : 0 ) + ";" +
+ OUString::number( m_pScopeCB->IsChecked() ? 1 : 0 );
sal_Int32 nCount = std::min( m_pSearchED->GetEntryCount(), sal_Int32(10) ); // save only 10 entries
for ( sal_Int32 i = 0; i < nCount; ++i )
{
- OUString aText = m_pSearchED->GetEntry(i);
- aUserData += INetURLObject::encode(
- aText, INetURLObject::PART_UNO_PARAM_VALUE,
+ aUserData += ";" + INetURLObject::encode(
+ m_pSearchED->GetEntry(i),
+ INetURLObject::PART_UNO_PARAM_VALUE,
INetURLObject::EncodeMechanism::All );
- aUserData += ";";
}
- aUserData = comphelper::string::stripEnd(aUserData, ';');
Any aUserItem = makeAny( aUserData );
aViewOpt.SetUserItem( USERITEM_NAME, aUserItem );
commit fbd787dc9bf048bfc1be8eebf5920a69e34b6b75
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Sat Jun 30 16:39:46 2018 +0200
Use indexed getToken() and avoid getTokenCount()
Change-Id: I8807f8e7fd0fb76723bc4d46fa35cc346777051e
diff --git a/sfx2/source/appl/newhelp.cxx b/sfx2/source/appl/newhelp.cxx
index a8234eaa99bf..0ac8ef38b41b 100644
--- a/sfx2/source/appl/newhelp.cxx
+++ b/sfx2/source/appl/newhelp.cxx
@@ -928,16 +928,17 @@ SearchTabPage_Impl::SearchTabPage_Impl(vcl::Window* pParent, SfxHelpIndexWindow_
Any aUserItem = aViewOpt.GetUserItem( USERITEM_NAME );
if ( aUserItem >>= aUserData )
{
- bool bChecked = aUserData.getToken(0, ';').toInt32() == 1;
+ sal_Int32 nIdx {0};
+ bool bChecked = aUserData.getToken(0, ';', nIdx).toInt32() == 1;
m_pFullWordsCB->Check( bChecked );
- bChecked = aUserData.getToken(1, ';').toInt32() == 1;
+ bChecked = aUserData.getToken(0, ';', nIdx).toInt32() == 1;
m_pScopeCB->Check( bChecked );
- for ( sal_Int32 i = 2; i < comphelper::string::getTokenCount(aUserData, ';'); ++i )
+ while ( nIdx > 0 )
{
- OUString aToken = aUserData.getToken(i, ';');
m_pSearchED->InsertEntry( INetURLObject::decode(
- aToken, INetURLObject::DecodeMechanism::WithCharset ) );
+ aUserData.getToken(0, ';', nIdx),
+ INetURLObject::DecodeMechanism::WithCharset ) );
}
}
}
commit d253ee7c8b04d19e415a4fdeefdc450bdee824e2
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Sat Jun 30 12:21:22 2018 +0200
Avoid using getTokenCount() to get last token in a string
Change-Id: I8e26d07c67fe10a55717a238563dd036b94fd381
diff --git a/svtools/source/config/printoptions.cxx b/svtools/source/config/printoptions.cxx
index f5d3c178f471..af1101acd8cd 100644
--- a/svtools/source/config/printoptions.cxx
+++ b/svtools/source/config/printoptions.cxx
@@ -30,7 +30,6 @@
#include <comphelper/configurationhelper.hxx>
#include <comphelper/processfactory.hxx>
-#include <comphelper/string.hxx>
#include "itemholder2.hxx"
@@ -129,10 +128,7 @@ SvtPrintOptions_Impl::SvtPrintOptions_Impl(const OUString& rConfigRoot)
if (m_xCfg.is())
{
- using comphelper::string::getTokenCount;
- sal_Int32 nTokenCount = getTokenCount(rConfigRoot, '/');
- OUString sTok = rConfigRoot.getToken(nTokenCount - 1, '/');
- m_xCfg->getByName(sTok) >>= m_xNode;
+ m_xCfg->getByName(rConfigRoot.copy(rConfigRoot.lastIndexOf('/')+1)) >>= m_xNode;
}
}
catch (const css::uno::Exception&)
commit 7f232e3319d39e7fb8e0ba0930c20176a91d6325
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Sat Jun 30 12:05:59 2018 +0200
Constify, fix whitespaces
Change-Id: Ief4c2e01fb855ce294ecf000dfb9b9e12982e441
diff --git a/svtools/source/misc/imap2.cxx b/svtools/source/misc/imap2.cxx
index e1424f5d47b4..0bccdab00f83 100644
--- a/svtools/source/misc/imap2.cxx
+++ b/svtools/source/misc/imap2.cxx
@@ -287,12 +287,11 @@ void ImageMap::ImpReadCERNLine( const OString& rLine )
{
const sal_uInt16 nCount = comphelper::string::getTokenCount(aStr, '(') - 1;
tools::Polygon aPoly( nCount );
- OUString aURL;
for ( sal_uInt16 i = 0; i < nCount; i++ )
aPoly[ i ] = ImpReadCERNCoords( &pStr );
- aURL = ImpReadCERNURL( &pStr );
+ const OUString aURL = ImpReadCERNURL( &pStr );
maList.emplace_back( new IMapPolygonObject( aPoly, aURL, OUString(), OUString(), OUString(), OUString() ) );
}
@@ -425,8 +424,7 @@ void ImageMap::ImpReadNCSALine( const OString& rLine )
}
else if ( aToken == "poly" )
{
- const sal_uInt16 nCount = comphelper::string::getTokenCount(aStr,
- ',') - 1;
+ const sal_uInt16 nCount = comphelper::string::getTokenCount(aStr, ',') - 1;
const OUString aURL( ImpReadNCSAURL( &pStr ) );
tools::Polygon aPoly( nCount );
commit f4b1a454883b71c631516ed9fb7f32e31f177821
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Sat Jun 30 09:56:57 2018 +0200
Avoid using getTokenCount() to get last token in a string
Change-Id: I6c36394f391850baf641268912e71ebaa3504b5d
diff --git a/svx/source/form/fmshimp.cxx b/svx/source/form/fmshimp.cxx
index 033ea0f337b8..4f3f6cd4eba7 100644
--- a/svx/source/form/fmshimp.cxx
+++ b/svx/source/form/fmshimp.cxx
@@ -408,9 +408,8 @@ namespace
for (j=0; j<pCurrentArray->getLength(); ++j, ++pCurrentListeners)
{
OUString aListener = (*pCurrentListeners).getTypeName();
- sal_Int32 nTokens = comphelper::string::getTokenCount(aListener, '.');
- if (nTokens)
- aListener = aListener.getToken(nTokens - 1, '.');
+ if (!aListener.isEmpty())
+ aListener = aListener.copy(aListener.lastIndexOf('.')+1);
if (aListener == pCurrent->ListenerType)
// the current ScriptEventDescriptor doesn't match the current listeners class
commit ba437fd59da07768826a1e816ba727109d3c5d3b
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Sat Jun 30 09:50:22 2018 +0200
Avoid using getTokenCount() to get last token in a string
Change-Id: I1a2d181fdf03926452cb00f49490c9c4151dd8f9
diff --git a/svx/source/gallery2/galbrws2.cxx b/svx/source/gallery2/galbrws2.cxx
index 3570c4c703ed..4760f19dc235 100644
--- a/svx/source/gallery2/galbrws2.cxx
+++ b/svx/source/gallery2/galbrws2.cxx
@@ -18,7 +18,6 @@
*/
-#include <comphelper/string.hxx>
#include <sot/formats.hxx>
#include <svl/urlbmk.hxx>
#include <svl/stritem.hxx>
@@ -1186,7 +1185,7 @@ OUString GalleryBrowser2::GetItemText( const GalleryTheme& rTheme, const SgaObje
if( aTitle.isEmpty() )
{
aTitle = aURL.GetMainURL( INetURLObject::DecodeMechanism::Unambiguous );
- aTitle = aTitle.getToken( comphelper::string::getTokenCount(aTitle, '/') - 1, '/' );
+ aTitle = aTitle.copy( aTitle.lastIndexOf('/')+1 );
}
aRet += aTitle;
commit e07a80e23bc8249a8bf1477aeed8e33f6c4c10be
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Sat Jun 30 09:26:47 2018 +0200
Initialize local variable
Change-Id: I07583fe1fb70ffb7ec5cbeaacfdba207dac7eb0d
diff --git a/svx/source/gallery2/gallery1.cxx b/svx/source/gallery2/gallery1.cxx
index 05e2821656f2..87a8c7d3e611 100644
--- a/svx/source/gallery2/gallery1.cxx
+++ b/svx/source/gallery2/gallery1.cxx
@@ -272,7 +272,7 @@ Gallery* Gallery::GetGalleryInstance()
void Gallery::ImplLoad( const OUString& rMultiPath )
{
- bool bIsReadOnlyDir;
+ bool bIsReadOnlyDir {false};
bMultiPath = !rMultiPath.isEmpty();
commit 6a53c4f5d984d03bee8a615c8adcd518a9952833
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Sat Jun 30 09:02:43 2018 +0200
Avoid getTokenCount() + not empty OUString has at least 1 token
Change-Id: Ib8771f9621e050c100f2a319e354106bf316b24c
diff --git a/svx/source/gallery2/gallery1.cxx b/svx/source/gallery2/gallery1.cxx
index e38da7bc9a98..05e2821656f2 100644
--- a/svx/source/gallery2/gallery1.cxx
+++ b/svx/source/gallery2/gallery1.cxx
@@ -29,7 +29,6 @@
#include <sal/config.h>
#include <comphelper/processfactory.hxx>
-#include <comphelper/string.hxx>
#include <osl/thread.h>
#include <tools/vcompat.hxx>
#include <vcl/lstbox.hxx>
@@ -273,10 +272,9 @@ Gallery* Gallery::GetGalleryInstance()
void Gallery::ImplLoad( const OUString& rMultiPath )
{
- const sal_Int32 nTokenCount = comphelper::string::getTokenCount(rMultiPath, ';');
bool bIsReadOnlyDir;
- bMultiPath = ( nTokenCount > 0 );
+ bMultiPath = !rMultiPath.isEmpty();
INetURLObject aCurURL(SvtPathOptions().GetConfigPath());
ImplLoadSubDirs( aCurURL, bIsReadOnlyDir );
@@ -287,9 +285,10 @@ void Gallery::ImplLoad( const OUString& rMultiPath )
if( bMultiPath )
{
bool bIsRelURL {true};
- for( sal_Int32 i = 0; i < nTokenCount; ++i )
+ sal_Int32 nIdx {0};
+ do
{
- aCurURL = INetURLObject(rMultiPath.getToken(i, ';'));
+ aCurURL = INetURLObject(rMultiPath.getToken(0, ';', nIdx));
if (bIsRelURL)
{
aRelURL = aCurURL;
@@ -301,6 +300,7 @@ void Gallery::ImplLoad( const OUString& rMultiPath )
if( !bIsReadOnlyDir )
aUserURL = aCurURL;
}
+ while (nIdx>0);
}
else
aRelURL = INetURLObject( rMultiPath );
commit 3199a740ac543b1f8fd55146f5ae062a16a11b6b
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Sat Jun 30 08:53:44 2018 +0200
Copy INetURLObject object instead of constructing it twice
Change-Id: Ib20f96fe63218aed4055bd0175ddc9e9c71e3fb3
diff --git a/svx/source/gallery2/gallery1.cxx b/svx/source/gallery2/gallery1.cxx
index 622974c2349d..e38da7bc9a98 100644
--- a/svx/source/gallery2/gallery1.cxx
+++ b/svx/source/gallery2/gallery1.cxx
@@ -286,11 +286,15 @@ void Gallery::ImplLoad( const OUString& rMultiPath )
if( bMultiPath )
{
- aRelURL = INetURLObject( rMultiPath.getToken(0, ';') );
-
+ bool bIsRelURL {true};
for( sal_Int32 i = 0; i < nTokenCount; ++i )
{
aCurURL = INetURLObject(rMultiPath.getToken(i, ';'));
+ if (bIsRelURL)
+ {
+ aRelURL = aCurURL;
+ bIsRelURL = false;
+ }
ImplLoadSubDirs( aCurURL, bIsReadOnlyDir );
commit f897da3f2d5326cc74d7c656f6d55d8449a24807
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Sun Jun 24 19:20:00 2018 +0200
Avoid getTokenCount()
Change-Id: Ia3c7657a89187ff21fca6d07c27ba260a0be36d8
diff --git a/svx/source/gallery2/galmisc.cxx b/svx/source/gallery2/galmisc.cxx
index 99b2b2628537..0fbeebe1e869 100644
--- a/svx/source/gallery2/galmisc.cxx
+++ b/svx/source/gallery2/galmisc.cxx
@@ -169,7 +169,7 @@ OUString GetReducedString( const INetURLObject& rURL, sal_Int32 nMaxLen )
{
OUString aReduced( rURL.GetMainURL( INetURLObject::DecodeMechanism::Unambiguous ) );
- aReduced = aReduced.getToken( comphelper::string::getTokenCount(aReduced, '/') - 1, '/' );
+ aReduced = aReduced.copy(aReduced.lastIndexOf('/')+1);
if( INetProtocol::PrivSoffice != rURL.GetProtocol() )
{
commit ab1e5f514c6f7d9ca482fe628b38e00d51c1e4a5
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Sun Jun 24 19:14:36 2018 +0200
Bail out early and reduce temporaries
Change-Id: I78e3d50f0bcbbb482ce79bbb1f14885e1e412569
diff --git a/svx/source/xml/xmlgrhlp.cxx b/svx/source/xml/xmlgrhlp.cxx
index cd785f8d0e1d..4063179e9082 100644
--- a/svx/source/xml/xmlgrhlp.cxx
+++ b/svx/source/xml/xmlgrhlp.cxx
@@ -397,26 +397,22 @@ bool SvXMLGraphicHelper::ImplGetStreamNames( const OUString& rURLStr,
OUString& rPictureStorageName,
OUString& rPictureStreamName )
{
- OUString aURLStr( rURLStr );
- bool bRet = false;
+ if (rURLStr.isEmpty())
+ return false;
- if( !aURLStr.isEmpty() )
- {
- aURLStr = aURLStr.copy(aURLStr.lastIndexOf(':')+1);
-
- if( comphelper::string::getTokenCount(aURLStr, '/') == 1 )
- {
- rPictureStorageName = XML_GRAPHICSTORAGE_NAME;
- rPictureStreamName = aURLStr;
- }
- else
- SvXMLEmbeddedObjectHelper::splitObjectURL(aURLStr, rPictureStorageName, rPictureStreamName);
+ const OUString aURLStr {rURLStr.copy(rURLStr.lastIndexOf(':')+1)};
- bRet = !rPictureStreamName.isEmpty();
- SAL_WARN_IF(!bRet, "svx", "SvXMLGraphicHelper::ImplInsertGraphicURL: invalid scheme: " << rURLStr);
+ if( comphelper::string::getTokenCount(aURLStr, '/') == 1 )
+ {
+ rPictureStorageName = XML_GRAPHICSTORAGE_NAME;
+ rPictureStreamName = aURLStr;
}
+ else
+ SvXMLEmbeddedObjectHelper::splitObjectURL(aURLStr, rPictureStorageName, rPictureStreamName);
+
+ SAL_WARN_IF(rPictureStreamName.isEmpty(), "svx", "SvXMLGraphicHelper::ImplInsertGraphicURL: invalid scheme: " << rURLStr);
- return bRet;
+ return !rPictureStreamName.isEmpty();
}
uno::Reference < embed::XStorage > SvXMLGraphicHelper::ImplGetGraphicStorage( const OUString& rStorageName )
commit 842bb20958af0a1a8af7e0403142fe3cf0112731
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Sun Jun 24 18:28:34 2018 +0200
Avoid getTokenCount()
Change-Id: If884a9eb09b55836995d04cd82832d3f79d6531c
diff --git a/svx/source/xml/xmlgrhlp.cxx b/svx/source/xml/xmlgrhlp.cxx
index 8d010850165c..cd785f8d0e1d 100644
--- a/svx/source/xml/xmlgrhlp.cxx
+++ b/svx/source/xml/xmlgrhlp.cxx
@@ -402,11 +402,9 @@ bool SvXMLGraphicHelper::ImplGetStreamNames( const OUString& rURLStr,
if( !aURLStr.isEmpty() )
{
- aURLStr = aURLStr.getToken( comphelper::string::getTokenCount(aURLStr, ':') - 1, ':' );
+ aURLStr = aURLStr.copy(aURLStr.lastIndexOf(':')+1);
- const sal_uInt32 nTokenCount = comphelper::string::getTokenCount(aURLStr, '/');
-
- if( 1 == nTokenCount )
+ if( comphelper::string::getTokenCount(aURLStr, '/') == 1 )
{
rPictureStorageName = XML_GRAPHICSTORAGE_NAME;
rPictureStreamName = aURLStr;
commit 5fa9aa1c8f5b9a3245a0cb23f689fecb563dd31f
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Sun Jun 24 12:09:11 2018 +0200
Avoid getTokenCount()
Change-Id: Ia56f125151aa96d014e348b6d022b45138f732c9
diff --git a/sw/source/ui/dbui/createaddresslistdialog.cxx b/sw/source/ui/dbui/createaddresslistdialog.cxx
index b0dcf5962536..a43be61db108 100644
--- a/sw/source/ui/dbui/createaddresslistdialog.cxx
+++ b/sw/source/ui/dbui/createaddresslistdialog.cxx
@@ -25,7 +25,6 @@
#include "createaddresslistdialog.hxx"
#include "customizeaddresslistdialog.hxx"
#include <mmconfigitem.hxx>
-#include <comphelper/string.hxx>
#include <vcl/scrbar.hxx>
#include <vcl/builderfactory.hxx>
#include <svtools/controldims.hxx>
@@ -438,12 +437,10 @@ SwCreateAddressListDialog::SwCreateAddressListDialog(
OUString sLine;
bool bRead = pStream->ReadByteStringLine( sLine, RTL_TEXTENCODING_UTF8 );
- if(bRead)
+ if(bRead && !sLine.isEmpty())
{
- //header line
- sal_Int32 nHeaders = comphelper::string::getTokenCount(sLine, '\t');
sal_Int32 nIndex = 0;
- for( sal_Int32 nToken = 0; nToken < nHeaders; ++nToken)
+ do
{
const OUString sHeader = sLine.getToken( 0, '\t', nIndex );
OSL_ENSURE(sHeader.getLength() > 2 &&
@@ -454,14 +451,14 @@ SwCreateAddressListDialog::SwCreateAddressListDialog(
m_pCSVData->aDBColumnHeaders.push_back( sHeader.copy(1, sHeader.getLength() -2));
}
}
+ while (nIndex > 0);
}
while(pStream->ReadByteStringLine( sLine, RTL_TEXTENCODING_UTF8 ))
{
std::vector<OUString> aNewData;
//analyze data line
- sal_Int32 nDataCount = comphelper::string::getTokenCount(sLine, '\t');
- sal_Int32 nIndex = 0;
- for( sal_Int32 nToken = 0; nToken < nDataCount; ++nToken)
+ sal_Int32 nIndex = { sLine.isEmpty() ? -1 : 0 };
+ while (nIndex >= 0)
{
const OUString sData = sLine.getToken( 0, '\t', nIndex );
OSL_ENSURE( sData.startsWith("\"") && sData.endsWith("\""),
commit 5b07f513cb758ec831e80f3e4dc1819445cdfb51
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Sun Jun 24 12:07:11 2018 +0200
Avoid getTokenCount()
Change-Id: Ia878affbdcb9674675619f34a423ac6c9a90b16d
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index ec2030f55507..3671060f4d52 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -1789,11 +1789,10 @@ void DocxAttributeOutput::CmdField_Impl( const SwTextNode* pNode, sal_Int32 nPos
DoWriteFieldRunProperties( pNode, nPos, bWriteCombChars );
}
- sal_Int32 nNbToken = comphelper::string::getTokenCount(rInfos.sCmd, '\t');
-
- for ( sal_Int32 i = 0; i < nNbToken; i++ )
+ sal_Int32 nIdx { rInfos.sCmd.isEmpty() ? -1 : 0 };
+ while ( nIdx >= 0 )
{
- OUString sToken = rInfos.sCmd.getToken( i, '\t' );
+ OUString sToken = rInfos.sCmd.getToken( 0, '\t', nIdx );
if ( rInfos.eType == ww::eCREATEDATE
|| rInfos.eType == ww::eSAVEDATE
|| rInfos.eType == ww::ePRINTDATE
@@ -1808,7 +1807,7 @@ void DocxAttributeOutput::CmdField_Impl( const SwTextNode* pNode, sal_Int32 nPos
DoWriteCmd( sToken );
// Replace tabs by </instrText><tab/><instrText>
- if ( i < ( nNbToken - 1 ) )
+ if ( nIdx > 0 ) // Is another token expected?
RunText( "\t" );
}
commit 4db69a8343ae7a26a827ec43225922c01ac2b5ef
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Sun Jun 24 11:54:40 2018 +0200
Avoid getTokenCount()
Change-Id: I2a1b034ba6b587664ce94560e88af5acb860788d
diff --git a/sw/source/filter/html/htmlforw.cxx b/sw/source/filter/html/htmlforw.cxx
index 710846dc9f7c..97636e64efff 100644
--- a/sw/source/filter/html/htmlforw.cxx
+++ b/sw/source/filter/html/htmlforw.cxx
@@ -28,7 +28,6 @@
#include <com/sun/star/form/XForm.hpp>
#include <com/sun/star/form/FormComponentType.hpp>
#include <com/sun/star/awt/XTextLayoutConstrains.hpp>
-#include <comphelper/string.hxx>
#include <hintids.hxx>
#include <o3tl/any.hxx>
#include <vcl/svapp.hxx>
@@ -144,9 +143,21 @@ static void lcl_html_outEvents( SvStream& rStrm,
continue;
OUString sListener( pDescs[i].ListenerType );
- sal_Int32 nTok = comphelper::string::getTokenCount(sListener, '.');
- if( nTok )
- sListener = sListener.getToken( nTok-1, '.' );
+ if (!sListener.isEmpty())
+ {
+ const sal_Int32 nIdx { sListener.lastIndexOf('.')+1 };
+ if (nIdx>0)
+ {
+ if (nIdx<sListener.getLength())
+ {
+ sListener = sListener.copy(nIdx);
+ }
+ else
+ {
+ sListener.clear();
+ }
+ }
+ }
OUString sMethod( pDescs[i].EventMethod );
const sal_Char *pOpt = nullptr;
commit 21c839d6f69fbddb7850444187eecec1f4f2f27f
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Sun Jun 24 11:52:47 2018 +0200
Not empty OUString has at least one token
Change-Id: I02dd1c045af1367ae56eeb60dad23912111dcd6f
diff --git a/sw/source/core/unocore/unofield.cxx b/sw/source/core/unocore/unofield.cxx
index 00c8677a5136..97bfb73358b9 100644
--- a/sw/source/core/unocore/unofield.cxx
+++ b/sw/source/core/unocore/unofield.cxx
@@ -2680,8 +2680,7 @@ static SwFieldIds lcl_GetIdByName( OUString& rName, OUString& rTypeName )
else if (rTypeName.equalsIgnoreAsciiCase("DataBase"))
{
rName = rName.copy(RTL_CONSTASCII_LENGTH("DataBase."));
- const sal_Int32 nDotCount = comphelper::string::getTokenCount(rName, '.');
- if( 1 <= nDotCount )
+ if (!rName.isEmpty())
{
// #i51815#
rName = "DataBase." + rName;
commit 051d4fdaea9321732a141db16f61dfd9af744303
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Sun Jun 24 11:45:14 2018 +0200
Avoid getTokenCount
Change-Id: I9bbfa1280857e3aaaac78402432001d4b48cd73a
diff --git a/sw/source/core/unocore/unochart.cxx b/sw/source/core/unocore/unochart.cxx
index fd5a2a883484..c76d85fb1a45 100644
--- a/sw/source/core/unocore/unochart.cxx
+++ b/sw/source/core/unocore/unochart.cxx
@@ -434,7 +434,7 @@ static bool GetSubranges( const OUString &rRangeRepresentation,
uno::Sequence< OUString > &rSubRanges, bool bNormalize )
{
bool bRes = true;
- sal_Int32 nLen = comphelper::string::getTokenCount(rRangeRepresentation, ';');
+ const sal_Int32 nLen = comphelper::string::getTokenCount(rRangeRepresentation, ';');
uno::Sequence< OUString > aRanges( nLen );
sal_Int32 nCnt = 0;
@@ -1685,15 +1685,16 @@ OUString SAL_CALL SwChartDataProvider::convertRangeToXML( const OUString& rRange
if (bDisposed)
throw lang::DisposedException();
+ if (rRangeRepresentation.isEmpty())
+ return OUString();
+
OUString aRes;
// multiple ranges are delimited by a ';' like in
// "Table1.A1:A4;Table1.C2:C5" the same table must be used in all ranges!
- sal_Int32 nNumRanges = comphelper::string::getTokenCount(rRangeRepresentation, ';');
SwTable* pFirstFoundTable = nullptr; // to check that only one table will be used
sal_Int32 nPos = 0;
- for (sal_Int32 i = 0; i < nNumRanges; ++i)
- {
+ do {
const OUString aRange( rRangeRepresentation.getToken(0, ';', nPos) );
SwFrameFormat *pTableFormat = nullptr; // pointer to table format
std::shared_ptr<SwUnoCursor> pCursor;
@@ -1743,6 +1744,7 @@ OUString SAL_CALL SwChartDataProvider::convertRangeToXML( const OUString& rRange
aRes += " ";
aRes += aTmp;
}
+ while (nPos>0);
return aRes;
}
@@ -1753,14 +1755,16 @@ OUString SAL_CALL SwChartDataProvider::convertRangeFromXML( const OUString& rXML
if (bDisposed)
throw lang::DisposedException();
+ if (rXMLRange.isEmpty())
+ return OUString();
+
OUString aRes;
// multiple ranges are delimited by a ' ' like in
// "Table1.$A$1:.$A$4 Table1.$C$2:.$C$5" the same table must be used in all ranges!
- sal_Int32 nNumRanges = comphelper::string::getTokenCount(rXMLRange, ' ');
OUString aFirstFoundTable; // to check that only one table will be used
sal_Int32 nPos = 0;
- for (sal_Int32 i = 0; i < nNumRanges; ++i)
+ do
{
OUString aRange( rXMLRange.getToken(0, ' ', nPos) );
@@ -1789,6 +1793,7 @@ OUString SAL_CALL SwChartDataProvider::convertRangeFromXML( const OUString& rXML
aRes += ";";
aRes += aTmp;
}
+ while (nPos>0);
return aRes;
}
More information about the Libreoffice-commits
mailing list