Avoid potential negative array index access to cached text.
[LibreOffice.git] / chart2 / source / inc / Diagram.hxx
blob1d3e8bd78901330c3b0eefadf0e1c2861e1fa11a
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 .
19 #pragma once
21 #include "OPropertySet.hxx"
22 #include <cppuhelper/implbase.hxx>
23 #include <comphelper/uno3.hxx>
24 #include <com/sun/star/chart2/XDiagram.hpp>
25 #include <com/sun/star/chart2/XCoordinateSystemContainer.hpp>
26 #include <com/sun/star/chart2/XTitled.hpp>
27 #include <com/sun/star/chart/X3DDefaultSetter.hpp>
28 #include <com/sun/star/util/XCloneable.hpp>
29 #include <com/sun/star/lang/XServiceInfo.hpp>
30 #include "ModifyListenerHelper.hxx"
31 #include "charttoolsdllapi.hxx"
33 #include <vector>
35 namespace com::sun::star::beans { struct PropertyValue; }
36 namespace com::sun::star::chart2 { class XDataSeries; }
37 namespace com::sun::star::chart2::data { class XDataSource; }
38 namespace com::sun::star::uno { class XComponentContext; }
40 namespace chart
42 class Axis;
43 class BaseCoordinateSystem;
44 class ChartType;
45 class ChartTypeManager;
46 class ChartTypeTemplate;
47 class DataSeries;
48 class Legend;
49 class DataTable;
50 class RegressionCurveModel;
51 enum class StackMode;
52 class Wall;
53 enum class ThreeDLookScheme;
55 enum class DiagramPositioningMode
57 Auto, Excluding, Including
61 namespace impl
63 typedef ::cppu::WeakImplHelper<
64 css::chart2::XDiagram,
65 css::lang::XServiceInfo,
66 css::chart2::XCoordinateSystemContainer,
67 css::chart2::XTitled,
68 css::chart::X3DDefaultSetter,
69 css::util::XModifyBroadcaster,
70 css::util::XModifyListener,
71 css::util::XCloneable >
72 Diagram_Base;
75 class OOO_DLLPUBLIC_CHARTTOOLS Diagram
76 final
77 : public impl::Diagram_Base
78 , public ::property::OPropertySet
80 public:
81 Diagram( css::uno::Reference< css::uno::XComponentContext > xContext );
82 virtual ~Diagram() override;
84 /// XServiceInfo declarations
85 virtual OUString SAL_CALL getImplementationName() override;
86 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
87 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
89 /// merge XInterface implementations
90 DECLARE_XINTERFACE()
91 /// merge XTypeProvider implementations
92 DECLARE_XTYPEPROVIDER()
94 explicit Diagram( const Diagram & rOther );
96 // ____ OPropertySet ____
97 virtual void GetDefaultValue( sal_Int32 nHandle, css::uno::Any& rAny ) const override;
99 // ____ OPropertySet ____
100 virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override;
102 // ____ XPropertySet ____
103 virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL
104 getPropertySetInfo() override;
106 // ____ XFastPropertySet ____
107 virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const css::uno::Any& rValue ) override;
109 /// make original interface function visible again
110 using ::com::sun::star::beans::XFastPropertySet::getFastPropertyValue;
112 virtual void SAL_CALL getFastPropertyValue(
113 css::uno::Any& rValue, sal_Int32 nHandle ) const override;
115 // ____ XDiagram ____
116 virtual css::uno::Reference< css::beans::XPropertySet > SAL_CALL getWall() override;
117 virtual css::uno::Reference< css::beans::XPropertySet > SAL_CALL getFloor() override;
118 virtual css::uno::Reference< css::chart2::XLegend > SAL_CALL getLegend() override;
119 virtual void SAL_CALL setLegend( const css::uno::Reference<
120 css::chart2::XLegend >& xLegend ) override;
121 virtual css::uno::Reference< css::chart2::XColorScheme > SAL_CALL getDefaultColorScheme() override;
122 virtual void SAL_CALL setDefaultColorScheme(
123 const css::uno::Reference< css::chart2::XColorScheme >& xColorScheme ) override;
124 virtual void SAL_CALL setDiagramData(
125 const css::uno::Reference< css::chart2::data::XDataSource >& xDataSource,
126 const css::uno::Sequence< css::beans::PropertyValue >& aArguments ) override;
128 virtual css::uno::Reference<css::chart2::XDataTable> SAL_CALL getDataTable() override;
129 virtual void SAL_CALL setDataTable(const css::uno::Reference<css::chart2::XDataTable>& xDataTable) override;
131 // ____ XCoordinateSystemContainer ____
132 virtual void SAL_CALL addCoordinateSystem(
133 const css::uno::Reference< css::chart2::XCoordinateSystem >& aCoordSys ) override;
134 virtual void SAL_CALL removeCoordinateSystem(
135 const css::uno::Reference< css::chart2::XCoordinateSystem >& aCoordSys ) override;
136 virtual css::uno::Sequence< css::uno::Reference< css::chart2::XCoordinateSystem > > SAL_CALL getCoordinateSystems() override;
137 virtual void SAL_CALL setCoordinateSystems(
138 const css::uno::Sequence< css::uno::Reference< css::chart2::XCoordinateSystem > >& aCoordinateSystems ) override;
140 // ____ XTitled ____
141 virtual css::uno::Reference<
142 css::chart2::XTitle > SAL_CALL getTitleObject() override;
143 virtual void SAL_CALL setTitleObject( const css::uno::Reference<
144 css::chart2::XTitle >& Title ) override;
146 // ____ X3DDefaultSetter ____
147 virtual void SAL_CALL set3DSettingsToDefault() override;
148 virtual void SAL_CALL setDefaultRotation() override;
149 virtual void SAL_CALL setDefaultIllumination() override;
151 // ____ XCloneable ____
152 virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone() override;
154 // ____ XModifyBroadcaster ____
155 virtual void SAL_CALL addModifyListener(
156 const css::uno::Reference< css::util::XModifyListener >& aListener ) override;
157 virtual void SAL_CALL removeModifyListener(
158 const css::uno::Reference< css::util::XModifyListener >& aListener ) override;
160 typedef
161 std::vector< rtl::Reference< ::chart::BaseCoordinateSystem > >
162 tCoordinateSystemContainerType;
164 tCoordinateSystemContainerType getBaseCoordinateSystems() const;
165 void setCoordinateSystems(
166 const std::vector< rtl::Reference< ::chart::BaseCoordinateSystem > >& aCoordinateSystems );
168 rtl::Reference< ::chart::Legend > getLegend2() const;
169 void setLegend(const rtl::Reference< ::chart::Legend > &);
171 void setDataTable(const rtl::Reference<::chart::DataTable>& xNewDataTable);
172 rtl::Reference<::chart::DataTable> getDataTableRef() const;
174 DiagramPositioningMode getDiagramPositioningMode();
176 //returns integer from constant group css::chart::MissingValueTreatment
177 sal_Int32 getCorrectedMissingValueTreatment(
178 const rtl::Reference< ::chart::ChartType >& xChartType );
180 void setGeometry3D( sal_Int32 nNewGeometry );
182 sal_Int32 getGeometry3D( bool& rbFound, bool& rbAmbiguous );
184 bool isPieOrDonutChart();
186 bool isSupportingFloorAndWall();
189 * Move a series forward or backward.
191 * @param xDiagram
192 * Reference to the diagram that contains the series.
194 * @param xGivenDataSeries
195 * Reference to the series that should be moved.
197 * @param bForward
198 * Direction in which the series should be moved.
200 * @returns </sal_True> if the series was moved successfully.
203 bool moveSeries(
204 const rtl::Reference< DataSeries >& xGivenDataSeries,
205 bool bForward );
208 * Test if a series can be moved.
210 * @param xDiagram
211 * Reference to the diagram that contains the series.
213 * @param xGivenDataSeries
214 * Reference to the series that should be tested for moving.
216 * @param bForward
217 * Direction of the move to be checked.
219 * @returns </sal_True> if the series can be moved.
222 bool isSeriesMoveable(
223 const rtl::Reference< DataSeries >& xGivenDataSeries,
224 bool bForward );
226 std::vector< rtl::Reference< ChartType > > getChartTypes();
228 rtl::Reference< ChartType > getChartTypeByIndex( sal_Int32 nIndex );
230 bool isSupportingDateAxis();
232 css::uno::Reference< css::chart2::data::XLabeledDataSequence >
233 getCategories();
235 void setCategories(
236 const css::uno::Reference< css::chart2::data::XLabeledDataSequence >& xCategories,
237 bool bSetAxisType = false, // when this flag is true ...
238 bool bCategoryAxis = true);// set the AxisType to CATEGORY or back to REALNUMBER
240 bool isCategory();
242 /** return all data series in this diagram grouped by chart-types
244 std::vector<
245 std::vector<
246 rtl::Reference< ::chart::DataSeries > > >
247 getDataSeriesGroups();
249 std::vector< rtl::Reference< ::chart::DataSeries > >
250 getDataSeries();
252 rtl::Reference< ChartType >
253 getChartTypeOfSeries( const rtl::Reference< DataSeries >& xSeries );
255 rtl::Reference< ::chart::Axis > getAttachedAxis(
256 const rtl::Reference< ::chart::DataSeries >& xSeries );
258 bool attachSeriesToAxis( bool bMainAxis,
259 const rtl::Reference< DataSeries >& xSeries,
260 const css::uno::Reference< css::uno::XComponentContext > & xContext,
261 bool bAdaptAxes=true );
263 /** Replaces all occurrences of xCooSysToReplace in the tree with
264 xReplacement in the diagram's tree
266 SAL_DLLPRIVATE void replaceCoordinateSystem(
267 const rtl::Reference< ::chart::BaseCoordinateSystem > & xCooSysToReplace,
268 const rtl::Reference< ::chart::BaseCoordinateSystem > & xReplacement );
271 /** Returns the dimension found for all chart types in the tree. If the
272 dimension is not unique, 0 is returned.
274 sal_Int32 getDimension();
276 /** Sets the dimension of the diagram given.
278 1. Sets the dimension of all used ChartTypes
279 2. Adapts the DataSeriesTree to reflect the new dimension
280 3. If new coordinate-systems have to be created, adapts the
281 XCoordinateSystemContainer of the diagram.
283 void setDimension( sal_Int32 nNewDimensionCount );
286 StackMode getStackMode(bool& rbFound, bool& rbAmbiguous);
288 /** The stacking mode is only set at the series found inside
289 the first chart type. This is the standard for all current
290 templates (the only template that has more than one chart-type and
291 allows stacking is bar/line combi, and for this the stacking only
292 applies to the first chart type/the bars)
294 void setStackMode(StackMode eStackMode);
297 /** Sets the "SwapXAndYAxis" property at all coordinate systems found in the
298 given diagram.
300 "vertical==true" for bar charts, "vertical==false" for column charts
302 void setVertical( bool bVertical );
304 /** Gets the "SwapXAndYAxis" property at all coordinate systems found in the
305 given diagram.
307 "vertical==true" for bar charts, "vertical==false" for column charts
309 bool getVertical( bool& rbOutFoundResult, bool& rbOutAmbiguousResult );
311 struct tTemplateWithServiceName {
312 rtl::Reference< ::chart::ChartTypeTemplate > xChartTypeTemplate;
313 OUString sServiceName;
316 /** tries to find a template in the chart-type manager that matches this
317 diagram.
319 @return
320 A pair containing a template with the correct properties set as
321 first entry and the service name of the templates second entry. If
322 no template was found both elements are empty.
324 tTemplateWithServiceName
325 getTemplate(const rtl::Reference< ::chart::ChartTypeManager > & xChartTypeManager);
327 std::vector<rtl::Reference<::chart::RegressionCurveModel> >
328 getAllRegressionCurvesNotMeanValueLine();
330 double getCameraDistance();
331 void setCameraDistance( double fCameraDistance );
333 void getRotation(
334 sal_Int32& rnHorizontalAngleDegree, sal_Int32& rnVerticalAngleDegree );
335 void setRotation(
336 sal_Int32 nHorizontalAngleDegree, sal_Int32 nVerticalYAngleDegree );
337 void getRotationAngle(
338 double& rfXAngleRad, double& rfYAngleRad, double& rfZAngleRad );
339 void setRotationAngle(
340 double fXAngleRad, double fYAngleRad, double fZAngleRad );
342 ThreeDLookScheme detectScheme();
343 void setScheme( ThreeDLookScheme aScheme );
345 void setDefaultRotation( bool bPieOrDonut );
347 void switchRightAngledAxes( bool bRightAngledAxes );
349 private:
350 // ____ XModifyListener ____
351 virtual void SAL_CALL modified(
352 const css::lang::EventObject& aEvent ) override;
354 // ____ XEventListener (base of XModifyListener) ____
355 virtual void SAL_CALL disposing(
356 const css::lang::EventObject& Source ) override;
358 // ____ OPropertySet ____
359 virtual void firePropertyChangeEvent() override;
360 using OPropertySet::disposing;
362 void fireModifyEvent();
364 css::uno::Reference<css::uno::XComponentContext> m_xContext;
365 tCoordinateSystemContainerType m_aCoordSystems;
367 rtl::Reference<Wall> m_xWall;
368 rtl::Reference<Wall> m_xFloor;
370 css::uno::Reference<css::chart2::XTitle> m_xTitle;
372 rtl::Reference<::chart::Legend> m_xLegend;
373 rtl::Reference<::chart::DataTable> m_xDataTable;
374 css::uno::Reference<css::chart2::XColorScheme> m_xColorScheme;
375 rtl::Reference<ModifyEventForwarder> m_xModifyEventForwarder;
379 } // namespace chart
381 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */