[Libreoffice-commits] core.git: Branch 'libreoffice-6-1' - chart2/qa oox/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Thu Aug 23 14:40:24 UTC 2018


 chart2/qa/extras/chart2export.cxx                                 |   23 ++++++++++
 chart2/qa/extras/data/xlsx/testDataseriesOverlapStackedChart.xlsx |binary
 oox/source/export/chartexport.cxx                                 |   17 ++++++-
 3 files changed, 39 insertions(+), 1 deletion(-)

New commits:
commit 8a7062c02c54330c3b6be0471dbc8a74e60aa479
Author:     Balazs Varga <balazs.varga991 at gmail.com>
AuthorDate: Wed Aug 22 11:15:45 2018 +0200
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Thu Aug 23 16:40:00 2018 +0200

    tdf#94502 Fix overlap export of Stacked Bar Chart to *.xlsx
    
    Export the Overlap value with 100% for stacked charts, because the
    default overlap value of the Bar/Column chart is 0% and LibreOffice
    do nothing with the overlap value in Stacked Chart case, unlike the
    MS Office.
    
    Change-Id: If4e20b88c2b1180f68a8d2b610c407d674a8498b
    Reviewed-on: https://gerrit.libreoffice.org/59448
    Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
    Tested-by: Jenkins
    (cherry picked from commit 17c2b0af97f73b9103be982b15d7111b3980e027)
    Reviewed-on: https://gerrit.libreoffice.org/59497
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/chart2/qa/extras/chart2export.cxx b/chart2/qa/extras/chart2export.cxx
index fa5ab14f0517..a8cf4480641c 100644
--- a/chart2/qa/extras/chart2export.cxx
+++ b/chart2/qa/extras/chart2export.cxx
@@ -104,6 +104,7 @@ public:
     void testChartTitlePropertiesGradientFillXLSX();
     void testChartTitlePropertiesBitmapFillXLSX();
     void testBarChartDataPointPropXLSX();
+    void testDataseriesOverlapStackedChartXLSX();
     void testAxisCharacterPropertiesXLSX();
     void testTitleCharacterPropertiesXLSX();
     void testPlotVisOnlyXLSX();
@@ -186,6 +187,7 @@ public:
     CPPUNIT_TEST(testChartTitlePropertiesGradientFillXLSX);
     CPPUNIT_TEST(testChartTitlePropertiesBitmapFillXLSX);
     CPPUNIT_TEST(testBarChartDataPointPropXLSX);
+    CPPUNIT_TEST(testDataseriesOverlapStackedChartXLSX);
     CPPUNIT_TEST(testAxisCharacterPropertiesXLSX);
     CPPUNIT_TEST(testTitleCharacterPropertiesXLSX);
     CPPUNIT_TEST(testPlotVisOnlyXLSX);
@@ -1606,6 +1608,27 @@ void Chart2ExportTest::testBarChartDataPointPropXLSX()
     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::testDataseriesOverlapStackedChartXLSX()
+{
+    load("/chart2/qa/extras/data/xlsx/", "testDataseriesOverlapStackedChart.xlsx");
+
+    // test the overlap value of a simple Stacked Column Chart
+    uno::Reference< chart2::XChartDocument > xChartDoc = getChartDocFromSheet( 0, mxComponent );
+    checkSheetForGapWidthAndOverlap(xChartDoc, 100, 0);
+
+    // test the overlap value of a Percent Stacked Bar Chart
+    xChartDoc = getChartDocFromSheet( 1, mxComponent );
+    checkSheetForGapWidthAndOverlap(xChartDoc, 100, 35);
+
+    reload("Calc Office Open XML");
+
+    xChartDoc = getChartDocFromSheet( 0, mxComponent );
+    checkSheetForGapWidthAndOverlap(xChartDoc, 100, 100);
+
+    xChartDoc = getChartDocFromSheet( 1, mxComponent );
+    checkSheetForGapWidthAndOverlap(xChartDoc, 100, 100);
+}
+
 void Chart2ExportTest::testAxisCharacterPropertiesXLSX()
 {
     load("/chart2/qa/extras/data/xlsx/", "axis_character_properties.xlsx");
diff --git a/chart2/qa/extras/data/xlsx/testDataseriesOverlapStackedChart.xlsx b/chart2/qa/extras/data/xlsx/testDataseriesOverlapStackedChart.xlsx
new file mode 100755
index 000000000000..ba1c526b41ca
Binary files /dev/null and b/chart2/qa/extras/data/xlsx/testDataseriesOverlapStackedChart.xlsx differ
diff --git a/oox/source/export/chartexport.cxx b/oox/source/export/chartexport.cxx
index 3a97ee186560..43fe63a51554 100644
--- a/oox/source/export/chartexport.cxx
+++ b/oox/source/export/chartexport.cxx
@@ -1498,9 +1498,24 @@ void ChartExport::exportBarChart( const Reference< chart2::XChartType >& xChartT
         if( aBarPositionSequence.getLength() )
         {
             sal_Int32 nOverlap = aBarPositionSequence[0];
-            pFS->singleElement( FSNS( XML_c, XML_overlap ),
+            // Stacked/Percent Bar/Column chart Overlap-workaround
+            // Export the Overlap value with 100% for stacked charts,
+            // because the default overlap value of the Bar/Column chart is 0% and
+            // LibreOffice do nothing with the overlap value in Stacked charts case,
+            // unlike the MS Office, which is interpreted differently.
+            if( ( mbStacked || mbPercent ) && nOverlap != 100 )
+            {
+                nOverlap = 100;
+                pFS->singleElement( FSNS( XML_c, XML_overlap ),
+                    XML_val, I32S( nOverlap ),
+                    FSEND );
+            }
+            else // Normal bar chart
+            {
+                pFS->singleElement( FSNS( XML_c, XML_overlap ),
                     XML_val, I32S( nOverlap ),
                     FSEND );
+            }
         }
     }
 


More information about the Libreoffice-commits mailing list