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 
28 #ifndef OOX_DRAWINGML_CHART_SERIESCONVERTER_HXX
29 #define OOX_DRAWINGML_CHART_SERIESCONVERTER_HXX
30 
31 #include "oox/drawingml/chart/converterbase.hxx"
32 #include "oox/drawingml/chart/seriesmodel.hxx"
33 
34 namespace com { namespace sun { namespace star {
35     namespace chart2 { class XDataSeries; }
36     namespace chart2 { namespace data { class XLabeledDataSequence; } }
37 } } }
38 
39 namespace oox {
40 namespace drawingml {
41 namespace chart {
42 
43 class TypeGroupConverter;
44 
45 // #i66858# enable this when Chart2 supports smoothed lines per data series
46 #define OOX_CHART_SMOOTHED_PER_SERIES 0
47 
48 // ============================================================================
49 
50 class DataLabelConverter : public ConverterBase< DataLabelModel >
51 {
52 public:
53     explicit            DataLabelConverter( const ConverterRoot& rParent, DataLabelModel& rModel );
54     virtual             ~DataLabelConverter();
55 
56     /** Converts OOXML data label settings for the passed data point. */
57     void                convertFromModel(
58                             const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDataSeries >& rxDataSeries,
59                             const TypeGroupConverter& rTypeGroup );
60 
61     /** Conversion helper for data series and data points. */
62     static void         convertLabelFormatting(
63                             PropertySet& rPropSet,
64                             ObjectFormatter& rFormatter,
65                             const DataLabelModelBase& rDataLabel,
66                             const TypeGroupConverter& rTypeGroup,
67                             bool bDataSeriesLabel );
68 };
69 
70 // ============================================================================
71 
72 class DataLabelsConverter : public ConverterBase< DataLabelsModel >
73 {
74 public:
75     explicit            DataLabelsConverter( const ConverterRoot& rParent, DataLabelsModel& rModel );
76     virtual             ~DataLabelsConverter();
77 
78     /** Converts OOXML data label settings for the passed data series. */
79     void                convertFromModel(
80                             const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDataSeries >& rxDataSeries,
81                             const TypeGroupConverter& rTypeGroup );
82 };
83 
84 // ============================================================================
85 
86 class ErrorBarConverter : public ConverterBase< ErrorBarModel >
87 {
88 public:
89     explicit            ErrorBarConverter( const ConverterRoot& rParent, ErrorBarModel& rModel );
90     virtual             ~ErrorBarConverter();
91 
92     /** Converts an OOXML errorbar and inserts it into the passed data series. */
93     void                convertFromModel(
94                             const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDataSeries >& rxDataSeries );
95 
96 private:
97     ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XLabeledDataSequence >
98                         createLabeledDataSequence( ErrorBarModel::SourceType eSourceType );
99 };
100 
101 // ============================================================================
102 
103 class TrendlineLabelConverter : public ConverterBase< TrendlineLabelModel >
104 {
105 public:
106     explicit            TrendlineLabelConverter( const ConverterRoot& rParent, TrendlineLabelModel& rModel );
107     virtual             ~TrendlineLabelConverter();
108 
109     /** Converts the OOXML trendline label. */
110     void                convertFromModel( PropertySet& rPropSet );
111 };
112 
113 // ============================================================================
114 
115 class TrendlineConverter : public ConverterBase< TrendlineModel >
116 {
117 public:
118     explicit            TrendlineConverter( const ConverterRoot& rParent, TrendlineModel& rModel );
119     virtual             ~TrendlineConverter();
120 
121     /** Converts an OOXML trendline and inserts it into the passed data series. */
122     void                convertFromModel(
123                             const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDataSeries >& rxDataSeries );
124 };
125 
126 // ============================================================================
127 
128 class DataPointConverter : public ConverterBase< DataPointModel >
129 {
130 public:
131     explicit            DataPointConverter( const ConverterRoot& rParent, DataPointModel& rModel );
132     virtual             ~DataPointConverter();
133 
134     /** Converts settings for a data point in the passed series. */
135     void                convertFromModel(
136                             const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDataSeries >& rxDataSeries,
137                             const TypeGroupConverter& rTypeGroup,
138                             const SeriesModel& rSeries );
139 };
140 
141 // ============================================================================
142 
143 class SeriesConverter : public ConverterBase< SeriesModel >
144 {
145 public:
146     explicit            SeriesConverter( const ConverterRoot& rParent, SeriesModel& rModel );
147     virtual             ~SeriesConverter();
148 
149     /** Creates a labeled data sequence object from category data link. */
150     ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XLabeledDataSequence >
151                         createCategorySequence( const ::rtl::OUString& rRole );
152     /** Creates a labeled data sequence object from value data link. */
153     ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XLabeledDataSequence >
154                         createValueSequence( const ::rtl::OUString& rRole );
155     /** Creates a data series object with initialized source links. */
156     ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDataSeries >
157                         createDataSeries( const TypeGroupConverter& rTypeGroup, bool bVaryColorsByPoint );
158 
159 private:
160     ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XLabeledDataSequence >
161                         createLabeledDataSequence(
162                             SeriesModel::SourceType eSourceType,
163                             const ::rtl::OUString& rRole,
164                             bool bUseTextLabel );
165 };
166 
167 // ============================================================================
168 
169 } // namespace chart
170 } // namespace drawingml
171 } // namespace oox
172 
173 #endif
174