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 : :
21 : : #include "WrappedScaleProperty.hxx"
22 : : #include "macros.hxx"
23 : : #include "CommonConverters.hxx"
24 : : #include "AxisHelper.hxx"
25 : : #include <com/sun/star/chart2/XAxis.hpp>
26 : : #include <com/sun/star/chart/ChartAxisType.hpp>
27 : : #include <chartview/ExplicitScaleValues.hxx>
28 : :
29 : : using namespace ::com::sun::star;
30 : : using ::com::sun::star::uno::Any;
31 : : using namespace ::com::sun::star::chart2;
32 : : using ::com::sun::star::uno::Reference;
33 : : using ::com::sun::star::uno::Sequence;
34 : : using ::rtl::OUString;
35 : : using ::com::sun::star::chart::TimeIncrement;
36 : :
37 : : //.............................................................................
38 : : namespace chart
39 : : {
40 : : namespace wrapper
41 : : {
42 : :
43 : 448 : WrappedScaleProperty::WrappedScaleProperty( tScaleProperty eScaleProperty
44 : : , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact )
45 : : : WrappedProperty(OUString(),OUString())
46 : : , m_spChart2ModelContact( spChart2ModelContact )
47 [ + - ][ + - ]: 448 : , m_eScaleProperty( eScaleProperty )
48 : : {
49 [ + + + + : 448 : switch( m_eScaleProperty )
+ + + + +
+ + + + +
+ + - ]
50 : : {
51 : : case SCALE_PROP_MAX:
52 : 28 : m_aOuterName = "Max";
53 : 28 : break;
54 : : case SCALE_PROP_MIN:
55 : 28 : m_aOuterName = "Min";
56 : 28 : break;
57 : : case SCALE_PROP_ORIGIN:
58 : 28 : m_aOuterName = "Origin";
59 : 28 : break;
60 : : case SCALE_PROP_STEPMAIN:
61 : 28 : m_aOuterName = "StepMain";
62 : 28 : break;
63 : : case SCALE_PROP_STEPHELP:
64 : 28 : m_aOuterName = "StepHelp";
65 : 28 : break;
66 : : case SCALE_PROP_STEPHELP_COUNT:
67 : 28 : m_aOuterName = "StepHelpCount";
68 : 28 : break;
69 : : case SCALE_PROP_AUTO_MAX:
70 : 28 : m_aOuterName = "AutoMax";
71 : 28 : break;
72 : : case SCALE_PROP_AUTO_MIN:
73 : 28 : m_aOuterName = "AutoMin";
74 : 28 : break;
75 : : case SCALE_PROP_AUTO_ORIGIN:
76 : 28 : m_aOuterName = "AutoOrigin";
77 : 28 : break;
78 : : case SCALE_PROP_AUTO_STEPMAIN:
79 : 28 : m_aOuterName = "AutoStepMain";
80 : 28 : break;
81 : : case SCALE_PROP_AUTO_STEPHELP:
82 : 28 : m_aOuterName = "AutoStepHelp";
83 : 28 : break;
84 : : case SCALE_PROP_AXIS_TYPE:
85 : 28 : m_aOuterName = "AxisType";
86 : 28 : break;
87 : : case SCALE_PROP_DATE_INCREMENT:
88 : 28 : m_aOuterName = "TimeIncrement";
89 : 28 : break;
90 : : case SCALE_PROP_EXPLICIT_DATE_INCREMENT:
91 : 28 : m_aOuterName = "ExplicitTimeIncrement";
92 : 28 : break;
93 : : case SCALE_PROP_LOGARITHMIC:
94 : 28 : m_aOuterName = "Logarithmic";
95 : 28 : break;
96 : : case SCALE_PROP_REVERSEDIRECTION:
97 : 28 : m_aOuterName = "ReverseDirection";
98 : 28 : break;
99 : : default:
100 : : OSL_FAIL("unknown scale property");
101 : 0 : break;
102 : : }
103 : 448 : }
104 : :
105 [ + - ]: 448 : WrappedScaleProperty::~WrappedScaleProperty()
106 : : {
107 [ - + ]: 896 : }
108 : :
109 : 28 : void WrappedScaleProperty::addWrappedProperties( std::vector< WrappedProperty* >& rList
110 : : , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact )
111 : : {
112 [ + - ][ + - ]: 28 : rList.push_back( new WrappedScaleProperty( SCALE_PROP_MAX, spChart2ModelContact ) );
[ + - ]
113 [ + - ][ + - ]: 28 : rList.push_back( new WrappedScaleProperty( SCALE_PROP_MIN, spChart2ModelContact ) );
[ + - ]
114 [ + - ][ + - ]: 28 : rList.push_back( new WrappedScaleProperty( SCALE_PROP_ORIGIN, spChart2ModelContact ) );
[ + - ]
115 [ + - ][ + - ]: 28 : rList.push_back( new WrappedScaleProperty( SCALE_PROP_STEPMAIN, spChart2ModelContact ) );
[ + - ]
116 [ + - ][ + - ]: 28 : rList.push_back( new WrappedScaleProperty( SCALE_PROP_STEPHELP, spChart2ModelContact ) );
[ + - ]
117 [ + - ][ + - ]: 28 : rList.push_back( new WrappedScaleProperty( SCALE_PROP_STEPHELP_COUNT, spChart2ModelContact ) );
[ + - ]
118 [ + - ][ + - ]: 28 : rList.push_back( new WrappedScaleProperty( SCALE_PROP_AUTO_MAX, spChart2ModelContact ) );
[ + - ]
119 [ + - ][ + - ]: 28 : rList.push_back( new WrappedScaleProperty( SCALE_PROP_AUTO_MIN, spChart2ModelContact ) );
[ + - ]
120 [ + - ][ + - ]: 28 : rList.push_back( new WrappedScaleProperty( SCALE_PROP_AUTO_ORIGIN, spChart2ModelContact ) );
[ + - ]
121 [ + - ][ + - ]: 28 : rList.push_back( new WrappedScaleProperty( SCALE_PROP_AUTO_STEPMAIN, spChart2ModelContact ) );
[ + - ]
122 [ + - ][ + - ]: 28 : rList.push_back( new WrappedScaleProperty( SCALE_PROP_AUTO_STEPHELP, spChart2ModelContact ) );
[ + - ]
123 [ + - ][ + - ]: 28 : rList.push_back( new WrappedScaleProperty( SCALE_PROP_AXIS_TYPE, spChart2ModelContact ) );
[ + - ]
124 [ + - ][ + - ]: 28 : rList.push_back( new WrappedScaleProperty( SCALE_PROP_DATE_INCREMENT, spChart2ModelContact ) );
[ + - ]
125 [ + - ][ + - ]: 28 : rList.push_back( new WrappedScaleProperty( SCALE_PROP_EXPLICIT_DATE_INCREMENT, spChart2ModelContact ) );
[ + - ]
126 [ + - ][ + - ]: 28 : rList.push_back( new WrappedScaleProperty( SCALE_PROP_LOGARITHMIC, spChart2ModelContact ) );
[ + - ]
127 [ + - ][ + - ]: 28 : rList.push_back( new WrappedScaleProperty( SCALE_PROP_REVERSEDIRECTION, spChart2ModelContact ) );
[ + - ]
128 : 28 : }
129 : :
130 : 96 : void WrappedScaleProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const
131 : : throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
132 : : {
133 : 96 : setPropertyValue( m_eScaleProperty, rOuterValue, xInnerPropertySet );
134 : 96 : }
135 : :
136 : 811 : Any WrappedScaleProperty::getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const
137 : : throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
138 : : {
139 : 811 : return getPropertyValue( m_eScaleProperty, xInnerPropertySet );
140 : : }
141 : :
142 : 96 : void WrappedScaleProperty::setPropertyValue( tScaleProperty eScaleProperty, const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const
143 : : throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
144 : : {
145 : 96 : m_aOuterValue = rOuterValue;
146 : :
147 [ + - ]: 96 : Reference< chart2::XAxis > xAxis( xInnerPropertySet, uno::UNO_QUERY );
148 : : OSL_ENSURE(xAxis.is(),"need an XAxis");
149 [ - + ]: 96 : if(!xAxis.is())
150 : 96 : return;
151 : :
152 : 96 : bool bSetScaleData = false;
153 : :
154 [ + - ][ + - ]: 96 : chart2::ScaleData aScaleData( xAxis->getScaleData() );
155 : :
156 : 96 : sal_Bool bBool = false;
157 [ + + + + : 96 : switch( eScaleProperty )
- + + + +
+ + + - -
+ + - ]
158 : : {
159 : : case SCALE_PROP_MAX:
160 : : {
161 : 2 : aScaleData.Maximum = rOuterValue;
162 : 2 : bSetScaleData = true;
163 : 2 : break;
164 : : }
165 : : case SCALE_PROP_MIN:
166 : : {
167 : 2 : aScaleData.Minimum = rOuterValue;
168 : 2 : bSetScaleData = true;
169 : 2 : break;
170 : : }
171 : : case SCALE_PROP_STEPMAIN:
172 : : {
173 : 2 : aScaleData.IncrementData.Distance = rOuterValue;
174 : 2 : bSetScaleData = true;
175 : 2 : break;
176 : : }
177 : : case SCALE_PROP_STEPHELP:
178 : : {
179 : 2 : Sequence< chart2::SubIncrement >& rSubIncrements( aScaleData.IncrementData.SubIncrements );
180 [ - + ]: 2 : if( rSubIncrements.getLength() == 0 )
181 [ # # ]: 0 : rSubIncrements.realloc( 1 );
182 : :
183 : 2 : double fStepHelp = 0;
184 [ + - ]: 2 : if( (rOuterValue >>= fStepHelp) )
185 : : {
186 : 2 : double fStepMain = 0;
187 [ + - ][ - + ]: 2 : if( AxisHelper::isLogarithmic(aScaleData.Scaling) )
188 : : {
189 : 0 : sal_Int32 nIntervalCount = static_cast< sal_Int32 >(fStepHelp);
190 [ # # ][ # # ]: 0 : rSubIncrements[ 0 ].IntervalCount <<= nIntervalCount;
191 : : }
192 [ + - + - ]: 4 : else if( (fStepHelp != 0.0) &&
[ + - ]
193 : 2 : (aScaleData.IncrementData.Distance >>= fStepMain) )
194 : : {
195 : : // approximate interval count
196 : 2 : sal_Int32 nIntervalCount = static_cast< sal_Int32 >(fStepMain / fStepHelp);
197 [ + - ][ + - ]: 2 : rSubIncrements[ 0 ].IntervalCount <<= nIntervalCount;
198 : : }
199 : : }
200 : 2 : bSetScaleData = true;
201 : : break;
202 : : }
203 : : case SCALE_PROP_STEPHELP_COUNT:
204 : : {
205 : 0 : Sequence< chart2::SubIncrement >& rSubIncrements( aScaleData.IncrementData.SubIncrements );
206 [ # # ]: 0 : if( rSubIncrements.getLength() == 0 )
207 [ # # ]: 0 : rSubIncrements.realloc( 1 );
208 : 0 : sal_Int32 nIntervalCount=0;
209 [ # # ]: 0 : if( rOuterValue>>=nIntervalCount )
210 [ # # ][ # # ]: 0 : rSubIncrements[ 0 ].IntervalCount <<= nIntervalCount;
211 : : else
212 [ # # ]: 0 : rSubIncrements[ 0 ].IntervalCount = Any();
213 : 0 : bSetScaleData = true;
214 : : break;
215 : : }
216 : : case SCALE_PROP_AUTO_MAX:
217 : : {
218 [ + - ][ + + ]: 8 : if( (rOuterValue >>= bBool) && bBool )
[ + + ]
219 : 4 : aScaleData.Maximum = Any();
220 : : else
221 [ + - ]: 4 : aScaleData.Maximum = getPropertyValue( SCALE_PROP_MAX, xInnerPropertySet );
222 : 8 : bSetScaleData = true;
223 : 8 : break;
224 : : }
225 : : case SCALE_PROP_AUTO_MIN:
226 : : {
227 [ + - ][ + + ]: 8 : if( (rOuterValue >>= bBool) && bBool )
[ + + ]
228 : 4 : aScaleData.Minimum = Any();
229 : : else
230 [ + - ]: 4 : aScaleData.Minimum = getPropertyValue( SCALE_PROP_MIN, xInnerPropertySet );
231 : 8 : bSetScaleData = true;
232 : 8 : break;
233 : : }
234 : : case SCALE_PROP_AUTO_STEPMAIN:
235 : : {
236 [ + - ][ + + ]: 8 : if( (rOuterValue >>= bBool) && bBool )
[ + + ]
237 : 4 : aScaleData.IncrementData.Distance = Any();
238 : : else
239 [ + - ]: 4 : aScaleData.IncrementData.Distance = getPropertyValue( SCALE_PROP_STEPMAIN, xInnerPropertySet );
240 : 8 : bSetScaleData = true;
241 : 8 : break;
242 : : }
243 : : case SCALE_PROP_AUTO_STEPHELP:
244 : : {
245 : 6 : Sequence< chart2::SubIncrement >& rSubIncrements( aScaleData.IncrementData.SubIncrements );
246 [ - + ]: 6 : if( rSubIncrements.getLength() == 0 )
247 [ # # ]: 0 : rSubIncrements.realloc( 1 );
248 : :
249 [ + - ][ + + ]: 6 : if( (rOuterValue >>= bBool) && bBool )
[ + + ]
250 [ + - ]: 4 : rSubIncrements[ 0 ].IntervalCount = Any();
251 : : else
252 [ + - ][ + - ]: 2 : rSubIncrements[ 0 ].IntervalCount = getPropertyValue( SCALE_PROP_STEPHELP_COUNT, xInnerPropertySet );
253 : 6 : bSetScaleData = true;
254 : 6 : break;
255 : : }
256 : : case SCALE_PROP_ORIGIN:
257 : : {
258 : 8 : aScaleData.Origin = rOuterValue;
259 : 8 : bSetScaleData = true;
260 : 8 : break;
261 : : }
262 : : case SCALE_PROP_AUTO_ORIGIN:
263 : : {
264 [ + - ][ + + ]: 22 : if( (rOuterValue >>= bBool) && bBool )
[ + + ]
265 : 20 : aScaleData.Origin = Any();
266 : : else
267 [ + - ]: 2 : aScaleData.Origin = getPropertyValue( SCALE_PROP_ORIGIN, xInnerPropertySet );
268 : 22 : bSetScaleData = true;
269 : 22 : break;
270 : : }
271 : : case SCALE_PROP_AXIS_TYPE:
272 : : {
273 : 2 : sal_Int32 nType = 0;
274 [ + - ]: 2 : if( (rOuterValue >>= nType) )
275 : : {
276 [ - + ]: 2 : if( ::com::sun::star::chart::ChartAxisType::AUTOMATIC == nType )
277 : : {
278 : 0 : aScaleData.AutoDateAxis = true;
279 [ # # ]: 0 : if( aScaleData.AxisType == AxisType::DATE )
280 : 0 : aScaleData.AxisType = AxisType::CATEGORY;
281 : : }
282 [ - + ]: 2 : else if( ::com::sun::star::chart::ChartAxisType::CATEGORY == nType )
283 : : {
284 : 0 : aScaleData.AutoDateAxis = false;
285 [ # # ]: 0 : if( aScaleData.AxisType == AxisType::DATE )
286 : 0 : aScaleData.AxisType = AxisType::CATEGORY;
287 : : }
288 [ - + ]: 2 : else if( ::com::sun::star::chart::ChartAxisType::DATE == nType )
289 : : {
290 [ # # ]: 0 : if( aScaleData.AxisType == AxisType::CATEGORY )
291 : 0 : aScaleData.AxisType = AxisType::DATE;
292 : : }
293 : 2 : bSetScaleData = true;
294 : : }
295 : : break;
296 : : }
297 : : case SCALE_PROP_DATE_INCREMENT:
298 : : {
299 : 0 : TimeIncrement aTimeIncrement;
300 [ # # ]: 0 : rOuterValue >>= aTimeIncrement;
301 : 0 : aScaleData.TimeIncrement = aTimeIncrement;
302 : 0 : bSetScaleData = true;
303 : 0 : break;
304 : : }
305 : : case SCALE_PROP_EXPLICIT_DATE_INCREMENT:
306 : : //read only property
307 : 0 : break;
308 : : case SCALE_PROP_LOGARITHMIC:
309 : : {
310 [ + - ]: 22 : if( rOuterValue >>= bBool )
311 : : {
312 [ + - ]: 22 : bool bWasLogarithm = AxisHelper::isLogarithmic( aScaleData.Scaling );
313 : :
314 : : // safe comparison between sal_Bool and bool
315 [ + + ]: 22 : if( (!bBool) != (!bWasLogarithm) )
316 : : {
317 [ + + ]: 6 : if( bBool )
318 [ + - ][ + - ]: 4 : aScaleData.Scaling = AxisHelper::createLogarithmicScaling( 10.0 );
319 : : else
320 [ + - ]: 2 : aScaleData.Scaling = 0;
321 : 6 : bSetScaleData = true;
322 : : }
323 : : }
324 : 22 : break;
325 : : }
326 : : case SCALE_PROP_REVERSEDIRECTION:
327 : : {
328 [ + - ]: 4 : if( rOuterValue >>= bBool )
329 : : {
330 : 4 : bool bWasReverse = ( AxisOrientation_REVERSE == aScaleData.Orientation );
331 [ + - ]: 4 : if( (!bBool) != (!bWasReverse) ) // safe comparison between sal_Bool and bool
332 : : {
333 [ + + ]: 4 : aScaleData.Orientation = bBool ? AxisOrientation_REVERSE : AxisOrientation_MATHEMATICAL;
334 : 4 : bSetScaleData = true;
335 : : }
336 : : }
337 : 4 : break;
338 : : }
339 : : default:
340 : : {
341 : : OSL_FAIL("unknown scale property");
342 : 0 : break;
343 : : }
344 : : }
345 : :
346 [ + + ]: 96 : if( bSetScaleData )
347 [ + - ][ + - ]: 96 : xAxis->setScaleData( aScaleData );
[ + - ][ + - ]
348 : : }
349 : :
350 : 827 : Any WrappedScaleProperty::getPropertyValue( tScaleProperty eScaleProperty, const Reference< beans::XPropertySet >& xInnerPropertySet ) const
351 : : throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
352 : : {
353 : 827 : Any aRet( m_aOuterValue );
354 : :
355 [ + - ]: 827 : Reference< chart2::XAxis > xAxis( xInnerPropertySet, uno::UNO_QUERY );
356 : : OSL_ENSURE(xAxis.is(),"need an XAxis");
357 [ + - ]: 827 : if(!xAxis.is())
358 : : return aRet;
359 : :
360 [ + - ][ + - ]: 827 : chart2::ScaleData aScaleData( xAxis->getScaleData() );
361 : :
362 [ + - ]: 827 : ExplicitScaleData aExplicitScale;
363 [ + - ]: 827 : ExplicitIncrementData aExplicitIncrement;
364 : :
365 [ + + + + : 827 : switch( eScaleProperty )
+ + + + +
+ + + + -
+ + - ]
366 : : {
367 : : case SCALE_PROP_MAX:
368 : : {
369 : 80 : aRet = aScaleData.Maximum;
370 [ + + ]: 80 : if( !aRet.hasValue() )
371 : : {
372 : : m_spChart2ModelContact->getExplicitValuesForAxis(
373 [ + - ]: 76 : xAxis, aExplicitScale, aExplicitIncrement );
374 [ + - ]: 76 : aRet <<= aExplicitScale.Maximum;
375 : : }
376 : 80 : break;
377 : : }
378 : : case SCALE_PROP_MIN:
379 : : {
380 : 80 : aRet = aScaleData.Minimum;
381 [ + + ]: 80 : if( !aRet.hasValue() )
382 : : {
383 : : m_spChart2ModelContact->getExplicitValuesForAxis(
384 [ + - ]: 76 : xAxis, aExplicitScale, aExplicitIncrement );
385 [ + - ]: 76 : aRet <<= aExplicitScale.Minimum;
386 : : }
387 : 80 : break;
388 : : }
389 : :
390 : : case SCALE_PROP_STEPMAIN:
391 : : {
392 : 80 : aRet = aScaleData.IncrementData.Distance;
393 [ + + ]: 80 : if( !aRet.hasValue() )
394 : : {
395 : : m_spChart2ModelContact->getExplicitValuesForAxis(
396 [ + - ]: 76 : xAxis, aExplicitScale, aExplicitIncrement );
397 [ + - ]: 76 : aRet <<= aExplicitIncrement.Distance;
398 : : }
399 : 80 : break;
400 : : }
401 : : case SCALE_PROP_STEPHELP:
402 : : {
403 : : // todo: evaluate PostEquidistant
404 : 4 : bool bNeedToCalculateExplicitValues = true;
405 : :
406 [ + - ]: 4 : bool bLogarithmic( AxisHelper::isLogarithmic(aScaleData.Scaling) );
407 : 4 : Sequence< chart2::SubIncrement >& rSubIncrements( aScaleData.IncrementData.SubIncrements );
408 [ - + ]: 4 : if( bLogarithmic )
409 : : {
410 [ # # ]: 0 : if( rSubIncrements.getLength() > 0 )
411 : : {
412 : 0 : sal_Int32 nIntervalCount = 0;
413 [ # # ]: 0 : rSubIncrements[ 0 ].IntervalCount >>= nIntervalCount;
414 [ # # ]: 0 : aRet = uno::makeAny( double(nIntervalCount) );
415 : 0 : bNeedToCalculateExplicitValues = false;
416 : : }
417 : : }
418 [ + - ]: 4 : else if( aScaleData.IncrementData.Distance.hasValue() )
419 : : {
420 [ + - ]: 4 : if( rSubIncrements.getLength() > 0 )
421 : : {
422 : 4 : double fStepMain = 0;
423 : 4 : sal_Int32 nIntervalCount = 0;
424 [ + - + + ]: 8 : if( (aScaleData.IncrementData.Distance >>= fStepMain) &&
[ - + ][ - + ]
425 [ + - ]: 4 : (rSubIncrements[ 0 ].IntervalCount >>= nIntervalCount) &&
426 : : nIntervalCount > 0 )
427 : : {
428 [ # # ]: 0 : aRet <<= ( fStepMain / static_cast< double >( nIntervalCount ) );
429 : 4 : bNeedToCalculateExplicitValues = false;
430 : : }
431 : : }
432 : : else
433 : : {
434 : 0 : aRet = aScaleData.IncrementData.Distance;
435 : 0 : bNeedToCalculateExplicitValues = false;
436 : : }
437 : : }
438 : :
439 [ + - ]: 4 : if( bNeedToCalculateExplicitValues )
440 : : {
441 : : m_spChart2ModelContact->getExplicitValuesForAxis(
442 [ + - ]: 4 : xAxis, aExplicitScale, aExplicitIncrement );
443 : :
444 [ + + ][ + + ]: 7 : if( !aExplicitIncrement.SubIncrements.empty() &&
[ + + ]
445 [ + - ]: 3 : aExplicitIncrement.SubIncrements[ 0 ].IntervalCount > 0 )
446 : : {
447 [ - + ]: 1 : if( bLogarithmic )
448 : : {
449 [ # # ]: 0 : if( rSubIncrements.getLength() > 0 )
450 : : {
451 [ # # ]: 0 : sal_Int32 nIntervalCount = aExplicitIncrement.SubIncrements[ 0 ].IntervalCount;
452 [ # # ]: 0 : aRet = uno::makeAny( double(nIntervalCount) );
453 : : }
454 : : }
455 : : else
456 : : aRet <<= ( aExplicitIncrement.Distance /
457 : : static_cast< double >(
458 [ + - ][ + - ]: 1 : aExplicitIncrement.SubIncrements[ 0 ].IntervalCount ));
459 : : }
460 : : else
461 : : {
462 [ - + ]: 3 : if( bLogarithmic )
463 [ # # ]: 0 : aRet <<= 5.0;
464 : : else
465 [ + - ]: 3 : aRet <<= aExplicitIncrement.Distance;
466 : : }
467 : : }
468 : 4 : break;
469 : : }
470 : : case SCALE_PROP_STEPHELP_COUNT:
471 : : {
472 : 74 : sal_Int32 nIntervalCount = 0;
473 : 74 : bool bNeedToCalculateExplicitValues = true;
474 : 74 : Sequence< chart2::SubIncrement >& rSubIncrements( aScaleData.IncrementData.SubIncrements );
475 [ + - ]: 74 : if( rSubIncrements.getLength() > 0 )
476 : : {
477 [ + - ][ - + ]: 74 : if( (rSubIncrements[ 0 ].IntervalCount >>= nIntervalCount) && (nIntervalCount > 0) )
[ # # ][ - + ]
478 : 0 : bNeedToCalculateExplicitValues = false;
479 : : }
480 [ + - ]: 74 : if( bNeedToCalculateExplicitValues )
481 : : {
482 [ + - ]: 74 : m_spChart2ModelContact->getExplicitValuesForAxis( xAxis, aExplicitScale, aExplicitIncrement );
483 [ + - ]: 74 : if( !aExplicitIncrement.SubIncrements.empty() )
484 [ + - ]: 74 : nIntervalCount = aExplicitIncrement.SubIncrements[ 0 ].IntervalCount;
485 : : }
486 [ + - ]: 74 : aRet = uno::makeAny( nIntervalCount );
487 : : break;
488 : : }
489 : : case SCALE_PROP_AUTO_MAX:
490 : : {
491 [ + - ]: 50 : aRet <<= (sal_Bool)( !aScaleData.Maximum.hasValue() );
492 : 50 : break;
493 : : }
494 : : case SCALE_PROP_AUTO_MIN:
495 : : {
496 [ + - ]: 50 : aRet <<= (sal_Bool)( !aScaleData.Minimum.hasValue() );
497 : 50 : break;
498 : : }
499 : : case SCALE_PROP_AUTO_STEPMAIN:
500 : : {
501 [ + - ]: 50 : aRet <<= (sal_Bool)( !aScaleData.IncrementData.Distance.hasValue() );
502 : 50 : break;
503 : : }
504 : : case SCALE_PROP_AUTO_STEPHELP:
505 : : {
506 : 50 : Sequence< chart2::SubIncrement >& rSubIncrements( aScaleData.IncrementData.SubIncrements );
507 [ + - ]: 50 : if( rSubIncrements.getLength() > 0 )
508 [ + - ][ + - ]: 50 : aRet <<= (sal_Bool)( !rSubIncrements[ 0 ].IntervalCount.hasValue() );
509 : : else
510 [ # # ]: 0 : aRet <<= sal_True;
511 : 50 : break;
512 : : }
513 : : case SCALE_PROP_ORIGIN:
514 : : {
515 : 78 : aRet = aScaleData.Origin;
516 [ + + ]: 78 : if( !aRet.hasValue() )
517 : : {
518 : : m_spChart2ModelContact->getExplicitValuesForAxis(
519 [ + - ]: 76 : xAxis, aExplicitScale, aExplicitIncrement );
520 [ + - ]: 76 : aRet <<= aExplicitScale.Origin;
521 : : }
522 : 78 : break;
523 : : }
524 : : case SCALE_PROP_AUTO_ORIGIN:
525 : : {
526 [ + - ][ + - ]: 50 : aRet <<= !hasDoubleValue(aScaleData.Origin);
527 : 50 : break;
528 : : }
529 : : case SCALE_PROP_AXIS_TYPE:
530 : : {
531 : 4 : sal_Int32 nType = ::com::sun::star::chart::ChartAxisType::AUTOMATIC;
532 [ - + ]: 4 : if( aScaleData.AxisType == AxisType::DATE )
533 : : {
534 : 0 : nType = ::com::sun::star::chart::ChartAxisType::DATE;
535 : : }
536 [ - + ]: 4 : else if( aScaleData.AxisType == AxisType::CATEGORY )
537 : : {
538 [ # # ]: 0 : if( !aScaleData.AutoDateAxis )
539 : 0 : nType = ::com::sun::star::chart::ChartAxisType::CATEGORY;
540 : : }
541 [ + - ]: 4 : aRet = uno::makeAny( nType );
542 : : break;
543 : : }
544 : : case SCALE_PROP_DATE_INCREMENT:
545 : : {
546 [ + - ][ + - ]: 9 : if( aScaleData.AxisType == AxisType::DATE || aScaleData.AutoDateAxis )
547 [ + - ]: 9 : aRet = uno::makeAny( aScaleData.TimeIncrement );
548 : 9 : break;
549 : : }
550 : : case SCALE_PROP_EXPLICIT_DATE_INCREMENT:
551 : : {
552 [ # # ][ # # ]: 0 : if( aScaleData.AxisType == AxisType::DATE || aScaleData.AutoDateAxis )
553 : : {
554 [ # # ]: 0 : m_spChart2ModelContact->getExplicitValuesForAxis( xAxis, aExplicitScale, aExplicitIncrement );
555 [ # # ]: 0 : if( aExplicitScale.AxisType == AxisType::DATE )
556 : : {
557 : 0 : TimeIncrement aTimeIncrement;
558 [ # # ]: 0 : aTimeIncrement.MajorTimeInterval = uno::makeAny( aExplicitIncrement.MajorTimeInterval );
559 [ # # ]: 0 : aTimeIncrement.MinorTimeInterval = uno::makeAny( aExplicitIncrement.MinorTimeInterval );
560 [ # # ]: 0 : aTimeIncrement.TimeResolution = uno::makeAny( aExplicitScale.TimeResolution );
561 [ # # ]: 0 : aRet = uno::makeAny(aTimeIncrement);
562 : : }
563 : : }
564 : :
565 [ # # ][ # # ]: 0 : if( aScaleData.AxisType == AxisType::DATE || aScaleData.AutoDateAxis )
566 [ # # ]: 0 : aRet = uno::makeAny( aScaleData.TimeIncrement );
567 : 0 : break;
568 : : }
569 : : case SCALE_PROP_LOGARITHMIC:
570 : : {
571 [ + - ][ + - ]: 86 : aRet <<= static_cast< sal_Bool >( AxisHelper::isLogarithmic(aScaleData.Scaling) );
572 : 86 : break;
573 : : }
574 : : case SCALE_PROP_REVERSEDIRECTION:
575 : : {
576 [ + - ]: 82 : aRet <<= static_cast< sal_Bool >( AxisOrientation_REVERSE == aScaleData.Orientation );
577 : 82 : break;
578 : : }
579 : : default:
580 : : {
581 : : OSL_FAIL("unknown scale property");
582 : 0 : break;
583 : : }
584 : : }
585 : :
586 [ + - ][ + - ]: 827 : return aRet;
587 : : }
588 : :
589 : : } // namespace wrapper
590 : : } // namespace chart
591 : : //.............................................................................
592 : :
593 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|