/src/libreoffice/chart2/source/view/inc/VDataSeries.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 | | #include "PropertyMapper.hxx" |
22 | | |
23 | | #include <com/sun/star/chart2/DataPointLabel.hpp> |
24 | | #include <com/sun/star/chart2/StackingDirection.hpp> |
25 | | #include <com/sun/star/chart2/Symbol.hpp> |
26 | | #include <com/sun/star/drawing/Position3D.hpp> |
27 | | #include <com/sun/star/awt/Size.hpp> |
28 | | #include <com/sun/star/awt/Point.hpp> |
29 | | #include <rtl/ref.hxx> |
30 | | #include <svx/unoshape.hxx> |
31 | | |
32 | | #include <map> |
33 | | |
34 | | namespace com::sun::star::beans { class XPropertySet; } |
35 | | namespace com::sun::star::chart2::data { class XDataSequence; } |
36 | | |
37 | | namespace chart |
38 | | { |
39 | | class ChartType; |
40 | | class DataSeries; |
41 | | |
42 | | class VDataSequence |
43 | | { |
44 | | public: |
45 | | void init( const css::uno::Reference<css::chart2::data::XDataSequence>& xModel ); |
46 | | bool is() const; |
47 | | void clear(); |
48 | | double getValue( sal_Int32 index ) const; |
49 | | sal_Int32 detectNumberFormatKey( sal_Int32 index ) const; |
50 | | sal_Int32 getLength() const; |
51 | | |
52 | | css::uno::Reference<css::chart2::data::XDataSequence> m_xModel; |
53 | | mutable css::uno::Sequence<double> m_aValues; |
54 | | }; |
55 | | |
56 | | class VDataSeries final |
57 | | { |
58 | | public: |
59 | | VDataSeries( const rtl::Reference<::chart::DataSeries>& xDataSeries ); |
60 | | |
61 | | ~VDataSeries(); |
62 | | |
63 | | VDataSeries(const VDataSeries&) = delete; |
64 | | const VDataSeries& operator=(const VDataSeries&) = delete; |
65 | | |
66 | | const rtl::Reference<::chart::DataSeries>& getModel() const; |
67 | | |
68 | | void setCategoryXAxis(); |
69 | | void setXValues( const css::uno::Reference<css::chart2::data::XDataSequence>& xValues ); |
70 | | void setXValuesIfNone( const css::uno::Reference<css::chart2::data::XDataSequence>& xValues ); |
71 | | void setParticle( const OUString& rSeriesParticle ); |
72 | | void setGlobalSeriesIndex( sal_Int32 nGlobalSeriesIndex ); |
73 | | void setPageReferenceSize( const css::awt::Size & rPageRefSize ); |
74 | | |
75 | 0 | sal_Int32 getTotalPointCount() const { return m_nPointCount;} |
76 | | double getXValue( sal_Int32 index ) const; |
77 | | double getYValue( sal_Int32 index ) const; |
78 | | |
79 | | void getMinMaxXValue( double& fMin, double& fMax ) const; |
80 | | |
81 | | double getY_Min( sal_Int32 index ) const; |
82 | | double getY_Max( sal_Int32 index ) const; |
83 | | double getY_First( sal_Int32 index ) const; |
84 | | double getY_Last( sal_Int32 index ) const; |
85 | | |
86 | | double getBubble_Size( sal_Int32 index ) const; |
87 | | |
88 | | double getMinimumofAllDifferentYValues( sal_Int32 index ) const; |
89 | | double getMaximumofAllDifferentYValues( sal_Int32 index ) const; |
90 | | |
91 | | double getValueByProperty( sal_Int32 index, const OUString& rPropName ) const; |
92 | | |
93 | | bool hasPropertyMapping( const OUString& rPropName ) const; |
94 | | |
95 | | css::uno::Sequence< double > const & getAllX() const; |
96 | | css::uno::Sequence< double > const & getAllY() const; |
97 | | |
98 | | double getXMeanValue() const; |
99 | | double getYMeanValue() const; |
100 | | |
101 | | bool hasExplicitNumberFormat( sal_Int32 nPointIndex, bool bForPercentage ) const; |
102 | | sal_Int32 getExplicitNumberFormat( sal_Int32 nPointIndex, bool bForPercentage ) const; |
103 | | sal_Int32 detectNumberFormatKey( sal_Int32 nPointIndex ) const; |
104 | | |
105 | | sal_Int32 getLabelPlacement( |
106 | | sal_Int32 nPointIndex, const rtl::Reference<::chart::ChartType>& xChartType, |
107 | | bool bSwapXAndY ) const; |
108 | | |
109 | | css::awt::Point getLabelPosition( css::awt::Point aTextShapePos, sal_Int32 nPointIndex ) const; |
110 | | bool isLabelCustomPos( sal_Int32 nPointIndex ) const; |
111 | | css::awt::Size getLabelCustomSize(sal_Int32 nPointIndex) const; |
112 | | |
113 | | css::uno::Reference<css::beans::XPropertySet> getPropertiesOfPoint( sal_Int32 index ) const; |
114 | | |
115 | | const css::uno::Reference<css::beans::XPropertySet> & getPropertiesOfSeries() const; |
116 | | |
117 | | css::chart2::Symbol* getSymbolProperties( sal_Int32 index ) const; |
118 | | |
119 | | css::uno::Reference<css::beans::XPropertySet> getXErrorBarProperties( sal_Int32 index ) const; |
120 | | |
121 | | css::uno::Reference<css::beans::XPropertySet> getYErrorBarProperties( sal_Int32 index ) const; |
122 | | |
123 | | bool hasPointOwnColor( sal_Int32 index ) const; |
124 | | |
125 | | css::chart2::StackingDirection getStackingDirection() const; |
126 | | sal_Int32 getAttachedAxisIndex() const; |
127 | | void setAttachedAxisIndex( sal_Int32 nAttachedAxisIndex ); |
128 | | |
129 | | void doSortByXValues(); |
130 | | |
131 | | void setConnectBars( bool bConnectBars ); |
132 | | bool getConnectBars() const; |
133 | | |
134 | | void setGroupBarsPerAxis( bool bGroupBarsPerAxis ); |
135 | | bool getGroupBarsPerAxis() const; |
136 | | |
137 | | void setStartingAngle( sal_Int32 nStartingAngle ); |
138 | | sal_Int32 getStartingAngle() const; |
139 | | |
140 | | void setRoleOfSequenceForDataLabelNumberFormatDetection( std::u16string_view rRole ); |
141 | | |
142 | | //this is only temporarily here for area chart: |
143 | | std::vector<std::vector<css::drawing::Position3D>> m_aPolyPolygonShape3D; |
144 | | sal_Int32 m_nPolygonIndex; |
145 | | double m_fLogicMinX; |
146 | | double m_fLogicMaxX; |
147 | | |
148 | | //this is here for deep stacking: |
149 | | double m_fLogicZPos;//from 0 to series count -1 |
150 | | |
151 | 0 | const OUString& getCID() const { return m_aCID;} |
152 | 0 | const OUString& getSeriesParticle() const { return m_aSeriesParticle;} |
153 | 0 | const OUString& getPointCID_Stub() const { return m_aPointCID_Stub;} |
154 | | OUString getErrorBarsCID( bool bYError ) const; |
155 | | OUString getLabelsCID() const; |
156 | 0 | const OUString& getLabelCID_Stub() const { return m_aLabelCID_Stub;} |
157 | | OUString getDataCurveCID( sal_Int32 nCurveIndex, bool bAverageLine ) const; |
158 | | |
159 | | css::chart2::DataPointLabel* getDataPointLabelIfLabel( sal_Int32 index ) const; |
160 | | bool getTextLabelMultiPropertyLists( sal_Int32 index, tNameSequence*& pPropNames, tAnySequence*& pPropValues ) const; |
161 | | |
162 | | OUString getDataCurveEquationCID( sal_Int32 nCurveIndex ) const; |
163 | | bool isAttributedDataPoint( sal_Int32 index ) const; |
164 | | |
165 | | bool isVaryColorsByPoint() const; |
166 | | |
167 | | void releaseShapes(); |
168 | | |
169 | | void setMissingValueTreatment( sal_Int32 nMissingValueTreatment ); |
170 | | sal_Int32 getMissingValueTreatment() const; |
171 | | |
172 | | void setOldTimeBased( VDataSeries* pOldSeries, double nPercent ); |
173 | | VDataSeries* createCopyForTimeBased() const; |
174 | | |
175 | | private: //methods |
176 | | css::chart2::DataPointLabel* getDataPointLabel( sal_Int32 index ) const; |
177 | | void adaptPointCache( sal_Int32 nNewPointIndex ) const; |
178 | | |
179 | | // for copies for time based charting |
180 | | VDataSeries(); |
181 | | |
182 | | public: //member |
183 | | rtl::Reference<SvxShapeGroupAnyD> m_xGroupShape; |
184 | | rtl::Reference<SvxShapeGroup> m_xLabelsGroupShape; |
185 | | rtl::Reference<SvxShapeGroupAnyD> m_xErrorXBarsGroupShape; |
186 | | rtl::Reference<SvxShapeGroupAnyD> m_xErrorYBarsGroupShape; |
187 | | |
188 | | //the following group shapes will be created as children of m_xGroupShape on demand |
189 | | //they can be used to assure that some parts of a series shape are always in front of others (e.g. symbols in front of lines) |
190 | | rtl::Reference<SvxShapeGroupAnyD> m_xFrontSubGroupShape; |
191 | | rtl::Reference<SvxShapeGroupAnyD> m_xBackSubGroupShape; |
192 | | |
193 | | private: //member |
194 | | rtl::Reference<::chart::DataSeries> m_xDataSeries; |
195 | | css::uno::Reference<css::beans::XPropertySet> m_xDataSeriesProps; // cached |
196 | | |
197 | | //all points given by the model data (here are not only the visible points meant) |
198 | | sal_Int32 m_nPointCount; |
199 | | |
200 | | VDataSequence m_aValues_X; |
201 | | VDataSequence m_aValues_Y; |
202 | | VDataSequence m_aValues_Z; |
203 | | |
204 | | VDataSequence m_aValues_Y_Min; |
205 | | VDataSequence m_aValues_Y_Max; |
206 | | VDataSequence m_aValues_Y_First; |
207 | | VDataSequence m_aValues_Y_Last; |
208 | | |
209 | | VDataSequence m_aValues_Bubble_Size; |
210 | | |
211 | | VDataSequence* m_pValueSequenceForDataLabelNumberFormatDetection; |
212 | | |
213 | | std::map<OUString, VDataSequence> m_PropertyMap; |
214 | | |
215 | | mutable double m_fXMeanValue; |
216 | | mutable double m_fYMeanValue; |
217 | | |
218 | | css::uno::Sequence<sal_Int32> m_aAttributedDataPointIndexList; |
219 | | |
220 | | css::chart2::StackingDirection m_eStackingDirection; |
221 | | |
222 | | sal_Int32 m_nAxisIndex;//indicates whether this is attached to a main or secondary axis |
223 | | |
224 | | bool m_bConnectBars; |
225 | | |
226 | | bool m_bGroupBarsPerAxis; |
227 | | |
228 | | sal_Int32 m_nStartingAngle; |
229 | | |
230 | | OUString m_aSeriesParticle; |
231 | | OUString m_aCID; |
232 | | OUString m_aPointCID_Stub; |
233 | | OUString m_aLabelCID_Stub; |
234 | | |
235 | | sal_Int32 m_nGlobalSeriesIndex; |
236 | | |
237 | | //some cached values for data labels as they are very expensive |
238 | | mutable std::optional<css::chart2::DataPointLabel> |
239 | | m_oLabel_Series; |
240 | | mutable std::optional<tNameSequence> m_oLabelPropNames_Series; |
241 | | mutable std::optional<tAnySequence> m_oLabelPropValues_Series; |
242 | | mutable std::optional<css::chart2::Symbol> m_oSymbolProperties_Series; |
243 | | |
244 | | mutable std::optional<css::chart2::DataPointLabel> |
245 | | m_oLabel_AttributedPoint; |
246 | | mutable std::optional<tNameSequence> m_oLabelPropNames_AttributedPoint; |
247 | | mutable std::optional<tAnySequence> m_oLabelPropValues_AttributedPoint; |
248 | | mutable std::optional<css::chart2::Symbol> m_oSymbolProperties_AttributedPoint; |
249 | | mutable std::optional<css::chart2::Symbol> m_oSymbolProperties_InvisibleSymbolForSelection; |
250 | | mutable sal_Int32 m_nCurrentAttributedPoint; |
251 | | css::awt::Size m_aReferenceSize; |
252 | | |
253 | | sal_Int32 m_nMissingValueTreatment; |
254 | | bool m_bAllowPercentValueInDataLabel; |
255 | | |
256 | | // for time based charting |
257 | | VDataSeries* mpOldSeries; |
258 | | double mnPercent; |
259 | | }; |
260 | | |
261 | | } //namespace chart |
262 | | |
263 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |