xref: /core/chart2/source/model/main/Axis.cxx (revision 309ac64cf45e0d165a84e8526bf388697dba9ec5)
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
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 <AxisHelper.hxx>
27 #include <EventListenerHelper.hxx>
28 #include <ModifyListenerHelper.hxx>
29 #include <Title.hxx>
30 #include <unonames.hxx>
31 
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 <comphelper/diagnose_ex.hxx>
40 #include <rtl/ref.hxx>
41 
42 #include <vector>
43 #include <algorithm>
44 
45 using namespace ::com::sun::star;
46 using namespace ::com::sun::star::beans::PropertyAttribute;
47 
48 using ::com::sun::star::uno::Sequence;
49 using ::com::sun::star::uno::Reference;
50 using ::com::sun::star::beans::Property;
51 using ::osl::MutexGuard;
52 
53 namespace
54 {
55 
56 enum
57 {
58     PROP_AXIS_SHOW,
59     PROP_AXIS_CROSSOVER_POSITION,
60     PROP_AXIS_CROSSOVER_VALUE,
61     PROP_AXIS_DISPLAY_LABELS,
62     PROP_AXIS_NUMBERFORMAT,
63     PROP_AXIS_LINK_NUMBERFORMAT_TO_SOURCE,
64     PROP_AXIS_LABEL_POSITION,
65     PROP_AXIS_TEXT_ROTATION,
66     PROP_AXIS_TEXT_BREAK,
67     PROP_AXIS_TEXT_OVERLAP,
68     PROP_AXIS_TEXT_STACKED,
69     PROP_AXIS_TEXT_ARRANGE_ORDER,
70     PROP_AXIS_REFERENCE_DIAGRAM_SIZE,
71 
72     PROP_AXIS_MAJOR_TICKMARKS,
73     PROP_AXIS_MINOR_TICKMARKS,
74     PROP_AXIS_MARK_POSITION,
75 
76     PROP_AXIS_DISPLAY_UNITS,
77     PROP_AXIS_BUILTINUNIT,
78 
79     PROP_AXIS_TRY_STAGGERING_FIRST,
80     PROP_AXIS_MAJOR_ORIGIN
81 };
82 
lcl_AddPropertiesToVector(std::vector<Property> & rOutProperties)83 void lcl_AddPropertiesToVector(
84     std::vector< Property > & rOutProperties )
85 {
86     rOutProperties.emplace_back( "Show",
87                   PROP_AXIS_SHOW,
88                   cppu::UnoType<bool>::get(),
89                   beans::PropertyAttribute::BOUND
90                   | beans::PropertyAttribute::MAYBEDEFAULT );
91 
92     rOutProperties.emplace_back( "CrossoverPosition",
93                   PROP_AXIS_CROSSOVER_POSITION,
94                   cppu::UnoType<css::chart::ChartAxisPosition>::get(),
95                   beans::PropertyAttribute::MAYBEDEFAULT );
96 
97     rOutProperties.emplace_back( "CrossoverValue",
98                   PROP_AXIS_CROSSOVER_VALUE,
99                   cppu::UnoType<double>::get(),
100                   beans::PropertyAttribute::MAYBEVOID );
101 
102     rOutProperties.emplace_back( "DisplayLabels",
103                   PROP_AXIS_DISPLAY_LABELS,
104                   cppu::UnoType<bool>::get(),
105                   beans::PropertyAttribute::BOUND
106                   | beans::PropertyAttribute::MAYBEDEFAULT );
107 
108     rOutProperties.emplace_back( CHART_UNONAME_NUMFMT,
109                   PROP_AXIS_NUMBERFORMAT,
110                   cppu::UnoType<sal_Int32>::get(),
111                   beans::PropertyAttribute::BOUND
112                   | beans::PropertyAttribute::MAYBEDEFAULT );
113 
114     rOutProperties.emplace_back( CHART_UNONAME_LINK_TO_SRC_NUMFMT,
115                   PROP_AXIS_LINK_NUMBERFORMAT_TO_SOURCE,
116                   cppu::UnoType<bool>::get(),
117                   beans::PropertyAttribute::BOUND
118                   | beans::PropertyAttribute::MAYBEDEFAULT );
119 
120     rOutProperties.emplace_back( "LabelPosition",
121                   PROP_AXIS_LABEL_POSITION,
122                   cppu::UnoType<css::chart::ChartAxisLabelPosition>::get(),
123                   beans::PropertyAttribute::MAYBEDEFAULT );
124 
125     rOutProperties.emplace_back( "TextRotation",
126                   PROP_AXIS_TEXT_ROTATION,
127                   cppu::UnoType<double>::get(),
128                   beans::PropertyAttribute::BOUND
129                   | beans::PropertyAttribute::MAYBEDEFAULT );
130 
131     rOutProperties.emplace_back( "TextBreak",
132                   PROP_AXIS_TEXT_BREAK,
133                   cppu::UnoType<bool>::get(),
134                   beans::PropertyAttribute::BOUND
135                   | beans::PropertyAttribute::MAYBEDEFAULT );
136 
137     rOutProperties.emplace_back( "TextOverlap",
138                   PROP_AXIS_TEXT_OVERLAP,
139                   cppu::UnoType<bool>::get(),
140                   beans::PropertyAttribute::BOUND
141                   | beans::PropertyAttribute::MAYBEDEFAULT );
142 
143     rOutProperties.emplace_back( "StackCharacters",
144                   PROP_AXIS_TEXT_STACKED,
145                   cppu::UnoType<bool>::get(),
146                   beans::PropertyAttribute::BOUND
147                   | beans::PropertyAttribute::MAYBEDEFAULT );
148 
149     rOutProperties.emplace_back( "ArrangeOrder",
150                   PROP_AXIS_TEXT_ARRANGE_ORDER,
151                   cppu::UnoType<css::chart::ChartAxisArrangeOrderType>::get(),
152                   beans::PropertyAttribute::BOUND
153                   | beans::PropertyAttribute::MAYBEDEFAULT );
154 
155     rOutProperties.emplace_back( "ReferencePageSize",
156                   PROP_AXIS_REFERENCE_DIAGRAM_SIZE,
157                   cppu::UnoType<awt::Size>::get(),
158                   beans::PropertyAttribute::BOUND
159                   | beans::PropertyAttribute::MAYBEVOID );
160 
161     rOutProperties.emplace_back( "MajorTickmarks",
162                   PROP_AXIS_MAJOR_TICKMARKS,
163                   cppu::UnoType<sal_Int32>::get(),
164                   beans::PropertyAttribute::BOUND
165                   | beans::PropertyAttribute::MAYBEDEFAULT );
166 
167     rOutProperties.emplace_back( "MinorTickmarks",
168                   PROP_AXIS_MINOR_TICKMARKS,
169                   cppu::UnoType<sal_Int32>::get(),
170                   beans::PropertyAttribute::BOUND
171                   | beans::PropertyAttribute::MAYBEDEFAULT );
172 
173     rOutProperties.emplace_back( "MarkPosition",
174                   PROP_AXIS_MARK_POSITION,
175                   cppu::UnoType<css::chart::ChartAxisMarkPosition>::get(),
176                   beans::PropertyAttribute::MAYBEDEFAULT );
177 
178     //Properties for display units:
179     rOutProperties.emplace_back( "DisplayUnits",
180                   PROP_AXIS_DISPLAY_UNITS,
181                   cppu::UnoType<bool>::get(),
182                   beans::PropertyAttribute::BOUND
183                   | beans::PropertyAttribute::MAYBEDEFAULT );
184 
185     //Properties for labels:
186     rOutProperties.emplace_back( "BuiltInUnit",
187                   PROP_AXIS_BUILTINUNIT,
188                   cppu::UnoType<OUString>::get(),
189                   beans::PropertyAttribute::BOUND
190                   | beans::PropertyAttribute::MAYBEDEFAULT );
191 
192     // Compatibility option: starting from LibreOffice 5.1 the rotated
193     // layout is preferred to staggering for axis labels.
194     rOutProperties.emplace_back( "TryStaggeringFirst",
195                   PROP_AXIS_TRY_STAGGERING_FIRST,
196                   cppu::UnoType<bool>::get(),
197                   beans::PropertyAttribute::BOUND
198                   | beans::PropertyAttribute::MAYBEDEFAULT );
199 
200     rOutProperties.emplace_back( "MajorOrigin",
201                   PROP_AXIS_MAJOR_ORIGIN,
202                   cppu::UnoType<double>::get(),
203                   beans::PropertyAttribute::BOUND
204                   | beans::PropertyAttribute::MAYBEVOID );
205 
206 }
207 } // namespace
208 
209 namespace chart
210 {
StaticAxisDefaults()211 const ::chart::tPropertyValueMap &  StaticAxisDefaults()
212 {
213     static ::chart::tPropertyValueMap aStaticDefaults = []()
214         {
215             ::chart::tPropertyValueMap aMap;
216             ::chart::CharacterProperties::AddDefaultsToMap( aMap );
217             ::chart::LinePropertiesHelper::AddDefaultsToMap( aMap );
218 
219             ::chart::PropertyHelper::setPropertyValueDefault( aMap, PROP_AXIS_SHOW, true );
220             ::chart::PropertyHelper::setPropertyValueDefault( aMap, PROP_AXIS_CROSSOVER_POSITION, css::chart::ChartAxisPosition_ZERO );
221             ::chart::PropertyHelper::setPropertyValueDefault( aMap, PROP_AXIS_DISPLAY_LABELS, true );
222             ::chart::PropertyHelper::setPropertyValueDefault( aMap, PROP_AXIS_LINK_NUMBERFORMAT_TO_SOURCE, true );
223             ::chart::PropertyHelper::setPropertyValueDefault( aMap, PROP_AXIS_LABEL_POSITION, css::chart::ChartAxisLabelPosition_NEAR_AXIS );
224             ::chart::PropertyHelper::setPropertyValueDefault< double >( aMap, PROP_AXIS_TEXT_ROTATION, 0.0 );
225             ::chart::PropertyHelper::setPropertyValueDefault( aMap, PROP_AXIS_TEXT_BREAK, false );
226             ::chart::PropertyHelper::setPropertyValueDefault( aMap, PROP_AXIS_TEXT_OVERLAP, false );
227             ::chart::PropertyHelper::setPropertyValueDefault( aMap, PROP_AXIS_TEXT_STACKED, false );
228             ::chart::PropertyHelper::setPropertyValueDefault( aMap, PROP_AXIS_TEXT_ARRANGE_ORDER, css::chart::ChartAxisArrangeOrderType_AUTO );
229 
230             float fDefaultCharHeight = 10.0;
231             ::chart::PropertyHelper::setPropertyValue( aMap, ::chart::CharacterProperties::PROP_CHAR_CHAR_HEIGHT, fDefaultCharHeight );
232             ::chart::PropertyHelper::setPropertyValue( aMap, ::chart::CharacterProperties::PROP_CHAR_ASIAN_CHAR_HEIGHT, fDefaultCharHeight );
233             ::chart::PropertyHelper::setPropertyValue( aMap, ::chart::CharacterProperties::PROP_CHAR_COMPLEX_CHAR_HEIGHT, fDefaultCharHeight );
234 
235             ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( aMap, PROP_AXIS_MAJOR_TICKMARKS, 2 /* CHAXIS_MARK_OUTER */ );
236             ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( aMap, PROP_AXIS_MINOR_TICKMARKS, 0 /* CHAXIS_MARK_NONE */ );
237             ::chart::PropertyHelper::setPropertyValueDefault( aMap, PROP_AXIS_MARK_POSITION, css::chart::ChartAxisMarkPosition_AT_LABELS_AND_AXIS );
238             ::chart::PropertyHelper::setPropertyValueDefault( aMap, PROP_AXIS_DISPLAY_UNITS, false );
239             ::chart::PropertyHelper::setPropertyValueDefault( aMap, PROP_AXIS_TRY_STAGGERING_FIRST, false );
240             return aMap;
241         }();
242     return aStaticDefaults;
243 };
244 } // namespace chart
245 
246 namespace
247 {
StaticAxisInfoHelper()248 ::cppu::OPropertyArrayHelper& StaticAxisInfoHelper()
249 {
250     static ::cppu::OPropertyArrayHelper aPropHelper = []()
251         {
252             std::vector< css::beans::Property > aProperties;
253             lcl_AddPropertiesToVector( aProperties );
254             ::chart::CharacterProperties::AddPropertiesToVector( aProperties );
255             ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties );
256             ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
257 
258             std::sort( aProperties.begin(), aProperties.end(),
259                          ::chart::PropertyNameLess() );
260 
261             return comphelper::containerToSequence( aProperties );
262         }();
263     return aPropHelper;
264 };
265 
lcl_CloneSubGrids(const std::vector<rtl::Reference<::chart::GridProperties>> & rSource)266 std::vector< rtl::Reference< ::chart::GridProperties > > lcl_CloneSubGrids(
267     const std::vector< rtl::Reference< ::chart::GridProperties > > & rSource )
268 {
269     std::vector< rtl::Reference< ::chart::GridProperties > > aDestination;
270     aDestination.reserve( rSource.size());
271     for( rtl::Reference< ::chart::GridProperties > const & i : rSource )
272     {
273         aDestination.push_back(new ::chart::GridProperties(*i));
274     }
275     return aDestination;
276 }
277 
278 } // anonymous namespace
279 
280 namespace chart
281 {
282 
Axis()283 Axis::Axis() :
284         m_xModifyEventForwarder( new ModifyEventForwarder() ),
285         m_aScaleData( AxisHelper::createDefaultScale() ),
286         m_xGrid( new GridProperties() )
287 {
288     osl_atomic_increment(&m_refCount);
289     setFastPropertyValue_NoBroadcast(
290         ::chart::LinePropertiesHelper::PROP_LINE_COLOR, uno::Any( static_cast< sal_Int32 >( 0xb3b3b3 ) ) );  // gray30
291 
292     if( m_xGrid.is())
293         ModifyListenerHelper::addListener( m_xGrid, m_xModifyEventForwarder );
294     if( m_aScaleData.Categories.is())
295         ModifyListenerHelper::addListener( m_aScaleData.Categories, m_xModifyEventForwarder );
296 
297     AllocateSubGrids();
298     osl_atomic_decrement(&m_refCount);
299 }
300 
Axis(const Axis & rOther)301 Axis::Axis( const Axis & rOther ) :
302         impl::Axis_Base(rOther),
303         ::property::OPropertySet( rOther ),
304     m_xModifyEventForwarder( new ModifyEventForwarder() ),
305     m_aScaleData( rOther.m_aScaleData )
306 {
307     if (rOther.m_xGrid)
308         m_xGrid = new ::chart::GridProperties(*rOther.m_xGrid);
309     if( m_xGrid.is())
310         ModifyListenerHelper::addListener( m_xGrid, m_xModifyEventForwarder );
311 
312     if( m_aScaleData.Categories.is())
313         ModifyListenerHelper::addListener( m_aScaleData.Categories, m_xModifyEventForwarder );
314 
315     if( !rOther.m_aSubGridProperties.empty() )
316         m_aSubGridProperties = lcl_CloneSubGrids( rOther.m_aSubGridProperties );
317     ModifyListenerHelper::addListenerToAllElements( m_aSubGridProperties, m_xModifyEventForwarder );
318 
319     if ( rOther.m_xTitle )
320         m_xTitle = new Title( *rOther.m_xTitle );
321     if( m_xTitle.is())
322         ModifyListenerHelper::addListener( m_xTitle, m_xModifyEventForwarder );
323 }
324 
325 // late initialization to call after copy-constructing
Init()326 void Axis::Init()
327 {
328     if( m_aScaleData.Categories.is())
329         EventListenerHelper::addListener( m_aScaleData.Categories, this );
330 }
331 
~Axis()332 Axis::~Axis()
333 {
334     try
335     {
336         ModifyListenerHelper::removeListener( m_xGrid, m_xModifyEventForwarder );
337         ModifyListenerHelper::removeListenerFromAllElements( m_aSubGridProperties, m_xModifyEventForwarder );
338         ModifyListenerHelper::removeListener( m_xTitle, m_xModifyEventForwarder );
339         if( m_aScaleData.Categories.is())
340         {
341             ModifyListenerHelper::removeListener( m_aScaleData.Categories, m_xModifyEventForwarder );
342             m_aScaleData.Categories.clear();
343         }
344     }
345     catch( const uno::Exception & )
346     {
347         DBG_UNHANDLED_EXCEPTION("chart2");
348     }
349 
350     m_aSubGridProperties.clear();
351     m_xGrid = nullptr;
352     m_xTitle = nullptr;
353 }
354 
AllocateSubGrids()355 void Axis::AllocateSubGrids()
356 {
357     rtl::Reference< ModifyEventForwarder > xModifyEventForwarder;
358     Reference< lang::XEventListener > xEventListener;
359     std::vector< rtl::Reference< GridProperties > > aOldBroadcasters;
360     std::vector< rtl::Reference< GridProperties > > aNewBroadcasters;
361     {
362         MutexGuard aGuard( m_aMutex );
363         xModifyEventForwarder = m_xModifyEventForwarder;
364         xEventListener = this;
365 
366         sal_Int32 nNewSubIncCount = m_aScaleData.IncrementData.SubIncrements.getLength();
367         sal_Int32 nOldSubIncCount = m_aSubGridProperties.size();
368 
369         if( nOldSubIncCount > nNewSubIncCount )
370         {
371             // remove superfluous entries
372             for( sal_Int32 i = nNewSubIncCount; i < nOldSubIncCount; ++i )
373                 aOldBroadcasters.push_back( m_aSubGridProperties[ i ] );
374             m_aSubGridProperties.resize( nNewSubIncCount );
375         }
376         else if( nOldSubIncCount < nNewSubIncCount )
377         {
378             m_aSubGridProperties.resize( nNewSubIncCount );
379 
380             // allocate new entries
381             for( sal_Int32 i = nOldSubIncCount; i < nNewSubIncCount; ++i )
382             {
383                 m_aSubGridProperties[ i ] = new GridProperties();
384                 LinePropertiesHelper::SetLineInvisible( m_aSubGridProperties[ i ] );
385                 LinePropertiesHelper::SetLineColor( m_aSubGridProperties[ i ], static_cast<sal_Int32>(0xdddddd) ); //gray2
386                 aNewBroadcasters.push_back( m_aSubGridProperties[ i ] );
387             }
388         }
389     }
390     //don't keep the mutex locked while calling out
391     for (auto const& oldBroadcaster : aOldBroadcasters)
392         ModifyListenerHelper::removeListener(oldBroadcaster, xModifyEventForwarder );
393     for (auto const& newBroadcaster : aNewBroadcasters)
394         ModifyListenerHelper::addListener( newBroadcaster, xModifyEventForwarder );
395 }
396 
397 // ____ XAxis ____
setScaleData(const chart2::ScaleData & rScaleData)398 void SAL_CALL Axis::setScaleData( const chart2::ScaleData& rScaleData )
399 {
400     rtl::Reference< ModifyEventForwarder > xModifyEventForwarder;
401     Reference< lang::XEventListener > xEventListener;
402     Reference< chart2::data::XLabeledDataSequence > xOldCategories;
403     Reference< chart2::data::XLabeledDataSequence > xNewCategories = rScaleData.Categories;
404     {
405         MutexGuard aGuard( m_aMutex );
406         xModifyEventForwarder = m_xModifyEventForwarder;
407         xEventListener = this;
408         xOldCategories = m_aScaleData.Categories;
409         m_aScaleData = rScaleData;
410     }
411     AllocateSubGrids();
412 
413     //don't keep the mutex locked while calling out
414     if( xOldCategories.is() && xOldCategories != xNewCategories )
415     {
416         ModifyListenerHelper::removeListener( xOldCategories, xModifyEventForwarder );
417         EventListenerHelper::removeListener( xOldCategories, xEventListener );
418     }
419     if( xNewCategories.is() && xOldCategories != xNewCategories )
420     {
421         ModifyListenerHelper::addListener( xNewCategories, m_xModifyEventForwarder );
422         EventListenerHelper::addListener( xNewCategories, xEventListener );
423     }
424     fireModifyEvent();
425 }
426 
getScaleData()427 chart2::ScaleData SAL_CALL Axis::getScaleData()
428 {
429     MutexGuard aGuard( m_aMutex );
430     return m_aScaleData;
431 }
432 
getGridProperties()433 Reference< beans::XPropertySet > SAL_CALL Axis::getGridProperties()
434 {
435     MutexGuard aGuard( m_aMutex );
436     return m_xGrid;
437 }
getGridProperties2()438 rtl::Reference< ::chart::GridProperties > Axis::getGridProperties2()
439 {
440     MutexGuard aGuard( m_aMutex );
441     return m_xGrid;
442 }
getSubGridProperties()443 Sequence< Reference< beans::XPropertySet > > SAL_CALL Axis::getSubGridProperties()
444 {
445     MutexGuard aGuard( m_aMutex );
446     return comphelper::containerToSequence<Reference< beans::XPropertySet >>(m_aSubGridProperties);
447 }
448 
getSubGridProperties2()449 std::vector< rtl::Reference< GridProperties > > Axis::getSubGridProperties2()
450 {
451     MutexGuard aGuard( m_aMutex );
452     return m_aSubGridProperties;
453 }
454 
getSubTickProperties()455 Sequence< Reference< beans::XPropertySet > > SAL_CALL Axis::getSubTickProperties()
456 {
457     OSL_FAIL( "Not implemented yet" );
458     return Sequence< Reference< beans::XPropertySet > >();
459 }
460 
461 // ____ XTitled ____
getTitleObject()462 Reference< chart2::XTitle > SAL_CALL Axis::getTitleObject()
463 {
464     MutexGuard aGuard( m_aMutex );
465     return m_xTitle;
466 }
467 
getTitleObject2() const468 rtl::Reference< Title > Axis::getTitleObject2() const
469 {
470     MutexGuard aGuard( m_aMutex );
471     return m_xTitle;
472 }
473 
setTitleObject(const Reference<chart2::XTitle> & xNewTitle)474 void SAL_CALL Axis::setTitleObject( const Reference< chart2::XTitle >& xNewTitle )
475 {
476     rtl::Reference<Title> xTitle = dynamic_cast<Title*>(xNewTitle.get());
477     assert(!xNewTitle || xTitle);
478     setTitleObject(xTitle);
479 }
480 
setTitleObject(const rtl::Reference<Title> & xNewTitle)481 void Axis::setTitleObject( const rtl::Reference< Title >& xNewTitle )
482 {
483     rtl::Reference< ModifyEventForwarder > xModifyEventForwarder;
484     rtl::Reference< Title > xOldTitle;
485     {
486         MutexGuard aGuard( m_aMutex );
487         xOldTitle = m_xTitle;
488         xModifyEventForwarder = m_xModifyEventForwarder;
489         m_xTitle = xNewTitle;
490     }
491 
492     //don't keep the mutex locked while calling out
493     if( xOldTitle.is() && xOldTitle != xNewTitle )
494         ModifyListenerHelper::removeListener( xOldTitle, xModifyEventForwarder );
495     if( xNewTitle.is() && xOldTitle != xNewTitle )
496         ModifyListenerHelper::addListener( xNewTitle, xModifyEventForwarder );
497     fireModifyEvent();
498 }
499 
500 // ____ XCloneable ____
createClone()501 Reference< util::XCloneable > SAL_CALL Axis::createClone()
502 {
503     rtl::Reference<Axis> pNewAxis( new Axis( *this ));
504     // do initialization that uses uno references to the clone
505     pNewAxis->Init();
506     return pNewAxis;
507 }
508 
509 // ____ XModifyBroadcaster ____
addModifyListener(const Reference<util::XModifyListener> & aListener)510 void SAL_CALL Axis::addModifyListener( const Reference< util::XModifyListener >& aListener )
511 {
512     m_xModifyEventForwarder->addModifyListener( aListener );
513 }
514 
removeModifyListener(const Reference<util::XModifyListener> & aListener)515 void SAL_CALL Axis::removeModifyListener( const Reference< util::XModifyListener >& aListener )
516 {
517     m_xModifyEventForwarder->removeModifyListener( aListener );
518 }
519 
520 // ____ XModifyListener ____
modified(const lang::EventObject & aEvent)521 void SAL_CALL Axis::modified( const lang::EventObject& aEvent )
522 {
523     m_xModifyEventForwarder->modified( aEvent );
524 }
525 
526 // ____ XEventListener (base of XModifyListener) ____
disposing(const lang::EventObject & Source)527 void SAL_CALL Axis::disposing( const lang::EventObject& Source )
528 {
529     if( Source.Source == m_aScaleData.Categories )
530         m_aScaleData.Categories = nullptr;
531 }
532 
533 // ____ OPropertySet ____
firePropertyChangeEvent()534 void Axis::firePropertyChangeEvent()
535 {
536     fireModifyEvent();
537 }
538 
fireModifyEvent()539 void Axis::fireModifyEvent()
540 {
541     m_xModifyEventForwarder->modified( lang::EventObject( static_cast< uno::XWeak* >( this )));
542 }
543 
544 // ____ OPropertySet ____
GetDefaultValue(sal_Int32 nHandle,uno::Any & rAny) const545 void Axis::GetDefaultValue( sal_Int32 nHandle, uno::Any& rAny ) const
546 {
547     const tPropertyValueMap& rStaticDefaults = StaticAxisDefaults();
548     tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
549     if( aFound == rStaticDefaults.end() )
550         rAny.clear();
551     else
552         rAny = (*aFound).second;
553 }
554 
getInfoHelper()555 ::cppu::IPropertyArrayHelper & SAL_CALL Axis::getInfoHelper()
556 {
557     return StaticAxisInfoHelper();
558 }
559 
560 // ____ XPropertySet ____
getPropertySetInfo()561 Reference< beans::XPropertySetInfo > SAL_CALL Axis::getPropertySetInfo()
562 {
563     static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
564         ::cppu::OPropertySetHelper::createPropertySetInfo(StaticAxisInfoHelper() ) );
565     return xPropertySetInfo;
566 }
567 
568 using impl::Axis_Base;
569 
IMPLEMENT_FORWARD_XINTERFACE2(Axis,Axis_Base,::property::OPropertySet)570 IMPLEMENT_FORWARD_XINTERFACE2( Axis, Axis_Base, ::property::OPropertySet )
571 IMPLEMENT_FORWARD_XTYPEPROVIDER2( Axis, Axis_Base, ::property::OPropertySet )
572 
573 // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
574 OUString SAL_CALL Axis::getImplementationName()
575 {
576     return u"com.sun.star.comp.chart2.Axis"_ustr;
577 }
578 
supportsService(const OUString & rServiceName)579 sal_Bool SAL_CALL Axis::supportsService( const OUString& rServiceName )
580 {
581     return cppu::supportsService(this, rServiceName);
582 }
583 
getSupportedServiceNames()584 css::uno::Sequence< OUString > SAL_CALL Axis::getSupportedServiceNames()
585 {
586     return {
587         u"com.sun.star.chart2.Axis"_ustr,
588         u"com.sun.star.beans.PropertySet"_ustr };
589 }
590 
591 } //  namespace chart
592 
593 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
com_sun_star_comp_chart2_Axis_get_implementation(css::uno::XComponentContext *,css::uno::Sequence<css::uno::Any> const &)594 com_sun_star_comp_chart2_Axis_get_implementation(css::uno::XComponentContext *,
595         css::uno::Sequence<css::uno::Any> const &)
596 {
597     return cppu::acquire(new ::chart::Axis);
598 }
599 
600 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
601