summaryrefslogtreecommitdiff
path: root/oox/source
diff options
context:
space:
mode:
authorMatteo Casalin <matteo.casalin@yahoo.com>2018-08-12 23:06:10 +0200
committerMatteo Casalin <matteo.casalin@yahoo.com>2018-09-09 21:07:53 +0200
commit088cb5c33fc78606e1db9fef6d33f77e63bf7b24 (patch)
treec26127c26b12e8fea354f3f72cdc9cf141f5b78e /oox/source
parent8a5d742accb7ec316bfc66743d9c3cba0fa9a9b4 (diff)
Avoid getTokenCount
Change-Id: I60d11dab9bc04462cf3cc0412a356ec51212fb6e
Diffstat (limited to 'oox/source')
-rw-r--r--oox/source/ole/axcontrol.cxx33
1 files changed, 17 insertions, 16 deletions
diff --git a/oox/source/ole/axcontrol.cxx b/oox/source/ole/axcontrol.cxx
index 3525e4f4d9a7..2eab7a0fa861 100644
--- a/oox/source/ole/axcontrol.cxx
+++ b/oox/source/ole/axcontrol.cxx
@@ -47,7 +47,6 @@
#include <com/sun/star/style/VerticalAlignment.hpp>
#include <com/sun/star/table/CellAddress.hpp>
#include <com/sun/star/table/CellRangeAddress.hpp>
-#include <comphelper/string.hxx>
#include <rtl/tencinfo.h>
#include <osl/diagnose.h>
#include <sal/log.hxx>
@@ -2550,30 +2549,32 @@ HtmlSelectModel::HtmlSelectModel()
bool
HtmlSelectModel::importBinaryModel( BinaryInputStream& rInStrm )
{
- OUString sStringContents = rInStrm.readUnicodeArray( rInStrm.size() );
+ if (rInStrm.size()<=0)
+ return true;
- OUString data = sStringContents;
+ OUString sStringContents = rInStrm.readUnicodeArray( rInStrm.size() );
// replace crlf with lf
- data = data.replaceAll( "\x0D\x0A" , "\x0A" );
+ OUString data = sStringContents.replaceAll( "\x0D\x0A" , "\x0A" );
+
std::vector< OUString > listValues;
std::vector< sal_Int16 > selectedIndices;
// Ultra hacky parser for the info
- sal_Int32 nTokenCount = comphelper::string::getTokenCount(data, '\n');
-
- for ( sal_Int32 nToken = 0; nToken < nTokenCount; ++nToken )
+ sal_Int32 nLineIdx {0};
+ // first line will tell us if multiselect is enabled
+ if (data.getToken( 0, '\n', nLineIdx )=="<SELECT MULTIPLE")
+ mnMultiSelect = AX_SELECTION_MULTI;
+ // skip first and last lines, no data there
+ if (nLineIdx>0)
{
- OUString sLine( data.getToken( nToken, '\n' ) );
- if ( !nToken ) // first line will tell us if multiselect is enabled
- {
- if ( sLine == "<SELECT MULTIPLE" )
- mnMultiSelect = AX_SELECTION_MULTI;
- }
- // skip first and last lines, no data there
- else if ( nToken < nTokenCount - 1)
+ for (;;)
{
- if ( comphelper::string::getTokenCount(sLine, '>') )
+ OUString sLine( data.getToken( 0, '\n', nLineIdx ) );
+ if (nLineIdx<0)
+ break; // skip last line
+
+ if ( !sLine.isEmpty() )
{
OUString displayValue = sLine.getToken( 1, '>' );
if ( displayValue.getLength() )