merged tag ooo/OOO330_m14
[LibreOffice.git] / chart2 / source / model / main / Diagram.cxx
blobff8a0c4030bcedc365cd170774792d5cd1bddf9f
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_chart2.hxx"
30 #include "Diagram.hxx"
31 #include "macros.hxx"
32 #include "PropertyHelper.hxx"
33 #include "Wall.hxx"
34 #include "UserDefinedProperties.hxx"
35 #include "ConfigColorScheme.hxx"
36 #include "ContainerHelper.hxx"
37 #include "ThreeDHelper.hxx"
38 #include "CloneHelper.hxx"
39 #include "AxisHelper.hxx"
40 #include "SceneProperties.hxx"
41 #include "DisposeHelper.hxx"
42 #include "BaseGFXHelper.hxx"
43 #include <basegfx/numeric/ftools.hxx>
44 #include <com/sun/star/beans/PropertyAttribute.hpp>
45 #include <com/sun/star/chart2/RelativePosition.hpp>
46 #include <com/sun/star/chart2/RelativeSize.hpp>
47 #include <com/sun/star/drawing/CameraGeometry.hpp>
49 #include <com/sun/star/drawing/HomogenMatrix.hpp>
51 #include <algorithm>
52 #include <iterator>
53 #include <functional>
55 using namespace ::com::sun::star;
56 using namespace ::com::sun::star::beans::PropertyAttribute;
58 using ::rtl::OUString;
59 using ::com::sun::star::beans::Property;
60 using ::com::sun::star::uno::Sequence;
61 using ::com::sun::star::uno::Reference;
62 using ::com::sun::star::uno::Any;
63 using ::osl::MutexGuard;
65 // ======================================================================
67 namespace
70 enum
72 PROP_DIAGRAM_REL_POS,
73 PROP_DIAGRAM_REL_SIZE,
74 PROP_DIAGRAM_POSSIZE_EXCLUDE_LABELS,
75 PROP_DIAGRAM_SORT_BY_X_VALUES,
76 PROP_DIAGRAM_CONNECT_BARS,
77 PROP_DIAGRAM_GROUP_BARS_PER_AXIS,
78 PROP_DIAGRAM_INCLUDE_HIDDEN_CELLS,
79 PROP_DIAGRAM_STARTING_ANGLE,
80 PROP_DIAGRAM_RIGHT_ANGLED_AXES,
81 PROP_DIAGRAM_PERSPECTIVE,
82 PROP_DIAGRAM_ROTATION_HORIZONTAL,
83 PROP_DIAGRAM_ROTATION_VERTICAL,
84 PROP_DIAGRAM_MISSING_VALUE_TREATMENT
87 void lcl_AddPropertiesToVector(
88 ::std::vector< Property > & rOutProperties )
90 rOutProperties.push_back(
91 Property( C2U( "RelativePosition" ),
92 PROP_DIAGRAM_REL_POS,
93 ::getCppuType( reinterpret_cast< const chart2::RelativePosition * >(0)),
94 beans::PropertyAttribute::BOUND
95 | beans::PropertyAttribute::MAYBEVOID ));
97 rOutProperties.push_back(
98 Property( C2U( "RelativeSize" ),
99 PROP_DIAGRAM_REL_SIZE,
100 ::getCppuType( reinterpret_cast< const chart2::RelativeSize * >(0)),
101 beans::PropertyAttribute::BOUND
102 | beans::PropertyAttribute::MAYBEVOID ));
104 rOutProperties.push_back(
105 Property( C2U( "PosSizeExcludeAxes" ),
106 PROP_DIAGRAM_POSSIZE_EXCLUDE_LABELS,
107 ::getBooleanCppuType(),
108 beans::PropertyAttribute::BOUND
109 | beans::PropertyAttribute::MAYBEDEFAULT ));
111 rOutProperties.push_back(
112 Property( C2U( "SortByXValues" ),
113 PROP_DIAGRAM_SORT_BY_X_VALUES,
114 ::getBooleanCppuType(),
115 beans::PropertyAttribute::BOUND
116 | beans::PropertyAttribute::MAYBEDEFAULT ));
118 rOutProperties.push_back(
119 Property( C2U("ConnectBars"),
120 PROP_DIAGRAM_CONNECT_BARS,
121 ::getBooleanCppuType(),
122 beans::PropertyAttribute::BOUND
123 | beans::PropertyAttribute::MAYBEDEFAULT ));
125 rOutProperties.push_back(
126 Property( C2U("GroupBarsPerAxis"),
127 PROP_DIAGRAM_GROUP_BARS_PER_AXIS,
128 ::getBooleanCppuType(),
129 beans::PropertyAttribute::BOUND
130 | beans::PropertyAttribute::MAYBEDEFAULT ));
132 rOutProperties.push_back(
133 Property( C2U("IncludeHiddenCells"),
134 PROP_DIAGRAM_INCLUDE_HIDDEN_CELLS,
135 ::getBooleanCppuType(),
136 beans::PropertyAttribute::BOUND
137 | beans::PropertyAttribute::MAYBEDEFAULT ));
139 rOutProperties.push_back(
140 Property( C2U( "StartingAngle" ),
141 PROP_DIAGRAM_STARTING_ANGLE,
142 ::getCppuType( reinterpret_cast< const sal_Int32 * >(0) ),
143 beans::PropertyAttribute::BOUND
144 | beans::PropertyAttribute::MAYBEDEFAULT ));
146 rOutProperties.push_back(
147 Property( C2U("RightAngledAxes"),
148 PROP_DIAGRAM_RIGHT_ANGLED_AXES,
149 ::getBooleanCppuType(),
150 beans::PropertyAttribute::BOUND
151 | beans::PropertyAttribute::MAYBEDEFAULT ));
153 rOutProperties.push_back(
154 Property( C2U("Perspective"),
155 PROP_DIAGRAM_PERSPECTIVE,
156 ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)),
157 beans::PropertyAttribute::MAYBEVOID ));
159 rOutProperties.push_back(
160 Property( C2U("RotationHorizontal"),
161 PROP_DIAGRAM_ROTATION_HORIZONTAL,
162 ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)),
163 beans::PropertyAttribute::MAYBEVOID ));
165 rOutProperties.push_back(
166 Property( C2U("RotationVertical"),
167 PROP_DIAGRAM_ROTATION_VERTICAL,
168 ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)),
169 beans::PropertyAttribute::MAYBEVOID ));
171 rOutProperties.push_back(
172 Property( C2U( "MissingValueTreatment" ),
173 PROP_DIAGRAM_MISSING_VALUE_TREATMENT,
174 ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)),
175 beans::PropertyAttribute::BOUND
176 | beans::PropertyAttribute::MAYBEVOID ));
179 void lcl_AddDefaultsToMap(
180 ::chart::tPropertyValueMap & rOutMap )
182 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DIAGRAM_POSSIZE_EXCLUDE_LABELS, true );
183 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DIAGRAM_SORT_BY_X_VALUES, false );
184 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DIAGRAM_CONNECT_BARS, false );
185 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DIAGRAM_GROUP_BARS_PER_AXIS, true );
186 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DIAGRAM_INCLUDE_HIDDEN_CELLS, true );
187 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DIAGRAM_RIGHT_ANGLED_AXES, false );
188 ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_DIAGRAM_STARTING_ANGLE, 90 );
191 const Sequence< Property > & lcl_GetPropertySequence()
193 static Sequence< Property > aPropSeq;
195 // /--
196 ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
197 if( 0 == aPropSeq.getLength() )
199 // get properties
200 ::std::vector< ::com::sun::star::beans::Property > aProperties;
201 lcl_AddPropertiesToVector( aProperties );
202 ::chart::SceneProperties::AddPropertiesToVector( aProperties );
203 ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
205 // and sort them for access via bsearch
206 ::std::sort( aProperties.begin(), aProperties.end(),
207 ::chart::PropertyNameLess() );
209 // transfer result to static Sequence
210 aPropSeq = ::chart::ContainerHelper::ContainerToSequence( aProperties );
213 return aPropSeq;
216 /// clones a UNO-sequence of UNO-References
217 typedef Reference< chart2::XCoordinateSystem > lcl_tCooSysRef;
218 typedef ::std::map< lcl_tCooSysRef, lcl_tCooSysRef > lcl_tCooSysMapping;
219 typedef ::std::vector< lcl_tCooSysRef > lcl_tCooSysVector;
221 lcl_tCooSysMapping lcl_CloneCoordinateSystems(
222 const lcl_tCooSysVector & rSource,
223 lcl_tCooSysVector & rDestination )
225 lcl_tCooSysMapping aResult;
227 for( lcl_tCooSysVector::const_iterator aIt( rSource.begin());
228 aIt != rSource.end(); ++aIt )
230 lcl_tCooSysRef xClone;
231 ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloneable >
232 xCloneable( *aIt, ::com::sun::star::uno::UNO_QUERY );
233 if( xCloneable.is())
234 xClone.set( xCloneable->createClone(), ::com::sun::star::uno::UNO_QUERY );
236 if( xClone.is())
238 rDestination.push_back( xClone );
239 aResult.insert( lcl_tCooSysMapping::value_type( *aIt, xClone ));
241 else
242 rDestination.push_back( *aIt );
245 return aResult;
248 } // anonymous namespace
250 // ======================================================================
252 namespace chart
255 Diagram::Diagram( uno::Reference< uno::XComponentContext > const & xContext ) :
256 ::property::OPropertySet( m_aMutex ),
257 m_xContext( xContext ),
258 m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
260 // Set camera position to a default position (that should be set hard, so
261 // that it will be exported. The property default is a camera looking
262 // straight ono the scene). These defaults have been acquired from the old
263 // chart implemetation.
264 setFastPropertyValue_NoBroadcast(
265 SceneProperties::PROP_SCENE_CAMERA_GEOMETRY, uno::makeAny(
266 ThreeDHelper::getDefaultCameraGeometry()));
269 Diagram::Diagram( const Diagram & rOther ) :
270 MutexContainer(),
271 impl::Diagram_Base(),
272 ::property::OPropertySet( rOther, m_aMutex ),
273 m_xContext( rOther.m_xContext ),
274 m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
276 lcl_tCooSysMapping aCooSysMapping =
277 lcl_CloneCoordinateSystems( rOther.m_aCoordSystems, m_aCoordSystems );
278 ModifyListenerHelper::addListenerToAllElements( m_aCoordSystems, m_xModifyEventForwarder );
280 m_xWall.set( CloneHelper::CreateRefClone< Reference< beans::XPropertySet > >()( rOther.m_xWall ));
281 m_xFloor.set( CloneHelper::CreateRefClone< Reference< beans::XPropertySet > >()( rOther.m_xFloor ));
282 m_xTitle.set( CloneHelper::CreateRefClone< Reference< chart2::XTitle > >()( rOther.m_xTitle ));
283 m_xLegend.set( CloneHelper::CreateRefClone< Reference< chart2::XLegend > >()( rOther.m_xLegend ));
285 ModifyListenerHelper::addListener( m_xWall, m_xModifyEventForwarder );
286 ModifyListenerHelper::addListener( m_xFloor, m_xModifyEventForwarder );
287 ModifyListenerHelper::addListener( m_xTitle, m_xModifyEventForwarder );
288 ModifyListenerHelper::addListener( m_xLegend, m_xModifyEventForwarder );
291 Diagram::~Diagram()
295 ModifyListenerHelper::removeListenerFromAllElements( m_aCoordSystems, m_xModifyEventForwarder );
297 ModifyListenerHelper::removeListener( m_xWall, m_xModifyEventForwarder );
298 ModifyListenerHelper::removeListener( m_xFloor, m_xModifyEventForwarder );
299 ModifyListenerHelper::removeListener( m_xTitle, m_xModifyEventForwarder );
300 ModifyListenerHelper::removeListener( m_xLegend, m_xModifyEventForwarder );
302 catch( const uno::Exception & ex )
304 ASSERT_EXCEPTION( ex );
308 // ____ XDiagram ____
309 uno::Reference< beans::XPropertySet > SAL_CALL Diagram::getWall()
310 throw (uno::RuntimeException)
312 uno::Reference< beans::XPropertySet > xRet;
313 bool bAddListener = false;
315 MutexGuard aGuard( GetMutex() );
316 if( !m_xWall.is() )
318 m_xWall.set( new Wall() );
319 bAddListener = true;
321 xRet = m_xWall;
323 if(bAddListener)
324 ModifyListenerHelper::addListener( xRet, m_xModifyEventForwarder );
325 return xRet;
328 uno::Reference< beans::XPropertySet > SAL_CALL Diagram::getFloor()
329 throw (uno::RuntimeException)
331 uno::Reference< beans::XPropertySet > xRet;
332 bool bAddListener = false;
334 MutexGuard aGuard( GetMutex() );
335 if( !m_xFloor.is() )
337 m_xFloor.set( new Wall() );
338 bAddListener = true;
340 xRet = m_xFloor;
342 if(bAddListener)
343 ModifyListenerHelper::addListener( xRet, m_xModifyEventForwarder );
344 return xRet;
347 uno::Reference< chart2::XLegend > SAL_CALL Diagram::getLegend()
348 throw (uno::RuntimeException)
350 MutexGuard aGuard( GetMutex() );
351 return m_xLegend;
354 void SAL_CALL Diagram::setLegend( const uno::Reference< chart2::XLegend >& xNewLegend )
355 throw (uno::RuntimeException)
357 Reference< chart2::XLegend > xOldLegend;
359 MutexGuard aGuard( GetMutex() );
360 if( m_xLegend == xNewLegend )
361 return;
362 xOldLegend = m_xLegend;
363 m_xLegend = xNewLegend;
365 if( xOldLegend.is())
366 ModifyListenerHelper::removeListener( xOldLegend, m_xModifyEventForwarder );
367 if( xNewLegend.is())
368 ModifyListenerHelper::addListener( xNewLegend, m_xModifyEventForwarder );
369 fireModifyEvent();
372 Reference< chart2::XColorScheme > SAL_CALL Diagram::getDefaultColorScheme()
373 throw (uno::RuntimeException)
375 Reference< chart2::XColorScheme > xRet;
377 MutexGuard aGuard( GetMutex() );
378 xRet = m_xColorScheme;
381 if( !xRet.is())
383 xRet.set( createConfigColorScheme( m_xContext ));
384 MutexGuard aGuard( GetMutex() );
385 m_xColorScheme = xRet;
387 return xRet;
390 void SAL_CALL Diagram::setDefaultColorScheme( const Reference< chart2::XColorScheme >& xColorScheme )
391 throw (uno::RuntimeException)
394 MutexGuard aGuard( GetMutex() );
395 m_xColorScheme.set( xColorScheme );
397 fireModifyEvent();
400 // ____ XTitled ____
401 uno::Reference< chart2::XTitle > SAL_CALL Diagram::getTitleObject()
402 throw (uno::RuntimeException)
404 MutexGuard aGuard( GetMutex() );
405 return m_xTitle;
408 void SAL_CALL Diagram::setTitleObject( const uno::Reference< chart2::XTitle >& xNewTitle )
409 throw (uno::RuntimeException)
411 Reference< chart2::XTitle > xOldTitle;
413 MutexGuard aGuard( GetMutex() );
414 if( m_xTitle == xNewTitle )
415 return;
416 xOldTitle = m_xTitle;
417 m_xTitle = xNewTitle;
419 if( xOldTitle.is())
420 ModifyListenerHelper::removeListener( xOldTitle, m_xModifyEventForwarder );
421 if( xNewTitle.is())
422 ModifyListenerHelper::addListener( xNewTitle, m_xModifyEventForwarder );
423 fireModifyEvent();
426 // ____ X3DDefaultSetter ____
427 void SAL_CALL Diagram::set3DSettingsToDefault()
428 throw (uno::RuntimeException)
430 ThreeDHelper::set3DSettingsToDefault( this );
433 void SAL_CALL Diagram::setDefaultRotation()
434 throw (uno::RuntimeException)
436 ThreeDHelper::setDefaultRotation( this );
439 void SAL_CALL Diagram::setDefaultIllumination()
440 throw (uno::RuntimeException)
442 ThreeDHelper::setDefaultIllumination( this );
445 // ____ XCoordinateSystemContainer ____
446 void SAL_CALL Diagram::addCoordinateSystem(
447 const uno::Reference< chart2::XCoordinateSystem >& aCoordSys )
448 throw (lang::IllegalArgumentException,
449 uno::RuntimeException)
452 MutexGuard aGuard( GetMutex() );
453 if( ::std::find( m_aCoordSystems.begin(), m_aCoordSystems.end(), aCoordSys )
454 != m_aCoordSystems.end())
455 throw lang::IllegalArgumentException();
457 if( m_aCoordSystems.size()>=1 )
459 OSL_ENSURE( false, "more than one coordinatesystem is not supported yet by the fileformat" );
460 return;
462 m_aCoordSystems.push_back( aCoordSys );
464 ModifyListenerHelper::addListener( aCoordSys, m_xModifyEventForwarder );
465 fireModifyEvent();
468 void SAL_CALL Diagram::removeCoordinateSystem(
469 const uno::Reference< chart2::XCoordinateSystem >& aCoordSys )
470 throw (container::NoSuchElementException,
471 uno::RuntimeException)
474 MutexGuard aGuard( GetMutex() );
475 ::std::vector< uno::Reference< chart2::XCoordinateSystem > >::iterator
476 aIt( ::std::find( m_aCoordSystems.begin(), m_aCoordSystems.end(), aCoordSys ));
477 if( aIt == m_aCoordSystems.end())
478 throw container::NoSuchElementException(
479 C2U( "The given coordinate-system is no element of the container" ),
480 static_cast< uno::XWeak * >( this ));
481 m_aCoordSystems.erase( aIt );
483 ModifyListenerHelper::removeListener( aCoordSys, m_xModifyEventForwarder );
484 fireModifyEvent();
487 uno::Sequence< uno::Reference< chart2::XCoordinateSystem > > SAL_CALL Diagram::getCoordinateSystems()
488 throw (uno::RuntimeException)
490 MutexGuard aGuard( GetMutex() );
491 return ContainerHelper::ContainerToSequence( m_aCoordSystems );
494 void SAL_CALL Diagram::setCoordinateSystems(
495 const Sequence< Reference< chart2::XCoordinateSystem > >& aCoordinateSystems )
496 throw (lang::IllegalArgumentException,
497 uno::RuntimeException)
499 tCoordinateSystemContainerType aNew;
500 tCoordinateSystemContainerType aOld;
501 if( aCoordinateSystems.getLength()>0 )
503 OSL_ENSURE( aCoordinateSystems.getLength()<=1, "more than one coordinatesystem is not supported yet by the fileformat" );
504 aNew.push_back( aCoordinateSystems[0] );
507 MutexGuard aGuard( GetMutex() );
508 std::swap( aOld, m_aCoordSystems );
509 m_aCoordSystems = aNew;
511 ModifyListenerHelper::removeListenerFromAllElements( aOld, m_xModifyEventForwarder );
512 ModifyListenerHelper::addListenerToAllElements( aNew, m_xModifyEventForwarder );
513 fireModifyEvent();
516 // ____ XCloneable ____
517 Reference< util::XCloneable > SAL_CALL Diagram::createClone()
518 throw (uno::RuntimeException)
520 MutexGuard aGuard( GetMutex() );
521 return Reference< util::XCloneable >( new Diagram( *this ));
524 // ____ XModifyBroadcaster ____
525 void SAL_CALL Diagram::addModifyListener( const Reference< util::XModifyListener >& aListener )
526 throw (uno::RuntimeException)
530 Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
531 xBroadcaster->addModifyListener( aListener );
533 catch( const uno::Exception & ex )
535 ASSERT_EXCEPTION( ex );
539 void SAL_CALL Diagram::removeModifyListener( const Reference< util::XModifyListener >& aListener )
540 throw (uno::RuntimeException)
544 Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
545 xBroadcaster->removeModifyListener( aListener );
547 catch( const uno::Exception & ex )
549 ASSERT_EXCEPTION( ex );
553 // ____ XModifyListener ____
554 void SAL_CALL Diagram::modified( const lang::EventObject& aEvent )
555 throw (uno::RuntimeException)
557 m_xModifyEventForwarder->modified( aEvent );
560 // ____ XEventListener (base of XModifyListener) ____
561 void SAL_CALL Diagram::disposing( const lang::EventObject& /* Source */ )
562 throw (uno::RuntimeException)
564 // nothing
567 // ____ OPropertySet ____
568 void Diagram::firePropertyChangeEvent()
570 fireModifyEvent();
573 void Diagram::fireModifyEvent()
575 m_xModifyEventForwarder->modified( lang::EventObject( static_cast< uno::XWeak* >( this )));
578 // ============================================================
580 Sequence< OUString > Diagram::getSupportedServiceNames_Static()
582 Sequence< OUString > aServices( 3 );
584 aServices[ 0 ] = C2U( "com.sun.star.chart2.Diagram" );
585 aServices[ 1 ] = C2U( "com.sun.star.layout.LayoutElement" );
586 aServices[ 2 ] = C2U( "com.sun.star.beans.PropertySet" );
587 return aServices;
590 // ____ OPropertySet ____
591 uno::Any Diagram::GetDefaultValue( sal_Int32 nHandle ) const
592 throw(beans::UnknownPropertyException)
594 static tPropertyValueMap aStaticDefaults;
596 // /--
597 ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
598 if( 0 == aStaticDefaults.size() )
600 // initialize defaults
601 lcl_AddDefaultsToMap( aStaticDefaults );
602 ::chart::SceneProperties::AddDefaultsToMap( aStaticDefaults );
605 tPropertyValueMap::const_iterator aFound(
606 aStaticDefaults.find( nHandle ));
608 if( aFound == aStaticDefaults.end())
609 return uno::Any();
611 return (*aFound).second;
612 // \--
615 // ____ OPropertySet ____
616 ::cppu::IPropertyArrayHelper & SAL_CALL Diagram::getInfoHelper()
618 static ::cppu::OPropertyArrayHelper aArrayHelper( lcl_GetPropertySequence(),
619 /* bSorted = */ sal_True );
621 return aArrayHelper;
625 // ____ XPropertySet ____
626 uno::Reference< beans::XPropertySetInfo > SAL_CALL
627 Diagram::getPropertySetInfo()
628 throw (uno::RuntimeException)
630 static uno::Reference< beans::XPropertySetInfo > xInfo;
632 // /--
633 ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
634 if( !xInfo.is())
636 xInfo = ::cppu::OPropertySetHelper::createPropertySetInfo(
637 getInfoHelper());
640 return xInfo;
641 // \--
644 // ____ XFastPropertySet ____
645 void SAL_CALL Diagram::setFastPropertyValue( sal_Int32 nHandle, const Any& rValue )
646 throw(beans::UnknownPropertyException,
647 beans::PropertyVetoException,
648 lang::IllegalArgumentException,
649 lang::WrappedTargetException, uno::RuntimeException)
651 //special treatment for some 3D properties
652 if( PROP_DIAGRAM_PERSPECTIVE == nHandle )
654 sal_Int32 fPerspective = 20;
655 if( rValue >>=fPerspective )
656 ThreeDHelper::setCameraDistance( this, ThreeDHelper::PerspectiveToCameraDistance( fPerspective ) );
658 else if( PROP_DIAGRAM_ROTATION_HORIZONTAL == nHandle
659 || PROP_DIAGRAM_ROTATION_VERTICAL == nHandle )
661 sal_Int32 nNewAngleDegree = 0;
662 if( rValue >>=nNewAngleDegree )
664 sal_Int32 nHorizontal, nVertical;
665 ThreeDHelper::getRotationFromDiagram( const_cast< Diagram* >( this ), nHorizontal, nVertical );
666 if( PROP_DIAGRAM_ROTATION_HORIZONTAL == nHandle )
667 nHorizontal = nNewAngleDegree;
668 else
669 nVertical = nNewAngleDegree;
670 ThreeDHelper::setRotationToDiagram( this, nHorizontal, nVertical );
673 else
674 ::property::OPropertySet::setFastPropertyValue( nHandle, rValue );
677 void SAL_CALL Diagram::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const
679 //special treatment for some 3D properties
680 if( nHandle == PROP_DIAGRAM_PERSPECTIVE )
682 sal_Int32 nPerspective = ::basegfx::fround( ThreeDHelper::CameraDistanceToPerspective(
683 ThreeDHelper::getCameraDistance( const_cast< Diagram* >( this ) ) ) );
684 rValue = uno::makeAny(nPerspective);
686 else if( PROP_DIAGRAM_ROTATION_HORIZONTAL == nHandle
687 || PROP_DIAGRAM_ROTATION_VERTICAL == nHandle )
689 sal_Int32 nHorizontal, nVertical;
690 ThreeDHelper::getRotationFromDiagram( const_cast< Diagram* >( this ), nHorizontal, nVertical );
691 sal_Int32 nAngleDegree = 0;
692 if( PROP_DIAGRAM_ROTATION_HORIZONTAL == nHandle )
693 nAngleDegree = nHorizontal;
694 else
695 nAngleDegree = nVertical;
696 rValue = uno::makeAny(nAngleDegree);
698 else
699 ::property::OPropertySet::getFastPropertyValue( rValue,nHandle );
702 // ================================================================================
704 using impl::Diagram_Base;
706 IMPLEMENT_FORWARD_XINTERFACE2( Diagram, Diagram_Base, ::property::OPropertySet )
707 IMPLEMENT_FORWARD_XTYPEPROVIDER2( Diagram, Diagram_Base, ::property::OPropertySet )
709 // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
710 APPHELPER_XSERVICEINFO_IMPL( Diagram,
711 C2U( "com.sun.star.comp.chart2.Diagram" ));
713 } // namespace chart