1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
27 #ifndef CHART2_DIAGRAMHELPER_HXX
28 #define CHART2_DIAGRAMHELPER_HXX
30 #include "StackMode.hxx"
31 #include "charttoolsdllapi.hxx"
32 #include <com/sun/star/chart2/XAxis.hpp>
33 #include <com/sun/star/chart2/XDiagram.hpp>
34 #include <com/sun/star/chart2/XChartTypeTemplate.hpp>
35 #include <com/sun/star/chart2/XCoordinateSystem.hpp>
36 #include <com/sun/star/chart2/InterpretedData.hpp>
37 #include <com/sun/star/chart2/StackingDirection.hpp>
38 #include <com/sun/star/chart2/XChartDocument.hpp>
39 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
40 #include <com/sun/star/uno/XComponentContext.hpp>
49 enum DiagramPositioningMode
51 DiagramPositioningMode_AUTO
,
52 DiagramPositioningMode_EXCLUDING
,
53 DiagramPositioningMode_INCLUDING
56 class OOO_DLLPUBLIC_CHARTTOOLS DiagramHelper
60 ::com::sun::star::uno::Reference
<
61 ::com::sun::star::chart2::XChartTypeTemplate
>,
63 tTemplateWithServiceName
;
65 /** tries to find a template in the chart-type manager that matches the
68 @param rPreferredTemplateName
69 Check this template first. This may speed up searching, if the
70 caller assumes a certain template as most likely to be the one that
74 A pair containing a template with the correct properties set as
75 first entry and the service name of the templateas second entry. If
76 no template was found both elements are empty.
78 static tTemplateWithServiceName
79 getTemplateForDiagram(
80 const ::com::sun::star::uno::Reference
<
81 ::com::sun::star::chart2::XDiagram
> & xDiagram
,
82 const ::com::sun::star::uno::Reference
<
83 ::com::sun::star::lang::XMultiServiceFactory
> & xChartTypeManager
,
84 const ::rtl::OUString
& rPreferredTemplateName
= ::rtl::OUString());
86 /** Sets the "SwapXAndYAxis" property at all coordinate systems found in the
89 "vertical==true" for bar charts, "vertical==false" for column charts
91 static void setVertical( const ::com::sun::star::uno::Reference
<
92 ::com::sun::star::chart2::XDiagram
> & xDiagram
,
93 bool bVertical
= true );
95 /** Gets the "SwapXAndYAxis" property at all coordinate systems found in the
98 "vertical==true" for bar charts, "vertical==false" for column charts
100 static bool getVertical( const ::com::sun::star::uno::Reference
<
101 ::com::sun::star::chart2::XDiagram
> & xDiagram
,
102 bool& rbOutFoundResult
, bool& rbOutAmbiguousResult
);
104 static StackMode
getStackMode(
105 const ::com::sun::star::uno::Reference
<
106 ::com::sun::star::chart2::XDiagram
> & xDiagram
,
107 bool& rbFound
, bool& rbAmbiguous
110 /** @param bOnlyAtFirstChartType
111 If </TRUE>, the stacking mode is only set at the series found inside
112 the first chart type. This is the standard for all current
113 templates (the only template that has more than one chart-type and
114 allows stacking is bar/line combi, and for this the stacking only
115 applies to the first chart type/the bars)
117 static void setStackMode(
118 const ::com::sun::star::uno::Reference
<
119 ::com::sun::star::chart2::XDiagram
> & xDiagram
,
120 StackMode eStackMode
,
121 bool bOnlyAtFirstChartType
= true
124 /** Retrieves the stackmode of the first DataSeries or none. If the series have differing stack
125 modes, rbAmbiguous is set to true. If no series is there rbFound is set to false.
127 @param xCorrespondingCoordinateSystem
128 The coordinate system in which the given chart type xChartType is
129 located. (This is needed for determining percent stacking. If
130 omitted, the result will just indicate "not stacked", "stacked" or
133 static StackMode
getStackModeFromChartType(
134 const ::com::sun::star::uno::Reference
<
135 ::com::sun::star::chart2::XChartType
> & xChartType
,
136 bool& rbFound
, bool& rbAmbiguous
,
137 const ::com::sun::star::uno::Reference
<
138 ::com::sun::star::chart2::XCoordinateSystem
> & xCorrespondingCoordinateSystem
=
139 ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::XCoordinateSystem
>()
142 /** Returns the dimension found for all chart types in the tree. If the
143 dimension is not unique, 0 is returned.
145 static sal_Int32
getDimension(
146 const ::com::sun::star::uno::Reference
<
147 ::com::sun::star::chart2::XDiagram
> & xDiagram
);
149 /** Sets the dimension of the diagram given.
151 1. Sets the dimension of all used ChartTypes
152 2. Adapts the DataSeriesTree to reflect the new dimension
153 3. If new coordinate-systems have to be created, adapts the
154 XCoordinateSystemContainer of the diagram.
156 static void setDimension(
157 const ::com::sun::star::uno::Reference
<
158 ::com::sun::star::chart2::XDiagram
> & xDiagram
,
159 sal_Int32 nNewDimensionCount
);
161 /** Replaces all occurences of xCooSysToReplace in the tree with
162 xReplacement in the diagram's tree
164 SAL_DLLPRIVATE
static void replaceCoordinateSystem(
165 const ::com::sun::star::uno::Reference
<
166 ::com::sun::star::chart2::XDiagram
> & xDiagram
,
167 const ::com::sun::star::uno::Reference
<
168 ::com::sun::star::chart2::XCoordinateSystem
> & xCooSysToReplace
,
169 const ::com::sun::star::uno::Reference
<
170 ::com::sun::star::chart2::XCoordinateSystem
> & xReplacement
);
172 static bool isSeriesAttachedToMainAxis(
173 const ::com::sun::star::uno::Reference
<
174 ::com::sun::star::chart2::XDataSeries
>& xDataSeries
);
176 static bool attachSeriesToAxis( bool bMainAxis
,
177 const ::com::sun::star::uno::Reference
<
178 ::com::sun::star::chart2::XDataSeries
>& xSeries
,
179 const ::com::sun::star::uno::Reference
<
180 ::com::sun::star::chart2::XDiagram
>& xDiagram
,
181 const ::com::sun::star::uno::Reference
<
182 ::com::sun::star::uno::XComponentContext
> & xContext
,
183 bool bAdaptAxes
=true );
185 static ::com::sun::star::uno::Reference
<
186 ::com::sun::star::chart2::XAxis
> getAttachedAxis(
187 const ::com::sun::star::uno::Reference
<
188 ::com::sun::star::chart2::XDataSeries
>& xSeries
,
189 const ::com::sun::star::uno::Reference
<
190 ::com::sun::star::chart2::XDiagram
>& xDiagram
);
192 static ::com::sun::star::uno::Reference
<
193 ::com::sun::star::chart2::XChartType
>
194 getChartTypeOfSeries(
195 const ::com::sun::star::uno::Reference
<
196 ::com::sun::star::chart2::XDiagram
>& xDiagram
,
197 const ::com::sun::star::uno::Reference
<
198 ::com::sun::star::chart2::XDataSeries
>& xSeries
);
200 static ::std::vector
<
201 ::com::sun::star::uno::Reference
<
202 ::com::sun::star::chart2::XDataSeries
> >
203 getDataSeriesFromDiagram(
204 const ::com::sun::star::uno::Reference
<
205 ::com::sun::star::chart2::XDiagram
> & xDiagram
);
207 /** return all data series in this diagram grouped by chart-types
209 static ::com::sun::star::uno::Sequence
<
210 ::com::sun::star::uno::Sequence
<
211 ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::XDataSeries
> > >
213 const ::com::sun::star::uno::Reference
<
214 ::com::sun::star::chart2::XDiagram
> & xDiagram
);
216 static bool isCategoryDiagram(
217 const ::com::sun::star::uno::Reference
<
218 ::com::sun::star::chart2::XDiagram
>& xDiagram
);
220 static void setCategoriesToDiagram(
221 const ::com::sun::star::uno::Reference
<
222 ::com::sun::star::chart2::data::XLabeledDataSequence
>& xCategories
,
223 const ::com::sun::star::uno::Reference
<
224 ::com::sun::star::chart2::XDiagram
>& xDiagram
,
225 bool bSetAxisType
= false, // when this flag is true ...
226 bool bCategoryAxis
= true);// set the AxisType to CATEGORY or back to REALNUMBER
228 static ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::data::XLabeledDataSequence
>
229 getCategoriesFromDiagram(
230 const ::com::sun::star::uno::Reference
<
231 ::com::sun::star::chart2::XDiagram
> & xDiagram
);
233 static ::com::sun::star::uno::Sequence
< rtl::OUString
>
234 getExplicitSimpleCategories(
235 const ::com::sun::star::uno::Reference
<
236 ::com::sun::star::chart2::XChartDocument
> & xChartDoc
);
238 SAL_DLLPRIVATE
static ::com::sun::star::uno::Sequence
< rtl::OUString
>
239 generateAutomaticCategoriesFromCooSys(
240 const ::com::sun::star::uno::Reference
<
241 ::com::sun::star::chart2::XCoordinateSystem
> & xCooSys
);
243 static ::com::sun::star::uno::Reference
<
244 ::com::sun::star::chart2::XChartType
>
245 getChartTypeByIndex( const ::com::sun::star::uno::Reference
<
246 ::com::sun::star::chart2::XDiagram
>& xDiagram
, sal_Int32 nIndex
);
248 static ::com::sun::star::uno::Sequence
<
249 ::com::sun::star::uno::Reference
<
250 ::com::sun::star::chart2::XChartType
> >
251 getChartTypesFromDiagram(
252 const ::com::sun::star::uno::Reference
<
253 ::com::sun::star::chart2::XDiagram
> & xDiagram
);
255 SAL_DLLPRIVATE
static bool areChartTypesCompatible( const ::com::sun::star::uno::Reference
<
256 ::com::sun::star::chart2::XChartType
>& xFirstType
,
257 const ::com::sun::star::uno::Reference
<
258 ::com::sun::star::chart2::XChartType
>& xSecondType
);
262 * Test if a series can be moved.
265 * Reference to the diagram that contains the series.
267 * @param xGivenDataSeries
268 * Reference to the series that should be tested for moving.
271 * Direction of the move to be checked.
273 * @returns </TRUE> if the series can be moved.
276 static bool isSeriesMoveable(
277 const ::com::sun::star::uno::Reference
<
278 ::com::sun::star::chart2::XDiagram
>& xDiagram
,
279 const ::com::sun::star::uno::Reference
<
280 ::com::sun::star::chart2::XDataSeries
>& xGivenDataSeries
,
284 * Move a series forward or backward.
287 * Reference to the diagram that contains the series.
289 * @param xGivenDataSeries
290 * Reference to the series that should be moved.
293 * Direction in which the series should be moved.
295 * @returns </TRUE> if the series was moved successfully.
298 static bool moveSeries(
299 const ::com::sun::star::uno::Reference
<
300 ::com::sun::star::chart2::XDiagram
>& xDiagram
,
301 const ::com::sun::star::uno::Reference
<
302 ::com::sun::star::chart2::XDataSeries
>& xGivenDataSeries
,
305 static bool isSupportingFloorAndWall( const ::com::sun::star::uno::Reference
<
306 ::com::sun::star::chart2::XDiagram
> & xDiagram
);
308 static bool isPieOrDonutChart( const ::com::sun::star::uno::Reference
<
309 ::com::sun::star::chart2::XDiagram
>& xDiagram
);
311 static sal_Int32
getGeometry3D(
312 const ::com::sun::star::uno::Reference
<
313 ::com::sun::star::chart2::XDiagram
> & xDiagram
,
314 bool& rbFound
, bool& rbAmbiguous
);
316 static void setGeometry3D(
317 const ::com::sun::star::uno::Reference
<
318 ::com::sun::star::chart2::XDiagram
> & xDiagram
,
319 sal_Int32 nNewGeometry
);
321 //returns integer from constant group ::com::sun::star::chart::MissingValueTreatment
322 static sal_Int32
getCorrectedMissingValueTreatment(
323 const ::com::sun::star::uno::Reference
<
324 ::com::sun::star::chart2::XDiagram
> & xDiagram
,
325 const ::com::sun::star::uno::Reference
<
326 ::com::sun::star::chart2::XChartType
>& xChartType
);
328 static DiagramPositioningMode
getDiagramPositioningMode( const ::com::sun::star::uno::Reference
<
329 ::com::sun::star::chart2::XDiagram
> & xDiagram
);
331 static bool setDiagramPositioning( const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XModel
>& xChartModel
,
332 const ::com::sun::star::awt::Rectangle
& rPosRect
/*100th mm*/ );
334 static ::com::sun::star::awt::Rectangle
getDiagramRectangleFromModel( const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XModel
>& xChartModel
);
336 static bool switchDiagramPositioningToExcludingPositioning( const ::com::sun::star::uno::Reference
<
337 ::com::sun::star::frame::XModel
>& xChartModel
338 , bool bResetModifiedState
//set model back to unchanged if it was unchanged before
339 , bool bConvertAlsoFromAutoPositioning
);
349 // CHART2_DIAGRAMHELPER_HXX