Avoid potential negative array index access to cached text.
[LibreOffice.git] / chart2 / source / inc / ChartTypeDialogController.hxx
blob4c03ff269e1f3226689001e0b3a69ca970816f6f
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #pragma once
22 #include <sal/config.h>
24 #include <map>
26 #include "ChangingResource.hxx"
27 #include "ThreeDHelper.hxx"
29 #include <com/sun/star/chart2/CurveStyle.hpp>
30 #include <vcl/weld.hxx>
32 namespace com::sun::star::beans
34 class XPropertySet;
36 namespace com::sun::star::chart2
38 class XChartDocument;
40 namespace com::sun::star::lang
42 class XMultiServiceFactory;
45 class ValueSet;
47 namespace chart
49 class ChartModel;
50 class ChartTypeTemplate;
51 class ChartTypeManager;
53 enum GlobalStackMode
55 GlobalStackMode_NONE,
56 GlobalStackMode_STACK_Y,
57 GlobalStackMode_STACK_Y_PERCENT,
58 GlobalStackMode_STACK_Z
61 class ChartTypeParameter
63 public:
64 ChartTypeParameter(sal_Int32 nSubTypeIndex, bool bXAxisWithValues = false, bool b3DLook = false,
65 GlobalStackMode eStackMode = GlobalStackMode_NONE, bool _bSymbols = true,
66 bool _bLines = true,
67 css::chart2::CurveStyle eCurveStyle = css::chart2::CurveStyle_LINES);
68 ChartTypeParameter();
70 bool mapsToSameService(const ChartTypeParameter& rParameter) const;
71 bool mapsToSimilarService(const ChartTypeParameter& rParameter,
72 sal_Int32 nTheHigherTheLess) const;
74 sal_Int32 nSubTypeIndex; //starting with 1
76 bool bXAxisWithValues;
77 bool b3DLook;
78 bool bSymbols;
79 bool bLines;
81 GlobalStackMode eStackMode;
82 css::chart2::CurveStyle eCurveStyle;
84 sal_Int32 nCurveResolution;
85 sal_Int32 nSplineOrder;
87 sal_Int32 nGeometry3D;
89 ThreeDLookScheme eThreeDLookScheme;
90 bool bSortByXValues;
92 bool mbRoundedEdge;
95 typedef std::map<OUString, ChartTypeParameter> tTemplateServiceChartTypeParameterMap;
97 class ChartTypeDialogController : public ChangingResource
99 public:
100 ChartTypeDialogController();
101 virtual ~ChartTypeDialogController() override;
103 virtual OUString getName() = 0;
104 virtual OUString getImage() = 0;
105 virtual const tTemplateServiceChartTypeParameterMap& getTemplateMap() const = 0;
106 virtual void fillSubTypeList(ValueSet& rSubTypeList, const ChartTypeParameter& rParameter);
108 virtual bool shouldShow_3DLookControl() const;
109 virtual bool shouldShow_StackingControl() const;
110 virtual bool shouldShow_SplineControl() const;
111 virtual bool shouldShow_GeometryControl() const;
112 virtual bool shouldShow_SortByXValuesResourceGroup() const;
114 virtual void showExtraControls(weld::Builder* pBuilder);
115 virtual void hideExtraControls() const;
116 virtual void
117 fillExtraControls(const rtl::Reference<::chart::ChartModel>& xChartModel,
118 const css::uno::Reference<css::beans::XPropertySet>& xTemplateProps) const;
119 /// @throws css::uno::RuntimeException
120 virtual void setTemplateProperties(
121 const css::uno::Reference<css::beans::XPropertySet>& xTemplateProps) const;
123 bool isSubType(const OUString& rServiceName);
124 ChartTypeParameter getChartTypeParameterForService(
125 const OUString& rServiceName,
126 const css::uno::Reference<css::beans::XPropertySet>& xTemplateProps);
127 virtual void adjustSubTypeAndEnableControls(
128 ChartTypeParameter&
129 rParameter); //if you have different counts of subtypes you may need to adjust the index
130 virtual void adjustParameterToSubType(ChartTypeParameter& rParameter);
131 virtual void adjustParameterToMainType(ChartTypeParameter& rParameter);
132 OUString getServiceNameForParameter(const ChartTypeParameter& rParameter) const;
133 void commitToModel(const ChartTypeParameter& rParameter,
134 const rtl::Reference<::chart::ChartModel>& xChartModel);
135 rtl::Reference<::chart::ChartTypeTemplate>
136 getCurrentTemplate(const ChartTypeParameter& rParameter,
137 const rtl::Reference<::chart::ChartTypeManager>& xTemplateManager) const;
139 protected:
140 bool bSupportsXAxisWithValues;
141 bool bSupports3D;
144 class ColumnOrBarChartDialogController_Base : public ChartTypeDialogController
146 public:
147 ColumnOrBarChartDialogController_Base();
148 virtual ~ColumnOrBarChartDialogController_Base() override;
150 virtual bool shouldShow_3DLookControl() const override;
151 virtual bool shouldShow_GeometryControl() const override;
153 virtual void adjustSubTypeAndEnableControls(ChartTypeParameter& rParameter) override;
156 class ColumnChartDialogController final : public ColumnOrBarChartDialogController_Base
158 public:
159 ColumnChartDialogController();
160 virtual ~ColumnChartDialogController() override;
162 virtual OUString getName() override;
163 virtual OUString getImage() override;
164 virtual const tTemplateServiceChartTypeParameterMap& getTemplateMap() const override;
165 virtual void fillSubTypeList(ValueSet& rSubTypeList,
166 const ChartTypeParameter& rParameter) override;
169 class BarChartDialogController final : public ColumnOrBarChartDialogController_Base
171 public:
172 BarChartDialogController();
173 virtual ~BarChartDialogController() override;
175 virtual OUString getName() override;
176 virtual OUString getImage() override;
177 virtual const tTemplateServiceChartTypeParameterMap& getTemplateMap() const override;
178 virtual void fillSubTypeList(ValueSet& rSubTypeList,
179 const ChartTypeParameter& rParameter) override;
182 class PieChartDialogController final : public ChartTypeDialogController
184 public:
185 PieChartDialogController();
186 virtual ~PieChartDialogController() override;
188 virtual OUString getName() override;
189 virtual OUString getImage() override;
190 virtual const tTemplateServiceChartTypeParameterMap& getTemplateMap() const override;
191 virtual void fillSubTypeList(ValueSet& rSubTypeList,
192 const ChartTypeParameter& rParameter) override;
193 virtual void adjustParameterToSubType(ChartTypeParameter& rParameter) override;
195 virtual bool shouldShow_3DLookControl() const override;
198 class LineChartDialogController final : public ChartTypeDialogController
200 public:
201 LineChartDialogController();
202 virtual ~LineChartDialogController() override;
204 virtual OUString getName() override;
205 virtual OUString getImage() override;
206 virtual const tTemplateServiceChartTypeParameterMap& getTemplateMap() const override;
207 virtual void fillSubTypeList(ValueSet& rSubTypeList,
208 const ChartTypeParameter& rParameter) override;
209 virtual void adjustParameterToSubType(ChartTypeParameter& rParameter) override;
210 virtual void adjustParameterToMainType(ChartTypeParameter& rParameter) override;
212 virtual bool shouldShow_StackingControl() const override;
213 virtual bool shouldShow_SplineControl() const override;
216 class XYChartDialogController final : public ChartTypeDialogController
218 public:
219 XYChartDialogController();
220 virtual ~XYChartDialogController() override;
222 virtual OUString getName() override;
223 virtual OUString getImage() override;
224 virtual const tTemplateServiceChartTypeParameterMap& getTemplateMap() const override;
225 virtual void fillSubTypeList(ValueSet& rSubTypeList,
226 const ChartTypeParameter& rParameter) override;
227 virtual void adjustParameterToSubType(ChartTypeParameter& rParameter) override;
229 virtual bool shouldShow_SplineControl() const override;
230 virtual bool shouldShow_SortByXValuesResourceGroup() const override;
233 class AreaChartDialogController final : public ChartTypeDialogController
235 public:
236 AreaChartDialogController();
237 virtual ~AreaChartDialogController() override;
239 virtual OUString getName() override;
240 virtual OUString getImage() override;
241 virtual const tTemplateServiceChartTypeParameterMap& getTemplateMap() const override;
242 virtual void fillSubTypeList(ValueSet& rSubTypeList,
243 const ChartTypeParameter& rParameter) override;
244 virtual void adjustParameterToSubType(ChartTypeParameter& rParameter) override;
245 virtual void adjustParameterToMainType(ChartTypeParameter& rParameter) override;
247 virtual bool shouldShow_3DLookControl() const override;
250 class NetChartDialogController final : public ChartTypeDialogController
252 public:
253 NetChartDialogController();
254 virtual ~NetChartDialogController() override;
256 virtual OUString getName() override;
257 virtual OUString getImage() override;
258 virtual const tTemplateServiceChartTypeParameterMap& getTemplateMap() const override;
259 virtual void fillSubTypeList(ValueSet& rSubTypeList,
260 const ChartTypeParameter& rParameter) override;
261 virtual void adjustParameterToSubType(ChartTypeParameter& rParameter) override;
263 virtual bool shouldShow_StackingControl() const override;
266 class StockChartDialogController final : public ChartTypeDialogController
268 public:
269 StockChartDialogController();
270 virtual ~StockChartDialogController() override;
272 virtual OUString getName() override;
273 virtual OUString getImage() override;
274 virtual const tTemplateServiceChartTypeParameterMap& getTemplateMap() const override;
275 virtual void fillSubTypeList(ValueSet& rSubTypeList,
276 const ChartTypeParameter& rParameter) override;
277 virtual void adjustParameterToSubType(ChartTypeParameter& rParameter) override;
280 class CombiColumnLineChartDialogController final : public ChartTypeDialogController
282 public:
283 CombiColumnLineChartDialogController();
285 virtual OUString getName() override;
286 virtual OUString getImage() override;
287 virtual const tTemplateServiceChartTypeParameterMap& getTemplateMap() const override;
288 virtual void fillSubTypeList(ValueSet& rSubTypeList,
289 const ChartTypeParameter& rParameter) override;
290 virtual void adjustParameterToSubType(ChartTypeParameter& rParameter) override;
292 virtual void showExtraControls(weld::Builder* pBuilder) override;
293 virtual void hideExtraControls() const override;
294 virtual void fillExtraControls(
295 const rtl::Reference<::chart::ChartModel>& xChartModel,
296 const css::uno::Reference<css::beans::XPropertySet>& xTemplateProps) const override;
298 virtual void setTemplateProperties(
299 const css::uno::Reference<css::beans::XPropertySet>& xTemplateProps) const override;
301 private:
302 DECL_LINK(ChangeLineCountHdl, weld::SpinButton&, void);
304 private:
305 std::unique_ptr<weld::Label> m_xFT_NumberOfLines;
306 std::unique_ptr<weld::SpinButton> m_xMF_NumberOfLines;
309 class BubbleChartDialogController final : public ChartTypeDialogController
311 public:
312 BubbleChartDialogController();
313 virtual ~BubbleChartDialogController() override;
315 virtual OUString getName() override;
316 virtual OUString getImage() override;
317 virtual const tTemplateServiceChartTypeParameterMap& getTemplateMap() const override;
318 virtual void fillSubTypeList(ValueSet& rSubTypeList,
319 const ChartTypeParameter& rParameter) override;
320 virtual void adjustParameterToSubType(ChartTypeParameter& rParameter) override;
323 } //namespace chart
325 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */