nss: upgrade to release 3.73
[LibreOffice.git] / chart2 / source / model / main / Axis.cxx
blobff42899d0c18b1cefb8db5581cf80e1aab9f4d1b
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 "Axis.hxx"
21 #include "GridProperties.hxx"
22 #include <CharacterProperties.hxx>
23 #include <LinePropertiesHelper.hxx>
24 #include <UserDefinedProperties.hxx>
25 #include <PropertyHelper.hxx>
26 #include <CloneHelper.hxx>
27 #include <AxisHelper.hxx>
28 #include <EventListenerHelper.hxx>
29 #include <ModifyListenerHelper.hxx>
30 #include <unonames.hxx>
32 #include <com/sun/star/chart/ChartAxisArrangeOrderType.hpp>
33 #include <com/sun/star/chart/ChartAxisLabelPosition.hpp>
34 #include <com/sun/star/chart/ChartAxisMarkPosition.hpp>
35 #include <com/sun/star/chart/ChartAxisPosition.hpp>
36 #include <com/sun/star/beans/PropertyAttribute.hpp>
37 #include <com/sun/star/awt/Size.hpp>
38 #include <cppuhelper/supportsservice.hxx>
39 #include <tools/diagnose_ex.h>
41 #include <vector>
42 #include <algorithm>
44 using namespace ::com::sun::star;
45 using namespace ::com::sun::star::beans::PropertyAttribute;
47 using ::com::sun::star::uno::Sequence;
48 using ::com::sun::star::uno::Reference;
49 using ::com::sun::star::beans::Property;
50 using ::osl::MutexGuard;
52 namespace
55 enum
57 PROP_AXIS_SHOW,
58 PROP_AXIS_CROSSOVER_POSITION,
59 PROP_AXIS_CROSSOVER_VALUE,
60 PROP_AXIS_DISPLAY_LABELS,
61 PROP_AXIS_NUMBERFORMAT,
62 PROP_AXIS_LINK_NUMBERFORMAT_TO_SOURCE,
63 PROP_AXIS_LABEL_POSITION,
64 PROP_AXIS_TEXT_ROTATION,
65 PROP_AXIS_TEXT_BREAK,
66 PROP_AXIS_TEXT_OVERLAP,
67 PROP_AXIS_TEXT_STACKED,
68 PROP_AXIS_TEXT_ARRANGE_ORDER,
69 PROP_AXIS_REFERENCE_DIAGRAM_SIZE,
71 PROP_AXIS_MAJOR_TICKMARKS,
72 PROP_AXIS_MINOR_TICKMARKS,
73 PROP_AXIS_MARK_POSITION,
75 PROP_AXIS_DISPLAY_UNITS,
76 PROP_AXIS_BUILTINUNIT,
78 PROP_AXIS_TRY_STAGGERING_FIRST,
79 PROP_AXIS_MAJOR_ORIGIN
82 void lcl_AddPropertiesToVector(
83 std::vector< Property > & rOutProperties )
85 rOutProperties.emplace_back( "Show",
86 PROP_AXIS_SHOW,
87 cppu::UnoType<bool>::get(),
88 beans::PropertyAttribute::BOUND
89 | beans::PropertyAttribute::MAYBEDEFAULT );
91 rOutProperties.emplace_back( "CrossoverPosition",
92 PROP_AXIS_CROSSOVER_POSITION,
93 cppu::UnoType<css::chart::ChartAxisPosition>::get(),
94 beans::PropertyAttribute::MAYBEDEFAULT );
96 rOutProperties.emplace_back( "CrossoverValue",
97 PROP_AXIS_CROSSOVER_VALUE,
98 cppu::UnoType<double>::get(),
99 beans::PropertyAttribute::MAYBEVOID );
101 rOutProperties.emplace_back( "DisplayLabels",
102 PROP_AXIS_DISPLAY_LABELS,
103 cppu::UnoType<bool>::get(),
104 beans::PropertyAttribute::BOUND
105 | beans::PropertyAttribute::MAYBEDEFAULT );
107 rOutProperties.emplace_back( CHART_UNONAME_NUMFMT,
108 PROP_AXIS_NUMBERFORMAT,
109 cppu::UnoType<sal_Int32>::get(),
110 beans::PropertyAttribute::BOUND
111 | beans::PropertyAttribute::MAYBEDEFAULT );
113 rOutProperties.emplace_back( CHART_UNONAME_LINK_TO_SRC_NUMFMT,
114 PROP_AXIS_LINK_NUMBERFORMAT_TO_SOURCE,
115 cppu::UnoType<bool>::get(),
116 beans::PropertyAttribute::BOUND
117 | beans::PropertyAttribute::MAYBEDEFAULT );
119 rOutProperties.emplace_back( "LabelPosition",
120 PROP_AXIS_LABEL_POSITION,
121 cppu::UnoType<css::chart::ChartAxisLabelPosition>::get(),
122 beans::PropertyAttribute::MAYBEDEFAULT );
124 rOutProperties.emplace_back( "TextRotation",
125 PROP_AXIS_TEXT_ROTATION,
126 cppu::UnoType<double>::get(),
127 beans::PropertyAttribute::BOUND
128 | beans::PropertyAttribute::MAYBEDEFAULT );
130 rOutProperties.emplace_back( "TextBreak",
131 PROP_AXIS_TEXT_BREAK,
132 cppu::UnoType<bool>::get(),
133 beans::PropertyAttribute::BOUND
134 | beans::PropertyAttribute::MAYBEDEFAULT );
136 rOutProperties.emplace_back( "TextOverlap",
137 PROP_AXIS_TEXT_OVERLAP,
138 cppu::UnoType<bool>::get(),
139 beans::PropertyAttribute::BOUND
140 | beans::PropertyAttribute::MAYBEDEFAULT );
142 rOutProperties.emplace_back( "StackCharacters",
143 PROP_AXIS_TEXT_STACKED,
144 cppu::UnoType<bool>::get(),
145 beans::PropertyAttribute::BOUND
146 | beans::PropertyAttribute::MAYBEDEFAULT );
148 rOutProperties.emplace_back( "ArrangeOrder",
149 PROP_AXIS_TEXT_ARRANGE_ORDER,
150 cppu::UnoType<css::chart::ChartAxisArrangeOrderType>::get(),
151 beans::PropertyAttribute::BOUND
152 | beans::PropertyAttribute::MAYBEDEFAULT );
154 rOutProperties.emplace_back( "ReferencePageSize",
155 PROP_AXIS_REFERENCE_DIAGRAM_SIZE,
156 cppu::UnoType<awt::Size>::get(),
157 beans::PropertyAttribute::BOUND
158 | beans::PropertyAttribute::MAYBEVOID );
160 rOutProperties.emplace_back( "MajorTickmarks",
161 PROP_AXIS_MAJOR_TICKMARKS,
162 cppu::UnoType<sal_Int32>::get(),
163 beans::PropertyAttribute::BOUND
164 | beans::PropertyAttribute::MAYBEDEFAULT );
166 rOutProperties.emplace_back( "MinorTickmarks",
167 PROP_AXIS_MINOR_TICKMARKS,
168 cppu::UnoType<sal_Int32>::get(),
169 beans::PropertyAttribute::BOUND
170 | beans::PropertyAttribute::MAYBEDEFAULT );
172 rOutProperties.emplace_back( "MarkPosition",
173 PROP_AXIS_MARK_POSITION,
174 cppu::UnoType<css::chart::ChartAxisMarkPosition>::get(),
175 beans::PropertyAttribute::MAYBEDEFAULT );
177 //Properties for display units:
178 rOutProperties.emplace_back( "DisplayUnits",
179 PROP_AXIS_DISPLAY_UNITS,
180 cppu::UnoType<bool>::get(),
181 beans::PropertyAttribute::BOUND
182 | beans::PropertyAttribute::MAYBEDEFAULT );
184 //Properties for labels:
185 rOutProperties.emplace_back( "BuiltInUnit",
186 PROP_AXIS_BUILTINUNIT,
187 cppu::UnoType<OUString>::get(),
188 beans::PropertyAttribute::BOUND
189 | beans::PropertyAttribute::MAYBEDEFAULT );
191 // Compatibility option: starting from LibreOffice 5.1 the rotated
192 // layout is preferred to staggering for axis labels.
193 rOutProperties.emplace_back( "TryStaggeringFirst",
194 PROP_AXIS_TRY_STAGGERING_FIRST,
195 cppu::UnoType<bool>::get(),
196 beans::PropertyAttribute::BOUND
197 | beans::PropertyAttribute::MAYBEDEFAULT );
199 rOutProperties.emplace_back( "MajorOrigin",
200 PROP_AXIS_MAJOR_ORIGIN,
201 cppu::UnoType<double>::get(),
202 beans::PropertyAttribute::BOUND
203 | beans::PropertyAttribute::MAYBEVOID );
207 struct StaticAxisDefaults_Initializer
209 ::chart::tPropertyValueMap* operator()()
211 static ::chart::tPropertyValueMap aStaticDefaults;
212 lcl_AddDefaultsToMap( aStaticDefaults );
213 return &aStaticDefaults;
215 private:
216 static void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap )
218 ::chart::CharacterProperties::AddDefaultsToMap( rOutMap );
219 ::chart::LinePropertiesHelper::AddDefaultsToMap( rOutMap );
221 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_SHOW, true );
222 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_CROSSOVER_POSITION, css::chart::ChartAxisPosition_ZERO );
223 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_DISPLAY_LABELS, true );
224 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_LINK_NUMBERFORMAT_TO_SOURCE, true );
225 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_LABEL_POSITION, css::chart::ChartAxisLabelPosition_NEAR_AXIS );
226 ::chart::PropertyHelper::setPropertyValueDefault< double >( rOutMap, PROP_AXIS_TEXT_ROTATION, 0.0 );
227 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_TEXT_BREAK, false );
228 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_TEXT_OVERLAP, false );
229 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_TEXT_STACKED, false );
230 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_TEXT_ARRANGE_ORDER, css::chart::ChartAxisArrangeOrderType_AUTO );
232 float fDefaultCharHeight = 10.0;
233 ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::CharacterProperties::PROP_CHAR_CHAR_HEIGHT, fDefaultCharHeight );
234 ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::CharacterProperties::PROP_CHAR_ASIAN_CHAR_HEIGHT, fDefaultCharHeight );
235 ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::CharacterProperties::PROP_CHAR_COMPLEX_CHAR_HEIGHT, fDefaultCharHeight );
237 ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_AXIS_MAJOR_TICKMARKS, 2 /* CHAXIS_MARK_OUTER */ );
238 ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_AXIS_MINOR_TICKMARKS, 0 /* CHAXIS_MARK_NONE */ );
239 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_MARK_POSITION, css::chart::ChartAxisMarkPosition_AT_LABELS_AND_AXIS );
240 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_DISPLAY_UNITS, false );
241 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_TRY_STAGGERING_FIRST, false );
245 struct StaticAxisDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticAxisDefaults_Initializer >
249 struct StaticAxisInfoHelper_Initializer
251 ::cppu::OPropertyArrayHelper* operator()()
253 static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
254 return &aPropHelper;
257 private:
258 static Sequence< Property > lcl_GetPropertySequence()
260 std::vector< css::beans::Property > aProperties;
261 lcl_AddPropertiesToVector( aProperties );
262 ::chart::CharacterProperties::AddPropertiesToVector( aProperties );
263 ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties );
264 ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
266 std::sort( aProperties.begin(), aProperties.end(),
267 ::chart::PropertyNameLess() );
269 return comphelper::containerToSequence( aProperties );
273 struct StaticAxisInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticAxisInfoHelper_Initializer >
277 struct StaticAxisInfo_Initializer
279 uno::Reference< beans::XPropertySetInfo >* operator()()
281 static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
282 ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticAxisInfoHelper::get() ) );
283 return &xPropertySetInfo;
287 struct StaticAxisInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticAxisInfo_Initializer >
291 typedef uno::Reference< beans::XPropertySet > lcl_tSubGridType;
293 void lcl_CloneSubGrids(
294 const uno::Sequence< lcl_tSubGridType > & rSource, uno::Sequence< lcl_tSubGridType > & rDestination )
296 rDestination.realloc( rSource.getLength());
297 lcl_tSubGridType * pDestBegin = rDestination.getArray();
298 lcl_tSubGridType * pDestEnd = pDestBegin + rDestination.getLength();
299 lcl_tSubGridType * pDestIt = pDestBegin;
301 for( Reference< beans::XPropertySet > const & i : rSource )
303 Reference< beans::XPropertySet > xSubGrid( i );
304 if( xSubGrid.is())
306 Reference< util::XCloneable > xCloneable( xSubGrid, uno::UNO_QUERY );
307 if( xCloneable.is())
308 xSubGrid.set( xCloneable->createClone(), uno::UNO_QUERY );
311 (*pDestIt) = xSubGrid;
312 OSL_ASSERT( pDestIt != pDestEnd );
313 ++pDestIt;
315 OSL_ASSERT( pDestIt == pDestEnd );
318 } // anonymous namespace
320 namespace chart
323 Axis::Axis() :
324 ::property::OPropertySet( m_aMutex ),
325 m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder()),
326 m_aScaleData( AxisHelper::createDefaultScale() ),
327 m_xGrid( new GridProperties() ),
328 m_aSubGridProperties(),
329 m_xTitle()
331 osl_atomic_increment(&m_refCount);
332 setFastPropertyValue_NoBroadcast(
333 ::chart::LinePropertiesHelper::PROP_LINE_COLOR, uno::Any( static_cast< sal_Int32 >( 0xb3b3b3 ) ) ); // gray30
335 if( m_xGrid.is())
336 ModifyListenerHelper::addListener( m_xGrid, m_xModifyEventForwarder );
337 if( m_aScaleData.Categories.is())
338 ModifyListenerHelper::addListener( m_aScaleData.Categories, m_xModifyEventForwarder );
340 AllocateSubGrids();
341 osl_atomic_decrement(&m_refCount);
344 Axis::Axis( const Axis & rOther ) :
345 impl::Axis_Base(rOther),
346 ::property::OPropertySet( rOther, m_aMutex ),
347 m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder()),
348 m_aScaleData( rOther.m_aScaleData )
350 m_xGrid.set( CloneHelper::CreateRefClone< beans::XPropertySet >()( rOther.m_xGrid ));
351 if( m_xGrid.is())
352 ModifyListenerHelper::addListener( m_xGrid, m_xModifyEventForwarder );
354 if( m_aScaleData.Categories.is())
355 ModifyListenerHelper::addListener( m_aScaleData.Categories, m_xModifyEventForwarder );
357 if( rOther.m_aSubGridProperties.hasElements() )
358 lcl_CloneSubGrids( rOther.m_aSubGridProperties, m_aSubGridProperties );
359 ModifyListenerHelper::addListenerToAllSequenceElements( m_aSubGridProperties, m_xModifyEventForwarder );
361 m_xTitle.set( CloneHelper::CreateRefClone< chart2::XTitle >()( rOther.m_xTitle ));
362 if( m_xTitle.is())
363 ModifyListenerHelper::addListener( m_xTitle, m_xModifyEventForwarder );
366 // late initialization to call after copy-constructing
367 void Axis::Init()
369 if( m_aScaleData.Categories.is())
370 EventListenerHelper::addListener( m_aScaleData.Categories, this );
373 Axis::~Axis()
377 ModifyListenerHelper::removeListener( m_xGrid, m_xModifyEventForwarder );
378 ModifyListenerHelper::removeListenerFromAllSequenceElements( m_aSubGridProperties, m_xModifyEventForwarder );
379 ModifyListenerHelper::removeListener( m_xTitle, m_xModifyEventForwarder );
380 if( m_aScaleData.Categories.is())
382 ModifyListenerHelper::removeListener( m_aScaleData.Categories, m_xModifyEventForwarder );
383 m_aScaleData.Categories.set(nullptr);
386 catch( const uno::Exception & )
388 DBG_UNHANDLED_EXCEPTION("chart2");
391 m_aSubGridProperties.realloc(0);
392 m_xGrid = nullptr;
393 m_xTitle = nullptr;
396 void Axis::AllocateSubGrids()
398 Reference< util::XModifyListener > xModifyEventForwarder;
399 Reference< lang::XEventListener > xEventListener;
400 std::vector< Reference< beans::XPropertySet > > aOldBroadcasters;
401 std::vector< Reference< beans::XPropertySet > > aNewBroadcasters;
403 MutexGuard aGuard( m_aMutex );
404 xModifyEventForwarder = m_xModifyEventForwarder;
405 xEventListener = this;
407 sal_Int32 nNewSubIncCount = m_aScaleData.IncrementData.SubIncrements.getLength();
408 sal_Int32 nOldSubIncCount = m_aSubGridProperties.getLength();
410 if( nOldSubIncCount > nNewSubIncCount )
412 // remove superfluous entries
413 for( sal_Int32 i = nNewSubIncCount; i < nOldSubIncCount; ++i )
414 aOldBroadcasters.push_back( m_aSubGridProperties[ i ] );
415 m_aSubGridProperties.realloc( nNewSubIncCount );
417 else if( nOldSubIncCount < nNewSubIncCount )
419 m_aSubGridProperties.realloc( nNewSubIncCount );
421 // allocate new entries
422 for( sal_Int32 i = nOldSubIncCount; i < nNewSubIncCount; ++i )
424 m_aSubGridProperties[ i ] = new GridProperties();
425 LinePropertiesHelper::SetLineInvisible( m_aSubGridProperties[ i ] );
426 LinePropertiesHelper::SetLineColor( m_aSubGridProperties[ i ], static_cast<sal_Int32>(0xdddddd) ); //gray2
427 aNewBroadcasters.push_back( m_aSubGridProperties[ i ] );
431 //don't keep the mutex locked while calling out
432 for (auto const& oldBroadcaster : aOldBroadcasters)
433 ModifyListenerHelper::removeListener(oldBroadcaster, xModifyEventForwarder );
434 for (auto const& newBroadcaster : aNewBroadcasters)
435 ModifyListenerHelper::addListener( newBroadcaster, xModifyEventForwarder );
438 // ____ XAxis ____
439 void SAL_CALL Axis::setScaleData( const chart2::ScaleData& rScaleData )
441 Reference< util::XModifyListener > xModifyEventForwarder;
442 Reference< lang::XEventListener > xEventListener;
443 Reference< chart2::data::XLabeledDataSequence > xOldCategories;
444 Reference< chart2::data::XLabeledDataSequence > xNewCategories = rScaleData.Categories;
446 MutexGuard aGuard( m_aMutex );
447 xModifyEventForwarder = m_xModifyEventForwarder;
448 xEventListener = this;
449 xOldCategories = m_aScaleData.Categories;
450 m_aScaleData = rScaleData;
452 AllocateSubGrids();
454 //don't keep the mutex locked while calling out
455 if( xOldCategories.is() && xOldCategories != xNewCategories )
457 ModifyListenerHelper::removeListener( xOldCategories, xModifyEventForwarder );
458 EventListenerHelper::removeListener( xOldCategories, xEventListener );
460 if( xNewCategories.is() && xOldCategories != xNewCategories )
462 ModifyListenerHelper::addListener( xNewCategories, m_xModifyEventForwarder );
463 EventListenerHelper::addListener( xNewCategories, xEventListener );
465 fireModifyEvent();
468 chart2::ScaleData SAL_CALL Axis::getScaleData()
470 MutexGuard aGuard( m_aMutex );
471 return m_aScaleData;
474 Reference< beans::XPropertySet > SAL_CALL Axis::getGridProperties()
476 MutexGuard aGuard( m_aMutex );
477 return m_xGrid;
479 Sequence< Reference< beans::XPropertySet > > SAL_CALL Axis::getSubGridProperties()
481 MutexGuard aGuard( m_aMutex );
482 return m_aSubGridProperties;
485 Sequence< Reference< beans::XPropertySet > > SAL_CALL Axis::getSubTickProperties()
487 OSL_FAIL( "Not implemented yet" );
488 return Sequence< Reference< beans::XPropertySet > >();
491 // ____ XTitled ____
492 Reference< chart2::XTitle > SAL_CALL Axis::getTitleObject()
494 MutexGuard aGuard( m_aMutex );
495 return m_xTitle;
498 void SAL_CALL Axis::setTitleObject( const Reference< chart2::XTitle >& xNewTitle )
500 Reference< util::XModifyListener > xModifyEventForwarder;
501 Reference< chart2::XTitle > xOldTitle;
503 MutexGuard aGuard( m_aMutex );
504 xOldTitle = m_xTitle;
505 xModifyEventForwarder = m_xModifyEventForwarder;
506 m_xTitle = xNewTitle;
509 //don't keep the mutex locked while calling out
510 if( xOldTitle.is() && xOldTitle != xNewTitle )
511 ModifyListenerHelper::removeListener( xOldTitle, xModifyEventForwarder );
512 if( xNewTitle.is() && xOldTitle != xNewTitle )
513 ModifyListenerHelper::addListener( xNewTitle, xModifyEventForwarder );
514 fireModifyEvent();
517 // ____ XCloneable ____
518 Reference< util::XCloneable > SAL_CALL Axis::createClone()
520 Axis * pNewAxis( new Axis( *this ));
521 // hold a reference to the clone
522 Reference< util::XCloneable > xResult( pNewAxis );
523 // do initialization that uses uno references to the clone
524 pNewAxis->Init();
525 return xResult;
528 // ____ XModifyBroadcaster ____
529 void SAL_CALL Axis::addModifyListener( const Reference< util::XModifyListener >& aListener )
533 Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
534 xBroadcaster->addModifyListener( aListener );
536 catch( const uno::Exception &)
538 DBG_UNHANDLED_EXCEPTION("chart2");
542 void SAL_CALL Axis::removeModifyListener( const Reference< util::XModifyListener >& aListener )
546 Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
547 xBroadcaster->removeModifyListener( aListener );
549 catch( const uno::Exception & )
551 DBG_UNHANDLED_EXCEPTION("chart2");
555 // ____ XModifyListener ____
556 void SAL_CALL Axis::modified( const lang::EventObject& aEvent )
558 m_xModifyEventForwarder->modified( aEvent );
561 // ____ XEventListener (base of XModifyListener) ____
562 void SAL_CALL Axis::disposing( const lang::EventObject& Source )
564 if( Source.Source == m_aScaleData.Categories )
565 m_aScaleData.Categories = nullptr;
568 // ____ OPropertySet ____
569 void Axis::firePropertyChangeEvent()
571 fireModifyEvent();
574 void Axis::fireModifyEvent()
576 m_xModifyEventForwarder->modified( lang::EventObject( static_cast< uno::XWeak* >( this )));
579 // ____ OPropertySet ____
580 uno::Any Axis::GetDefaultValue( sal_Int32 nHandle ) const
582 const tPropertyValueMap& rStaticDefaults = *StaticAxisDefaults::get();
583 tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
584 if( aFound == rStaticDefaults.end() )
585 return uno::Any();
586 return (*aFound).second;
589 ::cppu::IPropertyArrayHelper & SAL_CALL Axis::getInfoHelper()
591 return *StaticAxisInfoHelper::get();
594 // ____ XPropertySet ____
595 Reference< beans::XPropertySetInfo > SAL_CALL Axis::getPropertySetInfo()
597 return *StaticAxisInfo::get();
600 using impl::Axis_Base;
602 IMPLEMENT_FORWARD_XINTERFACE2( Axis, Axis_Base, ::property::OPropertySet )
603 IMPLEMENT_FORWARD_XTYPEPROVIDER2( Axis, Axis_Base, ::property::OPropertySet )
605 // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
606 OUString SAL_CALL Axis::getImplementationName()
608 return "com.sun.star.comp.chart2.Axis";
611 sal_Bool SAL_CALL Axis::supportsService( const OUString& rServiceName )
613 return cppu::supportsService(this, rServiceName);
616 css::uno::Sequence< OUString > SAL_CALL Axis::getSupportedServiceNames()
618 return {
619 "com.sun.star.chart2.Axis",
620 "com.sun.star.beans.PropertySet" };
623 } // namespace chart
625 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
626 com_sun_star_comp_chart2_Axis_get_implementation(css::uno::XComponentContext *,
627 css::uno::Sequence<css::uno::Any> const &)
629 return cppu::acquire(new ::chart::Axis);
632 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */