summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorBalazs Varga <balazs.varga991@gmail.com>2019-08-15 11:25:02 +0200
committerLászló Németh <nemeth@numbertext.org>2019-08-21 10:10:08 +0200
commit96a29c12a9d8734c9d2a812f38fc6654b5df9c48 (patch)
treea0fa0bb8848eb0fd36e7ffbaf276497097fec4fb /oox
parentd7b227d116086ef2023ae9b8b0eef8288c46cf3c (diff)
tdf#101322 Chart OOXML Export: fix missing subtitle
Concatenate subtitle and main title texts, if both exist, just like at the XLS/DOC export, because OOXML does not support subtitles. If we only have a subtitle, export the whole subtitle shape instead of the title shape, keeping its properties. Change-Id: If6a27c023fcce58f4549a0edad44027bb0348b93 Reviewed-on: https://gerrit.libreoffice.org/77499 Reviewed-by: László Németh <nemeth@numbertext.org> Tested-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'oox')
-rw-r--r--oox/source/export/chartexport.cxx33
1 files changed, 25 insertions, 8 deletions
diff --git a/oox/source/export/chartexport.cxx b/oox/source/export/chartexport.cxx
index 98d8724fe830..925afd0af96b 100644
--- a/oox/source/export/chartexport.cxx
+++ b/oox/source/export/chartexport.cxx
@@ -874,13 +874,13 @@ void ChartExport::exportChart( const Reference< css::chart::XChartDocument >& xC
// get Properties of ChartDocument
bool bHasMainTitle = false;
+ bool bHasSubTitle = false;
bool bHasLegend = false;
Reference< beans::XPropertySet > xDocPropSet( xChartDoc, uno::UNO_QUERY );
if( xDocPropSet.is())
{
try
{
- bool bHasSubTitle = false;
Any aAny( xDocPropSet->getPropertyValue("HasMainTitle"));
aAny >>= bHasMainTitle;
aAny = xDocPropSet->getPropertyValue("HasSubTitle");
@@ -899,15 +899,27 @@ void ChartExport::exportChart( const Reference< css::chart::XChartDocument >& xC
FSHelperPtr pFS = GetFS();
pFS->startElement(FSNS(XML_c, XML_chart));
- // title
- if( bHasMainTitle )
+ // titles
+ if( bHasMainTitle || bHasSubTitle )
{
- Reference< drawing::XShape > xShape = xChartDoc->getTitle();
- if( xShape.is() )
+ OUString aSubText;
+ Reference< drawing::XShape > xShape;
+ if( bHasSubTitle )
{
- exportTitle( xShape );
- pFS->singleElement(FSNS(XML_c, XML_autoTitleDeleted), XML_val, "0");
+ 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 );
+ pFS->singleElement(FSNS(XML_c, XML_autoTitleDeleted), XML_val, "0");
}
InitPlotArea( );
if( mbIs3DChart )
@@ -1086,7 +1098,7 @@ void ChartExport::exportLegend( const Reference< css::chart::XChartDocument >& x
pFS->endElement( FSNS( XML_c, XML_legend ) );
}
-void ChartExport::exportTitle( const Reference< XShape >& xShape )
+void ChartExport::exportTitle( const Reference< XShape >& xShape, const OUString* pSubText)
{
OUString sText;
Reference< beans::XPropertySet > xPropSet( xShape, uno::UNO_QUERY );
@@ -1094,6 +1106,11 @@ void ChartExport::exportTitle( const Reference< XShape >& xShape )
{
xPropSet->getPropertyValue("String") >>= sText;
}
+
+ // tdf#101322: add subtitle to title
+ if( pSubText )
+ sText = sText.isEmpty() ? *pSubText : sText + "\n" + *pSubText;
+
if( sText.isEmpty() )
return;