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_chart2.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 ()__anon5e7b04f00111::StaticAxisWrapperPropertyArray_Initializer353     Sequence< Property >* operator()()
354     {
355         static Sequence< Property > aPropSeq( lcl_GetPropertySequence() );
356         return &aPropSeq;
357     }
358 
359 private:
lcl_GetPropertySequence__anon5e7b04f00111::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() throw (uno::RuntimeException)
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() throw (uno::RuntimeException)
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() throw (uno::RuntimeException)
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     throw (uno::RuntimeException)
482 {
483     awt::Point aResult( m_spChart2ModelContact->GetAxisPosition( this->getAxis() ) );
484     return aResult;
485 }
486 
setPosition(const awt::Point &)487 void SAL_CALL AxisWrapper::setPosition( const awt::Point& /*aPosition*/ )
488     throw (uno::RuntimeException)
489 {
490     OSL_ENSURE( false, "trying to set position of Axis" );
491 }
492 
getSize()493 awt::Size SAL_CALL AxisWrapper::getSize()
494     throw (uno::RuntimeException)
495 {
496     awt::Size aSize( m_spChart2ModelContact->GetAxisSize( this->getAxis() ) );
497     return aSize;
498 }
499 
setSize(const awt::Size &)500 void SAL_CALL AxisWrapper::setSize( const awt::Size& /*aSize*/ )
501     throw (beans::PropertyVetoException,
502            uno::RuntimeException)
503 {
504     OSL_ENSURE( false, "trying to set size of Axis" );
505 }
506 
507 // ____ XShapeDescriptor (base of XShape) ____
getShapeType()508 OUString SAL_CALL AxisWrapper::getShapeType()
509     throw (uno::RuntimeException)
510 {
511     return C2U( "com.sun.star.chart.ChartAxis" );
512 }
513 
514 // ____ XNumberFormatsSupplier ____
getNumberFormatSettings()515 uno::Reference< beans::XPropertySet > SAL_CALL AxisWrapper::getNumberFormatSettings()
516     throw (uno::RuntimeException)
517 {
518     Reference< util::XNumberFormatsSupplier > xNumSuppl( m_spChart2ModelContact->getChartModel(), uno::UNO_QUERY );
519     if( xNumSuppl.is() )
520         return xNumSuppl->getNumberFormatSettings();
521 
522     return uno::Reference< beans::XPropertySet >();
523 }
524 
getNumberFormats()525 uno::Reference< util::XNumberFormats > SAL_CALL AxisWrapper::getNumberFormats()
526     throw (uno::RuntimeException)
527 {
528     Reference< util::XNumberFormatsSupplier > xNumSuppl( m_spChart2ModelContact->getChartModel(), uno::UNO_QUERY );
529     if( xNumSuppl.is() )
530         return xNumSuppl->getNumberFormats();
531 
532     return uno::Reference< util::XNumberFormats >();
533 }
534 
getDimensionAndMainAxisBool(tAxisType eType,sal_Int32 & rnDimensionIndex,sal_Bool & rbMainAxis)535 void AxisWrapper::getDimensionAndMainAxisBool( tAxisType eType, sal_Int32& rnDimensionIndex, sal_Bool& rbMainAxis )
536 {
537     switch( eType )
538     {
539         case X_AXIS:
540             rnDimensionIndex = 0; rbMainAxis = sal_True; break;
541         case Y_AXIS:
542             rnDimensionIndex = 1; rbMainAxis = sal_True; break;
543         case Z_AXIS:
544             rnDimensionIndex = 2; rbMainAxis = sal_True; break;
545         case SECOND_X_AXIS:
546             rnDimensionIndex = 0; rbMainAxis = sal_False; break;
547         case SECOND_Y_AXIS:
548             rnDimensionIndex = 1; rbMainAxis = sal_False; break;
549     }
550 }
551 
552 // ____ XComponent ____
dispose()553 void SAL_CALL AxisWrapper::dispose()
554     throw (uno::RuntimeException)
555 {
556     Reference< uno::XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) );
557     m_aEventListenerContainer.disposeAndClear( lang::EventObject( xSource ) );
558 
559     DisposeHelper::DisposeAndClear( m_xAxisTitle );
560     DisposeHelper::DisposeAndClear( m_xMajorGrid );
561     DisposeHelper::DisposeAndClear( m_xMinorGrid );
562 
563     clearWrappedPropertySet();
564 }
565 
addEventListener(const Reference<lang::XEventListener> & xListener)566 void SAL_CALL AxisWrapper::addEventListener(
567     const Reference< lang::XEventListener >& xListener )
568     throw (uno::RuntimeException)
569 {
570 	m_aEventListenerContainer.addInterface( xListener );
571 }
572 
removeEventListener(const Reference<lang::XEventListener> & aListener)573 void SAL_CALL AxisWrapper::removeEventListener(
574     const Reference< lang::XEventListener >& aListener )
575     throw (uno::RuntimeException)
576 {
577 	m_aEventListenerContainer.removeInterface( aListener );
578 }
579 
580 // ================================================================================
581 
582 //ReferenceSizePropertyProvider
updateReferenceSize()583 void AxisWrapper::updateReferenceSize()
584 {
585     Reference< beans::XPropertySet > xProp( this->getAxis(), uno::UNO_QUERY );
586     if( xProp.is() )
587     {
588         if( xProp->getPropertyValue( C2U("ReferencePageSize") ).hasValue() )
589             xProp->setPropertyValue( C2U("ReferencePageSize"), uno::makeAny(
590             m_spChart2ModelContact->GetPageSize() ));
591     }
592 }
getReferenceSize()593 Any AxisWrapper::getReferenceSize()
594 {
595     Any aRet;
596     Reference< beans::XPropertySet > xProp( this->getAxis(), uno::UNO_QUERY );
597     if( xProp.is() )
598         aRet = xProp->getPropertyValue( C2U("ReferencePageSize") );
599     return aRet;
600 }
getCurrentSizeForReference()601 awt::Size AxisWrapper::getCurrentSizeForReference()
602 {
603     return m_spChart2ModelContact->GetPageSize();
604 }
605 
606 // ================================================================================
607 
getAxis()608 Reference< chart2::XAxis > AxisWrapper::getAxis()
609 {
610     Reference< chart2::XAxis > xAxis;
611     try
612     {
613         sal_Int32 nDimensionIndex = 0;
614         sal_Bool  bMainAxis = sal_True;
615         AxisWrapper::getDimensionAndMainAxisBool( m_eType, nDimensionIndex, bMainAxis );
616 
617         Reference< XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() );
618         xAxis = AxisHelper::getAxis( nDimensionIndex, bMainAxis, xDiagram );
619         if( !xAxis.is() )
620         {
621             xAxis = AxisHelper::createAxis( nDimensionIndex, bMainAxis, xDiagram, m_spChart2ModelContact->m_xContext );
622             Reference< beans::XPropertySet > xProp( xAxis, uno::UNO_QUERY );
623             if( xProp.is() )
624                 xProp->setPropertyValue( C2U( "Show" ), uno::makeAny( sal_False ) );
625         }
626     }
627     catch( uno::Exception & ex )
628     {
629         ASSERT_EXCEPTION( ex );
630     }
631     return xAxis;
632 }
633 
634 // WrappedPropertySet
getInnerPropertySet()635 Reference< beans::XPropertySet > AxisWrapper::getInnerPropertySet()
636 {
637     return Reference< beans::XPropertySet >( this->getAxis(), uno::UNO_QUERY );
638 }
639 
getPropertySequence()640 const Sequence< beans::Property >& AxisWrapper::getPropertySequence()
641 {
642     return *StaticAxisWrapperPropertyArray::get();
643 }
644 
createWrappedProperties()645 const std::vector< WrappedProperty* > AxisWrapper::createWrappedProperties()
646 {
647     ::std::vector< ::chart::WrappedProperty* > aWrappedProperties;
648 
649     aWrappedProperties.push_back( new WrappedTextRotationProperty() );
650     aWrappedProperties.push_back( new WrappedProperty( C2U( "Marks" ), C2U( "MajorTickmarks" ) ) );
651     aWrappedProperties.push_back( new WrappedProperty( C2U( "HelpMarks" ), C2U( "MinorTickmarks" ) ) );
652     aWrappedProperties.push_back( new WrappedProperty( C2U( "TextCanOverlap" ), C2U( "TextOverlap" ) ) );
653     aWrappedProperties.push_back( new WrappedProperty( C2U( "ArrangeOrder" ), C2U( "ArrangeOrder" ) ) );
654     aWrappedProperties.push_back( new WrappedProperty( C2U( "Visible" ), C2U( "Show" ) ) );
655     aWrappedProperties.push_back( new WrappedDirectStateProperty( C2U( "DisplayLabels" ), C2U( "DisplayLabels" ) ) );
656     aWrappedProperties.push_back( new WrappedDirectStateProperty( C2U( "TextBreak" ), C2U( "TextBreak" ) ) );
657     WrappedNumberFormatProperty* pWrappedNumberFormatProperty = new WrappedNumberFormatProperty( m_spChart2ModelContact );
658     aWrappedProperties.push_back( pWrappedNumberFormatProperty );
659     aWrappedProperties.push_back( new WrappedLinkNumberFormatProperty(pWrappedNumberFormatProperty) );
660     aWrappedProperties.push_back( new WrappedProperty( C2U( "StackedText" ), C2U( "StackCharacters" ) ) );
661     aWrappedProperties.push_back( new WrappedDirectStateProperty( C2U( "CrossoverPosition" ), C2U( "CrossoverPosition" ) ) );
662     {
663         WrappedGapwidthProperty* pWrappedGapwidthProperty( new WrappedGapwidthProperty( m_spChart2ModelContact ) );
664         WrappedBarOverlapProperty* pWrappedBarOverlapProperty( new WrappedBarOverlapProperty( m_spChart2ModelContact ) );
665         sal_Int32 nDimensionIndex = 0;
666         sal_Bool  bMainAxis = sal_True;
667         sal_Int32 nAxisIndex = 0;
668         AxisWrapper::getDimensionAndMainAxisBool( m_eType, nDimensionIndex, bMainAxis );
669         if( !bMainAxis )
670             nAxisIndex = 1;
671         pWrappedGapwidthProperty->setDimensionAndAxisIndex( nDimensionIndex, nAxisIndex );
672         pWrappedBarOverlapProperty->setDimensionAndAxisIndex( nDimensionIndex, nAxisIndex );
673         aWrappedProperties.push_back( pWrappedGapwidthProperty );
674         aWrappedProperties.push_back( pWrappedBarOverlapProperty );
675     }
676 
677     WrappedScaleProperty::addWrappedProperties( aWrappedProperties, m_spChart2ModelContact );
678 
679     WrappedCharacterHeightProperty::addWrappedProperties( aWrappedProperties, this );
680     WrappedScaleTextProperties::addWrappedProperties( aWrappedProperties, m_spChart2ModelContact );
681 
682     return aWrappedProperties;
683 }
684 
685 // ================================================================================
686 
getSupportedServiceNames_Static()687 Sequence< OUString > AxisWrapper::getSupportedServiceNames_Static()
688 {
689     Sequence< OUString > aServices( 3 );
690     aServices[ 0 ] = C2U( "com.sun.star.chart.ChartAxis" );
691     aServices[ 1 ] = C2U( "com.sun.star.xml.UserDefinedAttributeSupplier" );
692     aServices[ 2 ] = C2U( "com.sun.star.style.CharacterProperties" );
693 //     aServices[ 3 ] = C2U( "com.sun.star.beans.PropertySet" );
694 //     aServices[ 4 ] = C2U( "com.sun.star.drawing.LineProperties" );
695 
696     return aServices;
697 }
698 
699 // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
700 APPHELPER_XSERVICEINFO_IMPL( AxisWrapper, lcl_aServiceName );
701 
702 } //  namespace wrapper
703 } //  namespace chart
704