[Libreoffice-commits] core.git: chart2/qa oox/source
Balazs Varga (via logerrit)
logerrit at kemper.freedesktop.org
Fri Nov 8 12:21:23 UTC 2019
chart2/qa/extras/chart2export.cxx | 10 ++++
chart2/qa/extras/data/xlsx/testAutoTitleDeleted.xlsx |binary
oox/source/export/chartexport.cxx | 47 ++++++++++---------
3 files changed, 35 insertions(+), 22 deletions(-)
New commits:
commit f6437b3a98256cd2782164fedefbc109bf5ab114
Author: Balazs Varga <balazs.varga991 at gmail.com>
AuthorDate: Wed Nov 6 15:50:32 2019 +0100
Commit: László Németh <nemeth at numbertext.org>
CommitDate: Fri Nov 8 13:19:47 2019 +0100
tdf#128618 OOXML chart export: deleted automatic title returns on save
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 <nemeth at numbertext.org>
Tested-by: László Németh <nemeth at numbertext.org>
diff --git a/chart2/qa/extras/chart2export.cxx b/chart2/qa/extras/chart2export.cxx
index dd07808b1d05..4d14a1e96638 100644
--- a/chart2/qa/extras/chart2export.cxx
+++ b/chart2/qa/extras/chart2export.cxx
@@ -108,6 +108,7 @@ public:
void testLegendManualLayoutXLSX();
void testChartSubTitle();
void testChartMainWithSubTitle();
+ void testAutoTitleDeleted();
void testChartTitlePropertiesColorFillXLSX();
void testChartTitlePropertiesGradientFillXLSX();
void testChartTitlePropertiesBitmapFillXLSX();
@@ -217,6 +218,7 @@ public:
CPPUNIT_TEST(testLegendManualLayoutXLSX);
CPPUNIT_TEST(testChartSubTitle);
CPPUNIT_TEST(testChartMainWithSubTitle);
+ CPPUNIT_TEST(testAutoTitleDeleted);
CPPUNIT_TEST(testChartTitlePropertiesColorFillXLSX);
CPPUNIT_TEST(testChartTitlePropertiesGradientFillXLSX);
CPPUNIT_TEST(testChartTitlePropertiesBitmapFillXLSX);
@@ -1732,6 +1734,14 @@ void Chart2ExportTest::testChartMainWithSubTitle()
assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:spPr/a:solidFill/a:srgbClr", "val", "81d41a");
}
+void Chart2ExportTest::testAutoTitleDeleted()
+{
+ load("/chart2/qa/extras/data/xlsx/", "testAutoTitleDeleted.xlsx");
+ xmlDocPtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
+ CPPUNIT_ASSERT(pXmlDoc);
+ assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:autoTitleDeleted", "val", "1");
+}
+
void Chart2ExportTest::testChartTitlePropertiesColorFillXLSX()
{
load("/chart2/qa/extras/data/xlsx/", "testChartTitlePropertiesColorFill.xlsx");
diff --git a/chart2/qa/extras/data/xlsx/testAutoTitleDeleted.xlsx b/chart2/qa/extras/data/xlsx/testAutoTitleDeleted.xlsx
new file mode 100644
index 000000000000..409389e23beb
Binary files /dev/null and b/chart2/qa/extras/data/xlsx/testAutoTitleDeleted.xlsx differ
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 )
{
More information about the Libreoffice-commits
mailing list