Kaydet (Commit) 088cb5c3 authored tarafından Matteo Casalin's avatar Matteo Casalin

Avoid getTokenCount

Change-Id: I60d11dab9bc04462cf3cc0412a356ec51212fb6e
üst 8a5d742a
...@@ -47,7 +47,6 @@ ...@@ -47,7 +47,6 @@
#include <com/sun/star/style/VerticalAlignment.hpp> #include <com/sun/star/style/VerticalAlignment.hpp>
#include <com/sun/star/table/CellAddress.hpp> #include <com/sun/star/table/CellAddress.hpp>
#include <com/sun/star/table/CellRangeAddress.hpp> #include <com/sun/star/table/CellRangeAddress.hpp>
#include <comphelper/string.hxx>
#include <rtl/tencinfo.h> #include <rtl/tencinfo.h>
#include <osl/diagnose.h> #include <osl/diagnose.h>
#include <sal/log.hxx> #include <sal/log.hxx>
...@@ -2550,30 +2549,32 @@ HtmlSelectModel::HtmlSelectModel() ...@@ -2550,30 +2549,32 @@ HtmlSelectModel::HtmlSelectModel()
bool bool
HtmlSelectModel::importBinaryModel( BinaryInputStream& rInStrm ) 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 // replace crlf with lf
data = data.replaceAll( "\x0D\x0A" , "\x0A" ); OUString data = sStringContents.replaceAll( "\x0D\x0A" , "\x0A" );
std::vector< OUString > listValues; std::vector< OUString > listValues;
std::vector< sal_Int16 > selectedIndices; std::vector< sal_Int16 > selectedIndices;
// Ultra hacky parser for the info // Ultra hacky parser for the info
sal_Int32 nTokenCount = comphelper::string::getTokenCount(data, '\n'); sal_Int32 nLineIdx {0};
// first line will tell us if multiselect is enabled
for ( sal_Int32 nToken = 0; nToken < nTokenCount; ++nToken ) 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' ) ); for (;;)
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)
{ {
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, '>' ); OUString displayValue = sLine.getToken( 1, '>' );
if ( displayValue.getLength() ) if ( displayValue.getLength() )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment