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