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