1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
28 #ifndef CHART2_DIAGRAMHELPER_HXX
29 #define CHART2_DIAGRAMHELPER_HXX
31 #include "StackMode.hxx"
32 #include "charttoolsdllapi.hxx"
33 #include <com/sun/star/chart2/XAxis.hpp>
34 #include <com/sun/star/chart2/XDiagram.hpp>
35 #include <com/sun/star/chart2/XChartTypeTemplate.hpp>
36 #include <com/sun/star/chart2/XCoordinateSystem.hpp>
37 #include <com/sun/star/chart2/InterpretedData.hpp>
38 #include <com/sun/star/chart2/StackingDirection.hpp>
39 #include <com/sun/star/chart2/XChartDocument.hpp>
40 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
41 #include <com/sun/star/uno/XComponentContext.hpp>
42 #include <com/sun/star/util/XNumberFormats.hpp>
43 #include <com/sun/star/util/XNumberFormatsSupplier.hpp>
52 enum DiagramPositioningMode
54 DiagramPositioningMode_AUTO
,
55 DiagramPositioningMode_EXCLUDING
,
56 DiagramPositioningMode_INCLUDING
59 class OOO_DLLPUBLIC_CHARTTOOLS DiagramHelper
63 ::com::sun::star::uno::Reference
<
64 ::com::sun::star::chart2::XChartTypeTemplate
>,
66 tTemplateWithServiceName
;
68 /** tries to find a template in the chart-type manager that matches the
71 @param rPreferredTemplateName
72 Check this template first. This may speed up searching, if the
73 caller assumes a certain template as most likely to be the one that
77 A pair containing a template with the correct properties set as
78 first entry and the service name of the templateas second entry. If
79 no template was found both elements are empty.
81 static tTemplateWithServiceName
82 getTemplateForDiagram(
83 const ::com::sun::star::uno::Reference
<
84 ::com::sun::star::chart2::XDiagram
> & xDiagram
,
85 const ::com::sun::star::uno::Reference
<
86 ::com::sun::star::lang::XMultiServiceFactory
> & xChartTypeManager
,
87 const ::rtl::OUString
& rPreferredTemplateName
= ::rtl::OUString());
89 /** Sets the "SwapXAndYAxis" property at all coordinate systems found in the
92 "vertical==true" for bar charts, "vertical==false" for column charts
94 static void setVertical( const ::com::sun::star::uno::Reference
<
95 ::com::sun::star::chart2::XDiagram
> & xDiagram
,
96 bool bVertical
= true );
98 /** Gets the "SwapXAndYAxis" property at all coordinate systems found in the
101 "vertical==true" for bar charts, "vertical==false" for column charts
103 static bool getVertical( const ::com::sun::star::uno::Reference
<
104 ::com::sun::star::chart2::XDiagram
> & xDiagram
,
105 bool& rbOutFoundResult
, bool& rbOutAmbiguousResult
);
107 static StackMode
getStackMode(
108 const ::com::sun::star::uno::Reference
<
109 ::com::sun::star::chart2::XDiagram
> & xDiagram
,
110 bool& rbFound
, bool& rbAmbiguous
113 /** @param bOnlyAtFirstChartType
114 If </sal_True>, the stacking mode is only set at the series found inside
115 the first chart type. This is the standard for all current
116 templates (the only template that has more than one chart-type and
117 allows stacking is bar/line combi, and for this the stacking only
118 applies to the first chart type/the bars)
120 static void setStackMode(
121 const ::com::sun::star::uno::Reference
<
122 ::com::sun::star::chart2::XDiagram
> & xDiagram
,
123 StackMode eStackMode
,
124 bool bOnlyAtFirstChartType
= true
127 /** Retrieves the stackmode of the first DataSeries or none. If the series have differing stack
128 modes, rbAmbiguous is set to true. If no series is there rbFound is set to false.
130 @param xCorrespondingCoordinateSystem
131 The coordinate system in which the given chart type xChartType is
132 located. (This is needed for determining percent stacking. If
133 omitted, the result will just indicate "not stacked", "stacked" or
136 static StackMode
getStackModeFromChartType(
137 const ::com::sun::star::uno::Reference
<
138 ::com::sun::star::chart2::XChartType
> & xChartType
,
139 bool& rbFound
, bool& rbAmbiguous
,
140 const ::com::sun::star::uno::Reference
<
141 ::com::sun::star::chart2::XCoordinateSystem
> & xCorrespondingCoordinateSystem
=
142 ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::XCoordinateSystem
>()
145 /** Returns the dimension found for all chart types in the tree. If the
146 dimension is not unique, 0 is returned.
148 static sal_Int32
getDimension(
149 const ::com::sun::star::uno::Reference
<
150 ::com::sun::star::chart2::XDiagram
> & xDiagram
);
152 /** Sets the dimension of the diagram given.
154 1. Sets the dimension of all used ChartTypes
155 2. Adapts the DataSeriesTree to reflect the new dimension
156 3. If new coordinate-systems have to be created, adapts the
157 XCoordinateSystemContainer of the diagram.
159 static void setDimension(
160 const ::com::sun::star::uno::Reference
<
161 ::com::sun::star::chart2::XDiagram
> & xDiagram
,
162 sal_Int32 nNewDimensionCount
);
164 /** Replaces all occurrences of xCooSysToReplace in the tree with
165 xReplacement in the diagram's tree
167 SAL_DLLPRIVATE
static void replaceCoordinateSystem(
168 const ::com::sun::star::uno::Reference
<
169 ::com::sun::star::chart2::XDiagram
> & xDiagram
,
170 const ::com::sun::star::uno::Reference
<
171 ::com::sun::star::chart2::XCoordinateSystem
> & xCooSysToReplace
,
172 const ::com::sun::star::uno::Reference
<
173 ::com::sun::star::chart2::XCoordinateSystem
> & xReplacement
);
175 static bool isSeriesAttachedToMainAxis(
176 const ::com::sun::star::uno::Reference
<
177 ::com::sun::star::chart2::XDataSeries
>& xDataSeries
);
179 static bool attachSeriesToAxis( bool bMainAxis
,
180 const ::com::sun::star::uno::Reference
<
181 ::com::sun::star::chart2::XDataSeries
>& xSeries
,
182 const ::com::sun::star::uno::Reference
<
183 ::com::sun::star::chart2::XDiagram
>& xDiagram
,
184 const ::com::sun::star::uno::Reference
<
185 ::com::sun::star::uno::XComponentContext
> & xContext
,
186 bool bAdaptAxes
=true );
188 static ::com::sun::star::uno::Reference
<
189 ::com::sun::star::chart2::XAxis
> getAttachedAxis(
190 const ::com::sun::star::uno::Reference
<
191 ::com::sun::star::chart2::XDataSeries
>& xSeries
,
192 const ::com::sun::star::uno::Reference
<
193 ::com::sun::star::chart2::XDiagram
>& xDiagram
);
195 static ::com::sun::star::uno::Reference
<
196 ::com::sun::star::chart2::XChartType
>
197 getChartTypeOfSeries(
198 const ::com::sun::star::uno::Reference
<
199 ::com::sun::star::chart2::XDiagram
>& xDiagram
,
200 const ::com::sun::star::uno::Reference
<
201 ::com::sun::star::chart2::XDataSeries
>& xSeries
);
203 static ::std::vector
<
204 ::com::sun::star::uno::Reference
<
205 ::com::sun::star::chart2::XDataSeries
> >
206 getDataSeriesFromDiagram(
207 const ::com::sun::star::uno::Reference
<
208 ::com::sun::star::chart2::XDiagram
> & xDiagram
);
210 /** return all data series in this diagram grouped by chart-types
212 static ::com::sun::star::uno::Sequence
<
213 ::com::sun::star::uno::Sequence
<
214 ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::XDataSeries
> > >
216 const ::com::sun::star::uno::Reference
<
217 ::com::sun::star::chart2::XDiagram
> & xDiagram
);
219 static bool isCategoryDiagram(
220 const ::com::sun::star::uno::Reference
<
221 ::com::sun::star::chart2::XDiagram
>& xDiagram
);
223 static void setCategoriesToDiagram(
224 const ::com::sun::star::uno::Reference
<
225 ::com::sun::star::chart2::data::XLabeledDataSequence
>& xCategories
,
226 const ::com::sun::star::uno::Reference
<
227 ::com::sun::star::chart2::XDiagram
>& xDiagram
,
228 bool bSetAxisType
= false, // when this flag is true ...
229 bool bCategoryAxis
= true);// set the AxisType to CATEGORY or back to REALNUMBER
231 static ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::data::XLabeledDataSequence
>
232 getCategoriesFromDiagram(
233 const ::com::sun::star::uno::Reference
<
234 ::com::sun::star::chart2::XDiagram
> & xDiagram
);
236 static ::com::sun::star::uno::Sequence
< rtl::OUString
>
237 getExplicitSimpleCategories(
238 const ::com::sun::star::uno::Reference
<
239 ::com::sun::star::chart2::XChartDocument
> & xChartDoc
);
241 SAL_DLLPRIVATE
static ::com::sun::star::uno::Sequence
< rtl::OUString
>
242 generateAutomaticCategoriesFromCooSys(
243 const ::com::sun::star::uno::Reference
<
244 ::com::sun::star::chart2::XCoordinateSystem
> & xCooSys
);
246 static void switchToDateCategories(
247 const ::com::sun::star::uno::Reference
<
248 ::com::sun::star::chart2::XChartDocument
> & xChartDoc
);
250 static void switchToTextCategories(
251 const ::com::sun::star::uno::Reference
<
252 ::com::sun::star::chart2::XChartDocument
> & xChartDoc
);
254 static bool isSupportingDateAxis( const ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::XDiagram
>& xDiagram
);
255 static bool isDateNumberFormat( sal_Int32 nNumberFormat
, const ::com::sun::star::uno::Reference
< ::com::sun::star::util::XNumberFormats
>& xNumberFormats
);
256 static sal_Int32
getDateNumberFormat( const ::com::sun::star::uno::Reference
< ::com::sun::star::util::XNumberFormatsSupplier
>& xNumberFormatsSupplier
);
258 static sal_Int32
getPercentNumberFormat( const ::com::sun::star::uno::Reference
<
259 ::com::sun::star::util::XNumberFormatsSupplier
>& xNumberFormatsSupplier
);
261 static ::com::sun::star::uno::Reference
<
262 ::com::sun::star::chart2::XChartType
>
263 getChartTypeByIndex( const ::com::sun::star::uno::Reference
<
264 ::com::sun::star::chart2::XDiagram
>& xDiagram
, sal_Int32 nIndex
);
266 static ::com::sun::star::uno::Sequence
<
267 ::com::sun::star::uno::Reference
<
268 ::com::sun::star::chart2::XChartType
> >
269 getChartTypesFromDiagram(
270 const ::com::sun::star::uno::Reference
<
271 ::com::sun::star::chart2::XDiagram
> & xDiagram
);
273 SAL_DLLPRIVATE
static bool areChartTypesCompatible( const ::com::sun::star::uno::Reference
<
274 ::com::sun::star::chart2::XChartType
>& xFirstType
,
275 const ::com::sun::star::uno::Reference
<
276 ::com::sun::star::chart2::XChartType
>& xSecondType
);
280 * Test if a series can be moved.
283 * Reference to the diagram that contains the series.
285 * @param xGivenDataSeries
286 * Reference to the series that should be tested for moving.
289 * Direction of the move to be checked.
291 * @returns </sal_True> if the series can be moved.
294 static bool isSeriesMoveable(
295 const ::com::sun::star::uno::Reference
<
296 ::com::sun::star::chart2::XDiagram
>& xDiagram
,
297 const ::com::sun::star::uno::Reference
<
298 ::com::sun::star::chart2::XDataSeries
>& xGivenDataSeries
,
302 * Move a series forward or backward.
305 * Reference to the diagram that contains the series.
307 * @param xGivenDataSeries
308 * Reference to the series that should be moved.
311 * Direction in which the series should be moved.
313 * @returns </sal_True> if the series was moved successfully.
316 static bool moveSeries(
317 const ::com::sun::star::uno::Reference
<
318 ::com::sun::star::chart2::XDiagram
>& xDiagram
,
319 const ::com::sun::star::uno::Reference
<
320 ::com::sun::star::chart2::XDataSeries
>& xGivenDataSeries
,
323 static bool isSupportingFloorAndWall( const ::com::sun::star::uno::Reference
<
324 ::com::sun::star::chart2::XDiagram
> & xDiagram
);
326 static bool isPieOrDonutChart( const ::com::sun::star::uno::Reference
<
327 ::com::sun::star::chart2::XDiagram
>& xDiagram
);
329 static sal_Int32
getGeometry3D(
330 const ::com::sun::star::uno::Reference
<
331 ::com::sun::star::chart2::XDiagram
> & xDiagram
,
332 bool& rbFound
, bool& rbAmbiguous
);
334 static void setGeometry3D(
335 const ::com::sun::star::uno::Reference
<
336 ::com::sun::star::chart2::XDiagram
> & xDiagram
,
337 sal_Int32 nNewGeometry
);
339 //returns integer from constant group ::com::sun::star::chart::MissingValueTreatment
340 static sal_Int32
getCorrectedMissingValueTreatment(
341 const ::com::sun::star::uno::Reference
<
342 ::com::sun::star::chart2::XDiagram
> & xDiagram
,
343 const ::com::sun::star::uno::Reference
<
344 ::com::sun::star::chart2::XChartType
>& xChartType
);
346 static DiagramPositioningMode
getDiagramPositioningMode( const ::com::sun::star::uno::Reference
<
347 ::com::sun::star::chart2::XDiagram
> & xDiagram
);
349 static bool setDiagramPositioning( const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XModel
>& xChartModel
,
350 const ::com::sun::star::awt::Rectangle
& rPosRect
/*100th mm*/ );
352 static ::com::sun::star::awt::Rectangle
getDiagramRectangleFromModel( const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XModel
>& xChartModel
);
354 static bool switchDiagramPositioningToExcludingPositioning( const ::com::sun::star::uno::Reference
<
355 ::com::sun::star::frame::XModel
>& xChartModel
356 , bool bResetModifiedState
//set model back to unchanged if it was unchanged before
357 , bool bConvertAlsoFromAutoPositioning
);
367 // CHART2_DIAGRAMHELPER_HXX
370 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */