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>
21 #include <PropertyHelper.hxx>
23 #include <ModifyListenerHelper.hxx>
24 #include <UserDefinedProperties.hxx>
25 #include <ConfigColorScheme.hxx>
26 #include <DiagramHelper.hxx>
27 #include <ThreeDHelper.hxx>
28 #include <CloneHelper.hxx>
29 #include <SceneProperties.hxx>
30 #include <unonames.hxx>
32 #include <basegfx/numeric/ftools.hxx>
33 #include <rtl/instance.hxx>
34 #include <com/sun/star/beans/PropertyAttribute.hpp>
35 #include <com/sun/star/chart2/RelativePosition.hpp>
36 #include <com/sun/star/chart2/RelativeSize.hpp>
37 #include <com/sun/star/container/NoSuchElementException.hpp>
38 #include <com/sun/star/uno/XComponentContext.hpp>
39 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
41 #include <cppuhelper/supportsservice.hxx>
42 #include <tools/diagnose_ex.h>
46 using namespace ::com::sun::star
;
47 using namespace ::com::sun::star::beans::PropertyAttribute
;
49 using ::com::sun::star::beans::Property
;
50 using ::com::sun::star::uno::Sequence
;
51 using ::com::sun::star::uno::Reference
;
52 using ::com::sun::star::uno::Any
;
53 using ::osl::MutexGuard
;
61 PROP_DIAGRAM_REL_SIZE
,
62 PROP_DIAGRAM_POSSIZE_EXCLUDE_LABELS
,
63 PROP_DIAGRAM_SORT_BY_X_VALUES
,
64 PROP_DIAGRAM_CONNECT_BARS
,
65 PROP_DIAGRAM_GROUP_BARS_PER_AXIS
,
66 PROP_DIAGRAM_INCLUDE_HIDDEN_CELLS
,
67 PROP_DIAGRAM_STARTING_ANGLE
,
68 PROP_DIAGRAM_RIGHT_ANGLED_AXES
,
69 PROP_DIAGRAM_PERSPECTIVE
,
70 PROP_DIAGRAM_ROTATION_HORIZONTAL
,
71 PROP_DIAGRAM_ROTATION_VERTICAL
,
72 PROP_DIAGRAM_MISSING_VALUE_TREATMENT
,
73 PROP_DIAGRAM_3DRELATIVEHEIGHT
,
74 PROP_DIAGRAM_DATATABLEHBORDER
,
75 PROP_DIAGRAM_DATATABLEVBORDER
,
76 PROP_DIAGRAM_DATATABLEOUTLINE
,
77 PROP_DIAGRAM_EXTERNALDATA
80 void lcl_AddPropertiesToVector(
81 std::vector
< Property
> & rOutProperties
)
83 rOutProperties
.emplace_back( "RelativePosition",
85 cppu::UnoType
<chart2::RelativePosition
>::get(),
86 beans::PropertyAttribute::BOUND
87 | beans::PropertyAttribute::MAYBEVOID
);
89 rOutProperties
.emplace_back( "RelativeSize",
90 PROP_DIAGRAM_REL_SIZE
,
91 cppu::UnoType
<chart2::RelativeSize
>::get(),
92 beans::PropertyAttribute::BOUND
93 | beans::PropertyAttribute::MAYBEVOID
);
95 rOutProperties
.emplace_back( "PosSizeExcludeAxes",
96 PROP_DIAGRAM_POSSIZE_EXCLUDE_LABELS
,
97 cppu::UnoType
<bool>::get(),
98 beans::PropertyAttribute::BOUND
99 | beans::PropertyAttribute::MAYBEDEFAULT
);
101 rOutProperties
.emplace_back( CHART_UNONAME_SORT_BY_XVALUES
,
102 PROP_DIAGRAM_SORT_BY_X_VALUES
,
103 cppu::UnoType
<bool>::get(),
104 beans::PropertyAttribute::BOUND
105 | beans::PropertyAttribute::MAYBEDEFAULT
);
107 rOutProperties
.emplace_back( "ConnectBars",
108 PROP_DIAGRAM_CONNECT_BARS
,
109 cppu::UnoType
<bool>::get(),
110 beans::PropertyAttribute::BOUND
111 | beans::PropertyAttribute::MAYBEDEFAULT
);
113 rOutProperties
.emplace_back( "GroupBarsPerAxis",
114 PROP_DIAGRAM_GROUP_BARS_PER_AXIS
,
115 cppu::UnoType
<bool>::get(),
116 beans::PropertyAttribute::BOUND
117 | beans::PropertyAttribute::MAYBEDEFAULT
);
119 rOutProperties
.emplace_back( "IncludeHiddenCells",
120 PROP_DIAGRAM_INCLUDE_HIDDEN_CELLS
,
121 cppu::UnoType
<bool>::get(),
122 beans::PropertyAttribute::BOUND
123 | beans::PropertyAttribute::MAYBEDEFAULT
);
125 rOutProperties
.emplace_back( "StartingAngle",
126 PROP_DIAGRAM_STARTING_ANGLE
,
127 cppu::UnoType
<sal_Int32
>::get(),
128 beans::PropertyAttribute::BOUND
129 | beans::PropertyAttribute::MAYBEDEFAULT
);
131 rOutProperties
.emplace_back( "RightAngledAxes",
132 PROP_DIAGRAM_RIGHT_ANGLED_AXES
,
133 cppu::UnoType
<bool>::get(),
134 beans::PropertyAttribute::BOUND
135 | beans::PropertyAttribute::MAYBEDEFAULT
);
137 rOutProperties
.emplace_back( "Perspective",
138 PROP_DIAGRAM_PERSPECTIVE
,
139 cppu::UnoType
<sal_Int32
>::get(),
140 beans::PropertyAttribute::MAYBEVOID
);
142 rOutProperties
.emplace_back( "RotationHorizontal",
143 PROP_DIAGRAM_ROTATION_HORIZONTAL
,
144 cppu::UnoType
<sal_Int32
>::get(),
145 beans::PropertyAttribute::MAYBEVOID
);
147 rOutProperties
.emplace_back( "RotationVertical",
148 PROP_DIAGRAM_ROTATION_VERTICAL
,
149 cppu::UnoType
<sal_Int32
>::get(),
150 beans::PropertyAttribute::MAYBEVOID
);
152 rOutProperties
.emplace_back( "MissingValueTreatment",
153 PROP_DIAGRAM_MISSING_VALUE_TREATMENT
,
154 cppu::UnoType
<sal_Int32
>::get(),
155 beans::PropertyAttribute::BOUND
156 | beans::PropertyAttribute::MAYBEVOID
);
157 rOutProperties
.emplace_back( "3DRelativeHeight",
158 PROP_DIAGRAM_3DRELATIVEHEIGHT
,
159 cppu::UnoType
<sal_Int32
>::get(),
160 beans::PropertyAttribute::MAYBEVOID
);
161 rOutProperties
.emplace_back( "DataTableHBorder",
162 PROP_DIAGRAM_DATATABLEHBORDER
,
163 cppu::UnoType
<bool>::get(),
164 beans::PropertyAttribute::BOUND
165 | beans::PropertyAttribute::MAYBEDEFAULT
);
166 rOutProperties
.emplace_back( "DataTableVBorder",
167 PROP_DIAGRAM_DATATABLEVBORDER
,
168 cppu::UnoType
<bool>::get(),
169 beans::PropertyAttribute::BOUND
170 | beans::PropertyAttribute::MAYBEDEFAULT
);
171 rOutProperties
.emplace_back( "DataTableOutline",
172 PROP_DIAGRAM_DATATABLEOUTLINE
,
173 cppu::UnoType
<bool>::get(),
174 beans::PropertyAttribute::BOUND
175 | beans::PropertyAttribute::MAYBEDEFAULT
);
176 rOutProperties
.emplace_back( "ExternalData",
177 PROP_DIAGRAM_EXTERNALDATA
,
178 cppu::UnoType
<OUString
>::get(),
179 beans::PropertyAttribute::MAYBEVOID
);
182 struct StaticDiagramDefaults_Initializer
184 ::chart::tPropertyValueMap
* operator()()
186 static ::chart::tPropertyValueMap aStaticDefaults
;
187 lcl_AddDefaultsToMap( aStaticDefaults
);
188 return &aStaticDefaults
;
191 static void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap
& rOutMap
)
193 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap
, PROP_DIAGRAM_POSSIZE_EXCLUDE_LABELS
, true );
194 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap
, PROP_DIAGRAM_SORT_BY_X_VALUES
, false );
195 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap
, PROP_DIAGRAM_CONNECT_BARS
, false );
196 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap
, PROP_DIAGRAM_GROUP_BARS_PER_AXIS
, true );
197 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap
, PROP_DIAGRAM_INCLUDE_HIDDEN_CELLS
, true );
198 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap
, PROP_DIAGRAM_RIGHT_ANGLED_AXES
, false );
199 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap
, PROP_DIAGRAM_DATATABLEHBORDER
, false );
200 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap
, PROP_DIAGRAM_DATATABLEVBORDER
, false );
201 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap
, PROP_DIAGRAM_DATATABLEOUTLINE
, false );
202 ::chart::PropertyHelper::setPropertyValueDefault
< sal_Int32
>( rOutMap
, PROP_DIAGRAM_STARTING_ANGLE
, 90 );
203 ::chart::PropertyHelper::setPropertyValueDefault
< sal_Int32
>( rOutMap
, PROP_DIAGRAM_3DRELATIVEHEIGHT
, 100 );
204 ::chart::SceneProperties::AddDefaultsToMap( rOutMap
);
208 struct StaticDiagramDefaults
: public rtl::StaticAggregate
< ::chart::tPropertyValueMap
, StaticDiagramDefaults_Initializer
>
212 struct StaticDiagramInfoHelper_Initializer
214 ::cppu::OPropertyArrayHelper
* operator()()
216 static ::cppu::OPropertyArrayHelper
aPropHelper( lcl_GetPropertySequence() );
221 static Sequence
< Property
> lcl_GetPropertySequence()
223 std::vector
< css::beans::Property
> aProperties
;
224 lcl_AddPropertiesToVector( aProperties
);
225 ::chart::SceneProperties::AddPropertiesToVector( aProperties
);
226 ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties
);
228 std::sort( aProperties
.begin(), aProperties
.end(),
229 ::chart::PropertyNameLess() );
231 return comphelper::containerToSequence( aProperties
);
235 struct StaticDiagramInfoHelper
: public rtl::StaticAggregate
< ::cppu::OPropertyArrayHelper
, StaticDiagramInfoHelper_Initializer
>
239 struct StaticDiagramInfo_Initializer
241 uno::Reference
< beans::XPropertySetInfo
>* operator()()
243 static uno::Reference
< beans::XPropertySetInfo
> xPropertySetInfo(
244 ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticDiagramInfoHelper::get() ) );
245 return &xPropertySetInfo
;
249 struct StaticDiagramInfo
: public rtl::StaticAggregate
< uno::Reference
< beans::XPropertySetInfo
>, StaticDiagramInfo_Initializer
>
253 /// clones a UNO-sequence of UNO-References
254 typedef Reference
< chart2::XCoordinateSystem
> lcl_tCooSysRef
;
255 typedef std::vector
< lcl_tCooSysRef
> lcl_tCooSysVector
;
257 void lcl_CloneCoordinateSystems(
258 const lcl_tCooSysVector
& rSource
,
259 lcl_tCooSysVector
& rDestination
)
261 for( auto const & i
: rSource
)
263 lcl_tCooSysRef xClone
;
264 css::uno::Reference
< css::util::XCloneable
> xCloneable( i
, css::uno::UNO_QUERY
);
266 xClone
.set( xCloneable
->createClone(), css::uno::UNO_QUERY
);
270 rDestination
.push_back( xClone
);
273 rDestination
.push_back( i
);
277 } // anonymous namespace
282 Diagram::Diagram( uno::Reference
< uno::XComponentContext
> const & xContext
) :
283 ::property::OPropertySet( m_aMutex
),
284 m_xContext( xContext
),
285 m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
287 // Set camera position to a default position (that should be set hard, so
288 // that it will be exported. The property default is a camera looking
289 // straight ono the scene). These defaults have been acquired from the old
290 // chart implementation.
291 setFastPropertyValue_NoBroadcast(
292 SceneProperties::PROP_SCENE_CAMERA_GEOMETRY
, uno::Any(
293 ThreeDHelper::getDefaultCameraGeometry()));
296 Diagram::Diagram( const Diagram
& rOther
) :
297 impl::Diagram_Base(rOther
),
298 ::property::OPropertySet( rOther
, m_aMutex
),
299 m_xContext( rOther
.m_xContext
),
300 m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
302 lcl_CloneCoordinateSystems( rOther
.m_aCoordSystems
, m_aCoordSystems
);
303 ModifyListenerHelper::addListenerToAllElements( m_aCoordSystems
, m_xModifyEventForwarder
);
305 m_xWall
.set( CloneHelper::CreateRefClone
< beans::XPropertySet
>()( rOther
.m_xWall
));
306 m_xFloor
.set( CloneHelper::CreateRefClone
< beans::XPropertySet
>()( rOther
.m_xFloor
));
307 m_xTitle
.set( CloneHelper::CreateRefClone
< chart2::XTitle
>()( rOther
.m_xTitle
));
308 m_xLegend
.set( CloneHelper::CreateRefClone
< chart2::XLegend
>()( rOther
.m_xLegend
));
310 ModifyListenerHelper::addListener( m_xWall
, m_xModifyEventForwarder
);
311 ModifyListenerHelper::addListener( m_xFloor
, m_xModifyEventForwarder
);
312 ModifyListenerHelper::addListener( m_xTitle
, m_xModifyEventForwarder
);
313 ModifyListenerHelper::addListener( m_xLegend
, m_xModifyEventForwarder
);
320 ModifyListenerHelper::removeListenerFromAllElements( m_aCoordSystems
, m_xModifyEventForwarder
);
322 ModifyListenerHelper::removeListener( m_xWall
, m_xModifyEventForwarder
);
323 ModifyListenerHelper::removeListener( m_xFloor
, m_xModifyEventForwarder
);
324 ModifyListenerHelper::removeListener( m_xTitle
, m_xModifyEventForwarder
);
325 ModifyListenerHelper::removeListener( m_xLegend
, m_xModifyEventForwarder
);
327 catch( const uno::Exception
& )
329 DBG_UNHANDLED_EXCEPTION("chart2");
333 // ____ XDiagram ____
334 uno::Reference
< beans::XPropertySet
> SAL_CALL
Diagram::getWall()
336 uno::Reference
< beans::XPropertySet
> xRet
;
337 bool bAddListener
= false;
339 MutexGuard
aGuard( m_aMutex
);
342 m_xWall
.set( new Wall() );
348 ModifyListenerHelper::addListener( xRet
, m_xModifyEventForwarder
);
352 uno::Reference
< beans::XPropertySet
> SAL_CALL
Diagram::getFloor()
354 uno::Reference
< beans::XPropertySet
> xRet
;
355 bool bAddListener
= false;
357 MutexGuard
aGuard( m_aMutex
);
360 m_xFloor
.set( new Wall() );
366 ModifyListenerHelper::addListener( xRet
, m_xModifyEventForwarder
);
370 uno::Reference
< chart2::XLegend
> SAL_CALL
Diagram::getLegend()
372 MutexGuard
aGuard( m_aMutex
);
376 void SAL_CALL
Diagram::setLegend( const uno::Reference
< chart2::XLegend
>& xNewLegend
)
378 Reference
< chart2::XLegend
> xOldLegend
;
380 MutexGuard
aGuard( m_aMutex
);
381 if( m_xLegend
== xNewLegend
)
383 xOldLegend
= m_xLegend
;
384 m_xLegend
= xNewLegend
;
387 ModifyListenerHelper::removeListener( xOldLegend
, m_xModifyEventForwarder
);
389 ModifyListenerHelper::addListener( xNewLegend
, m_xModifyEventForwarder
);
393 Reference
< chart2::XColorScheme
> SAL_CALL
Diagram::getDefaultColorScheme()
395 Reference
< chart2::XColorScheme
> xRet
;
397 MutexGuard
aGuard( m_aMutex
);
398 xRet
= m_xColorScheme
;
403 xRet
.set( createConfigColorScheme( m_xContext
));
404 MutexGuard
aGuard( m_aMutex
);
405 m_xColorScheme
= xRet
;
410 void SAL_CALL
Diagram::setDefaultColorScheme( const Reference
< chart2::XColorScheme
>& xColorScheme
)
413 MutexGuard
aGuard( m_aMutex
);
414 m_xColorScheme
.set( xColorScheme
);
419 void SAL_CALL
Diagram::setDiagramData(
420 const Reference
< chart2::data::XDataSource
>& xDataSource
,
421 const Sequence
< beans::PropertyValue
>& aArguments
)
423 uno::Reference
< lang::XMultiServiceFactory
> xChartTypeManager( m_xContext
->getServiceManager()->createInstanceWithContext(
424 "com.sun.star.chart2.ChartTypeManager", m_xContext
), uno::UNO_QUERY
);
425 DiagramHelper::tTemplateWithServiceName aTemplateAndService
= DiagramHelper::getTemplateForDiagram( this, xChartTypeManager
);
426 uno::Reference
< chart2::XChartTypeTemplate
> xTemplate( aTemplateAndService
.first
);
427 if( !xTemplate
.is() )
428 xTemplate
.set( xChartTypeManager
->createInstance( "com.sun.star.chart2.template.Column" ), uno::UNO_QUERY
);
431 xTemplate
->changeDiagramData( this, xDataSource
, aArguments
);
435 uno::Reference
< chart2::XTitle
> SAL_CALL
Diagram::getTitleObject()
437 MutexGuard
aGuard( m_aMutex
);
441 void SAL_CALL
Diagram::setTitleObject( const uno::Reference
< chart2::XTitle
>& xNewTitle
)
443 Reference
< chart2::XTitle
> xOldTitle
;
445 MutexGuard
aGuard( m_aMutex
);
446 if( m_xTitle
== xNewTitle
)
448 xOldTitle
= m_xTitle
;
449 m_xTitle
= xNewTitle
;
452 ModifyListenerHelper::removeListener( xOldTitle
, m_xModifyEventForwarder
);
454 ModifyListenerHelper::addListener( xNewTitle
, m_xModifyEventForwarder
);
458 // ____ X3DDefaultSetter ____
459 void SAL_CALL
Diagram::set3DSettingsToDefault()
461 ThreeDHelper::set3DSettingsToDefault( this );
464 void SAL_CALL
Diagram::setDefaultRotation()
466 ThreeDHelper::setDefaultRotation( this );
469 void SAL_CALL
Diagram::setDefaultIllumination()
471 ThreeDHelper::setDefaultIllumination( this );
474 // ____ XCoordinateSystemContainer ____
475 void SAL_CALL
Diagram::addCoordinateSystem(
476 const uno::Reference
< chart2::XCoordinateSystem
>& aCoordSys
)
479 MutexGuard
aGuard( m_aMutex
);
480 if( std::find( m_aCoordSystems
.begin(), m_aCoordSystems
.end(), aCoordSys
)
481 != m_aCoordSystems
.end())
482 throw lang::IllegalArgumentException();
484 if( !m_aCoordSystems
.empty() )
486 OSL_FAIL( "more than one coordinatesystem is not supported yet by the fileformat" );
489 m_aCoordSystems
.push_back( aCoordSys
);
491 ModifyListenerHelper::addListener( aCoordSys
, m_xModifyEventForwarder
);
495 void SAL_CALL
Diagram::removeCoordinateSystem(
496 const uno::Reference
< chart2::XCoordinateSystem
>& aCoordSys
)
499 MutexGuard
aGuard( m_aMutex
);
500 std::vector
< uno::Reference
< chart2::XCoordinateSystem
> >::iterator
501 aIt( std::find( m_aCoordSystems
.begin(), m_aCoordSystems
.end(), aCoordSys
));
502 if( aIt
== m_aCoordSystems
.end())
503 throw container::NoSuchElementException(
504 "The given coordinate-system is no element of the container",
505 static_cast< uno::XWeak
* >( this ));
506 m_aCoordSystems
.erase( aIt
);
508 ModifyListenerHelper::removeListener( aCoordSys
, m_xModifyEventForwarder
);
512 uno::Sequence
< uno::Reference
< chart2::XCoordinateSystem
> > SAL_CALL
Diagram::getCoordinateSystems()
514 MutexGuard
aGuard( m_aMutex
);
515 return comphelper::containerToSequence( m_aCoordSystems
);
518 void SAL_CALL
Diagram::setCoordinateSystems(
519 const Sequence
< Reference
< chart2::XCoordinateSystem
> >& aCoordinateSystems
)
521 tCoordinateSystemContainerType aNew
;
522 tCoordinateSystemContainerType aOld
;
523 if( aCoordinateSystems
.hasElements() )
525 OSL_ENSURE( aCoordinateSystems
.getLength()<=1, "more than one coordinatesystem is not supported yet by the fileformat" );
526 aNew
.push_back( aCoordinateSystems
[0] );
529 MutexGuard
aGuard( m_aMutex
);
530 std::swap( aOld
, m_aCoordSystems
);
531 m_aCoordSystems
= aNew
;
533 ModifyListenerHelper::removeListenerFromAllElements( aOld
, m_xModifyEventForwarder
);
534 ModifyListenerHelper::addListenerToAllElements( aNew
, m_xModifyEventForwarder
);
538 // ____ XCloneable ____
539 Reference
< util::XCloneable
> SAL_CALL
Diagram::createClone()
541 MutexGuard
aGuard( m_aMutex
);
542 return Reference
< util::XCloneable
>( new Diagram( *this ));
545 // ____ XModifyBroadcaster ____
546 void SAL_CALL
Diagram::addModifyListener( const Reference
< util::XModifyListener
>& aListener
)
550 Reference
< util::XModifyBroadcaster
> xBroadcaster( m_xModifyEventForwarder
, uno::UNO_QUERY_THROW
);
551 xBroadcaster
->addModifyListener( aListener
);
553 catch( const uno::Exception
& )
555 DBG_UNHANDLED_EXCEPTION("chart2");
559 void SAL_CALL
Diagram::removeModifyListener( const Reference
< util::XModifyListener
>& aListener
)
563 Reference
< util::XModifyBroadcaster
> xBroadcaster( m_xModifyEventForwarder
, uno::UNO_QUERY_THROW
);
564 xBroadcaster
->removeModifyListener( aListener
);
566 catch( const uno::Exception
& )
568 DBG_UNHANDLED_EXCEPTION("chart2");
572 // ____ XModifyListener ____
573 void SAL_CALL
Diagram::modified( const lang::EventObject
& aEvent
)
575 m_xModifyEventForwarder
->modified( aEvent
);
578 // ____ XEventListener (base of XModifyListener) ____
579 void SAL_CALL
Diagram::disposing( const lang::EventObject
& /* Source */ )
584 // ____ OPropertySet ____
585 void Diagram::firePropertyChangeEvent()
590 void Diagram::fireModifyEvent()
592 m_xModifyEventForwarder
->modified( lang::EventObject( static_cast< uno::XWeak
* >( this )));
595 // ____ OPropertySet ____
596 uno::Any
Diagram::GetDefaultValue( sal_Int32 nHandle
) const
598 const tPropertyValueMap
& rStaticDefaults
= *StaticDiagramDefaults::get();
599 tPropertyValueMap::const_iterator
aFound( rStaticDefaults
.find( nHandle
) );
600 if( aFound
== rStaticDefaults
.end() )
602 return (*aFound
).second
;
605 // ____ OPropertySet ____
606 ::cppu::IPropertyArrayHelper
& SAL_CALL
Diagram::getInfoHelper()
608 return *StaticDiagramInfoHelper::get();
611 // ____ XPropertySet ____
612 uno::Reference
< beans::XPropertySetInfo
> SAL_CALL
Diagram::getPropertySetInfo()
614 return *StaticDiagramInfo::get();
617 // ____ XFastPropertySet ____
618 void SAL_CALL
Diagram::setFastPropertyValue( sal_Int32 nHandle
, const Any
& rValue
)
620 //special treatment for some 3D properties
621 if( nHandle
== PROP_DIAGRAM_PERSPECTIVE
)
623 sal_Int32 fPerspective
= 20;
624 if( rValue
>>=fPerspective
)
625 ThreeDHelper::setCameraDistance( this, ThreeDHelper::PerspectiveToCameraDistance( fPerspective
) );
627 else if( nHandle
== PROP_DIAGRAM_ROTATION_HORIZONTAL
628 || nHandle
== PROP_DIAGRAM_ROTATION_VERTICAL
)
630 sal_Int32 nNewAngleDegree
= 0;
631 if( rValue
>>=nNewAngleDegree
)
633 sal_Int32 nHorizontal
, nVertical
;
634 ThreeDHelper::getRotationFromDiagram( this, nHorizontal
, nVertical
);
635 if( nHandle
== PROP_DIAGRAM_ROTATION_HORIZONTAL
)
636 nHorizontal
= nNewAngleDegree
;
638 nVertical
= nNewAngleDegree
;
639 ThreeDHelper::setRotationToDiagram( this, nHorizontal
, nVertical
);
643 ::property::OPropertySet::setFastPropertyValue( nHandle
, rValue
);
646 void SAL_CALL
Diagram::getFastPropertyValue( Any
& rValue
, sal_Int32 nHandle
) const
648 //special treatment for some 3D properties
649 if( nHandle
== PROP_DIAGRAM_PERSPECTIVE
)
651 sal_Int32 nPerspective
= ::basegfx::fround( ThreeDHelper::CameraDistanceToPerspective(
652 ThreeDHelper::getCameraDistance( const_cast< Diagram
* >( this ) ) ) );
653 rValue
<<= nPerspective
;
655 else if( nHandle
== PROP_DIAGRAM_ROTATION_HORIZONTAL
656 || nHandle
== PROP_DIAGRAM_ROTATION_VERTICAL
)
658 sal_Int32 nHorizontal
, nVertical
;
659 ThreeDHelper::getRotationFromDiagram( const_cast< Diagram
* >( this ), nHorizontal
, nVertical
);
660 sal_Int32 nAngleDegree
= 0;
661 if( nHandle
== PROP_DIAGRAM_ROTATION_HORIZONTAL
)
662 nAngleDegree
= nHorizontal
;
664 nAngleDegree
= nVertical
;
665 rValue
<<= nAngleDegree
;
668 ::property::OPropertySet::getFastPropertyValue( rValue
,nHandle
);
671 using impl::Diagram_Base
;
673 IMPLEMENT_FORWARD_XINTERFACE2( Diagram
, Diagram_Base
, ::property::OPropertySet
)
674 IMPLEMENT_FORWARD_XTYPEPROVIDER2( Diagram
, Diagram_Base
, ::property::OPropertySet
)
676 // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
677 OUString SAL_CALL
Diagram::getImplementationName()
679 return "com.sun.star.comp.chart2.Diagram";
682 sal_Bool SAL_CALL
Diagram::supportsService( const OUString
& rServiceName
)
684 return cppu::supportsService(this, rServiceName
);
687 css::uno::Sequence
< OUString
> SAL_CALL
Diagram::getSupportedServiceNames()
690 "com.sun.star.chart2.Diagram",
691 "com.sun.star.layout.LayoutElement",
692 "com.sun.star.beans.PropertySet" };
697 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
698 com_sun_star_comp_chart2_Diagram_get_implementation(css::uno::XComponentContext
*context
,
699 css::uno::Sequence
<css::uno::Any
> const &)
701 return cppu::acquire(new ::chart::Diagram(context
));
704 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */