merge the formfield patch from ooo-build
[ooovba.git] / chart2 / source / inc / DiagramHelper.hxx
blob49e2c17439473f404262138d93758ec8bae19be6
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: DiagramHelper.hxx,v $
10 * $Revision: 1.9.22.2 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef CHART2_DIAGRAMHELPER_HXX
31 #define CHART2_DIAGRAMHELPER_HXX
33 #include "StackMode.hxx"
34 #include "charttoolsdllapi.hxx"
35 #include <com/sun/star/chart2/XAxis.hpp>
36 #include <com/sun/star/chart2/XDiagram.hpp>
37 #include <com/sun/star/chart2/XChartTypeTemplate.hpp>
38 #include <com/sun/star/chart2/XCoordinateSystem.hpp>
39 #include <com/sun/star/chart2/InterpretedData.hpp>
40 #include <com/sun/star/chart2/StackingDirection.hpp>
41 #include <com/sun/star/chart2/XChartDocument.hpp>
42 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
43 #include <com/sun/star/uno/XComponentContext.hpp>
45 #include <utility>
46 #include <vector>
49 namespace chart
52 class OOO_DLLPUBLIC_CHARTTOOLS DiagramHelper
54 public:
55 typedef ::std::pair<
56 ::com::sun::star::uno::Reference<
57 ::com::sun::star::chart2::XChartTypeTemplate >,
58 ::rtl::OUString >
59 tTemplateWithServiceName;
61 /** tries to find a template in the chart-type manager that matches the
62 given diagram.
64 @param rPreferredTemplateName
65 Check this template first. This may speed up searching, if the
66 caller assumes a certain template as most likely to be the one that
67 matches.
69 @return
70 A pair containing a template with the correct properties set as
71 first entry and the service name of the templateas second entry. If
72 no template was found both elements are empty.
74 static tTemplateWithServiceName
75 getTemplateForDiagram(
76 const ::com::sun::star::uno::Reference<
77 ::com::sun::star::chart2::XDiagram > & xDiagram,
78 const ::com::sun::star::uno::Reference<
79 ::com::sun::star::lang::XMultiServiceFactory > & xChartTypeManager,
80 const ::rtl::OUString & rPreferredTemplateName = ::rtl::OUString());
82 /** Sets the "SwapXAndYAxis" property at all coordinate systems found in the
83 given diagram.
85 "vertical==true" for bar charts, "vertical==false" for column charts
87 static void setVertical( const ::com::sun::star::uno::Reference<
88 ::com::sun::star::chart2::XDiagram > & xDiagram,
89 bool bVertical = true );
91 /** Gets the "SwapXAndYAxis" property at all coordinate systems found in the
92 given diagram.
94 "vertical==true" for bar charts, "vertical==false" for column charts
96 static bool getVertical( const ::com::sun::star::uno::Reference<
97 ::com::sun::star::chart2::XDiagram > & xDiagram,
98 bool& rbOutFoundResult, bool& rbOutAmbiguousResult );
100 static StackMode getStackMode(
101 const ::com::sun::star::uno::Reference<
102 ::com::sun::star::chart2::XDiagram > & xDiagram,
103 bool& rbFound, bool& rbAmbiguous
106 /** @param bOnlyAtFirstChartType
107 If </TRUE>, the stacking mode is only set at the series found inside
108 the first chart type. This is the standard for all current
109 templates (the only template that has more than one chart-type and
110 allows stacking is bar/line combi, and for this the stacking only
111 applies to the first chart type/the bars)
113 static void setStackMode(
114 const ::com::sun::star::uno::Reference<
115 ::com::sun::star::chart2::XDiagram > & xDiagram,
116 StackMode eStackMode,
117 bool bOnlyAtFirstChartType = true
120 /** Retrieves the stackmode of the first DataSeries or none. If the series have differing stack
121 modes, rbAmbiguous is set to true. If no series is there rbFound is set to false.
123 @param xCorrespondingCoordinateSystem
124 The coordinate system in which the given chart type xChartType is
125 located. (This is needed for determining percent stacking. If
126 omitted, the result will just indicate "not stacked", "stacked" or
127 "ambiguous")
129 static StackMode getStackModeFromChartType(
130 const ::com::sun::star::uno::Reference<
131 ::com::sun::star::chart2::XChartType > & xChartType,
132 bool& rbFound, bool& rbAmbiguous,
133 const ::com::sun::star::uno::Reference<
134 ::com::sun::star::chart2::XCoordinateSystem > & xCorrespondingCoordinateSystem =
135 ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XCoordinateSystem >()
138 /** Returns the dimension found for all chart types in the tree. If the
139 dimension is not unique, 0 is returned.
141 static sal_Int32 getDimension(
142 const ::com::sun::star::uno::Reference<
143 ::com::sun::star::chart2::XDiagram > & xDiagram );
145 /** Sets the dimension of the diagram given.
147 1. Sets the dimension of all used ChartTypes
148 2. Adapts the DataSeriesTree to reflect the new dimension
149 3. If new coordinate-systems have to be created, adapts the
150 XCoordinateSystemContainer of the diagram.
152 static void setDimension(
153 const ::com::sun::star::uno::Reference<
154 ::com::sun::star::chart2::XDiagram > & xDiagram,
155 sal_Int32 nNewDimensionCount );
157 /** Replaces all occurences of xCooSysToReplace in the tree with
158 xReplacement in the diagram's tree
160 SAL_DLLPRIVATE static void replaceCoordinateSystem(
161 const ::com::sun::star::uno::Reference<
162 ::com::sun::star::chart2::XDiagram > & xDiagram,
163 const ::com::sun::star::uno::Reference<
164 ::com::sun::star::chart2::XCoordinateSystem > & xCooSysToReplace,
165 const ::com::sun::star::uno::Reference<
166 ::com::sun::star::chart2::XCoordinateSystem > & xReplacement );
168 static bool isSeriesAttachedToMainAxis(
169 const ::com::sun::star::uno::Reference<
170 ::com::sun::star::chart2::XDataSeries >& xDataSeries );
172 static bool attachSeriesToAxis( bool bMainAxis,
173 const ::com::sun::star::uno::Reference<
174 ::com::sun::star::chart2::XDataSeries >& xSeries,
175 const ::com::sun::star::uno::Reference<
176 ::com::sun::star::chart2::XDiagram >& xDiagram,
177 const ::com::sun::star::uno::Reference<
178 ::com::sun::star::uno::XComponentContext > & xContext );
180 static ::com::sun::star::uno::Reference<
181 ::com::sun::star::chart2::XAxis > getAttachedAxis(
182 const ::com::sun::star::uno::Reference<
183 ::com::sun::star::chart2::XDataSeries >& xSeries,
184 const ::com::sun::star::uno::Reference<
185 ::com::sun::star::chart2::XDiagram >& xDiagram );
187 static ::com::sun::star::uno::Reference<
188 ::com::sun::star::chart2::XChartType >
189 getChartTypeOfSeries(
190 const ::com::sun::star::uno::Reference<
191 ::com::sun::star::chart2::XDiagram >& xDiagram,
192 const ::com::sun::star::uno::Reference<
193 ::com::sun::star::chart2::XDataSeries >& xSeries );
195 static ::std::vector<
196 ::com::sun::star::uno::Reference<
197 ::com::sun::star::chart2::XDataSeries > >
198 getDataSeriesFromDiagram(
199 const ::com::sun::star::uno::Reference<
200 ::com::sun::star::chart2::XDiagram > & xDiagram );
202 /** return all data series in this diagram grouped by chart-types
204 static ::com::sun::star::uno::Sequence<
205 ::com::sun::star::uno::Sequence<
206 ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDataSeries > > >
207 getDataSeriesGroups(
208 const ::com::sun::star::uno::Reference<
209 ::com::sun::star::chart2::XDiagram > & xDiagram );
211 static bool isCategoryDiagram(
212 const ::com::sun::star::uno::Reference<
213 ::com::sun::star::chart2::XDiagram >& xDiagram );
215 static void setCategoriesToDiagram(
216 const ::com::sun::star::uno::Reference<
217 ::com::sun::star::chart2::data::XLabeledDataSequence >& xCategories,
218 const ::com::sun::star::uno::Reference<
219 ::com::sun::star::chart2::XDiagram >& xDiagram,
220 bool bSetAxisType = false, // when this flag is true ...
221 bool bCategoryAxis = true);// set the AxisType to CATEGORY or back to REALNUMBER
223 static ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XLabeledDataSequence >
224 getCategoriesFromDiagram(
225 const ::com::sun::star::uno::Reference<
226 ::com::sun::star::chart2::XDiagram > & xDiagram );
228 static ::com::sun::star::uno::Sequence< rtl::OUString >
229 generateAutomaticCategories(
230 const ::com::sun::star::uno::Reference<
231 ::com::sun::star::chart2::XChartDocument > & xChartDoc );
233 SAL_DLLPRIVATE static ::com::sun::star::uno::Sequence< rtl::OUString >
234 generateAutomaticCategories(
235 const ::com::sun::star::uno::Reference<
236 ::com::sun::star::chart2::XCoordinateSystem > & xCooSys );
238 SAL_DLLPRIVATE static void generateAutomaticCategoriesFromChartType(
239 ::com::sun::star::uno::Sequence< rtl::OUString >& rRet,
240 const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartType >& xChartType );
242 static ::com::sun::star::uno::Reference<
243 ::com::sun::star::chart2::XChartType >
244 getChartTypeByIndex( const ::com::sun::star::uno::Reference<
245 ::com::sun::star::chart2::XDiagram >& xDiagram, sal_Int32 nIndex );
247 static ::com::sun::star::uno::Sequence<
248 ::com::sun::star::uno::Reference<
249 ::com::sun::star::chart2::XChartType > >
250 getChartTypesFromDiagram(
251 const ::com::sun::star::uno::Reference<
252 ::com::sun::star::chart2::XDiagram > & xDiagram );
254 SAL_DLLPRIVATE static bool areChartTypesCompatible( const ::com::sun::star::uno::Reference<
255 ::com::sun::star::chart2::XChartType >& xFirstType,
256 const ::com::sun::star::uno::Reference<
257 ::com::sun::star::chart2::XChartType >& xSecondType );
261 * Test if a series can be moved.
263 * @param xDiagram
264 * Reference to the diagram that contains the series.
266 * @param xGivenDataSeries
267 * Reference to the series that should be tested for moving.
269 * @param bForward
270 * Direction of the move to be checked.
272 * @returns </TRUE> if the series can be moved.
275 static bool isSeriesMoveable(
276 const ::com::sun::star::uno::Reference<
277 ::com::sun::star::chart2::XDiagram >& xDiagram,
278 const ::com::sun::star::uno::Reference<
279 ::com::sun::star::chart2::XDataSeries >& xGivenDataSeries,
280 bool bForward );
283 * Move a series forward or backward.
285 * @param xDiagram
286 * Reference to the diagram that contains the series.
288 * @param xGivenDataSeries
289 * Reference to the series that should be moved.
291 * @param bForward
292 * Direction in which the series should be moved.
294 * @returns </TRUE> if the series was moved successfully.
297 static bool moveSeries(
298 const ::com::sun::star::uno::Reference<
299 ::com::sun::star::chart2::XDiagram >& xDiagram,
300 const ::com::sun::star::uno::Reference<
301 ::com::sun::star::chart2::XDataSeries >& xGivenDataSeries,
302 bool bForward );
304 static bool isSupportingFloorAndWall( const ::com::sun::star::uno::Reference<
305 ::com::sun::star::chart2::XDiagram > & xDiagram );
307 static bool isPieOrDonutChart( const ::com::sun::star::uno::Reference<
308 ::com::sun::star::chart2::XDiagram >& xDiagram );
310 static sal_Int32 getGeometry3D(
311 const ::com::sun::star::uno::Reference<
312 ::com::sun::star::chart2::XDiagram > & xDiagram,
313 bool& rbFound, bool& rbAmbiguous );
315 static void setGeometry3D(
316 const ::com::sun::star::uno::Reference<
317 ::com::sun::star::chart2::XDiagram > & xDiagram,
318 sal_Int32 nNewGeometry );
320 //returns integer from constant group ::com::sun::star::chart::MissingValueTreatment
321 static sal_Int32 getCorrectedMissingValueTreatment(
322 const ::com::sun::star::uno::Reference<
323 ::com::sun::star::chart2::XDiagram > & xDiagram,
324 const ::com::sun::star::uno::Reference<
325 ::com::sun::star::chart2::XChartType >& xChartType );
327 private:
328 // not implemented
329 DiagramHelper();
333 } // namespace chart
335 // CHART2_DIAGRAMHELPER_HXX
336 #endif