From acf7d8d1ab6fe6ad0fb8a5d1ad2d2ef53f578757 Mon Sep 17 00:00:00 2001 From: Julien Nabet Date: Wed, 18 Nov 2020 21:56:25 +0100 Subject: Avoid wrong warning in OElementImport::implApplyGenericProperties (xmloff) When empty sequence, there's nothing to convert so no need to spend time here and to indicate the following warning: Avoid warn:legacy.osl:93722:93722:xmloff/source/forms/elementimport.cxx:364: OElementImport::implApplyGenericProperties: conversion to sequences other than 'sequence< short >' not implemented, yet! + avoid these in the same time: warn:xmloff.forms:88800:88800:xmloff/source/forms/elementimport.cxx:428: DBG_UNHANDLED_EXCEPTION in implApplyGenericProperties exception: com.sun.star.lang.IllegalArgumentException message: /home/julien/lo/libreoffice/include/cppuhelper/proptypehlp.hxx:35 ArgumentPosition: 0 In addition, convert 2 OSL_ENSURE of this block in SAL_WARN_IF Change-Id: I047eb5afba6fd22249010791aa61ebd1f83f3c67 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106082 Tested-by: Jenkins Reviewed-by: Noel Grandin --- xmloff/source/forms/elementimport.cxx | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'xmloff') diff --git a/xmloff/source/forms/elementimport.cxx b/xmloff/source/forms/elementimport.cxx index 1fac083e463c..42a151c9354b 100644 --- a/xmloff/source/forms/elementimport.cxx +++ b/xmloff/source/forms/elementimport.cxx @@ -356,16 +356,21 @@ namespace xmloff if ( bValueIsSequence ) { - OSL_ENSURE( eValueTypeClass == TypeClass_ANY, + Sequence< Any > aXMLValueList; + rPropValues.Value >>= aXMLValueList; + // just skip this part if empty sequence + if (!aXMLValueList.getLength()) + continue; + + Sequence< sal_Int16 > aPropertyValueList( aXMLValueList.getLength() ); + + SAL_WARN_IF( eValueTypeClass != TypeClass_ANY, "xmloff", "OElementImport::implApplyGenericProperties: only ANYs should have been imported as generic list property!" ); // (OPropertyImport should produce only Sequencer< Any >, since it cannot know the real type - OSL_ENSURE( ePropTypeClass == TypeClass_SHORT, + SAL_WARN_IF( ePropTypeClass != TypeClass_SHORT, "xmloff", "OElementImport::implApplyGenericProperties: conversion to sequences other than 'sequence< short >' not implemented, yet!" ); - Sequence< Any > aXMLValueList; - rPropValues.Value >>= aXMLValueList; - Sequence< sal_Int16 > aPropertyValueList( aXMLValueList.getLength() ); std::transform(aXMLValueList.begin(), aXMLValueList.end(), aPropertyValueList.begin(), [](const Any& rXMLValue) -> sal_Int16 { -- cgit v1.2.3