[Libreoffice-commits] core.git: 2 commits - chart2/qa include/oox oox/source

Kohei Yoshida kohei.yoshida at collabora.com
Mon Aug 4 09:27:05 PDT 2014


 chart2/qa/extras/chart2export.cxx                     |   11 +++++++
 chart2/qa/extras/chart2import.cxx                     |   26 ++++++++++++++++++
 chart2/qa/extras/charttest.hxx                        |    3 +-
 chart2/qa/extras/data/xlsx/chart-auto-background.xlsx |binary
 include/oox/helper/graphichelper.hxx                  |    3 ++
 oox/source/drawingml/chart/chartspaceconverter.cxx    |    8 ++++-
 oox/source/helper/graphichelper.cxx                   |    5 +++
 oox/source/ppt/pptimport.cxx                          |    6 ++++
 8 files changed, 60 insertions(+), 2 deletions(-)

New commits:
commit 0ee728634d29aa3e77139491d4eac2b2962ee418
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Mon Aug 4 12:14:43 2014 -0400

    bnc#886540: Add test cases for chart background fill variance.
    
    "Automatic" fill in docx and xlsx should be solid white, whereas in
    pptx it is no fill (transparent).
    
    Change-Id: I7e64f2f895e4c4ed072a234e622a348599456f37

diff --git a/chart2/qa/extras/chart2export.cxx b/chart2/qa/extras/chart2export.cxx
index 0c31f22..1beb411 100644
--- a/chart2/qa/extras/chart2export.cxx
+++ b/chart2/qa/extras/chart2export.cxx
@@ -779,6 +779,17 @@ void Chart2ExportTest::testDataLabelBordersDOCX()
     load("/chart2/qa/extras/data/docx/", "data-label-borders.docx");
 
     Reference<chart2::XChartDocument> xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY);
+
+    // "Automatic" chart background fill in docx should be loaded as solid white.
+    Reference<beans::XPropertySet> xPropSet = xChartDoc->getPageBackground();
+    CPPUNIT_ASSERT(xPropSet.is());
+    drawing::FillStyle eStyle = xPropSet->getPropertyValue("FillStyle").get<drawing::FillStyle>();
+    sal_Int32 nColor = xPropSet->getPropertyValue("FillColor").get<sal_Int32>();
+    CPPUNIT_ASSERT_MESSAGE("'Automatic' chart background fill in docx should be loaded as solid fill.",
+        eStyle == drawing::FillStyle_SOLID);
+    CPPUNIT_ASSERT_MESSAGE("'Automatic' chart background fill in docx should be loaded as solid white.",
+        (nColor & 0x00FFFFFF) == 0x00FFFFFF); // highest 2 bytes are transparency which we ignore here.
+
     aTest.checkObject1(xChartDoc);
     xChartDoc.set(getChartDocFromWriter(1), uno::UNO_QUERY);
     aTest.checkObject2(xChartDoc);
diff --git a/chart2/qa/extras/chart2import.cxx b/chart2/qa/extras/chart2import.cxx
index 659987a..73200f9 100644
--- a/chart2/qa/extras/chart2import.cxx
+++ b/chart2/qa/extras/chart2import.cxx
@@ -52,6 +52,7 @@ public:
     void testFlatODSStackedColumnChart();
     void testFdo78080();
     void testFdo54361();
+    void testAutoBackgroundXLSX();
 
     CPPUNIT_TEST_SUITE(Chart2ImportTest);
     CPPUNIT_TEST(Fdo60083);
@@ -83,6 +84,7 @@ public:
     CPPUNIT_TEST(testFlatODSStackedColumnChart);
     CPPUNIT_TEST(testFdo78080);
     CPPUNIT_TEST(testFdo54361);
+    CPPUNIT_TEST(testAutoBackgroundXLSX);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -344,6 +346,13 @@ void Chart2ImportTest::testPPTXHiddenDataSeries()
     Reference<chart2::XChartDocument> xChartDoc(getChartDocFromDrawImpress(0, 0), uno::UNO_QUERY);
     CPPUNIT_ASSERT(xChartDoc.is());
 
