Coverage Report

Created: 2025-07-07 10:01

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