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 24 #ifndef OOX_DRAWINGML_CHART_TYPEGROUPCONVERTER_HXX 25 #define OOX_DRAWINGML_CHART_TYPEGROUPCONVERTER_HXX 26 27 #include "oox/drawingml/chart/converterbase.hxx" 28 29 namespace com { namespace sun { namespace star { 30 namespace chart2 { class XChartType; } 31 namespace chart2 { class XCoordinateSystem; } 32 namespace chart2 { class XDataSeries; } 33 namespace chart2 { class XDiagram; } 34 namespace chart2 { namespace data { class XLabeledDataSequence; } } 35 } } } 36 37 namespace oox { 38 namespace drawingml { 39 namespace chart { 40 41 // ============================================================================ 42 43 /** Enumerates different chart types. */ 44 enum TypeId 45 { 46 TYPEID_BAR, /// Vertical bar chart. 47 TYPEID_HORBAR, /// Horizontal bar chart. 48 TYPEID_LINE, /// Line chart. 49 TYPEID_AREA, /// Area chart. 50 TYPEID_STOCK, /// Stock chart. 51 TYPEID_RADARLINE, /// Linear radar chart. 52 TYPEID_RADARAREA, /// Filled radar chart. 53 TYPEID_PIE, /// Pie chart. 54 TYPEID_DOUGHNUT, /// Doughnut (ring) chart. 55 TYPEID_OFPIE, /// Pie-to-pie or pie-to-bar chart. 56 TYPEID_SCATTER, /// Scatter (XY) chart. 57 TYPEID_BUBBLE, /// Bubble chart. 58 TYPEID_SURFACE, /// Surface chart. 59 TYPEID_UNKNOWN /// Default for unknown chart types. 60 }; 61 62 // ---------------------------------------------------------------------------- 63 64 /** Enumerates different categories of similar chart types. */ 65 enum TypeCategory 66 { 67 TYPECATEGORY_BAR, /// Bar charts (horizontal or vertical). 68 TYPECATEGORY_LINE, /// Line charts (line, area, stock charts). 69 TYPECATEGORY_RADAR, /// Radar charts (linear or filled). 70 TYPECATEGORY_PIE, /// Pie and donut charts. 71 TYPECATEGORY_SCATTER, /// Scatter and bubble charts. 72 TYPECATEGORY_SURFACE /// Surface charts. 73 }; 74 75 // ---------------------------------------------------------------------------- 76 77 /** Enumerates modes for varying point colors in a series. */ 78 enum VarPointMode 79 { 80 VARPOINTMODE_NONE, /// No varied colors supported. 81 VARPOINTMODE_SINGLE, /// Only supported, if type group contains only one series. 82 VARPOINTMODE_MULTI /// Supported for multiple series in a chart type group. 83 }; 84 85 // ============================================================================ 86 87 /** Contains info for a chart type related to the OpenOffice.org chart module. */ 88 struct TypeGroupInfo 89 { 90 TypeId meTypeId; /// Unique chart type identifier. 91 TypeCategory meTypeCategory; /// Category this chart type belongs to. 92 const sal_Char* mpcServiceName; /// Service name of the type. 93 VarPointMode meVarPointMode; /// Mode for varying point colors. 94 sal_Int32 mnDefLabelPos; /// Default data label position (API constant). 95 bool mbCombinable2d; /// True = types can be combined in one axes set. 96 bool mbSupports3d; /// True = 3D type allowed, false = only 2D type. 97 bool mbPolarCoordSystem; /// True = polar, false = cartesian. 98 bool mbSeriesIsFrame2d; /// True = 2D type series with area formatting. 99 bool mbSingleSeriesVis; /// True = only first series visible (e.g. pie charts). 100 bool mbCategoryAxis; /// True = X axis contains categories. 101 bool mbSwappedAxesSet; /// True = X axis and Y axis are swapped. 102 bool mbSupportsStacking; /// True = data points can be stacked on each other. 103 bool mbReverseSeries; /// True = insert unstacked series in reverse order. 104 bool mbTicksBetweenCateg; /// True = X axis ticks between categories. 105 bool mbPictureOptions; /// True = bitmaps support options from c:pictureOptions. 106 }; 107 108 // ============================================================================ 109 110 struct UpDownBarsModel; 111 112 class UpDownBarsConverter : public ConverterBase< UpDownBarsModel > 113 { 114 public: 115 explicit UpDownBarsConverter( const ConverterRoot& rParent, UpDownBarsModel& rModel ); 116 virtual ~UpDownBarsConverter(); 117 118 /** Converts the OOXML up/down bars. */ 119 void convertFromModel( 120 const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartType >& rxChartType ); 121 }; 122 123 // ============================================================================ 124 125 struct TypeGroupModel; 126 struct View3DModel; 127 128 class TypeGroupConverter : public ConverterBase< TypeGroupModel > 129 { 130 public: 131 explicit TypeGroupConverter( const ConverterRoot& rParent, TypeGroupModel& rModel ); 132 virtual ~TypeGroupConverter(); 133 134 /** Returns the type info struct that describes this chart type group. */ getTypeInfo() const135 inline const TypeGroupInfo& getTypeInfo() const { return maTypeInfo; } 136 137 /** Returns true, if the series in this chart type group are stacked on each other (no percentage). */ 138 bool isStacked() const; 139 /** Returns true, if the series in this chart type group are stacked on each other as percentage. */ 140 bool isPercent() const; 141 /** Returns true, if the chart is three-dimensional. */ 142 bool is3dChart() const; 143 /** Returns true, if chart type supports wall and floor format in 3D mode. */ 144 bool isWall3dChart() const; 145 /** Returns true, if the series in this chart type group are ordered on the Z axis. */ 146 bool isDeep3dChart() const; 147 148 /** Returns true, if this chart type supports area formatting for its series. */ 149 bool isSeriesFrameFormat() const; 150 /** Returns the object type for a series depending on the chart type. */ 151 ObjectType getSeriesObjectType() const; 152 153 /** Returns true, if this chart type has to reverse its series order. */ 154 bool isReverseSeries() const; 155 /** Returns series title, if the chart type group contains only one single series. */ 156 ::rtl::OUString getSingleSeriesTitle() const; 157 158 /** Creates a coordinate system according to the contained chart type. */ 159 ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XCoordinateSystem > 160 createCoordinateSystem(); 161 /** Creates a labeled data sequence object for axis categories. */ 162 ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XLabeledDataSequence > 163 createCategorySequence(); 164 165 /** Converts the OOXML type group model into a chart2 coordinate system. */ 166 void convertFromModel( 167 const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDiagram >& rxDiagram, 168 const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XCoordinateSystem >& rxCoordSystem, 169 sal_Int32 nAxesSetIdx, bool bSupportsVaryColorsByPoint ); 170 171 /** Sets the passed OOXML marker style at the passed property set. */ 172 void convertMarker( PropertySet& rPropSet, sal_Int32 nOoxSymbol, sal_Int32 nOoxSize ) const; 173 /** Sets the passed OOXML line smoothing at the passed property set. */ 174 void convertLineSmooth( PropertySet& rPropSet, bool bOoxSmooth ) const; 175 /** Sets the passed OOXML bar 3D geometry at the passed property set. */ 176 void convertBarGeometry( PropertySet& rPropSet, sal_Int32 nOoxShape ) const; 177 /** Sets the passed OOXML pie rotation at the passed property set. */ 178 void convertPieRotation( PropertySet& rPropSet, sal_Int32 nOoxAngle ) const; 179 /** Sets the passed OOXML pie explosion at the passed property set. */ 180 void convertPieExplosion( PropertySet& rPropSet, sal_Int32 nOoxExplosion ) const; 181 182 private: 183 /** Inserts the passed series into the chart type. Adds additional properties to the series. */ 184 void insertDataSeries( 185 const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartType >& rxChartType, 186 const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDataSeries >& rxSeries, 187 sal_Int32 nAxesSetIdx ); 188 189 private: 190 TypeGroupInfo maTypeInfo; /// Extended type info for contained chart type model. 191 bool mb3dChart; /// True = type is a 3D chart type. 192 }; 193 194 // ============================================================================ 195 196 } // namespace chart 197 } // namespace drawingml 198 } // namespace oox 199 200 #endif 201