Fix crash with fdo60063-1.docx
Compared to the original version, this one tries hard not to produce empty keywords. Change-Id: I11d036c2d54cde2d3c311a77c115011246f38d0a Reviewed-on: https://gerrit.libreoffice.org/4091 Reviewed-by: Fridrich Strba <fridrich@documentfoundation.org> Tested-by: Fridrich Strba <fridrich@documentfoundation.org>
This commit is contained in:
committed by
Fridrich Strba
parent
51c18e8e80
commit
b2f97d7723
@@ -25,6 +25,8 @@
|
|||||||
|
|
||||||
#include <osl/time.h>
|
#include <osl/time.h>
|
||||||
|
|
||||||
|
#include <boost/algorithm/string.hpp>
|
||||||
|
|
||||||
#include "oox/helper/attributelist.hxx"
|
#include "oox/helper/attributelist.hxx"
|
||||||
|
|
||||||
using namespace ::com::sun::star;
|
using namespace ::com::sun::star;
|
||||||
@@ -158,39 +160,21 @@ uno::Sequence< OUString > OOXMLDocPropHandler::GetKeywordsSet( const OUString& a
|
|||||||
{
|
{
|
||||||
if ( !aChars.isEmpty() )
|
if ( !aChars.isEmpty() )
|
||||||
{
|
{
|
||||||
uno::Sequence< OUString > aResult( 20 );
|
std::string aUtf8Chars = OUStringToOString( aChars, RTL_TEXTENCODING_UTF8 ).getStr();
|
||||||
sal_Int32 nCounter = 0;
|
std::vector<std::string> aUtf8Result;
|
||||||
|
boost::split( aUtf8Result, aUtf8Chars, boost::is_any_of(" ,;:\t"), boost::token_compress_on );
|
||||||
|
|
||||||
const sal_Unicode* pStr = aChars.getStr();
|
if (!aUtf8Result.empty())
|
||||||
for( sal_Int32 nInd = 0; nInd < aChars.getLength() && pStr[nInd] != 0; nInd++ )
|
|
||||||
{
|
{
|
||||||
switch( pStr[nInd] )
|
uno::Sequence< OUString > aResult( aUtf8Result.size() );
|
||||||
{
|
OUString* pResultValues = aResult.getArray();
|
||||||
case (sal_Unicode)' ':
|
for ( std::vector< std::string >::const_iterator i = aUtf8Result.begin();
|
||||||
case (sal_Unicode)',':
|
i != aUtf8Result.end(); ++i, ++pResultValues )
|
||||||
case (sal_Unicode)';':
|
*pResultValues = OUString( i->c_str(), static_cast< sal_Int32 >( i->size() ),RTL_TEXTENCODING_UTF8 );
|
||||||
case (sal_Unicode)':':
|
|
||||||
case (sal_Unicode)'\t':
|
|
||||||
// this is a delimiter
|
|
||||||
// unfortunately I did not find any specification for the possible delimiters
|
|
||||||
if ( !aResult[nCounter].isEmpty() )
|
|
||||||
{
|
|
||||||
if ( nCounter >= aResult.getLength() )
|
|
||||||
aResult.realloc( nCounter + 10 );
|
|
||||||
nCounter++;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
return aResult;
|
||||||
// this should be a part of keyword
|
|
||||||
aResult[nCounter] += OUString( (sal_Unicode)pStr[nInd] );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
aResult.realloc( nCounter + 1 );
|
|
||||||
return aResult;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return uno::Sequence< OUString >();
|
return uno::Sequence< OUString >();
|
||||||
}
|
}
|
||||||
// ------------------------------------------------
|
// ------------------------------------------------
|
||||||
|
Reference in New Issue
Block a user