[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-4.2' - 8 commits - chart2/qa include/oox oox/README oox/source

Andras Timar andras.timar at collabora.com
Thu Feb 19 02:58:07 PST 2015


 chart2/qa/extras/chart2import.cxx                           |   20 ++++++
 chart2/qa/extras/data/xlsx/chart-area-style-background.xlsx |binary
 include/oox/helper/graphichelper.hxx                        |    2 
 oox/README                                                  |    9 ++
 oox/source/drawingml/chart/chartspaceconverter.cxx          |    5 -
 oox/source/drawingml/chart/chartspacefragment.cxx           |    3 
 oox/source/drawingml/chart/chartspacemodel.cxx              |    2 
 oox/source/drawingml/chart/objectformatter.cxx              |   37 ++++++++----
 oox/source/helper/graphichelper.cxx                         |    4 -
 oox/source/ppt/pptimport.cxx                                |    6 -
 10 files changed, 62 insertions(+), 26 deletions(-)

New commits:
commit 225054ca85e0a853baaa4213f19971fb3417de29
Author: Andras Timar <andras.timar at collabora.com>
Date:   Thu Feb 19 11:55:01 2015 +0100

    fix chart2 unit test backport
    
    Change-Id: I40a3816b0a942ca9dcdb84c0fe96b21c71496c9f

diff --git a/chart2/qa/extras/chart2import.cxx b/chart2/qa/extras/chart2import.cxx
index 07b3dc0..2a684ed 100644
--- a/chart2/qa/extras/chart2import.cxx
+++ b/chart2/qa/extras/chart2import.cxx
@@ -18,6 +18,7 @@
 #include <com/sun/star/chart/XChartData.hpp>
 #include <com/sun/star/chart2/XInternalDataProvider.hpp>
 #include <com/sun/star/chart/XChartDataArray.hpp>
+#include <com/sun/star/drawing/FillStyle.hpp>
 
 class Chart2ImportTest : public ChartTest
 {
commit bf7ff8f265a8a832e9872f60e8399f7e6d173d00
Author: Muthu Subramanian <muthu.subramanian.karunanidhi at ericsson.com>
Date:   Fri Oct 10 18:59:46 2014 +0530

    fdo#54361: Chart background in XLSX is transparent instead of white.
    
    (cherry picked from commit aad90e18cd00ac8af6bcddf14e4e19c9475dedbf)
    
    Conflicts:
    	oox/source/drawingml/chart/objectformatter.cxx
    
    Change-Id: I116e7e8c9046009cfcadc04b5367a6fe25f88d96

diff --git a/oox/source/drawingml/chart/objectformatter.cxx b/oox/source/drawingml/chart/objectformatter.cxx
index 22b9931..d6cd258 100644
--- a/oox/source/drawingml/chart/objectformatter.cxx
+++ b/oox/source/drawingml/chart/objectformatter.cxx
@@ -630,7 +630,8 @@ class FillFormatter : public DetailFormatterBase
 public:
     explicit            FillFormatter(
                             ObjectFormatterData& rData,
-                            const AutoFormatEntry* pAutoFormatEntry );
+                            const AutoFormatEntry* pAutoFormatEntry,
+                            const ObjectType eObjType );
 
     /** Converts area formatting to the passed property set. */
     void                convertFormatting(
@@ -691,7 +692,8 @@ public:
     explicit            ObjectTypeFormatter(
                             ObjectFormatterData& rData,
                             const ObjectTypeFormatEntry& rEntry,
-                            const ChartSpaceModel& rChartSpace );
+                            const ChartSpaceModel& rChartSpace,
+                            const ObjectType eObjType );
 
     /** Sets frame formatting properties to the passed property set. */
     void                convertFrameFormatting(
@@ -873,15 +875,14 @@ void LineFormatter::convertFormatting( ShapePropertyMap& rPropMap, const ModelRe
     aLineProps.pushToPropMap( rPropMap, mrData.mrFilter.getGraphicHelper(), getPhColor( nSeriesIdx ) );
 }
 
-// ============================================================================
-
-FillFormatter::FillFormatter( ObjectFormatterData& rData, const AutoFormatEntry* pAutoFormatEntry ) :
+FillFormatter::FillFormatter( ObjectFormatterData& rData, const AutoFormatEntry* pAutoFormatEntry, const ObjectType eObjType ) :
     DetailFormatterBase( rData, pAutoFormatEntry )
 {
     if( pAutoFormatEntry )
     {
         mxAutoFill.reset( new FillProperties );
-        mxAutoFill->moFillType = XML_noFill;
+        if( eObjType != OBJECTTYPE_CHARTSPACE )
+            mxAutoFill->moFillType = XML_noFill;
         if( const Theme* pTheme = mrData.mrFilter.getCurrentTheme() )
             if( const FillProperties* pFillProps = pTheme->getFillStyle( pAutoFormatEntry->mnThemedIdx ) )
                 *mxAutoFill = *pFillProps;
@@ -967,11 +968,9 @@ void TextFormatter::convertFormatting( PropertySet& rPropSet, const ModelRef< Te
     convertFormatting( rPropSet, lclGetTextProperties( rxTextProp ) );
 }
 
-// ============================================================================
-
-ObjectTypeFormatter::ObjectTypeFormatter( ObjectFormatterData& rData, const ObjectTypeFormatEntry& rEntry, const ChartSpaceModel& rChartSpace ) :
+ObjectTypeFormatter::ObjectTypeFormatter( ObjectFormatterData& rData, const ObjectTypeFormatEntry& rEntry, const ChartSpaceModel& rChartSpace, const ObjectType eObjType ) :
     maLineFormatter(   rData, lclGetAutoFormatEntry( rEntry.mpAutoLines,   rChartSpace.mnStyle ) ),
-    maFillFormatter(   rData, lclGetAutoFormatEntry( rEntry.mpAutoFills,   rChartSpace.mnStyle ) ),
+    maFillFormatter(   rData, lclGetAutoFormatEntry( rEntry.mpAutoFills,   rChartSpace.mnStyle ), eObjType ),
     maEffectFormatter( rData, lclGetAutoFormatEntry( rEntry.mpAutoEffects, rChartSpace.mnStyle ) ),
     maTextFormatter(   rData, lclGetAutoTextEntry(   rEntry.mpAutoTexts,   rChartSpace.mnStyle ), rChartSpace.mxTextProp ),
     mrModelObjHelper( rData.maModelObjHelper ),
@@ -1024,7 +1023,7 @@ ObjectFormatterData::ObjectFormatterData( const XmlFilterBase& rFilter, const Re
 {
     const ObjectTypeFormatEntry* pEntryEnd = STATIC_ARRAY_END( spObjTypeFormatEntries );
     for( const ObjectTypeFormatEntry* pEntry = spObjTypeFormatEntries; pEntry != pEntryEnd; ++pEntry )
-        maTypeFormatters[ pEntry->meObjType ].reset( new ObjectTypeFormatter( *this, *pEntry, rChartSpace ) );
+        maTypeFormatters[ pEntry->meObjType ].reset( new ObjectTypeFormatter( *this, *pEntry, rChartSpace, pEntry->meObjType ) );
 
     try
     {
commit 9d0a08542503f7696f7766c791d6718e72725dc7
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Wed Feb 18 22:00:11 2015 +0100

    no need for that anymore
    
    (cherry picked from commit de684f47da785c0da6194df1f582648ebf3d1569)
    
    Conflicts:
    	oox/source/drawingml/chart/chartspaceconverter.cxx
    
    Change-Id: I53002c0b97da66c44429b5ace0fc709b5e8a325f

diff --git a/oox/source/drawingml/chart/chartspaceconverter.cxx b/oox/source/drawingml/chart/chartspaceconverter.cxx
index 3b7961a..c347bbb 100644
--- a/oox/source/drawingml/chart/chartspaceconverter.cxx
+++ b/oox/source/drawingml/chart/chartspaceconverter.cxx
@@ -80,11 +80,6 @@ void ChartSpaceConverter::convertFromModel( const Reference< XShapes >& rxExtern
 
     // 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()));
-
     getFormatter().convertFrameFormatting( aBackPropSet, mrModel.mxShapeProp, OBJECTTYPE_CHARTSPACE );
 
     // convert plot area (container of all chart type groups)
commit f95aeba3f32596b6bb623610aa8a5fd2289f4cf4
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Wed Feb 18 21:44:28 2015 +0100

    add test for missing chart area style fill import, tdf#89451
    
    (cherry picked from commit a9924d94e7db6db50b8b36a311f7d7abf80e4700)
    
    Conflicts:
    	chart2/qa/extras/chart2import.cxx
    
    Change-Id: I052838eaf4134a72feb067fc2a1355fabcafe11f

diff --git a/chart2/qa/extras/chart2import.cxx b/chart2/qa/extras/chart2import.cxx
index 67ada39..07b3dc0 100644
--- a/chart2/qa/extras/chart2import.cxx
+++ b/chart2/qa/extras/chart2import.cxx
@@ -34,6 +34,7 @@ public:
     void testPPTXChartSeries();
     void testPPTChartSeries();
     void testODPChartSeries();
+    void testChartAreaStyleBackgroundXLSX();
     void testNumberFormatsXLSX();
 
     CPPUNIT_TEST_SUITE(Chart2ImportTest);
@@ -55,6 +56,7 @@ public:
 //    CPPUNIT_TEST(testPPTChartSeries);
 //    CPPUNIT_TEST(testPPTXChartSeries);
 //    CPPUNIT_TEST(testODPChartSeries);
+    CPPUNIT_TEST(testChartAreaStyleBackgroundXLSX);
     CPPUNIT_TEST(testNumberFormatsXLSX);
     CPPUNIT_TEST_SUITE_END();
 
@@ -297,6 +299,23 @@ void Chart2ImportTest::testODPChartSeries()
     CPPUNIT_ASSERT_EQUAL(OUString("Column 3"), seriesList[2]);
 
 }
+void Chart2ImportTest::testChartAreaStyleBackgroundXLSX()
+{
+    load("/chart2/qa/extras/data/xlsx/", "chart-area-style-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_EQUAL_MESSAGE("'Automatic' chart background fill in xlsx should be loaded as solid white.",
+        sal_Int32(0), nColor);
+}
+
 
 void Chart2ImportTest::testNumberFormatsXLSX()
 {
diff --git a/chart2/qa/extras/data/xlsx/chart-area-style-background.xlsx b/chart2/qa/extras/data/xlsx/chart-area-style-background.xlsx
new file mode 100644
index 0000000..2baf1e2
Binary files /dev/null and b/chart2/qa/extras/data/xlsx/chart-area-style-background.xlsx differ
commit 1141870c3c8f8e89370e3866045ffbd351fbba6a
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Wed Feb 18 21:19:08 2015 +0100

    better way to set default for chart area fill style, related tdf#89451
    
    (cherry picked from commit 32fe0c6adcff25a0df536127ca980413e1cabefd)
    
    Conflicts:
    	oox/source/ppt/pptimport.cxx
    
    Change-Id: Iee7fea0f55cf54d43a349b6cc0ffa25995069e40

diff --git a/include/oox/helper/graphichelper.hxx b/include/oox/helper/graphichelper.hxx
index 761156f..7689a16 100644
--- a/include/oox/helper/graphichelper.hxx
+++ b/include/oox/helper/graphichelper.hxx
@@ -76,7 +76,7 @@ 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;
+    virtual sal_Int32 getDefaultChartAreaFillStyle() const;
 
     // Device info and device dependent unit conversion -----------------------
 
diff --git a/oox/source/drawingml/chart/objectformatter.cxx b/oox/source/drawingml/chart/objectformatter.cxx
index d7446a8..22b9931 100644
--- a/oox/source/drawingml/chart/objectformatter.cxx
+++ b/oox/source/drawingml/chart/objectformatter.cxx
@@ -32,6 +32,7 @@
 #include "oox/drawingml/theme.hxx"
 #include "oox/drawingml/chart/chartspacemodel.hxx"
 #include "oox/helper/modelobjecthelper.hxx"
+#include <oox/helper/graphichelper.hxx>
 
 namespace oox {
 namespace drawingml {
@@ -884,6 +885,11 @@ FillFormatter::FillFormatter( ObjectFormatterData& rData, const AutoFormatEntry*
         if( const Theme* pTheme = mrData.mrFilter.getCurrentTheme() )
             if( const FillProperties* pFillProps = pTheme->getFillStyle( pAutoFormatEntry->mnThemedIdx ) )
                 *mxAutoFill = *pFillProps;
+
+        if (eObjType == OBJECTTYPE_CHARTSPACE)
+        {
+            mxAutoFill->moFillType = rData.mrFilter.getGraphicHelper().getDefaultChartAreaFillStyle();
+        }
     }
 }
 
diff --git a/oox/source/helper/graphichelper.cxx b/oox/source/helper/graphichelper.cxx
index 62d0dd5..dd2681d 100644
--- a/oox/source/helper/graphichelper.cxx
+++ b/oox/source/helper/graphichelper.cxx
@@ -158,9 +158,9 @@ sal_Int32 GraphicHelper::getPaletteColor( sal_Int32 /*nPaletteIdx*/ ) const
     return API_RGB_TRANSPARENT;
 }
 
-drawing::FillStyle GraphicHelper::getDefaultChartAreaFillStyle() const
+sal_Int32 GraphicHelper::getDefaultChartAreaFillStyle() const
 {
-    return drawing::FillStyle_SOLID;
+    return XML_solidFill;
 }
 
 // Device info and device dependent unit conversion ---------------------------
diff --git a/oox/source/ppt/pptimport.cxx b/oox/source/ppt/pptimport.cxx
index 259e716..aad4cc5 100644
--- a/oox/source/ppt/pptimport.cxx
+++ b/oox/source/ppt/pptimport.cxx
@@ -187,7 +187,7 @@ class PptGraphicHelper : public GraphicHelper
 public:
     explicit            PptGraphicHelper( const PowerPointImport& rFilter );
     virtual sal_Int32   getSchemeColor( sal_Int32 nToken ) const;
-    virtual drawing::FillStyle getDefaultChartAreaFillStyle() const;
+    virtual sal_Int32 getDefaultChartAreaFillStyle() const;
 private:
     const PowerPointImport& mrFilter;
 };
@@ -203,9 +203,9 @@ sal_Int32 PptGraphicHelper::getSchemeColor( sal_Int32 nToken ) const
     return mrFilter.getSchemeColor( nToken );
 }
 
-drawing::FillStyle PptGraphicHelper::getDefaultChartAreaFillStyle() const
+sal_Int32 PptGraphicHelper::getDefaultChartAreaFillStyle() const
 {
-    return drawing::FillStyle_NONE;
+    return XML_noFill;
 }
 
 } // namespace
commit 5b5ea27cfdf614caca14af2b973063eef2cc77c3
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Wed Feb 18 20:16:43 2015 +0100

    implement fill based on style also for chart area, tdf#89451
    
    Change-Id: I7b488e222cd44e75d1e0ff7f8e545e9399f418b5
    (cherry picked from commit a51300bc9223b28fc5da6059e4fe1d2af62fb323)

diff --git a/oox/source/drawingml/chart/objectformatter.cxx b/oox/source/drawingml/chart/objectformatter.cxx
index 0e4b914..d7446a8 100644
--- a/oox/source/drawingml/chart/objectformatter.cxx
+++ b/oox/source/drawingml/chart/objectformatter.cxx
@@ -171,6 +171,14 @@ static const AutoFormatEntry spNoFormats[] =
     AUTOFORMAT_END()
 };
 
+static const AutoFormatEntry spChartSpaceFill[] =
+{
+    AUTOFORMAT_COLOR( 1, 32, THEMED_STYLE_SUBTLE, XML_bg1 ),
+    AUTOFORMAT_COLOR( 33, 40, THEMED_STYLE_SUBTLE, XML_lt1 ),
+    AUTOFORMAT_COLOR( 41, 48, THEMED_STYLE_SUBTLE, XML_dk1 ),
+    AUTOFORMAT_END()
+};
+
 static const AutoFormatEntry spDataTableLines[] =
 {
     AUTOFORMAT_COLORMOD(  1, 32, THEMED_STYLE_SUBTLE, XML_tx1, XML_tint, 75000 ),
@@ -522,7 +530,7 @@ struct ObjectTypeFormatEntry
 static const ObjectTypeFormatEntry spObjTypeFormatEntries[] =
 {
     //                object type                property info      auto text          auto line            auto fill              auto effect
-    TYPEFORMAT_FRAME( OBJECTTYPE_CHARTSPACE,     &saCommonPropInfo, 0,                 spNoFormats,         spNoFormats,           0 /* eq to Ch2 */ ),
+    TYPEFORMAT_FRAME( OBJECTTYPE_CHARTSPACE,     &saCommonPropInfo, 0,                 spNoFormats,         spChartSpaceFill,      0 /* eq to Ch2 */ ),
     TYPEFORMAT_FRAME( OBJECTTYPE_CHARTTITLE,     &saCommonPropInfo, spChartTitleTexts, 0 /* eq to Ch2 */,   0 /* eq to Ch2 */,     0 /* eq to Ch2 */ ),
     TYPEFORMAT_FRAME( OBJECTTYPE_LEGEND,         &saCommonPropInfo, spOtherTexts,      spNoFormats,         spNoFormats,           0 /* eq to Ch2 */ ),
     TYPEFORMAT_FRAME( OBJECTTYPE_PLOTAREA2D,     &saCommonPropInfo, 0,                 0 /* eq to Ch2 */,   spPlotArea2dFills,     0 /* eq to Ch2 */ ),
commit 3b44fc8c4b4a4469ae1e4d511d2c0df15c026c4e
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Thu Feb 19 01:32:54 2015 +0100

    document one more place where MSO 2007 export wrong values
    
    (cherry picked from commit 5fb41ae3920cd635fa42057e1623aa21bcb53167)
    
    Conflicts:
    	oox/source/drawingml/chart/chartspacefragment.cxx
    
    Change-Id: Ic35f1188e66cf89f203b34f354a2c4b11f1f65a2

diff --git a/oox/source/drawingml/chart/chartspacefragment.cxx b/oox/source/drawingml/chart/chartspacefragment.cxx
index 2e717a8..9917588 100644
--- a/oox/source/drawingml/chart/chartspacefragment.cxx
+++ b/oox/source/drawingml/chart/chartspacefragment.cxx
@@ -81,8 +81,7 @@ ContextHandlerRef ChartSpaceFragment::onCreateContext( sal_Int32 nElement, const
             switch( nElement )
             {
                 case C_TOKEN( autoTitleDeleted ):
-                    // default is 'false', not 'true' as specified
-                    mrModel.mbAutoTitleDel = rAttribs.getBool( XML_val, false );
+                    mrModel.mbAutoTitleDel = rAttribs.getBool( XML_val, true ); // TODO: OOXML_spec
                     return 0;
                 case C_TOKEN( backWall ):
                     return new WallFloorContext( *this, mrModel.mxBackWall.create() );
commit de6afbecc1220fef01ed33c5db5cdc6ba47c9583
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Wed Feb 18 19:53:36 2015 +0100

    start documenting problems around OOXML spec
    
    We implement in many places wrong default values based on how MSO 2007
    behaves. Newer MSO versions produce correct files so our import is
    wrong. Instead of changing the default value we need to be able to use
    default values based on the document producer.
    
    Change-Id: I6a2a0b30885ebccc384d17f896709ecdd475d786
    (cherry picked from commit ffc0391e2e9d797ef8ce3d1089e8d9d2b11a5ead)

diff --git a/oox/README b/oox/README
index a253079..22a3c3a 100644
--- a/oox/README
+++ b/oox/README
@@ -3,6 +3,15 @@ Support for Office Open XML, the office XML-format designed by Microsoft.
 See also:
 [http://wiki.openoffice.org/wiki/OOX]
 
+
+The "TODO: OOXML_spec" comments are related to wrong implementation of the spec. The oox code was
+written against the OOXML dialect produced by MSO 2007,
+which is not standard compliant. Newer MSO version use the correct
+default values as desribed in the spec. We need a way to handle both in the future.
+The first step is to mark these places when you see them. Many of them
+already have a comment that the implemented default value is not
+in line with the spec.
+
 == DrawingML Custom shapes and presets ==
 
 custom shapes are part of DrawingML and are different to binary ppt
diff --git a/oox/source/drawingml/chart/chartspacemodel.cxx b/oox/source/drawingml/chart/chartspacemodel.cxx
index 7bf4793..d36a2f2 100644
--- a/oox/source/drawingml/chart/chartspacemodel.cxx
+++ b/oox/source/drawingml/chart/chartspacemodel.cxx
@@ -26,7 +26,7 @@ namespace chart {
 // ============================================================================
 
 ChartSpaceModel::ChartSpaceModel() :
-    mnDispBlanksAs( XML_gap ),  // not zero as specified
+    mnDispBlanksAs( XML_gap ),  // not zero as specified, TODO: OOXML_spec
     mnStyle( 2 ),
     mbAutoTitleDel( false ),
     mbPlotVisOnly( false ),


More information about the Libreoffice-commits mailing list