summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFridrich Štrba <fridrich.strba@bluewin.ch>2013-05-30 11:46:35 +0200
committerDavid Tardon <dtardon@redhat.com>2013-05-31 07:30:40 +0000
commitdb145ca43064ea46ed47dceada3052a105267140 (patch)
treed78177c2b06d08f4a10c3172dfd31e824845ce9f
parentb453554ce529a99e47e10fb8d631d19a56e4a458 (diff)
Fix crash with fdo60063-1.docx
Compared to the original version, this one tries hard not to produce empty keywords. Reviewed-on: https://gerrit.libreoffice.org/4091 Reviewed-by: Fridrich Strba <fridrich@documentfoundation.org> Tested-by: Fridrich Strba <fridrich@documentfoundation.org> (cherry picked from commit b2f97d77237cde249b4c40acc8ad3f7f8755e768) (cherry picked from commit 693707e338922d8dc7578975a1990e8a1cba6a53) Conflicts: oox/source/docprop/docprophandler.cxx Change-Id: I11d036c2d54cde2d3c311a77c115011246f38d0a Reviewed-on: https://gerrit.libreoffice.org/4093 Reviewed-by: Miklos Vajna <vmiklos@suse.cz> Tested-by: Miklos Vajna <vmiklos@suse.cz> (cherry picked from commit d60f81a3e9d020ff1ae0db2e73551bff45c43256) Reviewed-on: https://gerrit.libreoffice.org/4103 Reviewed-by: Luboš Luňák <l.lunak@suse.cz> Reviewed-by: David Tardon <dtardon@redhat.com> Tested-by: David Tardon <dtardon@redhat.com>
-rw-r--r--oox/source/docprop/docprophandler.cxx41
1 files changed, 13 insertions, 28 deletions
diff --git a/oox/source/docprop/docprophandler.cxx b/oox/source/docprop/docprophandler.cxx
index 106731586af5..ff6d1705e6cd 100644
--- a/oox/source/docprop/docprophandler.cxx
+++ b/oox/source/docprop/docprophandler.cxx
@@ -25,6 +25,9 @@
#include <osl/time.h>
+#include <vector>
+#include <boost/algorithm/string.hpp>
+
#include "oox/helper/attributelist.hxx"
using namespace ::com::sun::star;
@@ -157,39 +160,21 @@ uno::Sequence< ::rtl::OUString > OOXMLDocPropHandler::GetKeywordsSet( const ::rt
{
if ( !aChars.isEmpty() )
{
- uno::Sequence< ::rtl::OUString > aResult( 20 );
- sal_Int32 nCounter = 0;
+ std::string aUtf8Chars = rtl::OUStringToOString( aChars, RTL_TEXTENCODING_UTF8 ).getStr();
+ std::vector<std::string> aUtf8Result;
+ boost::split( aUtf8Result, aUtf8Chars, boost::is_any_of(" ,;:\t"), boost::token_compress_on );
- const sal_Unicode* pStr = aChars.getStr();
- for( sal_Int32 nInd = 0; nInd < aChars.getLength() && pStr[nInd] != 0; nInd++ )
+ if (!aUtf8Result.empty())
{
- switch( pStr[nInd] )
- {
- case (sal_Unicode)' ':
- case (sal_Unicode)',':
- case (sal_Unicode)';':
- 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;
+ uno::Sequence< rtl::OUString > aResult( aUtf8Result.size() );
+ OUString* pResultValues = aResult.getArray();
+ for ( std::vector< std::string >::const_iterator i = aUtf8Result.begin();
+ i != aUtf8Result.end(); ++i, ++pResultValues )
+ *pResultValues = rtl::OUString( i->c_str(), static_cast< sal_Int32 >( i->size() ),RTL_TEXTENCODING_UTF8 );
- default:
- // this should be a part of keyword
- aResult[nCounter] += ::rtl::OUString( (sal_Unicode)pStr[nInd] );
- }
+ return aResult;
}
-
- aResult.realloc( nCounter + 1 );
- return aResult;
}
-
return uno::Sequence< ::rtl::OUString >();
}
// ------------------------------------------------