bump product version to 4.1.6.2
[LibreOffice.git] / chart2 / source / model / main / Diagram.cxx
blobec1637ba1f51b700e2d4f14a4ef4a2ad8cacfae6
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "Diagram.hxx"
21 #include "macros.hxx"
22 #include "PropertyHelper.hxx"
23 #include "Wall.hxx"
24 #include "UserDefinedProperties.hxx"
25 #include "ConfigColorScheme.hxx"
26 #include "DiagramHelper.hxx"
27 #include "ContainerHelper.hxx"
28 #include "ThreeDHelper.hxx"
29 #include "CloneHelper.hxx"
30 #include "AxisHelper.hxx"
31 #include "SceneProperties.hxx"
32 #include "DisposeHelper.hxx"
33 #include "BaseGFXHelper.hxx"
34 #include <basegfx/numeric/ftools.hxx>
35 #include <rtl/instance.hxx>
36 #include <com/sun/star/beans/PropertyAttribute.hpp>
37 #include <com/sun/star/chart2/RelativePosition.hpp>
38 #include <com/sun/star/chart2/RelativeSize.hpp>
39 #include <com/sun/star/drawing/CameraGeometry.hpp>
41 #include <com/sun/star/drawing/HomogenMatrix.hpp>
43 #include <algorithm>
44 #include <iterator>
45 #include <functional>
47 using namespace ::com::sun::star;
48 using namespace ::com::sun::star::beans::PropertyAttribute;
50 using ::com::sun::star::beans::Property;
51 using ::com::sun::star::uno::Sequence;
52 using ::com::sun::star::uno::Reference;
53 using ::com::sun::star::uno::Any;
54 using ::osl::MutexGuard;
56 // ======================================================================
58 namespace
61 enum
63 PROP_DIAGRAM_REL_POS,
64 PROP_DIAGRAM_REL_SIZE,
65 PROP_DIAGRAM_POSSIZE_EXCLUDE_LABELS,
66 PROP_DIAGRAM_SORT_BY_X_VALUES,
67 PROP_DIAGRAM_CONNECT_BARS,
68 PROP_DIAGRAM_GROUP_BARS_PER_AXIS,
69 PROP_DIAGRAM_INCLUDE_HIDDEN_CELLS,
70 PROP_DIAGRAM_STARTING_ANGLE,
71 PROP_DIAGRAM_RIGHT_ANGLED_AXES,
72 PROP_DIAGRAM_PERSPECTIVE,
73 PROP_DIAGRAM_ROTATION_HORIZONTAL,
74 PROP_DIAGRAM_ROTATION_VERTICAL,
75 PROP_DIAGRAM_MISSING_VALUE_TREATMENT,
76 PROP_DIAGRAM_3DRELATIVEHEIGHT
79 void lcl_AddPropertiesToVector(
80 ::std::vector< Property > & rOutProperties )
82 rOutProperties.push_back(
83 Property( "RelativePosition",
84 PROP_DIAGRAM_REL_POS,
85 ::getCppuType( reinterpret_cast< const chart2::RelativePosition * >(0)),
86 beans::PropertyAttribute::BOUND
87 | beans::PropertyAttribute::MAYBEVOID ));
89 rOutProperties.push_back(
90 Property( "RelativeSize",
91 PROP_DIAGRAM_REL_SIZE,
92 ::getCppuType( reinterpret_cast< const chart2::RelativeSize * >(0)),
93 beans::PropertyAttribute::BOUND
94 | beans::PropertyAttribute::MAYBEVOID ));
96 rOutProperties.push_back(
97 Property( "PosSizeExcludeAxes",
98 PROP_DIAGRAM_POSSIZE_EXCLUDE_LABELS,
99 ::getBooleanCppuType(),
100 beans::PropertyAttribute::BOUND
101 | beans::PropertyAttribute::MAYBEDEFAULT ));
103 rOutProperties.push_back(
104 Property( "SortByXValues",
105 PROP_DIAGRAM_SORT_BY_X_VALUES,
106 ::getBooleanCppuType(),
107 beans::PropertyAttribute::BOUND
108 | beans::PropertyAttribute::MAYBEDEFAULT ));
110 rOutProperties.push_back(
111 Property( "ConnectBars",
112 PROP_DIAGRAM_CONNECT_BARS,
113 ::getBooleanCppuType(),
114 beans::PropertyAttribute::BOUND
115 | beans::PropertyAttribute::MAYBEDEFAULT ));
117 rOutProperties.push_back(
118 Property( "GroupBarsPerAxis",
119 PROP_DIAGRAM_GROUP_BARS_PER_AXIS,
120 ::getBooleanCppuType(),
121 beans::PropertyAttribute::BOUND
122 | beans::PropertyAttribute::MAYBEDEFAULT ));
124 rOutProperties.push_back(
125 Property( "IncludeHiddenCells",
126 PROP_DIAGRAM_INCLUDE_HIDDEN_CELLS,
127 ::getBooleanCppuType(),
128 beans::PropertyAttribute::BOUND
129 | beans::PropertyAttribute::MAYBEDEFAULT ));
131 rOutProperties.push_back(
132 Property( "StartingAngle",
133 PROP_DIAGRAM_STARTING_ANGLE,
134 ::getCppuType( reinterpret_cast< const sal_Int32 * >(0) ),
135 beans::PropertyAttribute::BOUND
136 | beans::PropertyAttribute::MAYBEDEFAULT ));
138 rOutProperties.push_back(
139 Property( "RightAngledAxes",
140 PROP_DIAGRAM_RIGHT_ANGLED_AXES,
141 ::getBooleanCppuType(),
142 beans::PropertyAttribute::BOUND
143 | beans::PropertyAttribute::MAYBEDEFAULT ));
145 rOutProperties.push_back(
146 Property( "Perspective",
147 PROP_DIAGRAM_PERSPECTIVE,
148 ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)),
149 beans::PropertyAttribute::MAYBEVOID ));
151 rOutProperties.push_back(
152 Property( "RotationHorizontal",
153 PROP_DIAGRAM_ROTATION_HORIZONTAL,
154 ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)),
155 beans::PropertyAttribute::MAYBEVOID ));
157 rOutProperties.push_back(
158 Property( "RotationVertical",
159 PROP_DIAGRAM_ROTATION_VERTICAL,
160 ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)),
161 beans::PropertyAttribute::MAYBEVOID ));
163 rOutProperties.push_back(
164 Property( "MissingValueTreatment",
165 PROP_DIAGRAM_MISSING_VALUE_TREATMENT,
166 ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)),
167 beans::PropertyAttribute::BOUND
168 | beans::PropertyAttribute::MAYBEVOID ));
169 rOutProperties.push_back(
170 Property( "3DRelativeHeight",
171 PROP_DIAGRAM_3DRELATIVEHEIGHT,
172 ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)),
173 beans::PropertyAttribute::MAYBEVOID ));
176 struct StaticDiagramDefaults_Initializer
178 ::chart::tPropertyValueMap* operator()()
180 static ::chart::tPropertyValueMap aStaticDefaults;
181 lcl_AddDefaultsToMap( aStaticDefaults );
182 return &aStaticDefaults;
184 private:
185 void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap )
187 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DIAGRAM_POSSIZE_EXCLUDE_LABELS, true );
188 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DIAGRAM_SORT_BY_X_VALUES, false );
189 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DIAGRAM_CONNECT_BARS, false );
190 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DIAGRAM_GROUP_BARS_PER_AXIS, true );
191 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DIAGRAM_INCLUDE_HIDDEN_CELLS, true );
192 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DIAGRAM_RIGHT_ANGLED_AXES, false );
193 ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_DIAGRAM_STARTING_ANGLE, 90 );
194 ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_DIAGRAM_3DRELATIVEHEIGHT, 100 );
195 ::chart::SceneProperties::AddDefaultsToMap( rOutMap );
199 struct StaticDiagramDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticDiagramDefaults_Initializer >
203 struct StaticDiagramInfoHelper_Initializer
205 ::cppu::OPropertyArrayHelper* operator()()
207 static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
208 return &aPropHelper;
211 private:
212 Sequence< Property > lcl_GetPropertySequence()
214 ::std::vector< ::com::sun::star::beans::Property > aProperties;
215 lcl_AddPropertiesToVector( aProperties );
216 ::chart::SceneProperties::AddPropertiesToVector( aProperties );
217 ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
219 ::std::sort( aProperties.begin(), aProperties.end(),
220 ::chart::PropertyNameLess() );
222 return ::chart::ContainerHelper::ContainerToSequence( aProperties );
226 struct StaticDiagramInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticDiagramInfoHelper_Initializer >
230 struct StaticDiagramInfo_Initializer
232 uno::Reference< beans::XPropertySetInfo >* operator()()
234 static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
235 ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticDiagramInfoHelper::get() ) );
236 return &xPropertySetInfo;
240 struct StaticDiagramInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticDiagramInfo_Initializer >
244 /// clones a UNO-sequence of UNO-References
245 typedef Reference< chart2::XCoordinateSystem > lcl_tCooSysRef;
246 typedef ::std::map< lcl_tCooSysRef, lcl_tCooSysRef > lcl_tCooSysMapping;
247 typedef ::std::vector< lcl_tCooSysRef > lcl_tCooSysVector;
249 lcl_tCooSysMapping lcl_CloneCoordinateSystems(
250 const lcl_tCooSysVector & rSource,
251 lcl_tCooSysVector & rDestination )
253 lcl_tCooSysMapping aResult;
255 for( lcl_tCooSysVector::const_iterator aIt( rSource.begin());
256 aIt != rSource.end(); ++aIt )
258 lcl_tCooSysRef xClone;
259 ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloneable >
260 xCloneable( *aIt, ::com::sun::star::uno::UNO_QUERY );
261 if( xCloneable.is())
262 xClone.set( xCloneable->createClone(), ::com::sun::star::uno::UNO_QUERY );
264 if( xClone.is())
266 rDestination.push_back( xClone );
267 aResult.insert( lcl_tCooSysMapping::value_type( *aIt, xClone ));
269 else
270 rDestination.push_back( *aIt );
273 return aResult;
276 } // anonymous namespace
278 // ======================================================================
280 namespace chart
283 Diagram::Diagram( uno::Reference< uno::XComponentContext > const & xContext ) :
284 ::property::OPropertySet( m_aMutex ),
285 m_xContext( xContext ),
286 m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
288 // Set camera position to a default position (that should be set hard, so
289 // that it will be exported. The property default is a camera looking
290 // straight ono the scene). These defaults have been acquired from the old
291 // chart implemetation.
292 setFastPropertyValue_NoBroadcast(
293 SceneProperties::PROP_SCENE_CAMERA_GEOMETRY, uno::makeAny(
294 ThreeDHelper::getDefaultCameraGeometry()));
297 Diagram::Diagram( const Diagram & rOther ) :
298 MutexContainer(),
299 impl::Diagram_Base(),
300 ::property::OPropertySet( rOther, m_aMutex ),
301 m_xContext( rOther.m_xContext ),
302 m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
304 lcl_tCooSysMapping aCooSysMapping =
305 lcl_CloneCoordinateSystems( rOther.m_aCoordSystems, m_aCoordSystems );
306 ModifyListenerHelper::addListenerToAllElements( m_aCoordSystems, m_xModifyEventForwarder );
308 m_xWall.set( CloneHelper::CreateRefClone< Reference< beans::XPropertySet > >()( rOther.m_xWall ));
309 m_xFloor.set( CloneHelper::CreateRefClone< Reference< beans::XPropertySet > >()( rOther.m_xFloor ));
310 m_xTitle.set( CloneHelper::CreateRefClone< Reference< chart2::XTitle > >()( rOther.m_xTitle ));
311 m_xLegend.set( CloneHelper::CreateRefClone< Reference< chart2::XLegend > >()( rOther.m_xLegend ));
313 ModifyListenerHelper::addListener( m_xWall, m_xModifyEventForwarder );
314 ModifyListenerHelper::addListener( m_xFloor, m_xModifyEventForwarder );
315 ModifyListenerHelper::addListener( m_xTitle, m_xModifyEventForwarder );
316 ModifyListenerHelper::addListener( m_xLegend, m_xModifyEventForwarder );
319 Diagram::~Diagram()
323 ModifyListenerHelper::removeListenerFromAllElements( m_aCoordSystems, m_xModifyEventForwarder );
325 ModifyListenerHelper::removeListener( m_xWall, m_xModifyEventForwarder );
326 ModifyListenerHelper::removeListener( m_xFloor, m_xModifyEventForwarder );
327 ModifyListenerHelper::removeListener( m_xTitle, m_xModifyEventForwarder );
328 ModifyListenerHelper::removeListener( m_xLegend, m_xModifyEventForwarder );
330 catch( const uno::Exception & ex )
332 ASSERT_EXCEPTION( ex );
336 // ____ XDiagram ____
337 uno::Reference< beans::XPropertySet > SAL_CALL Diagram::getWall()
338 throw (uno::RuntimeException)
340 uno::Reference< beans::XPropertySet > xRet;
341 bool bAddListener = false;
343 MutexGuard aGuard( GetMutex() );
344 if( !m_xWall.is() )
346 m_xWall.set( new Wall() );
347 bAddListener = true;
349 xRet = m_xWall;
351 if(bAddListener)
352 ModifyListenerHelper::addListener( xRet, m_xModifyEventForwarder );
353 return xRet;
356 uno::Reference< beans::XPropertySet > SAL_CALL Diagram::getFloor()
357 throw (uno::RuntimeException)
359 uno::Reference< beans::XPropertySet > xRet;
360 bool bAddListener = false;
362 MutexGuard aGuard( GetMutex() );
363 if( !m_xFloor.is() )
365 m_xFloor.set( new Wall() );
366 bAddListener = true;
368 xRet = m_xFloor;
370 if(bAddListener)
371 ModifyListenerHelper::addListener( xRet, m_xModifyEventForwarder );
372 return xRet;
375 uno::Reference< chart2::XLegend > SAL_CALL Diagram::getLegend()
376 throw (uno::RuntimeException)
378 MutexGuard aGuard( GetMutex() );
379 return m_xLegend;
382 void SAL_CALL Diagram::setLegend( const uno::Reference< chart2::XLegend >& xNewLegend )
383 throw (uno::RuntimeException)
385 Reference< chart2::XLegend > xOldLegend;
387 MutexGuard aGuard( GetMutex() );
388 if( m_xLegend == xNewLegend )
389 return;
390 xOldLegend = m_xLegend;
391 m_xLegend = xNewLegend;
393 if( xOldLegend.is())
394 ModifyListenerHelper::removeListener( xOldLegend, m_xModifyEventForwarder );
395 if( xNewLegend.is())
396 ModifyListenerHelper::addListener( xNewLegend, m_xModifyEventForwarder );
397 fireModifyEvent();
400 Reference< chart2::XColorScheme > SAL_CALL Diagram::getDefaultColorScheme()
401 throw (uno::RuntimeException)
403 Reference< chart2::XColorScheme > xRet;
405 MutexGuard aGuard( GetMutex() );
406 xRet = m_xColorScheme;
409 if( !xRet.is())
411 xRet.set( createConfigColorScheme( m_xContext ));
412 MutexGuard aGuard( GetMutex() );
413 m_xColorScheme = xRet;
415 return xRet;
418 void SAL_CALL Diagram::setDefaultColorScheme( const Reference< chart2::XColorScheme >& xColorScheme )
419 throw (uno::RuntimeException)
422 MutexGuard aGuard( GetMutex() );
423 m_xColorScheme.set( xColorScheme );
425 fireModifyEvent();
428 void SAL_CALL Diagram::setDiagramData(
429 const Reference< chart2::data::XDataSource >& xDataSource,
430 const Sequence< beans::PropertyValue >& aArguments )
431 throw (uno::RuntimeException)
433 uno::Reference< lang::XMultiServiceFactory > xChartTypeManager( m_xContext->getServiceManager()->createInstanceWithContext(
434 "com.sun.star.chart2.ChartTypeManager", m_xContext ), uno::UNO_QUERY );
435 DiagramHelper::tTemplateWithServiceName aTemplateAndService = DiagramHelper::getTemplateForDiagram( this, xChartTypeManager );
436 uno::Reference< chart2::XChartTypeTemplate > xTemplate( aTemplateAndService.first );
437 if( !xTemplate.is() )
438 xTemplate.set( xChartTypeManager->createInstance( "com.sun.star.chart2.template.Column" ), uno::UNO_QUERY );
439 if(!xTemplate.is())
440 return;
441 xTemplate->changeDiagramData( this, xDataSource, aArguments );
444 // ____ XTitled ____
445 uno::Reference< chart2::XTitle > SAL_CALL Diagram::getTitleObject()
446 throw (uno::RuntimeException)
448 MutexGuard aGuard( GetMutex() );
449 return m_xTitle;
452 void SAL_CALL Diagram::setTitleObject( const uno::Reference< chart2::XTitle >& xNewTitle )
453 throw (uno::RuntimeException)
455 Reference< chart2::XTitle > xOldTitle;
457 MutexGuard aGuard( GetMutex() );
458 if( m_xTitle == xNewTitle )
459 return;
460 xOldTitle = m_xTitle;
461 m_xTitle = xNewTitle;
463 if( xOldTitle.is())
464 ModifyListenerHelper::removeListener( xOldTitle, m_xModifyEventForwarder );
465 if( xNewTitle.is())
466 ModifyListenerHelper::addListener( xNewTitle, m_xModifyEventForwarder );
467 fireModifyEvent();
470 // ____ X3DDefaultSetter ____
471 void SAL_CALL Diagram::set3DSettingsToDefault()
472 throw (uno::RuntimeException)
474 ThreeDHelper::set3DSettingsToDefault( this );
477 void SAL_CALL Diagram::setDefaultRotation()
478 throw (uno::RuntimeException)
480 ThreeDHelper::setDefaultRotation( this );
483 void SAL_CALL Diagram::setDefaultIllumination()
484 throw (uno::RuntimeException)
486 ThreeDHelper::setDefaultIllumination( this );
489 // ____ XCoordinateSystemContainer ____
490 void SAL_CALL Diagram::addCoordinateSystem(
491 const uno::Reference< chart2::XCoordinateSystem >& aCoordSys )
492 throw (lang::IllegalArgumentException,
493 uno::RuntimeException)
496 MutexGuard aGuard( GetMutex() );
497 if( ::std::find( m_aCoordSystems.begin(), m_aCoordSystems.end(), aCoordSys )
498 != m_aCoordSystems.end())
499 throw lang::IllegalArgumentException();
501 if( m_aCoordSystems.size()>=1 )
503 OSL_FAIL( "more than one coordinatesystem is not supported yet by the fileformat" );
504 return;
506 m_aCoordSystems.push_back( aCoordSys );
508 ModifyListenerHelper::addListener( aCoordSys, m_xModifyEventForwarder );
509 fireModifyEvent();
512 void SAL_CALL Diagram::removeCoordinateSystem(
513 const uno::Reference< chart2::XCoordinateSystem >& aCoordSys )
514 throw (container::NoSuchElementException,
515 uno::RuntimeException)
518 MutexGuard aGuard( GetMutex() );
519 ::std::vector< uno::Reference< chart2::XCoordinateSystem > >::iterator
520 aIt( ::std::find( m_aCoordSystems.begin(), m_aCoordSystems.end(), aCoordSys ));
521 if( aIt == m_aCoordSystems.end())
522 throw container::NoSuchElementException(
523 "The given coordinate-system is no element of the container",
524 static_cast< uno::XWeak * >( this ));
525 m_aCoordSystems.erase( aIt );
527 ModifyListenerHelper::removeListener( aCoordSys, m_xModifyEventForwarder );
528 fireModifyEvent();
531 uno::Sequence< uno::Reference< chart2::XCoordinateSystem > > SAL_CALL Diagram::getCoordinateSystems()
532 throw (uno::RuntimeException)
534 MutexGuard aGuard( GetMutex() );
535 return ContainerHelper::ContainerToSequence( m_aCoordSystems );
538 void SAL_CALL Diagram::setCoordinateSystems(
539 const Sequence< Reference< chart2::XCoordinateSystem > >& aCoordinateSystems )
540 throw (lang::IllegalArgumentException,
541 uno::RuntimeException)
543 tCoordinateSystemContainerType aNew;
544 tCoordinateSystemContainerType aOld;
545 if( aCoordinateSystems.getLength()>0 )
547 OSL_ENSURE( aCoordinateSystems.getLength()<=1, "more than one coordinatesystem is not supported yet by the fileformat" );
548 aNew.push_back( aCoordinateSystems[0] );
551 MutexGuard aGuard( GetMutex() );
552 std::swap( aOld, m_aCoordSystems );
553 m_aCoordSystems = aNew;
555 ModifyListenerHelper::removeListenerFromAllElements( aOld, m_xModifyEventForwarder );
556 ModifyListenerHelper::addListenerToAllElements( aNew, m_xModifyEventForwarder );
557 fireModifyEvent();
560 // ____ XCloneable ____
561 Reference< util::XCloneable > SAL_CALL Diagram::createClone()
562 throw (uno::RuntimeException)
564 MutexGuard aGuard( GetMutex() );
565 return Reference< util::XCloneable >( new Diagram( *this ));
568 // ____ XModifyBroadcaster ____
569 void SAL_CALL Diagram::addModifyListener( const Reference< util::XModifyListener >& aListener )
570 throw (uno::RuntimeException)
574 Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
575 xBroadcaster->addModifyListener( aListener );
577 catch( const uno::Exception & ex )
579 ASSERT_EXCEPTION( ex );
583 void SAL_CALL Diagram::removeModifyListener( const Reference< util::XModifyListener >& aListener )
584 throw (uno::RuntimeException)
588 Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
589 xBroadcaster->removeModifyListener( aListener );
591 catch( const uno::Exception & ex )
593 ASSERT_EXCEPTION( ex );
597 // ____ XModifyListener ____
598 void SAL_CALL Diagram::modified( const lang::EventObject& aEvent )
599 throw (uno::RuntimeException)
601 m_xModifyEventForwarder->modified( aEvent );
604 // ____ XEventListener (base of XModifyListener) ____
605 void SAL_CALL Diagram::disposing( const lang::EventObject& /* Source */ )
606 throw (uno::RuntimeException)
608 // nothing
611 // ____ OPropertySet ____
612 void Diagram::firePropertyChangeEvent()
614 fireModifyEvent();
617 void Diagram::fireModifyEvent()
619 m_xModifyEventForwarder->modified( lang::EventObject( static_cast< uno::XWeak* >( this )));
622 // ============================================================
624 Sequence< OUString > Diagram::getSupportedServiceNames_Static()
626 Sequence< OUString > aServices( 3 );
628 aServices[ 0 ] = "com.sun.star.chart2.Diagram";
629 aServices[ 1 ] = "com.sun.star.layout.LayoutElement";
630 aServices[ 2 ] = "com.sun.star.beans.PropertySet";
631 return aServices;
634 // ____ OPropertySet ____
635 uno::Any Diagram::GetDefaultValue( sal_Int32 nHandle ) const
636 throw(beans::UnknownPropertyException)
638 const tPropertyValueMap& rStaticDefaults = *StaticDiagramDefaults::get();
639 tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
640 if( aFound == rStaticDefaults.end() )
641 return uno::Any();
642 return (*aFound).second;
645 // ____ OPropertySet ____
646 ::cppu::IPropertyArrayHelper & SAL_CALL Diagram::getInfoHelper()
648 return *StaticDiagramInfoHelper::get();
651 // ____ XPropertySet ____
652 uno::Reference< beans::XPropertySetInfo > SAL_CALL Diagram::getPropertySetInfo()
653 throw (uno::RuntimeException)
655 return *StaticDiagramInfo::get();
658 // ____ XFastPropertySet ____
659 void SAL_CALL Diagram::setFastPropertyValue( sal_Int32 nHandle, const Any& rValue )
660 throw(beans::UnknownPropertyException,
661 beans::PropertyVetoException,
662 lang::IllegalArgumentException,
663 lang::WrappedTargetException, uno::RuntimeException)
665 //special treatment for some 3D properties
666 if( PROP_DIAGRAM_PERSPECTIVE == nHandle )
668 sal_Int32 fPerspective = 20;
669 if( rValue >>=fPerspective )
670 ThreeDHelper::setCameraDistance( this, ThreeDHelper::PerspectiveToCameraDistance( fPerspective ) );
672 else if( PROP_DIAGRAM_ROTATION_HORIZONTAL == nHandle
673 || PROP_DIAGRAM_ROTATION_VERTICAL == nHandle )
675 sal_Int32 nNewAngleDegree = 0;
676 if( rValue >>=nNewAngleDegree )
678 sal_Int32 nHorizontal, nVertical;
679 ThreeDHelper::getRotationFromDiagram( const_cast< Diagram* >( this ), nHorizontal, nVertical );
680 if( PROP_DIAGRAM_ROTATION_HORIZONTAL == nHandle )
681 nHorizontal = nNewAngleDegree;
682 else
683 nVertical = nNewAngleDegree;
684 ThreeDHelper::setRotationToDiagram( this, nHorizontal, nVertical );
687 else
688 ::property::OPropertySet::setFastPropertyValue( nHandle, rValue );
691 void SAL_CALL Diagram::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const
693 //special treatment for some 3D properties
694 if( nHandle == PROP_DIAGRAM_PERSPECTIVE )
696 sal_Int32 nPerspective = ::basegfx::fround( ThreeDHelper::CameraDistanceToPerspective(
697 ThreeDHelper::getCameraDistance( const_cast< Diagram* >( this ) ) ) );
698 rValue = uno::makeAny(nPerspective);
700 else if( PROP_DIAGRAM_ROTATION_HORIZONTAL == nHandle
701 || PROP_DIAGRAM_ROTATION_VERTICAL == nHandle )
703 sal_Int32 nHorizontal, nVertical;
704 ThreeDHelper::getRotationFromDiagram( const_cast< Diagram* >( this ), nHorizontal, nVertical );
705 sal_Int32 nAngleDegree = 0;
706 if( PROP_DIAGRAM_ROTATION_HORIZONTAL == nHandle )
707 nAngleDegree = nHorizontal;
708 else
709 nAngleDegree = nVertical;
710 rValue = uno::makeAny(nAngleDegree);
712 else
713 ::property::OPropertySet::getFastPropertyValue( rValue,nHandle );
716 // ================================================================================
718 using impl::Diagram_Base;
720 IMPLEMENT_FORWARD_XINTERFACE2( Diagram, Diagram_Base, ::property::OPropertySet )
721 IMPLEMENT_FORWARD_XTYPEPROVIDER2( Diagram, Diagram_Base, ::property::OPropertySet )
723 // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
724 APPHELPER_XSERVICEINFO_IMPL( Diagram,
725 OUString("com.sun.star.comp.chart2.Diagram") );
727 } // namespace chart
729 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */