[Libreoffice-commits] core.git: chart2/Library_chartcore.mk chart2/source include/svx svx/source

Jan Holesovsky kendy at collabora.com
Fri Sep 12 04:04:20 PDT 2014


 chart2/Library_chartcore.mk                       |    1 
 chart2/source/controller/main/ChartController.cxx |    1 
 chart2/source/inc/GL3DHelper.hxx                  |   29 ----
 chart2/source/model/main/ChartModel.cxx           |    4 
 chart2/source/tools/GL3DHelper.cxx                |   54 --------
 chart2/source/view/main/ChartView.cxx             |    4 
 include/svx/charthelper.hxx                       |    7 +
 include/svx/svdoole2.hxx                          |    1 
 svx/source/sdr/contact/viewobjectcontact.cxx      |   16 ++
 svx/source/svdraw/charthelper.cxx                 |  134 ++++++++++++++--------
 svx/source/svdraw/svdoole2.cxx                    |   19 ++-
 11 files changed, 132 insertions(+), 138 deletions(-)

New commits:
commit aa325833295e3983d93758b0e1194d7fb9365ee7
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Fri Sep 12 12:54:11 2014 +0200

    3D charts: Update the 3D charts when a value changes.
    
    Change-Id: I9c4052108446959ff6f5215d704b496e7a8e6aee

