fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / chart2 / source / controller / chartapiwrapper / AxisWrapper.cxx
blobee32f16fbd46f9730a5308d461e3a161abd89835
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "AxisWrapper.hxx"
21 #include "AxisHelper.hxx"
22 #include "TitleHelper.hxx"
23 #include "Chart2ModelContact.hxx"
24 #include "ContainerHelper.hxx"
25 #include "macros.hxx"
26 #include "WrappedDirectStateProperty.hxx"
27 #include "GridWrapper.hxx"
28 #include "TitleWrapper.hxx"
29 #include "DisposeHelper.hxx"
30 #include <unonames.hxx>
32 #include <cppuhelper/supportsservice.hxx>
33 #include <comphelper/InlineContainer.hxx>
34 #include <com/sun/star/beans/PropertyAttribute.hpp>
35 #include <com/sun/star/chart/ChartAxisArrangeOrderType.hpp>
36 #include <com/sun/star/chart/ChartAxisPosition.hpp>
37 #include <com/sun/star/chart/ChartAxisLabelPosition.hpp>
38 #include <com/sun/star/chart/ChartAxisMarkPosition.hpp>
40 #include "CharacterProperties.hxx"
41 #include "LinePropertiesHelper.hxx"
42 #include "UserDefinedProperties.hxx"
43 #include "WrappedCharacterHeightProperty.hxx"
44 #include "WrappedTextRotationProperty.hxx"
45 #include "WrappedGapwidthProperty.hxx"
46 #include "WrappedScaleProperty.hxx"
47 #include "WrappedDefaultProperty.hxx"
48 #include "WrappedNumberFormatProperty.hxx"
49 #include "WrappedScaleTextProperties.hxx"
51 #include <algorithm>
52 #include <rtl/ustrbuf.hxx>
53 #include <rtl/math.hxx>
55 using namespace ::com::sun::star;
56 using namespace ::com::sun::star::chart2;
57 using namespace ::chart::ContainerHelper;
59 using ::com::sun::star::beans::Property;
60 using ::osl::MutexGuard;
61 using ::com::sun::star::uno::Reference;
62 using ::com::sun::star::uno::Sequence;
63 using ::com::sun::star::uno::Any;
65 namespace
67 static const char lcl_aServiceName[] = "com.sun.star.comp.chart.Axis";
69 enum
71 PROP_AXIS_MAX,
72 PROP_AXIS_MIN,
73 PROP_AXIS_STEPMAIN,
74 PROP_AXIS_STEPHELP, //deprecated property use 'StepHelpCount' instead
75 PROP_AXIS_STEPHELP_COUNT,
76 PROP_AXIS_AUTO_MAX,
77 PROP_AXIS_AUTO_MIN,
78 PROP_AXIS_AUTO_STEPMAIN,
79 PROP_AXIS_AUTO_STEPHELP,
80 PROP_AXIS_TYPE,
81 PROP_AXIS_TIME_INCREMENT,
82 PROP_AXIS_EXPLICIT_TIME_INCREMENT,
83 PROP_AXIS_LOGARITHMIC,
84 PROP_AXIS_REVERSEDIRECTION,
85 PROP_AXIS_VISIBLE,
86 PROP_AXIS_CROSSOVER_POSITION,
87 PROP_AXIS_CROSSOVER_VALUE,
88 PROP_AXIS_ORIGIN,
89 PROP_AXIS_AUTO_ORIGIN,
90 PROP_AXIS_MARKS,
91 PROP_AXIS_HELPMARKS,
92 PROP_AXIS_MARK_POSITION,
93 PROP_AXIS_DISPLAY_LABELS,
94 PROP_AXIS_NUMBERFORMAT,
95 PROP_AXIS_LINK_NUMBERFORMAT_TO_SOURCE,
96 PROP_AXIS_LABEL_POSITION,
97 PROP_AXIS_TEXT_ROTATION,
98 PROP_AXIS_ARRANGE_ORDER,
99 PROP_AXIS_TEXTBREAK,
100 PROP_AXIS_CAN_OVERLAP,
101 PROP_AXIS_STACKEDTEXT,
102 PROP_AXIS_OVERLAP,
103 PROP_AXIS_GAP_WIDTH,
104 PROP_AXIS_DISPLAY_UNITS,
105 PROP_AXIS_BUILTINUNIT
108 void lcl_AddPropertiesToVector(
109 ::std::vector< Property > & rOutProperties )
111 //Properties for scaling:
112 rOutProperties.push_back(
113 Property( "Max",
114 PROP_AXIS_MAX,
115 cppu::UnoType<double>::get(),
116 beans::PropertyAttribute::BOUND
117 | beans::PropertyAttribute::MAYBEVOID ));
119 rOutProperties.push_back(
120 Property( "Min",
121 PROP_AXIS_MIN,
122 cppu::UnoType<double>::get(),
123 beans::PropertyAttribute::BOUND
124 | beans::PropertyAttribute::MAYBEVOID ));
126 rOutProperties.push_back(
127 Property( "StepMain",
128 PROP_AXIS_STEPMAIN,
129 cppu::UnoType<double>::get(),
130 beans::PropertyAttribute::BOUND
131 | beans::PropertyAttribute::MAYBEVOID ));
133 rOutProperties.push_back(
134 Property( "StepHelpCount",
135 PROP_AXIS_STEPHELP_COUNT,
136 cppu::UnoType<sal_Int32>::get(),
137 beans::PropertyAttribute::BOUND
138 | beans::PropertyAttribute::MAYBEVOID ));
140 //deprecated property use 'StepHelpCount' instead
141 rOutProperties.push_back(
142 Property( "StepHelp",
143 PROP_AXIS_STEPHELP,
144 cppu::UnoType<double>::get(),
145 beans::PropertyAttribute::BOUND
146 | beans::PropertyAttribute::MAYBEVOID ));
148 rOutProperties.push_back(
149 Property( "AutoMax",
150 PROP_AXIS_AUTO_MAX,
151 cppu::UnoType<bool>::get(),
152 //#i111967# no PropertyChangeEvent is fired on change so far
153 beans::PropertyAttribute::MAYBEDEFAULT ));
155 rOutProperties.push_back(
156 Property( "AutoMin",
157 PROP_AXIS_AUTO_MIN,
158 cppu::UnoType<bool>::get(),
159 //#i111967# no PropertyChangeEvent is fired on change so far
160 beans::PropertyAttribute::MAYBEDEFAULT ));
162 rOutProperties.push_back(
163 Property( "AutoStepMain",
164 PROP_AXIS_AUTO_STEPMAIN,
165 cppu::UnoType<bool>::get(),
166 //#i111967# no PropertyChangeEvent is fired on change so far
167 beans::PropertyAttribute::MAYBEDEFAULT ));
169 rOutProperties.push_back(
170 Property( "AutoStepHelp",
171 PROP_AXIS_AUTO_STEPHELP,
172 cppu::UnoType<bool>::get(),
173 //#i111967# no PropertyChangeEvent is fired on change so far
174 beans::PropertyAttribute::MAYBEDEFAULT ));
176 rOutProperties.push_back(
177 Property( "AxisType",
178 PROP_AXIS_TYPE,
179 cppu::UnoType<sal_Int32>::get(), //type com::sun::star::chart::ChartAxisType
180 //#i111967# no PropertyChangeEvent is fired on change so far
181 beans::PropertyAttribute::MAYBEDEFAULT ));
183 rOutProperties.push_back(
184 Property( "TimeIncrement",
185 PROP_AXIS_TIME_INCREMENT,
186 cppu::UnoType<com::sun::star::chart::TimeIncrement>::get(),
187 //#i111967# no PropertyChangeEvent is fired on change so far
188 beans::PropertyAttribute::MAYBEVOID ));
190 rOutProperties.push_back(
191 Property( "ExplicitTimeIncrement",
192 PROP_AXIS_EXPLICIT_TIME_INCREMENT,
193 cppu::UnoType<com::sun::star::chart::TimeIncrement>::get(),
194 beans::PropertyAttribute::READONLY |
195 beans::PropertyAttribute::MAYBEVOID ));
197 rOutProperties.push_back(
198 Property( "Logarithmic",
199 PROP_AXIS_LOGARITHMIC,
200 cppu::UnoType<bool>::get(),
201 //#i111967# no PropertyChangeEvent is fired on change so far
202 beans::PropertyAttribute::MAYBEDEFAULT ));
204 rOutProperties.push_back(
205 Property( "ReverseDirection",
206 PROP_AXIS_REVERSEDIRECTION,
207 cppu::UnoType<bool>::get(),
208 //#i111967# no PropertyChangeEvent is fired on change so far
209 beans::PropertyAttribute::MAYBEDEFAULT ));
211 //todo: this property is missing in the API
212 rOutProperties.push_back(
213 Property( "Visible",
214 PROP_AXIS_VISIBLE,
215 cppu::UnoType<bool>::get(),
216 beans::PropertyAttribute::BOUND
217 | beans::PropertyAttribute::MAYBEDEFAULT ));
219 rOutProperties.push_back(
220 Property( "CrossoverPosition",
221 PROP_AXIS_CROSSOVER_POSITION,
222 cppu::UnoType<com::sun::star::chart::ChartAxisPosition>::get(),
223 beans::PropertyAttribute::MAYBEDEFAULT ));
225 rOutProperties.push_back(
226 Property( "CrossoverValue",
227 PROP_AXIS_CROSSOVER_VALUE,
228 cppu::UnoType<double>::get(),
229 beans::PropertyAttribute::MAYBEVOID ));
231 rOutProperties.push_back(
232 Property( "Origin",
233 PROP_AXIS_ORIGIN,
234 cppu::UnoType<double>::get(),
235 beans::PropertyAttribute::BOUND
236 | beans::PropertyAttribute::MAYBEVOID ));
238 rOutProperties.push_back(
239 Property( "AutoOrigin",
240 PROP_AXIS_AUTO_ORIGIN,
241 cppu::UnoType<bool>::get(),
242 //#i111967# no PropertyChangeEvent is fired on change so far
243 beans::PropertyAttribute::MAYBEDEFAULT ));
245 //Properties for interval marks:
246 rOutProperties.push_back(
247 Property( "Marks",
248 PROP_AXIS_MARKS,
249 cppu::UnoType<sal_Int32>::get(),
250 beans::PropertyAttribute::BOUND
251 | beans::PropertyAttribute::MAYBEDEFAULT ));
253 rOutProperties.push_back(
254 Property( "HelpMarks",
255 PROP_AXIS_HELPMARKS,
256 cppu::UnoType<sal_Int32>::get(),
257 beans::PropertyAttribute::BOUND
258 | beans::PropertyAttribute::MAYBEDEFAULT ));
260 rOutProperties.push_back(
261 Property( "MarkPosition",
262 PROP_AXIS_MARK_POSITION,
263 cppu::UnoType<com::sun::star::chart::ChartAxisMarkPosition>::get(),
264 beans::PropertyAttribute::MAYBEDEFAULT ));
266 //Properties for labels:
267 rOutProperties.push_back(
268 Property( "DisplayLabels",
269 PROP_AXIS_DISPLAY_LABELS,
270 cppu::UnoType<bool>::get(),
271 beans::PropertyAttribute::BOUND
272 | beans::PropertyAttribute::MAYBEDEFAULT ));
274 rOutProperties.push_back(
275 Property( CHART_UNONAME_NUMFMT,
276 PROP_AXIS_NUMBERFORMAT,
277 cppu::UnoType<sal_Int32>::get(),
278 beans::PropertyAttribute::BOUND
279 | beans::PropertyAttribute::MAYBEDEFAULT ));
281 rOutProperties.push_back(
282 Property( CHART_UNONAME_LINK_TO_SRC_NUMFMT,
283 PROP_AXIS_LINK_NUMBERFORMAT_TO_SOURCE,
284 cppu::UnoType<bool>::get(),
285 beans::PropertyAttribute::BOUND
286 | beans::PropertyAttribute::MAYBEDEFAULT ));
288 rOutProperties.push_back(
289 Property( "LabelPosition",
290 PROP_AXIS_LABEL_POSITION,
291 cppu::UnoType<com::sun::star::chart::ChartAxisLabelPosition>::get(),
292 beans::PropertyAttribute::MAYBEDEFAULT ));
294 rOutProperties.push_back(
295 Property( "TextRotation",
296 PROP_AXIS_TEXT_ROTATION,
297 cppu::UnoType<sal_Int32>::get(),
298 beans::PropertyAttribute::BOUND
299 | beans::PropertyAttribute::MAYBEDEFAULT ));
301 rOutProperties.push_back(
302 Property( "ArrangeOrder",
303 PROP_AXIS_ARRANGE_ORDER,
304 cppu::UnoType<com::sun::star::chart::ChartAxisArrangeOrderType>::get(),
305 beans::PropertyAttribute::BOUND
306 | beans::PropertyAttribute::MAYBEDEFAULT ));
308 rOutProperties.push_back(
309 Property( "TextBreak",
310 PROP_AXIS_TEXTBREAK,
311 cppu::UnoType<bool>::get(),
312 beans::PropertyAttribute::BOUND
313 | beans::PropertyAttribute::MAYBEDEFAULT ));
315 rOutProperties.push_back(
316 Property( "TextCanOverlap",
317 PROP_AXIS_CAN_OVERLAP,
318 cppu::UnoType<bool>::get(),
319 beans::PropertyAttribute::BOUND
320 | beans::PropertyAttribute::MAYBEDEFAULT ));
322 rOutProperties.push_back(
323 Property( "StackedText",
324 PROP_AXIS_STACKEDTEXT,
325 cppu::UnoType<bool>::get(),
326 beans::PropertyAttribute::BOUND
327 | beans::PropertyAttribute::MAYBEDEFAULT ));
329 // Properties related to bar charts:
330 rOutProperties.push_back(
331 Property( "Overlap",
332 PROP_AXIS_OVERLAP,
333 cppu::UnoType<sal_Int32>::get(),
334 //#i111967# no PropertyChangeEvent is fired on change so far
335 beans::PropertyAttribute::MAYBEDEFAULT ));
337 rOutProperties.push_back(
338 Property( "GapWidth",
339 PROP_AXIS_GAP_WIDTH,
340 cppu::UnoType<sal_Int32>::get(),
341 //#i111967# no PropertyChangeEvent is fired on change so far
342 beans::PropertyAttribute::MAYBEDEFAULT ));
344 //Properties for display units:
345 rOutProperties.push_back(
346 Property( "DisplayUnits",
347 PROP_AXIS_DISPLAY_UNITS,
348 cppu::UnoType<bool>::get(),
349 beans::PropertyAttribute::BOUND
350 | beans::PropertyAttribute::MAYBEDEFAULT ));
352 //Properties for labels:
353 rOutProperties.push_back(
354 Property( "BuiltInUnit",
355 PROP_AXIS_BUILTINUNIT,
356 cppu::UnoType<OUString>::get(),
357 beans::PropertyAttribute::BOUND
358 | beans::PropertyAttribute::MAYBEDEFAULT ));
361 struct StaticAxisWrapperPropertyArray_Initializer
363 Sequence< Property >* operator()()
365 static Sequence< Property > aPropSeq( lcl_GetPropertySequence() );
366 return &aPropSeq;
369 private:
370 static Sequence< Property > lcl_GetPropertySequence()
372 ::std::vector< ::com::sun::star::beans::Property > aProperties;
373 lcl_AddPropertiesToVector( aProperties );
374 ::chart::CharacterProperties::AddPropertiesToVector( aProperties );
375 ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties );
376 ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
377 ::chart::wrapper::WrappedScaleTextProperties::addProperties( aProperties );
379 ::std::sort( aProperties.begin(), aProperties.end(),
380 ::chart::PropertyNameLess() );
382 return ::chart::ContainerHelper::ContainerToSequence( aProperties );
386 struct StaticAxisWrapperPropertyArray : public rtl::StaticAggregate< Sequence< Property >, StaticAxisWrapperPropertyArray_Initializer >
390 } // anonymous namespace
392 namespace chart
394 namespace wrapper
397 AxisWrapper::AxisWrapper(
398 tAxisType eType, ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) :
399 m_spChart2ModelContact( spChart2ModelContact ),
400 m_aEventListenerContainer( m_aMutex ),
401 m_eType( eType )
405 AxisWrapper::~AxisWrapper()
409 // ____ chart::XAxis ____
410 Reference< beans::XPropertySet > SAL_CALL AxisWrapper::getAxisTitle() throw (uno::RuntimeException, std::exception)
412 if( !m_xAxisTitle.is() )
414 TitleHelper::eTitleType eTitleType( TitleHelper::X_AXIS_TITLE );
415 switch( m_eType )
417 case X_AXIS:
418 eTitleType = TitleHelper::X_AXIS_TITLE;
419 break;
420 case Y_AXIS:
421 eTitleType = TitleHelper::Y_AXIS_TITLE;
422 break;
423 case Z_AXIS:
424 eTitleType = TitleHelper::Z_AXIS_TITLE;
425 break;
426 case SECOND_X_AXIS:
427 eTitleType = TitleHelper::SECONDARY_X_AXIS_TITLE;
428 break;
429 case SECOND_Y_AXIS:
430 eTitleType = TitleHelper::SECONDARY_Y_AXIS_TITLE;
431 break;
432 default:
433 return 0;
435 m_xAxisTitle = new TitleWrapper( eTitleType, m_spChart2ModelContact );
437 return m_xAxisTitle;
439 Reference< beans::XPropertySet > SAL_CALL AxisWrapper::getMajorGrid() throw (uno::RuntimeException, std::exception)
441 if( !m_xMajorGrid.is() )
443 GridWrapper::tGridType eGridType( GridWrapper::X_MAJOR_GRID );
444 switch( m_eType )
446 case X_AXIS:
447 eGridType = GridWrapper::X_MAJOR_GRID;
448 break;
449 case Y_AXIS:
450 eGridType = GridWrapper::Y_MAJOR_GRID;
451 break;
452 case Z_AXIS:
453 eGridType = GridWrapper::Z_MAJOR_GRID;
454 break;
455 default:
456 return 0;
458 m_xMajorGrid = new GridWrapper( eGridType, m_spChart2ModelContact );
460 return m_xMajorGrid;
462 Reference< beans::XPropertySet > SAL_CALL AxisWrapper::getMinorGrid() throw (uno::RuntimeException, std::exception)
464 if( !m_xMinorGrid.is() )
466 GridWrapper::tGridType eGridType( GridWrapper::X_MAJOR_GRID );
467 switch( m_eType )
469 case X_AXIS:
470 eGridType = GridWrapper::X_MINOR_GRID;
471 break;
472 case Y_AXIS:
473 eGridType = GridWrapper::Y_MINOR_GRID;
474 break;
475 case Z_AXIS:
476 eGridType = GridWrapper::Z_MINOR_GRID;
477 break;
478 default:
479 return 0;
481 m_xMinorGrid = new GridWrapper( eGridType, m_spChart2ModelContact );
483 return m_xMinorGrid;
486 // ____ XShape ____
487 awt::Point SAL_CALL AxisWrapper::getPosition()
488 throw (uno::RuntimeException, std::exception)
490 awt::Point aResult( m_spChart2ModelContact->GetAxisPosition( this->getAxis() ) );
491 return aResult;
494 void SAL_CALL AxisWrapper::setPosition( const awt::Point& /*aPosition*/ )
495 throw (uno::RuntimeException, std::exception)
497 OSL_FAIL( "trying to set position of Axis" );
500 awt::Size SAL_CALL AxisWrapper::getSize()
501 throw (uno::RuntimeException, std::exception)
503 awt::Size aSize( m_spChart2ModelContact->GetAxisSize( this->getAxis() ) );
504 return aSize;
507 void SAL_CALL AxisWrapper::setSize( const awt::Size& /*aSize*/ )
508 throw (beans::PropertyVetoException,
509 uno::RuntimeException, std::exception)
511 OSL_FAIL( "trying to set size of Axis" );
514 // ____ XShapeDescriptor (base of XShape) ____
515 OUString SAL_CALL AxisWrapper::getShapeType()
516 throw (uno::RuntimeException, std::exception)
518 return OUString("com.sun.star.chart.ChartAxis");
521 // ____ XNumberFormatsSupplier ____
522 uno::Reference< beans::XPropertySet > SAL_CALL AxisWrapper::getNumberFormatSettings()
523 throw (uno::RuntimeException, std::exception)
525 Reference< util::XNumberFormatsSupplier > xNumSuppl( m_spChart2ModelContact->getChartModel(), uno::UNO_QUERY );
526 if( xNumSuppl.is() )
527 return xNumSuppl->getNumberFormatSettings();
529 return uno::Reference< beans::XPropertySet >();
532 uno::Reference< util::XNumberFormats > SAL_CALL AxisWrapper::getNumberFormats()
533 throw (uno::RuntimeException, std::exception)
535 Reference< util::XNumberFormatsSupplier > xNumSuppl( m_spChart2ModelContact->getChartModel(), uno::UNO_QUERY );
536 if( xNumSuppl.is() )
537 return xNumSuppl->getNumberFormats();
539 return uno::Reference< util::XNumberFormats >();
542 void AxisWrapper::getDimensionAndMainAxisBool( tAxisType eType, sal_Int32& rnDimensionIndex, bool& rbMainAxis )
544 switch( eType )
546 case X_AXIS:
547 rnDimensionIndex = 0; rbMainAxis = true; break;
548 case Y_AXIS:
549 rnDimensionIndex = 1; rbMainAxis = true; break;
550 case Z_AXIS:
551 rnDimensionIndex = 2; rbMainAxis = true; break;
552 case SECOND_X_AXIS:
553 rnDimensionIndex = 0; rbMainAxis = false; break;
554 case SECOND_Y_AXIS:
555 rnDimensionIndex = 1; rbMainAxis = false; break;
559 // ____ XComponent ____
560 void SAL_CALL AxisWrapper::dispose()
561 throw (uno::RuntimeException, std::exception)
563 Reference< uno::XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) );
564 m_aEventListenerContainer.disposeAndClear( lang::EventObject( xSource ) );
566 DisposeHelper::DisposeAndClear( m_xAxisTitle );
567 DisposeHelper::DisposeAndClear( m_xMajorGrid );
568 DisposeHelper::DisposeAndClear( m_xMinorGrid );
570 clearWrappedPropertySet();
573 void SAL_CALL AxisWrapper::addEventListener(
574 const Reference< lang::XEventListener >& xListener )
575 throw (uno::RuntimeException, std::exception)
577 m_aEventListenerContainer.addInterface( xListener );
580 void SAL_CALL AxisWrapper::removeEventListener(
581 const Reference< lang::XEventListener >& aListener )
582 throw (uno::RuntimeException, std::exception)
584 m_aEventListenerContainer.removeInterface( aListener );
587 //ReferenceSizePropertyProvider
588 void AxisWrapper::updateReferenceSize()
590 Reference< beans::XPropertySet > xProp( this->getAxis(), uno::UNO_QUERY );
591 if( xProp.is() )
593 if( xProp->getPropertyValue("ReferencePageSize").hasValue() )
594 xProp->setPropertyValue("ReferencePageSize", uno::makeAny(
595 m_spChart2ModelContact->GetPageSize() ));
598 Any AxisWrapper::getReferenceSize()
600 Any aRet;
601 Reference< beans::XPropertySet > xProp( this->getAxis(), uno::UNO_QUERY );
602 if( xProp.is() )
603 aRet = xProp->getPropertyValue("ReferencePageSize");
604 return aRet;
606 awt::Size AxisWrapper::getCurrentSizeForReference()
608 return m_spChart2ModelContact->GetPageSize();
611 Reference< chart2::XAxis > AxisWrapper::getAxis()
613 Reference< chart2::XAxis > xAxis;
616 sal_Int32 nDimensionIndex = 0;
617 bool bMainAxis = true;
618 AxisWrapper::getDimensionAndMainAxisBool( m_eType, nDimensionIndex, bMainAxis );
620 Reference< XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() );
621 xAxis = AxisHelper::getAxis( nDimensionIndex, bMainAxis, xDiagram );
622 if( !xAxis.is() )
624 xAxis = AxisHelper::createAxis( nDimensionIndex, bMainAxis, xDiagram, m_spChart2ModelContact->m_xContext );
625 Reference< beans::XPropertySet > xProp( xAxis, uno::UNO_QUERY );
626 if( xProp.is() )
627 xProp->setPropertyValue("Show", uno::makeAny( sal_False ) );
630 catch( const uno::Exception & ex )
632 ASSERT_EXCEPTION( ex );
634 return xAxis;
637 // WrappedPropertySet
638 Reference< beans::XPropertySet > AxisWrapper::getInnerPropertySet()
640 return Reference< beans::XPropertySet >( this->getAxis(), uno::UNO_QUERY );
643 const Sequence< beans::Property >& AxisWrapper::getPropertySequence()
645 return *StaticAxisWrapperPropertyArray::get();
648 const std::vector< WrappedProperty* > AxisWrapper::createWrappedProperties()
650 ::std::vector< ::chart::WrappedProperty* > aWrappedProperties;
652 aWrappedProperties.push_back( new WrappedTextRotationProperty() );
653 aWrappedProperties.push_back( new WrappedProperty("Marks","MajorTickmarks") );
654 aWrappedProperties.push_back( new WrappedProperty("HelpMarks","MinorTickmarks") );
655 aWrappedProperties.push_back( new WrappedProperty("TextCanOverlap","TextOverlap") );
656 aWrappedProperties.push_back( new WrappedProperty("ArrangeOrder","ArrangeOrder") );
657 aWrappedProperties.push_back( new WrappedProperty("Visible","Show") );
658 aWrappedProperties.push_back( new WrappedDirectStateProperty("DisplayLabels","DisplayLabels") );
659 aWrappedProperties.push_back( new WrappedDirectStateProperty("TextBreak","TextBreak") );
660 aWrappedProperties.push_back( new WrappedNumberFormatProperty(m_spChart2ModelContact) );
661 aWrappedProperties.push_back( new WrappedLinkNumberFormatProperty(m_spChart2ModelContact) );
662 aWrappedProperties.push_back( new WrappedProperty("StackedText","StackCharacters") );
663 aWrappedProperties.push_back( new WrappedDirectStateProperty("CrossoverPosition","CrossoverPosition") );
665 WrappedGapwidthProperty* pWrappedGapwidthProperty( new WrappedGapwidthProperty( m_spChart2ModelContact ) );
666 WrappedBarOverlapProperty* pWrappedBarOverlapProperty( new WrappedBarOverlapProperty( m_spChart2ModelContact ) );
667 sal_Int32 nDimensionIndex = 0;
668 bool bMainAxis = true;
669 sal_Int32 nAxisIndex = 0;
670 AxisWrapper::getDimensionAndMainAxisBool( m_eType, nDimensionIndex, bMainAxis );
671 if( !bMainAxis )
672 nAxisIndex = 1;
673 pWrappedGapwidthProperty->setDimensionAndAxisIndex( nDimensionIndex, nAxisIndex );
674 pWrappedBarOverlapProperty->setDimensionAndAxisIndex( nDimensionIndex, nAxisIndex );
675 aWrappedProperties.push_back( pWrappedGapwidthProperty );
676 aWrappedProperties.push_back( pWrappedBarOverlapProperty );
679 WrappedScaleProperty::addWrappedProperties( aWrappedProperties, m_spChart2ModelContact );
681 WrappedCharacterHeightProperty::addWrappedProperties( aWrappedProperties, this );
682 WrappedScaleTextProperties::addWrappedProperties( aWrappedProperties, m_spChart2ModelContact );
684 return aWrappedProperties;
687 Sequence< OUString > AxisWrapper::getSupportedServiceNames_Static()
689 Sequence< OUString > aServices( 3 );
690 aServices[ 0 ] = "com.sun.star.chart.ChartAxis";
691 aServices[ 1 ] = "com.sun.star.xml.UserDefinedAttributesSupplier";
692 aServices[ 2 ] = "com.sun.star.style.CharacterProperties";
694 return aServices;
697 // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
698 OUString SAL_CALL AxisWrapper::getImplementationName()
699 throw( css::uno::RuntimeException, std::exception )
701 return getImplementationName_Static();
704 OUString AxisWrapper::getImplementationName_Static()
706 return OUString(lcl_aServiceName);
709 sal_Bool SAL_CALL AxisWrapper::supportsService( const OUString& rServiceName )
710 throw( css::uno::RuntimeException, std::exception )
712 return cppu::supportsService(this, rServiceName);
715 css::uno::Sequence< OUString > SAL_CALL AxisWrapper::getSupportedServiceNames()
716 throw( css::uno::RuntimeException, std::exception )
718 return getSupportedServiceNames_Static();
721 } // namespace wrapper
722 } // namespace chart
724 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */