1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 #ifndef _CHART2_VIEW_DATASERIES_HXX 28 #define _CHART2_VIEW_DATASERIES_HXX 29 30 #include "PropertyMapper.hxx" 31 32 #include <vector> 33 //for auto_ptr 34 #include <memory> 35 #include <com/sun/star/chart2/DataPointLabel.hpp> 36 #include <com/sun/star/chart2/Symbol.hpp> 37 #include <com/sun/star/chart2/StackingDirection.hpp> 38 #include <com/sun/star/chart2/data/XLabeledDataSequence.hpp> 39 #include <com/sun/star/chart2/XChartType.hpp> 40 #include <com/sun/star/chart2/XDataSeries.hpp> 41 #include <com/sun/star/drawing/HomogenMatrix.hpp> 42 #include <com/sun/star/drawing/PolyPolygonShape3D.hpp> 43 #include <com/sun/star/drawing/XShape.hpp> 44 #include <com/sun/star/drawing/XShapes.hpp> 45 #include <cppuhelper/weakref.hxx> 46 47 //............................................................................. 48 namespace chart 49 { 50 //............................................................................. 51 52 //----------------------------------------------------------------------------- 53 /** 54 */ 55 class VDataSequence 56 { 57 public: 58 void init( const ::com::sun::star::uno::Reference< 59 ::com::sun::star::chart2::data::XDataSequence >& xModel ); 60 bool is() const; 61 void clear(); 62 double getValue( sal_Int32 index ) const; 63 sal_Int32 detectNumberFormatKey( sal_Int32 index ) const; 64 sal_Int32 getLength() const; 65 66 67 ::com::sun::star::uno::Reference< 68 ::com::sun::star::chart2::data::XDataSequence > Model; 69 70 mutable ::com::sun::star::uno::Sequence< double > Doubles; 71 }; 72 73 class VDataSeries 74 { 75 public: 76 VDataSeries( const ::com::sun::star::uno::Reference< 77 ::com::sun::star::chart2::XDataSeries >& xDataSeries ); 78 virtual ~VDataSeries(); 79 80 ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDataSeries > 81 getModel() const; 82 83 void setCategoryXAxis(); 84 void setXValues( const ::com::sun::star::uno::Reference< 85 ::com::sun::star::chart2::data::XDataSequence >& xValues ); 86 void setXValuesIfNone( const ::com::sun::star::uno::Reference< 87 ::com::sun::star::chart2::data::XDataSequence >& xValues ); 88 void setParticle( const rtl::OUString& rSeriesParticle ); 89 void setGlobalSeriesIndex( sal_Int32 nGlobalSeriesIndex ); 90 void setPageReferenceSize( const ::com::sun::star::awt::Size & rPageRefSize ); 91 92 sal_Int32 getTotalPointCount() const; 93 double getXValue( sal_Int32 index ) const; 94 double getYValue( sal_Int32 index ) const; 95 96 double getY_Min( sal_Int32 index ) const; 97 double getY_Max( sal_Int32 index ) const; 98 double getY_First( sal_Int32 index ) const; 99 double getY_Last( sal_Int32 index ) const; 100 101 double getBubble_Size( sal_Int32 index ) const; 102 103 double getMinimumofAllDifferentYValues( sal_Int32 index ) const; 104 double getMaximumofAllDifferentYValues( sal_Int32 index ) const; 105 106 ::com::sun::star::uno::Sequence< double > getAllX() const; 107 ::com::sun::star::uno::Sequence< double > getAllY() const; 108 109 double getYMeanValue() const; 110 111 bool hasExplicitNumberFormat( sal_Int32 nPointIndex, bool bForPercentage ) const; 112 sal_Int32 getExplicitNumberFormat( sal_Int32 nPointIndex, bool bForPercentage ) const; 113 sal_Int32 detectNumberFormatKey( sal_Int32 nPointIndex ) const; 114 bool shouldLabelNumberFormatKeyBeDetectedFromYAxis() const; 115 116 sal_Int32 getLabelPlacement( sal_Int32 nPointIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartType >& xChartType 117 , sal_Int32 nDimensionCount, sal_Bool bSwapXAndY ) const; 118 119 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > 120 getPropertiesOfPoint( sal_Int32 index ) const; 121 122 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > 123 getPropertiesOfSeries() const; 124 125 ::com::sun::star::chart2::Symbol* 126 getSymbolProperties( sal_Int32 index ) const; 127 128 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > 129 getYErrorBarProperties( sal_Int32 index ) const; 130 131 bool hasPointOwnColor( sal_Int32 index ) const; 132 133 ::com::sun::star::chart2::StackingDirection getStackingDirection() const; 134 sal_Int32 getAttachedAxisIndex() const; 135 void setAttachedAxisIndex( sal_Int32 nAttachedAxisIndex ); 136 137 void doSortByXValues(); 138 139 void setConnectBars( sal_Bool bConnectBars ); 140 sal_Bool getConnectBars() const; 141 142 void setGroupBarsPerAxis( sal_Bool bGroupBarsPerAxis ); 143 sal_Bool getGroupBarsPerAxis() const; 144 145 void setStartingAngle( sal_Int32 nStartingAngle ); 146 sal_Int32 getStartingAngle() const; 147 148 void setRoleOfSequenceForDataLabelNumberFormatDetection( const rtl::OUString& rRole ); 149 150 //this is only temporarily here for area chart: 151 ::com::sun::star::drawing::PolyPolygonShape3D m_aPolyPolygonShape3D; 152 sal_Int32 m_nPolygonIndex; 153 double m_fLogicMinX; 154 double m_fLogicMaxX; 155 // 156 //this is here for deep stacking: 157 double m_fLogicZPos;//from 0 to series count -1 158 // 159 160 rtl::OUString getCID() const; 161 rtl::OUString getSeriesParticle() const; 162 rtl::OUString getPointCID_Stub() const; 163 rtl::OUString getErrorBarsCID() const; 164 rtl::OUString getLabelsCID() const; 165 rtl::OUString getLabelCID_Stub() const; 166 rtl::OUString getDataCurveCID( sal_Int32 nCurveIndex, bool bAverageLine ) const; 167 168 ::com::sun::star::chart2::DataPointLabel* 169 getDataPointLabelIfLabel( sal_Int32 index ) const; 170 bool getTextLabelMultiPropertyLists( sal_Int32 index, tNameSequence*& pPropNames, tAnySequence*& pPropValues ) const; 171 172 rtl::OUString getDataCurveEquationCID( sal_Int32 nCurveIndex ) const; 173 bool isAttributedDataPoint( sal_Int32 index ) const; 174 175 bool isVaryColorsByPoint() const; 176 177 void releaseShapes(); 178 179 void setMissingValueTreatment( sal_Int32 nMissingValueTreatment ); 180 sal_Int32 getMissingValueTreatment() const; 181 182 private: //methods 183 ::com::sun::star::chart2::DataPointLabel* 184 getDataPointLabel( sal_Int32 index ) const; 185 void adaptPointCache( sal_Int32 nNewPointIndex ) const; 186 187 public: //member 188 ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes > m_xGroupShape; 189 ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes > m_xLabelsGroupShape; 190 ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes > m_xErrorBarsGroupShape; 191 192 //the following group shapes will be created as children of m_xGroupShape on demand 193 //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) 194 ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes > m_xFrontSubGroupShape; 195 ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes > m_xBackSubGroupShape; 196 197 private: //member 198 ::com::sun::star::uno::Reference< 199 ::com::sun::star::chart2::XDataSeries > m_xDataSeries; 200 ::com::sun::star::uno::Sequence< 201 ::com::sun::star::uno::Reference< 202 ::com::sun::star::chart2::data::XLabeledDataSequence > > m_aDataSequences; 203 204 //all points given by the model data (here are not only the visible points meant) 205 sal_Int32 m_nPointCount; 206 207 VDataSequence m_aValues_X; 208 VDataSequence m_aValues_Y; 209 VDataSequence m_aValues_Z; 210 211 VDataSequence m_aValues_Y_Min; 212 VDataSequence m_aValues_Y_Max; 213 VDataSequence m_aValues_Y_First; 214 VDataSequence m_aValues_Y_Last; 215 216 VDataSequence m_aValues_Bubble_Size; 217 218 VDataSequence* m_pValueSequenceForDataLabelNumberFormatDetection; 219 220 mutable double m_fYMeanValue; 221 222 ::com::sun::star::uno::Sequence< sal_Int32 > m_aAttributedDataPointIndexList; 223 224 ::com::sun::star::chart2::StackingDirection m_eStackingDirection; 225 226 sal_Int32 m_nAxisIndex;//indicates wether this is attached to a main or secondary axis 227 228 sal_Bool m_bConnectBars; 229 230 sal_Bool m_bGroupBarsPerAxis; 231 232 sal_Int32 m_nStartingAngle; 233 234 rtl::OUString m_aSeriesParticle; 235 rtl::OUString m_aCID; 236 rtl::OUString m_aPointCID_Stub; 237 rtl::OUString m_aLabelCID_Stub; 238 239 sal_Int32 m_nGlobalSeriesIndex; 240 241 //some cached values for data labels as they are very expensive 242 mutable ::std::auto_ptr< ::com::sun::star::chart2::DataPointLabel > 243 m_apLabel_Series; 244 mutable ::std::auto_ptr< tNameSequence > m_apLabelPropNames_Series; 245 mutable ::std::auto_ptr< tAnySequence > m_apLabelPropValues_Series; 246 mutable ::std::auto_ptr< ::com::sun::star::chart2::Symbol > 247 m_apSymbolProperties_Series; 248 249 mutable ::std::auto_ptr< ::com::sun::star::chart2::DataPointLabel > 250 m_apLabel_AttributedPoint; 251 mutable ::std::auto_ptr< tNameSequence > m_apLabelPropNames_AttributedPoint; 252 mutable ::std::auto_ptr< tAnySequence > m_apLabelPropValues_AttributedPoint; 253 mutable ::std::auto_ptr< ::com::sun::star::chart2::Symbol > 254 m_apSymbolProperties_AttributedPoint; 255 mutable ::std::auto_ptr< ::com::sun::star::chart2::Symbol > 256 m_apSymbolProperties_InvisibleSymbolForSelection; 257 mutable sal_Int32 m_nCurrentAttributedPoint; 258 ::com::sun::star::awt::Size m_aReferenceSize; 259 // 260 261 sal_Int32 m_nMissingValueTreatment; 262 bool m_bAllowPercentValueInDataLabel; 263 }; 264 265 //............................................................................. 266 } //namespace chart 267 //............................................................................. 268 #endif 269