diff --git a/chart2/Library_chartcore.mk b/chart2/Library_chartcore.mk
index 094762d..2543eaa 100644
--- a/chart2/Library_chartcore.mk
+++ b/chart2/Library_chartcore.mk
@@ -199,7 +199,6 @@ $(eval $(call gb_Library_add_exception_objects,chartcore,\
     chart2/source/tools/ExponentialRegressionCurveCalculator \
     chart2/source/tools/FillProperties \
     chart2/source/tools/FormattedStringHelper \
-    chart2/source/tools/GL3DHelper \
     chart2/source/tools/ImplOPropertySet \
     chart2/source/tools/InternalData \
     chart2/source/tools/InternalDataProvider \
diff --git a/chart2/source/controller/main/ChartController.cxx b/chart2/source/controller/main/ChartController.cxx
index d5eca79..f167992 100644
--- a/chart2/source/controller/main/ChartController.cxx
+++ b/chart2/source/controller/main/ChartController.cxx
@@ -43,7 +43,6 @@
 #include "DrawCommandDispatch.hxx"
 #include "ShapeController.hxx"
 #include "UndoActions.hxx"
-#include <GL3DHelper.hxx>
 
 #include <comphelper/InlineContainer.hxx>
 
diff --git a/chart2/source/inc/GL3DHelper.hxx b/chart2/source/inc/GL3DHelper.hxx
deleted file mode 100644
index 6377105..0000000
--- a/chart2/source/inc/GL3DHelper.hxx
+++ /dev/null
@@ -1,29 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- */
-
-#ifndef INCLUDED_CHART2_SOURCE_INC_GL3DHELPER_HXX
-#define INCLUDED_CHART2_SOURCE_INC_GL3DHELPER_HXX
-
-#include <charttoolsdllapi.hxx>
-
-#include <com/sun/star/chart2/XDiagram.hpp>
-
-namespace chart {
-
-class OOO_DLLPUBLIC_CHARTTOOLS GL3DHelper
-{
-public:
-    static bool isGL3DDiagram( const css::uno::Reference<css::chart2::XDiagram>& xDiagram );
-};
-
-}
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/main/ChartModel.cxx b/chart2/source/model/main/ChartModel.cxx
index a3d97c2..9e65853 100644
--- a/chart2/source/model/main/ChartModel.cxx
+++ b/chart2/source/model/main/ChartModel.cxx
@@ -32,7 +32,7 @@
 #include "NameContainer.hxx"
 #include "UndoManager.hxx"
 #include "ChartView.hxx"
-#include "GL3DHelper.hxx"
+#include <svx/charthelper.hxx>
 
 #include <vcl/openglwin.hxx>
 
@@ -968,7 +968,7 @@ void SAL_CALL ChartModel::createDefaultChart()
 sal_Bool SAL_CALL ChartModel::isOpenGLChart()
     throw (css::uno::RuntimeException, std::exception)
 {
-    return GL3DHelper::isGL3DDiagram(m_xDiagram);
+    return ChartHelper::isGL3DDiagram(m_xDiagram);
 }
 
 // ____ XTitled ____
diff --git a/chart2/source/tools/GL3DHelper.cxx b/chart2/source/tools/GL3DHelper.cxx
deleted file mode 100644
index 03a2306..0000000
--- a/chart2/source/tools/GL3DHelper.cxx
+++ /dev/null
@@ -1,54 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- */
-
-#include <GL3DHelper.hxx>
-
-#include <com/sun/star/chart2/XCoordinateSystemContainer.hpp>
-#include <com/sun/star/chart2/XCoordinateSystem.hpp>
-#include <com/sun/star/chart2/XChartTypeContainer.hpp>
-#include <com/sun/star/chart2/XChartType.hpp>
-
-using namespace com::sun::star;
-
-namespace chart {
-
-bool GL3DHelper::isGL3DDiagram( const css::uno::Reference<css::chart2::XDiagram>& xDiagram )
-{
-    uno::Reference<chart2::XCoordinateSystemContainer> xCooSysContainer(xDiagram, uno::UNO_QUERY);
-
-    if (!xCooSysContainer.is())
-        return false;
-
-    uno::Sequence< uno::Reference<chart2::XCoordinateSystem> > aCooSysList = xCooSysContainer->getCoordinateSystems();
-    for (sal_Int32 nCS = 0; nCS < aCooSysList.getLength(); ++nCS)
-    {
-        uno::Reference<chart2::XCoordinateSystem> xCooSys = aCooSysList[nCS];
-
-        //iterate through all chart types in the current coordinate system
-        uno::Reference<chart2::XChartTypeContainer> xChartTypeContainer(xCooSys, uno::UNO_QUERY);
-        OSL_ASSERT( xChartTypeContainer.is());
-        if( !xChartTypeContainer.is() )
-            continue;
-
-        uno::Sequence< uno::Reference<chart2::XChartType> > aChartTypeList = xChartTypeContainer->getChartTypes();
-        for( sal_Int32 nT = 0; nT < aChartTypeList.getLength(); ++nT )
-        {
-            uno::Reference<chart2::XChartType> xChartType = aChartTypeList[nT];
-            OUString aChartType = xChartType->getChartType();
-            if( aChartType == "com.sun.star.chart2.GL3DBarChartType" )
-                return true;
-        }
-    }
-
-    return false;
-}
-
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx
index d2dfbf5..61ba728 100644
--- a/chart2/source/view/main/ChartView.cxx
+++ b/chart2/source/view/main/ChartView.cxx
@@ -51,7 +51,6 @@
 #include "defines.hxx"
 #include <unonames.hxx>
 #include <GL3DBarChart.hxx>
-#include <GL3DHelper.hxx>
 
 #include <editeng/frmdiritem.hxx>
 #include <rtl/uuid.h>
@@ -60,6 +59,7 @@
 #include <boost/bind.hpp>
 #include <unotools/streamwrap.hxx>
 #include <unotools/localedatawrapper.hxx>
+#include <svx/charthelper.hxx>
 #include <svx/svdpage.hxx>
 #include <svx/unopage.hxx>
 #include <svx/unoshape.hxx>
@@ -2444,7 +2444,7 @@ bool ChartView::isReal3DChart()
 {
     uno::Reference< XDiagram > xDiagram( mrChartModel.getFirstDiagram() );
 
-    return GL3DHelper::isGL3DDiagram(xDiagram);
+    return ChartHelper::isGL3DDiagram(xDiagram);
 }
 
 static const char* envChartDummyFactory = getenv("CHART_DUMMY_FACTORY");
diff --git a/include/svx/charthelper.hxx b/include/svx/charthelper.hxx
index bfa1bf78..f88b8c4 100644
--- a/include/svx/charthelper.hxx
+++ b/include/svx/charthelper.hxx
@@ -25,11 +25,18 @@
 #include <basegfx/range/b2drange.hxx>
 #include <svx/svxdllapi.h>
 #include <drawinglayer/primitive2d/baseprimitive2d.hxx>
+#include <com/sun/star/chart2/XDiagram.hpp>
 #include <com/sun/star/embed/XEmbeddedObject.hpp>
 
 class SVX_DLLPUBLIC ChartHelper
 {
 public:
+    /// Check that the XDiagram is a real 3D chart.
+    static bool isGL3DDiagram(const css::uno::Reference<css::chart2::XDiagram>& xDiagram);
+
+    /// Use chart's XUpdatable::update() to update values.
+    static void updateChart(const css::uno::Reference< css::frame::XModel >& rXModel);
+
     // try to access rXModel in case of a chart to to get the chart content
     // as sequence of primitives. Return range of primitives (chart size) in rRange;
     // it will be used to embed the chart to the SdrObject transformation. This
diff --git a/include/svx/svdoole2.hxx b/include/svx/svdoole2.hxx
index fe41d2f..f14646b 100644
--- a/include/svx/svdoole2.hxx
+++ b/include/svx/svdoole2.hxx
@@ -153,6 +153,7 @@ public:
 
     // #109985#
     bool IsChart() const;
+    bool IsReal3DChart() const;
     bool IsCalc() const;
 
     bool UpdateLinkURL_Impl();
diff --git a/svx/source/sdr/contact/viewobjectcontact.cxx b/svx/source/sdr/contact/viewobjectcontact.cxx
index 4ab9d0a..91aecee 100644
--- a/svx/source/sdr/contact/viewobjectcontact.cxx
+++ b/svx/source/sdr/contact/viewobjectcontact.cxx
@@ -17,6 +17,9 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include <config_features.h>
+
+#include <svx/charthelper.hxx>
 #include <svx/sdr/contact/viewobjectcontact.hxx>
 #include <svx/sdr/contact/viewcontact.hxx>
 #include <svx/sdr/contact/objectcontact.hxx>
@@ -32,13 +35,12 @@
 #include <drawinglayer/primitive2d/animatedprimitive2d.hxx>
 #include <drawinglayer/processor2d/baseprocessor2d.hxx>
 #include <svx/sdr/primitive2d/svx_primitivetypes2d.hxx>
+#include <svx/svdoole2.hxx>
 
-
+#include <sdr/contact/viewcontactofsdrole2obj.hxx>
 
 using namespace com::sun::star;
 
-
-
 namespace
 {
     // animated extractor
@@ -205,6 +207,14 @@ namespace sdr
 
         const basegfx::B2DRange& ViewObjectContact::getObjectRange() const
         {
+#if HAVE_FEATURE_DESKTOP
+            // 3D charts need to be notified separately, they are not to be
+            // drawn by the drawinglayer
+            ViewContactOfSdrOle2Obj* pViewContact = dynamic_cast<ViewContactOfSdrOle2Obj*>(&GetViewContact());
+            if (pViewContact && pViewContact->GetOle2Obj().IsReal3DChart())
+                ChartHelper::updateChart(pViewContact->GetOle2Obj().getXModel());
+#endif
+
             if(maObjectRange.isEmpty())
             {
                 // if range is not computed (new or LazyInvalidate objects), force it
diff --git a/svx/source/svdraw/charthelper.cxx b/svx/source/svdraw/charthelper.cxx
index 86c0a84..4965e07 100644
--- a/svx/source/svdraw/charthelper.cxx
+++ b/svx/source/svdraw/charthelper.cxx
@@ -20,6 +20,8 @@
 #include <svx/charthelper.hxx>
 #include <tools/globname.hxx>
 #include <comphelper/classids.hxx>
+#include <com/sun/star/chart2/XCoordinateSystemContainer.hpp>
+#include <com/sun/star/chart2/XChartTypeContainer.hpp>
 #include <com/sun/star/embed/XEmbeddedObject.hpp>
 #include <com/sun/star/lang/XUnoTunnel.hpp>
 #include <com/sun/star/util/XUpdatable.hpp>
@@ -34,67 +36,111 @@
 
 using namespace ::com::sun::star;
 
+bool ChartHelper::isGL3DDiagram( const css::uno::Reference<css::chart2::XDiagram>& xDiagram )
+{
+    uno::Reference<chart2::XCoordinateSystemContainer> xCooSysContainer(xDiagram, uno::UNO_QUERY);
+
+    if (!xCooSysContainer.is())
+        return false;
+
+    uno::Sequence< uno::Reference<chart2::XCoordinateSystem> > aCooSysList = xCooSysContainer->getCoordinateSystems();
+    for (sal_Int32 nCS = 0; nCS < aCooSysList.getLength(); ++nCS)
+    {
+        uno::Reference<chart2::XCoordinateSystem> xCooSys = aCooSysList[nCS];
+
+        //iterate through all chart types in the current coordinate system
+        uno::Reference<chart2::XChartTypeContainer> xChartTypeContainer(xCooSys, uno::UNO_QUERY);
+        OSL_ASSERT( xChartTypeContainer.is());
+        if( !xChartTypeContainer.is() )
+            continue;
+
+        uno::Sequence< uno::Reference<chart2::XChartType> > aChartTypeList = xChartTypeContainer->getChartTypes();
+        for( sal_Int32 nT = 0; nT < aChartTypeList.getLength(); ++nT )
+        {
+            uno::Reference<chart2::XChartType> xChartType = aChartTypeList[nT];
+            OUString aChartType = xChartType->getChartType();
+            if( aChartType == "com.sun.star.chart2.GL3DBarChartType" )
+                return true;
+        }
+    }
+
+    return false;
+}
+
+void ChartHelper::updateChart(const uno::Reference< ::frame::XModel >& rXModel)
+{
+    if (!rXModel.is())
+        return;
+
+    try
+    {
+        const uno::Reference< lang::XMultiServiceFactory > xChartFact(rXModel, uno::UNO_QUERY_THROW);
+        const uno::Reference< lang::XUnoTunnel > xChartView(xChartFact->createInstance("com.sun.star.chart2.ChartView"), uno::UNO_QUERY_THROW);
+        const uno::Reference< util::XUpdatable > xUpdatable(xChartView, uno::UNO_QUERY_THROW);
+
+        if (xUpdatable.is())
+            xUpdatable->update();
+    }
+    catch(uno::Exception&)
+    {
+        OSL_ENSURE(false, "Unexpected exception!");
+    }
+}
+
 drawinglayer::primitive2d::Primitive2DSequence ChartHelper::tryToGetChartContentAsPrimitive2DSequence(
     const uno::Reference< ::frame::XModel >& rXModel,
     basegfx::B2DRange& rRange)
 {
     drawinglayer::primitive2d::Primitive2DSequence aRetval;
 
-    if(rXModel.is())
+    if (!rXModel.is())
+        return aRetval;
+
+    updateChart(rXModel);
+
+    try
     {
-        try
+        const uno::Reference< drawing::XDrawPageSupplier > xDrawPageSupplier(rXModel, uno::UNO_QUERY_THROW);
+        const uno::Reference< container::XIndexAccess > xShapeAccess(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY_THROW);
+
+        if(xShapeAccess.is() && xShapeAccess->getCount())
         {
-            const uno::Reference< lang::XMultiServiceFactory > xChartFact(rXModel, uno::UNO_QUERY_THROW);
-            const uno::Reference< lang::XUnoTunnel > xChartView(xChartFact->createInstance("com.sun.star.chart2.ChartView"), uno::UNO_QUERY_THROW);
-            const uno::Reference< util::XUpdatable > xUpdatable(xChartView, uno::UNO_QUERY_THROW);
+            const sal_Int32 nShapeCount(xShapeAccess->getCount());
+            const uno::Reference< uno::XComponentContext > xContext(::comphelper::getProcessComponentContext());
+            const uno::Reference< graphic::XPrimitiveFactory2D > xPrimitiveFactory =
+                graphic::PrimitiveFactory2D::create( xContext );
 
-            if(xUpdatable.is())
-            {
-                xUpdatable->update();
+            const uno::Sequence< beans::PropertyValue > aParams;
+            uno::Reference< drawing::XShape > xShape;
 
-                const uno::Reference< drawing::XDrawPageSupplier > xDrawPageSupplier(rXModel, uno::UNO_QUERY_THROW);
-                const uno::Reference< container::XIndexAccess > xShapeAccess(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY_THROW);
+            for(sal_Int32 a(0); a < nShapeCount; a++)
+            {
+                xShapeAccess->getByIndex(a) >>= xShape;
 
-                if(xShapeAccess.is() && xShapeAccess->getCount())
+                if(xShape.is())
                 {
-                    const sal_Int32 nShapeCount(xShapeAccess->getCount());
-                    const uno::Reference< uno::XComponentContext > xContext(::comphelper::getProcessComponentContext());
-                    const uno::Reference< graphic::XPrimitiveFactory2D > xPrimitiveFactory =
-                        graphic::PrimitiveFactory2D::create( xContext );
-
-                    const uno::Sequence< beans::PropertyValue > aParams;
-                    uno::Reference< drawing::XShape > xShape;
-
-                    for(sal_Int32 a(0); a < nShapeCount; a++)
-                    {
-                        xShapeAccess->getByIndex(a) >>= xShape;
-
-                        if(xShape.is())
-                        {
-                            const drawinglayer::primitive2d::Primitive2DSequence aNew(
-                                xPrimitiveFactory->createPrimitivesFromXShape(
-                                    xShape,
-                                    aParams));
-
-                            drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(
-                                aRetval,
-                                aNew);
-                        }
-                    }
+                    const drawinglayer::primitive2d::Primitive2DSequence aNew(
+                            xPrimitiveFactory->createPrimitivesFromXShape(
+                                xShape,
+                                aParams));
+
+                    drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(
+                            aRetval,
+                            aNew);
                 }
             }
         }
-        catch(uno::Exception&)
-        {
-            OSL_ENSURE(false, "Unexpected exception!");
-        }
+    }
+    catch(uno::Exception&)
+    {
+        OSL_ENSURE(false, "Unexpected exception!");
+    }
 
-        if(aRetval.hasElements())
-        {
-            const drawinglayer::geometry::ViewInformation2D aViewInformation2D;
+    if(aRetval.hasElements())
+    {
+        const drawinglayer::geometry::ViewInformation2D aViewInformation2D;
 
-            rRange = drawinglayer::primitive2d::getB2DRangeFromPrimitive2DSequence(aRetval, aViewInformation2D);
-        }
+        rRange = drawinglayer::primitive2d::getB2DRangeFromPrimitive2DSequence(aRetval, aViewInformation2D);
     }
 
     return aRetval;
diff --git a/svx/source/svdraw/svdoole2.cxx b/svx/source/svdraw/svdoole2.cxx
index d25480c..df43156 100644
--- a/svx/source/svdraw/svdoole2.cxx
+++ b/svx/source/svdraw/svdoole2.cxx
@@ -17,10 +17,11 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-
 #include <svx/svdoole2.hxx>
+
 #include <com/sun/star/util/XModifyBroadcaster.hpp>
 #include <com/sun/star/util/XModifiable.hpp>
+#include <com/sun/star/chart2/XChartDocument.hpp>
 #include <com/sun/star/embed/EmbedStates.hpp>
 #include <com/sun/star/embed/ElementModes.hpp>
 #include <com/sun/star/embed/EmbedMisc.hpp>
@@ -33,7 +34,7 @@
 #include <com/sun/star/embed/XWindowSupplier.hpp>
 #include <com/sun/star/document/XEventListener.hpp>
 #include <com/sun/star/container/XChild.hpp>
-#include "com/sun/star/document/XStorageBasedDocument.hpp"
+#include <com/sun/star/document/XStorageBasedDocument.hpp>
 
 #include <comphelper/processfactory.hxx>
 #include <cppuhelper/exc_hlp.hxx>
@@ -66,6 +67,7 @@
 #include <osl/mutex.hxx>
 #include <vcl/svapp.hxx>
 
+#include <svx/charthelper.hxx>
 #include <svx/svdmodel.hxx>
 #include "svdglob.hxx"
 #include "svx/svdstr.hrc"
@@ -2154,6 +2156,19 @@ bool SdrOle2Obj::IsChart() const
     return mpImpl->mbIsChart;
 }
 
+bool SdrOle2Obj::IsReal3DChart() const
+{
+    if (!IsChart())
+        return false;
+
+    uno::Reference<chart2::XChartDocument> xChart2Document(getXModel(), uno::UNO_QUERY);
+    uno::Reference<chart2::XDiagram> xChart2Diagram(xChart2Document->getFirstDiagram(), uno::UNO_QUERY);
+
+    if (!xChart2Diagram.is())
+        return false;
+
+    return ChartHelper::isGL3DDiagram(xChart2Diagram);
+}
 
 void SdrOle2Obj::SetGraphicToObj( const Graphic& aGraphic, const OUString& aMediaType )
 {


More information about the Libreoffice-commits mailing list