From c958f52b813d34baa9b5236bb34a08a04e6b0aba Mon Sep 17 00:00:00 2001 From: Balazs Varga Date: Thu, 9 Aug 2018 00:06:47 +0200 Subject: tdf#96469 Export Data Point properties in Charts on DOCX/XLSX If the color or other property of a datapoint in the chart deviates from the dataseries property, this patch will write it into a separate dPt tag and fixing the lost properies during OOXML export. Change-Id: I3d975675ac3691fcafe76de16e46851561eb2807 Reviewed-on: https://gerrit.libreoffice.org/58752 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek --- oox/source/export/chartexport.cxx | 51 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) (limited to 'oox') diff --git a/oox/source/export/chartexport.cxx b/oox/source/export/chartexport.cxx index 2ef2074aa068..654ffdbfb008 100644 --- a/oox/source/export/chartexport.cxx +++ b/oox/source/export/chartexport.cxx @@ -3284,6 +3284,57 @@ void ChartExport::exportDataPoints( } } } + + // Export Data Point Property in Charts even if the VaryColors is false + if( !bVaryColorsByPoint ) + { + ::std::set< sal_Int32 > aAttrPointSet; + ::std::copy( pPoints, pPoints + aDataPointSeq.getLength(), + ::std::inserter( aAttrPointSet, aAttrPointSet.begin())); + const ::std::set< sal_Int32 >::const_iterator aEndIt( aAttrPointSet.end()); + for( nElement = 0; nElement < nSeriesLength; ++nElement ) + { + uno::Reference< beans::XPropertySet > xPropSet; + if( aAttrPointSet.find( nElement ) != aEndIt ) + { + try + { + xPropSet = SchXMLSeriesHelper::createOldAPIDataPointPropertySet( + xSeries, nElement, getModel() ); + } + catch( const uno::Exception & ) + { + DBG_UNHANDLED_EXCEPTION( "oox", "Exception caught during Export of data point" ); + } + } + + if( xPropSet.is() ) + { + FSHelperPtr pFS = GetFS(); + pFS->startElement( FSNS( XML_c, XML_dPt ), + FSEND ); + pFS->singleElement( FSNS( XML_c, XML_idx ), + XML_val, I32S(nElement), + FSEND ); + + switch( eChartType ) + { + case chart::TYPEID_BUBBLE: + case chart::TYPEID_HORBAR: + case chart::TYPEID_BAR: + { + pFS->singleElement(FSNS(XML_c, XML_invertIfNegative), + XML_val, "0", + FSEND); + } + break; + } + exportShapeProps( xPropSet ); + + pFS->endElement( FSNS( XML_c, XML_dPt ) ); + } + } + } } void ChartExport::exportAxesId(bool bPrimaryAxes) -- cgit