1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_chartmodel.hxx"
26 #include "Axis.hxx"
27 #include "GridProperties.hxx"
28 #include "macros.hxx"
29 #include "CharacterProperties.hxx"
30 #include "LineProperties.hxx"
31 #include "UserDefinedProperties.hxx"
32 #include "PropertyHelper.hxx"
33 #include "ContainerHelper.hxx"
34 #include "CloneHelper.hxx"
35 #include "AxisHelper.hxx"
36 #include "EventListenerHelper.hxx"
37 #include <com/sun/star/chart/ChartAxisArrangeOrderType.hpp>
38 #include <com/sun/star/chart/ChartAxisLabelPosition.hpp>
39 #include <com/sun/star/chart/ChartAxisMarkPosition.hpp>
40 #include <com/sun/star/chart/ChartAxisPosition.hpp>
41 #include <com/sun/star/chart2/AxisType.hpp>
42 #include <com/sun/star/beans/PropertyAttribute.hpp>
43 #include <com/sun/star/lang/Locale.hpp>
44 #include <com/sun/star/drawing/LineStyle.hpp>
45 #include <com/sun/star/drawing/LineDash.hpp>
46 #include <com/sun/star/drawing/LineJoint.hpp>
47 #include <com/sun/star/awt/Size.hpp>
48 #include <rtl/uuid.h>
49 #include <cppuhelper/queryinterface.hxx>
50
51 #include <vector>
52 #include <algorithm>
53
54 using namespace ::com::sun::star;
55 using namespace ::com::sun::star::beans::PropertyAttribute;
56
57 using ::rtl::OUString;
58 using ::com::sun::star::uno::Sequence;
59 using ::com::sun::star::uno::Reference;
60 using ::com::sun::star::uno::Any;
61 using ::com::sun::star::beans::Property;
62 using ::osl::MutexGuard;
63
64 namespace
65 {
66
67 static const OUString lcl_aServiceName(
68 RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.chart2.Axis" ));
69
70 enum
71 {
72 PROP_AXIS_SHOW,
73 PROP_AXIS_CROSSOVER_POSITION,
74 PROP_AXIS_CROSSOVER_VALUE,
75 PROP_AXIS_DISPLAY_LABELS,
76 PROP_AXIS_NUMBER_FORMAT,
77 PROP_AXIS_LABEL_POSITION,
78 PROP_AXIS_TEXT_ROTATION,
79 PROP_AXIS_TEXT_BREAK,
80 PROP_AXIS_TEXT_OVERLAP,
81 PROP_AXIS_TEXT_STACKED,
82 PROP_AXIS_TEXT_ARRANGE_ORDER,
83 PROP_AXIS_REFERENCE_DIAGRAM_SIZE,
84
85 PROP_AXIS_MAJOR_TICKMARKS,
86 PROP_AXIS_MINOR_TICKMARKS,
87 PROP_AXIS_MARK_POSITION
88 };
89
lcl_AddPropertiesToVector(::std::vector<Property> & rOutProperties)90 void lcl_AddPropertiesToVector(
91 ::std::vector< Property > & rOutProperties )
92 {
93 rOutProperties.push_back(
94 Property( C2U( "Show" ),
95 PROP_AXIS_SHOW,
96 ::getBooleanCppuType(),
97 beans::PropertyAttribute::BOUND
98 | beans::PropertyAttribute::MAYBEDEFAULT ));
99
100 rOutProperties.push_back(
101 Property( C2U( "CrossoverPosition" ),
102 PROP_AXIS_CROSSOVER_POSITION,
103 ::getCppuType( reinterpret_cast< const ::com::sun::star::chart::ChartAxisPosition * >(0)),
104 beans::PropertyAttribute::MAYBEDEFAULT ));
105
106 rOutProperties.push_back(
107 Property( C2U( "CrossoverValue" ),
108 PROP_AXIS_CROSSOVER_VALUE,
109 ::getCppuType( reinterpret_cast< const double * >(0)),
110 beans::PropertyAttribute::MAYBEVOID ));
111
112 rOutProperties.push_back(
113 Property( C2U( "DisplayLabels" ),
114 PROP_AXIS_DISPLAY_LABELS,
115 ::getBooleanCppuType(),
116 beans::PropertyAttribute::BOUND
117 | beans::PropertyAttribute::MAYBEDEFAULT ));
118
119 rOutProperties.push_back(
120 Property( C2U( "NumberFormat" ),
121 PROP_AXIS_NUMBER_FORMAT,
122 ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)),
123 beans::PropertyAttribute::BOUND
124 | beans::PropertyAttribute::MAYBEVOID ));
125
126 rOutProperties.push_back(
127 Property( C2U( "LabelPosition" ),
128 PROP_AXIS_LABEL_POSITION,
129 ::getCppuType( reinterpret_cast< const ::com::sun::star::chart::ChartAxisLabelPosition * >(0)),
130 beans::PropertyAttribute::MAYBEDEFAULT ));
131
132 rOutProperties.push_back(
133 Property( C2U( "TextRotation" ),
134 PROP_AXIS_TEXT_ROTATION,
135 ::getCppuType( reinterpret_cast< const double * >(0)),
136 beans::PropertyAttribute::BOUND
137 | beans::PropertyAttribute::MAYBEDEFAULT ));
138
139 rOutProperties.push_back(
140 Property( C2U( "TextBreak" ),
141 PROP_AXIS_TEXT_BREAK,
142 ::getBooleanCppuType(),
143 beans::PropertyAttribute::BOUND
144 | beans::PropertyAttribute::MAYBEDEFAULT ));
145
146 rOutProperties.push_back(
147 Property( C2U( "TextOverlap" ),
148 PROP_AXIS_TEXT_OVERLAP,
149 ::getBooleanCppuType(),
150 beans::PropertyAttribute::BOUND
151 | beans::PropertyAttribute::MAYBEDEFAULT ));
152
153 rOutProperties.push_back(
154 Property( C2U( "StackCharacters" ),
155 PROP_AXIS_TEXT_STACKED,
156 ::getBooleanCppuType(),
157 beans::PropertyAttribute::BOUND
158 | beans::PropertyAttribute::MAYBEDEFAULT ));
159
160 rOutProperties.push_back(
161 Property( C2U( "ArrangeOrder" ),
162 PROP_AXIS_TEXT_ARRANGE_ORDER,
163 ::getCppuType( reinterpret_cast< const ::com::sun::star::chart::ChartAxisArrangeOrderType * >(0)),
164 beans::PropertyAttribute::BOUND
165 | beans::PropertyAttribute::MAYBEDEFAULT ));
166
167 rOutProperties.push_back(
168 Property( C2U( "ReferencePageSize" ),
169 PROP_AXIS_REFERENCE_DIAGRAM_SIZE,
170 ::getCppuType( reinterpret_cast< const awt::Size * >(0)),
171 beans::PropertyAttribute::BOUND
172 | beans::PropertyAttribute::MAYBEVOID ));
173
174 rOutProperties.push_back(
175 Property( C2U( "MajorTickmarks" ),
176 PROP_AXIS_MAJOR_TICKMARKS,
177 ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)),
178 beans::PropertyAttribute::BOUND
179 | beans::PropertyAttribute::MAYBEDEFAULT ));
180 rOutProperties.push_back(
181 Property( C2U( "MinorTickmarks" ),
182 PROP_AXIS_MINOR_TICKMARKS,
183 ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)),
184 beans::PropertyAttribute::BOUND
185 | beans::PropertyAttribute::MAYBEDEFAULT ));
186 rOutProperties.push_back(
187 Property( C2U( "MarkPosition" ),
188 PROP_AXIS_MARK_POSITION,
189 ::getCppuType( reinterpret_cast< const ::com::sun::star::chart::ChartAxisMarkPosition * >(0)),
190 beans::PropertyAttribute::MAYBEDEFAULT ));
191 }
192
193 struct StaticAxisDefaults_Initializer
194 {
operator ()__anonbc3742b30111::StaticAxisDefaults_Initializer195 ::chart::tPropertyValueMap* operator()()
196 {
197 static ::chart::tPropertyValueMap aStaticDefaults;
198 lcl_AddDefaultsToMap( aStaticDefaults );
199 return &aStaticDefaults;
200 }
201 private:
lcl_AddDefaultsToMap__anonbc3742b30111::StaticAxisDefaults_Initializer202 void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap )
203 {
204 ::chart::CharacterProperties::AddDefaultsToMap( rOutMap );
205 ::chart::LineProperties::AddDefaultsToMap( rOutMap );
206
207 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_SHOW, true );
208 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_CROSSOVER_POSITION, ::com::sun::star::chart::ChartAxisPosition_ZERO );
209 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_DISPLAY_LABELS, true );
210 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_LABEL_POSITION, ::com::sun::star::chart::ChartAxisLabelPosition_NEAR_AXIS );
211 ::chart::PropertyHelper::setPropertyValueDefault< double >( rOutMap, PROP_AXIS_TEXT_ROTATION, 0.0 );
212 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_TEXT_BREAK, false );
213 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_TEXT_OVERLAP, false );
214 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_TEXT_STACKED, false );
215 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_TEXT_ARRANGE_ORDER, ::com::sun::star::chart::ChartAxisArrangeOrderType_AUTO );
216
217 float fDefaultCharHeight = 10.0;
218 ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::CharacterProperties::PROP_CHAR_CHAR_HEIGHT, fDefaultCharHeight );
219 ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::CharacterProperties::PROP_CHAR_ASIAN_CHAR_HEIGHT, fDefaultCharHeight );
220 ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::CharacterProperties::PROP_CHAR_COMPLEX_CHAR_HEIGHT, fDefaultCharHeight );
221
222 ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_AXIS_MAJOR_TICKMARKS, 2 /* CHAXIS_MARK_OUTER */ );
223 ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_AXIS_MINOR_TICKMARKS, 0 /* CHAXIS_MARK_NONE */ );
224 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_MARK_POSITION, ::com::sun::star::chart::ChartAxisMarkPosition_AT_LABELS_AND_AXIS );
225 }
226 };
227
228 struct StaticAxisDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticAxisDefaults_Initializer >
229 {
230 };
231
232 struct StaticAxisInfoHelper_Initializer
233 {
operator ()__anonbc3742b30111::StaticAxisInfoHelper_Initializer234 ::cppu::OPropertyArrayHelper* operator()()
235 {
236 static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
237 return &aPropHelper;
238 }
239
240 private:
lcl_GetPropertySequence__anonbc3742b30111::StaticAxisInfoHelper_Initializer241 Sequence< Property > lcl_GetPropertySequence()
242 {
243 ::std::vector< ::com::sun::star::beans::Property > aProperties;
244 lcl_AddPropertiesToVector( aProperties );
245 ::chart::CharacterProperties::AddPropertiesToVector( aProperties );
246 ::chart::LineProperties::AddPropertiesToVector( aProperties );
247 ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
248
249 ::std::sort( aProperties.begin(), aProperties.end(),
250 ::chart::PropertyNameLess() );
251
252 return ::chart::ContainerHelper::ContainerToSequence( aProperties );
253 }
254 };
255
256 struct StaticAxisInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticAxisInfoHelper_Initializer >
257 {
258 };
259
260 struct StaticAxisInfo_Initializer
261 {
operator ()__anonbc3742b30111::StaticAxisInfo_Initializer262 uno::Reference< beans::XPropertySetInfo >* operator()()
263 {
264 static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
265 ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticAxisInfoHelper::get() ) );
266 return &xPropertySetInfo;
267 }
268 };
269
270 struct StaticAxisInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticAxisInfo_Initializer >
271 {
272 };
273
274 typedef uno::Reference< beans::XPropertySet > lcl_tSubGridType;
275 typedef uno::Sequence< lcl_tSubGridType > lcl_tSubGridSeq;
276
lcl_CloneSubGrids(const lcl_tSubGridSeq & rSource,lcl_tSubGridSeq & rDestination)277 void lcl_CloneSubGrids(
278 const lcl_tSubGridSeq & rSource, lcl_tSubGridSeq & rDestination )
279 {
280 const lcl_tSubGridType * pBegin = rSource.getConstArray();
281 const lcl_tSubGridType * pEnd = pBegin + rSource.getLength();
282
283 rDestination.realloc( rSource.getLength());
284 lcl_tSubGridType * pDestBegin = rDestination.getArray();
285 lcl_tSubGridType * pDestEnd = pDestBegin + rDestination.getLength();
286 lcl_tSubGridType * pDestIt = pDestBegin;
287
288 for( const lcl_tSubGridType * pIt = pBegin; pIt != pEnd; ++pIt )
289 {
290 Reference< beans::XPropertySet > xSubGrid( *pIt );
291 if( xSubGrid.is())
292 {
293 Reference< util::XCloneable > xCloneable( xSubGrid, uno::UNO_QUERY );
294 if( xCloneable.is())
295 xSubGrid.set( xCloneable->createClone(), uno::UNO_QUERY );
296 }
297
298 (*pDestIt) = xSubGrid;
299 OSL_ASSERT( pDestIt != pDestEnd );
300 ++pDestIt;
301 }
302 OSL_ASSERT( pDestIt == pDestEnd );
303 (void)(pDestEnd); // avoid warning
304 }
305
306 } // anonymous namespace
307
308 // ================================================================================
309
310 namespace chart
311 {
312
Axis(Reference<uno::XComponentContext> const &)313 Axis::Axis( Reference< uno::XComponentContext > const & /* xContext */ ) :
314 ::property::OPropertySet( m_aMutex ),
315 m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder()),
316 m_aScaleData( AxisHelper::createDefaultScale() ),
317 m_xGrid( new GridProperties() ),
318 m_aSubGridProperties(),
319 m_xTitle()
320 {
321 osl_incrementInterlockedCount(&m_refCount);
322 setFastPropertyValue_NoBroadcast(
323 ::chart::LineProperties::PROP_LINE_COLOR, uno::makeAny( static_cast< sal_Int32 >( 0xb3b3b3 ) ) ); // gray30
324
325 if( m_xGrid.is())
326 ModifyListenerHelper::addListener( m_xGrid, m_xModifyEventForwarder );
327 if( m_aScaleData.Categories.is())
328 ModifyListenerHelper::addListener( m_aScaleData.Categories, m_xModifyEventForwarder );
329
330 AllocateSubGrids();
331 osl_decrementInterlockedCount(&m_refCount);
332 }
333
Axis(const Axis & rOther)334 Axis::Axis( const Axis & rOther ) :
335 MutexContainer(),
336 impl::Axis_Base(),
337 ::property::OPropertySet( rOther, m_aMutex ),
338 m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder()),
339 m_aScaleData( rOther.m_aScaleData )
340 {
341 m_xGrid.set( CloneHelper::CreateRefClone< Reference< beans::XPropertySet > >()( rOther.m_xGrid ));
342 if( m_xGrid.is())
343 ModifyListenerHelper::addListener( m_xGrid, m_xModifyEventForwarder );
344
345 if( m_aScaleData.Categories.is())
346 ModifyListenerHelper::addListener( m_aScaleData.Categories, m_xModifyEventForwarder );
347
348 if( rOther.m_aSubGridProperties.getLength() != 0 )
349 lcl_CloneSubGrids( rOther.m_aSubGridProperties, m_aSubGridProperties );
350 ModifyListenerHelper::addListenerToAllSequenceElements( m_aSubGridProperties, m_xModifyEventForwarder );
351
352 m_xTitle.set( CloneHelper::CreateRefClone< Reference< chart2::XTitle > >()( rOther.m_xTitle ));
353 if( m_xTitle.is())
354 ModifyListenerHelper::addListener( m_xTitle, m_xModifyEventForwarder );
355 }
356
357 // late initialization to call after copy-constructing
Init(const Axis &)358 void Axis::Init( const Axis & /* rOther */ )
359 {
360 if( m_aScaleData.Categories.is())
361 EventListenerHelper::addListener( m_aScaleData.Categories, this );
362 }
363
~Axis()364 Axis::~Axis()
365 {
366 try
367 {
368 ModifyListenerHelper::removeListener( m_xGrid, m_xModifyEventForwarder );
369 ModifyListenerHelper::removeListenerFromAllSequenceElements( m_aSubGridProperties, m_xModifyEventForwarder );
370 ModifyListenerHelper::removeListener( m_xTitle, m_xModifyEventForwarder );
371 if( m_aScaleData.Categories.is())
372 {
373 ModifyListenerHelper::removeListener( m_aScaleData.Categories, m_xModifyEventForwarder );
374 m_aScaleData.Categories.set(0);
375 }
376 }
377 catch( const uno::Exception & ex )
378 {
379 ASSERT_EXCEPTION( ex );
380 }
381
382 m_aSubGridProperties.realloc(0);
383 m_xGrid = 0;
384 m_xTitle = 0;
385 }
386
AllocateSubGrids()387 void Axis::AllocateSubGrids()
388 {
389 Reference< util::XModifyListener > xModifyEventForwarder;
390 Reference< lang::XEventListener > xEventListener;
391 std::vector< Reference< beans::XPropertySet > > aOldBroadcasters;
392 std::vector< Reference< beans::XPropertySet > > aNewBroadcasters;
393 {
394 MutexGuard aGuard( m_aMutex );
395 xModifyEventForwarder = m_xModifyEventForwarder;
396 xEventListener = this;
397
398 sal_Int32 nNewSubIncCount = m_aScaleData.IncrementData.SubIncrements.getLength();
399 sal_Int32 nOldSubIncCount = m_aSubGridProperties.getLength();
400
401 if( nOldSubIncCount > nNewSubIncCount )
402 {
403 // remove superfluous entries
404 for( sal_Int32 i = nNewSubIncCount; i < nOldSubIncCount; ++i )
405 aOldBroadcasters.push_back( m_aSubGridProperties[ i ] );
406 m_aSubGridProperties.realloc( nNewSubIncCount );
407 }
408 else if( nOldSubIncCount < nNewSubIncCount )
409 {
410 m_aSubGridProperties.realloc( nNewSubIncCount );
411
412 // allocate new entries
413 for( sal_Int32 i = nOldSubIncCount; i < nNewSubIncCount; ++i )
414 {
415 m_aSubGridProperties[ i ] = new GridProperties();
416 LineProperties::SetLineInvisible( m_aSubGridProperties[ i ] );
417 aNewBroadcasters.push_back( m_aSubGridProperties[ i ] );
418 }
419 }
420 }
421 //don't keep the mutex locked while calling out
422 std::vector< Reference< beans::XPropertySet > >::iterator aBroadcaster = aOldBroadcasters.begin();
423 for( ;aBroadcaster != aOldBroadcasters.end(); ++aBroadcaster )
424 ModifyListenerHelper::removeListener( *aBroadcaster, xModifyEventForwarder );
425 for( aBroadcaster = aNewBroadcasters.begin(); aBroadcaster != aNewBroadcasters.end(); ++aBroadcaster )
426 ModifyListenerHelper::addListener( *aBroadcaster, xModifyEventForwarder );
427 }
428
429 // --------------------------------------------------------------------------------
430
431 // ____ XAxis ____
setScaleData(const chart2::ScaleData & rScaleData)432 void SAL_CALL Axis::setScaleData( const chart2::ScaleData& rScaleData )
433 {
434 Reference< util::XModifyListener > xModifyEventForwarder;
435 Reference< lang::XEventListener > xEventListener;
436 Reference< chart2::data::XLabeledDataSequence > xOldCategories;
437 Reference< chart2::data::XLabeledDataSequence > xNewCategories = rScaleData.Categories;
438 {
439 MutexGuard aGuard( m_aMutex );
440 xModifyEventForwarder = m_xModifyEventForwarder;
441 xEventListener = this;
442 xOldCategories = m_aScaleData.Categories;
443 m_aScaleData = rScaleData;
444 }
445 AllocateSubGrids();
446
447 //don't keep the mutex locked while calling out
448 if( xOldCategories.is() && xOldCategories != xNewCategories )
449 {
450 ModifyListenerHelper::removeListener( xOldCategories, xModifyEventForwarder );
451 EventListenerHelper::removeListener( xOldCategories, xEventListener );
452 }
453 if( xNewCategories.is() && xOldCategories != xNewCategories )
454 {
455 ModifyListenerHelper::addListener( xNewCategories, m_xModifyEventForwarder );
456 EventListenerHelper::addListener( xNewCategories, xEventListener );
457 }
458 fireModifyEvent();
459 }
460
getScaleData()461 chart2::ScaleData SAL_CALL Axis::getScaleData()
462 {
463 // /--
464 MutexGuard aGuard( m_aMutex );
465 return m_aScaleData;
466 // \--
467 }
468
getGridProperties()469 Reference< beans::XPropertySet > SAL_CALL Axis::getGridProperties()
470 {
471 // /--
472 MutexGuard aGuard( m_aMutex );
473 return m_xGrid;
474 // \--
475 }
getSubGridProperties()476 Sequence< Reference< beans::XPropertySet > > SAL_CALL Axis::getSubGridProperties()
477 {
478 // /--
479 MutexGuard aGuard( m_aMutex );
480 return m_aSubGridProperties;
481 // \--
482 }
483
getSubTickProperties()484 Sequence< Reference< beans::XPropertySet > > SAL_CALL Axis::getSubTickProperties()
485 {
486 OSL_ENSURE( false, "Not implemented yet" );
487 return Sequence< Reference< beans::XPropertySet > >();
488 }
489
490
491 // ____ XTitled ____
getTitleObject()492 Reference< chart2::XTitle > SAL_CALL Axis::getTitleObject()
493 {
494 // /--
495 MutexGuard aGuard( GetMutex() );
496 return m_xTitle;
497 // \--
498 }
499
setTitleObject(const Reference<chart2::XTitle> & xNewTitle)500 void SAL_CALL Axis::setTitleObject( const Reference< chart2::XTitle >& xNewTitle )
501 {
502 Reference< util::XModifyListener > xModifyEventForwarder;
503 Reference< chart2::XTitle > xOldTitle;
504 {
505 MutexGuard aGuard( GetMutex() );
506 xOldTitle = m_xTitle;
507 xModifyEventForwarder = m_xModifyEventForwarder;
508 m_xTitle = xNewTitle;
509 }
510
511 //don't keep the mutex locked while calling out
512 if( xOldTitle.is() && xOldTitle != xNewTitle )
513 ModifyListenerHelper::removeListener( xOldTitle, xModifyEventForwarder );
514 if( xNewTitle.is() && xOldTitle != xNewTitle )
515 ModifyListenerHelper::addListener( xNewTitle, xModifyEventForwarder );
516 fireModifyEvent();
517 }
518
519 // ____ XCloneable ____
createClone()520 Reference< util::XCloneable > SAL_CALL Axis::createClone()
521 {
522 Axis * pNewAxis( new Axis( *this ));
523 // hold a reference to the clone
524 Reference< util::XCloneable > xResult( pNewAxis );
525 // do initialization that uses uno references to the clone
526 pNewAxis->Init( *this );
527 return xResult;
528 }
529
530 // ____ XModifyBroadcaster ____
addModifyListener(const Reference<util::XModifyListener> & aListener)531 void SAL_CALL Axis::addModifyListener( const Reference< util::XModifyListener >& aListener )
532 {
533 try
534 {
535 Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
536 xBroadcaster->addModifyListener( aListener );
537 }
538 catch( const uno::Exception & ex )
539 {
540 ASSERT_EXCEPTION( ex );
541 }
542 }
543
removeModifyListener(const Reference<util::XModifyListener> & aListener)544 void SAL_CALL Axis::removeModifyListener( const Reference< util::XModifyListener >& aListener )
545 {
546 try
547 {
548 Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
549 xBroadcaster->removeModifyListener( aListener );
550 }
551 catch( const uno::Exception & ex )
552 {
553 ASSERT_EXCEPTION( ex );
554 }
555 }
556
557 // ____ XModifyListener ____
modified(const lang::EventObject & aEvent)558 void SAL_CALL Axis::modified( const lang::EventObject& aEvent )
559 {
560 m_xModifyEventForwarder->modified( aEvent );
561 }
562
563 // ____ XEventListener (base of XModifyListener) ____
disposing(const lang::EventObject & Source)564 void SAL_CALL Axis::disposing( const lang::EventObject& Source )
565 {
566 if( Source.Source == m_aScaleData.Categories )
567 m_aScaleData.Categories = 0;
568 }
569
570 // ____ OPropertySet ____
firePropertyChangeEvent()571 void Axis::firePropertyChangeEvent()
572 {
573 fireModifyEvent();
574 }
575
fireModifyEvent()576 void Axis::fireModifyEvent()
577 {
578 m_xModifyEventForwarder->modified( lang::EventObject( static_cast< uno::XWeak* >( this )));
579 }
580
581 // ================================================================================
582
583 // ____ OPropertySet ____
GetDefaultValue(sal_Int32 nHandle) const584 uno::Any Axis::GetDefaultValue( sal_Int32 nHandle ) const
585 {
586 const tPropertyValueMap& rStaticDefaults = *StaticAxisDefaults::get();
587 tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
588 if( aFound == rStaticDefaults.end() )
589 return uno::Any();
590 return (*aFound).second;
591 }
592
getInfoHelper()593 ::cppu::IPropertyArrayHelper & SAL_CALL Axis::getInfoHelper()
594 {
595 return *StaticAxisInfoHelper::get();
596 }
597
598 // ____ XPropertySet ____
getPropertySetInfo()599 Reference< beans::XPropertySetInfo > SAL_CALL Axis::getPropertySetInfo()
600 {
601 return *StaticAxisInfo::get();
602 }
603
604 // ================================================================================
605
getSupportedServiceNames_Static()606 Sequence< OUString > Axis::getSupportedServiceNames_Static()
607 {
608 Sequence< OUString > aServices( 2 );
609 aServices[ 0 ] = C2U( "com.sun.star.chart2.Axis" );
610 aServices[ 1 ] = C2U( "com.sun.star.beans.PropertySet" );
611 return aServices;
612 }
613
614 using impl::Axis_Base;
615
616 IMPLEMENT_FORWARD_XINTERFACE2( Axis, Axis_Base, ::property::OPropertySet )
617 IMPLEMENT_FORWARD_XTYPEPROVIDER2( Axis, Axis_Base, ::property::OPropertySet )
618
619 // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
620 APPHELPER_XSERVICEINFO_IMPL( Axis, lcl_aServiceName );
621
622 } // namespace chart
623