From 9f800d2caf934c58b5845f6e235468ddfc80604f Mon Sep 17 00:00:00 2001 From: Balazs Varga Date: Mon, 23 Jul 2018 21:13:09 +0200 Subject: tdf#108078 OOXML Export Chart shapes area fill properties Verified with color, gradient, bitmap for: Chart Title in DOCX, XLSX and PPTX. Also verified with gradient, bitmap for Chart Legend, Plot Area, Dataseries and Background in DOCX, XLSX and PPTX. Change-Id: I15d29f3ca2d75f45f612766b635d50a29d8551ae Reviewed-on: https://gerrit.libreoffice.org/57880 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek (cherry picked from commit 051399740e41c6495ed362e78c63e0868bcd180c) Reviewed-on: https://gerrit.libreoffice.org/58348 Reviewed-by: Balazs Varga --- chart2/qa/extras/chart2export.cxx | 102 +++++++++++++++++++++ .../docx/testChartTitlePropertiesBitmapFill.docx | Bin 0 -> 47851 bytes .../docx/testChartTitlePropertiesColorFill.docx | Bin 0 -> 5549 bytes .../docx/testChartTitlePropertiesGradientFill.docx | Bin 0 -> 5595 bytes .../pptx/testChartTitlePropertiesBitmapFill.pptx | Bin 0 -> 50865 bytes .../pptx/testChartTitlePropertiesColorFill.pptx | Bin 0 -> 47424 bytes .../pptx/testChartTitlePropertiesGradientFill.pptx | Bin 0 -> 47473 bytes .../xlsx/testChartTitlePropertiesBitmapFill.xlsx | Bin 0 -> 49790 bytes .../xlsx/testChartTitlePropertiesColorFill.xlsx | Bin 0 -> 11515 bytes .../xlsx/testChartTitlePropertiesGradientFill.xlsx | Bin 0 -> 7542 bytes include/oox/export/chartexport.hxx | 1 - oox/source/export/chartexport.cxx | 22 ++--- oox/source/export/drawingml.cxx | 9 +- 13 files changed, 116 insertions(+), 18 deletions(-) create mode 100644 chart2/qa/extras/data/docx/testChartTitlePropertiesBitmapFill.docx create mode 100644 chart2/qa/extras/data/docx/testChartTitlePropertiesColorFill.docx create mode 100644 chart2/qa/extras/data/docx/testChartTitlePropertiesGradientFill.docx create mode 100644 chart2/qa/extras/data/pptx/testChartTitlePropertiesBitmapFill.pptx create mode 100644 chart2/qa/extras/data/pptx/testChartTitlePropertiesColorFill.pptx create mode 100644 chart2/qa/extras/data/pptx/testChartTitlePropertiesGradientFill.pptx create mode 100644 chart2/qa/extras/data/xlsx/testChartTitlePropertiesBitmapFill.xlsx create mode 100644 chart2/qa/extras/data/xlsx/testChartTitlePropertiesColorFill.xlsx create mode 100644 chart2/qa/extras/data/xlsx/testChartTitlePropertiesGradientFill.xlsx diff --git a/chart2/qa/extras/chart2export.cxx b/chart2/qa/extras/chart2export.cxx index da15d321a881..124dd4735e3a 100644 --- a/chart2/qa/extras/chart2export.cxx +++ b/chart2/qa/extras/chart2export.cxx @@ -82,6 +82,9 @@ public: void testDataLabelDoughnutChartDOCX(); void testDataLabelAreaChartDOCX(); void testDataLabelDefaultLineChartDOCX(); + void testChartTitlePropertiesColorFillDOCX(); + void testChartTitlePropertiesGradientFillDOCX(); + void testChartTitlePropertiesBitmapFillDOCX(); void testFdo83058dlblPos(); void testAutoTitleDelXLSX(); void testDispBlanksAsXLSX(); @@ -96,6 +99,9 @@ public: void testTitleManualLayoutXLSX(); void testPlotAreaManualLayoutXLSX(); void testLegendManualLayoutXLSX(); + void testChartTitlePropertiesColorFillXLSX(); + void testChartTitlePropertiesGradientFillXLSX(); + void testChartTitlePropertiesBitmapFillXLSX(); void testAxisCharacterPropertiesXLSX(); void testTitleCharacterPropertiesXLSX(); void testPlotVisOnlyXLSX(); @@ -107,6 +113,9 @@ public: void testCustomDataLabel(); void testCustomDataLabelMultipleSeries(); void testNumberFormatExportPPTX(); + void testChartTitlePropertiesColorFillPPTX(); + void testChartTitlePropertiesGradientFillPPTX(); + void testChartTitlePropertiesBitmapFillPPTX(); void testTdf116163(); CPPUNIT_TEST_SUITE(Chart2ExportTest); @@ -152,6 +161,9 @@ public: CPPUNIT_TEST(testDataLabelDoughnutChartDOCX); CPPUNIT_TEST(testDataLabelAreaChartDOCX); CPPUNIT_TEST(testDataLabelDefaultLineChartDOCX); + CPPUNIT_TEST(testChartTitlePropertiesColorFillDOCX); + CPPUNIT_TEST(testChartTitlePropertiesGradientFillDOCX); + CPPUNIT_TEST(testChartTitlePropertiesBitmapFillDOCX); CPPUNIT_TEST(testFdo83058dlblPos); CPPUNIT_TEST(testAutoTitleDelXLSX); CPPUNIT_TEST(testDispBlanksAsXLSX); @@ -166,6 +178,9 @@ public: CPPUNIT_TEST(testTitleManualLayoutXLSX); CPPUNIT_TEST(testPlotAreaManualLayoutXLSX); CPPUNIT_TEST(testLegendManualLayoutXLSX); + CPPUNIT_TEST(testChartTitlePropertiesColorFillXLSX); + CPPUNIT_TEST(testChartTitlePropertiesGradientFillXLSX); + CPPUNIT_TEST(testChartTitlePropertiesBitmapFillXLSX); CPPUNIT_TEST(testAxisCharacterPropertiesXLSX); CPPUNIT_TEST(testTitleCharacterPropertiesXLSX); CPPUNIT_TEST(testPlotVisOnlyXLSX); @@ -177,6 +192,9 @@ public: CPPUNIT_TEST(testCustomDataLabel); CPPUNIT_TEST(testCustomDataLabelMultipleSeries); CPPUNIT_TEST(testNumberFormatExportPPTX); + CPPUNIT_TEST(testChartTitlePropertiesColorFillPPTX); + CPPUNIT_TEST(testChartTitlePropertiesGradientFillPPTX); + CPPUNIT_TEST(testChartTitlePropertiesBitmapFillPPTX); CPPUNIT_TEST(testTdf116163); CPPUNIT_TEST_SUITE_END(); @@ -1053,6 +1071,34 @@ void Chart2ExportTest::testDataLabelDefaultLineChartDOCX() CPPUNIT_ASSERT_EQUAL_MESSAGE("Line chart's default label placement should be 'right'.", chart::DataLabelPlacement::RIGHT, nLabelPlacement ); } +void Chart2ExportTest::testChartTitlePropertiesColorFillDOCX() +{ + load("/chart2/qa/extras/data/docx/", "testChartTitlePropertiesColorFill.docx"); + xmlDocPtr pXmlDoc = parseExport("word/charts/chart","Office Open XML Text"); + CPPUNIT_ASSERT(pXmlDoc); + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:spPr/a:solidFill/a:srgbClr", "val", "ff0000"); + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:spPr/a:ln/a:noFill", 1); +} + +void Chart2ExportTest::testChartTitlePropertiesGradientFillDOCX() +{ + load("/chart2/qa/extras/data/docx/", "testChartTitlePropertiesGradientFill.docx"); + xmlDocPtr pXmlDoc = parseExport("word/charts/chart","Office Open XML Text"); + CPPUNIT_ASSERT(pXmlDoc); + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:spPr/a:gradFill/a:gsLst/a:gs[1]/a:srgbClr", "val", "cccccc"); + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:spPr/a:gradFill/a:gsLst/a:gs[2]/a:srgbClr", "val", "666666"); + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:spPr/a:ln/a:noFill", 1); +} + +void Chart2ExportTest::testChartTitlePropertiesBitmapFillDOCX() +{ + load("/chart2/qa/extras/data/docx/", "testChartTitlePropertiesBitmapFill.docx"); + xmlDocPtr pXmlDoc = parseExport("word/charts/chart","Office Open XML Text"); + CPPUNIT_ASSERT(pXmlDoc); + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:spPr/a:blipFill/a:blip", "embed", "rId1"); + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:spPr/a:ln/a:noFill", 1); +} + void Chart2ExportTest::testBarChartRotation() { load ("/chart2/qa/extras/data/docx/", "barChartRotation.docx"); @@ -1490,6 +1536,34 @@ void Chart2ExportTest::testLegendManualLayoutXLSX() assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:legend/c:txPr/a:p/a:pPr/a:defRPr", "sz", "900"); } +void Chart2ExportTest::testChartTitlePropertiesColorFillXLSX() +{ + load("/chart2/qa/extras/data/xlsx/", "testChartTitlePropertiesColorFill.xlsx"); + xmlDocPtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML"); + CPPUNIT_ASSERT(pXmlDoc); + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:spPr/a:solidFill/a:srgbClr", "val", "ff0000"); + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:spPr/a:ln/a:noFill", 1); +} + +void Chart2ExportTest::testChartTitlePropertiesGradientFillXLSX() +{ + load("/chart2/qa/extras/data/xlsx/", "testChartTitlePropertiesGradientFill.xlsx"); + xmlDocPtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML"); + CPPUNIT_ASSERT(pXmlDoc); + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:spPr/a:gradFill/a:gsLst/a:gs[1]/a:srgbClr", "val", "cccccc"); + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:spPr/a:gradFill/a:gsLst/a:gs[2]/a:srgbClr", "val", "666666"); + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:spPr/a:ln/a:noFill", 1); +} + +void Chart2ExportTest::testChartTitlePropertiesBitmapFillXLSX() +{ + load("/chart2/qa/extras/data/xlsx/", "testChartTitlePropertiesBitmapFill.xlsx"); + xmlDocPtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML"); + CPPUNIT_ASSERT(pXmlDoc); + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:spPr/a:blipFill/a:blip", "embed", "rId1"); + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:spPr/a:ln/a:noFill", 1); +} + void Chart2ExportTest::testAxisCharacterPropertiesXLSX() { load("/chart2/qa/extras/data/xlsx/", "axis_character_properties.xlsx"); @@ -1742,6 +1816,34 @@ void Chart2ExportTest::testNumberFormatExportPPTX() assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dLbls/c:numFmt", "sourceLinked", "0"); } +void Chart2ExportTest::testChartTitlePropertiesColorFillPPTX() +{ + load("/chart2/qa/extras/data/pptx/", "testChartTitlePropertiesColorFill.pptx"); + xmlDocPtr pXmlDoc = parseExport("ppt/charts/chart", "Impress MS PowerPoint 2007 XML"); + CPPUNIT_ASSERT(pXmlDoc); + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:spPr/a:solidFill/a:srgbClr", "val", "ff0000"); + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:spPr/a:ln/a:noFill", 1); +} + +void Chart2ExportTest::testChartTitlePropertiesGradientFillPPTX() +{ + load("/chart2/qa/extras/data/pptx/", "testChartTitlePropertiesGradientFill.pptx"); + xmlDocPtr pXmlDoc = parseExport("ppt/charts/chart", "Impress MS PowerPoint 2007 XML"); + CPPUNIT_ASSERT(pXmlDoc); + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:spPr/a:gradFill/a:gsLst/a:gs[1]/a:srgbClr", "val", "f6f8fc"); + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:spPr/a:gradFill/a:gsLst/a:gs[2]/a:srgbClr", "val", "c7d5ed"); + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:spPr/a:ln/a:noFill", 1); +} + +void Chart2ExportTest::testChartTitlePropertiesBitmapFillPPTX() +{ + load("/chart2/qa/extras/data/pptx/", "testChartTitlePropertiesBitmapFill.pptx"); + xmlDocPtr pXmlDoc = parseExport("ppt/charts/chart", "Impress MS PowerPoint 2007 XML"); + CPPUNIT_ASSERT(pXmlDoc); + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:spPr/a:blipFill/a:blip", "embed", "rId1"); + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:spPr/a:ln/a:noFill", 1); +} + void Chart2ExportTest::testTdf116163() { load("/chart2/qa/extras/data/pptx/", "tdf116163.pptx"); diff --git a/chart2/qa/extras/data/docx/testChartTitlePropertiesBitmapFill.docx b/chart2/qa/extras/data/docx/testChartTitlePropertiesBitmapFill.docx new file mode 100644 index 000000000000..462c15976a04 Binary files /dev/null and b/chart2/qa/extras/data/docx/testChartTitlePropertiesBitmapFill.docx differ diff --git a/chart2/qa/extras/data/docx/testChartTitlePropertiesColorFill.docx b/chart2/qa/extras/data/docx/testChartTitlePropertiesColorFill.docx new file mode 100644 index 000000000000..d86928d615f3 Binary files /dev/null and b/chart2/qa/extras/data/docx/testChartTitlePropertiesColorFill.docx differ diff --git a/chart2/qa/extras/data/docx/testChartTitlePropertiesGradientFill.docx b/chart2/qa/extras/data/docx/testChartTitlePropertiesGradientFill.docx new file mode 100644 index 000000000000..a72600d09ee4 Binary files /dev/null and b/chart2/qa/extras/data/docx/testChartTitlePropertiesGradientFill.docx differ diff --git a/chart2/qa/extras/data/pptx/testChartTitlePropertiesBitmapFill.pptx b/chart2/qa/extras/data/pptx/testChartTitlePropertiesBitmapFill.pptx new file mode 100644 index 000000000000..395546edb497 Binary files /dev/null and b/chart2/qa/extras/data/pptx/testChartTitlePropertiesBitmapFill.pptx differ diff --git a/chart2/qa/extras/data/pptx/testChartTitlePropertiesColorFill.pptx b/chart2/qa/extras/data/pptx/testChartTitlePropertiesColorFill.pptx new file mode 100644 index 000000000000..361bdd643ce9 Binary files /dev/null and b/chart2/qa/extras/data/pptx/testChartTitlePropertiesColorFill.pptx differ diff --git a/chart2/qa/extras/data/pptx/testChartTitlePropertiesGradientFill.pptx b/chart2/qa/extras/data/pptx/testChartTitlePropertiesGradientFill.pptx new file mode 100644 index 000000000000..a77896dcdf09 Binary files /dev/null and b/chart2/qa/extras/data/pptx/testChartTitlePropertiesGradientFill.pptx differ diff --git a/chart2/qa/extras/data/xlsx/testChartTitlePropertiesBitmapFill.xlsx b/chart2/qa/extras/data/xlsx/testChartTitlePropertiesBitmapFill.xlsx new file mode 100644 index 000000000000..9d2dff9b3e59 Binary files /dev/null and b/chart2/qa/extras/data/xlsx/testChartTitlePropertiesBitmapFill.xlsx differ diff --git a/chart2/qa/extras/data/xlsx/testChartTitlePropertiesColorFill.xlsx b/chart2/qa/extras/data/xlsx/testChartTitlePropertiesColorFill.xlsx new file mode 100644 index 000000000000..9e9aa0beaf5e Binary files /dev/null and b/chart2/qa/extras/data/xlsx/testChartTitlePropertiesColorFill.xlsx differ diff --git a/chart2/qa/extras/data/xlsx/testChartTitlePropertiesGradientFill.xlsx b/chart2/qa/extras/data/xlsx/testChartTitlePropertiesGradientFill.xlsx new file mode 100644 index 000000000000..b5b617754340 Binary files /dev/null and b/chart2/qa/extras/data/xlsx/testChartTitlePropertiesGradientFill.xlsx differ diff --git a/include/oox/export/chartexport.hxx b/include/oox/export/chartexport.hxx index 04ef384785a2..d6761bdea021 100644 --- a/include/oox/export/chartexport.hxx +++ b/include/oox/export/chartexport.hxx @@ -136,7 +136,6 @@ private: css::drawing::XShape >& xShape ); void exportPlotArea( const css::uno::Reference< css::chart::XChartDocument >& rChartDoc ); - void exportPlotAreaShapeProps( const css::uno::Reference< css::beans::XPropertySet >& xPropSet ); void exportFill( const css::uno::Reference< css::beans::XPropertySet >& xPropSet ); void exportGradientFill( const css::uno::Reference< css::beans::XPropertySet >& xPropSet ); void exportBitmapFill( const css::uno::Reference< css::beans::XPropertySet >& xPropSet ); diff --git a/oox/source/export/chartexport.cxx b/oox/source/export/chartexport.cxx index 16ae6a190ea3..18d748fca05d 100644 --- a/oox/source/export/chartexport.cxx +++ b/oox/source/export/chartexport.cxx @@ -1039,6 +1039,12 @@ void ChartExport::exportTitle( const Reference< XShape >& xShape ) XML_val, "0", FSEND); + // shape properties + if( xPropSet.is() ) + { + exportShapeProps( xPropSet ); + } + pFS->endElement( FSNS( XML_c, XML_title ) ); } @@ -1172,7 +1178,7 @@ void ChartExport::exportPlotArea( const Reference< css::chart::XChartDocument >& Reference< beans::XPropertySet > xWallPropSet( xWallFloorSupplier->getWall(), uno::UNO_QUERY ); if( xWallPropSet.is() ) { - exportPlotAreaShapeProps( xWallPropSet ); + exportShapeProps( xWallPropSet ); } } @@ -1262,18 +1268,6 @@ void ChartExport::exportManualLayout(const css::chart2::RelativePosition& rPos, pFS->endElement(FSNS(XML_c, XML_layout)); } -void ChartExport::exportPlotAreaShapeProps( const Reference< XPropertySet >& xPropSet ) -{ - FSHelperPtr pFS = GetFS(); - pFS->startElement( FSNS( XML_c, XML_spPr ), - FSEND ); - - exportFill( xPropSet ); - WriteOutline( xPropSet ); - - pFS->endElement( FSNS( XML_c, XML_spPr ) ); -} - void ChartExport::exportFill( const Reference< XPropertySet >& xPropSet ) { if ( !GetProperty( xPropSet, "FillStyle" ) ) @@ -2313,7 +2307,7 @@ void ChartExport::exportShapeProps( const Reference< XPropertySet >& xPropSet ) pFS->startElement( FSNS( XML_c, XML_spPr ), FSEND ); - WriteFill( xPropSet ); + exportFill( xPropSet ); WriteOutline( xPropSet ); pFS->endElement( FSNS( XML_c, XML_spPr ) ); diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx index af1e76fc03b9..38ff08740de8 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -916,13 +916,16 @@ OUString DrawingML::WriteImage( const Graphic& rGraphic , bool bRelPathToMedia ) xOutStream->writeBytes( Sequence< sal_Int8 >( static_cast(aData), nDataSize ) ); xOutStream->closeOutput(); - OString sRelPathToMedia = "media/image"; + const OString sRelPathToMedia = "media/image"; + OString sRelationCompPrefix; if ( bRelPathToMedia ) - sRelPathToMedia = "../" + sRelPathToMedia; + sRelationCompPrefix = "../"; + else + sRelationCompPrefix = GetRelationCompPrefix(); sRelId = mpFB->addRelation( mpFS->getOutputStream(), oox::getRelationship(Relationship::IMAGE), OUStringBuffer() - .appendAscii( GetRelationCompPrefix() ) + .appendAscii( sRelationCompPrefix.getStr() ) .appendAscii( sRelPathToMedia.getStr() ) .append( static_cast(mnImageCounter ++) ) .appendAscii( pExtension ) -- cgit