summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTünde Tóth <tundeth@gmail.com>2020-03-17 15:25:56 +0100
committerLászló Németh <nemeth@numbertext.org>2020-03-30 12:45:57 +0200
commitab40a7843a66d1fe276224db16ddaecd538df234 (patch)
tree9651bd37bc32f184de0eca75d2aa83658f612c9c
parent55c8ab7294e9e1651b94215d4ff14c7afcb7d733 (diff)
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@numbertext.org> Reviewed-by: László Németh <nemeth@numbertext.org>
-rw-r--r--chart2/qa/extras/chart2export.cxx27
-rw-r--r--oox/inc/drawingml/chart/titlemodel.hxx2
-rw-r--r--oox/source/drawingml/chart/chartspacefragment.cxx2
-rw-r--r--oox/source/drawingml/chart/titlecontext.cxx6
-rw-r--r--oox/source/drawingml/chart/titleconverter.cxx3
-rw-r--r--oox/source/drawingml/chart/titlemodel.cxx4
-rw-r--r--oox/source/export/chartexport.cxx6
-rw-r--r--oox/source/token/properties.txt1
-rw-r--r--schema/libreoffice/OpenDocument-schema-v1.3+libreoffice.rng9
9 files changed, 43 insertions, 17 deletions
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>