1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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"
22 #include "PropertyHelper.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 <unonames.hxx>
36 #include <basegfx/numeric/ftools.hxx>
37 #include <rtl/instance.hxx>
38 #include <com/sun/star/beans/PropertyAttribute.hpp>
39 #include <com/sun/star/chart2/RelativePosition.hpp>
40 #include <com/sun/star/chart2/RelativeSize.hpp>
41 #include <com/sun/star/drawing/CameraGeometry.hpp>
43 #include <com/sun/star/drawing/HomogenMatrix.hpp>
44 #include <cppuhelper/supportsservice.hxx>
50 using namespace ::com::sun::star
;
51 using namespace ::com::sun::star::beans::PropertyAttribute
;
53 using ::com::sun::star::beans::Property
;
54 using ::com::sun::star::uno::Sequence
;
55 using ::com::sun::star::uno::Reference
;
56 using ::com::sun::star::uno::Any
;
57 using ::osl::MutexGuard
;
65 PROP_DIAGRAM_REL_SIZE
,
66 PROP_DIAGRAM_POSSIZE_EXCLUDE_LABELS
,
67 PROP_DIAGRAM_SORT_BY_X_VALUES
,
68 PROP_DIAGRAM_CONNECT_BARS
,
69 PROP_DIAGRAM_GROUP_BARS_PER_AXIS
,
70 PROP_DIAGRAM_INCLUDE_HIDDEN_CELLS
,
71 PROP_DIAGRAM_STARTING_ANGLE
,
72 PROP_DIAGRAM_RIGHT_ANGLED_AXES
,
73 PROP_DIAGRAM_PERSPECTIVE
,
74 PROP_DIAGRAM_ROTATION_HORIZONTAL
,
75 PROP_DIAGRAM_ROTATION_VERTICAL
,
76 PROP_DIAGRAM_MISSING_VALUE_TREATMENT
,
77 PROP_DIAGRAM_3DRELATIVEHEIGHT
,
78 PROP_DIAGRAM_DATATABLEHBORDER
,
79 PROP_DIAGRAM_DATATABLEVBORDER
,
80 PROP_DIAGRAM_DATATABLEOUTLINE
,
81 PROP_DIAGRAM_EXTERNALDATA
84 void lcl_AddPropertiesToVector(
85 ::std::vector
< Property
> & rOutProperties
)
87 rOutProperties
.push_back(
88 Property( "RelativePosition",
90 cppu::UnoType
<chart2::RelativePosition
>::get(),
91 beans::PropertyAttribute::BOUND
92 | beans::PropertyAttribute::MAYBEVOID
));
94 rOutProperties
.push_back(
95 Property( "RelativeSize",
96 PROP_DIAGRAM_REL_SIZE
,
97 cppu::UnoType
<chart2::RelativeSize
>::get(),
98 beans::PropertyAttribute::BOUND
99 | beans::PropertyAttribute::MAYBEVOID
));
101 rOutProperties
.push_back(
102 Property( "PosSizeExcludeAxes",
103 PROP_DIAGRAM_POSSIZE_EXCLUDE_LABELS
,
104 cppu::UnoType
<bool>::get(),
105 beans::PropertyAttribute::BOUND
106 | beans::PropertyAttribute::MAYBEDEFAULT
));
108 rOutProperties
.push_back(
109 Property( CHART_UNONAME_SORT_BY_XVALUES
,
110 PROP_DIAGRAM_SORT_BY_X_VALUES
,
111 cppu::UnoType
<bool>::get(),
112 beans::PropertyAttribute::BOUND
113 | beans::PropertyAttribute::MAYBEDEFAULT
));
115 rOutProperties
.push_back(
116 Property( "ConnectBars",
117 PROP_DIAGRAM_CONNECT_BARS
,
118 cppu::UnoType
<bool>::get(),
119 beans::PropertyAttribute::BOUND
120 | beans::PropertyAttribute::MAYBEDEFAULT
));
122 rOutProperties
.push_back(
123 Property( "GroupBarsPerAxis",
124 PROP_DIAGRAM_GROUP_BARS_PER_AXIS
,
125 cppu::UnoType
<bool>::get(),
126 beans::PropertyAttribute::BOUND
127 | beans::PropertyAttribute::MAYBEDEFAULT
));
129 rOutProperties
.push_back(
130 Property( "IncludeHiddenCells",
131 PROP_DIAGRAM_INCLUDE_HIDDEN_CELLS
,
132 cppu::UnoType
<bool>::get(),
133 beans::PropertyAttribute::BOUND
134 | beans::PropertyAttribute::MAYBEDEFAULT
));
136 rOutProperties
.push_back(
137 Property( "StartingAngle",
138 PROP_DIAGRAM_STARTING_ANGLE
,
139 cppu::UnoType
<sal_Int32
>::get(),
140 beans::PropertyAttribute::BOUND
141 | beans::PropertyAttribute::MAYBEDEFAULT
));
143 rOutProperties
.push_back(
144 Property( "RightAngledAxes",
145 PROP_DIAGRAM_RIGHT_ANGLED_AXES
,
146 cppu::UnoType
<bool>::get(),
147 beans::PropertyAttribute::BOUND
148 | beans::PropertyAttribute::MAYBEDEFAULT
));
150 rOutProperties
.push_back(
151 Property( "Perspective",
152 PROP_DIAGRAM_PERSPECTIVE
,
153 cppu::UnoType
<sal_Int32
>::get(),
154 beans::PropertyAttribute::MAYBEVOID
));
156 rOutProperties
.push_back(
157 Property( "RotationHorizontal",
158 PROP_DIAGRAM_ROTATION_HORIZONTAL
,
159 cppu::UnoType
<sal_Int32
>::get(),
160 beans::PropertyAttribute::MAYBEVOID
));
162 rOutProperties
.push_back(
163 Property( "RotationVertical",
164 PROP_DIAGRAM_ROTATION_VERTICAL
,
165 cppu::UnoType
<sal_Int32
>::get(),
166 beans::PropertyAttribute::MAYBEVOID
));
168 rOutProperties
.push_back(
169 Property( "MissingValueTreatment",
170 PROP_DIAGRAM_MISSING_VALUE_TREATMENT
,
171 cppu::UnoType
<sal_Int32
>::get(),
172 beans::PropertyAttribute::BOUND
173 | beans::PropertyAttribute::MAYBEVOID
));
174 rOutProperties
.push_back(
175 Property( "3DRelativeHeight",
176 PROP_DIAGRAM_3DRELATIVEHEIGHT
,
177 cppu::UnoType
<sal_Int32
>::get(),
178 beans::PropertyAttribute::MAYBEVOID
));
179 rOutProperties
.push_back(
180 Property( "DataTableHBorder",
181 PROP_DIAGRAM_DATATABLEHBORDER
,
182 cppu::UnoType
<bool>::get(),
183 beans::PropertyAttribute::BOUND
184 | beans::PropertyAttribute::MAYBEDEFAULT
));
185 rOutProperties
.push_back(
186 Property( "DataTableVBorder",
187 PROP_DIAGRAM_DATATABLEVBORDER
,
188 cppu::UnoType
<bool>::get(),
189 beans::PropertyAttribute::BOUND
190 | beans::PropertyAttribute::MAYBEDEFAULT
));
191 rOutProperties
.push_back(
192 Property( "DataTableOutline",
193 PROP_DIAGRAM_DATATABLEOUTLINE
,
194 cppu::UnoType
<bool>::get(),
195 beans::PropertyAttribute::BOUND
196 | beans::PropertyAttribute::MAYBEDEFAULT
));
197 rOutProperties
.push_back(
198 Property( "ExternalData",
199 PROP_DIAGRAM_EXTERNALDATA
,
200 cppu::UnoType
<OUString
>::get(),
201 beans::PropertyAttribute::MAYBEVOID
));
204 struct StaticDiagramDefaults_Initializer
206 ::chart::tPropertyValueMap
* operator()()
208 static ::chart::tPropertyValueMap aStaticDefaults
;
209 lcl_AddDefaultsToMap( aStaticDefaults
);
210 return &aStaticDefaults
;
213 static void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap
& rOutMap
)
215 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap
, PROP_DIAGRAM_POSSIZE_EXCLUDE_LABELS
, true );
216 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap
, PROP_DIAGRAM_SORT_BY_X_VALUES
, false );
217 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap
, PROP_DIAGRAM_CONNECT_BARS
, false );
218 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap
, PROP_DIAGRAM_GROUP_BARS_PER_AXIS
, true );
219 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap
, PROP_DIAGRAM_INCLUDE_HIDDEN_CELLS
, true );
220 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap
, PROP_DIAGRAM_RIGHT_ANGLED_AXES
, false );
221 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap
, PROP_DIAGRAM_DATATABLEHBORDER
, false );
222 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap
, PROP_DIAGRAM_DATATABLEVBORDER
, false );
223 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap
, PROP_DIAGRAM_DATATABLEOUTLINE
, false );
224 ::chart::PropertyHelper::setPropertyValueDefault
< sal_Int32
>( rOutMap
, PROP_DIAGRAM_STARTING_ANGLE
, 90 );
225 ::chart::PropertyHelper::setPropertyValueDefault
< sal_Int32
>( rOutMap
, PROP_DIAGRAM_3DRELATIVEHEIGHT
, 100 );
226 ::chart::SceneProperties::AddDefaultsToMap( rOutMap
);
230 struct StaticDiagramDefaults
: public rtl::StaticAggregate
< ::chart::tPropertyValueMap
, StaticDiagramDefaults_Initializer
>
234 struct StaticDiagramInfoHelper_Initializer
236 ::cppu::OPropertyArrayHelper
* operator()()
238 static ::cppu::OPropertyArrayHelper
aPropHelper( lcl_GetPropertySequence() );
243 static Sequence
< Property
> lcl_GetPropertySequence()
245 ::std::vector
< ::com::sun::star::beans::Property
> aProperties
;
246 lcl_AddPropertiesToVector( aProperties
);
247 ::chart::SceneProperties::AddPropertiesToVector( aProperties
);
248 ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties
);
250 ::std::sort( aProperties
.begin(), aProperties
.end(),
251 ::chart::PropertyNameLess() );
253 return ::chart::ContainerHelper::ContainerToSequence( aProperties
);
257 struct StaticDiagramInfoHelper
: public rtl::StaticAggregate
< ::cppu::OPropertyArrayHelper
, StaticDiagramInfoHelper_Initializer
>
261 struct StaticDiagramInfo_Initializer
263 uno::Reference
< beans::XPropertySetInfo
>* operator()()
265 static uno::Reference
< beans::XPropertySetInfo
> xPropertySetInfo(
266 ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticDiagramInfoHelper::get() ) );
267 return &xPropertySetInfo
;
271 struct StaticDiagramInfo
: public rtl::StaticAggregate
< uno::Reference
< beans::XPropertySetInfo
>, StaticDiagramInfo_Initializer
>
275 /// clones a UNO-sequence of UNO-References
276 typedef Reference
< chart2::XCoordinateSystem
> lcl_tCooSysRef
;
277 typedef ::std::map
< lcl_tCooSysRef
, lcl_tCooSysRef
> lcl_tCooSysMapping
;
278 typedef ::std::vector
< lcl_tCooSysRef
> lcl_tCooSysVector
;
280 lcl_tCooSysMapping
lcl_CloneCoordinateSystems(
281 const lcl_tCooSysVector
& rSource
,
282 lcl_tCooSysVector
& rDestination
)
284 lcl_tCooSysMapping aResult
;
286 for( lcl_tCooSysVector::const_iterator
aIt( rSource
.begin());
287 aIt
!= rSource
.end(); ++aIt
)
289 lcl_tCooSysRef xClone
;
290 ::com::sun::star::uno::Reference
< ::com::sun::star::util::XCloneable
>
291 xCloneable( *aIt
, ::com::sun::star::uno::UNO_QUERY
);
293 xClone
.set( xCloneable
->createClone(), ::com::sun::star::uno::UNO_QUERY
);
297 rDestination
.push_back( xClone
);
298 aResult
.insert( lcl_tCooSysMapping::value_type( *aIt
, xClone
));
301 rDestination
.push_back( *aIt
);
307 } // anonymous namespace
312 Diagram::Diagram( uno::Reference
< uno::XComponentContext
> const & xContext
) :
313 ::property::OPropertySet( m_aMutex
),
314 m_xContext( xContext
),
315 m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
317 // Set camera position to a default position (that should be set hard, so
318 // that it will be exported. The property default is a camera looking
319 // straight ono the scene). These defaults have been acquired from the old
320 // chart implementation.
321 setFastPropertyValue_NoBroadcast(
322 SceneProperties::PROP_SCENE_CAMERA_GEOMETRY
, uno::makeAny(
323 ThreeDHelper::getDefaultCameraGeometry()));
326 Diagram::Diagram( const Diagram
& rOther
) :
328 impl::Diagram_Base(),
329 ::property::OPropertySet( rOther
, m_aMutex
),
330 m_xContext( rOther
.m_xContext
),
331 m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
333 lcl_tCooSysMapping aCooSysMapping
=
334 lcl_CloneCoordinateSystems( rOther
.m_aCoordSystems
, m_aCoordSystems
);
335 ModifyListenerHelper::addListenerToAllElements( m_aCoordSystems
, m_xModifyEventForwarder
);
337 m_xWall
.set( CloneHelper::CreateRefClone
< Reference
< beans::XPropertySet
> >()( rOther
.m_xWall
));
338 m_xFloor
.set( CloneHelper::CreateRefClone
< Reference
< beans::XPropertySet
> >()( rOther
.m_xFloor
));
339 m_xTitle
.set( CloneHelper::CreateRefClone
< Reference
< chart2::XTitle
> >()( rOther
.m_xTitle
));
340 m_xLegend
.set( CloneHelper::CreateRefClone
< Reference
< chart2::XLegend
> >()( rOther
.m_xLegend
));
342 ModifyListenerHelper::addListener( m_xWall
, m_xModifyEventForwarder
);
343 ModifyListenerHelper::addListener( m_xFloor
, m_xModifyEventForwarder
);
344 ModifyListenerHelper::addListener( m_xTitle
, m_xModifyEventForwarder
);
345 ModifyListenerHelper::addListener( m_xLegend
, m_xModifyEventForwarder
);
352 ModifyListenerHelper::removeListenerFromAllElements( m_aCoordSystems
, m_xModifyEventForwarder
);
354 ModifyListenerHelper::removeListener( m_xWall
, m_xModifyEventForwarder
);
355 ModifyListenerHelper::removeListener( m_xFloor
, m_xModifyEventForwarder
);
356 ModifyListenerHelper::removeListener( m_xTitle
, m_xModifyEventForwarder
);
357 ModifyListenerHelper::removeListener( m_xLegend
, m_xModifyEventForwarder
);
359 catch( const uno::Exception
& ex
)
361 ASSERT_EXCEPTION( ex
);
365 // ____ XDiagram ____
366 uno::Reference
< beans::XPropertySet
> SAL_CALL
Diagram::getWall()
367 throw (uno::RuntimeException
, std::exception
)
369 uno::Reference
< beans::XPropertySet
> xRet
;
370 bool bAddListener
= false;
372 MutexGuard
aGuard( GetMutex() );
375 m_xWall
.set( new Wall() );
381 ModifyListenerHelper::addListener( xRet
, m_xModifyEventForwarder
);
385 uno::Reference
< beans::XPropertySet
> SAL_CALL
Diagram::getFloor()
386 throw (uno::RuntimeException
, std::exception
)
388 uno::Reference
< beans::XPropertySet
> xRet
;
389 bool bAddListener
= false;
391 MutexGuard
aGuard( GetMutex() );
394 m_xFloor
.set( new Wall() );
400 ModifyListenerHelper::addListener( xRet
, m_xModifyEventForwarder
);
404 uno::Reference
< chart2::XLegend
> SAL_CALL
Diagram::getLegend()
405 throw (uno::RuntimeException
, std::exception
)
407 MutexGuard
aGuard( GetMutex() );
411 void SAL_CALL
Diagram::setLegend( const uno::Reference
< chart2::XLegend
>& xNewLegend
)
412 throw (uno::RuntimeException
, std::exception
)
414 Reference
< chart2::XLegend
> xOldLegend
;
416 MutexGuard
aGuard( GetMutex() );
417 if( m_xLegend
== xNewLegend
)
419 xOldLegend
= m_xLegend
;
420 m_xLegend
= xNewLegend
;
423 ModifyListenerHelper::removeListener( xOldLegend
, m_xModifyEventForwarder
);
425 ModifyListenerHelper::addListener( xNewLegend
, m_xModifyEventForwarder
);
429 Reference
< chart2::XColorScheme
> SAL_CALL
Diagram::getDefaultColorScheme()
430 throw (uno::RuntimeException
, std::exception
)
432 Reference
< chart2::XColorScheme
> xRet
;
434 MutexGuard
aGuard( GetMutex() );
435 xRet
= m_xColorScheme
;
440 xRet
.set( createConfigColorScheme( m_xContext
));
441 MutexGuard
aGuard( GetMutex() );
442 m_xColorScheme
= xRet
;
447 void SAL_CALL
Diagram::setDefaultColorScheme( const Reference
< chart2::XColorScheme
>& xColorScheme
)
448 throw (uno::RuntimeException
, std::exception
)
451 MutexGuard
aGuard( GetMutex() );
452 m_xColorScheme
.set( xColorScheme
);
457 void SAL_CALL
Diagram::setDiagramData(
458 const Reference
< chart2::data::XDataSource
>& xDataSource
,
459 const Sequence
< beans::PropertyValue
>& aArguments
)
460 throw (uno::RuntimeException
, std::exception
)
462 uno::Reference
< lang::XMultiServiceFactory
> xChartTypeManager( m_xContext
->getServiceManager()->createInstanceWithContext(
463 "com.sun.star.chart2.ChartTypeManager", m_xContext
), uno::UNO_QUERY
);
464 DiagramHelper::tTemplateWithServiceName aTemplateAndService
= DiagramHelper::getTemplateForDiagram( this, xChartTypeManager
);
465 uno::Reference
< chart2::XChartTypeTemplate
> xTemplate( aTemplateAndService
.first
);
466 if( !xTemplate
.is() )
467 xTemplate
.set( xChartTypeManager
->createInstance( "com.sun.star.chart2.template.Column" ), uno::UNO_QUERY
);
470 xTemplate
->changeDiagramData( this, xDataSource
, aArguments
);
474 uno::Reference
< chart2::XTitle
> SAL_CALL
Diagram::getTitleObject()
475 throw (uno::RuntimeException
, std::exception
)
477 MutexGuard
aGuard( GetMutex() );
481 void SAL_CALL
Diagram::setTitleObject( const uno::Reference
< chart2::XTitle
>& xNewTitle
)
482 throw (uno::RuntimeException
, std::exception
)
484 Reference
< chart2::XTitle
> xOldTitle
;
486 MutexGuard
aGuard( GetMutex() );
487 if( m_xTitle
== xNewTitle
)
489 xOldTitle
= m_xTitle
;
490 m_xTitle
= xNewTitle
;
493 ModifyListenerHelper::removeListener( xOldTitle
, m_xModifyEventForwarder
);
495 ModifyListenerHelper::addListener( xNewTitle
, m_xModifyEventForwarder
);
499 // ____ X3DDefaultSetter ____
500 void SAL_CALL
Diagram::set3DSettingsToDefault()
501 throw (uno::RuntimeException
, std::exception
)
503 ThreeDHelper::set3DSettingsToDefault( this );
506 void SAL_CALL
Diagram::setDefaultRotation()
507 throw (uno::RuntimeException
, std::exception
)
509 ThreeDHelper::setDefaultRotation( this );
512 void SAL_CALL
Diagram::setDefaultIllumination()
513 throw (uno::RuntimeException
, std::exception
)
515 ThreeDHelper::setDefaultIllumination( this );
518 // ____ XCoordinateSystemContainer ____
519 void SAL_CALL
Diagram::addCoordinateSystem(
520 const uno::Reference
< chart2::XCoordinateSystem
>& aCoordSys
)
521 throw (lang::IllegalArgumentException
,
522 uno::RuntimeException
, std::exception
)
525 MutexGuard
aGuard( GetMutex() );
526 if( ::std::find( m_aCoordSystems
.begin(), m_aCoordSystems
.end(), aCoordSys
)
527 != m_aCoordSystems
.end())
528 throw lang::IllegalArgumentException();
530 if( m_aCoordSystems
.size()>=1 )
532 OSL_FAIL( "more than one coordinatesystem is not supported yet by the fileformat" );
535 m_aCoordSystems
.push_back( aCoordSys
);
537 ModifyListenerHelper::addListener( aCoordSys
, m_xModifyEventForwarder
);
541 void SAL_CALL
Diagram::removeCoordinateSystem(
542 const uno::Reference
< chart2::XCoordinateSystem
>& aCoordSys
)
543 throw (container::NoSuchElementException
,
544 uno::RuntimeException
, std::exception
)
547 MutexGuard
aGuard( GetMutex() );
548 ::std::vector
< uno::Reference
< chart2::XCoordinateSystem
> >::iterator
549 aIt( ::std::find( m_aCoordSystems
.begin(), m_aCoordSystems
.end(), aCoordSys
));
550 if( aIt
== m_aCoordSystems
.end())
551 throw container::NoSuchElementException(
552 "The given coordinate-system is no element of the container",
553 static_cast< uno::XWeak
* >( this ));
554 m_aCoordSystems
.erase( aIt
);
556 ModifyListenerHelper::removeListener( aCoordSys
, m_xModifyEventForwarder
);
560 uno::Sequence
< uno::Reference
< chart2::XCoordinateSystem
> > SAL_CALL
Diagram::getCoordinateSystems()
561 throw (uno::RuntimeException
, std::exception
)
563 MutexGuard
aGuard( GetMutex() );
564 return ContainerHelper::ContainerToSequence( m_aCoordSystems
);
567 void SAL_CALL
Diagram::setCoordinateSystems(
568 const Sequence
< Reference
< chart2::XCoordinateSystem
> >& aCoordinateSystems
)
569 throw (lang::IllegalArgumentException
,
570 uno::RuntimeException
, std::exception
)
572 tCoordinateSystemContainerType aNew
;
573 tCoordinateSystemContainerType aOld
;
574 if( aCoordinateSystems
.getLength()>0 )
576 OSL_ENSURE( aCoordinateSystems
.getLength()<=1, "more than one coordinatesystem is not supported yet by the fileformat" );
577 aNew
.push_back( aCoordinateSystems
[0] );
580 MutexGuard
aGuard( GetMutex() );
581 std::swap( aOld
, m_aCoordSystems
);
582 m_aCoordSystems
= aNew
;
584 ModifyListenerHelper::removeListenerFromAllElements( aOld
, m_xModifyEventForwarder
);
585 ModifyListenerHelper::addListenerToAllElements( aNew
, m_xModifyEventForwarder
);
589 // ____ XCloneable ____
590 Reference
< util::XCloneable
> SAL_CALL
Diagram::createClone()
591 throw (uno::RuntimeException
, std::exception
)
593 MutexGuard
aGuard( GetMutex() );
594 return Reference
< util::XCloneable
>( new Diagram( *this ));
597 // ____ XModifyBroadcaster ____
598 void SAL_CALL
Diagram::addModifyListener( const Reference
< util::XModifyListener
>& aListener
)
599 throw (uno::RuntimeException
, std::exception
)
603 Reference
< util::XModifyBroadcaster
> xBroadcaster( m_xModifyEventForwarder
, uno::UNO_QUERY_THROW
);
604 xBroadcaster
->addModifyListener( aListener
);
606 catch( const uno::Exception
& ex
)
608 ASSERT_EXCEPTION( ex
);
612 void SAL_CALL
Diagram::removeModifyListener( const Reference
< util::XModifyListener
>& aListener
)
613 throw (uno::RuntimeException
, std::exception
)
617 Reference
< util::XModifyBroadcaster
> xBroadcaster( m_xModifyEventForwarder
, uno::UNO_QUERY_THROW
);
618 xBroadcaster
->removeModifyListener( aListener
);
620 catch( const uno::Exception
& ex
)
622 ASSERT_EXCEPTION( ex
);
626 // ____ XModifyListener ____
627 void SAL_CALL
Diagram::modified( const lang::EventObject
& aEvent
)
628 throw (uno::RuntimeException
, std::exception
)
630 m_xModifyEventForwarder
->modified( aEvent
);
633 // ____ XEventListener (base of XModifyListener) ____
634 void SAL_CALL
Diagram::disposing( const lang::EventObject
& /* Source */ )
635 throw (uno::RuntimeException
, std::exception
)
640 // ____ OPropertySet ____
641 void Diagram::firePropertyChangeEvent()
646 void Diagram::fireModifyEvent()
648 m_xModifyEventForwarder
->modified( lang::EventObject( static_cast< uno::XWeak
* >( this )));
651 Sequence
< OUString
> Diagram::getSupportedServiceNames_Static()
653 Sequence
< OUString
> aServices( 3 );
655 aServices
[ 0 ] = "com.sun.star.chart2.Diagram";
656 aServices
[ 1 ] = "com.sun.star.layout.LayoutElement";
657 aServices
[ 2 ] = "com.sun.star.beans.PropertySet";
661 // ____ OPropertySet ____
662 uno::Any
Diagram::GetDefaultValue( sal_Int32 nHandle
) const
663 throw(beans::UnknownPropertyException
)
665 const tPropertyValueMap
& rStaticDefaults
= *StaticDiagramDefaults::get();
666 tPropertyValueMap::const_iterator
aFound( rStaticDefaults
.find( nHandle
) );
667 if( aFound
== rStaticDefaults
.end() )
669 return (*aFound
).second
;
672 // ____ OPropertySet ____
673 ::cppu::IPropertyArrayHelper
& SAL_CALL
Diagram::getInfoHelper()
675 return *StaticDiagramInfoHelper::get();
678 // ____ XPropertySet ____
679 uno::Reference
< beans::XPropertySetInfo
> SAL_CALL
Diagram::getPropertySetInfo()
680 throw (uno::RuntimeException
, std::exception
)
682 return *StaticDiagramInfo::get();
685 // ____ XFastPropertySet ____
686 void SAL_CALL
Diagram::setFastPropertyValue( sal_Int32 nHandle
, const Any
& rValue
)
687 throw(beans::UnknownPropertyException
,
688 beans::PropertyVetoException
,
689 lang::IllegalArgumentException
,
690 lang::WrappedTargetException
, uno::RuntimeException
, std::exception
)
692 //special treatment for some 3D properties
693 if( PROP_DIAGRAM_PERSPECTIVE
== nHandle
)
695 sal_Int32 fPerspective
= 20;
696 if( rValue
>>=fPerspective
)
697 ThreeDHelper::setCameraDistance( this, ThreeDHelper::PerspectiveToCameraDistance( fPerspective
) );
699 else if( PROP_DIAGRAM_ROTATION_HORIZONTAL
== nHandle
700 || PROP_DIAGRAM_ROTATION_VERTICAL
== nHandle
)
702 sal_Int32 nNewAngleDegree
= 0;
703 if( rValue
>>=nNewAngleDegree
)
705 sal_Int32 nHorizontal
, nVertical
;
706 ThreeDHelper::getRotationFromDiagram( this, nHorizontal
, nVertical
);
707 if( PROP_DIAGRAM_ROTATION_HORIZONTAL
== nHandle
)
708 nHorizontal
= nNewAngleDegree
;
710 nVertical
= nNewAngleDegree
;
711 ThreeDHelper::setRotationToDiagram( this, nHorizontal
, nVertical
);
715 ::property::OPropertySet::setFastPropertyValue( nHandle
, rValue
);
718 void SAL_CALL
Diagram::getFastPropertyValue( Any
& rValue
, sal_Int32 nHandle
) const
720 //special treatment for some 3D properties
721 if( nHandle
== PROP_DIAGRAM_PERSPECTIVE
)
723 sal_Int32 nPerspective
= ::basegfx::fround( ThreeDHelper::CameraDistanceToPerspective(
724 ThreeDHelper::getCameraDistance( const_cast< Diagram
* >( this ) ) ) );
725 rValue
= uno::makeAny(nPerspective
);
727 else if( PROP_DIAGRAM_ROTATION_HORIZONTAL
== nHandle
728 || PROP_DIAGRAM_ROTATION_VERTICAL
== nHandle
)
730 sal_Int32 nHorizontal
, nVertical
;
731 ThreeDHelper::getRotationFromDiagram( const_cast< Diagram
* >( this ), nHorizontal
, nVertical
);
732 sal_Int32 nAngleDegree
= 0;
733 if( PROP_DIAGRAM_ROTATION_HORIZONTAL
== nHandle
)
734 nAngleDegree
= nHorizontal
;
736 nAngleDegree
= nVertical
;
737 rValue
= uno::makeAny(nAngleDegree
);
740 ::property::OPropertySet::getFastPropertyValue( rValue
,nHandle
);
743 using impl::Diagram_Base
;
745 IMPLEMENT_FORWARD_XINTERFACE2( Diagram
, Diagram_Base
, ::property::OPropertySet
)
746 IMPLEMENT_FORWARD_XTYPEPROVIDER2( Diagram
, Diagram_Base
, ::property::OPropertySet
)
748 // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
749 OUString SAL_CALL
Diagram::getImplementationName()
750 throw( css::uno::RuntimeException
, std::exception
)
752 return getImplementationName_Static();
755 OUString
Diagram::getImplementationName_Static()
757 return OUString("com.sun.star.comp.chart2.Diagram");
760 sal_Bool SAL_CALL
Diagram::supportsService( const OUString
& rServiceName
)
761 throw( css::uno::RuntimeException
, std::exception
)
763 return cppu::supportsService(this, rServiceName
);
766 css::uno::Sequence
< OUString
> SAL_CALL
Diagram::getSupportedServiceNames()
767 throw( css::uno::RuntimeException
, std::exception
)
769 return getSupportedServiceNames_Static();
774 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
* SAL_CALL
775 com_sun_star_comp_chart2_Diagram_get_implementation(css::uno::XComponentContext
*context
,
776 css::uno::Sequence
<css::uno::Any
> const &)
778 return cppu::acquire(new ::chart::Diagram(context
));
781 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */