[Libreoffice-commits] core.git: chart2/qa oox/inc oox/source schema/libreoffice

Tünde Tóth (via logerrit) logerrit at kemper.freedesktop.org
Mon Mar 30 10:46:36 UTC 2020


 chart2/qa/extras/chart2export.cxx                           |   27 ++++++++----
 oox/inc/drawingml/chart/titlemodel.hxx                      |    2 
 oox/source/drawingml/chart/chartspacefragment.cxx           |    2 
 oox/source/drawingml/chart/titlecontext.cxx                 |    6 --
 oox/source/drawingml/chart/titleconverter.cxx               |    3 +
 oox/source/drawingml/chart/titlemodel.cxx                   |    4 -
 oox/source/export/chartexport.cxx                           |    6 ++
 oox/source/token/properties.txt                             |    1 
 schema/libreoffice/OpenDocument-schema-v1.3+libreoffice.rng |    9 ++++
 9 files changed, 43 insertions(+), 17 deletions(-)

New commits:
commit ab40a7843a66d1fe276224db16ddaecd538df234
Author:     Tünde Tóth <tundeth at gmail.com>
AuthorDate: Tue Mar 17 15:25:56 2020 +0100
Commit:     László Németh <nemeth at numbertext.org>
CommitDate: Mon Mar 30 12:45:57 2020 +0200

    tdf#131370 chart: implement OOXML import/export of legend overlay feature
    
    Follow-up of the following commits related to the new UNO property
    Overlay for legends:
    
    commit 9fab1ba8ddc59924c633aa17c65f7330a4762726
    (tdf#75330 add a new overlay/no-overlay feature for the legend)
    
    commit 65123d41f62597053bc3893ee4fb46868a6b1f2d
    (tdf#75330 chart: implement ODF import/export of legend overlay feature)
    
    Change-Id: Ie3eff9b8a4f99980a7ae28add909a27eb0e9d14b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90655
    Tested-by: Jenkins
    Tested-by: László Németh <nemeth at numbertext.org>
    Reviewed-by: László Németh <nemeth at numbertext.org>

diff --git a/chart2/qa/extras/chart2export.cxx b/chart2/qa/extras/chart2export.cxx
index 323a026594d8..0570ca4697c6 100644
--- a/chart2/qa/extras/chart2export.cxx
+++ b/chart2/qa/extras/chart2export.cxx
@@ -2597,16 +2597,27 @@ void Chart2ExportTest::testTdf126076()
 
 void Chart2ExportTest::testTdf75330()
 {
-    mbSkipValidation = true;
     load("/chart2/qa/extras/data/ods/", "legend_overlay.ods");
     reload("calc8");
-    uno::Reference< chart2::XChartDocument > xChart2Doc = getChartDocFromSheet(0, mxComponent);
-    uno::Reference< chart::XChartDocument > xChartDoc (xChart2Doc, uno::UNO_QUERY);
-    uno::Reference<drawing::XShape> xLegend = xChartDoc->getLegend();
-    Reference<beans::XPropertySet> xPropertySet(xLegend, uno::UNO_QUERY_THROW);
-    bool bOverlay = false;
-    CPPUNIT_ASSERT(xPropertySet->getPropertyValue("Overlay") >>= bOverlay);
-    CPPUNIT_ASSERT(bOverlay);
+    {
+        uno::Reference<chart2::XChartDocument> xChart2Doc = getChartDocFromSheet(0, mxComponent);
+        uno::Reference<chart::XChartDocument> xChartDoc(xChart2Doc, uno::UNO_QUERY);
+        uno::Reference<drawing::XShape> xLegend = xChartDoc->getLegend();
+        Reference<beans::XPropertySet> xPropertySet(xLegend, uno::UNO_QUERY_THROW);
+        bool bOverlay = false;
+        CPPUNIT_ASSERT(xPropertySet->getPropertyValue("Overlay") >>= bOverlay);
+        CPPUNIT_ASSERT(bOverlay);
+    }
+    reload("Calc Office Open XML");
+    {
+        uno::Reference<chart2::XChartDocument> xChart2Doc = getChartDocFromSheet(0, mxComponent);
+        uno::Reference<chart::XChartDocument> xChartDoc(xChart2Doc, uno::UNO_QUERY);
+        uno::Reference<drawing::XShape> xLegend = xChartDoc->getLegend();
+        Reference<beans::XPropertySet> xPropertySet(xLegend, uno::UNO_QUERY_THROW);
+        bool bOverlay = false;
+        CPPUNIT_ASSERT(xPropertySet->getPropertyValue("Overlay") >>= bOverlay);
+        CPPUNIT_ASSERT(bOverlay);
+    }
 }
 
 CPPUNIT_TEST_SUITE_REGISTRATION(Chart2ExportTest);
diff --git a/oox/inc/drawingml/chart/titlemodel.hxx b/oox/inc/drawingml/chart/titlemodel.hxx
index c31b8d34ba73..4b693e2e60e0 100644
--- a/oox/inc/drawingml/chart/titlemodel.hxx
+++ b/oox/inc/drawingml/chart/titlemodel.hxx
@@ -80,7 +80,7 @@ struct LegendModel
     sal_Int32           mnPosition;         /// Legend position.
     bool                mbOverlay;          /// True = legend may overlay other objects.
 
-    explicit            LegendModel(bool bMSO2007Doc);
+    explicit            LegendModel();
                         ~LegendModel();
 };
 
diff --git a/oox/source/drawingml/chart/chartspacefragment.cxx b/oox/source/drawingml/chart/chartspacefragment.cxx
index 4d5d9158567f..aa045d4a5079 100644
--- a/oox/source/drawingml/chart/chartspacefragment.cxx
+++ b/oox/source/drawingml/chart/chartspacefragment.cxx
@@ -98,7 +98,7 @@ ContextHandlerRef ChartSpaceFragment::onCreateContext( sal_Int32 nElement, const
                 case C_TOKEN( floor ):
                     return new WallFloorContext( *this, mrModel.mxFloor.create() );
                 case C_TOKEN( legend ):
-                    return new LegendContext( *this, mrModel.mxLegend.create(bMSO2007Document) );
+                    return new LegendContext( *this, mrModel.mxLegend.create() );
                 case C_TOKEN( plotArea ):
                     return new PlotAreaContext( *this, mrModel.mxPlotArea.create() );
                 case C_TOKEN( plotVisOnly ):
diff --git a/oox/source/drawingml/chart/titlecontext.cxx b/oox/source/drawingml/chart/titlecontext.cxx
index f62d8ced995f..35ba44cf60fc 100644
--- a/oox/source/drawingml/chart/titlecontext.cxx
+++ b/oox/source/drawingml/chart/titlecontext.cxx
@@ -88,7 +88,6 @@ TitleContext::~TitleContext()
 
 ContextHandlerRef TitleContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
 {
-    bool bMSO2007Doc = getFilter().isMSO2007Document();
     // this context handler is used for <c:title> only
     switch( nElement )
     {
@@ -96,7 +95,7 @@ ContextHandlerRef TitleContext::onCreateContext( sal_Int32 nElement, const Attri
             return new LayoutContext( *this, mrModel.mxLayout.create() );
 
         case C_TOKEN( overlay ):
-            mrModel.mbOverlay = rAttribs.getBool( XML_val, !bMSO2007Doc );
+            mrModel.mbOverlay = rAttribs.getBool( XML_val, true );
             return nullptr;
 
         case C_TOKEN( spPr ):
@@ -147,7 +146,6 @@ LegendContext::~LegendContext()
 
 ContextHandlerRef LegendContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
 {
-    bool bMSO2007Doc = getFilter().isMSO2007Document();
     // this context handler is used for <c:legend> only
     switch( nElement )
     {
@@ -162,7 +160,7 @@ ContextHandlerRef LegendContext::onCreateContext( sal_Int32 nElement, const Attr
             return new LegendEntryContext( *this, mrModel.maLegendEntries.create() );
 
         case C_TOKEN( overlay ):
-            mrModel.mbOverlay = rAttribs.getBool( XML_val, !bMSO2007Doc );
+            mrModel.mbOverlay = rAttribs.getBool( XML_val, true );
             return nullptr;
 
         case C_TOKEN( spPr ):
diff --git a/oox/source/drawingml/chart/titleconverter.cxx b/oox/source/drawingml/chart/titleconverter.cxx
index c0de3919571e..10ebd308b4fa 100644
--- a/oox/source/drawingml/chart/titleconverter.cxx
+++ b/oox/source/drawingml/chart/titleconverter.cxx
@@ -249,6 +249,9 @@ void LegendConverter::convertFromModel( const Reference< XDiagram >& rxDiagram )
 
         if (bTopRight && !bManualLayout)
             aPropSet.setProperty( PROP_RelativePosition , makeAny(eRelPos));
+
+        aPropSet.setProperty(PROP_Overlay, mrModel.mbOverlay);
+
         if (mrModel.maLegendEntries.size() > 0)
             legendEntriesFormatting(rxDiagram);
     }
diff --git a/oox/source/drawingml/chart/titlemodel.cxx b/oox/source/drawingml/chart/titlemodel.cxx
index ff1891d02f8d..f28520573904 100644
--- a/oox/source/drawingml/chart/titlemodel.cxx
+++ b/oox/source/drawingml/chart/titlemodel.cxx
@@ -50,9 +50,9 @@ LegendEntryModel::~LegendEntryModel()
 {
 }
 
-LegendModel::LegendModel(bool bMSO2007Doc) :
+LegendModel::LegendModel() :
     mnPosition( XML_r ),
-    mbOverlay( !bMSO2007Doc )
+    mbOverlay( false )
 {
 }
 
diff --git a/oox/source/export/chartexport.cxx b/oox/source/export/chartexport.cxx
index 78685f38b5d3..2d7758fb7ed0 100644
--- a/oox/source/export/chartexport.cxx
+++ b/oox/source/export/chartexport.cxx
@@ -1197,7 +1197,11 @@ void ChartExport::exportLegend( const Reference< css::chart::XChartDocument >& x
 
         if (strPos != nullptr)
         {
-            pFS->singleElement(FSNS(XML_c, XML_overlay), XML_val, "0");
+            uno::Any aOverlay = xProp->getPropertyValue("Overlay");
+            if(aOverlay.get<bool>())
+                pFS->singleElement(FSNS(XML_c, XML_overlay), XML_val, "1");
+            else
+                pFS->singleElement(FSNS(XML_c, XML_overlay), XML_val, "0");
         }
 
         // shape properties
diff --git a/oox/source/token/properties.txt b/oox/source/token/properties.txt
index 4624573d579b..83dd8f9ff3d1 100644
--- a/oox/source/token/properties.txt
+++ b/oox/source/token/properties.txt
@@ -347,6 +347,7 @@ Opaque
 Orientation
 OutputPosition
 OverlapSequence
+Overlay
 PageScale
 PageStyle
 PageToggle
diff --git a/schema/libreoffice/OpenDocument-schema-v1.3+libreoffice.rng b/schema/libreoffice/OpenDocument-schema-v1.3+libreoffice.rng
index e44c01bd8d06..05607e00f571 100644
--- a/schema/libreoffice/OpenDocument-schema-v1.3+libreoffice.rng
+++ b/schema/libreoffice/OpenDocument-schema-v1.3+libreoffice.rng
@@ -2430,4 +2430,13 @@ xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.
     </rng:optional>
   </rng:define>
 
+  <!-- TODO no proposal -->
+  <rng:define name="chart-legend-attlist" combine="interleave">
+    <rng:optional>
+      <rng:attribute name="loext:overlay">
+        <rng:ref name="boolean"/>
+      </rng:attribute>
+    </rng:optional>
+  </rng:define>
+
 </rng:grammar>


More information about the Libreoffice-commits mailing list