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