1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 #ifndef _CHART2_VIEW_DATASERIES_HXX 24 #define _CHART2_VIEW_DATASERIES_HXX 25 26 #include "PropertyMapper.hxx" 27 28 #include <vector> 29 //for auto_ptr 30 #include <memory> 31 #include <com/sun/star/chart2/DataPointLabel.hpp> 32 #include <com/sun/star/chart2/Symbol.hpp> 33 #include <com/sun/star/chart2/StackingDirection.hpp> 34 #include <com/sun/star/chart2/data/XLabeledDataSequence.hpp> 35 #include <com/sun/star/chart2/XChartType.hpp> 36 #include <com/sun/star/chart2/XDataSeries.hpp> 37 #include <com/sun/star/drawing/HomogenMatrix.hpp> 38 #include <com/sun/star/drawing/PolyPolygonShape3D.hpp> 39 #include <com/sun/star/drawing/XShape.hpp> 40 #include <com/sun/star/drawing/XShapes.hpp> 41 #include <cppuhelper/weakref.hxx> 42 43 //............................................................................. 44 namespace chart 45 { 46 //............................................................................. 47 48 //----------------------------------------------------------------------------- 49 /** 50 */ 51 class VDataSequence 52 { 53 public: 54 void init( const ::com::sun::star::uno::Reference< 55 ::com::sun::star::chart2::data::XDataSequence >& xModel ); 56 bool is() const; 57 void clear(); 58 double getValue( sal_Int32 index ) const; 59 sal_Int32 detectNumberFormatKey( sal_Int32 index ) const; 60 sal_Int32 getLength() const; 61 62 63 ::com::sun::star::uno::Reference< 64 ::com::sun::star::chart2::data::XDataSequence > Model; 65 66 mutable ::com::sun::star::uno::Sequence< double > Doubles; 67 }; 68 69 class VDataSeries 70 { 71 public: 72 VDataSeries( const ::com::sun::star::uno::Reference< 73 ::com::sun::star::chart2::XDataSeries >& xDataSeries ); 74 virtual ~VDataSeries(); 75 76 ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDataSeries > 77 getModel() const; 78 79 void setCategoryXAxis(); 80 void setXValues( const ::com::sun::star::uno::Reference< 81 ::com::sun::star::chart2::data::XDataSequence >& xValues ); 82 void setXValuesIfNone( const ::com::sun::star::uno::Reference< 83 ::com::sun::star::chart2::data::XDataSequence >& xValues ); 84 void setParticle( const rtl::OUString& rSeriesParticle ); 85 void setGlobalSeriesIndex( sal_Int32 nGlobalSeriesIndex ); 86 void setPageReferenceSize( const ::com::sun::star::awt::Size & rPageRefSize ); 87 88 sal_Int32 getTotalPointCount() const; 89 double getXValue( sal_Int32 index ) const; 90 double getYValue( sal_Int32 index ) const; 91 92 double getY_Min( sal_Int32 index ) const; 93 double getY_Max( sal_Int32 index ) const; 94 double getY_First( sal_Int32 index ) const; 95 double getY_Last( sal_Int32 index ) const; 96 97 double getBubble_Size( sal_Int32 index ) const; 98 99 double getMinimumofAllDifferentYValues( sal_Int32 index ) const; 100 double getMaximumofAllDifferentYValues( sal_Int32 index ) const; 101 102 ::com::sun::star::uno::Sequence< double > getAllX() const; 103 ::com::sun::star::uno::Sequence< double > getAllY() const; 104 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 getYErrorBarProperties( sal_Int32 index ) const; 126 127 bool hasPointOwnColor( sal_Int32 index ) const; 128 129 ::com::sun::star::chart2::StackingDirection getStackingDirection() const; 130 sal_Int32 getAttachedAxisIndex() const; 131 void setAttachedAxisIndex( sal_Int32 nAttachedAxisIndex ); 132 133 void doSortByXValues(); 134 135 void setConnectBars( sal_Bool bConnectBars ); 136 sal_Bool getConnectBars() const; 137 138 void setGroupBarsPerAxis( sal_Bool bGroupBarsPerAxis ); 139 sal_Bool getGroupBarsPerAxis() const; 140 141 void setStartingAngle( sal_Int32 nStartingAngle ); 142 sal_Int32 getStartingAngle() const; 143 144 void setRoleOfSequenceForDataLabelNumberFormatDetection( const rtl::OUString& rRole ); 145 146 //this is only temporarily here for area chart: 147 ::com::sun::star::drawing::PolyPolygonShape3D m_aPolyPolygonShape3D; 148 sal_Int32 m_nPolygonIndex; 149 double m_fLogicMinX; 150 double m_fLogicMaxX; 151 // 152 //this is here for deep stacking: 153 double m_fLogicZPos;//from 0 to series count -1 154 // 155 156 rtl::OUString getCID() const; 157 rtl::OUString getSeriesParticle() const; 158 rtl::OUString getPointCID_Stub() const; 159 rtl::OUString getErrorBarsCID() const; 160 rtl::OUString getLabelsCID() const; 161 rtl::OUString getLabelCID_Stub() const; 162 rtl::OUString getDataCurveCID( sal_Int32 nCurveIndex, bool bAverageLine ) const; 163 164 ::com::sun::star::chart2::DataPointLabel* 165 getDataPointLabelIfLabel( sal_Int32 index ) const; 166 bool getTextLabelMultiPropertyLists( sal_Int32 index, tNameSequence*& pPropNames, tAnySequence*& pPropValues ) const; 167 168 rtl::OUString getDataCurveEquationCID( sal_Int32 nCurveIndex ) const; 169 bool isAttributedDataPoint( sal_Int32 index ) const; 170 171 bool isVaryColorsByPoint() const; 172 173 void releaseShapes(); 174 175 void setMissingValueTreatment( sal_Int32 nMissingValueTreatment ); 176 sal_Int32 getMissingValueTreatment() const; 177 178 private: //methods 179 ::com::sun::star::chart2::DataPointLabel* 180 getDataPointLabel( sal_Int32 index ) const; 181 void adaptPointCache( sal_Int32 nNewPointIndex ) const; 182 183 public: //member 184 ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes > m_xGroupShape; 185 ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes > m_xLabelsGroupShape; 186 ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes > m_xErrorBarsGroupShape; 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 ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes > m_xFrontSubGroupShape; 191 ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes > m_xBackSubGroupShape; 192 193 private: //member 194 ::com::sun::star::uno::Reference< 195 ::com::sun::star::chart2::XDataSeries > m_xDataSeries; 196 ::com::sun::star::uno::Sequence< 197 ::com::sun::star::uno::Reference< 198 ::com::sun::star::chart2::data::XLabeledDataSequence > > m_aDataSequences; 199 200 //all points given by the model data (here are not only the visible points meant) 201 sal_Int32 m_nPointCount; 202 203 VDataSequence m_aValues_X; 204 VDataSequence m_aValues_Y; 205 VDataSequence m_aValues_Z; 206 207 VDataSequence m_aValues_Y_Min; 208 VDataSequence m_aValues_Y_Max; 209 VDataSequence m_aValues_Y_First; 210 VDataSequence m_aValues_Y_Last; 211 212 VDataSequence m_aValues_Bubble_Size; 213 214 VDataSequence* m_pValueSequenceForDataLabelNumberFormatDetection; 215 216 mutable double m_fYMeanValue; 217 218 ::com::sun::star::uno::Sequence< sal_Int32 > m_aAttributedDataPointIndexList; 219 220 ::com::sun::star::chart2::StackingDirection m_eStackingDirection; 221 222 sal_Int32 m_nAxisIndex;//indicates wether this is attached to a main or secondary axis 223 224 sal_Bool m_bConnectBars; 225 226 sal_Bool m_bGroupBarsPerAxis; 227 228 sal_Int32 m_nStartingAngle; 229 230 rtl::OUString m_aSeriesParticle; 231 rtl::OUString m_aCID; 232 rtl::OUString m_aPointCID_Stub; 233 rtl::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::auto_ptr< ::com::sun::star::chart2::DataPointLabel > 239 m_apLabel_Series; 240 mutable ::std::auto_ptr< tNameSequence > m_apLabelPropNames_Series; 241 mutable ::std::auto_ptr< tAnySequence > m_apLabelPropValues_Series; 242 mutable ::std::auto_ptr< ::com::sun::star::chart2::Symbol > 243 m_apSymbolProperties_Series; 244 245 mutable ::std::auto_ptr< ::com::sun::star::chart2::DataPointLabel > 246 m_apLabel_AttributedPoint; 247 mutable ::std::auto_ptr< tNameSequence > m_apLabelPropNames_AttributedPoint; 248 mutable ::std::auto_ptr< tAnySequence > m_apLabelPropValues_AttributedPoint; 249 mutable ::std::auto_ptr< ::com::sun::star::chart2::Symbol > 250 m_apSymbolProperties_AttributedPoint; 251 mutable ::std::auto_ptr< ::com::sun::star::chart2::Symbol > 252 m_apSymbolProperties_InvisibleSymbolForSelection; 253 mutable sal_Int32 m_nCurrentAttributedPoint; 254 ::com::sun::star::awt::Size m_aReferenceSize; 255 // 256 257 sal_Int32 m_nMissingValueTreatment; 258 bool m_bAllowPercentValueInDataLabel; 259 }; 260 261 //............................................................................. 262 } //namespace chart 263 //............................................................................. 264 #endif 265