summaryrefslogtreecommitdiff
path: root/xmloff
diff options
context:
space:
mode:
authorMatteo Casalin <matteo.casalin@yahoo.com>2018-12-30 15:35:33 +0100
committerMatteo Casalin <matteo.casalin@yahoo.com>2019-01-18 23:30:59 +0100
commitf7923deee042a39d5328987e579b1ac60c6c4186 (patch)
treed4eb83a60fd5175e653b3e492954575e270c5582 /xmloff
parent284e998aae8f65857a6ef8df965e03910fc4bef0 (diff)
Use getTokenCount instead of custom code
Change-Id: Ie6f097984950d306453f0735eb299cfa65d4d74e Reviewed-on: https://gerrit.libreoffice.org/66225 Tested-by: Jenkins Reviewed-by: Matteo Casalin <matteo.casalin@yahoo.com>
Diffstat (limited to 'xmloff')
-rw-r--r--xmloff/source/draw/animationimport.cxx42
1 files changed, 7 insertions, 35 deletions
diff --git a/xmloff/source/draw/animationimport.cxx b/xmloff/source/draw/animationimport.cxx
index ccf3dfb39325..814871c22f05 100644
--- a/xmloff/source/draw/animationimport.cxx
+++ b/xmloff/source/draw/animationimport.cxx
@@ -48,6 +48,7 @@
#include <com/sun/star/presentation/EffectCommands.hpp>
#include <com/sun/star/util/Duration.hpp>
#include <comphelper/processfactory.hxx>
+#include <comphelper/string.hxx>
#include <sax/tools/converter.hxx>
@@ -320,24 +321,6 @@ static bool isTime( const OUString& rValue )
return (nLength == 0) || ((*pStr == 's' || *pStr == 'S') && (nLength == 1));
}
-static sal_Int32 count_codes( const OUString& rString, sal_Unicode nCode )
-{
- sal_Int32 nCount = 0;
- sal_Int32 fromIndex = 0;
-
- while(true)
- {
- fromIndex = rString.indexOf( nCode, fromIndex );
- if( fromIndex == -1 )
- break;
-
- fromIndex++;
- nCount++;
- }
-
- return nCount;
-}
-
Any AnimationsImportHelperImpl::convertTarget( const OUString& rValue )
{
try
@@ -466,11 +449,9 @@ Sequence< Any > AnimationsImportHelperImpl::convertValueSequence( XMLTokenEnum e
{
Sequence< Any > aValues;
- // do we have any value at all?
- if( !rValue.isEmpty() )
+ const sal_Int32 nElements { comphelper::string::getTokenCount(rValue, ';') };
+ if ( nElements>0 )
{
- sal_Int32 nElements = count_codes( rValue, ';') + 1; // a non empty string has at least one value
-
// prepare the sequence
aValues.realloc( nElements );
@@ -487,12 +468,9 @@ Any AnimationsImportHelperImpl::convertTiming( const OUString& rValue )
{
Any aAny;
- // do we have any value at all?
- if( !rValue.isEmpty() )
+ const sal_Int32 nElements { comphelper::string::getTokenCount(rValue, ';') };
+ if ( nElements>0 )
{
- // count the values
- sal_Int32 nElements = count_codes( rValue, ';' ) + 1; // a non empty string has at least one value
-
if( nElements == 1 )
{
if( IsXMLToken( rValue, XML_MEDIA ) )
@@ -564,10 +542,7 @@ Any AnimationsImportHelperImpl::convertTiming( const OUString& rValue )
Sequence< double > AnimationsImportHelperImpl::convertKeyTimes( const OUString& rValue )
{
- sal_Int32 nElements = 0;
-
- if( !rValue.isEmpty() )
- nElements = count_codes( rValue, ';' ) + 1; // a non empty string has at least one value
+ const sal_Int32 nElements { comphelper::string::getTokenCount(rValue, ';') };
Sequence< double > aKeyTimes( nElements );
@@ -583,10 +558,7 @@ Sequence< double > AnimationsImportHelperImpl::convertKeyTimes( const OUString&
Sequence< TimeFilterPair > AnimationsImportHelperImpl::convertTimeFilter( const OUString& rValue )
{
- sal_Int32 nElements = 0;
-
- if( !rValue.isEmpty() )
- nElements = count_codes( rValue, ';' ) + 1; // a non empty string has at least one value
+ const sal_Int32 nElements { comphelper::string::getTokenCount(rValue, ';') };
Sequence< TimeFilterPair > aTimeFilter( nElements );