chart2/qa/extras/chart2export.cxx                             |   40 +++++++
 chart2/qa/extras/data/docx/testBarChartDataPointPropDOCX.docx |binary
 chart2/qa/extras/data/xlsx/testBarChartDataPointPropXLSX.xlsx |binary
 oox/source/export/chartexport.cxx                             |   51 ++++++++++
 4 files changed, 91 insertions(+)

New commits:
commit 15035b98dc694bde4c4073fa75bdd2ce9d7e6670
Author:     Balazs Varga <balazs.varga...@gmail.com>
AuthorDate: Thu Aug 9 00:06:47 2018 +0200
Commit:     Bartosz Kosiorek <gan...@poczta.onet.pl>
CommitDate: Fri Aug 10 15:36:52 2018 +0200

    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/58806
    Reviewed-by: Bartosz Kosiorek <gan...@poczta.onet.pl>
    Tested-by: Jenkins

diff --git a/chart2/qa/extras/chart2export.cxx 
b/chart2/qa/extras/chart2export.cxx
index ffbe040a42dd..fa5ab14f0517 100644
--- a/chart2/qa/extras/chart2export.cxx
+++ b/chart2/qa/extras/chart2export.cxx
@@ -85,6 +85,7 @@ public:
     void testChartTitlePropertiesColorFillDOCX();
     void testChartTitlePropertiesGradientFillDOCX();
     void testChartTitlePropertiesBitmapFillDOCX();
+    void testBarChartDataPointPropDOCX();
     void testFdo83058dlblPos();
     void testAutoTitleDelXLSX();
     void testDispBlanksAsXLSX();
@@ -102,6 +103,7 @@ public:
     void testChartTitlePropertiesColorFillXLSX();
     void testChartTitlePropertiesGradientFillXLSX();
     void testChartTitlePropertiesBitmapFillXLSX();
+    void testBarChartDataPointPropXLSX();
     void testAxisCharacterPropertiesXLSX();
     void testTitleCharacterPropertiesXLSX();
     void testPlotVisOnlyXLSX();
@@ -165,6 +167,7 @@ public:
     CPPUNIT_TEST(testChartTitlePropertiesColorFillDOCX);
     CPPUNIT_TEST(testChartTitlePropertiesGradientFillDOCX);
     CPPUNIT_TEST(testChartTitlePropertiesBitmapFillDOCX);
+    CPPUNIT_TEST(testBarChartDataPointPropDOCX);
     CPPUNIT_TEST(testFdo83058dlblPos);
     CPPUNIT_TEST(testAutoTitleDelXLSX);
     CPPUNIT_TEST(testDispBlanksAsXLSX);
@@ -182,6 +185,7 @@ public:
     CPPUNIT_TEST(testChartTitlePropertiesColorFillXLSX);
     CPPUNIT_TEST(testChartTitlePropertiesGradientFillXLSX);
     CPPUNIT_TEST(testChartTitlePropertiesBitmapFillXLSX);
+    CPPUNIT_TEST(testBarChartDataPointPropXLSX);
     CPPUNIT_TEST(testAxisCharacterPropertiesXLSX);
     CPPUNIT_TEST(testTitleCharacterPropertiesXLSX);
     CPPUNIT_TEST(testPlotVisOnlyXLSX);
@@ -1101,6 +1105,24 @@ void 
Chart2ExportTest::testChartTitlePropertiesBitmapFillDOCX()
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:spPr/a:ln/a:noFill", 
1);
 }
 
