Version 6.1.4.1, tag libreoffice-6.1.4.1
[LibreOffice.git] / chart2 / source / view / inc / VDataSeries.hxx
blob1566c642c74526e238ff1ed6579b0bc2540ba416
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 #ifndef INCLUDED_CHART2_SOURCE_VIEW_INC_VDATASERIES_HXX
20 #define INCLUDED_CHART2_SOURCE_VIEW_INC_VDATASERIES_HXX
22 #include "PropertyMapper.hxx"
24 #include <com/sun/star/chart2/DataPointLabel.hpp>
25 #include <com/sun/star/chart2/Symbol.hpp>
26 #include <com/sun/star/chart2/StackingDirection.hpp>
27 #include <com/sun/star/chart2/data/XLabeledDataSequence.hpp>
28 #include <com/sun/star/chart2/XChartType.hpp>
29 #include <com/sun/star/chart2/XDataSeries.hpp>
30 #include <com/sun/star/drawing/HomogenMatrix.hpp>
31 #include <com/sun/star/drawing/PolyPolygonShape3D.hpp>
32 #include <com/sun/star/drawing/XShape.hpp>
33 #include <com/sun/star/drawing/XShapes.hpp>
34 #include <cppuhelper/weakref.hxx>
36 #include <memory>
37 #include <vector>
38 #include <map>
40 namespace chart
43 class VDataSequence
45 public:
46 void init( const css::uno::Reference<css::chart2::data::XDataSequence>& xModel );
47 bool is() const;
48 void clear();
49 double getValue( sal_Int32 index ) const;
50 sal_Int32 detectNumberFormatKey( sal_Int32 index ) const;
51 sal_Int32 getLength() const;
53 css::uno::Reference<css::chart2::data::XDataSequence> Model;
55 mutable css::uno::Sequence<double> Doubles;
58 class VDataSeries final
60 public:
61 VDataSeries( const css::uno::Reference<css::chart2::XDataSeries>& xDataSeries );
63 ~VDataSeries();
65 VDataSeries(const VDataSeries&) = delete;
66 const VDataSeries& operator=(const VDataSeries&) = delete;
68 const css::uno::Reference<css::chart2::XDataSeries>& getModel() const;
70 void setCategoryXAxis();
71 void setXValues( const css::uno::Reference<css::chart2::data::XDataSequence>& xValues );
72 void setXValuesIfNone( const css::uno::Reference<css::chart2::data::XDataSequence>& xValues );
73 void setParticle( const OUString& rSeriesParticle );
74 void setGlobalSeriesIndex( sal_Int32 nGlobalSeriesIndex );
75 void setPageReferenceSize( const css::awt::Size & rPageRefSize );
77 sal_Int32 getTotalPointCount() const { return m_nPointCount;}
78 double getXValue( sal_Int32 index ) const;
79 double getYValue( sal_Int32 index ) const;
81 void getMinMaxXValue( double& fMin, double& fMax ) const;
83 double getY_Min( sal_Int32 index ) const;
84 double getY_Max( sal_Int32 index ) const;
85 double getY_First( sal_Int32 index ) const;
86 double getY_Last( sal_Int32 index ) const;
88 double getBubble_Size( sal_Int32 index ) const;
90 double getMinimumofAllDifferentYValues( sal_Int32 index ) const;
91 double getMaximumofAllDifferentYValues( sal_Int32 index ) const;
93 double getValueByProperty( sal_Int32 index, const OUString& rPropName ) const;
95 bool hasPropertyMapping( const OUString& rPropName ) const;
97 css::uno::Sequence< double > const & getAllX() const;
98 css::uno::Sequence< double > const & getAllY() const;
100 double getXMeanValue() const;
101 double getYMeanValue() const;
103 bool hasExplicitNumberFormat( sal_Int32 nPointIndex, bool bForPercentage ) const;
104 sal_Int32 getExplicitNumberFormat( sal_Int32 nPointIndex, bool bForPercentage ) const;
105 sal_Int32 detectNumberFormatKey( sal_Int32 nPointIndex ) const;
106 bool shouldLabelNumberFormatKeyBeDetectedFromYAxis() const;
108 sal_Int32 getLabelPlacement(
109 sal_Int32 nPointIndex, const css::uno::Reference<css::chart2::XChartType>& xChartType,
110 bool bSwapXAndY ) const;
112 css::uno::Reference<css::beans::XPropertySet> getPropertiesOfPoint( sal_Int32 index ) const;
114 css::uno::Reference<css::beans::XPropertySet> getPropertiesOfSeries() const;
116 css::chart2::Symbol* getSymbolProperties( sal_Int32 index ) const;
118 css::uno::Reference<css::beans::XPropertySet> getXErrorBarProperties( sal_Int32 index ) const;
120 css::uno::Reference<css::beans::XPropertySet> getYErrorBarProperties( sal_Int32 index ) const;
122 bool hasPointOwnColor( sal_Int32 index ) const;
124 css::chart2::StackingDirection getStackingDirection() const;
125 sal_Int32 getAttachedAxisIndex() const;
126 void setAttachedAxisIndex( sal_Int32 nAttachedAxisIndex );
128 void doSortByXValues();
130 void setConnectBars( bool bConnectBars );
131 bool getConnectBars() const;
133 void setGroupBarsPerAxis( bool bGroupBarsPerAxis );
134 bool getGroupBarsPerAxis() const;
136 void setStartingAngle( sal_Int32 nStartingAngle );
137 sal_Int32 getStartingAngle() const;
139 void setRoleOfSequenceForDataLabelNumberFormatDetection( const OUString& rRole );
141 //this is only temporarily here for area chart:
142 css::drawing::PolyPolygonShape3D m_aPolyPolygonShape3D;
143 sal_Int32 m_nPolygonIndex;
144 double m_fLogicMinX;
145 double m_fLogicMaxX;
147 //this is here for deep stacking:
148 double m_fLogicZPos;//from 0 to series count -1
150 const OUString& getCID() const { return m_aCID;}
151 const OUString& getSeriesParticle() const { return m_aSeriesParticle;}
152 const OUString& getPointCID_Stub() const { return m_aPointCID_Stub;}
153 OUString getErrorBarsCID( bool bYError ) const;
154 OUString getLabelsCID() const;
155 const OUString& getLabelCID_Stub() const { return m_aLabelCID_Stub;}
156 OUString getDataCurveCID( sal_Int32 nCurveIndex, bool bAverageLine ) const;
158 css::chart2::DataPointLabel* getDataPointLabelIfLabel( sal_Int32 index ) const;
159 bool getTextLabelMultiPropertyLists( sal_Int32 index, tNameSequence*& pPropNames, tAnySequence*& pPropValues ) const;
161 OUString getDataCurveEquationCID( sal_Int32 nCurveIndex ) const;
162 bool isAttributedDataPoint( sal_Int32 index ) const;
164 bool isVaryColorsByPoint() const;
166 void releaseShapes();
168 void setMissingValueTreatment( sal_Int32 nMissingValueTreatment );
169 sal_Int32 getMissingValueTreatment() const;
171 void setOldTimeBased( VDataSeries* pOldSeries, double nPercent );
172 VDataSeries* createCopyForTimeBased() const;
174 private: //methods
175 css::chart2::DataPointLabel* getDataPointLabel( sal_Int32 index ) const;
176 void adaptPointCache( sal_Int32 nNewPointIndex ) const;
178 // for copies for time based charting
179 VDataSeries();
181 public: //member
182 css::uno::Reference<css::drawing::XShapes> m_xGroupShape;
183 css::uno::Reference<css::drawing::XShapes> m_xLabelsGroupShape;
184 css::uno::Reference<css::drawing::XShapes> m_xErrorXBarsGroupShape;
185 css::uno::Reference<css::drawing::XShapes> m_xErrorYBarsGroupShape;
187 //the following group shapes will be created as children of m_xGroupShape on demand
188 //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)
189 css::uno::Reference<css::drawing::XShapes> m_xFrontSubGroupShape;
190 css::uno::Reference<css::drawing::XShapes> m_xBackSubGroupShape;
192 private: //member
193 css::uno::Reference<css::chart2::XDataSeries> m_xDataSeries;
195 //all points given by the model data (here are not only the visible points meant)
196 sal_Int32 m_nPointCount;
198 VDataSequence m_aValues_X;
199 VDataSequence m_aValues_Y;
200 VDataSequence m_aValues_Z;
202 VDataSequence m_aValues_Y_Min;
203 VDataSequence m_aValues_Y_Max;
204 VDataSequence m_aValues_Y_First;
205 VDataSequence m_aValues_Y_Last;
207 VDataSequence m_aValues_Bubble_Size;
209 VDataSequence* m_pValueSequenceForDataLabelNumberFormatDetection;
211 std::map<OUString, VDataSequence> m_PropertyMap;
213 mutable double m_fXMeanValue;
214 mutable double m_fYMeanValue;
216 css::uno::Sequence<sal_Int32> m_aAttributedDataPointIndexList;
218 css::chart2::StackingDirection m_eStackingDirection;
220 sal_Int32 m_nAxisIndex;//indicates whether this is attached to a main or secondary axis
222 bool m_bConnectBars;
224 bool m_bGroupBarsPerAxis;
226 sal_Int32 m_nStartingAngle;
228 OUString m_aSeriesParticle;
229 OUString m_aCID;
230 OUString m_aPointCID_Stub;
231 OUString m_aLabelCID_Stub;
233 sal_Int32 m_nGlobalSeriesIndex;
235 //some cached values for data labels as they are very expensive
236 mutable std::unique_ptr<css::chart2::DataPointLabel>
237 m_apLabel_Series;
238 mutable std::unique_ptr<tNameSequence> m_apLabelPropNames_Series;
239 mutable std::unique_ptr<tAnySequence> m_apLabelPropValues_Series;
240 mutable std::unique_ptr<css::chart2::Symbol> m_apSymbolProperties_Series;
242 mutable std::unique_ptr<css::chart2::DataPointLabel>
243 m_apLabel_AttributedPoint;
244 mutable std::unique_ptr<tNameSequence> m_apLabelPropNames_AttributedPoint;
245 mutable std::unique_ptr<tAnySequence> m_apLabelPropValues_AttributedPoint;
246 mutable std::unique_ptr<css::chart2::Symbol> m_apSymbolProperties_AttributedPoint;
247 mutable std::unique_ptr<css::chart2::Symbol>
248 m_apSymbolProperties_InvisibleSymbolForSelection;
249 mutable sal_Int32 m_nCurrentAttributedPoint;
250 css::awt::Size m_aReferenceSize;
252 sal_Int32 m_nMissingValueTreatment;
253 bool m_bAllowPercentValueInDataLabel;
255 // for time based charting
256 VDataSeries* mpOldSeries;
257 double mnPercent;
260 } //namespace chart
261 #endif
263 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */