Line data Source code
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 : #ifndef INCLUDED_CHART2_SOURCE_VIEW_INC_VDATASERIES_HXX
20 : #define INCLUDED_CHART2_SOURCE_VIEW_INC_VDATASERIES_HXX
21 :
22 : #include "PropertyMapper.hxx"
23 :
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>
35 :
36 : #include <vector>
37 : #include <boost/noncopyable.hpp>
38 : #include <boost/scoped_ptr.hpp>
39 : #include <boost/ptr_container/ptr_map.hpp>
40 :
41 : namespace chart
42 : {
43 :
44 49568 : class VDataSequence
45 : {
46 : public:
47 : void init( const css::uno::Reference<css::chart2::data::XDataSequence>& xModel );
48 : bool is() const;
49 : void clear();
50 : double getValue( sal_Int32 index ) const;
51 : sal_Int32 detectNumberFormatKey( sal_Int32 index ) const;
52 : sal_Int32 getLength() const;
53 :
54 : css::uno::Reference<css::chart2::data::XDataSequence> Model;
55 :
56 : mutable css::uno::Sequence<double> Doubles;
57 : };
58 :
59 : class VDataSeries SAL_FINAL : boost::noncopyable
60 : {
61 : public:
62 : VDataSeries( const css::uno::Reference<css::chart2::XDataSeries>& xDataSeries );
63 :
64 : ~VDataSeries();
65 :
66 : css::uno::Reference<css::chart2::XDataSeries> 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 16016 : 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 > getAllX() const;
96 : css::uno::Sequence< double > 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 : bool shouldLabelNumberFormatKeyBeDetectedFromYAxis() const;
105 :
106 : sal_Int32 getLabelPlacement(
107 : sal_Int32 nPointIndex, const css::uno::Reference<css::chart2::XChartType>& xChartType,
108 : sal_Int32 nDimensionCount, bool bSwapXAndY ) const;
109 :
110 : css::uno::Reference<css::beans::XPropertySet> getPropertiesOfPoint( sal_Int32 index ) const;
111 :
112 : css::uno::Reference<css::beans::XPropertySet> getPropertiesOfSeries() const;
113 :
114 : css::chart2::Symbol* getSymbolProperties( sal_Int32 index ) const;
115 :
116 : css::uno::Reference<css::beans::XPropertySet> getXErrorBarProperties( sal_Int32 index ) const;
117 :
118 : css::uno::Reference<css::beans::XPropertySet> getYErrorBarProperties( sal_Int32 index ) const;
119 :
120 : bool hasPointOwnColor( sal_Int32 index ) const;
121 :
122 : css::chart2::StackingDirection getStackingDirection() const;
123 : sal_Int32 getAttachedAxisIndex() const;
124 : void setAttachedAxisIndex( sal_Int32 nAttachedAxisIndex );
125 :
126 : void doSortByXValues();
127 :
128 : void setConnectBars( bool bConnectBars );
129 : bool getConnectBars() const;
130 :
131 : void setGroupBarsPerAxis( bool bGroupBarsPerAxis );
132 : bool getGroupBarsPerAxis() const;
133 :
134 : void setStartingAngle( sal_Int32 nStartingAngle );
135 : sal_Int32 getStartingAngle() const;
136 :
137 : void setRoleOfSequenceForDataLabelNumberFormatDetection( const OUString& rRole );
138 :
139 : //this is only temporarily here for area chart:
140 : css::drawing::PolyPolygonShape3D m_aPolyPolygonShape3D;
141 : sal_Int32 m_nPolygonIndex;
142 : double m_fLogicMinX;
143 : double m_fLogicMaxX;
144 :
145 : //this is here for deep stacking:
146 : double m_fLogicZPos;//from 0 to series count -1
147 :
148 3106 : OUString getCID() const { return m_aCID;}
149 3044 : OUString getSeriesParticle() const { return m_aSeriesParticle;}
150 12130 : OUString getPointCID_Stub() const { return m_aPointCID_Stub;}
151 : OUString getErrorBarsCID( bool bYError ) const;
152 : OUString getLabelsCID() const;
153 1674 : OUString getLabelCID_Stub() const { return m_aLabelCID_Stub;}
154 : OUString getDataCurveCID( sal_Int32 nCurveIndex, bool bAverageLine ) const;
155 :
156 : css::chart2::DataPointLabel* getDataPointLabelIfLabel( sal_Int32 index ) const;
157 : bool getTextLabelMultiPropertyLists( sal_Int32 index, tNameSequence*& pPropNames, tAnySequence*& pPropValues ) const;
158 :
159 : OUString getDataCurveEquationCID( sal_Int32 nCurveIndex ) const;
160 : bool isAttributedDataPoint( sal_Int32 index ) const;
161 :
162 : bool isVaryColorsByPoint() const;
163 :
164 : void releaseShapes();
165 :
166 : void setMissingValueTreatment( sal_Int32 nMissingValueTreatment );
167 : sal_Int32 getMissingValueTreatment() const;
168 :
169 : void setOldTimeBased( VDataSeries* pOldSeries, double nPercent );
170 : VDataSeries* createCopyForTimeBased() const;
171 :
172 : private: //methods
173 : css::chart2::DataPointLabel* getDataPointLabel( sal_Int32 index ) const;
174 : void adaptPointCache( sal_Int32 nNewPointIndex ) const;
175 :
176 : // for copies for time based charting
177 : VDataSeries();
178 :
179 : public: //member
180 : css::uno::Reference<css::drawing::XShapes> m_xGroupShape;
181 : css::uno::Reference<css::drawing::XShapes> m_xLabelsGroupShape;
182 : css::uno::Reference<css::drawing::XShapes> m_xErrorXBarsGroupShape;
183 : css::uno::Reference<css::drawing::XShapes> m_xErrorYBarsGroupShape;
184 :
185 : //the following group shapes will be created as children of m_xGroupShape on demand
186 : //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)
187 : css::uno::Reference<css::drawing::XShapes> m_xFrontSubGroupShape;
188 : css::uno::Reference<css::drawing::XShapes> m_xBackSubGroupShape;
189 :
190 : private: //member
191 : css::uno::Reference<css::chart2::XDataSeries> m_xDataSeries;
192 :
193 : //all points given by the model data (here are not only the visible points meant)
194 : sal_Int32 m_nPointCount;
195 :
196 : VDataSequence m_aValues_X;
197 : VDataSequence m_aValues_Y;
198 : VDataSequence m_aValues_Z;
199 :
200 : VDataSequence m_aValues_Y_Min;
201 : VDataSequence m_aValues_Y_Max;
202 : VDataSequence m_aValues_Y_First;
203 : VDataSequence m_aValues_Y_Last;
204 :
205 : VDataSequence m_aValues_Bubble_Size;
206 :
207 : VDataSequence* m_pValueSequenceForDataLabelNumberFormatDetection;
208 :
209 : boost::ptr_map<OUString, VDataSequence> maPropertyMap;
210 :
211 : mutable double m_fXMeanValue;
212 : mutable double m_fYMeanValue;
213 :
214 : css::uno::Sequence<sal_Int32> m_aAttributedDataPointIndexList;
215 :
216 : css::chart2::StackingDirection m_eStackingDirection;
217 :
218 : sal_Int32 m_nAxisIndex;//indicates whether this is attached to a main or secondary axis
219 :
220 : bool m_bConnectBars;
221 :
222 : bool m_bGroupBarsPerAxis;
223 :
224 : sal_Int32 m_nStartingAngle;
225 :
226 : OUString m_aSeriesParticle;
227 : OUString m_aCID;
228 : OUString m_aPointCID_Stub;
229 : OUString m_aLabelCID_Stub;
230 :
231 : sal_Int32 m_nGlobalSeriesIndex;
232 :
233 : //some cached values for data labels as they are very expensive
234 : mutable boost::scoped_ptr<css::chart2::DataPointLabel>
235 : m_apLabel_Series;
236 : mutable boost::scoped_ptr<tNameSequence> m_apLabelPropNames_Series;
237 : mutable boost::scoped_ptr<tAnySequence> m_apLabelPropValues_Series;
238 : mutable boost::scoped_ptr<css::chart2::Symbol> m_apSymbolProperties_Series;
239 :
240 : mutable boost::scoped_ptr<css::chart2::DataPointLabel>
241 : m_apLabel_AttributedPoint;
242 : mutable boost::scoped_ptr<tNameSequence> m_apLabelPropNames_AttributedPoint;
243 : mutable boost::scoped_ptr<tAnySequence> m_apLabelPropValues_AttributedPoint;
244 : mutable boost::scoped_ptr<css::chart2::Symbol> m_apSymbolProperties_AttributedPoint;
245 : mutable boost::scoped_ptr<css::chart2::Symbol>
246 : m_apSymbolProperties_InvisibleSymbolForSelection;
247 : mutable sal_Int32 m_nCurrentAttributedPoint;
248 : css::awt::Size m_aReferenceSize;
249 :
250 : sal_Int32 m_nMissingValueTreatment;
251 : bool m_bAllowPercentValueInDataLabel;
252 :
253 : // for time based charting
254 : VDataSeries* mpOldSeries;
255 : double mnPercent;
256 : };
257 :
258 : } //namespace chart
259 : #endif
260 :
261 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|