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