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