+    // "Automatic" chart background fill in pptx should be loaded as no fill.
+    Reference<beans::XPropertySet> xPropSet = xChartDoc->getPageBackground();
+    CPPUNIT_ASSERT(xPropSet.is());
+    drawing::FillStyle eStyle = xPropSet->getPropertyValue("FillStyle").get<drawing::FillStyle>();
+    CPPUNIT_ASSERT_MESSAGE("'Automatic' chart background fill in pptx should be loaded as no fill (transparent).",
+        eStyle == drawing::FillStyle_NONE);
+
     Reference<chart2::XChartType> xCT = getChartTypeFromDoc(xChartDoc, 0, 0);
     CPPUNIT_ASSERT(xCT.is());
 
@@ -600,6 +609,23 @@ void Chart2ImportTest::testFdo54361()
     CPPUNIT_ASSERT_MESSAGE("Background needs to be with solid fill style", aStyle == 1);
 }
 
+void Chart2ImportTest::testAutoBackgroundXLSX()
+{
+    load("/chart2/qa/extras/data/xlsx/", "chart-auto-background.xlsx");
+    uno::Reference<chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent);
+    CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc.is());
+
+    // "Automatic" chart background fill in xlsx should be loaded as solid white.
+    Reference<beans::XPropertySet> xPropSet = xChartDoc->getPageBackground();
+    CPPUNIT_ASSERT(xPropSet.is());
+    drawing::FillStyle eStyle = xPropSet->getPropertyValue("FillStyle").get<drawing::FillStyle>();
+    sal_Int32 nColor = xPropSet->getPropertyValue("FillColor").get<sal_Int32>();
+    CPPUNIT_ASSERT_MESSAGE("'Automatic' chart background fill in xlsx should be loaded as solid fill.",
+        eStyle == drawing::FillStyle_SOLID);
+    CPPUNIT_ASSERT_MESSAGE("'Automatic' chart background fill in xlsx should be loaded as solid white.",
+        (nColor & 0x00FFFFFF) == 0x00FFFFFF); // highest 2 bytes are transparency which we ignore here.
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(Chart2ImportTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/chart2/qa/extras/charttest.hxx b/chart2/qa/extras/charttest.hxx
index 7c53b95..d9c022d 100644
--- a/chart2/qa/extras/charttest.hxx
+++ b/chart2/qa/extras/charttest.hxx
@@ -30,7 +30,6 @@
 
 #include <unotools/tempfile.hxx>
 
-#include <com/sun/star/drawing/XDrawPageSupplier.hpp>
 #include <com/sun/star/chart2/XAnyDescriptionAccess.hpp>
 #include <com/sun/star/chart2/XChartDocument.hpp>
 #include <com/sun/star/chart2/XDiagram.hpp>
@@ -46,6 +45,8 @@
 #include <com/sun/star/chart/XChartDataArray.hpp>
 #include <com/sun/star/chart/XComplexDescriptionAccess.hpp>
 #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
+#include <com/sun/star/drawing/XDrawPageSupplier.hpp>
+#include <com/sun/star/drawing/FillStyle.hpp>
 #include <com/sun/star/chart/XChartDocument.hpp>
 #include <com/sun/star/util/XNumberFormatsSupplier.hpp>
 #include <com/sun/star/util/NumberFormat.hpp>
diff --git a/chart2/qa/extras/data/xlsx/chart-auto-background.xlsx b/chart2/qa/extras/data/xlsx/chart-auto-background.xlsx
new file mode 100755
index 0000000..a4594ad
Binary files /dev/null and b/chart2/qa/extras/data/xlsx/chart-auto-background.xlsx differ
commit 4a8f2431718f99de6fd9ee3461d703d007261c03
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Fri Aug 1 21:39:49 2014 -0400

    bnc#886540: Default chart background for pptx docs should be transparent.
    
    Charts in docx and xlsx OTOH use solid white as the default fill style.
    
    Change-Id: Ic4351fe65cabc12d60214b67c7026a317841f2c7

diff --git a/include/oox/helper/graphichelper.hxx b/include/oox/helper/graphichelper.hxx
index feb0629..37c882a 100644
--- a/include/oox/helper/graphichelper.hxx
+++ b/include/oox/helper/graphichelper.hxx
@@ -24,6 +24,7 @@
 #include <map>
 #include <rtl/ustring.hxx>
 #include <com/sun/star/awt/DeviceInfo.hpp>
+#include <com/sun/star/drawing/FillStyle.hpp>
 #include <com/sun/star/uno/Reference.hxx>
 #include <oox/helper/binarystreambase.hxx>
 #include <oox/helper/storagebase.hxx>
@@ -75,6 +76,8 @@ public:
     /** Derived classes may implement to resolve a palette index to an RGB color. */
     virtual sal_Int32   getPaletteColor( sal_Int32 nPaletteIdx ) const;
 
+    virtual css::drawing::FillStyle getDefaultChartAreaFillStyle() const;
+
     // Device info and device dependent unit conversion -----------------------
 
     /** Returns information about the output device. */
diff --git a/oox/source/drawingml/chart/chartspaceconverter.cxx b/oox/source/drawingml/chart/chartspaceconverter.cxx
index b0b5f9c..f29016c 100644
--- a/oox/source/drawingml/chart/chartspaceconverter.cxx
+++ b/oox/source/drawingml/chart/chartspaceconverter.cxx
@@ -25,8 +25,10 @@
 #include <com/sun/star/chart2/XTitled.hpp>
 #include <com/sun/star/chart2/data/XDataReceiver.hpp>
 #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
+#include <com/sun/star/drawing/FillStyle.hpp>
 #include "oox/core/xmlfilterbase.hxx"
 #include "oox/drawingml/chart/chartconverter.hxx"
+#include <oox/helper/graphichelper.hxx>
 #include "drawingml/chart/chartdrawingfragment.hxx"
 #include "drawingml/chart/chartspacemodel.hxx"
 #include "drawingml/chart/plotareaconverter.hxx"
@@ -86,8 +88,12 @@ void ChartSpaceConverter::convertFromModel( const Reference< XShapes >& rxExtern
     {
     }
 
-    // formatting of the chart background
+    // formatting of the chart background.  The default fill style varies with applications.
     PropertySet aBackPropSet( getChartDocument()->getPageBackground() );
+    aBackPropSet.setProperty(
+        PROP_FillStyle,
+        uno::makeAny(getFilter().getGraphicHelper().getDefaultChartAreaFillStyle()));
+
     if( mrModel.mxShapeProp.is() )
     {
         getFormatter().convertFrameFormatting( aBackPropSet, mrModel.mxShapeProp, OBJECTTYPE_CHARTSPACE );
diff --git a/oox/source/helper/graphichelper.cxx b/oox/source/helper/graphichelper.cxx
index 11dc2da..180df3c 100644
--- a/oox/source/helper/graphichelper.cxx
+++ b/oox/source/helper/graphichelper.cxx
@@ -151,6 +151,11 @@ sal_Int32 GraphicHelper::getPaletteColor( sal_Int32 /*nPaletteIdx*/ ) const
     return API_RGB_TRANSPARENT;
 }
 
+drawing::FillStyle GraphicHelper::getDefaultChartAreaFillStyle() const
+{
+    return drawing::FillStyle_SOLID;
+}
+
 // Device info and device dependent unit conversion ---------------------------
 
 sal_Int32 GraphicHelper::convertScreenPixelXToHmm( double fPixelX ) const
diff --git a/oox/source/ppt/pptimport.cxx b/oox/source/ppt/pptimport.cxx
index 62ed37f..aaaa9fb 100644
--- a/oox/source/ppt/pptimport.cxx
+++ b/oox/source/ppt/pptimport.cxx
@@ -189,6 +189,7 @@ class PptGraphicHelper : public GraphicHelper
 public:
     explicit            PptGraphicHelper( const PowerPointImport& rFilter );
     virtual sal_Int32   getSchemeColor( sal_Int32 nToken ) const SAL_OVERRIDE;
+    virtual drawing::FillStyle getDefaultChartAreaFillStyle() const;
 private:
     const PowerPointImport& mrFilter;
 };
@@ -204,6 +205,11 @@ sal_Int32 PptGraphicHelper::getSchemeColor( sal_Int32 nToken ) const
     return mrFilter.getSchemeColor( nToken );
 }
 
+drawing::FillStyle PptGraphicHelper::getDefaultChartAreaFillStyle() const
+{
+    return drawing::FillStyle_NONE;
+}
+
 } // namespace
 
 GraphicHelper* PowerPointImport::implCreateGraphicHelper() const


More information about the Libreoffice-commits mailing list