[Libreoffice-commits] core.git: Branch 'libreoffice-4-0-2' - sc/source

Markus Mohrhard markus.mohrhard at googlemail.com
Mon Mar 25 08:43:54 PDT 2013


 sc/source/ui/view/drawvie4.cxx |   87 ++++++++++++++++++++++++++++++++---------
 1 file changed, 70 insertions(+), 17 deletions(-)

New commits:
commit 2f66ba2490af85a01beb31d086df9c5b26cd29b1
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Sun Mar 17 02:53:02 2013 +0100

    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 at documentfoundation.org>
    Tested-by: Fridrich Strba <fridrich at documentfoundation.org>
    (cherry picked from commit 875a8fb01238e998fc6e64fbf7a4e51c18973e61)
    Reviewed-on: https://gerrit.libreoffice.org/2984
    Reviewed-by: Eike Rathke <erack at redhat.com>
    Reviewed-by: Petr Mladek <pmladek at suse.cz>
    Tested-by: Petr Mladek <pmladek at suse.cz>

diff --git a/sc/source/ui/view/drawvie4.cxx b/sc/source/ui/view/drawvie4.cxx
index ceebfbd..adf45ee 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);
 }
 
 /**


More information about the Libreoffice-commits mailing list