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