diff options
author | Balazs Varga <balazs.varga991@gmail.com> | 2018-12-05 16:00:09 +0100 |
---|---|---|
committer | Bartosz Kosiorek <gang65@poczta.onet.pl> | 2018-12-11 09:43:38 +0100 |
commit | ee2434656f24ccb31246b1347d46b72710faf076 (patch) | |
tree | 916283c46e3b853cbe9ce579cfeb8d9d852837c5 /chart2 | |
parent | 030c9f1fcb8fecfd8b80d9f7f73025bab8a1b65b (diff) |
tdf#114163 Chart: fix order of legend names
Respecting the axis direction in case of
normal/stacked/percent stacked Bar chart and
the legend names will be in the right order.
Change-Id: If782393a33e48dae32f919d137e1d1148a85b0b0
Reviewed-on: https://gerrit.libreoffice.org/64632
Tested-by: Jenkins
Reviewed-by: Bartosz Kosiorek <gang65@poczta.onet.pl>
(cherry picked from commit 40144617ce05d7eff86eeb8a412c6991fe0b819e)
Reviewed-on: https://gerrit.libreoffice.org/64835
Reviewed-by: Balazs Varga <balazs.varga991@gmail.com>
Diffstat (limited to 'chart2')
-rw-r--r-- | chart2/source/view/charttypes/VSeriesPlotter.cxx | 21 | ||||
-rw-r--r-- | chart2/source/view/inc/LegendEntryProvider.hxx | 4 | ||||
-rw-r--r-- | chart2/source/view/inc/VSeriesPlotter.hxx | 4 | ||||
-rw-r--r-- | chart2/source/view/main/VLegend.cxx | 2 |
4 files changed, 27 insertions, 4 deletions
diff --git a/chart2/source/view/charttypes/VSeriesPlotter.cxx b/chart2/source/view/charttypes/VSeriesPlotter.cxx index 27f57980f4be..7a45aa8b2d13 100644 --- a/chart2/source/view/charttypes/VSeriesPlotter.cxx +++ b/chart2/source/view/charttypes/VSeriesPlotter.cxx @@ -43,6 +43,7 @@ #include <DateHelper.hxx> #include <DiagramHelper.hxx> #include <defines.hxx> +#include <ChartModel.hxx> //only for creation: @todo remove if all plotter are uno components and instantiated via servicefactory #include "BarChart.hxx" @@ -69,6 +70,7 @@ #include <basegfx/vector/b2dvector.hxx> #include <com/sun/star/drawing/LineStyle.hpp> #include <com/sun/star/util/XCloneable.hpp> +#include <com/sun/star/chart2/XCoordinateSystemContainer.hpp> #include <com/sun/star/container/XEnumerationAccess.hpp> #include <com/sun/star/container/XEnumeration.hpp> @@ -2200,12 +2202,26 @@ std::vector< ViewLegendEntry > VSeriesPlotter::createLegendEntries( , const Reference< drawing::XShapes >& xTarget , const Reference< lang::XMultiServiceFactory >& xShapeFactory , const Reference< uno::XComponentContext >& xContext + , ChartModel& rModel ) { std::vector< ViewLegendEntry > aResult; if( xTarget.is() ) { + uno::Reference< XCoordinateSystemContainer > xCooSysCnt( rModel.getFirstDiagram(), uno::UNO_QUERY ); + Reference< chart2::XCoordinateSystem > xCooSys(xCooSysCnt->getCoordinateSystems()[0]); + Reference< beans::XPropertySet > xProp( xCooSys, uno::UNO_QUERY ); + bool bSwapXAndY = false; + + if( xProp.is()) try + { + xProp->getPropertyValue( "SwapXAndYAxis" ) >>= bSwapXAndY; + } + catch( const uno::Exception& ) + { + } + //iterate through all series bool bBreak = false; bool bFirstSeries = true; @@ -2241,7 +2257,10 @@ std::vector< ViewLegendEntry > VSeriesPlotter::createLegendEntries( StackingDirection eStackingDirection( pSeries->getStackingDirection() ); bReverse = ( eStackingDirection == StackingDirection_Y_STACKING ); - //todo: respect direction of axis in future + if( bSwapXAndY ) + { + bReverse = !bReverse; + } } if (bReverse) diff --git a/chart2/source/view/inc/LegendEntryProvider.hxx b/chart2/source/view/inc/LegendEntryProvider.hxx index 3ad8a94b8832..aff7a5d84116 100644 --- a/chart2/source/view/inc/LegendEntryProvider.hxx +++ b/chart2/source/view/inc/LegendEntryProvider.hxx @@ -25,6 +25,7 @@ #include <com/sun/star/uno/Sequence.h> #include <vector> +namespace chart { class ChartModel; } namespace com { namespace sun { namespace star { namespace beans { class XPropertySet; } } } } namespace com { namespace sun { namespace star { namespace chart2 { class XFormattedString2; } } } } namespace com { namespace sun { namespace star { namespace drawing { class XShape; } } } } @@ -75,7 +76,8 @@ public: const css::uno::Reference< css::beans::XPropertySet >& xTextProperties, const css::uno::Reference< css::drawing::XShapes >& xTarget, const css::uno::Reference< css::lang::XMultiServiceFactory >& xShapeFactory, - const css::uno::Reference< css::uno::XComponentContext >& xContext + const css::uno::Reference< css::uno::XComponentContext >& xContext, + ChartModel& rModel ) = 0; protected: diff --git a/chart2/source/view/inc/VSeriesPlotter.hxx b/chart2/source/view/inc/VSeriesPlotter.hxx index e181c7590a71..445411523359 100644 --- a/chart2/source/view/inc/VSeriesPlotter.hxx +++ b/chart2/source/view/inc/VSeriesPlotter.hxx @@ -33,6 +33,7 @@ namespace com { namespace sun { namespace star { namespace chart2 { class XChart namespace chart { class ExplicitCategoriesProvider; } namespace chart { struct ExplicitScaleData; } +namespace chart { class ChartModel; } namespace com { namespace sun { namespace star { namespace util { @@ -197,7 +198,8 @@ public: const css::uno::Reference< css::beans::XPropertySet >& xTextProperties, const css::uno::Reference< css::drawing::XShapes >& xTarget, const css::uno::Reference< css::lang::XMultiServiceFactory >& xShapeFactory, - const css::uno::Reference< css::uno::XComponentContext >& xContext + const css::uno::Reference< css::uno::XComponentContext >& xContext, + ChartModel& rModel ) override; virtual LegendSymbolStyle getLegendSymbolStyle(); diff --git a/chart2/source/view/main/VLegend.cxx b/chart2/source/view/main/VLegend.cxx index 0e6e32be4988..22c32d510c15 100644 --- a/chart2/source/view/main/VLegend.cxx +++ b/chart2/source/view/main/VLegend.cxx @@ -953,7 +953,7 @@ void VLegend::createShapes( { std::vector<ViewLegendEntry> aNewEntries = pLegendEntryProvider->createLegendEntries( aMaxSymbolExtent, eExpansion, xLegendProp, - xLegendContainer, m_xShapeFactory, m_xContext); + xLegendContainer, m_xShapeFactory, m_xContext, mrModel); aViewEntries.insert( aViewEntries.end(), aNewEntries.begin(), aNewEntries.end() ); } } |