summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@collabora.com>2014-09-12 12:54:11 +0200
committerJan Holesovsky <kendy@collabora.com>2014-09-12 13:03:52 +0200
commitaa325833295e3983d93758b0e1194d7fb9365ee7 (patch)
tree03a8d73b46512209abb78aeca541cd1315c2fac8
parentd41747cb4232e1feec8f41874cb53c4dacce51d9 (diff)
3D charts: Update the 3D charts when a value changes.
Change-Id: I9c4052108446959ff6f5215d704b496e7a8e6aee
-rw-r--r--chart2/Library_chartcore.mk1
-rw-r--r--chart2/source/controller/main/ChartController.cxx1
-rw-r--r--chart2/source/inc/GL3DHelper.hxx29
-rw-r--r--chart2/source/model/main/ChartModel.cxx4
-rw-r--r--chart2/source/tools/GL3DHelper.cxx54
-rw-r--r--chart2/source/view/main/ChartView.cxx4
-rw-r--r--include/svx/charthelper.hxx7
-rw-r--r--include/svx/svdoole2.hxx1
-rw-r--r--svx/source/sdr/contact/viewobjectcontact.cxx16
-rw-r--r--svx/source/svdraw/charthelper.cxx134
-rw-r--r--svx/source/svdraw/svdoole2.cxx19
11 files changed, 132 insertions, 138 deletions
diff --git a/chart2/Library_chartcore.mk b/chart2/Library_chartcore.mk
index 094762d33d4a..2543eaa557ab 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 d5eca79114b9..f1679922a07e 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 637710515cc9..000000000000
--- 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 a3d97c243482..9e65853e313e 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 03a23062d354..000000000000
--- 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 d2dfbf535af9..61ba728da93e 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 bfa1bf783650..f88b8c4e370d 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 fe41d2f64d9a..f14646b20428 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 4ab9d0a6b867..91aecee9fa5c 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 86c0a840cea6..4965e073d53e 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 d25480c88e88..df431560a8d2 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 )
{