From f6437b3a98256cd2782164fedefbc109bf5ab114 Mon Sep 17 00:00:00 2001 From: Balazs Varga Date: Wed, 6 Nov 2019 15:50:32 +0100 Subject: tdf#128618 OOXML chart export: deleted automatic title returns on save MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If there is no main title and/or subtitle, write out autoTitleDeleted with a true value. Regression from the commit 96a29c12a9d8734c9d2a812f38fc6654b5df9c48 (tdf#101322 Chart OOXML Export: fix missing subtitle) Change-Id: I0094014fc4da4cb66d31e4249f916452d00758c7 Reviewed-on: https://gerrit.libreoffice.org/82142 Reviewed-by: László Németh Tested-by: László Németh --- oox/source/export/chartexport.cxx | 47 +++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 22 deletions(-) (limited to 'oox') diff --git a/oox/source/export/chartexport.cxx b/oox/source/export/chartexport.cxx index 040014912b32..aeb2c8012674 100644 --- a/oox/source/export/chartexport.cxx +++ b/oox/source/export/chartexport.cxx @@ -917,7 +917,7 @@ void ChartExport::exportChart( const Reference< css::chart::XChartDocument >& xC // get Properties of ChartDocument bool bHasMainTitle = false; - bool bHasSubTitle = false; + OUString aSubTitle; bool bHasLegend = false; Reference< beans::XPropertySet > xDocPropSet( xChartDoc, uno::UNO_QUERY ); if( xDocPropSet.is()) @@ -926,8 +926,6 @@ void ChartExport::exportChart( const Reference< css::chart::XChartDocument >& xC { Any aAny( xDocPropSet->getPropertyValue("HasMainTitle")); aAny >>= bHasMainTitle; - aAny = xDocPropSet->getPropertyValue("HasSubTitle"); - aAny >>= bHasSubTitle; aAny = xDocPropSet->getPropertyValue("HasLegend"); aAny >>= bHasLegend; } @@ -937,33 +935,38 @@ void ChartExport::exportChart( const Reference< css::chart::XChartDocument >& xC } } // if( xDocPropSet.is()) - // chart element + Reference< beans::XPropertySet > xPropSubTitle( xChartDoc->getSubTitle(), UNO_QUERY ); + if( xPropSubTitle.is()) + { + try + { + xPropSubTitle->getPropertyValue("String") >>= aSubTitle; + } + catch( beans::UnknownPropertyException & ) + { + } + } + // chart element FSHelperPtr pFS = GetFS(); pFS->startElement(FSNS(XML_c, XML_chart)); // titles - if( bHasMainTitle || bHasSubTitle ) + if( bHasMainTitle ) { - OUString aSubText; - Reference< drawing::XShape > xShape; - if( bHasSubTitle ) - { - xShape = xChartDoc->getSubTitle(); - if( bHasMainTitle ) - { - // if we have a title and a subtitle too, we need only the subtitle text - Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY); - if( xPropSet.is() ) - xPropSet->getPropertyValue("String") >>= aSubText; - } - } - if( bHasMainTitle ) - xShape = xChartDoc->getTitle(); - - exportTitle( xShape, !aSubText.isEmpty() ? &aSubText : nullptr ); + exportTitle( xChartDoc->getTitle(), !aSubTitle.isEmpty() ? &aSubTitle : nullptr ); pFS->singleElement(FSNS(XML_c, XML_autoTitleDeleted), XML_val, "0"); } + else if( !aSubTitle.isEmpty() ) + { + exportTitle( xChartDoc->getSubTitle(), nullptr ); + pFS->singleElement(FSNS(XML_c, XML_autoTitleDeleted), XML_val, "0"); + } + else + { + pFS->singleElement(FSNS(XML_c, XML_autoTitleDeleted), XML_val, "1"); + } + InitPlotArea( ); if( mbIs3DChart ) { -- cgit