Coverage Report

Created: 2026-07-10 11:04

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/chart2/source/inc/DataSeries.hxx
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
#pragma once
20
21
// UNO types
22
#include <com/sun/star/chart2/XDataSeries.hpp>
23
#include <com/sun/star/chart2/data/XDataSink.hpp>
24
#include <com/sun/star/chart2/data/XDataSource.hpp>
25
#include <com/sun/star/chart2/XRegressionCurveContainer.hpp>
26
#include <com/sun/star/util/XCloneable.hpp>
27
#include <com/sun/star/lang/XServiceInfo.hpp>
28
29
// helper classes
30
#include <cppuhelper/implbase.hxx>
31
#include <comphelper/uno3.hxx>
32
#include "ModifyListenerHelper.hxx"
33
#include "PropertyHelper.hxx"
34
35
// STL
36
#include <vector>
37
#include <map>
38
39
#include "OPropertySet.hxx"
40
41
namespace com::sun::star::beans { class XPropertySet; }
42
43
namespace chart
44
{
45
class RegressionCurveModel;
46
47
namespace impl
48
{
49
typedef ::cppu::WeakImplHelper<
50
        css::chart2::XDataSeries,
51
        css::chart2::data::XDataSink,
52
        css::chart2::data::XDataSource,
53
        css::lang::XServiceInfo,
54
        css::chart2::XRegressionCurveContainer,
55
        css::util::XCloneable,
56
        css::util::XModifyBroadcaster,
57
        css::util::XModifyListener >
58
    DataSeries_Base;
59
}
60
61
class DataSeries
62
    final
63
    : public impl::DataSeries_Base
64
    , public ::property::OPropertySet
65
{
66
public:
67
    explicit DataSeries();
68
    virtual ~DataSeries() override;
69
70
    /// XServiceInfo declarations
71
    virtual OUString SAL_CALL getImplementationName() override;
72
    virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
73
    virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
74
75
    /// merge XInterface implementations
76
    DECLARE_XINTERFACE()
77
    /// merge XTypeProvider implementations
78
    DECLARE_XTYPEPROVIDER()
79
80
    explicit DataSeries( const DataSeries & rOther );
81
82
    // ____ XDataSeries ____
83
    /// @see css::chart2::XDataSeries
84
    virtual css::uno::Reference< css::beans::XPropertySet >
85
        SAL_CALL getDataPointByIndex( sal_Int32 nIndex ) override;
86
    virtual void SAL_CALL resetDataPoint( sal_Int32 nIndex ) override;
87
    virtual void SAL_CALL resetAllDataPoints() override;
88
89
    // ____ XDataSink ____
90
    /// @see css::chart2::data::XDataSink
91
    virtual void SAL_CALL setData( const css::uno::Sequence< css::uno::Reference< css::chart2::data::XLabeledDataSequence > >& aData ) override;
92
93
    // ____ XDataSource ____
94
    /// @see css::chart2::data::XDataSource
95
    virtual css::uno::Sequence< css::uno::Reference< css::chart2::data::XLabeledDataSequence > > SAL_CALL getDataSequences() override;
96
97
    // ____ OPropertySet ____
98
    virtual void GetDefaultValue( sal_Int32 nHandle, css::uno::Any& rAny ) const override;
99
    virtual void SAL_CALL getFastPropertyValue( css::uno::Any& rValue, sal_Int32 nHandle ) const override;
100
    virtual void SAL_CALL setFastPropertyValue_NoBroadcast
101
        ( sal_Int32 nHandle,
102
          const css::uno::Any& rValue ) override;
103
104
    virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override;
105
106
    // ____ XPropertySet ____
107
    /// @see css::beans::XPropertySet
108
    virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL
109
        getPropertySetInfo() override;
110
111
    /// make original interface function visible again
112
    using ::com::sun::star::beans::XFastPropertySet::getFastPropertyValue;
113
114
    // ____ XRegressionCurveContainer ____
115
    /// @see css::chart2::XRegressionCurveContainer
116
    virtual void SAL_CALL addRegressionCurve(
117
        const css::uno::Reference< css::chart2::XRegressionCurve >& aRegressionCurve ) override;
118
    virtual void SAL_CALL removeRegressionCurve(
119
        const css::uno::Reference< css::chart2::XRegressionCurve >& aRegressionCurve ) override;
120
    virtual css::uno::Sequence< css::uno::Reference< css::chart2::XRegressionCurve > > SAL_CALL getRegressionCurves() override;
121
    virtual void SAL_CALL setRegressionCurves(
122
        const css::uno::Sequence< css::uno::Reference< css::chart2::XRegressionCurve > >& aRegressionCurves ) override;
123
124
    // ____ XCloneable ____
125
    virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone() override;
126
127
    // ____ XModifyBroadcaster ____
128
    virtual void SAL_CALL addModifyListener(
129
        const css::uno::Reference< css::util::XModifyListener >& aListener ) override;
130
    virtual void SAL_CALL removeModifyListener(
131
        const css::uno::Reference< css::util::XModifyListener >& aListener ) override;
132
133
    typedef std::vector< css::uno::Reference< css::chart2::data::XLabeledDataSequence > > tDataSequenceContainer;
134
135
    void setData( const tDataSequenceContainer& aData );
136
0
    const tDataSequenceContainer & getDataSequences2() const { return m_aDataSequences; }
137
138
    typedef
139
        std::vector< rtl::Reference< ::chart::RegressionCurveModel > >
140
        tRegressionCurveContainerType;
141
142
0
    const tRegressionCurveContainerType & getRegressionCurves2() const { return m_aRegressionCurves; }
143
144
    /** Get the label of a series (e.g. for the legend)
145
146
        @param rLabelSequenceRole
147
            The data sequence contained in xSeries that has this role will be used
148
            to take its label.
149
     */
150
    OUString getLabelForRole( const OUString & rLabelSequenceRole );
151
152
    bool hasUnhiddenData();
153
154
    bool hasPointOwnColor(
155
        sal_Int32 nPointIndex
156
        , const css::uno::Reference< css::beans::XPropertySet >& xDataPointProperties //may be NULL this is just for performance
157
         );
158
159
    // returns true if AttributedDataPoints contains nPointIndex and the
160
    // property Color is DEFAULT
161
    bool hasPointOwnProperties( sal_Int32 nPointIndex );
162
163
    sal_Int32 getAttachedAxisIndex();
164
165
0
    bool isAttachedToMainAxis() { return getAttachedAxisIndex() == 0; }
166
167
    void switchSymbolsOnOrOff( bool bSymbolsOn, sal_Int32 nSeriesIndex );
168
169
    void switchLinesOnOrOff( bool bLinesOn );
170
171
    void makeLinesThickOrThin( bool bThick );
172
173
    bool hasAttributedDataPointDifferentValue(
174
        const OUString& rPropertyName,
175
        const css::uno::Any& rPropertyValue );
176
177
    void setPropertyAlsoToAllAttributedDataPoints(
178
            const OUString& rPropertyName,
179
            const css::uno::Any& rPropertyValue );
180
181
    bool hasDataLabelsAtSeries();
182
183
    bool hasDataLabelsAtPoints();
184
185
    bool hasDataLabelAtPoint( sal_Int32 nPointIndex );
186
187
    void insertDataLabelsToSeriesAndAllPoints();
188
189
    void deleteDataLabelsFromSeriesAndAllPoints();
190
191
    sal_Int32 getExplicitNumberFormatKeyForDataLabel();
192
193
    void setCalculatedYSequence(css::uno::Reference<css::chart2::data::XLabeledDataSequence> const& xSequence);
194
195
    css::uno::Reference<css::chart2::data::XLabeledDataSequence> getCalculatedYSequence() const;
196
197
    void clearCalculatedYSequence();
198
199
private:
200
201
    // late initialization to call after copy-constructing
202
    void Init( const DataSeries & rOther );
203
204
    // ____ XModifyListener ____
205
    virtual void SAL_CALL modified(
206
        const css::lang::EventObject& aEvent ) override;
207
208
    // ____ XEventListener (base of XModifyListener) ____
209
    virtual void SAL_CALL disposing(
210
        const css::lang::EventObject& Source ) override;
211
212
    // ____ OPropertySet ____
213
    virtual void firePropertyChangeEvent() override;
214
    using OPropertySet::disposing;
215
216
    void fireModifyEvent();
217
218
    void impl_insertOrDeleteDataLabelsToSeriesAndAllPoints( bool bInsert );
219
220
    tDataSequenceContainer        m_aDataSequences;
221
222
    typedef std::map< sal_Int32,
223
        css::uno::Reference< css::beans::XPropertySet > > tDataPointAttributeContainer;
224
    tDataPointAttributeContainer  m_aAttributedDataPoints;
225
226
    tRegressionCurveContainerType m_aRegressionCurves;
227
228
    rtl::Reference<ModifyEventForwarder> m_xModifyEventForwarder;
229
230
    css::uno::Reference<css::chart2::data::XLabeledDataSequence> m_xCalculatedYSequence;
231
};
232
233
const tPropertyValueMap & StaticDataSeriesDefaults();
234
235
}  // namespace chart
236
237
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */