Kaydet (Commit) aa325833 authored tarafından Jan Holesovsky's avatar Jan Holesovsky

3D charts: Update the 3D charts when a value changes.

Change-Id: I9c4052108446959ff6f5215d704b496e7a8e6aee
üst d41747cb
...@@ -199,7 +199,6 @@ $(eval $(call gb_Library_add_exception_objects,chartcore,\ ...@@ -199,7 +199,6 @@ $(eval $(call gb_Library_add_exception_objects,chartcore,\
chart2/source/tools/ExponentialRegressionCurveCalculator \ chart2/source/tools/ExponentialRegressionCurveCalculator \
chart2/source/tools/FillProperties \ chart2/source/tools/FillProperties \
chart2/source/tools/FormattedStringHelper \ chart2/source/tools/FormattedStringHelper \
chart2/source/tools/GL3DHelper \
chart2/source/tools/ImplOPropertySet \ chart2/source/tools/ImplOPropertySet \
chart2/source/tools/InternalData \ chart2/source/tools/InternalData \
chart2/source/tools/InternalDataProvider \ chart2/source/tools/InternalDataProvider \
......
...@@ -43,7 +43,6 @@ ...@@ -43,7 +43,6 @@
#include "DrawCommandDispatch.hxx" #include "DrawCommandDispatch.hxx"
#include "ShapeController.hxx" #include "ShapeController.hxx"
#include "UndoActions.hxx" #include "UndoActions.hxx"
#include <GL3DHelper.hxx>
#include <comphelper/InlineContainer.hxx> #include <comphelper/InlineContainer.hxx>
......
/* -*- 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: */
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
#include "NameContainer.hxx" #include "NameContainer.hxx"
#include "UndoManager.hxx" #include "UndoManager.hxx"
#include "ChartView.hxx" #include "ChartView.hxx"
#include "GL3DHelper.hxx" #include <svx/charthelper.hxx>
#include <vcl/openglwin.hxx> #include <vcl/openglwin.hxx>
...@@ -968,7 +968,7 @@ void SAL_CALL ChartModel::createDefaultChart() ...@@ -968,7 +968,7 @@ void SAL_CALL ChartModel::createDefaultChart()
sal_Bool SAL_CALL ChartModel::isOpenGLChart() sal_Bool SAL_CALL ChartModel::isOpenGLChart()
throw (css::uno::RuntimeException, std::exception) throw (css::uno::RuntimeException, std::exception)
{ {
return GL3DHelper::isGL3DDiagram(m_xDiagram); return ChartHelper::isGL3DDiagram(m_xDiagram);
} }
// ____ XTitled ____ // ____ XTitled ____
......
/* -*- 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: */
...@@ -51,7 +51,6 @@ ...@@ -51,7 +51,6 @@
#include "defines.hxx" #include "defines.hxx"
#include <unonames.hxx> #include <unonames.hxx>
#include <GL3DBarChart.hxx> #include <GL3DBarChart.hxx>
#include <GL3DHelper.hxx>
#include <editeng/frmdiritem.hxx> #include <editeng/frmdiritem.hxx>
#include <rtl/uuid.h> #include <rtl/uuid.h>
...@@ -60,6 +59,7 @@ ...@@ -60,6 +59,7 @@
#include <boost/bind.hpp> #include <boost/bind.hpp>
#include <unotools/streamwrap.hxx> #include <unotools/streamwrap.hxx>
#include <unotools/localedatawrapper.hxx> #include <unotools/localedatawrapper.hxx>
#include <svx/charthelper.hxx>
#include <svx/svdpage.hxx> #include <svx/svdpage.hxx>
#include <svx/unopage.hxx> #include <svx/unopage.hxx>
#include <svx/unoshape.hxx> #include <svx/unoshape.hxx>
...@@ -2444,7 +2444,7 @@ bool ChartView::isReal3DChart() ...@@ -2444,7 +2444,7 @@ bool ChartView::isReal3DChart()
{ {
uno::Reference< XDiagram > xDiagram( mrChartModel.getFirstDiagram() ); uno::Reference< XDiagram > xDiagram( mrChartModel.getFirstDiagram() );
return GL3DHelper::isGL3DDiagram(xDiagram); return ChartHelper::isGL3DDiagram(xDiagram);
} }
static const char* envChartDummyFactory = getenv("CHART_DUMMY_FACTORY"); static const char* envChartDummyFactory = getenv("CHART_DUMMY_FACTORY");
......
...@@ -25,11 +25,18 @@ ...@@ -25,11 +25,18 @@
#include <basegfx/range/b2drange.hxx> #include <basegfx/range/b2drange.hxx>
#include <svx/svxdllapi.h> #include <svx/svxdllapi.h>
#include <drawinglayer/primitive2d/baseprimitive2d.hxx> #include <drawinglayer/primitive2d/baseprimitive2d.hxx>
#include <com/sun/star/chart2/XDiagram.hpp>
#include <com/sun/star/embed/XEmbeddedObject.hpp> #include <com/sun/star/embed/XEmbeddedObject.hpp>
class SVX_DLLPUBLIC ChartHelper class SVX_DLLPUBLIC ChartHelper
{ {
public: 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 // 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; // 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 // it will be used to embed the chart to the SdrObject transformation. This
......
...@@ -153,6 +153,7 @@ public: ...@@ -153,6 +153,7 @@ public:
// #109985# // #109985#
bool IsChart() const; bool IsChart() const;
bool IsReal3DChart() const;
bool IsCalc() const; bool IsCalc() const;
bool UpdateLinkURL_Impl(); bool UpdateLinkURL_Impl();
......
...@@ -17,6 +17,9 @@ ...@@ -17,6 +17,9 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 . * 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/viewobjectcontact.hxx>
#include <svx/sdr/contact/viewcontact.hxx> #include <svx/sdr/contact/viewcontact.hxx>
#include <svx/sdr/contact/objectcontact.hxx> #include <svx/sdr/contact/objectcontact.hxx>
...@@ -32,13 +35,12 @@ ...@@ -32,13 +35,12 @@
#include <drawinglayer/primitive2d/animatedprimitive2d.hxx> #include <drawinglayer/primitive2d/animatedprimitive2d.hxx>
#include <drawinglayer/processor2d/baseprocessor2d.hxx> #include <drawinglayer/processor2d/baseprocessor2d.hxx>
#include <svx/sdr/primitive2d/svx_primitivetypes2d.hxx> #include <svx/sdr/primitive2d/svx_primitivetypes2d.hxx>
#include <svx/svdoole2.hxx>
#include <sdr/contact/viewcontactofsdrole2obj.hxx>
using namespace com::sun::star; using namespace com::sun::star;
namespace namespace
{ {
// animated extractor // animated extractor
...@@ -205,6 +207,14 @@ namespace sdr ...@@ -205,6 +207,14 @@ namespace sdr
const basegfx::B2DRange& ViewObjectContact::getObjectRange() const 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(maObjectRange.isEmpty())
{ {
// if range is not computed (new or LazyInvalidate objects), force it // if range is not computed (new or LazyInvalidate objects), force it
......
...@@ -20,6 +20,8 @@ ...@@ -20,6 +20,8 @@
#include <svx/charthelper.hxx> #include <svx/charthelper.hxx>
#include <tools/globname.hxx> #include <tools/globname.hxx>
#include <comphelper/classids.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/embed/XEmbeddedObject.hpp>
#include <com/sun/star/lang/XUnoTunnel.hpp> #include <com/sun/star/lang/XUnoTunnel.hpp>
#include <com/sun/star/util/XUpdatable.hpp> #include <com/sun/star/util/XUpdatable.hpp>
...@@ -34,67 +36,111 @@ ...@@ -34,67 +36,111 @@
using namespace ::com::sun::star; 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( drawinglayer::primitive2d::Primitive2DSequence ChartHelper::tryToGetChartContentAsPrimitive2DSequence(
const uno::Reference< ::frame::XModel >& rXModel, const uno::Reference< ::frame::XModel >& rXModel,
basegfx::B2DRange& rRange) basegfx::B2DRange& rRange)
{ {
drawinglayer::primitive2d::Primitive2DSequence aRetval; 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 sal_Int32 nShapeCount(xShapeAccess->getCount());
const uno::Reference< lang::XUnoTunnel > xChartView(xChartFact->createInstance("com.sun.star.chart2.ChartView"), uno::UNO_QUERY_THROW); const uno::Reference< uno::XComponentContext > xContext(::comphelper::getProcessComponentContext());
const uno::Reference< util::XUpdatable > xUpdatable(xChartView, uno::UNO_QUERY_THROW); const uno::Reference< graphic::XPrimitiveFactory2D > xPrimitiveFactory =
graphic::PrimitiveFactory2D::create( xContext );
if(xUpdatable.is()) const uno::Sequence< beans::PropertyValue > aParams;
{ uno::Reference< drawing::XShape > xShape;
xUpdatable->update();
const uno::Reference< drawing::XDrawPageSupplier > xDrawPageSupplier(rXModel, uno::UNO_QUERY_THROW); for(sal_Int32 a(0); a < nShapeCount; a++)
const uno::Reference< container::XIndexAccess > xShapeAccess(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY_THROW); {
xShapeAccess->getByIndex(a) >>= xShape;
if(xShapeAccess.is() && xShapeAccess->getCount()) if(xShape.is())
{ {
const sal_Int32 nShapeCount(xShapeAccess->getCount()); const drawinglayer::primitive2d::Primitive2DSequence aNew(
const uno::Reference< uno::XComponentContext > xContext(::comphelper::getProcessComponentContext()); xPrimitiveFactory->createPrimitivesFromXShape(
const uno::Reference< graphic::XPrimitiveFactory2D > xPrimitiveFactory = xShape,
graphic::PrimitiveFactory2D::create( xContext ); aParams));
const uno::Sequence< beans::PropertyValue > aParams; drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(
uno::Reference< drawing::XShape > xShape; aRetval,
aNew);
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);
}
}
} }
} }
} }
catch(uno::Exception&) }
{ catch(uno::Exception&)
OSL_ENSURE(false, "Unexpected exception!"); {
} OSL_ENSURE(false, "Unexpected exception!");
}
if(aRetval.hasElements()) if(aRetval.hasElements())
{ {
const drawinglayer::geometry::ViewInformation2D aViewInformation2D; const drawinglayer::geometry::ViewInformation2D aViewInformation2D;
rRange = drawinglayer::primitive2d::getB2DRangeFromPrimitive2DSequence(aRetval, aViewInformation2D); rRange = drawinglayer::primitive2d::getB2DRangeFromPrimitive2DSequence(aRetval, aViewInformation2D);
}
} }
return aRetval; return aRetval;
......
...@@ -17,10 +17,11 @@ ...@@ -17,10 +17,11 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 . * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/ */
#include <svx/svdoole2.hxx> #include <svx/svdoole2.hxx>
#include <com/sun/star/util/XModifyBroadcaster.hpp> #include <com/sun/star/util/XModifyBroadcaster.hpp>
#include <com/sun/star/util/XModifiable.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/EmbedStates.hpp>
#include <com/sun/star/embed/ElementModes.hpp> #include <com/sun/star/embed/ElementModes.hpp>
#include <com/sun/star/embed/EmbedMisc.hpp> #include <com/sun/star/embed/EmbedMisc.hpp>
...@@ -33,7 +34,7 @@ ...@@ -33,7 +34,7 @@
#include <com/sun/star/embed/XWindowSupplier.hpp> #include <com/sun/star/embed/XWindowSupplier.hpp>
#include <com/sun/star/document/XEventListener.hpp> #include <com/sun/star/document/XEventListener.hpp>
#include <com/sun/star/container/XChild.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 <comphelper/processfactory.hxx>
#include <cppuhelper/exc_hlp.hxx> #include <cppuhelper/exc_hlp.hxx>
...@@ -66,6 +67,7 @@ ...@@ -66,6 +67,7 @@
#include <osl/mutex.hxx> #include <osl/mutex.hxx>
#include <vcl/svapp.hxx> #include <vcl/svapp.hxx>
#include <svx/charthelper.hxx>
#include <svx/svdmodel.hxx> #include <svx/svdmodel.hxx>
#include "svdglob.hxx" #include "svdglob.hxx"
#include "svx/svdstr.hrc" #include "svx/svdstr.hrc"
...@@ -2154,6 +2156,19 @@ bool SdrOle2Obj::IsChart() const ...@@ -2154,6 +2156,19 @@ bool SdrOle2Obj::IsChart() const
return mpImpl->mbIsChart; 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 ) void SdrOle2Obj::SetGraphicToObj( const Graphic& aGraphic, const OUString& aMediaType )
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment