bump product version to 4.1.6.2
[LibreOffice.git] / chart2 / source / inc / DiagramHelper.hxx
blob5b1bb7bda23f6346569444f0e6603ec0f3fc08d6
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 #ifndef CHART2_DIAGRAMHELPER_HXX
20 #define CHART2_DIAGRAMHELPER_HXX
22 #include "StackMode.hxx"
23 #include "charttoolsdllapi.hxx"
24 #include <com/sun/star/chart2/XAxis.hpp>
25 #include <com/sun/star/chart2/XDiagram.hpp>
26 #include <com/sun/star/chart2/XChartTypeTemplate.hpp>
27 #include <com/sun/star/chart2/XCoordinateSystem.hpp>
28 #include <com/sun/star/chart2/InterpretedData.hpp>
29 #include <com/sun/star/chart2/StackingDirection.hpp>
30 #include <com/sun/star/chart2/XChartDocument.hpp>
31 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
32 #include <com/sun/star/uno/XComponentContext.hpp>
33 #include <com/sun/star/util/XNumberFormats.hpp>
34 #include <com/sun/star/util/XNumberFormatsSupplier.hpp>
36 #include <utility>
37 #include <vector>
40 namespace chart
43 enum DiagramPositioningMode
45 DiagramPositioningMode_AUTO,
46 DiagramPositioningMode_EXCLUDING,
47 DiagramPositioningMode_INCLUDING
50 class OOO_DLLPUBLIC_CHARTTOOLS DiagramHelper
52 public:
53 typedef ::std::pair<
54 ::com::sun::star::uno::Reference<
55 ::com::sun::star::chart2::XChartTypeTemplate >,
56 OUString >
57 tTemplateWithServiceName;
59 /** tries to find a template in the chart-type manager that matches the
60 given diagram.
62 @param rPreferredTemplateName
63 Check this template first. This may speed up searching, if the
64 caller assumes a certain template as most likely to be the one that
65 matches.
67 @return
68 A pair containing a template with the correct properties set as
69 first entry and the service name of the templateas second entry. If
70 no template was found both elements are empty.
72 static tTemplateWithServiceName
73 getTemplateForDiagram(
74 const ::com::sun::star::uno::Reference<
75 ::com::sun::star::chart2::XDiagram > & xDiagram,
76 const ::com::sun::star::uno::Reference<
77 ::com::sun::star::lang::XMultiServiceFactory > & xChartTypeManager,
78 const OUString & rPreferredTemplateName = OUString());
80 /** Sets the "SwapXAndYAxis" property at all coordinate systems found in the
81 given diagram.
83 "vertical==true" for bar charts, "vertical==false" for column charts
85 static void setVertical( const ::com::sun::star::uno::Reference<
86 ::com::sun::star::chart2::XDiagram > & xDiagram,
87 bool bVertical = true );
89 /** Gets the "SwapXAndYAxis" property at all coordinate systems found in the
90 given diagram.
92 "vertical==true" for bar charts, "vertical==false" for column charts
94 static bool getVertical( const ::com::sun::star::uno::Reference<
95 ::com::sun::star::chart2::XDiagram > & xDiagram,
96 bool& rbOutFoundResult, bool& rbOutAmbiguousResult );
98 static StackMode getStackMode(
99 const ::com::sun::star::uno::Reference<
100 ::com::sun::star::chart2::XDiagram > & xDiagram,
101 bool& rbFound, bool& rbAmbiguous
104 /** @param bOnlyAtFirstChartType
105 If </sal_True>, the stacking mode is only set at the series found inside
106 the first chart type. This is the standard for all current
107 templates (the only template that has more than one chart-type and
108 allows stacking is bar/line combi, and for this the stacking only
109 applies to the first chart type/the bars)
111 static void setStackMode(
112 const ::com::sun::star::uno::Reference<
113 ::com::sun::star::chart2::XDiagram > & xDiagram,
114 StackMode eStackMode,
115 bool bOnlyAtFirstChartType = true
118 /** Retrieves the stackmode of the first DataSeries or none. If the series have differing stack
119 modes, rbAmbiguous is set to true. If no series is there rbFound is set to false.
121 @param xCorrespondingCoordinateSystem
122 The coordinate system in which the given chart type xChartType is
123 located. (This is needed for determining percent stacking. If
124 omitted, the result will just indicate "not stacked", "stacked" or
125 "ambiguous")
127 static StackMode getStackModeFromChartType(
128 const ::com::sun::star::uno::Reference<
129 ::com::sun::star::chart2::XChartType > & xChartType,
130 bool& rbFound, bool& rbAmbiguous,
131 const ::com::sun::star::uno::Reference<
132 ::com::sun::star::chart2::XCoordinateSystem > & xCorrespondingCoordinateSystem =
133 ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XCoordinateSystem >()
136 /** Returns the dimension found for all chart types in the tree. If the
137 dimension is not unique, 0 is returned.
139 static sal_Int32 getDimension(
140 const ::com::sun::star::uno::Reference<
141 ::com::sun::star::chart2::XDiagram > & xDiagram );
143 /** Sets the dimension of the diagram given.
145 1. Sets the dimension of all used ChartTypes
146 2. Adapts the DataSeriesTree to reflect the new dimension
147 3. If new coordinate-systems have to be created, adapts the
148 XCoordinateSystemContainer of the diagram.
150 static void setDimension(
151 const ::com::sun::star::uno::Reference<
152 ::com::sun::star::chart2::XDiagram > & xDiagram,
153 sal_Int32 nNewDimensionCount );
155 /** Replaces all occurrences of xCooSysToReplace in the tree with
156 xReplacement in the diagram's tree
158 SAL_DLLPRIVATE static void replaceCoordinateSystem(
159 const ::com::sun::star::uno::Reference<
160 ::com::sun::star::chart2::XDiagram > & xDiagram,
161 const ::com::sun::star::uno::Reference<
162 ::com::sun::star::chart2::XCoordinateSystem > & xCooSysToReplace,
163 const ::com::sun::star::uno::Reference<
164 ::com::sun::star::chart2::XCoordinateSystem > & xReplacement );
166 static bool isSeriesAttachedToMainAxis(
167 const ::com::sun::star::uno::Reference<
168 ::com::sun::star::chart2::XDataSeries >& xDataSeries );
170 static bool attachSeriesToAxis( bool bMainAxis,
171 const ::com::sun::star::uno::Reference<
172 ::com::sun::star::chart2::XDataSeries >& xSeries,
173 const ::com::sun::star::uno::Reference<
174 ::com::sun::star::chart2::XDiagram >& xDiagram,
175 const ::com::sun::star::uno::Reference<
176 ::com::sun::star::uno::XComponentContext > & xContext,
177 bool bAdaptAxes=true );
179 static ::com::sun::star::uno::Reference<
180 ::com::sun::star::chart2::XAxis > getAttachedAxis(
181 const ::com::sun::star::uno::Reference<
182 ::com::sun::star::chart2::XDataSeries >& xSeries,
183 const ::com::sun::star::uno::Reference<
184 ::com::sun::star::chart2::XDiagram >& xDiagram );
186 static ::com::sun::star::uno::Reference<
187 ::com::sun::star::chart2::XChartType >
188 getChartTypeOfSeries(
189 const ::com::sun::star::uno::Reference<
190 ::com::sun::star::chart2::XDiagram >& xDiagram,
191 const ::com::sun::star::uno::Reference<
192 ::com::sun::star::chart2::XDataSeries >& xSeries );
194 static ::std::vector<
195 ::com::sun::star::uno::Reference<
196 ::com::sun::star::chart2::XDataSeries > >
197 getDataSeriesFromDiagram(
198 const ::com::sun::star::uno::Reference<
199 ::com::sun::star::chart2::XDiagram > & xDiagram );
201 /** return all data series in this diagram grouped by chart-types
203 static ::com::sun::star::uno::Sequence<
204 ::com::sun::star::uno::Sequence<
205 ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDataSeries > > >
206 getDataSeriesGroups(
207 const ::com::sun::star::uno::Reference<
208 ::com::sun::star::chart2::XDiagram > & xDiagram );
210 static bool isCategoryDiagram(
211 const ::com::sun::star::uno::Reference<
212 ::com::sun::star::chart2::XDiagram >& xDiagram );
214 static void setCategoriesToDiagram(
215 const ::com::sun::star::uno::Reference<
216 ::com::sun::star::chart2::data::XLabeledDataSequence >& xCategories,
217 const ::com::sun::star::uno::Reference<
218 ::com::sun::star::chart2::XDiagram >& xDiagram,
219 bool bSetAxisType = false, // when this flag is true ...
220 bool bCategoryAxis = true);// set the AxisType to CATEGORY or back to REALNUMBER
222 static ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XLabeledDataSequence >
223 getCategoriesFromDiagram(
224 const ::com::sun::star::uno::Reference<
225 ::com::sun::star::chart2::XDiagram > & xDiagram );
227 static ::com::sun::star::uno::Sequence< OUString >
228 getExplicitSimpleCategories(
229 const ::com::sun::star::uno::Reference<
230 ::com::sun::star::chart2::XChartDocument > & xChartDoc );
232 SAL_DLLPRIVATE static ::com::sun::star::uno::Sequence< OUString >
233 generateAutomaticCategoriesFromCooSys(
234 const ::com::sun::star::uno::Reference<
235 ::com::sun::star::chart2::XCoordinateSystem > & xCooSys );
237 static void switchToDateCategories(
238 const ::com::sun::star::uno::Reference<
239 ::com::sun::star::chart2::XChartDocument > & xChartDoc );
241 static void switchToTextCategories(
242 const ::com::sun::star::uno::Reference<
243 ::com::sun::star::chart2::XChartDocument > & xChartDoc );
245 static bool isSupportingDateAxis( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDiagram >& xDiagram );
246 static bool isDateNumberFormat( sal_Int32 nNumberFormat, const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormats >& xNumberFormats );
247 static sal_Int32 getDateNumberFormat( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier >& xNumberFormatsSupplier );
249 static sal_Int32 getPercentNumberFormat( const ::com::sun::star::uno::Reference<
250 ::com::sun::star::util::XNumberFormatsSupplier >& xNumberFormatsSupplier );
252 static ::com::sun::star::uno::Reference<
253 ::com::sun::star::chart2::XChartType >
254 getChartTypeByIndex( const ::com::sun::star::uno::Reference<
255 ::com::sun::star::chart2::XDiagram >& xDiagram, sal_Int32 nIndex );
257 static ::com::sun::star::uno::Sequence<
258 ::com::sun::star::uno::Reference<
259 ::com::sun::star::chart2::XChartType > >
260 getChartTypesFromDiagram(
261 const ::com::sun::star::uno::Reference<
262 ::com::sun::star::chart2::XDiagram > & xDiagram );
264 SAL_DLLPRIVATE static bool areChartTypesCompatible( const ::com::sun::star::uno::Reference<
265 ::com::sun::star::chart2::XChartType >& xFirstType,
266 const ::com::sun::star::uno::Reference<
267 ::com::sun::star::chart2::XChartType >& xSecondType );
271 * Test if a series can be moved.
273 * @param xDiagram
274 * Reference to the diagram that contains the series.
276 * @param xGivenDataSeries
277 * Reference to the series that should be tested for moving.
279 * @param bForward
280 * Direction of the move to be checked.
282 * @returns </sal_True> if the series can be moved.
285 static bool isSeriesMoveable(
286 const ::com::sun::star::uno::Reference<
287 ::com::sun::star::chart2::XDiagram >& xDiagram,
288 const ::com::sun::star::uno::Reference<
289 ::com::sun::star::chart2::XDataSeries >& xGivenDataSeries,
290 bool bForward );
293 * Move a series forward or backward.
295 * @param xDiagram
296 * Reference to the diagram that contains the series.
298 * @param xGivenDataSeries
299 * Reference to the series that should be moved.
301 * @param bForward
302 * Direction in which the series should be moved.
304 * @returns </sal_True> if the series was moved successfully.
307 static bool moveSeries(
308 const ::com::sun::star::uno::Reference<
309 ::com::sun::star::chart2::XDiagram >& xDiagram,
310 const ::com::sun::star::uno::Reference<
311 ::com::sun::star::chart2::XDataSeries >& xGivenDataSeries,
312 bool bForward );
314 static bool isSupportingFloorAndWall( const ::com::sun::star::uno::Reference<
315 ::com::sun::star::chart2::XDiagram > & xDiagram );
317 static bool isPieOrDonutChart( const ::com::sun::star::uno::Reference<
318 ::com::sun::star::chart2::XDiagram >& xDiagram );
320 static sal_Int32 getGeometry3D(
321 const ::com::sun::star::uno::Reference<
322 ::com::sun::star::chart2::XDiagram > & xDiagram,
323 bool& rbFound, bool& rbAmbiguous );
325 static void setGeometry3D(
326 const ::com::sun::star::uno::Reference<
327 ::com::sun::star::chart2::XDiagram > & xDiagram,
328 sal_Int32 nNewGeometry );
330 //returns integer from constant group ::com::sun::star::chart::MissingValueTreatment
331 static sal_Int32 getCorrectedMissingValueTreatment(
332 const ::com::sun::star::uno::Reference<
333 ::com::sun::star::chart2::XDiagram > & xDiagram,
334 const ::com::sun::star::uno::Reference<
335 ::com::sun::star::chart2::XChartType >& xChartType );
337 static DiagramPositioningMode getDiagramPositioningMode( const ::com::sun::star::uno::Reference<
338 ::com::sun::star::chart2::XDiagram > & xDiagram );
340 static bool setDiagramPositioning( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xChartModel,
341 const ::com::sun::star::awt::Rectangle& rPosRect /*100th mm*/ );
343 static ::com::sun::star::awt::Rectangle getDiagramRectangleFromModel( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xChartModel );
345 static bool switchDiagramPositioningToExcludingPositioning( const ::com::sun::star::uno::Reference<
346 ::com::sun::star::frame::XModel >& xChartModel
347 , bool bResetModifiedState //set model back to unchanged if it was unchanged before
348 , bool bConvertAlsoFromAutoPositioning );
350 private:
351 // not implemented
352 DiagramHelper();
356 } // namespace chart
358 // CHART2_DIAGRAMHELPER_HXX
359 #endif
361 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */