diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2013-03-17 02:53:02 +0100 |
---|---|---|
committer | Petr Mladek <pmladek@suse.cz> | 2013-03-25 15:43:33 +0000 |
commit | 2f66ba2490af85a01beb31d086df9c5b26cd29b1 (patch) | |
tree | a9e2fcb44c26e10c3129c74a43b65275190daf2f | |
parent | 34925853dbd32faa5fc49e1f96c2ffb42114974a (diff) |
error bar range is also part of chart range, related fdo#52159
Change-Id: I344448db559de8435dcc26e2be4597c385724a7b
(cherry picked from commit e15d8ef44fbf9fc23da58648e4d288782a81c7c1)
Reviewed-on: https://gerrit.libreoffice.org/2820
Reviewed-by: Fridrich Strba <fridrich@documentfoundation.org>
Tested-by: Fridrich Strba <fridrich@documentfoundation.org>
(cherry picked from commit 875a8fb01238e998fc6e64fbf7a4e51c18973e61)
Reviewed-on: https://gerrit.libreoffice.org/2984
Reviewed-by: Eike Rathke <erack@redhat.com>
Reviewed-by: Petr Mladek <pmladek@suse.cz>
Tested-by: Petr Mladek <pmladek@suse.cz>
-rw-r--r-- | sc/source/ui/view/drawvie4.cxx | 87 |
1 files changed, 70 insertions, 17 deletions
diff --git a/sc/source/ui/view/drawvie4.cxx b/sc/source/ui/view/drawvie4.cxx index ceebfbdab7fe..adf45ee6de17 100644 --- a/sc/source/ui/view/drawvie4.cxx +++ b/sc/source/ui/view/drawvie4.cxx @@ -46,6 +46,9 @@ #include <com/sun/star/embed/Aspects.hpp> #include <com/sun/star/embed/XEmbeddedObject.hpp> #include <com/sun/star/embed/XComponentSupplier.hpp> +#include <com/sun/star/chart2/XChartTypeContainer.hpp> +#include <com/sun/star/chart2/XCoordinateSystemContainer.hpp> +#include <com/sun/star/chart2/XDataSeriesContainer.hpp> using namespace com::sun::star; @@ -151,6 +154,70 @@ sal_Bool ScDrawView::BeginDrag( Window* pWindow, const Point& rStartPos ) namespace { +void getRangeFromDataSource( uno::Reference< chart2::data::XDataSource > xDataSource, std::vector<OUString>& rRangeRep) +{ + uno::Sequence<uno::Reference<chart2::data::XLabeledDataSequence> > xSeqs = xDataSource->getDataSequences(); + for (sal_Int32 i = 0, n = xSeqs.getLength(); i < n; ++i) + { + uno::Reference<chart2::data::XLabeledDataSequence> xLS = xSeqs[i]; + uno::Reference<chart2::data::XDataSequence> xSeq = xLS->getValues(); + if (xSeq.is()) + { + OUString aRep = xSeq->getSourceRangeRepresentation(); + rRangeRep.push_back(aRep); + } + xSeq = xLS->getLabel(); + if (xSeq.is()) + { + OUString aRep = xSeq->getSourceRangeRepresentation(); + rRangeRep.push_back(aRep); + } + } +} + + +void getRangeFromErrorBar(const uno::Reference< chart2::XChartDocument > xChartDoc, std::vector<OUString>& rRangeRep) +{ + uno::Reference <chart2::XDiagram > xDiagram = xChartDoc->getFirstDiagram(); + if(!xDiagram.is()) + return; + + uno::Reference< chart2::XCoordinateSystemContainer > xCooSysContainer( xDiagram, uno::UNO_QUERY); + if(!xCooSysContainer.is()) + return; + + uno::Sequence< uno::Reference< chart2::XCoordinateSystem > > xCooSysSequence( xCooSysContainer->getCoordinateSystems()); + for(sal_Int32 i = 0; i < xCooSysSequence.getLength(); ++i) + { + uno::Reference< chart2::XChartTypeContainer > xChartTypeContainer( xCooSysSequence[i], uno::UNO_QUERY); + if(!xChartTypeContainer.is()) + continue; + + uno::Sequence< uno::Reference< chart2::XChartType > > xChartTypeSequence( xChartTypeContainer->getChartTypes() ); + for(sal_Int32 nChartType = 0; nChartType < xChartTypeSequence.getLength(); ++nChartType) + { + uno::Reference< chart2::XDataSeriesContainer > xDataSequenceContainer( xChartTypeSequence[nChartType], uno::UNO_QUERY); + if(!xDataSequenceContainer.is()) + continue; + + uno::Sequence< uno::Reference< chart2::XDataSeries > > xSeriesSequence( xDataSequenceContainer->getDataSeries() ); + for(sal_Int32 nDataSeries = 0; nDataSeries < xSeriesSequence.getLength(); ++nDataSeries) + { + uno::Reference< chart2::XDataSeries > xSeries = xSeriesSequence[nDataSeries]; + uno::Reference< beans::XPropertySet > xPropSet( xSeries, uno::UNO_QUERY); + uno::Reference< chart2::data::XDataSource > xErrorBarY; + xPropSet->getPropertyValue("ErrorBarY") >>= xErrorBarY; + if(xErrorBarY.is()) + getRangeFromDataSource(xErrorBarY, rRangeRep); + uno::Reference< chart2::data::XDataSource > xErrorBarX; + xPropSet->getPropertyValue("ErrorBarX") >>= xErrorBarX; + if(xErrorBarX.is()) + getRangeFromDataSource(xErrorBarX, rRangeRep); + } + } + } +} + void getRangeFromOle2Object(const SdrOle2Obj& rObj, std::vector<OUString>& rRangeRep) { if (!rObj.IsChart()) @@ -172,28 +239,14 @@ void getRangeFromOle2Object(const SdrOle2Obj& rObj, std::vector<OUString>& rRang if(xChartDoc->hasInternalDataProvider()) return; + getRangeFromErrorBar(xChartDoc, rRangeRep); + uno::Reference<chart2::data::XDataSource> xDataSource(xChartDoc, uno::UNO_QUERY); if (!xDataSource.is()) return; // Get all data sources used in this chart. - uno::Sequence<uno::Reference<chart2::data::XLabeledDataSequence> > xSeqs = xDataSource->getDataSequences(); - for (sal_Int32 i = 0, n = xSeqs.getLength(); i < n; ++i) - { - uno::Reference<chart2::data::XLabeledDataSequence> xLS = xSeqs[i]; - uno::Reference<chart2::data::XDataSequence> xSeq = xLS->getValues(); - if (xSeq.is()) - { - OUString aRep = xSeq->getSourceRangeRepresentation(); - rRangeRep.push_back(aRep); - } - xSeq = xLS->getLabel(); - if (xSeq.is()) - { - OUString aRep = xSeq->getSourceRangeRepresentation(); - rRangeRep.push_back(aRep); - } - } + getRangeFromDataSource(xDataSource, rRangeRep); } /** |