+void Chart2ExportTest::testBarChartDataPointPropDOCX()
+{
+    load("/chart2/qa/extras/data/docx/", "testBarChartDataPointPropDOCX.docx");
+    xmlDocPtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML 
Text");
+    CPPUNIT_ASSERT(pXmlDoc);
+
+    assertXPath(pXmlDoc, 
"/c:chartSpace/c:chart/c:plotArea/c:barChart/c:varyColors", "val", "0");
+
+    assertXPath(pXmlDoc, 
"/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dPt[1]/c:idx", "val", "1");
+    assertXPath(pXmlDoc, 
"/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dPt[1]/c:spPr/a:gradFill/a:gsLst/a:gs[1]/a:srgbClr",
 "val", "f6f8fc");
+    assertXPath(pXmlDoc, 
"/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dPt[1]/c:spPr/a:gradFill/a:gsLst/a:gs[2]/a:srgbClr",
 "val", "c7d5ed");
+    assertXPath(pXmlDoc, 
"/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dPt[1]/c:spPr/a:ln/a:solidFill/a:srgbClr",
 "val", "70ad47");
+
+    assertXPath(pXmlDoc, 
"/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dPt[2]/c:idx", "val", "2");
+    assertXPath(pXmlDoc, 
"/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dPt[2]/c:spPr/a:solidFill/a:srgbClr",
 "val", "ff0000");
+    assertXPath(pXmlDoc, 
"/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dPt[2]/c:spPr/a:ln/a:solidFill/a:srgbClr",
 "val", "000000");
+}
+
 void Chart2ExportTest::testBarChartRotation()
 {
     load ("/chart2/qa/extras/data/docx/", "barChartRotation.docx");
@@ -1566,6 +1588,24 @@ void 
Chart2ExportTest::testChartTitlePropertiesBitmapFillXLSX()
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:spPr/a:ln/a:noFill", 
1);
 }
 
+void Chart2ExportTest::testBarChartDataPointPropXLSX()
+{
+    load("/chart2/qa/extras/data/xlsx/", "testBarChartDataPointPropXLSX.xlsx");
+    xmlDocPtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
+    CPPUNIT_ASSERT(pXmlDoc);
+
+    assertXPath(pXmlDoc, 
"/c:chartSpace/c:chart/c:plotArea/c:barChart/c:varyColors", "val", "0");
+
+    assertXPath(pXmlDoc, 
"/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dPt[1]/c:idx", "val", "1");
+    assertXPath(pXmlDoc, 
"/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dPt[1]/c:spPr/a:solidFill/a:srgbClr",
 "val", "ff0000");
+    assertXPath(pXmlDoc, 
"/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dPt[1]/c:spPr/a:ln/a:solidFill/a:srgbClr",
 "val", "000000");
+
+    assertXPath(pXmlDoc, 
"/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dPt[2]/c:idx", "val", "2");
+    assertXPath(pXmlDoc, 
"/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dPt[2]/c:spPr/a:gradFill/a:gsLst/a:gs[1]/a:srgbClr",
 "val", "f6f8fc");
+    assertXPath(pXmlDoc, 
"/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dPt[2]/c:spPr/a:gradFill/a:gsLst/a:gs[2]/a:srgbClr",
 "val", "c7d5ed");
+    assertXPath(pXmlDoc, 
"/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dPt[2]/c:spPr/a:ln/a:solidFill/a:srgbClr",
 "val", "70ad47");
+}
+
 void Chart2ExportTest::testAxisCharacterPropertiesXLSX()
 {
     load("/chart2/qa/extras/data/xlsx/", "axis_character_properties.xlsx");
diff --git a/chart2/qa/extras/data/docx/testBarChartDataPointPropDOCX.docx 
b/chart2/qa/extras/data/docx/testBarChartDataPointPropDOCX.docx
new file mode 100644
index 000000000000..66df9153d3c9
Binary files /dev/null and 
b/chart2/qa/extras/data/docx/testBarChartDataPointPropDOCX.docx differ
diff --git a/chart2/qa/extras/data/xlsx/testBarChartDataPointPropXLSX.xlsx 
b/chart2/qa/extras/data/xlsx/testBarChartDataPointPropXLSX.xlsx
new file mode 100644
index 000000000000..e73d16bd2dac
Binary files /dev/null and 
b/chart2/qa/extras/data/xlsx/testBarChartDataPointPropXLSX.xlsx differ
diff --git a/oox/source/export/chartexport.cxx 
b/oox/source/export/chartexport.cxx
index 891bb9707e55..3a97ee186560 100644
--- a/oox/source/export/chartexport.cxx
+++ b/oox/source/export/chartexport.cxx
@@ -3285,6 +3285,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)
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to