Avoid potential negative array index access to cached text.
[LibreOffice.git] / chart2 / source / inc / DataSeries.hxx
blobe643486d599291bb929f986d044c70b623d45670
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #pragma once
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>
29 // helper classes
30 #include <cppuhelper/implbase.hxx>
31 #include <comphelper/uno3.hxx>
32 #include "ModifyListenerHelper.hxx"
33 #include "PropertyHelper.hxx"
35 // STL
36 #include <vector>
37 #include <map>
39 #include "OPropertySet.hxx"
40 #include "charttoolsdllapi.hxx"
42 namespace com::sun::star::beans { class XPropertySet; }
44 namespace chart
46 class LabeledDataSequence;
47 class RegressionCurveModel;
49 namespace impl
51 typedef ::cppu::WeakImplHelper<
52 css::chart2::XDataSeries,
53 css::chart2::data::XDataSink,
54 css::chart2::data::XDataSource,
55 css::lang::XServiceInfo,
56 css::chart2::XRegressionCurveContainer,
57 css::util::XCloneable,
58 css::util::XModifyBroadcaster,
59 css::util::XModifyListener >
60 DataSeries_Base;
63 class OOO_DLLPUBLIC_CHARTTOOLS DataSeries
64 final
65 : public impl::DataSeries_Base
66 , public ::property::OPropertySet
68 public:
69 explicit DataSeries();
70 virtual ~DataSeries() override;
72 /// XServiceInfo declarations
73 virtual OUString SAL_CALL getImplementationName() override;
74 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
75 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
77 /// merge XInterface implementations
78 DECLARE_XINTERFACE()
79 /// merge XTypeProvider implementations
80 DECLARE_XTYPEPROVIDER()
82 explicit DataSeries( const DataSeries & rOther );
84 // ____ XDataSeries ____
85 /// @see css::chart2::XDataSeries
86 virtual css::uno::Reference< css::beans::XPropertySet >
87 SAL_CALL getDataPointByIndex( sal_Int32 nIndex ) override;
88 virtual void SAL_CALL resetDataPoint( sal_Int32 nIndex ) override;
89 virtual void SAL_CALL resetAllDataPoints() override;
91 // ____ XDataSink ____
92 /// @see css::chart2::data::XDataSink
93 virtual void SAL_CALL setData( const css::uno::Sequence< css::uno::Reference< css::chart2::data::XLabeledDataSequence > >& aData ) override;
95 // ____ XDataSource ____
96 /// @see css::chart2::data::XDataSource
97 virtual css::uno::Sequence< css::uno::Reference< css::chart2::data::XLabeledDataSequence > > SAL_CALL getDataSequences() override;
99 // ____ OPropertySet ____
100 virtual void GetDefaultValue( sal_Int32 nHandle, css::uno::Any& rAny ) const override;
101 virtual void SAL_CALL getFastPropertyValue( css::uno::Any& rValue, sal_Int32 nHandle ) const override;
102 virtual void SAL_CALL setFastPropertyValue_NoBroadcast
103 ( sal_Int32 nHandle,
104 const css::uno::Any& rValue ) override;
106 virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override;
108 // ____ XPropertySet ____
109 /// @see css::beans::XPropertySet
110 virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL
111 getPropertySetInfo() override;
113 /// make original interface function visible again
114 using ::com::sun::star::beans::XFastPropertySet::getFastPropertyValue;
116 // ____ XRegressionCurveContainer ____
117 /// @see css::chart2::XRegressionCurveContainer
118 virtual void SAL_CALL addRegressionCurve(
119 const css::uno::Reference< css::chart2::XRegressionCurve >& aRegressionCurve ) override;
120 virtual void SAL_CALL removeRegressionCurve(
121 const css::uno::Reference< css::chart2::XRegressionCurve >& aRegressionCurve ) override;
122 virtual css::uno::Sequence< css::uno::Reference< css::chart2::XRegressionCurve > > SAL_CALL getRegressionCurves() override;
123 virtual void SAL_CALL setRegressionCurves(
124 const css::uno::Sequence< css::uno::Reference< css::chart2::XRegressionCurve > >& aRegressionCurves ) override;
126 // ____ XCloneable ____
127 virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone() override;
129 // ____ XModifyBroadcaster ____
130 virtual void SAL_CALL addModifyListener(
131 const css::uno::Reference< css::util::XModifyListener >& aListener ) override;
132 virtual void SAL_CALL removeModifyListener(
133 const css::uno::Reference< css::util::XModifyListener >& aListener ) override;
135 typedef std::vector< css::uno::Reference< css::chart2::data::XLabeledDataSequence > > tDataSequenceContainer;
137 void setData( const tDataSequenceContainer& aData );
138 const tDataSequenceContainer & getDataSequences2() const { return m_aDataSequences; }
140 typedef
141 std::vector< rtl::Reference< ::chart::RegressionCurveModel > >
142 tRegressionCurveContainerType;
144 const tRegressionCurveContainerType & getRegressionCurves2() const { return m_aRegressionCurves; }
146 /** Get the label of a series (e.g. for the legend)
148 @param rLabelSequenceRole
149 The data sequence contained in xSeries that has this role will be used
150 to take its label.
152 OUString getLabelForRole( const OUString & rLabelSequenceRole );
154 bool hasUnhiddenData();
156 private:
158 // late initialization to call after copy-constructing
159 void Init( const DataSeries & rOther );
161 // ____ XModifyListener ____
162 virtual void SAL_CALL modified(
163 const css::lang::EventObject& aEvent ) override;
165 // ____ XEventListener (base of XModifyListener) ____
166 virtual void SAL_CALL disposing(
167 const css::lang::EventObject& Source ) override;
169 // ____ OPropertySet ____
170 virtual void firePropertyChangeEvent() override;
171 using OPropertySet::disposing;
173 void fireModifyEvent();
175 tDataSequenceContainer m_aDataSequences;
177 typedef std::map< sal_Int32,
178 css::uno::Reference< css::beans::XPropertySet > > tDataPointAttributeContainer;
179 tDataPointAttributeContainer m_aAttributedDataPoints;
181 tRegressionCurveContainerType m_aRegressionCurves;
183 rtl::Reference<ModifyEventForwarder> m_xModifyEventForwarder;
186 OOO_DLLPUBLIC_CHARTTOOLS const tPropertyValueMap & StaticDataSeriesDefaults();
188 } // namespace chart
190 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */