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 0 : class VDataSequence
45 : {
46 : public:
47 : void init( const ::com::sun::star::uno::Reference<
48 : ::com::sun::star::chart2::data::XDataSequence >& xModel );
49 : bool is() const;
50 : void clear();
51 : double getValue( sal_Int32 index ) const;
52 : sal_Int32 detectNumberFormatKey( sal_Int32 index ) const;
53 : sal_Int32 getLength() const;
54 :
55 : ::com::sun::star::uno::Reference<
56 : ::com::sun::star::chart2::data::XDataSequence > Model;
57 :
58 : mutable ::com::sun::star::uno::Sequence< double > Doubles;
59 : };
60 :
61 : class VDataSeries SAL_FINAL : boost::noncopyable
62 : {
63 : public:
64 : VDataSeries( const ::com::sun::star::uno::Reference<
65 : ::com::sun::star::chart2::XDataSeries >& xDataSeries );
66 :
67 : ~VDataSeries();
68 :
69 : ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDataSeries >
70 : getModel() const;
71 :
72 : void setCategoryXAxis();
73 : void setXValues( const ::com::sun::star::uno::Reference<
74 : ::com::sun::star::chart2::data::XDataSequence >& xValues );
75 : void setXValuesIfNone( const ::com::sun::star::uno::Reference<
76 : ::com::sun::star::chart2::data::XDataSequence >& xValues );
77 : void setParticle( const OUString& rSeriesParticle );
78 : void setGlobalSeriesIndex( sal_Int32 nGlobalSeriesIndex );
79 : void setPageReferenceSize( const ::com::sun::star::awt::Size & rPageRefSize );
80 :
81 : sal_Int32 getTotalPointCount() const;
82 : double getXValue( sal_Int32 index ) const;
83 : double getYValue( sal_Int32 index ) const;
84 :
85 : void getMinMaxXValue( double& fMin, double& fMax ) const;
86 :
87 : double getY_Min( sal_Int32 index ) const;
88 : double getY_Max( sal_Int32 index ) const;
89 : double getY_First( sal_Int32 index ) const;
90 : double getY_Last( sal_Int32 index ) const;
91 :
92 : double getBubble_Size( sal_Int32 index ) const;
93 :
94 : double getMinimumofAllDifferentYValues( sal_Int32 index ) const;
95 : double getMaximumofAllDifferentYValues( sal_Int32 index ) const;
96 :
97 : double getValueByProperty( sal_Int32 index, const OUString& rPropName ) const;
98 :
99 : bool hasPropertyMapping( const OUString& rPropName ) const;
100 :
101 : ::com::sun::star::uno::Sequence< double > getAllX() const;
102 : ::com::sun::star::uno::Sequence< double > getAllY() const;
103 :
104 : double getXMeanValue() const;
105 : double getYMeanValue() const;
106 :
107 : bool hasExplicitNumberFormat( sal_Int32 nPointIndex, bool bForPercentage ) const;
108 : sal_Int32 getExplicitNumberFormat( sal_Int32 nPointIndex, bool bForPercentage ) const;
109 : sal_Int32 detectNumberFormatKey( sal_Int32 nPointIndex ) const;
110 : bool shouldLabelNumberFormatKeyBeDetectedFromYAxis() const;
111 :
112 : sal_Int32 getLabelPlacement( sal_Int32 nPointIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartType >& xChartType
113 : , sal_Int32 nDimensionCount, sal_Bool bSwapXAndY ) const;
114 :
115 : ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
116 : getPropertiesOfPoint( sal_Int32 index ) const;
117 :
118 : ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
119 : getPropertiesOfSeries() const;
120 :
121 : ::com::sun::star::chart2::Symbol*
122 : getSymbolProperties( sal_Int32 index ) const;
123 :
124 : ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
125 : getXErrorBarProperties( sal_Int32 index ) const;
126 :
127 : ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
128 : getYErrorBarProperties( sal_Int32 index ) const;
129 :
130 : bool hasPointOwnColor( sal_Int32 index ) const;
131 :
132 : ::com::sun::star::chart2::StackingDirection getStackingDirection() const;
133 : sal_Int32 getAttachedAxisIndex() const;
134 : void setAttachedAxisIndex( sal_Int32 nAttachedAxisIndex );
135 :
136 : void doSortByXValues();
137 :
138 : void setConnectBars( sal_Bool bConnectBars );
139 : sal_Bool getConnectBars() const;
140 :
141 : void setGroupBarsPerAxis( sal_Bool bGroupBarsPerAxis );
142 : sal_Bool getGroupBarsPerAxis() const;
143 :
144 : void setStartingAngle( sal_Int32 nStartingAngle );
145 : sal_Int32 getStartingAngle() const;
146 :
147 : void setRoleOfSequenceForDataLabelNumberFormatDetection( const OUString& rRole );
148 :
149 : //this is only temporarily here for area chart:
150 : ::com::sun::star::drawing::PolyPolygonShape3D m_aPolyPolygonShape3D;
151 : sal_Int32 m_nPolygonIndex;
152 : double m_fLogicMinX;
153 : double m_fLogicMaxX;
154 :
155 : //this is here for deep stacking:
156 : double m_fLogicZPos;//from 0 to series count -1
157 :
158 : OUString getCID() const;
159 : OUString getSeriesParticle() const;
160 : OUString getPointCID_Stub() const;
161 : OUString getErrorBarsCID( bool bYError ) const;
162 : OUString getLabelsCID() const;
163 : OUString getLabelCID_Stub() const;
164 : OUString getDataCurveCID( sal_Int32 nCurveIndex, bool bAverageLine ) const;
165 :
166 : ::com::sun::star::chart2::DataPointLabel*
167 : getDataPointLabelIfLabel( sal_Int32 index ) const;
168 : bool getTextLabelMultiPropertyLists( sal_Int32 index, tNameSequence*& pPropNames, tAnySequence*& pPropValues ) const;
169 :
170 : OUString getDataCurveEquationCID( sal_Int32 nCurveIndex ) const;
171 : bool isAttributedDataPoint( sal_Int32 index ) const;
172 :
173 : bool isVaryColorsByPoint() const;
174 :
175 : void releaseShapes();
176 :
177 : void setMissingValueTreatment( sal_Int32 nMissingValueTreatment );
178 : sal_Int32 getMissingValueTreatment() const;
179 :
180 : void setOldTimeBased( VDataSeries* pOldSeries, double nPercent );
181 : VDataSeries* createCopyForTimeBased() const;
182 :
183 : private: //methods
184 : ::com::sun::star::chart2::DataPointLabel*
185 : getDataPointLabel( sal_Int32 index ) const;
186 : void adaptPointCache( sal_Int32 nNewPointIndex ) const;
187 :
188 : // for copies for time based charting
189 : VDataSeries();
190 :
191 : public: //member
192 : ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes > m_xGroupShape;
193 : ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes > m_xLabelsGroupShape;
194 : ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes > m_xErrorXBarsGroupShape;
195 : ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes > m_xErrorYBarsGroupShape;
196 :
197 : //the following group shapes will be created as children of m_xGroupShape on demand
198 : //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)
199 : ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes > m_xFrontSubGroupShape;
200 : ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes > m_xBackSubGroupShape;
201 :
202 : private: //member
203 : ::com::sun::star::uno::Reference<
204 : ::com::sun::star::chart2::XDataSeries > m_xDataSeries;
205 :
206 : //all points given by the model data (here are not only the visible points meant)
207 : sal_Int32 m_nPointCount;
208 :
209 : VDataSequence m_aValues_X;
210 : VDataSequence m_aValues_Y;
211 : VDataSequence m_aValues_Z;
212 :
213 : VDataSequence m_aValues_Y_Min;
214 : VDataSequence m_aValues_Y_Max;
215 : VDataSequence m_aValues_Y_First;
216 : VDataSequence m_aValues_Y_Last;
217 :
218 : VDataSequence m_aValues_Bubble_Size;
219 :
220 : VDataSequence* m_pValueSequenceForDataLabelNumberFormatDetection;
221 :
222 : boost::ptr_map<OUString, VDataSequence> maPropertyMap;
223 :
224 : mutable double m_fXMeanValue;
225 : mutable double m_fYMeanValue;
226 :
227 : ::com::sun::star::uno::Sequence< sal_Int32 > m_aAttributedDataPointIndexList;
228 :
229 : ::com::sun::star::chart2::StackingDirection m_eStackingDirection;
230 :
231 : sal_Int32 m_nAxisIndex;//indicates whether this is attached to a main or secondary axis
232 :
233 : sal_Bool m_bConnectBars;
234 :
235 : sal_Bool m_bGroupBarsPerAxis;
236 :
237 : sal_Int32 m_nStartingAngle;
238 :
239 : OUString m_aSeriesParticle;
240 : OUString m_aCID;
241 : OUString m_aPointCID_Stub;
242 : OUString m_aLabelCID_Stub;
243 :
244 : sal_Int32 m_nGlobalSeriesIndex;
245 :
246 : //some cached values for data labels as they are very expensive
247 : mutable boost::scoped_ptr<com::sun::star::chart2::DataPointLabel>
248 : m_apLabel_Series;
249 : mutable boost::scoped_ptr<tNameSequence> m_apLabelPropNames_Series;
250 : mutable boost::scoped_ptr<tAnySequence> m_apLabelPropValues_Series;
251 : mutable boost::scoped_ptr<com::sun::star::chart2::Symbol>
252 : m_apSymbolProperties_Series;
253 :
254 : mutable boost::scoped_ptr<com::sun::star::chart2::DataPointLabel>
255 : m_apLabel_AttributedPoint;
256 : mutable boost::scoped_ptr<tNameSequence> m_apLabelPropNames_AttributedPoint;
257 : mutable boost::scoped_ptr<tAnySequence> m_apLabelPropValues_AttributedPoint;
258 : mutable boost::scoped_ptr<com::sun::star::chart2::Symbol>
259 : m_apSymbolProperties_AttributedPoint;
260 : mutable boost::scoped_ptr<com::sun::star::chart2::Symbol>
261 : m_apSymbolProperties_InvisibleSymbolForSelection;
262 : mutable sal_Int32 m_nCurrentAttributedPoint;
263 : ::com::sun::star::awt::Size m_aReferenceSize;
264 :
265 : sal_Int32 m_nMissingValueTreatment;
266 : bool m_bAllowPercentValueInDataLabel;
267 :
268 : // for time based charting
269 : VDataSeries* mpOldSeries;
270 : double mnPercent;
271 : };
272 :
273 : } //namespace chart
274 : #endif
275 :
276 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|