Branch data 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 : 16 : 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 : 7 : 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 [ + - ]: 7 : ::getCppuType( reinterpret_cast< const double * >(0)),
114 : : beans::PropertyAttribute::BOUND
115 [ + - ]: 7 : | beans::PropertyAttribute::MAYBEVOID ));
116 : :
117 : : rOutProperties.push_back(
118 : : Property( "Min",
119 : : PROP_AXIS_MIN,
120 [ + - ]: 7 : ::getCppuType( reinterpret_cast< const double * >(0)),
121 : : beans::PropertyAttribute::BOUND
122 [ + - ]: 7 : | beans::PropertyAttribute::MAYBEVOID ));
123 : :
124 : : rOutProperties.push_back(
125 : : Property( "StepMain",
126 : : PROP_AXIS_STEPMAIN,
127 [ + - ]: 7 : ::getCppuType( reinterpret_cast< const double * >(0)),
128 : : beans::PropertyAttribute::BOUND
129 [ + - ]: 7 : | beans::PropertyAttribute::MAYBEVOID ));
130 : :
131 : : rOutProperties.push_back(
132 : : Property( "StepHelpCount",
133 : : PROP_AXIS_STEPHELP_COUNT,
134 [ + - ]: 7 : ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)),
135 : : beans::PropertyAttribute::BOUND
136 [ + - ]: 7 : | beans::PropertyAttribute::MAYBEVOID ));
137 : :
138 : : //deprecated property use 'StepHelpCount' instead
139 : : rOutProperties.push_back(
140 : : Property( "StepHelp",
141 : : PROP_AXIS_STEPHELP,
142 [ + - ]: 7 : ::getCppuType( reinterpret_cast< const double * >(0)),
143 : : beans::PropertyAttribute::BOUND
144 [ + - ]: 7 : | beans::PropertyAttribute::MAYBEVOID ));
145 : :
146 : : rOutProperties.push_back(
147 : : Property( "AutoMax",
148 : : PROP_AXIS_AUTO_MAX,
149 : 7 : ::getBooleanCppuType(),
150 : : //#i111967# no PropertyChangeEvent is fired on change so far
151 [ + - ]: 7 : beans::PropertyAttribute::MAYBEDEFAULT ));
152 : :
153 : : rOutProperties.push_back(
154 : : Property( "AutoMin",
155 : : PROP_AXIS_AUTO_MIN,
156 : 7 : ::getBooleanCppuType(),
157 : : //#i111967# no PropertyChangeEvent is fired on change so far
158 [ + - ]: 7 : beans::PropertyAttribute::MAYBEDEFAULT ));
159 : :
160 : : rOutProperties.push_back(
161 : : Property( "AutoStepMain",
162 : : PROP_AXIS_AUTO_STEPMAIN,
163 : 7 : ::getBooleanCppuType(),
164 : : //#i111967# no PropertyChangeEvent is fired on change so far
165 [ + - ]: 7 : beans::PropertyAttribute::MAYBEDEFAULT ));
166 : :
167 : : rOutProperties.push_back(
168 : : Property( "AutoStepHelp",
169 : : PROP_AXIS_AUTO_STEPHELP,
170 : 7 : ::getBooleanCppuType(),
171 : : //#i111967# no PropertyChangeEvent is fired on change so far
172 [ + - ]: 7 : beans::PropertyAttribute::MAYBEDEFAULT ));
173 : :
174 : : rOutProperties.push_back(
175 : : Property( "AxisType",
176 : : PROP_AXIS_TYPE,
177 : 7 : ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)), //type com::sun::star::chart::ChartAxisType
178 : : //#i111967# no PropertyChangeEvent is fired on change so far
179 [ + - ]: 7 : beans::PropertyAttribute::MAYBEDEFAULT ));
180 : :
181 : : rOutProperties.push_back(
182 : : Property( "TimeIncrement",
183 : : PROP_AXIS_TIME_INCREMENT,
184 : 7 : ::getCppuType( reinterpret_cast< const ::com::sun::star::chart::TimeIncrement * >(0)),
185 : : //#i111967# no PropertyChangeEvent is fired on change so far
186 [ + - ]: 7 : beans::PropertyAttribute::MAYBEVOID ));
187 : :
188 : : rOutProperties.push_back(
189 : : Property( "ExplicitTimeIncrement",
190 : : PROP_AXIS_EXPLICIT_TIME_INCREMENT,
191 [ + - ]: 7 : ::getCppuType( reinterpret_cast< const ::com::sun::star::chart::TimeIncrement * >(0)),
192 : : beans::PropertyAttribute::READONLY |
193 [ + - ]: 7 : beans::PropertyAttribute::MAYBEVOID ));
194 : :
195 : : rOutProperties.push_back(
196 : : Property( "Logarithmic",
197 : : PROP_AXIS_LOGARITHMIC,
198 : 7 : ::getBooleanCppuType(),
199 : : //#i111967# no PropertyChangeEvent is fired on change so far
200 [ + - ]: 7 : beans::PropertyAttribute::MAYBEDEFAULT ));
201 : :
202 : : rOutProperties.push_back(
203 : : Property( "ReverseDirection",
204 : : PROP_AXIS_REVERSEDIRECTION,
205 : 7 : ::getBooleanCppuType(),
206 : : //#i111967# no PropertyChangeEvent is fired on change so far
207 [ + - ]: 7 : 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 [ + - ]: 7 : ::getBooleanCppuType(),
214 : : beans::PropertyAttribute::BOUND
215 [ + - ]: 7 : | beans::PropertyAttribute::MAYBEDEFAULT ));
216 : :
217 : : rOutProperties.push_back(
218 : : Property( "CrossoverPosition",
219 : : PROP_AXIS_CROSSOVER_POSITION,
220 : 7 : ::getCppuType( reinterpret_cast< const ::com::sun::star::chart::ChartAxisPosition * >(0)),
221 [ + - ]: 7 : beans::PropertyAttribute::MAYBEDEFAULT ));
222 : :
223 : : rOutProperties.push_back(
224 : : Property( "CrossoverValue",
225 : : PROP_AXIS_CROSSOVER_VALUE,
226 : 7 : ::getCppuType( reinterpret_cast< const double * >(0)),
227 [ + - ]: 7 : beans::PropertyAttribute::MAYBEVOID ));
228 : :
229 : :
230 : : rOutProperties.push_back(
231 : : Property( "Origin",
232 : : PROP_AXIS_ORIGIN,
233 [ + - ]: 7 : ::getCppuType( reinterpret_cast< const double * >(0)),
234 : : beans::PropertyAttribute::BOUND
235 [ + - ]: 7 : | beans::PropertyAttribute::MAYBEVOID ));
236 : :
237 : : rOutProperties.push_back(
238 : : Property( "AutoOrigin",
239 : : PROP_AXIS_AUTO_ORIGIN,
240 : 7 : ::getBooleanCppuType(),
241 : : //#i111967# no PropertyChangeEvent is fired on change so far
242 [ + - ]: 7 : beans::PropertyAttribute::MAYBEDEFAULT ));
243 : :
244 : : //Properties for interval marks:
245 : : rOutProperties.push_back(
246 : : Property( "Marks",
247 : : PROP_AXIS_MARKS,
248 [ + - ]: 7 : ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)),
249 : : beans::PropertyAttribute::BOUND
250 [ + - ]: 7 : | beans::PropertyAttribute::MAYBEDEFAULT ));
251 : :
252 : : rOutProperties.push_back(
253 : : Property( "HelpMarks",
254 : : PROP_AXIS_HELPMARKS,
255 [ + - ]: 7 : ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)),
256 : : beans::PropertyAttribute::BOUND
257 [ + - ]: 7 : | beans::PropertyAttribute::MAYBEDEFAULT ));
258 : :
259 : : rOutProperties.push_back(
260 : : Property( "MarkPosition",
261 : : PROP_AXIS_MARK_POSITION,
262 : 7 : ::getCppuType( reinterpret_cast< const ::com::sun::star::chart::ChartAxisMarkPosition * >(0)),
263 [ + - ]: 7 : beans::PropertyAttribute::MAYBEDEFAULT ));
264 : :
265 : :
266 : : //Properties for labels:
267 : : rOutProperties.push_back(
268 : : Property( "DisplayLabels",
269 : : PROP_AXIS_DISPLAY_LABELS,
270 [ + - ]: 7 : ::getBooleanCppuType(),
271 : : beans::PropertyAttribute::BOUND
272 [ + - ]: 7 : | beans::PropertyAttribute::MAYBEDEFAULT ));
273 : :
274 : : rOutProperties.push_back(
275 : : Property( "NumberFormat",
276 : : PROP_AXIS_NUMBERFORMAT,
277 [ + - ]: 7 : ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)),
278 : : beans::PropertyAttribute::BOUND
279 [ + - ]: 7 : | beans::PropertyAttribute::MAYBEDEFAULT ));
280 : :
281 : : rOutProperties.push_back(
282 : : Property( "LinkNumberFormatToSource",
283 : : PROP_AXIS_LINK_NUMBERFORMAT_TO_SOURCE,
284 [ + - ]: 7 : ::getBooleanCppuType(),
285 : : beans::PropertyAttribute::BOUND
286 [ + - ]: 7 : | beans::PropertyAttribute::MAYBEDEFAULT ));
287 : :
288 : : rOutProperties.push_back(
289 : : Property( "LabelPosition",
290 : : PROP_AXIS_LABEL_POSITION,
291 : 7 : ::getCppuType( reinterpret_cast< const ::com::sun::star::chart::ChartAxisLabelPosition * >(0)),
292 [ + - ]: 7 : beans::PropertyAttribute::MAYBEDEFAULT ));
293 : :
294 : : rOutProperties.push_back(
295 : : Property( "TextRotation",
296 : : PROP_AXIS_TEXT_ROTATION,
297 [ + - ]: 7 : ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)),
298 : : beans::PropertyAttribute::BOUND
299 [ + - ]: 7 : | beans::PropertyAttribute::MAYBEDEFAULT ));
300 : :
301 : : rOutProperties.push_back(
302 : : Property( "ArrangeOrder",
303 : : PROP_AXIS_ARRANGE_ORDER,
304 [ + - ]: 7 : ::getCppuType( reinterpret_cast< const ::com::sun::star::chart::ChartAxisArrangeOrderType * >(0)),
305 : : beans::PropertyAttribute::BOUND
306 [ + - ]: 7 : | beans::PropertyAttribute::MAYBEDEFAULT ));
307 : :
308 : : rOutProperties.push_back(
309 : : Property( "TextBreak",
310 : : PROP_AXIS_TEXTBREAK,
311 [ + - ]: 7 : ::getBooleanCppuType(),
312 : : beans::PropertyAttribute::BOUND
313 [ + - ]: 7 : | beans::PropertyAttribute::MAYBEDEFAULT ));
314 : :
315 : : rOutProperties.push_back(
316 : : Property( "TextCanOverlap",
317 : : PROP_AXIS_CAN_OVERLAP,
318 [ + - ]: 7 : ::getBooleanCppuType(),
319 : : beans::PropertyAttribute::BOUND
320 [ + - ]: 7 : | beans::PropertyAttribute::MAYBEDEFAULT ));
321 : :
322 : : rOutProperties.push_back(
323 : : Property( "StackedText",
324 : : PROP_AXIS_STACKEDTEXT,
325 [ + - ]: 7 : ::getBooleanCppuType(),
326 : : beans::PropertyAttribute::BOUND
327 [ + - ]: 7 : | beans::PropertyAttribute::MAYBEDEFAULT ));
328 : :
329 : : // Properties related to bar charts:
330 : : rOutProperties.push_back(
331 : : Property( "Overlap",
332 : : PROP_AXIS_OVERLAP,
333 : 7 : ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)),
334 : : //#i111967# no PropertyChangeEvent is fired on change so far
335 [ + - ]: 7 : beans::PropertyAttribute::MAYBEDEFAULT ));
336 : :
337 : : rOutProperties.push_back(
338 : : Property( "GapWidth",
339 : : PROP_AXIS_GAP_WIDTH,
340 : 7 : ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)),
341 : : //#i111967# no PropertyChangeEvent is fired on change so far
342 [ + - ]: 7 : beans::PropertyAttribute::MAYBEDEFAULT ));
343 : 7 : }
344 : :
345 : : struct StaticAxisWrapperPropertyArray_Initializer
346 : : {
347 : 7 : Sequence< Property >* operator()()
348 : : {
349 [ + - ][ + - ]: 7 : static Sequence< Property > aPropSeq( lcl_GetPropertySequence() );
[ + - ][ # # ]
350 : 7 : return &aPropSeq;
351 : : }
352 : :
353 : : private:
354 : 7 : Sequence< Property > lcl_GetPropertySequence()
355 : : {
356 [ + - ]: 7 : ::std::vector< ::com::sun::star::beans::Property > aProperties;
357 [ + - ]: 7 : lcl_AddPropertiesToVector( aProperties );
358 [ + - ]: 7 : ::chart::CharacterProperties::AddPropertiesToVector( aProperties );
359 [ + - ]: 7 : ::chart::LineProperties::AddPropertiesToVector( aProperties );
360 [ + - ]: 7 : ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
361 [ + - ]: 7 : ::chart::wrapper::WrappedScaleTextProperties::addProperties( aProperties );
362 : :
363 : : ::std::sort( aProperties.begin(), aProperties.end(),
364 [ + - ]: 7 : ::chart::PropertyNameLess() );
365 : :
366 [ + - ]: 7 : 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 : 40 : AxisWrapper::AxisWrapper(
384 : : tAxisType eType, ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) :
385 : : m_spChart2ModelContact( spChart2ModelContact ),
386 : : m_aEventListenerContainer( m_aMutex ),
387 [ + - ][ + - ]: 40 : m_eType( eType )
388 : : {
389 : 40 : }
390 : :
391 [ + - ][ + - ]: 40 : AxisWrapper::~AxisWrapper()
392 : : {
393 [ - + ]: 80 : }
394 : :
395 : : // ____ chart::XAxis ____
396 : 6 : Reference< beans::XPropertySet > SAL_CALL AxisWrapper::getAxisTitle() throw (uno::RuntimeException)
397 : : {
398 [ + - ]: 6 : if( !m_xAxisTitle.is() )
399 : : {
400 : 6 : TitleHelper::eTitleType eTitleType( TitleHelper::X_AXIS_TITLE );
401 [ + + + - : 6 : switch( m_eType )
- - ]
402 : : {
403 : : case X_AXIS:
404 : 2 : eTitleType = TitleHelper::X_AXIS_TITLE;
405 : 2 : break;
406 : : case Y_AXIS:
407 : 2 : eTitleType = TitleHelper::Y_AXIS_TITLE;
408 : 2 : break;
409 : : case Z_AXIS:
410 : 2 : eTitleType = TitleHelper::Z_AXIS_TITLE;
411 : 2 : 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 [ + - ][ + - ]: 6 : m_xAxisTitle = new TitleWrapper( eTitleType, m_spChart2ModelContact );
[ + - ]
422 : : }
423 : 6 : return m_xAxisTitle;
424 : : }
425 : 38 : Reference< beans::XPropertySet > SAL_CALL AxisWrapper::getMajorGrid() throw (uno::RuntimeException)
426 : : {
427 [ + + ]: 38 : if( !m_xMajorGrid.is() )
428 : : {
429 : 27 : GridWrapper::tGridType eGridType( GridWrapper::X_MAJOR_GRID );
430 [ + + + - ]: 27 : switch( m_eType )
431 : : {
432 : : case X_AXIS:
433 : 10 : eGridType = GridWrapper::X_MAJOR_GRID;
434 : 10 : break;
435 : : case Y_AXIS:
436 : 15 : eGridType = GridWrapper::Y_MAJOR_GRID;
437 : 15 : break;
438 : : case Z_AXIS:
439 : 2 : eGridType = GridWrapper::Z_MAJOR_GRID;
440 : 2 : break;
441 : : default:
442 : 0 : return 0;
443 : : }
444 [ + - ][ + - ]: 27 : m_xMajorGrid = new GridWrapper( eGridType, m_spChart2ModelContact );
[ + - ]
445 : : }
446 : 38 : return m_xMajorGrid;
447 : : }
448 : 6 : Reference< beans::XPropertySet > SAL_CALL AxisWrapper::getMinorGrid() throw (uno::RuntimeException)
449 : : {
450 [ + - ]: 6 : if( !m_xMinorGrid.is() )
451 : : {
452 : 6 : GridWrapper::tGridType eGridType( GridWrapper::X_MAJOR_GRID );
453 [ + + + - ]: 6 : switch( m_eType )
454 : : {
455 : : case X_AXIS:
456 : 2 : eGridType = GridWrapper::X_MINOR_GRID;
457 : 2 : break;
458 : : case Y_AXIS:
459 : 2 : eGridType = GridWrapper::Y_MINOR_GRID;
460 : 2 : break;
461 : : case Z_AXIS:
462 : 2 : eGridType = GridWrapper::Z_MINOR_GRID;
463 : 2 : break;
464 : : default:
465 : 0 : return 0;
466 : : }
467 [ + - ][ + - ]: 6 : m_xMinorGrid = new GridWrapper( eGridType, m_spChart2ModelContact );
[ + - ]
468 : : }
469 : 6 : 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 : 5987 : void AxisWrapper::getDimensionAndMainAxisBool( tAxisType eType, sal_Int32& rnDimensionIndex, sal_Bool& rbMainAxis )
529 : : {
530 [ + + - - : 5987 : switch( eType )
- - ]
531 : : {
532 : : case X_AXIS:
533 : 2062 : rnDimensionIndex = 0; rbMainAxis = sal_True; break;
534 : : case Y_AXIS:
535 : 3925 : 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 : 5987 : }
544 : :
545 : : // ____ XComponent ____
546 : 36 : void SAL_CALL AxisWrapper::dispose()
547 : : throw (uno::RuntimeException)
548 : : {
549 [ + - ]: 36 : Reference< uno::XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) );
550 [ + - ][ + - ]: 36 : m_aEventListenerContainer.disposeAndClear( lang::EventObject( xSource ) );
[ + - ]
551 : :
552 [ + - ]: 36 : DisposeHelper::DisposeAndClear( m_xAxisTitle );
553 [ + - ]: 36 : DisposeHelper::DisposeAndClear( m_xMajorGrid );
554 [ + - ]: 36 : DisposeHelper::DisposeAndClear( m_xMinorGrid );
555 : :
556 [ + - ]: 36 : clearWrappedPropertySet();
557 : 36 : }
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 : 62 : void AxisWrapper::updateReferenceSize()
577 : : {
578 [ + - ][ + - ]: 62 : Reference< beans::XPropertySet > xProp( this->getAxis(), uno::UNO_QUERY );
579 [ + - ]: 62 : if( xProp.is() )
580 : : {
581 [ + - ][ + - ]: 62 : if( xProp->getPropertyValue("ReferencePageSize").hasValue() )
[ - + ]
582 [ # # ]: 0 : xProp->setPropertyValue("ReferencePageSize", uno::makeAny(
583 [ # # ][ # # ]: 0 : m_spChart2ModelContact->GetPageSize() ));
[ # # ]
584 : 62 : }
585 : 62 : }
586 : 154 : Any AxisWrapper::getReferenceSize()
587 : : {
588 : 154 : Any aRet;
589 [ + - ][ + - ]: 154 : Reference< beans::XPropertySet > xProp( this->getAxis(), uno::UNO_QUERY );
590 [ + - ]: 154 : if( xProp.is() )
591 [ + - ][ + - ]: 154 : aRet = xProp->getPropertyValue("ReferencePageSize");
592 : 154 : return aRet;
593 : : }
594 : 0 : awt::Size AxisWrapper::getCurrentSizeForReference()
595 : : {
596 : 0 : return m_spChart2ModelContact->GetPageSize();
597 : : }
598 : :
599 : : // ================================================================================
600 : :
601 : 5959 : Reference< chart2::XAxis > AxisWrapper::getAxis()
602 : : {
603 : 5959 : Reference< chart2::XAxis > xAxis;
604 : : try
605 : : {
606 : 5959 : sal_Int32 nDimensionIndex = 0;
607 : 5959 : sal_Bool bMainAxis = sal_True;
608 : 5959 : AxisWrapper::getDimensionAndMainAxisBool( m_eType, nDimensionIndex, bMainAxis );
609 : :
610 [ + - ]: 5959 : Reference< XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() );
611 [ + - ][ + - ]: 5959 : xAxis = AxisHelper::getAxis( nDimensionIndex, bMainAxis, xDiagram );
612 [ - + ]: 5959 : 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 [ # # ]: 5959 : }
619 : : }
620 [ # # ]: 0 : catch( const uno::Exception & ex )
621 : : {
622 : : ASSERT_EXCEPTION( ex );
623 : : }
624 : 5959 : return xAxis;
625 : : }
626 : :
627 : : // WrappedPropertySet
628 : 5743 : Reference< beans::XPropertySet > AxisWrapper::getInnerPropertySet()
629 : : {
630 [ + - ]: 5743 : return Reference< beans::XPropertySet >( this->getAxis(), uno::UNO_QUERY );
631 : : }
632 : :
633 : 28 : const Sequence< beans::Property >& AxisWrapper::getPropertySequence()
634 : : {
635 : 28 : return *StaticAxisWrapperPropertyArray::get();
636 : : }
637 : :
638 : 28 : const std::vector< WrappedProperty* > AxisWrapper::createWrappedProperties()
639 : : {
640 : 28 : ::std::vector< ::chart::WrappedProperty* > aWrappedProperties;
641 : :
642 [ + - ][ + - ]: 28 : aWrappedProperties.push_back( new WrappedTextRotationProperty() );
[ + - ]
643 [ + - ][ + - ]: 28 : aWrappedProperties.push_back( new WrappedProperty("Marks","MajorTickmarks") );
[ + - ]
644 [ + - ][ + - ]: 28 : aWrappedProperties.push_back( new WrappedProperty("HelpMarks","MinorTickmarks") );
[ + - ]
645 [ + - ][ + - ]: 28 : aWrappedProperties.push_back( new WrappedProperty("TextCanOverlap","TextOverlap") );
[ + - ]
646 [ + - ][ + - ]: 28 : aWrappedProperties.push_back( new WrappedProperty("ArrangeOrder","ArrangeOrder") );
[ + - ]
647 [ + - ][ + - ]: 28 : aWrappedProperties.push_back( new WrappedProperty("Visible","Show") );
[ + - ]
648 [ + - ][ + - ]: 28 : aWrappedProperties.push_back( new WrappedDirectStateProperty("DisplayLabels","DisplayLabels") );
[ + - ]
649 [ + - ][ + - ]: 28 : aWrappedProperties.push_back( new WrappedDirectStateProperty("TextBreak","TextBreak") );
[ + - ]
650 [ + - ][ + - ]: 28 : WrappedNumberFormatProperty* pWrappedNumberFormatProperty = new WrappedNumberFormatProperty( m_spChart2ModelContact );
[ + - ][ + - ]
651 [ + - ]: 28 : aWrappedProperties.push_back( pWrappedNumberFormatProperty );
652 [ + - ][ + - ]: 28 : aWrappedProperties.push_back( new WrappedLinkNumberFormatProperty(pWrappedNumberFormatProperty) );
[ + - ]
653 [ + - ][ + - ]: 28 : aWrappedProperties.push_back( new WrappedProperty("StackedText","StackCharacters") );
[ + - ]
654 [ + - ][ + - ]: 28 : aWrappedProperties.push_back( new WrappedDirectStateProperty("CrossoverPosition","CrossoverPosition") );
[ + - ]
655 : : {
656 [ + - ][ + - ]: 28 : WrappedGapwidthProperty* pWrappedGapwidthProperty( new WrappedGapwidthProperty( m_spChart2ModelContact ) );
[ + - ][ + - ]
657 [ + - ][ + - ]: 28 : WrappedBarOverlapProperty* pWrappedBarOverlapProperty( new WrappedBarOverlapProperty( m_spChart2ModelContact ) );
[ + - ][ + - ]
658 : 28 : sal_Int32 nDimensionIndex = 0;
659 : 28 : sal_Bool bMainAxis = sal_True;
660 : 28 : sal_Int32 nAxisIndex = 0;
661 : 28 : AxisWrapper::getDimensionAndMainAxisBool( m_eType, nDimensionIndex, bMainAxis );
662 [ - + ]: 28 : if( !bMainAxis )
663 : 0 : nAxisIndex = 1;
664 [ + - ]: 28 : pWrappedGapwidthProperty->setDimensionAndAxisIndex( nDimensionIndex, nAxisIndex );
665 [ + - ]: 28 : pWrappedBarOverlapProperty->setDimensionAndAxisIndex( nDimensionIndex, nAxisIndex );
666 [ + - ]: 28 : aWrappedProperties.push_back( pWrappedGapwidthProperty );
667 [ + - ]: 28 : aWrappedProperties.push_back( pWrappedBarOverlapProperty );
668 : : }
669 : :
670 [ + - ][ + - ]: 28 : WrappedScaleProperty::addWrappedProperties( aWrappedProperties, m_spChart2ModelContact );
[ + - ]
671 : :
672 [ + - ]: 28 : WrappedCharacterHeightProperty::addWrappedProperties( aWrappedProperties, this );
673 [ + - ][ + - ]: 28 : WrappedScaleTextProperties::addWrappedProperties( aWrappedProperties, m_spChart2ModelContact );
[ + - ]
674 : :
675 : 28 : return aWrappedProperties;
676 : : }
677 : :
678 : : // ================================================================================
679 : :
680 : 6 : Sequence< OUString > AxisWrapper::getSupportedServiceNames_Static()
681 : : {
682 : 6 : Sequence< OUString > aServices( 3 );
683 [ + - ]: 6 : aServices[ 0 ] = "com.sun.star.chart.ChartAxis";
684 [ + - ]: 6 : aServices[ 1 ] = "com.sun.star.xml.UserDefinedAttributeSupplier";
685 [ + - ]: 6 : aServices[ 2 ] = "com.sun.star.style.CharacterProperties";
686 : :
687 : 6 : return aServices;
688 : : }
689 : :
690 : : // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
691 [ + - ][ + - ]: 22 : APPHELPER_XSERVICEINFO_IMPL( AxisWrapper, lcl_aServiceName );
[ + + ][ + + ]
[ + - ]
692 : :
693 : : } // namespace wrapper
694 [ + - ][ + - ]: 48 : } // namespace chart
695 : :
696 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|