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 _CHART2_CHARTTYPE_DIALOG_CONTROLLER_HXX
25 #define _CHART2_CHARTTYPE_DIALOG_CONTROLLER_HXX
26 
27 #include "ChangingResource.hxx"
28 #include "ThreeDHelper.hxx"
29 #include <comphelper/InlineContainer.hxx>
30 
31 #include <com/sun/star/chart2/CurveStyle.hpp>
32 #include <com/sun/star/chart2/XChartDocument.hpp>
33 #include <com/sun/star/chart2/XChartTypeTemplate.hpp>
34 #include <svtools/valueset.hxx>
35 // header for class CheckBox
36 #ifndef _SV_BUTTON_HXX
37 #include <vcl/button.hxx>
38 #endif
39 // header for class FixedText
40 #include <vcl/fixed.hxx>
41 // header for class MetricField
42 #include <vcl/field.hxx>
43 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
44 
45 //.............................................................................
46 namespace chart
47 {
48 //.............................................................................
49 
50 //-----------------------------------------------------------------------------
51 /**
52 */
53 
54 enum GlobalStackMode
55 {
56     GlobalStackMode_NONE,
57     GlobalStackMode_STACK_Y,
58     GlobalStackMode_STACK_Y_PERCENT,
59     GlobalStackMode_STACK_Z
60 };
61 
62 class ChartTypeParameter
63 {
64 public:
65     ChartTypeParameter( sal_Int32 nSubTypeIndex, bool bXAxisWithValues=false
66                     ,  bool b3DLook=false,  GlobalStackMode eStackMode=GlobalStackMode_NONE
67                     ,  bool _bSymbols = true, bool _bLines = true
68                     , ::com::sun::star::chart2::CurveStyle eCurveStyle = ::com::sun::star::chart2::CurveStyle_LINES );
69     ChartTypeParameter();
70     virtual ~ChartTypeParameter();
71 
72     bool mapsToSameService( const ChartTypeParameter& rParameter ) const;
73     bool mapsToSimilarService( const ChartTypeParameter& rParameter, sal_Int32 nTheHigherTheLess ) const;
74 
75     sal_Int32       nSubTypeIndex;//starting with 1
76 
77     bool            bXAxisWithValues;
78     bool            b3DLook;
79     bool            bSymbols;
80     bool            bLines;
81 
82     GlobalStackMode eStackMode;
83     ::com::sun::star::chart2::CurveStyle      eCurveStyle;
84 
85     sal_Int32       nCurveResolution;
86     sal_Int32       nSplineOrder;
87 
88     sal_Int32       nGeometry3D;
89 
90     ThreeDLookScheme                    eThreeDLookScheme;
91     sal_Bool                            bSortByXValues;
92 };
93 
94 typedef ::comphelper::MakeMap< ::rtl::OUString, ChartTypeParameter > tTemplateServiceChartTypeParameterMap;
95 
96 class ChartTypeDialogController : public ChangingResource
97 {
98 public:
99     ChartTypeDialogController();
100     virtual ~ChartTypeDialogController();
101 
102     virtual String  getName()=0;
103     virtual Image   getImage( bool bIsHighContrast );
104     virtual const tTemplateServiceChartTypeParameterMap& getTemplateMap() const = 0;
105     virtual void fillSubTypeList( ValueSet& rSubTypeList, bool bIsHighContrast, const ChartTypeParameter& rParameter );
106 
107     virtual bool    shouldShow_XAxisTypeControl() const;
108     virtual bool    shouldShow_3DLookControl() const;
109     virtual bool    shouldShow_StackingControl() const;
110     virtual bool    shouldShow_DeepStackingControl() const;
111     virtual bool    shouldShow_SplineControl() const;
112     virtual bool    shouldShow_GeometryControl() const;
113     virtual bool    shouldShow_SortByXValuesResourceGroup() const;
114 
115     virtual void    showExtraControls( Window* pParent, const Point& rPosition, const Size& rSize );
116     virtual void    hideExtraControls() const;
117     virtual void    fillExtraControls( const ChartTypeParameter& rParameter
118                                      , const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument >& xChartModel
119                                      , const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xTemplateProps=::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >() ) const;
120     virtual void    setTemplateProperties( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xTemplateProps ) const throw (::com::sun::star::uno::RuntimeException);
121 
122     virtual bool                isSubType( const rtl::OUString& rServiceName );
123     virtual ChartTypeParameter  getChartTypeParameterForService( const rtl::OUString& rServiceName, const ::com::sun::star::uno::Reference<
124                                                                 ::com::sun::star::beans::XPropertySet >& xTemplateProps );
125     virtual void                adjustSubTypeAndEnableControls( ChartTypeParameter& rParameter );//if you have different counts of subtypes you may need to adjust the index
126     virtual void                adjustParameterToSubType( ChartTypeParameter& rParameter );
127     virtual void                adjustParameterToMainType( ChartTypeParameter& rParameter );
128     virtual rtl::OUString       getServiceNameForParameter( const ChartTypeParameter& rParameter ) const;
129     virtual bool                commitToModel( const ChartTypeParameter& rParameter
130         , const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument >& xChartModel );
131     virtual ::com::sun::star::uno::Reference<
132                 ::com::sun::star::chart2::XChartTypeTemplate > getCurrentTemplate( const ChartTypeParameter& rParameter
133                 , const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xTemplateManager ) const;
134 
135 protected:
136     bool bSupportsXAxisWithValues;
137     bool bSupports3D;
138 };
139 
140 class ColumnOrBarChartDialogController_Base : public ChartTypeDialogController
141 {
142 public:
143     ColumnOrBarChartDialogController_Base();
144     virtual ~ColumnOrBarChartDialogController_Base();
145 
146     virtual bool    shouldShow_3DLookControl() const;
147     virtual bool    shouldShow_GeometryControl() const;
148 
149     virtual void    adjustSubTypeAndEnableControls( ChartTypeParameter& rParameter );
150 };
151 
152 class ColumnChartDialogController : public ColumnOrBarChartDialogController_Base
153 {
154 public:
155     ColumnChartDialogController();
156     virtual ~ColumnChartDialogController();
157 
158     virtual String  getName();
159     virtual Image   getImage( bool bIsHighContrast );
160     virtual const tTemplateServiceChartTypeParameterMap& getTemplateMap() const;
161     virtual void fillSubTypeList( ValueSet& rSubTypeList, bool bIsHighContrast, const ChartTypeParameter& rParameter );
162 };
163 
164 class BarChartDialogController : public ColumnOrBarChartDialogController_Base
165 {
166 public:
167     BarChartDialogController();
168     virtual ~BarChartDialogController();
169 
170     virtual String  getName();
171     virtual Image   getImage( bool bIsHighContrast );
172     virtual const tTemplateServiceChartTypeParameterMap& getTemplateMap() const;
173     virtual void fillSubTypeList( ValueSet& rSubTypeList, bool bIsHighContrast, const ChartTypeParameter& rParameter );
174 };
175 
176 class PieChartDialogController : public ChartTypeDialogController
177 {
178 public:
179     PieChartDialogController();
180     virtual ~PieChartDialogController();
181 
182     virtual String  getName();
183     virtual Image   getImage( bool bIsHighContrast );
184     virtual const tTemplateServiceChartTypeParameterMap& getTemplateMap() const;
185     virtual void fillSubTypeList( ValueSet& rSubTypeList, bool bIsHighContrast, const ChartTypeParameter& rParameter );
186     virtual void adjustParameterToSubType( ChartTypeParameter& rParameter );
187 
188     virtual bool    shouldShow_3DLookControl() const;
189 };
190 
191 class LineChartDialogController : public ChartTypeDialogController
192 {
193 public:
194     LineChartDialogController();
195     virtual ~LineChartDialogController();
196 
197     virtual String  getName();
198     virtual Image   getImage( bool bIsHighContrast );
199     virtual const tTemplateServiceChartTypeParameterMap& getTemplateMap() const;
200     virtual void fillSubTypeList( ValueSet& rSubTypeList, bool bIsHighContrast, const ChartTypeParameter& rParameter );
201     virtual void adjustParameterToSubType( ChartTypeParameter& rParameter );
202     virtual void adjustParameterToMainType( ChartTypeParameter& rParameter );
203 
204     virtual bool    shouldShow_StackingControl() const;
205     virtual bool    shouldShow_DeepStackingControl() const;
206     virtual bool    shouldShow_SplineControl() const;
207 };
208 
209 class XYChartDialogController : public ChartTypeDialogController
210 {
211 public:
212     XYChartDialogController();
213     virtual ~XYChartDialogController();
214 
215     virtual String  getName();
216     virtual Image   getImage( bool bIsHighContrast );
217     virtual const tTemplateServiceChartTypeParameterMap& getTemplateMap() const;
218     virtual void fillSubTypeList( ValueSet& rSubTypeList, bool bIsHighContrast, const ChartTypeParameter& rParameter );
219     virtual void adjustParameterToSubType( ChartTypeParameter& rParameter );
220 
221     virtual bool    shouldShow_SplineControl() const;
222     virtual bool    shouldShow_SortByXValuesResourceGroup() const;
223 };
224 
225 class AreaChartDialogController : public ChartTypeDialogController
226 {
227 public:
228     AreaChartDialogController();
229     virtual ~AreaChartDialogController();
230 
231     virtual String  getName();
232     virtual Image   getImage( bool bIsHighContrast );
233     virtual const tTemplateServiceChartTypeParameterMap& getTemplateMap() const;
234     virtual void fillSubTypeList( ValueSet& rSubTypeList, bool bIsHighContrast, const ChartTypeParameter& rParameter );
235     virtual void adjustParameterToSubType( ChartTypeParameter& rParameter );
236     virtual void adjustParameterToMainType( ChartTypeParameter& rParameter );
237 
238     virtual bool    shouldShow_3DLookControl() const;
239 };
240 
241 class NetChartDialogController : public ChartTypeDialogController
242 {
243 public:
244     NetChartDialogController();
245     virtual ~NetChartDialogController();
246 
247     virtual String  getName();
248     virtual Image   getImage( bool bIsHighContrast );
249     virtual const tTemplateServiceChartTypeParameterMap& getTemplateMap() const;
250     virtual void fillSubTypeList( ValueSet& rSubTypeList, bool bIsHighContrast, const ChartTypeParameter& rParameter );
251     virtual void adjustParameterToSubType( ChartTypeParameter& rParameter );
252 
253     virtual bool    shouldShow_StackingControl() const;
254 };
255 
256 class StockChartDialogController : public ChartTypeDialogController
257 {
258 public:
259     StockChartDialogController();
260     virtual ~StockChartDialogController();
261 
262     virtual String  getName();
263     virtual Image   getImage( bool bIsHighContrast );
264     virtual const tTemplateServiceChartTypeParameterMap& getTemplateMap() const;
265     virtual void fillSubTypeList( ValueSet& rSubTypeList, bool bIsHighContrast, const ChartTypeParameter& rParameter );
266     virtual void adjustParameterToSubType( ChartTypeParameter& rParameter );
267 };
268 
269 class CombiColumnLineChartDialogController : public ChartTypeDialogController
270 {
271 public:
272     CombiColumnLineChartDialogController();
273     virtual ~CombiColumnLineChartDialogController();
274 
275     virtual String  getName();
276     virtual Image   getImage( bool bIsHighContrast );
277     virtual const tTemplateServiceChartTypeParameterMap& getTemplateMap() const;
278     virtual void fillSubTypeList( ValueSet& rSubTypeList, bool bIsHighContrast, const ChartTypeParameter& rParameter );
279     virtual void adjustParameterToSubType( ChartTypeParameter& rParameter );
280 
281     virtual void    showExtraControls( Window* pParent, const Point& rPosition, const Size& rSize );
282     virtual void    hideExtraControls() const;
283     virtual void    fillExtraControls( const ChartTypeParameter& rParameter
284                                      , const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument >& xChartModel
285                                      , const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xTemplateProps=::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >() ) const;
286 
287     virtual void    setTemplateProperties( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xTemplateProps ) const throw (::com::sun::star::uno::RuntimeException);
288 
289 private:
290     DECL_LINK( ChangeLineCountHdl, void* );
291 
292 private:
293     FixedText*      m_pFT_NumberOfLines;
294     MetricField*    m_pMF_NumberOfLines;
295 };
296 
297 class BubbleChartDialogController : public ChartTypeDialogController
298 {
299 public:
300     BubbleChartDialogController();
301     virtual ~BubbleChartDialogController();
302 
303     virtual String  getName();
304     virtual Image   getImage( bool bIsHighContrast );
305     virtual const tTemplateServiceChartTypeParameterMap& getTemplateMap() const;
306     virtual void fillSubTypeList( ValueSet& rSubTypeList, bool bIsHighContrast, const ChartTypeParameter& rParameter );
307     virtual void adjustParameterToSubType( ChartTypeParameter& rParameter );
308 };
309 
310 //.............................................................................
311 } //namespace chart
312 //.............................................................................
313 #endif
314