1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_chart2.hxx"
30 #include "AxisWrapper.hxx"
31 #include "AxisHelper.hxx"
32 #include "TitleHelper.hxx"
33 #include "Chart2ModelContact.hxx"
34 #include "ContainerHelper.hxx"
35 #include "macros.hxx"
36 #include "WrappedDirectStateProperty.hxx"
37 #include "GridWrapper.hxx"
38 #include "TitleWrapper.hxx"
39 #include "DisposeHelper.hxx"
40 
41 #include <comphelper/InlineContainer.hxx>
42 #include <com/sun/star/beans/PropertyAttribute.hpp>
43 #include <com/sun/star/chart/ChartAxisArrangeOrderType.hpp>
44 #include <com/sun/star/chart/ChartAxisPosition.hpp>
45 #include <com/sun/star/chart/ChartAxisLabelPosition.hpp>
46 #include <com/sun/star/chart/ChartAxisMarkPosition.hpp>
47 
48 #include "CharacterProperties.hxx"
49 #include "LineProperties.hxx"
50 #include "UserDefinedProperties.hxx"
51 #include "WrappedCharacterHeightProperty.hxx"
52 #include "WrappedTextRotationProperty.hxx"
53 #include "WrappedGapwidthProperty.hxx"
54 #include "WrappedScaleProperty.hxx"
55 #include "WrappedDefaultProperty.hxx"
56 #include "WrappedNumberFormatProperty.hxx"
57 #include "WrappedScaleTextProperties.hxx"
58 
59 #include <algorithm>
60 #include <rtl/ustrbuf.hxx>
61 #include <rtl/math.hxx>
62 
63 using namespace ::com::sun::star;
64 using namespace ::com::sun::star::chart2;
65 using namespace ::chart::ContainerHelper;
66 
67 using ::com::sun::star::beans::Property;
68 using ::osl::MutexGuard;
69 using ::com::sun::star::uno::Reference;
70 using ::com::sun::star::uno::Sequence;
71 using ::com::sun::star::uno::Any;
72 using ::rtl::OUString;
73 
74 namespace
75 {
76 static const OUString lcl_aServiceName(
77     RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.chart.Axis" ));
78 
79 enum
80 {
81     PROP_AXIS_MAX,
82     PROP_AXIS_MIN,
83     PROP_AXIS_STEPMAIN,
84     PROP_AXIS_STEPHELP, //deprecated property use 'StepHelpCount' instead
85     PROP_AXIS_STEPHELP_COUNT,
86     PROP_AXIS_AUTO_MAX,
87     PROP_AXIS_AUTO_MIN,
88     PROP_AXIS_AUTO_STEPMAIN,
89     PROP_AXIS_AUTO_STEPHELP,
90     PROP_AXIS_TYPE,
91     PROP_AXIS_TIME_INCREMENT,
92     PROP_AXIS_EXPLICIT_TIME_INCREMENT,
93     PROP_AXIS_LOGARITHMIC,
94     PROP_AXIS_REVERSEDIRECTION,
95     PROP_AXIS_VISIBLE,
96     PROP_AXIS_CROSSOVER_POSITION,
97     PROP_AXIS_CROSSOVER_VALUE,
98     PROP_AXIS_ORIGIN,
99     PROP_AXIS_AUTO_ORIGIN,
100     PROP_AXIS_MARKS,
101     PROP_AXIS_HELPMARKS,
102     PROP_AXIS_MARK_POSITION,
103     PROP_AXIS_DISPLAY_LABELS,
104     PROP_AXIS_NUMBERFORMAT,
105     PROP_AXIS_LINK_NUMBERFORMAT_TO_SOURCE,
106     PROP_AXIS_LABEL_POSITION,
107     PROP_AXIS_TEXT_ROTATION,
108     PROP_AXIS_ARRANGE_ORDER,
109     PROP_AXIS_TEXTBREAK,
110     PROP_AXIS_CAN_OVERLAP,
111     PROP_AXIS_STACKEDTEXT,
112     PROP_AXIS_OVERLAP,
113     PROP_AXIS_GAP_WIDTH
114 };
115 
116 void lcl_AddPropertiesToVector(
117     ::std::vector< Property > & rOutProperties )
118 {
119     //Properties for scaling:
120     rOutProperties.push_back(
121         Property( C2U( "Max" ),
122                   PROP_AXIS_MAX,
123                   ::getCppuType( reinterpret_cast< const double * >(0)),
124                   beans::PropertyAttribute::BOUND
125                   | beans::PropertyAttribute::MAYBEVOID ));
126 
127     rOutProperties.push_back(
128         Property( C2U( "Min" ),
129                   PROP_AXIS_MIN,
130                   ::getCppuType( reinterpret_cast< const double * >(0)),
131                   beans::PropertyAttribute::BOUND
132                   | beans::PropertyAttribute::MAYBEVOID ));
133 
134     rOutProperties.push_back(
135         Property( C2U( "StepMain" ),
136                   PROP_AXIS_STEPMAIN,
137                   ::getCppuType( reinterpret_cast< const double * >(0)),
138                   beans::PropertyAttribute::BOUND
139                   | beans::PropertyAttribute::MAYBEVOID ));
140 
141     rOutProperties.push_back(
142         Property( C2U( "StepHelpCount" ),
143                   PROP_AXIS_STEPHELP_COUNT,
144                   ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)),
145                   beans::PropertyAttribute::BOUND
146                   | beans::PropertyAttribute::MAYBEVOID ));
147 
148     //deprecated property use 'StepHelpCount' instead
149     rOutProperties.push_back(
150         Property( C2U( "StepHelp" ),
151                   PROP_AXIS_STEPHELP,
152                   ::getCppuType( reinterpret_cast< const double * >(0)),
153                   beans::PropertyAttribute::BOUND
154                   | beans::PropertyAttribute::MAYBEVOID ));
155 
156     rOutProperties.push_back(
157         Property( C2U( "AutoMax" ),
158                   PROP_AXIS_AUTO_MAX,
159                   ::getBooleanCppuType(),
160                   //#i111967# no PropertyChangeEvent is fired on change so far
161                   beans::PropertyAttribute::MAYBEDEFAULT ));
162 
163     rOutProperties.push_back(
164         Property( C2U( "AutoMin" ),
165                   PROP_AXIS_AUTO_MIN,
166                   ::getBooleanCppuType(),
167                   //#i111967# no PropertyChangeEvent is fired on change so far
168                   beans::PropertyAttribute::MAYBEDEFAULT ));
169 
170     rOutProperties.push_back(
171         Property( C2U( "AutoStepMain" ),
172                   PROP_AXIS_AUTO_STEPMAIN,
173                   ::getBooleanCppuType(),
174                   //#i111967# no PropertyChangeEvent is fired on change so far
175                   beans::PropertyAttribute::MAYBEDEFAULT ));
176 
177     rOutProperties.push_back(
178         Property( C2U( "AutoStepHelp" ),
179                   PROP_AXIS_AUTO_STEPHELP,
180                   ::getBooleanCppuType(),
181                   //#i111967# no PropertyChangeEvent is fired on change so far
182                   beans::PropertyAttribute::MAYBEDEFAULT ));
183 
184     rOutProperties.push_back(
185         Property( C2U( "AxisType" ),
186                   PROP_AXIS_TYPE,
187                   ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)), //type com::sun::star::chart::ChartAxisType
188                   //#i111967# no PropertyChangeEvent is fired on change so far
189                   beans::PropertyAttribute::MAYBEDEFAULT ));
190 
191     rOutProperties.push_back(
192         Property( C2U( "TimeIncrement" ),
193                   PROP_AXIS_TIME_INCREMENT,
194                   ::getCppuType( reinterpret_cast< const ::com::sun::star::chart::TimeIncrement * >(0)),
195                   //#i111967# no PropertyChangeEvent is fired on change so far
196                   beans::PropertyAttribute::MAYBEVOID ));
197 
198     rOutProperties.push_back(
199         Property( C2U( "ExplicitTimeIncrement" ),
200                   PROP_AXIS_EXPLICIT_TIME_INCREMENT,
201                   ::getCppuType( reinterpret_cast< const ::com::sun::star::chart::TimeIncrement * >(0)),
202                   beans::PropertyAttribute::READONLY |
203                   beans::PropertyAttribute::MAYBEVOID ));
204 
205     rOutProperties.push_back(
206         Property( C2U( "Logarithmic" ),
207                   PROP_AXIS_LOGARITHMIC,
208                   ::getBooleanCppuType(),
209                   //#i111967# no PropertyChangeEvent is fired on change so far
210                   beans::PropertyAttribute::MAYBEDEFAULT ));
211 
212     rOutProperties.push_back(
213         Property( C2U( "ReverseDirection" ),
214                   PROP_AXIS_REVERSEDIRECTION,
215                   ::getBooleanCppuType(),
216                   //#i111967# no PropertyChangeEvent is fired on change so far
217                   beans::PropertyAttribute::MAYBEDEFAULT ));
218 
219     //todo: this property is missing in the API
220     rOutProperties.push_back(
221         Property( C2U( "Visible" ),
222                   PROP_AXIS_VISIBLE,
223                   ::getBooleanCppuType(),
224                   beans::PropertyAttribute::BOUND
225                   | beans::PropertyAttribute::MAYBEDEFAULT ));
226 
227     rOutProperties.push_back(
228         Property( C2U( "CrossoverPosition" ),
229                   PROP_AXIS_CROSSOVER_POSITION,
230                   ::getCppuType( reinterpret_cast< const ::com::sun::star::chart::ChartAxisPosition * >(0)),
231                   beans::PropertyAttribute::MAYBEDEFAULT ));
232 
233     rOutProperties.push_back(
234         Property( C2U( "CrossoverValue" ),
235                   PROP_AXIS_CROSSOVER_VALUE,
236                   ::getCppuType( reinterpret_cast< const double * >(0)),
237                   beans::PropertyAttribute::MAYBEVOID ));
238 
239 
240     rOutProperties.push_back(
241         Property( C2U( "Origin" ),
242                   PROP_AXIS_ORIGIN,
243                   ::getCppuType( reinterpret_cast< const double * >(0)),
244                   beans::PropertyAttribute::BOUND
245                   | beans::PropertyAttribute::MAYBEVOID ));
246 
247     rOutProperties.push_back(
248         Property( C2U( "AutoOrigin" ),
249                   PROP_AXIS_AUTO_ORIGIN,
250                   ::getBooleanCppuType(),
251                   //#i111967# no PropertyChangeEvent is fired on change so far
252                   beans::PropertyAttribute::MAYBEDEFAULT ));
253 
254     //Properties for interval marks:
255     rOutProperties.push_back(
256         Property( C2U( "Marks" ),
257                   PROP_AXIS_MARKS,
258                   ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)),
259                   beans::PropertyAttribute::BOUND
260                   | beans::PropertyAttribute::MAYBEDEFAULT ));
261 
262     rOutProperties.push_back(
263         Property( C2U( "HelpMarks" ),
264                   PROP_AXIS_HELPMARKS,
265                   ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)),
266                   beans::PropertyAttribute::BOUND
267                   | beans::PropertyAttribute::MAYBEDEFAULT ));
268 
269     rOutProperties.push_back(
270         Property( C2U( "MarkPosition" ),
271                   PROP_AXIS_MARK_POSITION,
272                   ::getCppuType( reinterpret_cast< const ::com::sun::star::chart::ChartAxisMarkPosition * >(0)),
273                   beans::PropertyAttribute::MAYBEDEFAULT ));
274 
275 
276     //Properties for labels:
277     rOutProperties.push_back(
278         Property( C2U( "DisplayLabels" ),
279                   PROP_AXIS_DISPLAY_LABELS,
280                   ::getBooleanCppuType(),
281                   beans::PropertyAttribute::BOUND
282                   | beans::PropertyAttribute::MAYBEDEFAULT ));
283 
284     rOutProperties.push_back(
285         Property( C2U( "NumberFormat" ),
286                   PROP_AXIS_NUMBERFORMAT,
287                   ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)),
288                   beans::PropertyAttribute::BOUND
289                   | beans::PropertyAttribute::MAYBEDEFAULT ));
290 
291     rOutProperties.push_back(
292         Property( C2U( "LinkNumberFormatToSource" ),
293                   PROP_AXIS_LINK_NUMBERFORMAT_TO_SOURCE,
294                   ::getBooleanCppuType(),
295                   beans::PropertyAttribute::BOUND
296                   | beans::PropertyAttribute::MAYBEDEFAULT ));
297 
298     rOutProperties.push_back(
299         Property( C2U( "LabelPosition" ),
300                   PROP_AXIS_LABEL_POSITION,
301                   ::getCppuType( reinterpret_cast< const ::com::sun::star::chart::ChartAxisLabelPosition * >(0)),
302                   beans::PropertyAttribute::MAYBEDEFAULT ));
303 
304     rOutProperties.push_back(
305         Property( C2U( "TextRotation" ),
306                   PROP_AXIS_TEXT_ROTATION,
307                   ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)),
308                   beans::PropertyAttribute::BOUND
309                   | beans::PropertyAttribute::MAYBEDEFAULT ));
310 
311     rOutProperties.push_back(
312         Property( C2U( "ArrangeOrder" ),
313                   PROP_AXIS_ARRANGE_ORDER,
314                   ::getCppuType( reinterpret_cast< const ::com::sun::star::chart::ChartAxisArrangeOrderType * >(0)),
315                   beans::PropertyAttribute::BOUND
316                   | beans::PropertyAttribute::MAYBEDEFAULT ));
317 
318     rOutProperties.push_back(
319         Property( C2U( "TextBreak" ),
320                   PROP_AXIS_TEXTBREAK,
321                   ::getBooleanCppuType(),
322                   beans::PropertyAttribute::BOUND
323                   | beans::PropertyAttribute::MAYBEDEFAULT ));
324 
325     rOutProperties.push_back(
326         Property( C2U( "TextCanOverlap" ),
327                   PROP_AXIS_CAN_OVERLAP,
328                   ::getBooleanCppuType(),
329                   beans::PropertyAttribute::BOUND
330                   | beans::PropertyAttribute::MAYBEDEFAULT ));
331 
332     rOutProperties.push_back(
333         Property( C2U( "StackedText" ),
334                   PROP_AXIS_STACKEDTEXT,
335                   ::getBooleanCppuType(),
336                   beans::PropertyAttribute::BOUND
337                   | beans::PropertyAttribute::MAYBEDEFAULT ));
338 
339     // Properties related to bar charts:
340     rOutProperties.push_back(
341         Property( C2U( "Overlap" ),
342                   PROP_AXIS_OVERLAP,
343                   ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)),
344                   //#i111967# no PropertyChangeEvent is fired on change so far
345                   beans::PropertyAttribute::MAYBEDEFAULT ));
346 
347     rOutProperties.push_back(
348         Property( C2U( "GapWidth" ),
349                   PROP_AXIS_GAP_WIDTH,
350                   ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)),
351                   //#i111967# no PropertyChangeEvent is fired on change so far
352                   beans::PropertyAttribute::MAYBEDEFAULT ));
353 }
354 
355 struct StaticAxisWrapperPropertyArray_Initializer
356 {
357     Sequence< Property >* operator()()
358     {
359         static Sequence< Property > aPropSeq( lcl_GetPropertySequence() );
360         return &aPropSeq;
361     }
362 
363 private:
364     Sequence< Property > lcl_GetPropertySequence()
365     {
366         ::std::vector< ::com::sun::star::beans::Property > aProperties;
367         lcl_AddPropertiesToVector( aProperties );
368         ::chart::CharacterProperties::AddPropertiesToVector( aProperties );
369         ::chart::LineProperties::AddPropertiesToVector( aProperties );
370         //::chart::NamedLineProperties::AddPropertiesToVector( aProperties );
371         ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
372         ::chart::wrapper::WrappedScaleTextProperties::addProperties( aProperties );
373 
374         ::std::sort( aProperties.begin(), aProperties.end(),
375                      ::chart::PropertyNameLess() );
376 
377         return ::chart::ContainerHelper::ContainerToSequence( aProperties );
378     }
379 };
380 
381 struct StaticAxisWrapperPropertyArray : public rtl::StaticAggregate< Sequence< Property >, StaticAxisWrapperPropertyArray_Initializer >
382 {
383 };
384 
385 } // anonymous namespace
386 
387 // --------------------------------------------------------------------------------
388 
389 namespace chart
390 {
391 namespace wrapper
392 {
393 
394 AxisWrapper::AxisWrapper(
395     tAxisType eType, ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) :
396         m_spChart2ModelContact( spChart2ModelContact ),
397         m_aEventListenerContainer( m_aMutex ),
398         m_eType( eType )
399 {
400 }
401 
402 AxisWrapper::~AxisWrapper()
403 {
404 }
405 
406 // ____ chart::XAxis ____
407 Reference< beans::XPropertySet > SAL_CALL AxisWrapper::getAxisTitle() throw (uno::RuntimeException)
408 {
409     if( !m_xAxisTitle.is() )
410     {
411         TitleHelper::eTitleType eTitleType( TitleHelper::X_AXIS_TITLE    );
412         switch( m_eType )
413         {
414             case X_AXIS:
415                 eTitleType = TitleHelper::X_AXIS_TITLE;
416                 break;
417             case Y_AXIS:
418                 eTitleType = TitleHelper::Y_AXIS_TITLE;
419                 break;
420             case Z_AXIS:
421                 eTitleType = TitleHelper::Z_AXIS_TITLE;
422                 break;
423             case SECOND_X_AXIS:
424                 eTitleType = TitleHelper::SECONDARY_X_AXIS_TITLE;
425                 break;
426             case SECOND_Y_AXIS:
427                 eTitleType = TitleHelper::SECONDARY_Y_AXIS_TITLE;
428                 break;
429             default:
430                 return 0;
431         }
432         m_xAxisTitle = new TitleWrapper( eTitleType, m_spChart2ModelContact );
433     }
434     return m_xAxisTitle;
435 }
436 Reference< beans::XPropertySet > SAL_CALL AxisWrapper::getMajorGrid() throw (uno::RuntimeException)
437 {
438     if( !m_xMajorGrid.is() )
439     {
440         GridWrapper::tGridType eGridType( GridWrapper::X_MAJOR_GRID );
441         switch( m_eType )
442         {
443             case X_AXIS:
444                 eGridType = GridWrapper::X_MAJOR_GRID;
445                 break;
446             case Y_AXIS:
447                 eGridType = GridWrapper::Y_MAJOR_GRID;
448                 break;
449             case Z_AXIS:
450                 eGridType = GridWrapper::Z_MAJOR_GRID;
451                 break;
452             default:
453                 return 0;
454         }
455         m_xMajorGrid = new GridWrapper( eGridType, m_spChart2ModelContact );
456     }
457     return m_xMajorGrid;
458 }
459 Reference< beans::XPropertySet > SAL_CALL AxisWrapper::getMinorGrid() throw (uno::RuntimeException)
460 {
461     if( !m_xMinorGrid.is() )
462     {
463         GridWrapper::tGridType eGridType( GridWrapper::X_MAJOR_GRID );
464         switch( m_eType )
465         {
466             case X_AXIS:
467                 eGridType = GridWrapper::X_MINOR_GRID;
468                 break;
469             case Y_AXIS:
470                 eGridType = GridWrapper::Y_MINOR_GRID;
471                 break;
472             case Z_AXIS:
473                 eGridType = GridWrapper::Z_MINOR_GRID;
474                 break;
475             default:
476                 return 0;
477         }
478         m_xMinorGrid = new GridWrapper( eGridType, m_spChart2ModelContact );
479     }
480     return m_xMinorGrid;
481 }
482 
483 // ____ XShape ____
484 awt::Point SAL_CALL AxisWrapper::getPosition()
485     throw (uno::RuntimeException)
486 {
487     awt::Point aResult( m_spChart2ModelContact->GetAxisPosition( this->getAxis() ) );
488     return aResult;
489 }
490 
491 void SAL_CALL AxisWrapper::setPosition( const awt::Point& /*aPosition*/ )
492     throw (uno::RuntimeException)
493 {
494     OSL_ENSURE( false, "trying to set position of Axis" );
495 }
496 
497 awt::Size SAL_CALL AxisWrapper::getSize()
498     throw (uno::RuntimeException)
499 {
500     awt::Size aSize( m_spChart2ModelContact->GetAxisSize( this->getAxis() ) );
501     return aSize;
502 }
503 
504 void SAL_CALL AxisWrapper::setSize( const awt::Size& /*aSize*/ )
505     throw (beans::PropertyVetoException,
506            uno::RuntimeException)
507 {
508     OSL_ENSURE( false, "trying to set size of Axis" );
509 }
510 
511 // ____ XShapeDescriptor (base of XShape) ____
512 OUString SAL_CALL AxisWrapper::getShapeType()
513     throw (uno::RuntimeException)
514 {
515     return C2U( "com.sun.star.chart.ChartAxis" );
516 }
517 
518 // ____ XNumberFormatsSupplier ____
519 uno::Reference< beans::XPropertySet > SAL_CALL AxisWrapper::getNumberFormatSettings()
520     throw (uno::RuntimeException)
521 {
522     Reference< util::XNumberFormatsSupplier > xNumSuppl( m_spChart2ModelContact->getChartModel(), uno::UNO_QUERY );
523     if( xNumSuppl.is() )
524         return xNumSuppl->getNumberFormatSettings();
525 
526     return uno::Reference< beans::XPropertySet >();
527 }
528 
529 uno::Reference< util::XNumberFormats > SAL_CALL AxisWrapper::getNumberFormats()
530     throw (uno::RuntimeException)
531 {
532     Reference< util::XNumberFormatsSupplier > xNumSuppl( m_spChart2ModelContact->getChartModel(), uno::UNO_QUERY );
533     if( xNumSuppl.is() )
534         return xNumSuppl->getNumberFormats();
535 
536     return uno::Reference< util::XNumberFormats >();
537 }
538 
539 void AxisWrapper::getDimensionAndMainAxisBool( tAxisType eType, sal_Int32& rnDimensionIndex, sal_Bool& rbMainAxis )
540 {
541     switch( eType )
542     {
543         case X_AXIS:
544             rnDimensionIndex = 0; rbMainAxis = sal_True; break;
545         case Y_AXIS:
546             rnDimensionIndex = 1; rbMainAxis = sal_True; break;
547         case Z_AXIS:
548             rnDimensionIndex = 2; rbMainAxis = sal_True; break;
549         case SECOND_X_AXIS:
550             rnDimensionIndex = 0; rbMainAxis = sal_False; break;
551         case SECOND_Y_AXIS:
552             rnDimensionIndex = 1; rbMainAxis = sal_False; break;
553     }
554 }
555 
556 // ____ XComponent ____
557 void SAL_CALL AxisWrapper::dispose()
558     throw (uno::RuntimeException)
559 {
560     Reference< uno::XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) );
561     m_aEventListenerContainer.disposeAndClear( lang::EventObject( xSource ) );
562 
563     DisposeHelper::DisposeAndClear( m_xAxisTitle );
564     DisposeHelper::DisposeAndClear( m_xMajorGrid );
565     DisposeHelper::DisposeAndClear( m_xMinorGrid );
566 
567     clearWrappedPropertySet();
568 }
569 
570 void SAL_CALL AxisWrapper::addEventListener(
571     const Reference< lang::XEventListener >& xListener )
572     throw (uno::RuntimeException)
573 {
574 	m_aEventListenerContainer.addInterface( xListener );
575 }
576 
577 void SAL_CALL AxisWrapper::removeEventListener(
578     const Reference< lang::XEventListener >& aListener )
579     throw (uno::RuntimeException)
580 {
581 	m_aEventListenerContainer.removeInterface( aListener );
582 }
583 
584 // ================================================================================
585 
586 //ReferenceSizePropertyProvider
587 void AxisWrapper::updateReferenceSize()
588 {
589     Reference< beans::XPropertySet > xProp( this->getAxis(), uno::UNO_QUERY );
590     if( xProp.is() )
591     {
592         if( xProp->getPropertyValue( C2U("ReferencePageSize") ).hasValue() )
593             xProp->setPropertyValue( C2U("ReferencePageSize"), uno::makeAny(
594             m_spChart2ModelContact->GetPageSize() ));
595     }
596 }
597 Any AxisWrapper::getReferenceSize()
598 {
599     Any aRet;
600     Reference< beans::XPropertySet > xProp( this->getAxis(), uno::UNO_QUERY );
601     if( xProp.is() )
602         aRet = xProp->getPropertyValue( C2U("ReferencePageSize") );
603     return aRet;
604 }
605 awt::Size AxisWrapper::getCurrentSizeForReference()
606 {
607     return m_spChart2ModelContact->GetPageSize();
608 }
609 
610 // ================================================================================
611 
612 Reference< chart2::XAxis > AxisWrapper::getAxis()
613 {
614     Reference< chart2::XAxis > xAxis;
615     try
616     {
617         sal_Int32 nDimensionIndex = 0;
618         sal_Bool  bMainAxis = sal_True;
619         AxisWrapper::getDimensionAndMainAxisBool( m_eType, nDimensionIndex, bMainAxis );
620 
621         Reference< XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() );
622         xAxis = AxisHelper::getAxis( nDimensionIndex, bMainAxis, xDiagram );
623         if( !xAxis.is() )
624         {
625             xAxis = AxisHelper::createAxis( nDimensionIndex, bMainAxis, xDiagram, m_spChart2ModelContact->m_xContext );
626             Reference< beans::XPropertySet > xProp( xAxis, uno::UNO_QUERY );
627             if( xProp.is() )
628                 xProp->setPropertyValue( C2U( "Show" ), uno::makeAny( sal_False ) );
629         }
630     }
631     catch( uno::Exception & ex )
632     {
633         ASSERT_EXCEPTION( ex );
634     }
635     return xAxis;
636 }
637 
638 // WrappedPropertySet
639 Reference< beans::XPropertySet > AxisWrapper::getInnerPropertySet()
640 {
641     return Reference< beans::XPropertySet >( this->getAxis(), uno::UNO_QUERY );
642 }
643 
644 const Sequence< beans::Property >& AxisWrapper::getPropertySequence()
645 {
646     return *StaticAxisWrapperPropertyArray::get();
647 }
648 
649 const std::vector< WrappedProperty* > AxisWrapper::createWrappedProperties()
650 {
651     ::std::vector< ::chart::WrappedProperty* > aWrappedProperties;
652 
653     aWrappedProperties.push_back( new WrappedTextRotationProperty() );
654     aWrappedProperties.push_back( new WrappedProperty( C2U( "Marks" ), C2U( "MajorTickmarks" ) ) );
655     aWrappedProperties.push_back( new WrappedProperty( C2U( "HelpMarks" ), C2U( "MinorTickmarks" ) ) );
656     aWrappedProperties.push_back( new WrappedProperty( C2U( "TextCanOverlap" ), C2U( "TextOverlap" ) ) );
657     aWrappedProperties.push_back( new WrappedProperty( C2U( "ArrangeOrder" ), C2U( "ArrangeOrder" ) ) );
658     aWrappedProperties.push_back( new WrappedProperty( C2U( "Visible" ), C2U( "Show" ) ) );
659     aWrappedProperties.push_back( new WrappedDirectStateProperty( C2U( "DisplayLabels" ), C2U( "DisplayLabels" ) ) );
660     aWrappedProperties.push_back( new WrappedDirectStateProperty( C2U( "TextBreak" ), C2U( "TextBreak" ) ) );
661     WrappedNumberFormatProperty* pWrappedNumberFormatProperty = new WrappedNumberFormatProperty( m_spChart2ModelContact );
662     aWrappedProperties.push_back( pWrappedNumberFormatProperty );
663     aWrappedProperties.push_back( new WrappedLinkNumberFormatProperty(pWrappedNumberFormatProperty) );
664     aWrappedProperties.push_back( new WrappedProperty( C2U( "StackedText" ), C2U( "StackCharacters" ) ) );
665     aWrappedProperties.push_back( new WrappedDirectStateProperty( C2U( "CrossoverPosition" ), C2U( "CrossoverPosition" ) ) );
666     {
667         WrappedGapwidthProperty* pWrappedGapwidthProperty( new WrappedGapwidthProperty( m_spChart2ModelContact ) );
668         WrappedBarOverlapProperty* pWrappedBarOverlapProperty( new WrappedBarOverlapProperty( m_spChart2ModelContact ) );
669         sal_Int32 nDimensionIndex = 0;
670         sal_Bool  bMainAxis = sal_True;
671         sal_Int32 nAxisIndex = 0;
672         AxisWrapper::getDimensionAndMainAxisBool( m_eType, nDimensionIndex, bMainAxis );
673         if( !bMainAxis )
674             nAxisIndex = 1;
675         pWrappedGapwidthProperty->setDimensionAndAxisIndex( nDimensionIndex, nAxisIndex );
676         pWrappedBarOverlapProperty->setDimensionAndAxisIndex( nDimensionIndex, nAxisIndex );
677         aWrappedProperties.push_back( pWrappedGapwidthProperty );
678         aWrappedProperties.push_back( pWrappedBarOverlapProperty );
679     }
680 
681     WrappedScaleProperty::addWrappedProperties( aWrappedProperties, m_spChart2ModelContact );
682 
683     WrappedCharacterHeightProperty::addWrappedProperties( aWrappedProperties, this );
684     WrappedScaleTextProperties::addWrappedProperties( aWrappedProperties, m_spChart2ModelContact );
685 
686     return aWrappedProperties;
687 }
688 
689 // ================================================================================
690 
691 Sequence< OUString > AxisWrapper::getSupportedServiceNames_Static()
692 {
693     Sequence< OUString > aServices( 3 );
694     aServices[ 0 ] = C2U( "com.sun.star.chart.ChartAxis" );
695     aServices[ 1 ] = C2U( "com.sun.star.xml.UserDefinedAttributeSupplier" );
696     aServices[ 2 ] = C2U( "com.sun.star.style.CharacterProperties" );
697 //     aServices[ 3 ] = C2U( "com.sun.star.beans.PropertySet" );
698 //     aServices[ 4 ] = C2U( "com.sun.star.drawing.LineProperties" );
699 
700     return aServices;
701 }
702 
703 // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
704 APPHELPER_XSERVICEINFO_IMPL( AxisWrapper, lcl_aServiceName );
705 
706 } //  namespace wrapper
707 } //  namespace chart
708