merge the formfield patch from ooo-build
[ooovba.git] / chart2 / source / model / main / Diagram.cxx
blobd66641aa7122d52dd4d861f4a4d9bc22cd2bd07a
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: Diagram.cxx,v $
11 * $Revision: 1.24.32.2 $
13 * This file is part of OpenOffice.org.
15 * OpenOffice.org is free software: you can redistribute it and/or modify
16 * it under the terms of the GNU Lesser General Public License version 3
17 * only, as published by the Free Software Foundation.
19 * OpenOffice.org is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Lesser General Public License version 3 for more details
23 * (a copy is included in the LICENSE file that accompanied this code).
25 * You should have received a copy of the GNU Lesser General Public License
26 * version 3 along with OpenOffice.org. If not, see
27 * <http://www.openoffice.org/license.html>
28 * for a copy of the LGPLv3 License.
30 ************************************************************************/
32 // MARKER(update_precomp.py): autogen include statement, do not remove
33 #include "precompiled_chart2.hxx"
34 #include "Diagram.hxx"
35 #include "macros.hxx"
36 #include "PropertyHelper.hxx"
37 #include "Wall.hxx"
38 #include "UserDefinedProperties.hxx"
39 #include "ConfigColorScheme.hxx"
40 #include "ContainerHelper.hxx"
41 #include "ThreeDHelper.hxx"
42 #include "CloneHelper.hxx"
43 #include "AxisHelper.hxx"
44 #include "SceneProperties.hxx"
45 #include "DisposeHelper.hxx"
46 #include "BaseGFXHelper.hxx"
47 #include <basegfx/numeric/ftools.hxx>
48 #include <com/sun/star/beans/PropertyAttribute.hpp>
49 #include <com/sun/star/chart2/RelativePosition.hpp>
50 #include <com/sun/star/chart2/RelativeSize.hpp>
51 #include <com/sun/star/drawing/CameraGeometry.hpp>
53 #include <com/sun/star/drawing/HomogenMatrix.hpp>
55 #include <algorithm>
56 #include <iterator>
57 #include <functional>
59 using namespace ::com::sun::star;
60 using namespace ::com::sun::star::beans::PropertyAttribute;
62 using ::rtl::OUString;
63 using ::com::sun::star::beans::Property;
64 using ::com::sun::star::uno::Sequence;
65 using ::com::sun::star::uno::Reference;
66 using ::com::sun::star::uno::Any;
67 using ::osl::MutexGuard;
69 // ======================================================================
71 namespace
74 enum
76 PROP_DIAGRAM_REL_POS,
77 PROP_DIAGRAM_REL_SIZE,
78 PROP_DIAGRAM_SORT_BY_X_VALUES,
79 PROP_DIAGRAM_CONNECT_BARS,
80 PROP_DIAGRAM_GROUP_BARS_PER_AXIS,
81 PROP_DIAGRAM_INCLUDE_HIDDEN_CELLS,
82 PROP_DIAGRAM_STARTING_ANGLE,
83 PROP_DIAGRAM_RIGHT_ANGLED_AXES,
84 PROP_DIAGRAM_PERSPECTIVE,
85 PROP_DIAGRAM_ROTATION_HORIZONTAL,
86 PROP_DIAGRAM_ROTATION_VERTICAL,
87 PROP_DIAGRAM_MISSING_VALUE_TREATMENT
90 void lcl_AddPropertiesToVector(
91 ::std::vector< Property > & rOutProperties )
93 rOutProperties.push_back(
94 Property( C2U( "RelativePosition" ),
95 PROP_DIAGRAM_REL_POS,
96 ::getCppuType( reinterpret_cast< const chart2::RelativePosition * >(0)),
97 beans::PropertyAttribute::BOUND
98 | beans::PropertyAttribute::MAYBEVOID ));
100 rOutProperties.push_back(
101 Property( C2U( "RelativeSize" ),
102 PROP_DIAGRAM_REL_SIZE,
103 ::getCppuType( reinterpret_cast< const chart2::RelativeSize * >(0)),
104 beans::PropertyAttribute::BOUND
105 | beans::PropertyAttribute::MAYBEVOID ));
107 rOutProperties.push_back(
108 Property( C2U( "SortByXValues" ),
109 PROP_DIAGRAM_SORT_BY_X_VALUES,
110 ::getBooleanCppuType(),
111 beans::PropertyAttribute::BOUND
112 | beans::PropertyAttribute::MAYBEDEFAULT ));
114 rOutProperties.push_back(
115 Property( C2U("ConnectBars"),
116 PROP_DIAGRAM_CONNECT_BARS,
117 ::getBooleanCppuType(),
118 beans::PropertyAttribute::BOUND
119 | beans::PropertyAttribute::MAYBEDEFAULT ));
121 rOutProperties.push_back(
122 Property( C2U("GroupBarsPerAxis"),
123 PROP_DIAGRAM_GROUP_BARS_PER_AXIS,
124 ::getBooleanCppuType(),
125 beans::PropertyAttribute::BOUND
126 | beans::PropertyAttribute::MAYBEDEFAULT ));
128 rOutProperties.push_back(
129 Property( C2U("IncludeHiddenCells"),
130 PROP_DIAGRAM_INCLUDE_HIDDEN_CELLS,
131 ::getBooleanCppuType(),
132 beans::PropertyAttribute::BOUND
133 | beans::PropertyAttribute::MAYBEDEFAULT ));
135 rOutProperties.push_back(
136 Property( C2U( "StartingAngle" ),
137 PROP_DIAGRAM_STARTING_ANGLE,
138 ::getCppuType( reinterpret_cast< const sal_Int32 * >(0) ),
139 beans::PropertyAttribute::BOUND
140 | beans::PropertyAttribute::MAYBEDEFAULT ));
142 rOutProperties.push_back(
143 Property( C2U("RightAngledAxes"),
144 PROP_DIAGRAM_RIGHT_ANGLED_AXES,
145 ::getBooleanCppuType(),
146 beans::PropertyAttribute::BOUND
147 | beans::PropertyAttribute::MAYBEDEFAULT ));
149 rOutProperties.push_back(
150 Property( C2U("Perspective"),
151 PROP_DIAGRAM_PERSPECTIVE,
152 ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)),
153 beans::PropertyAttribute::MAYBEVOID ));
155 rOutProperties.push_back(
156 Property( C2U("RotationHorizontal"),
157 PROP_DIAGRAM_ROTATION_HORIZONTAL,
158 ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)),
159 beans::PropertyAttribute::MAYBEVOID ));
161 rOutProperties.push_back(
162 Property( C2U("RotationVertical"),
163 PROP_DIAGRAM_ROTATION_VERTICAL,
164 ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)),
165 beans::PropertyAttribute::MAYBEVOID ));
167 rOutProperties.push_back(
168 Property( C2U( "MissingValueTreatment" ),
169 PROP_DIAGRAM_MISSING_VALUE_TREATMENT,
170 ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)),
171 beans::PropertyAttribute::BOUND
172 | beans::PropertyAttribute::MAYBEVOID ));
175 void lcl_AddDefaultsToMap(
176 ::chart::tPropertyValueMap & rOutMap )
178 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DIAGRAM_SORT_BY_X_VALUES, false );
179 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DIAGRAM_CONNECT_BARS, false );
180 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DIAGRAM_GROUP_BARS_PER_AXIS, true );
181 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DIAGRAM_INCLUDE_HIDDEN_CELLS, true );
182 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DIAGRAM_RIGHT_ANGLED_AXES, false );
183 ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_DIAGRAM_STARTING_ANGLE, 90 );
186 const Sequence< Property > & lcl_GetPropertySequence()
188 static Sequence< Property > aPropSeq;
190 // /--
191 ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
192 if( 0 == aPropSeq.getLength() )
194 // get properties
195 ::std::vector< ::com::sun::star::beans::Property > aProperties;
196 lcl_AddPropertiesToVector( aProperties );
197 ::chart::SceneProperties::AddPropertiesToVector( aProperties );
198 ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
200 // and sort them for access via bsearch
201 ::std::sort( aProperties.begin(), aProperties.end(),
202 ::chart::PropertyNameLess() );
204 // transfer result to static Sequence
205 aPropSeq = ::chart::ContainerHelper::ContainerToSequence( aProperties );
208 return aPropSeq;
211 /// clones a UNO-sequence of UNO-References
212 typedef Reference< chart2::XCoordinateSystem > lcl_tCooSysRef;
213 typedef ::std::map< lcl_tCooSysRef, lcl_tCooSysRef > lcl_tCooSysMapping;
214 typedef ::std::vector< lcl_tCooSysRef > lcl_tCooSysVector;
216 lcl_tCooSysMapping lcl_CloneCoordinateSystems(
217 const lcl_tCooSysVector & rSource,
218 lcl_tCooSysVector & rDestination )
220 lcl_tCooSysMapping aResult;
222 for( lcl_tCooSysVector::const_iterator aIt( rSource.begin());
223 aIt != rSource.end(); ++aIt )
225 lcl_tCooSysRef xClone;
226 ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloneable >
227 xCloneable( *aIt, ::com::sun::star::uno::UNO_QUERY );
228 if( xCloneable.is())
229 xClone.set( xCloneable->createClone(), ::com::sun::star::uno::UNO_QUERY );
231 if( xClone.is())
233 rDestination.push_back( xClone );
234 aResult.insert( lcl_tCooSysMapping::value_type( *aIt, xClone ));
236 else
237 rDestination.push_back( *aIt );
240 return aResult;
243 } // anonymous namespace
245 // ======================================================================
247 namespace chart
250 Diagram::Diagram( uno::Reference< uno::XComponentContext > const & xContext ) :
251 ::property::OPropertySet( m_aMutex ),
252 m_xContext( xContext ),
253 m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
255 // Set camera position to a default position (that should be set hard, so
256 // that it will be exported. The property default is a camera looking
257 // straight ono the scene). These defaults have been acquired from the old
258 // chart implemetation.
259 setFastPropertyValue_NoBroadcast(
260 SceneProperties::PROP_SCENE_CAMERA_GEOMETRY, uno::makeAny(
261 ThreeDHelper::getDefaultCameraGeometry()));
264 Diagram::Diagram( const Diagram & rOther ) :
265 MutexContainer(),
266 impl::Diagram_Base(),
267 ::property::OPropertySet( rOther, m_aMutex ),
268 m_xContext( rOther.m_xContext ),
269 m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
271 lcl_tCooSysMapping aCooSysMapping =
272 lcl_CloneCoordinateSystems( rOther.m_aCoordSystems, m_aCoordSystems );
273 ModifyListenerHelper::addListenerToAllElements( m_aCoordSystems, m_xModifyEventForwarder );
275 m_xWall.set( CloneHelper::CreateRefClone< Reference< beans::XPropertySet > >()( rOther.m_xWall ));
276 m_xFloor.set( CloneHelper::CreateRefClone< Reference< beans::XPropertySet > >()( rOther.m_xFloor ));
277 m_xTitle.set( CloneHelper::CreateRefClone< Reference< chart2::XTitle > >()( rOther.m_xTitle ));
278 m_xLegend.set( CloneHelper::CreateRefClone< Reference< chart2::XLegend > >()( rOther.m_xLegend ));
280 ModifyListenerHelper::addListener( m_xWall, m_xModifyEventForwarder );
281 ModifyListenerHelper::addListener( m_xFloor, m_xModifyEventForwarder );
282 ModifyListenerHelper::addListener( m_xTitle, m_xModifyEventForwarder );
283 ModifyListenerHelper::addListener( m_xLegend, m_xModifyEventForwarder );
286 Diagram::~Diagram()
290 ModifyListenerHelper::removeListenerFromAllElements( m_aCoordSystems, m_xModifyEventForwarder );
292 ModifyListenerHelper::removeListener( m_xWall, m_xModifyEventForwarder );
293 ModifyListenerHelper::removeListener( m_xFloor, m_xModifyEventForwarder );
294 ModifyListenerHelper::removeListener( m_xTitle, m_xModifyEventForwarder );
295 ModifyListenerHelper::removeListener( m_xLegend, m_xModifyEventForwarder );
297 catch( const uno::Exception & ex )
299 ASSERT_EXCEPTION( ex );
303 // ____ XDiagram ____
304 uno::Reference< beans::XPropertySet > SAL_CALL Diagram::getWall()
305 throw (uno::RuntimeException)
307 // /--
308 MutexGuard aGuard( GetMutex() );
309 if( ! m_xWall.is())
311 m_xWall.set( new Wall());
312 ModifyListenerHelper::addListener( m_xWall, m_xModifyEventForwarder );
314 return m_xWall;
315 // \--
318 uno::Reference< beans::XPropertySet > SAL_CALL Diagram::getFloor()
319 throw (uno::RuntimeException)
321 // /--
322 MutexGuard aGuard( GetMutex() );
323 if( ! m_xFloor.is())
325 m_xFloor.set( new Wall());
326 ModifyListenerHelper::addListener( m_xFloor, m_xModifyEventForwarder );
328 return m_xFloor;
329 // \--
332 uno::Reference< chart2::XLegend > SAL_CALL Diagram::getLegend()
333 throw (uno::RuntimeException)
335 // /--
336 MutexGuard aGuard( GetMutex() );
337 return m_xLegend;
338 // \--
341 void SAL_CALL Diagram::setLegend( const uno::Reference< chart2::XLegend >& xLegend )
342 throw (uno::RuntimeException)
344 // /--
345 ::osl::ClearableMutexGuard aGuard( GetMutex() );
346 if( xLegend != m_xLegend )
348 if( m_xLegend.is())
349 ModifyListenerHelper::removeListener( m_xLegend, m_xModifyEventForwarder );
350 m_xLegend = xLegend;
351 if( m_xLegend.is())
352 ModifyListenerHelper::addListener( m_xLegend, m_xModifyEventForwarder );
353 aGuard.clear();
354 // \--
355 fireModifyEvent();
359 Reference< chart2::XColorScheme > SAL_CALL Diagram::getDefaultColorScheme()
360 throw (uno::RuntimeException)
362 if( ! m_xColorScheme.is())
364 m_xColorScheme.set( createConfigColorScheme( m_xContext ));
366 return m_xColorScheme;
369 void SAL_CALL Diagram::setDefaultColorScheme( const Reference< chart2::XColorScheme >& xColorScheme )
370 throw (uno::RuntimeException)
372 m_xColorScheme.set( xColorScheme );
373 fireModifyEvent();
376 void SAL_CALL Diagram::setUnusedData( const Sequence< Reference< chart2::data::XLabeledDataSequence > >& aUnusedData )
377 throw (uno::RuntimeException)
379 m_aUnusedData = aUnusedData;
382 Sequence< Reference< chart2::data::XLabeledDataSequence > > SAL_CALL Diagram::getUnusedData()
383 throw (uno::RuntimeException)
385 return m_aUnusedData;
388 // ____ XTitled ____
389 uno::Reference< chart2::XTitle > SAL_CALL Diagram::getTitleObject()
390 throw (uno::RuntimeException)
392 // /--
393 MutexGuard aGuard( GetMutex() );
394 return m_xTitle;
395 // \--
398 void SAL_CALL Diagram::setTitleObject( const uno::Reference< chart2::XTitle >& Title )
399 throw (uno::RuntimeException)
401 // /--
402 ::osl::ClearableMutexGuard aGuard( GetMutex() );
404 if( m_xTitle != Title )
406 ModifyListenerHelper::removeListener( m_xTitle, m_xModifyEventForwarder );
407 m_xTitle = Title;
408 ModifyListenerHelper::addListener( m_xTitle, m_xModifyEventForwarder );
409 // \--
410 aGuard.clear();
411 fireModifyEvent();
415 // ____ X3DDefaultSetter ____
416 void SAL_CALL Diagram::set3DSettingsToDefault()
417 throw (uno::RuntimeException)
419 ThreeDHelper::set3DSettingsToDefault( this );
422 void SAL_CALL Diagram::setDefaultRotation()
423 throw (uno::RuntimeException)
425 ThreeDHelper::setDefaultRotation( this );
428 void SAL_CALL Diagram::setDefaultIllumination()
429 throw (uno::RuntimeException)
431 ThreeDHelper::setDefaultIllumination( this );
434 // ____ XCoordinateSystemContainer ____
435 void SAL_CALL Diagram::addCoordinateSystem(
436 const uno::Reference< chart2::XCoordinateSystem >& aCoordSys )
437 throw (lang::IllegalArgumentException,
438 uno::RuntimeException)
440 if( ::std::find( m_aCoordSystems.begin(), m_aCoordSystems.end(), aCoordSys )
441 != m_aCoordSystems.end())
442 throw lang::IllegalArgumentException();
444 if( m_aCoordSystems.size()>=1 )
446 OSL_ENSURE( false, "more than one coordinatesystem is not supported yet by the fileformat" );
447 return;
450 m_aCoordSystems.push_back( aCoordSys );
452 ModifyListenerHelper::addListener( aCoordSys, m_xModifyEventForwarder );
453 fireModifyEvent();
456 void SAL_CALL Diagram::removeCoordinateSystem(
457 const uno::Reference< chart2::XCoordinateSystem >& aCoordSys )
458 throw (container::NoSuchElementException,
459 uno::RuntimeException)
461 ::std::vector< uno::Reference< chart2::XCoordinateSystem > >::iterator
462 aIt( ::std::find( m_aCoordSystems.begin(), m_aCoordSystems.end(), aCoordSys ));
463 if( aIt == m_aCoordSystems.end())
464 throw container::NoSuchElementException(
465 C2U( "The given coordinate-system is no element of the container" ),
466 static_cast< uno::XWeak * >( this ));
468 m_aCoordSystems.erase( aIt );
470 ModifyListenerHelper::removeListener( aCoordSys, m_xModifyEventForwarder );
471 fireModifyEvent();
474 uno::Sequence< uno::Reference< chart2::XCoordinateSystem > > SAL_CALL Diagram::getCoordinateSystems()
475 throw (uno::RuntimeException)
477 return ContainerHelper::ContainerToSequence( m_aCoordSystems );
480 void SAL_CALL Diagram::setCoordinateSystems(
481 const Sequence< Reference< chart2::XCoordinateSystem > >& aCoordinateSystems )
482 throw (lang::IllegalArgumentException,
483 uno::RuntimeException)
485 Sequence< Reference< chart2::XCoordinateSystem > > aNew(aCoordinateSystems);
487 if( aNew.getLength()>1 )
489 OSL_ENSURE( false, "more than one coordinatesystem is not supported yet by the fileformat" );
490 aNew.realloc(1);
493 ModifyListenerHelper::removeListenerFromAllElements( m_aCoordSystems, m_xModifyEventForwarder );
494 m_aCoordSystems = ContainerHelper::SequenceToVector( aNew );
495 ModifyListenerHelper::addListenerToAllElements( m_aCoordSystems, m_xModifyEventForwarder );
496 fireModifyEvent();
499 // ____ XCloneable ____
500 Reference< util::XCloneable > SAL_CALL Diagram::createClone()
501 throw (uno::RuntimeException)
503 return Reference< util::XCloneable >( new Diagram( *this ));
506 // ____ XModifyBroadcaster ____
507 void SAL_CALL Diagram::addModifyListener( const Reference< util::XModifyListener >& aListener )
508 throw (uno::RuntimeException)
512 Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
513 xBroadcaster->addModifyListener( aListener );
515 catch( const uno::Exception & ex )
517 ASSERT_EXCEPTION( ex );
521 void SAL_CALL Diagram::removeModifyListener( const Reference< util::XModifyListener >& aListener )
522 throw (uno::RuntimeException)
526 Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
527 xBroadcaster->removeModifyListener( aListener );
529 catch( const uno::Exception & ex )
531 ASSERT_EXCEPTION( ex );
535 // ____ XModifyListener ____
536 void SAL_CALL Diagram::modified( const lang::EventObject& aEvent )
537 throw (uno::RuntimeException)
539 m_xModifyEventForwarder->modified( aEvent );
542 // ____ XEventListener (base of XModifyListener) ____
543 void SAL_CALL Diagram::disposing( const lang::EventObject& /* Source */ )
544 throw (uno::RuntimeException)
546 // nothing
549 // ____ OPropertySet ____
550 void Diagram::firePropertyChangeEvent()
552 fireModifyEvent();
555 void Diagram::fireModifyEvent()
557 m_xModifyEventForwarder->modified( lang::EventObject( static_cast< uno::XWeak* >( this )));
560 // ============================================================
562 Sequence< OUString > Diagram::getSupportedServiceNames_Static()
564 Sequence< OUString > aServices( 3 );
566 aServices[ 0 ] = C2U( "com.sun.star.chart2.Diagram" );
567 aServices[ 1 ] = C2U( "com.sun.star.layout.LayoutElement" );
568 aServices[ 2 ] = C2U( "com.sun.star.beans.PropertySet" );
569 return aServices;
572 // ____ OPropertySet ____
573 uno::Any Diagram::GetDefaultValue( sal_Int32 nHandle ) const
574 throw(beans::UnknownPropertyException)
576 static tPropertyValueMap aStaticDefaults;
578 // /--
579 ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
580 if( 0 == aStaticDefaults.size() )
582 // initialize defaults
583 lcl_AddDefaultsToMap( aStaticDefaults );
584 ::chart::SceneProperties::AddDefaultsToMap( aStaticDefaults );
587 tPropertyValueMap::const_iterator aFound(
588 aStaticDefaults.find( nHandle ));
590 if( aFound == aStaticDefaults.end())
591 return uno::Any();
593 return (*aFound).second;
594 // \--
597 // ____ OPropertySet ____
598 ::cppu::IPropertyArrayHelper & SAL_CALL Diagram::getInfoHelper()
600 static ::cppu::OPropertyArrayHelper aArrayHelper( lcl_GetPropertySequence(),
601 /* bSorted = */ sal_True );
603 return aArrayHelper;
607 // ____ XPropertySet ____
608 uno::Reference< beans::XPropertySetInfo > SAL_CALL
609 Diagram::getPropertySetInfo()
610 throw (uno::RuntimeException)
612 static uno::Reference< beans::XPropertySetInfo > xInfo;
614 // /--
615 ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
616 if( !xInfo.is())
618 xInfo = ::cppu::OPropertySetHelper::createPropertySetInfo(
619 getInfoHelper());
622 return xInfo;
623 // \--
626 // ____ XFastPropertySet ____
627 void SAL_CALL Diagram::setFastPropertyValue( sal_Int32 nHandle, const Any& rValue )
628 throw(beans::UnknownPropertyException,
629 beans::PropertyVetoException,
630 lang::IllegalArgumentException,
631 lang::WrappedTargetException, uno::RuntimeException)
633 //special treatment for some 3D properties
634 if( PROP_DIAGRAM_PERSPECTIVE == nHandle )
636 sal_Int32 fPerspective = 20;
637 if( rValue >>=fPerspective )
638 ThreeDHelper::setCameraDistance( this, ThreeDHelper::PerspectiveToCameraDistance( fPerspective ) );
640 else if( PROP_DIAGRAM_ROTATION_HORIZONTAL == nHandle
641 || PROP_DIAGRAM_ROTATION_VERTICAL == nHandle )
643 sal_Int32 nNewAngleDegree = 0;
644 if( rValue >>=nNewAngleDegree )
646 sal_Int32 nHorizontal, nVertical;
647 ThreeDHelper::getRotationFromDiagram( const_cast< Diagram* >( this ), nHorizontal, nVertical );
648 if( PROP_DIAGRAM_ROTATION_HORIZONTAL == nHandle )
649 nHorizontal = nNewAngleDegree;
650 else
651 nVertical = nNewAngleDegree;
652 ThreeDHelper::setRotationToDiagram( this, nHorizontal, nVertical );
655 else
656 ::property::OPropertySet::setFastPropertyValue( nHandle, rValue );
659 void SAL_CALL Diagram::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const
661 //special treatment for some 3D properties
662 if( nHandle == PROP_DIAGRAM_PERSPECTIVE )
664 sal_Int32 nPerspective = ::basegfx::fround( ThreeDHelper::CameraDistanceToPerspective(
665 ThreeDHelper::getCameraDistance( const_cast< Diagram* >( this ) ) ) );
666 rValue = uno::makeAny(nPerspective);
668 else if( PROP_DIAGRAM_ROTATION_HORIZONTAL == nHandle
669 || PROP_DIAGRAM_ROTATION_VERTICAL == nHandle )
671 sal_Int32 nHorizontal, nVertical;
672 ThreeDHelper::getRotationFromDiagram( const_cast< Diagram* >( this ), nHorizontal, nVertical );
673 sal_Int32 nAngleDegree = 0;
674 if( PROP_DIAGRAM_ROTATION_HORIZONTAL == nHandle )
675 nAngleDegree = nHorizontal;
676 else
677 nAngleDegree = nVertical;
678 rValue = uno::makeAny(nAngleDegree);
680 else
681 ::property::OPropertySet::getFastPropertyValue( rValue,nHandle );
684 // ================================================================================
686 using impl::Diagram_Base;
688 IMPLEMENT_FORWARD_XINTERFACE2( Diagram, Diagram_Base, ::property::OPropertySet )
689 IMPLEMENT_FORWARD_XTYPEPROVIDER2( Diagram, Diagram_Base, ::property::OPropertySet )
691 // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
692 APPHELPER_XSERVICEINFO_IMPL( Diagram,
693 C2U( "com.sun.star.comp.chart2.Diagram" ));
695 } // namespace chart