Coverage Report

Created: 2026-02-14 09:37

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