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