/src/libreoffice/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx
Line | Count | Source |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | /* |
3 | | * This file is part of the LibreOffice project. |
4 | | * |
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/. |
8 | | * |
9 | | * This file incorporates work covered by the following license notice: |
10 | | * |
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 . |
18 | | */ |
19 | | |
20 | | #include "DiagramWrapper.hxx" |
21 | | #include <servicenames_charttypes.hxx> |
22 | | #include "DataSeriesPointWrapper.hxx" |
23 | | #include <DataSeriesProperties.hxx> |
24 | | #include "AxisWrapper.hxx" |
25 | | #include "Chart2ModelContact.hxx" |
26 | | #include "WallFloorWrapper.hxx" |
27 | | #include "MinMaxLineWrapper.hxx" |
28 | | #include "UpDownBarWrapper.hxx" |
29 | | #include <Diagram.hxx> |
30 | | #include <DiagramHelper.hxx> |
31 | | #include <DataSourceHelper.hxx> |
32 | | #include <ChartType.hxx> |
33 | | #include <DataSeries.hxx> |
34 | | #include <WrappedIgnoreProperty.hxx> |
35 | | #include "WrappedAxisAndGridExistenceProperties.hxx" |
36 | | #include "WrappedStatisticProperties.hxx" |
37 | | #include "WrappedSymbolProperties.hxx" |
38 | | #include "WrappedDataCaptionProperties.hxx" |
39 | | #include "WrappedSplineProperties.hxx" |
40 | | #include "WrappedStockProperties.hxx" |
41 | | #include "WrappedSceneProperty.hxx" |
42 | | #include <ControllerLockGuard.hxx> |
43 | | #include <DisposeHelper.hxx> |
44 | | #include "WrappedAutomaticPositionProperties.hxx" |
45 | | #include <CommonConverters.hxx> |
46 | | #include <unonames.hxx> |
47 | | #include <comphelper/sequence.hxx> |
48 | | #include <cppuhelper/supportsservice.hxx> |
49 | | #include <ChartTypeManager.hxx> |
50 | | #include <ChartTypeTemplate.hxx> |
51 | | |
52 | | #include <com/sun/star/beans/PropertyAttribute.hpp> |
53 | | #include <com/sun/star/chart/ChartDataRowSource.hpp> |
54 | | #include <com/sun/star/chart2/RelativeSize.hpp> |
55 | | #include <com/sun/star/chart2/RelativePosition.hpp> |
56 | | #include <com/sun/star/chart2/PieChartSubType.hpp> |
57 | | #include <com/sun/star/chart/ChartSolidType.hpp> |
58 | | #include <com/sun/star/lang/IndexOutOfBoundsException.hpp> |
59 | | |
60 | | #include <LinePropertiesHelper.hxx> |
61 | | #include <FillProperties.hxx> |
62 | | #include <UserDefinedProperties.hxx> |
63 | | #include <SceneProperties.hxx> |
64 | | |
65 | | #include <algorithm> |
66 | | #include <map> |
67 | | #include <com/sun/star/lang/XServiceName.hpp> |
68 | | #include <com/sun/star/util/XRefreshable.hpp> |
69 | | #include <comphelper/diagnose_ex.hxx> |
70 | | #include <o3tl/string_view.hxx> |
71 | | #include <utility> |
72 | | |
73 | | using namespace ::com::sun::star; |
74 | | using namespace ::chart::wrapper; |
75 | | using namespace ::chart::DataSeriesProperties; |
76 | | |
77 | | using ::com::sun::star::uno::Reference; |
78 | | using ::com::sun::star::uno::Any; |
79 | | using ::com::sun::star::uno::Sequence; |
80 | | using ::com::sun::star::beans::Property; |
81 | | using ::com::sun::star::chart::XAxis; |
82 | | |
83 | | namespace |
84 | | { |
85 | | |
86 | | enum |
87 | | { |
88 | | PROP_DIAGRAM_ATTRIBUTED_DATA_POINTS, |
89 | | PROP_DIAGRAM_PERCENT_STACKED, |
90 | | PROP_DIAGRAM_STACKED, |
91 | | PROP_DIAGRAM_THREE_D, |
92 | | PROP_DIAGRAM_SOLIDTYPE, |
93 | | PROP_DIAGRAM_DEEP, |
94 | | PROP_DIAGRAM_VERTICAL, |
95 | | PROP_DIAGRAM_NUMBER_OF_LINES, |
96 | | PROP_DIAGRAM_STACKED_BARS_CONNECTED, |
97 | | PROP_DIAGRAM_DATAROW_SOURCE, |
98 | | |
99 | | PROP_DIAGRAM_GROUP_BARS_PER_AXIS, |
100 | | PROP_DIAGRAM_INCLUDE_HIDDEN_CELLS, |
101 | | |
102 | | PROP_DIAGRAM_SORT_BY_X_VALUES, |
103 | | |
104 | | PROP_DIAGRAM_STARTING_ANGLE, |
105 | | PROP_DIAGRAM_OF_PIE_TYPE, |
106 | | PROP_DIAGRAM_SPLIT_POS, |
107 | | |
108 | | PROP_DIAGRAM_RIGHT_ANGLED_AXES, |
109 | | PROP_DIAGRAM_PERSPECTIVE, |
110 | | PROP_DIAGRAM_ROTATION_HORIZONTAL, |
111 | | PROP_DIAGRAM_ROTATION_VERTICAL, |
112 | | |
113 | | PROP_DIAGRAM_MISSING_VALUE_TREATMENT, |
114 | | |
115 | | PROP_DIAGRAM_HAS_X_AXIS, |
116 | | PROP_DIAGRAM_HAS_X_AXIS_DESCR, |
117 | | PROP_DIAGRAM_HAS_X_AXIS_TITLE, |
118 | | PROP_DIAGRAM_HAS_X_AXIS_GRID, |
119 | | PROP_DIAGRAM_HAS_X_AXIS_HELP_GRID, |
120 | | |
121 | | PROP_DIAGRAM_HAS_Y_AXIS, |
122 | | PROP_DIAGRAM_HAS_Y_AXIS_DESCR, |
123 | | PROP_DIAGRAM_HAS_Y_AXIS_TITLE, |
124 | | PROP_DIAGRAM_HAS_Y_AXIS_GRID, |
125 | | PROP_DIAGRAM_HAS_Y_AXIS_HELP_GRID, |
126 | | |
127 | | PROP_DIAGRAM_HAS_Z_AXIS, |
128 | | PROP_DIAGRAM_HAS_Z_AXIS_DESCR, |
129 | | PROP_DIAGRAM_HAS_Z_AXIS_TITLE, |
130 | | PROP_DIAGRAM_HAS_Z_AXIS_GRID, |
131 | | PROP_DIAGRAM_HAS_Z_AXIS_HELP_GRID, |
132 | | |
133 | | PROP_DIAGRAM_HAS_SECOND_X_AXIS, |
134 | | PROP_DIAGRAM_HAS_SECOND_X_AXIS_DESCR, |
135 | | |
136 | | PROP_DIAGRAM_HAS_SECOND_Y_AXIS, |
137 | | PROP_DIAGRAM_HAS_SECOND_Y_AXIS_DESCR, |
138 | | |
139 | | PROP_DIAGRAM_HAS_SECOND_X_AXIS_TITLE, |
140 | | PROP_DIAGRAM_HAS_SECOND_Y_AXIS_TITLE, |
141 | | |
142 | | PROP_DIAGRAM_AUTOMATIC_SIZE, |
143 | | PROP_DIAGRAM_EXTERNALDATA, |
144 | | PROP_DIAGRAM_STYLE_INDEX |
145 | | }; |
146 | | |
147 | | void lcl_AddPropertiesToVector( |
148 | | std::vector< Property > & rOutProperties ) |
149 | 0 | { |
150 | 0 | rOutProperties.emplace_back( "AttributedDataPoints", |
151 | 0 | PROP_DIAGRAM_ATTRIBUTED_DATA_POINTS, |
152 | 0 | cppu::UnoType<uno::Sequence< uno::Sequence< sal_Int32 > >>::get(), |
153 | 0 | beans::PropertyAttribute::BOUND |
154 | 0 | | beans::PropertyAttribute::MAYBEVOID ); |
155 | | |
156 | | // see com.sun.star.chart.StackableDiagram |
157 | 0 | rOutProperties.emplace_back( "Percent", |
158 | 0 | PROP_DIAGRAM_PERCENT_STACKED, |
159 | 0 | cppu::UnoType<bool>::get(), |
160 | 0 | beans::PropertyAttribute::BOUND |
161 | 0 | | beans::PropertyAttribute::MAYBEDEFAULT ); |
162 | 0 | rOutProperties.emplace_back( "Stacked", |
163 | 0 | PROP_DIAGRAM_STACKED, |
164 | 0 | cppu::UnoType<bool>::get(), |
165 | 0 | beans::PropertyAttribute::BOUND |
166 | 0 | | beans::PropertyAttribute::MAYBEDEFAULT ); |
167 | |
|
168 | 0 | rOutProperties.emplace_back( "Dim3D", |
169 | 0 | PROP_DIAGRAM_THREE_D, |
170 | 0 | cppu::UnoType<bool>::get(), |
171 | 0 | beans::PropertyAttribute::BOUND |
172 | 0 | | beans::PropertyAttribute::MAYBEDEFAULT ); |
173 | | |
174 | | // see com.sun.star.chart.Chart3DBarProperties |
175 | 0 | rOutProperties.emplace_back( "SolidType", |
176 | 0 | PROP_DIAGRAM_SOLIDTYPE, |
177 | 0 | cppu::UnoType<sal_Int32>::get(), |
178 | 0 | beans::PropertyAttribute::BOUND |
179 | 0 | | beans::PropertyAttribute::MAYBEDEFAULT ); |
180 | | |
181 | | // see com.sun.star.chart.BarDiagram |
182 | 0 | rOutProperties.emplace_back( "Deep", |
183 | 0 | PROP_DIAGRAM_DEEP, |
184 | 0 | cppu::UnoType<bool>::get(), |
185 | 0 | beans::PropertyAttribute::BOUND |
186 | 0 | | beans::PropertyAttribute::MAYBEDEFAULT ); |
187 | 0 | rOutProperties.emplace_back( "Vertical", |
188 | 0 | PROP_DIAGRAM_VERTICAL, |
189 | 0 | cppu::UnoType<bool>::get(), |
190 | 0 | beans::PropertyAttribute::BOUND |
191 | 0 | | beans::PropertyAttribute::MAYBEDEFAULT ); |
192 | 0 | rOutProperties.emplace_back( "NumberOfLines", |
193 | 0 | PROP_DIAGRAM_NUMBER_OF_LINES, |
194 | 0 | cppu::UnoType<sal_Int32>::get(), |
195 | 0 | beans::PropertyAttribute::BOUND |
196 | 0 | | beans::PropertyAttribute::MAYBEDEFAULT ); |
197 | 0 | rOutProperties.emplace_back( "StackedBarsConnected", |
198 | 0 | PROP_DIAGRAM_STACKED_BARS_CONNECTED, |
199 | 0 | cppu::UnoType<bool>::get(), |
200 | 0 | beans::PropertyAttribute::BOUND |
201 | 0 | | beans::PropertyAttribute::MAYBEDEFAULT ); |
202 | |
|
203 | 0 | rOutProperties.emplace_back( "DataRowSource", |
204 | 0 | PROP_DIAGRAM_DATAROW_SOURCE, |
205 | 0 | cppu::UnoType<css::chart::ChartDataRowSource>::get(), |
206 | 0 | beans::PropertyAttribute::BOUND |
207 | 0 | | beans::PropertyAttribute::MAYBEDEFAULT ); |
208 | |
|
209 | 0 | rOutProperties.emplace_back( "GroupBarsPerAxis", |
210 | 0 | PROP_DIAGRAM_GROUP_BARS_PER_AXIS, |
211 | 0 | cppu::UnoType<bool>::get(), |
212 | 0 | beans::PropertyAttribute::BOUND |
213 | 0 | | beans::PropertyAttribute::MAYBEDEFAULT ); |
214 | |
|
215 | 0 | rOutProperties.emplace_back( "IncludeHiddenCells", |
216 | 0 | PROP_DIAGRAM_INCLUDE_HIDDEN_CELLS, |
217 | 0 | cppu::UnoType<bool>::get(), |
218 | 0 | beans::PropertyAttribute::BOUND |
219 | 0 | | beans::PropertyAttribute::MAYBEDEFAULT ); |
220 | | |
221 | | //new for XY charts |
222 | 0 | rOutProperties.emplace_back( CHART_UNONAME_SORT_BY_XVALUES, |
223 | 0 | PROP_DIAGRAM_SORT_BY_X_VALUES, |
224 | 0 | cppu::UnoType<bool>::get(), |
225 | 0 | beans::PropertyAttribute::BOUND |
226 | 0 | | beans::PropertyAttribute::MAYBEDEFAULT ); |
227 | | |
228 | | //for pie and donut charts |
229 | 0 | rOutProperties.emplace_back( "StartingAngle", |
230 | 0 | PROP_DIAGRAM_STARTING_ANGLE, |
231 | 0 | cppu::UnoType<sal_Int32>::get(), |
232 | 0 | beans::PropertyAttribute::BOUND |
233 | 0 | | beans::PropertyAttribute::MAYBEDEFAULT ); |
234 | 0 | rOutProperties.emplace_back( "SubPieType", |
235 | 0 | PROP_DIAGRAM_OF_PIE_TYPE, |
236 | 0 | cppu::UnoType<chart2::PieChartSubType>::get(), |
237 | 0 | beans::PropertyAttribute::BOUND |
238 | 0 | | beans::PropertyAttribute::MAYBEDEFAULT ); |
239 | 0 | rOutProperties.emplace_back( "SplitPos", |
240 | 0 | PROP_DIAGRAM_SPLIT_POS, |
241 | 0 | cppu::UnoType<sal_Int32>::get(), |
242 | 0 | beans::PropertyAttribute::BOUND |
243 | 0 | | beans::PropertyAttribute::MAYBEDEFAULT ); |
244 | | |
245 | | //new for 3D charts |
246 | 0 | rOutProperties.emplace_back( "RightAngledAxes", |
247 | 0 | PROP_DIAGRAM_RIGHT_ANGLED_AXES, |
248 | 0 | cppu::UnoType<bool>::get(), |
249 | 0 | beans::PropertyAttribute::BOUND |
250 | 0 | | beans::PropertyAttribute::MAYBEDEFAULT ); |
251 | |
|
252 | 0 | rOutProperties.emplace_back( "Perspective", |
253 | 0 | PROP_DIAGRAM_PERSPECTIVE, |
254 | 0 | cppu::UnoType<sal_Int32>::get(), |
255 | 0 | beans::PropertyAttribute::MAYBEVOID ); |
256 | |
|
257 | 0 | rOutProperties.emplace_back( "RotationHorizontal", |
258 | 0 | PROP_DIAGRAM_ROTATION_HORIZONTAL, |
259 | 0 | cppu::UnoType<sal_Int32>::get(), |
260 | 0 | beans::PropertyAttribute::MAYBEVOID ); |
261 | |
|
262 | 0 | rOutProperties.emplace_back( "RotationVertical", |
263 | 0 | PROP_DIAGRAM_ROTATION_VERTICAL, |
264 | 0 | cppu::UnoType<sal_Int32>::get(), |
265 | 0 | beans::PropertyAttribute::MAYBEVOID ); |
266 | | |
267 | | // XAxisXSupplier |
268 | 0 | rOutProperties.emplace_back( "HasXAxis", |
269 | 0 | PROP_DIAGRAM_HAS_X_AXIS, |
270 | 0 | cppu::UnoType<bool>::get(), |
271 | 0 | beans::PropertyAttribute::BOUND |
272 | 0 | | beans::PropertyAttribute::MAYBEDEFAULT ); |
273 | 0 | rOutProperties.emplace_back( "HasXAxisDescription", |
274 | 0 | PROP_DIAGRAM_HAS_X_AXIS_DESCR, |
275 | 0 | cppu::UnoType<bool>::get(), |
276 | 0 | beans::PropertyAttribute::BOUND |
277 | 0 | | beans::PropertyAttribute::MAYBEDEFAULT ); |
278 | 0 | rOutProperties.emplace_back( "HasXAxisTitle", |
279 | 0 | PROP_DIAGRAM_HAS_X_AXIS_TITLE, |
280 | 0 | cppu::UnoType<bool>::get(), |
281 | 0 | beans::PropertyAttribute::BOUND |
282 | 0 | | beans::PropertyAttribute::MAYBEDEFAULT ); |
283 | 0 | rOutProperties.emplace_back( "HasXAxisGrid", |
284 | 0 | PROP_DIAGRAM_HAS_X_AXIS_GRID, |
285 | 0 | cppu::UnoType<bool>::get(), |
286 | 0 | beans::PropertyAttribute::BOUND |
287 | 0 | | beans::PropertyAttribute::MAYBEDEFAULT ); |
288 | 0 | rOutProperties.emplace_back( "HasXAxisHelpGrid", |
289 | 0 | PROP_DIAGRAM_HAS_X_AXIS_HELP_GRID, |
290 | 0 | cppu::UnoType<bool>::get(), |
291 | 0 | beans::PropertyAttribute::BOUND |
292 | 0 | | beans::PropertyAttribute::MAYBEDEFAULT ); |
293 | | |
294 | | // XAxisYSupplier |
295 | 0 | rOutProperties.emplace_back( "HasYAxis", |
296 | 0 | PROP_DIAGRAM_HAS_Y_AXIS, |
297 | 0 | cppu::UnoType<bool>::get(), |
298 | 0 | beans::PropertyAttribute::BOUND |
299 | 0 | | beans::PropertyAttribute::MAYBEDEFAULT ); |
300 | 0 | rOutProperties.emplace_back( "HasYAxisDescription", |
301 | 0 | PROP_DIAGRAM_HAS_Y_AXIS_DESCR, |
302 | 0 | cppu::UnoType<bool>::get(), |
303 | 0 | beans::PropertyAttribute::BOUND |
304 | 0 | | beans::PropertyAttribute::MAYBEDEFAULT ); |
305 | 0 | rOutProperties.emplace_back( "HasYAxisTitle", |
306 | 0 | PROP_DIAGRAM_HAS_Y_AXIS_TITLE, |
307 | 0 | cppu::UnoType<bool>::get(), |
308 | 0 | beans::PropertyAttribute::BOUND |
309 | 0 | | beans::PropertyAttribute::MAYBEDEFAULT ); |
310 | 0 | rOutProperties.emplace_back( "HasYAxisGrid", |
311 | 0 | PROP_DIAGRAM_HAS_Y_AXIS_GRID, |
312 | 0 | cppu::UnoType<bool>::get(), |
313 | 0 | beans::PropertyAttribute::BOUND |
314 | 0 | | beans::PropertyAttribute::MAYBEDEFAULT ); |
315 | 0 | rOutProperties.emplace_back( "HasYAxisHelpGrid", |
316 | 0 | PROP_DIAGRAM_HAS_Y_AXIS_HELP_GRID, |
317 | 0 | cppu::UnoType<bool>::get(), |
318 | 0 | beans::PropertyAttribute::BOUND |
319 | 0 | | beans::PropertyAttribute::MAYBEDEFAULT ); |
320 | | |
321 | | // XAxisZSupplier |
322 | 0 | rOutProperties.emplace_back( "HasZAxis", |
323 | 0 | PROP_DIAGRAM_HAS_Z_AXIS, |
324 | 0 | cppu::UnoType<bool>::get(), |
325 | 0 | beans::PropertyAttribute::BOUND |
326 | 0 | | beans::PropertyAttribute::MAYBEDEFAULT ); |
327 | 0 | rOutProperties.emplace_back( "HasZAxisDescription", |
328 | 0 | PROP_DIAGRAM_HAS_Z_AXIS_DESCR, |
329 | 0 | cppu::UnoType<bool>::get(), |
330 | 0 | beans::PropertyAttribute::BOUND |
331 | 0 | | beans::PropertyAttribute::MAYBEDEFAULT ); |
332 | 0 | rOutProperties.emplace_back( "HasZAxisTitle", |
333 | 0 | PROP_DIAGRAM_HAS_Z_AXIS_TITLE, |
334 | 0 | cppu::UnoType<bool>::get(), |
335 | 0 | beans::PropertyAttribute::BOUND |
336 | 0 | | beans::PropertyAttribute::MAYBEDEFAULT ); |
337 | 0 | rOutProperties.emplace_back( "HasZAxisGrid", |
338 | 0 | PROP_DIAGRAM_HAS_Z_AXIS_GRID, |
339 | 0 | cppu::UnoType<bool>::get(), |
340 | 0 | beans::PropertyAttribute::BOUND |
341 | 0 | | beans::PropertyAttribute::MAYBEDEFAULT ); |
342 | 0 | rOutProperties.emplace_back( "HasZAxisHelpGrid", |
343 | 0 | PROP_DIAGRAM_HAS_Z_AXIS_HELP_GRID, |
344 | 0 | cppu::UnoType<bool>::get(), |
345 | 0 | beans::PropertyAttribute::BOUND |
346 | 0 | | beans::PropertyAttribute::MAYBEDEFAULT ); |
347 | | |
348 | | // XTwoAxisXSupplier |
349 | 0 | rOutProperties.emplace_back( "HasSecondaryXAxis", |
350 | 0 | PROP_DIAGRAM_HAS_SECOND_X_AXIS, |
351 | 0 | cppu::UnoType<bool>::get(), |
352 | 0 | beans::PropertyAttribute::BOUND |
353 | 0 | | beans::PropertyAttribute::MAYBEDEFAULT ); |
354 | 0 | rOutProperties.emplace_back( "HasSecondaryXAxisDescription", |
355 | 0 | PROP_DIAGRAM_HAS_SECOND_X_AXIS_DESCR, |
356 | 0 | cppu::UnoType<bool>::get(), |
357 | 0 | beans::PropertyAttribute::BOUND |
358 | 0 | | beans::PropertyAttribute::MAYBEDEFAULT ); |
359 | | |
360 | | // XTwoAxisYSupplier |
361 | 0 | rOutProperties.emplace_back( "HasSecondaryYAxis", |
362 | 0 | PROP_DIAGRAM_HAS_SECOND_Y_AXIS, |
363 | 0 | cppu::UnoType<bool>::get(), |
364 | 0 | beans::PropertyAttribute::BOUND |
365 | 0 | | beans::PropertyAttribute::MAYBEDEFAULT ); |
366 | 0 | rOutProperties.emplace_back( "HasSecondaryYAxisDescription", |
367 | 0 | PROP_DIAGRAM_HAS_SECOND_Y_AXIS_DESCR, |
368 | 0 | cppu::UnoType<bool>::get(), |
369 | 0 | beans::PropertyAttribute::BOUND |
370 | 0 | | beans::PropertyAttribute::MAYBEDEFAULT ); |
371 | | |
372 | | // XSecondAxisTitleSupplier |
373 | 0 | rOutProperties.emplace_back( "HasSecondaryXAxisTitle", |
374 | 0 | PROP_DIAGRAM_HAS_SECOND_X_AXIS_TITLE, |
375 | 0 | cppu::UnoType<bool>::get(), |
376 | 0 | beans::PropertyAttribute::BOUND |
377 | 0 | | beans::PropertyAttribute::MAYBEDEFAULT ); |
378 | 0 | rOutProperties.emplace_back( "HasSecondaryYAxisTitle", |
379 | 0 | PROP_DIAGRAM_HAS_SECOND_Y_AXIS_TITLE, |
380 | 0 | cppu::UnoType<bool>::get(), |
381 | 0 | beans::PropertyAttribute::BOUND |
382 | 0 | | beans::PropertyAttribute::MAYBEDEFAULT ); |
383 | |
|
384 | 0 | rOutProperties.emplace_back( "MissingValueTreatment", |
385 | 0 | PROP_DIAGRAM_MISSING_VALUE_TREATMENT, |
386 | 0 | cppu::UnoType<sal_Int32>::get(), |
387 | 0 | beans::PropertyAttribute::BOUND |
388 | 0 | | beans::PropertyAttribute::MAYBEVOID ); |
389 | |
|
390 | 0 | rOutProperties.emplace_back( "AutomaticSize", |
391 | 0 | PROP_DIAGRAM_AUTOMATIC_SIZE, |
392 | 0 | cppu::UnoType<bool>::get(), |
393 | 0 | beans::PropertyAttribute::BOUND |
394 | 0 | | beans::PropertyAttribute::MAYBEDEFAULT ); |
395 | | |
396 | | // chartSpace properties |
397 | 0 | rOutProperties.emplace_back( "ExternalData", |
398 | 0 | PROP_DIAGRAM_EXTERNALDATA, |
399 | 0 | cppu::UnoType<OUString>::get(), |
400 | 0 | beans::PropertyAttribute::BOUND |
401 | 0 | | beans::PropertyAttribute::MAYBEVOID ); |
402 | |
|
403 | 0 | rOutProperties.emplace_back( "StyleIndex", |
404 | 0 | PROP_DIAGRAM_STYLE_INDEX, |
405 | 0 | cppu::UnoType<sal_Int32>::get(), |
406 | 0 | beans::PropertyAttribute::BOUND |
407 | 0 | | beans::PropertyAttribute::MAYBEVOID ); |
408 | 0 | } |
409 | | |
410 | | const Sequence< Property >& StaticDiagramWrapperPropertyArray() |
411 | 0 | { |
412 | 0 | static Sequence< Property > aPropSeq = []() |
413 | 0 | { |
414 | 0 | std::vector< css::beans::Property > aProperties; |
415 | 0 | lcl_AddPropertiesToVector( aProperties ); |
416 | 0 | ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties ); |
417 | 0 | ::chart::FillProperties::AddPropertiesToVector( aProperties ); |
418 | 0 | ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); |
419 | 0 | ::chart::SceneProperties::AddPropertiesToVector( aProperties ); |
420 | 0 | WrappedStatisticProperties::addProperties( aProperties ); |
421 | 0 | WrappedSymbolProperties::addProperties( aProperties ); |
422 | 0 | WrappedDataCaptionProperties::addProperties( aProperties ); |
423 | 0 | WrappedSplineProperties::addProperties( aProperties ); |
424 | 0 | WrappedStockProperties::addProperties( aProperties ); |
425 | 0 | WrappedAutomaticPositionProperties::addProperties( aProperties ); |
426 | |
|
427 | 0 | std::sort( aProperties.begin(), aProperties.end(), |
428 | 0 | ::chart::PropertyNameLess() ); |
429 | |
|
430 | 0 | return comphelper::containerToSequence( aProperties ); |
431 | 0 | }(); |
432 | 0 | return aPropSeq; |
433 | 0 | }; |
434 | | |
435 | | bool lcl_isXYChart( const rtl::Reference< ::chart::Diagram >& xDiagram ) |
436 | 0 | { |
437 | 0 | bool bRet = false; |
438 | 0 | rtl::Reference< ::chart::ChartType > xChartType( xDiagram->getChartTypeByIndex( 0 ) ); |
439 | 0 | if( xChartType.is() ) |
440 | 0 | { |
441 | 0 | OUString aChartType( xChartType->getChartType() ); |
442 | 0 | if( aChartType.equalsIgnoreAsciiCase(CHART2_SERVICE_NAME_CHARTTYPE_SCATTER) ) |
443 | 0 | bRet = true; |
444 | 0 | } |
445 | 0 | return bRet; |
446 | 0 | } |
447 | | |
448 | | sal_Int32 lcl_getNewAPIIndexForOldAPIIndex( |
449 | | sal_Int32 nOldAPIIndex |
450 | | , const rtl::Reference< ::chart::Diagram >& xDiagram ) |
451 | 0 | { |
452 | 0 | sal_Int32 nNewAPIIndex = nOldAPIIndex; |
453 | |
|
454 | 0 | if( lcl_isXYChart( xDiagram ) ) |
455 | 0 | { |
456 | 0 | if( nNewAPIIndex >= 1 ) |
457 | 0 | nNewAPIIndex -= 1; |
458 | 0 | } |
459 | |
|
460 | 0 | std::vector< rtl::Reference< ::chart::DataSeries > > aSeriesList = |
461 | 0 | xDiagram->getDataSeries(); |
462 | 0 | if( nNewAPIIndex >= static_cast<sal_Int32>(aSeriesList.size()) ) |
463 | 0 | nNewAPIIndex = -1; |
464 | |
|
465 | 0 | return nNewAPIIndex; |
466 | 0 | } |
467 | | |
468 | | OUString lcl_getDiagramType( std::u16string_view rTemplateServiceName ) |
469 | 0 | { |
470 | 0 | static constexpr OUString aPrefix(u"com.sun.star.chart2.template."_ustr); |
471 | |
|
472 | 0 | if( o3tl::starts_with(rTemplateServiceName, aPrefix) ) |
473 | 0 | { |
474 | 0 | const std::u16string_view aName( rTemplateServiceName.substr( aPrefix.getLength())); |
475 | | |
476 | | // "Area" "StackedArea" "PercentStackedArea" "ThreeDArea" |
477 | | // "StackedThreeDArea" "PercentStackedThreeDArea" |
478 | 0 | if( aName.find( u"Area" ) != std::u16string_view::npos ) |
479 | 0 | return u"com.sun.star.chart.AreaDiagram"_ustr; |
480 | | |
481 | | // Handle bar-of-pie and pie-of-pie before simple pie |
482 | | // "BarOfPie" |
483 | 0 | if( aName.find( u"BarOfPie" ) != std::u16string_view::npos ) |
484 | 0 | return u"com.sun.star.chart.BarOfPieDiagram"_ustr; |
485 | | |
486 | | // "PieOfPie" |
487 | 0 | if( aName.find( u"PieOfPie" ) != std::u16string_view::npos ) |
488 | 0 | return u"com.sun.star.chart.PieOfPieDiagram"_ustr; |
489 | | |
490 | | // "Pie" "PieAllExploded" "ThreeDPie" "ThreeDPieAllExploded" |
491 | 0 | if( aName.find( u"Pie" ) != std::u16string_view::npos ) |
492 | 0 | return u"com.sun.star.chart.PieDiagram"_ustr; |
493 | | |
494 | | // "Column" "StackedColumn" "PercentStackedColumn" "ThreeDColumnDeep" |
495 | | // "ThreeDColumnFlat" "StackedThreeDColumnFlat" |
496 | | // "PercentStackedThreeDColumnFlat" "Bar" "StackedBar" |
497 | | // "PercentStackedBar" "ThreeDBarDeep" "ThreeDBarFlat" |
498 | | // "StackedThreeDBarFlat" "PercentStackedThreeDBarFlat" "ColumnWithLine" |
499 | | // "StackedColumnWithLine" |
500 | 0 | if( aName.find( u"Column" ) != std::u16string_view::npos || aName.find( u"Bar" ) != std::u16string_view::npos ) |
501 | 0 | return u"com.sun.star.chart.BarDiagram"_ustr; |
502 | | |
503 | | // "Donut" "DonutAllExploded" "ThreeDDonut" "ThreeDDonutAllExploded" |
504 | 0 | if( aName.find( u"Donut" ) != std::u16string_view::npos ) |
505 | 0 | return u"com.sun.star.chart.DonutDiagram"_ustr; |
506 | | |
507 | | // "ScatterLineSymbol" "ScatterLine" "ScatterSymbol" "ThreeDScatter" |
508 | 0 | if( aName.find( u"Scatter" ) != std::u16string_view::npos ) |
509 | 0 | return u"com.sun.star.chart.XYDiagram"_ustr; |
510 | | |
511 | | // "FilledNet" "StackedFilledNet" "PercentStackedFilledNet" |
512 | 0 | if( aName.find( u"FilledNet" ) != std::u16string_view::npos ) |
513 | 0 | return u"com.sun.star.chart.FilledNetDiagram"_ustr; |
514 | | |
515 | | // "Net" "NetSymbol" "NetLine" "StackedNet" "StackedNetSymbol" |
516 | | // "StackedNetLine" "PercentStackedNet" "PercentStackedNetSymbol" |
517 | | // "PercentStackedNetLine" |
518 | 0 | if( aName.find( u"Net" ) != std::u16string_view::npos ) |
519 | 0 | return u"com.sun.star.chart.NetDiagram"_ustr; |
520 | | |
521 | | // "StockLowHighClose" "StockOpenLowHighClose" "StockVolumeLowHighClose" |
522 | | // "StockVolumeOpenLowHighClose" |
523 | 0 | if( aName.find( u"Stock" ) != std::u16string_view::npos ) |
524 | 0 | return u"com.sun.star.chart.StockDiagram"_ustr; |
525 | | |
526 | 0 | if( aName.find( u"Bubble" ) != std::u16string_view::npos ) |
527 | 0 | return u"com.sun.star.chart.BubbleDiagram"_ustr; |
528 | | |
529 | | // Note: this must be checked after Bar, Net and Scatter |
530 | | |
531 | | // "Symbol" "StackedSymbol" "PercentStackedSymbol" "Line" "StackedLine" |
532 | | // "PercentStackedLine" "LineSymbol" "StackedLineSymbol" |
533 | | // "PercentStackedLineSymbol" "ThreeDLine" "StackedThreeDLine" |
534 | | // "PercentStackedThreeDLine" "ThreeDLineDeep" |
535 | 0 | if( aName.find( u"Line" ) != std::u16string_view::npos || aName.find( u"Symbol" ) != std::u16string_view::npos ) |
536 | 0 | return u"com.sun.star.chart.LineDiagram"_ustr; |
537 | | |
538 | 0 | OSL_FAIL( "unknown template" ); |
539 | 0 | } |
540 | | |
541 | 0 | return OUString(); |
542 | 0 | } |
543 | | |
544 | | typedef std::map< OUString, OUString > tMakeStringStringMap; |
545 | | |
546 | | const tMakeStringStringMap& lcl_getChartTypeNameMap() |
547 | 0 | { |
548 | 0 | static tMakeStringStringMap g_aChartTypeNameMap{ |
549 | 0 | {"com.sun.star.chart2.LineChartType", "com.sun.star.chart.LineDiagram"}, |
550 | 0 | {"com.sun.star.chart2.AreaChartType", "com.sun.star.chart.AreaDiagram"}, |
551 | 0 | {"com.sun.star.chart2.ColumnChartType", "com.sun.star.chart.BarDiagram"}, |
552 | 0 | {"com.sun.star.chart2.PieChartType", "com.sun.star.chart.PieDiagram"}, |
553 | 0 | {"com.sun.star.chart2.DonutChartType", "com.sun.star.chart.DonutDiagram"}, |
554 | 0 | {"com.sun.star.chart2.ScatterChartType", "com.sun.star.chart.XYDiagram"}, |
555 | 0 | {"com.sun.star.chart2.FilledNetChartType", "com.sun.star.chart.FilledNetDiagram"}, |
556 | 0 | {"com.sun.star.chart2.NetChartType", "com.sun.star.chart.NetDiagram"}, |
557 | 0 | {"com.sun.star.chart2.CandleStickChartType", "com.sun.star.chart.StockDiagram"}, |
558 | 0 | {"com.sun.star.chart2.BubbleChartType", "com.sun.star.chart.BubbleDiagram"} |
559 | 0 | }; |
560 | 0 | return g_aChartTypeNameMap; |
561 | 0 | } |
562 | | |
563 | | OUString lcl_getOldChartTypeName( const OUString & rNewChartTypeName ) |
564 | 0 | { |
565 | 0 | OUString aOld(rNewChartTypeName); |
566 | |
|
567 | 0 | const tMakeStringStringMap& rMap = lcl_getChartTypeNameMap(); |
568 | 0 | tMakeStringStringMap::const_iterator aIt( rMap.find( rNewChartTypeName )); |
569 | 0 | if( aIt != rMap.end()) |
570 | 0 | { |
571 | 0 | aOld = aIt->second; |
572 | 0 | } |
573 | 0 | return aOld; |
574 | 0 | } |
575 | | |
576 | | } // anonymous namespace |
577 | | |
578 | | namespace chart::wrapper |
579 | | { |
580 | | |
581 | | DiagramWrapper::DiagramWrapper(std::shared_ptr<Chart2ModelContact> spChart2ModelContact) |
582 | 0 | : m_spChart2ModelContact(std::move(spChart2ModelContact)) |
583 | 0 | { |
584 | 0 | } |
585 | | |
586 | | DiagramWrapper::~DiagramWrapper() |
587 | 0 | {} |
588 | | |
589 | | // ____ XDiagram ____ |
590 | | OUString SAL_CALL DiagramWrapper::getDiagramType() |
591 | 0 | { |
592 | 0 | OUString aRet; |
593 | |
|
594 | 0 | rtl::Reference< ChartModel > xChartDoc( m_spChart2ModelContact->getDocumentModel() ); |
595 | 0 | rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); |
596 | 0 | if( xChartDoc.is() && xDiagram.is() ) |
597 | 0 | { |
598 | 0 | Reference< beans::XPropertySet > xChartDocProp( static_cast<cppu::OWeakObject*>(xChartDoc.get()), uno::UNO_QUERY ); |
599 | 0 | if( xChartDocProp.is() ) |
600 | 0 | { |
601 | 0 | uno::Reference< util::XRefreshable > xAddIn; |
602 | 0 | if( xChartDocProp->getPropertyValue( u"AddIn"_ustr ) >>= xAddIn ) |
603 | 0 | { |
604 | 0 | uno::Reference< lang::XServiceName > xServiceName( xAddIn, uno::UNO_QUERY ); |
605 | 0 | if( xServiceName.is()) |
606 | 0 | return xServiceName->getServiceName(); |
607 | 0 | } |
608 | 0 | } |
609 | | |
610 | 0 | rtl::Reference< ::chart::ChartTypeManager > xChartTypeManager = xChartDoc->getTypeManager(); |
611 | 0 | Diagram::tTemplateWithServiceName aTemplateAndService = |
612 | 0 | xDiagram->getTemplate( xChartTypeManager ); |
613 | |
|
614 | 0 | aRet = lcl_getDiagramType( aTemplateAndService.sServiceName ); |
615 | 0 | } |
616 | | |
617 | 0 | if( !aRet.isEmpty()) |
618 | 0 | return aRet; |
619 | | |
620 | | // none of the standard templates matched |
621 | | // use first chart type |
622 | 0 | if (xDiagram) |
623 | 0 | { |
624 | 0 | rtl::Reference< ChartType > xChartType( xDiagram->getChartTypeByIndex( 0 ) ); |
625 | 0 | if( xChartType.is() ) |
626 | 0 | { |
627 | 0 | aRet = xChartType->getChartType(); |
628 | 0 | if( !aRet.isEmpty() ) |
629 | 0 | aRet = lcl_getOldChartTypeName( aRet ); |
630 | 0 | } |
631 | 0 | } |
632 | 0 | if( aRet.isEmpty()) |
633 | 0 | aRet = "com.sun.star.chart.BarDiagram"; |
634 | |
|
635 | 0 | return aRet; |
636 | 0 | } |
637 | | |
638 | | Reference< |
639 | | beans::XPropertySet > SAL_CALL DiagramWrapper::getDataRowProperties( sal_Int32 nRow ) |
640 | 0 | { |
641 | 0 | if( nRow < 0 ) |
642 | 0 | throw lang::IndexOutOfBoundsException(u"DataSeries index invalid"_ustr, |
643 | 0 | static_cast< ::cppu::OWeakObject * >( this )); |
644 | | |
645 | 0 | sal_Int32 nNewAPIIndex = lcl_getNewAPIIndexForOldAPIIndex( nRow, m_spChart2ModelContact->getDiagram() ); |
646 | 0 | if( nNewAPIIndex < 0 ) |
647 | 0 | throw lang::IndexOutOfBoundsException(u"DataSeries index invalid"_ustr, |
648 | 0 | static_cast< ::cppu::OWeakObject * >( this )); |
649 | | |
650 | 0 | Reference< beans::XPropertySet > xRet( new DataSeriesPointWrapper( |
651 | 0 | DataSeriesPointWrapper::DATA_SERIES, nNewAPIIndex, 0, m_spChart2ModelContact ) ); |
652 | 0 | return xRet; |
653 | 0 | } |
654 | | |
655 | | Reference< |
656 | | beans::XPropertySet > SAL_CALL DiagramWrapper::getDataPointProperties( sal_Int32 nCol, sal_Int32 nRow ) |
657 | 0 | { |
658 | 0 | if( nCol < 0 || nRow < 0 ) |
659 | 0 | throw lang::IndexOutOfBoundsException(u"DataSeries index invalid"_ustr, |
660 | 0 | static_cast< ::cppu::OWeakObject * >( this )); |
661 | | |
662 | 0 | sal_Int32 nNewAPIIndex = lcl_getNewAPIIndexForOldAPIIndex( nRow, m_spChart2ModelContact->getDiagram() ); |
663 | 0 | if( nNewAPIIndex < 0 ) |
664 | 0 | throw lang::IndexOutOfBoundsException(u"DataSeries index invalid"_ustr, |
665 | 0 | static_cast< ::cppu::OWeakObject * >( this )); |
666 | | |
667 | | //todo: check borders of point index |
668 | | |
669 | 0 | Reference< beans::XPropertySet > xRet( new DataSeriesPointWrapper( |
670 | 0 | DataSeriesPointWrapper::DATA_POINT, nNewAPIIndex, nCol, m_spChart2ModelContact ) ); |
671 | |
|
672 | 0 | return xRet; |
673 | 0 | } |
674 | | |
675 | | // ____ XShape (base of XDiagram) ____ |
676 | | awt::Point SAL_CALL DiagramWrapper::getPosition() |
677 | 0 | { |
678 | 0 | awt::Point aPosition = ToPoint( m_spChart2ModelContact->GetDiagramRectangleIncludingAxes() ); |
679 | 0 | return aPosition; |
680 | 0 | } |
681 | | |
682 | | void SAL_CALL DiagramWrapper::setPosition( const awt::Point& aPosition ) |
683 | 0 | { |
684 | 0 | ControllerLockGuardUNO aCtrlLockGuard( m_spChart2ModelContact->getDocumentModel() ); |
685 | 0 | Reference< beans::XPropertySet > xProp( getInnerPropertySet() ); |
686 | 0 | if( !xProp.is() ) |
687 | 0 | return; |
688 | | |
689 | 0 | awt::Size aPageSize( m_spChart2ModelContact->GetPageSize() ); |
690 | |
|
691 | 0 | chart2::RelativePosition aRelativePosition; |
692 | 0 | aRelativePosition.Anchor = drawing::Alignment_TOP_LEFT; |
693 | 0 | aRelativePosition.Primary = double(aPosition.X)/double(aPageSize.Width); |
694 | 0 | aRelativePosition.Secondary = double(aPosition.Y)/double(aPageSize.Height); |
695 | 0 | if( aRelativePosition.Primary < 0 || aRelativePosition.Secondary < 0 || aRelativePosition.Primary > 1 || aRelativePosition.Secondary > 1 ) |
696 | 0 | { |
697 | 0 | OSL_FAIL("DiagramWrapper::setPosition called with a position out of range -> automatic values are taken instead" ); |
698 | 0 | uno::Any aEmpty; |
699 | 0 | xProp->setPropertyValue( u"RelativePosition"_ustr, aEmpty ); |
700 | 0 | return; |
701 | 0 | } |
702 | 0 | xProp->setPropertyValue( u"RelativePosition"_ustr, uno::Any(aRelativePosition) ); |
703 | 0 | xProp->setPropertyValue( u"PosSizeExcludeAxes"_ustr, uno::Any(false) ); |
704 | 0 | } |
705 | | |
706 | | awt::Size SAL_CALL DiagramWrapper::getSize() |
707 | 0 | { |
708 | 0 | awt::Size aSize = ToSize( m_spChart2ModelContact->GetDiagramRectangleIncludingAxes() ); |
709 | 0 | return aSize; |
710 | 0 | } |
711 | | |
712 | | void SAL_CALL DiagramWrapper::setSize( const awt::Size& aSize ) |
713 | 0 | { |
714 | 0 | ControllerLockGuardUNO aCtrlLockGuard( m_spChart2ModelContact->getDocumentModel() ); |
715 | 0 | Reference< beans::XPropertySet > xProp( getInnerPropertySet() ); |
716 | 0 | if( !xProp.is() ) |
717 | 0 | return; |
718 | | |
719 | 0 | awt::Size aPageSize( m_spChart2ModelContact->GetPageSize() ); |
720 | |
|
721 | 0 | chart2::RelativeSize aRelativeSize; |
722 | 0 | aRelativeSize.Primary = double(aSize.Width)/double(aPageSize.Width); |
723 | 0 | aRelativeSize.Secondary = double(aSize.Height)/double(aPageSize.Height); |
724 | |
|
725 | 0 | if( aRelativeSize.Primary > 1 || aRelativeSize.Secondary > 1 ) |
726 | 0 | { |
727 | 0 | OSL_FAIL("DiagramWrapper::setSize called with sizes bigger than page -> automatic values are taken instead" ); |
728 | 0 | uno::Any aEmpty; |
729 | 0 | xProp->setPropertyValue( u"RelativeSize"_ustr, aEmpty ); |
730 | 0 | return; |
731 | 0 | } |
732 | | |
733 | 0 | xProp->setPropertyValue( u"RelativeSize"_ustr, uno::Any(aRelativeSize) ); |
734 | 0 | xProp->setPropertyValue( u"PosSizeExcludeAxes"_ustr, uno::Any(false) ); |
735 | 0 | } |
736 | | |
737 | | // ____ XShapeDescriptor (base of XShape) ____ |
738 | | OUString SAL_CALL DiagramWrapper::getShapeType() |
739 | 0 | { |
740 | 0 | return u"com.sun.star.chart.Diagram"_ustr; |
741 | 0 | } |
742 | | |
743 | | // ____ XDiagramPositioning ____ |
744 | | |
745 | | void SAL_CALL DiagramWrapper::setAutomaticDiagramPositioning() |
746 | 0 | { |
747 | 0 | ControllerLockGuardUNO aCtrlLockGuard( m_spChart2ModelContact->getDocumentModel() ); |
748 | 0 | uno::Reference< beans::XPropertySet > xDiaProps( getDiagram(), uno::UNO_QUERY ); |
749 | 0 | if( xDiaProps.is() ) |
750 | 0 | { |
751 | 0 | xDiaProps->setPropertyValue( u"RelativeSize"_ustr, Any() ); |
752 | 0 | xDiaProps->setPropertyValue( u"RelativePosition"_ustr, Any() ); |
753 | 0 | } |
754 | 0 | } |
755 | | sal_Bool SAL_CALL DiagramWrapper::isAutomaticDiagramPositioning( ) |
756 | 0 | { |
757 | 0 | uno::Reference< beans::XPropertySet > xDiaProps( getDiagram(), uno::UNO_QUERY ); |
758 | 0 | if( xDiaProps.is() ) |
759 | 0 | { |
760 | 0 | Any aRelativeSize( xDiaProps->getPropertyValue( u"RelativeSize"_ustr ) ); |
761 | 0 | Any aRelativePosition( xDiaProps->getPropertyValue( u"RelativePosition"_ustr ) ); |
762 | 0 | if( aRelativeSize.hasValue() && aRelativePosition.hasValue() ) |
763 | 0 | return false; |
764 | 0 | } |
765 | 0 | return true; |
766 | 0 | } |
767 | | void SAL_CALL DiagramWrapper::setDiagramPositionExcludingAxes( const awt::Rectangle& rPositionRect ) |
768 | 0 | { |
769 | 0 | ControllerLockGuardUNO aCtrlLockGuard( m_spChart2ModelContact->getDocumentModel() ); |
770 | 0 | DiagramHelper::setDiagramPositioning( m_spChart2ModelContact->getDocumentModel(), rPositionRect ); |
771 | 0 | uno::Reference< beans::XPropertySet > xDiaProps( getDiagram(), uno::UNO_QUERY ); |
772 | 0 | if( xDiaProps.is() ) |
773 | 0 | xDiaProps->setPropertyValue(u"PosSizeExcludeAxes"_ustr, uno::Any(true) ); |
774 | 0 | } |
775 | | sal_Bool SAL_CALL DiagramWrapper::isExcludingDiagramPositioning() |
776 | 0 | { |
777 | 0 | uno::Reference< beans::XPropertySet > xDiaProps( getDiagram(), uno::UNO_QUERY ); |
778 | 0 | if( xDiaProps.is() ) |
779 | 0 | { |
780 | 0 | Any aRelativeSize( xDiaProps->getPropertyValue( u"RelativeSize"_ustr ) ); |
781 | 0 | Any aRelativePosition( xDiaProps->getPropertyValue( u"RelativePosition"_ustr ) ); |
782 | 0 | if( aRelativeSize.hasValue() && aRelativePosition.hasValue() ) |
783 | 0 | { |
784 | 0 | bool bPosSizeExcludeAxes = false; |
785 | 0 | xDiaProps->getPropertyValue( u"PosSizeExcludeAxes"_ustr ) >>= bPosSizeExcludeAxes; |
786 | 0 | return bPosSizeExcludeAxes; |
787 | 0 | } |
788 | 0 | } |
789 | 0 | return false; |
790 | 0 | } |
791 | | awt::Rectangle SAL_CALL DiagramWrapper::calculateDiagramPositionExcludingAxes( ) |
792 | 0 | { |
793 | 0 | return m_spChart2ModelContact->GetDiagramRectangleExcludingAxes(); |
794 | 0 | } |
795 | | void SAL_CALL DiagramWrapper::setDiagramPositionIncludingAxes( const awt::Rectangle& rPositionRect ) |
796 | 0 | { |
797 | 0 | ControllerLockGuardUNO aCtrlLockGuard( m_spChart2ModelContact->getDocumentModel() ); |
798 | 0 | DiagramHelper::setDiagramPositioning( m_spChart2ModelContact->getDocumentModel(), rPositionRect ); |
799 | 0 | uno::Reference< beans::XPropertySet > xDiaProps( getDiagram(), uno::UNO_QUERY ); |
800 | 0 | if( xDiaProps.is() ) |
801 | 0 | xDiaProps->setPropertyValue(u"PosSizeExcludeAxes"_ustr, uno::Any(false) ); |
802 | 0 | } |
803 | | awt::Rectangle SAL_CALL DiagramWrapper::calculateDiagramPositionIncludingAxes( ) |
804 | 0 | { |
805 | 0 | return m_spChart2ModelContact->GetDiagramRectangleIncludingAxes(); |
806 | 0 | } |
807 | | void SAL_CALL DiagramWrapper::setDiagramPositionIncludingAxesAndAxisTitles( const awt::Rectangle& rPositionRect ) |
808 | 0 | { |
809 | 0 | ControllerLockGuardUNO aCtrlLockGuard( m_spChart2ModelContact->getDocumentModel() ); |
810 | 0 | awt::Rectangle aRect( m_spChart2ModelContact->SubstractAxisTitleSizes(rPositionRect) ); |
811 | 0 | DiagramWrapper::setDiagramPositionIncludingAxes( aRect ); |
812 | 0 | } |
813 | | css::awt::Rectangle SAL_CALL DiagramWrapper::calculateDiagramPositionIncludingAxesAndAxisTitles( ) |
814 | 0 | { |
815 | 0 | return m_spChart2ModelContact->GetDiagramRectangleIncludingTitle(); |
816 | 0 | } |
817 | | |
818 | | // ____ XAxisSupplier ____ |
819 | | Reference< XAxis > SAL_CALL DiagramWrapper::getAxis( sal_Int32 nDimensionIndex ) |
820 | 0 | { |
821 | 0 | rtl::Reference< AxisWrapper > xAxis; |
822 | 0 | if(!nDimensionIndex) |
823 | 0 | { |
824 | 0 | if( !m_xXAxis.is() ) |
825 | 0 | m_xXAxis = new AxisWrapper( AxisWrapper::X_AXIS, m_spChart2ModelContact ); |
826 | 0 | xAxis = m_xXAxis; |
827 | 0 | } |
828 | 0 | else if(nDimensionIndex==1) |
829 | 0 | { |
830 | 0 | if( !m_xYAxis.is() ) |
831 | 0 | m_xYAxis = new AxisWrapper( AxisWrapper::Y_AXIS, m_spChart2ModelContact ); |
832 | 0 | xAxis = m_xYAxis; |
833 | 0 | } |
834 | 0 | else if(nDimensionIndex==2) |
835 | 0 | { |
836 | 0 | if( !m_xZAxis.is() ) |
837 | 0 | m_xZAxis = new AxisWrapper( AxisWrapper::Z_AXIS, m_spChart2ModelContact ); |
838 | 0 | xAxis = m_xZAxis; |
839 | 0 | } |
840 | 0 | return xAxis; |
841 | 0 | } |
842 | | |
843 | | Reference< XAxis > SAL_CALL DiagramWrapper::getSecondaryAxis( sal_Int32 nDimensionIndex ) |
844 | 0 | { |
845 | 0 | rtl::Reference< AxisWrapper > xAxis; |
846 | 0 | if(!nDimensionIndex) |
847 | 0 | { |
848 | 0 | if( !m_xSecondXAxis.is() ) |
849 | 0 | m_xSecondXAxis = new AxisWrapper( AxisWrapper::SECOND_X_AXIS, m_spChart2ModelContact ); |
850 | 0 | xAxis = m_xSecondXAxis; |
851 | 0 | } |
852 | 0 | else if(nDimensionIndex==1) |
853 | 0 | { |
854 | 0 | if( !m_xSecondYAxis.is() ) |
855 | 0 | m_xSecondYAxis = new AxisWrapper( AxisWrapper::SECOND_Y_AXIS, m_spChart2ModelContact ); |
856 | 0 | xAxis = m_xSecondYAxis; |
857 | 0 | } |
858 | 0 | return xAxis; |
859 | 0 | } |
860 | | |
861 | | // ____ XAxisZSupplier ____ |
862 | | Reference< drawing::XShape > SAL_CALL DiagramWrapper::getZAxisTitle() |
863 | 0 | { |
864 | 0 | Reference< drawing::XShape > xRet; |
865 | 0 | Reference< XAxis > xAxis( getAxis(2) ); |
866 | 0 | if( xAxis.is() ) |
867 | 0 | xRet.set( xAxis->getAxisTitle(), uno::UNO_QUERY ); |
868 | 0 | return xRet; |
869 | 0 | } |
870 | | |
871 | | Reference< beans::XPropertySet > SAL_CALL DiagramWrapper::getZMainGrid() |
872 | 0 | { |
873 | 0 | Reference< beans::XPropertySet > xRet; |
874 | 0 | Reference< XAxis > xAxis( getAxis(2) ); |
875 | 0 | if( xAxis.is() ) |
876 | 0 | xRet = xAxis->getMajorGrid(); |
877 | 0 | return xRet; |
878 | 0 | } |
879 | | |
880 | | Reference< beans::XPropertySet > SAL_CALL DiagramWrapper::getZHelpGrid() |
881 | 0 | { |
882 | 0 | Reference< beans::XPropertySet > xRet; |
883 | 0 | Reference< XAxis > xAxis( getAxis(2) ); |
884 | 0 | if( xAxis.is() ) |
885 | 0 | xRet = xAxis->getMinorGrid(); |
886 | 0 | return xRet; |
887 | 0 | } |
888 | | |
889 | | Reference< beans::XPropertySet > SAL_CALL DiagramWrapper::getZAxis() |
890 | 0 | { |
891 | 0 | if( ! m_xZAxis.is()) |
892 | 0 | m_xZAxis = new AxisWrapper( AxisWrapper::Z_AXIS, m_spChart2ModelContact ); |
893 | 0 | return m_xZAxis; |
894 | 0 | } |
895 | | |
896 | | // ____ XTwoAxisXSupplier ____ |
897 | | Reference< beans::XPropertySet > SAL_CALL DiagramWrapper::getSecondaryXAxis() |
898 | 0 | { |
899 | 0 | if( ! m_xSecondXAxis.is()) |
900 | 0 | m_xSecondXAxis = new AxisWrapper( AxisWrapper::SECOND_X_AXIS, m_spChart2ModelContact ); |
901 | 0 | return m_xSecondXAxis; |
902 | 0 | } |
903 | | |
904 | | // ____ XAxisXSupplier (base of XTwoAxisXSupplier) ____ |
905 | | Reference< drawing::XShape > SAL_CALL DiagramWrapper::getXAxisTitle() |
906 | 0 | { |
907 | 0 | Reference< drawing::XShape > xRet; |
908 | 0 | Reference< XAxis > xAxis( getAxis(0) ); |
909 | 0 | if( xAxis.is() ) |
910 | 0 | xRet.set( xAxis->getAxisTitle(), uno::UNO_QUERY ); |
911 | 0 | return xRet; |
912 | 0 | } |
913 | | |
914 | | Reference< beans::XPropertySet > SAL_CALL DiagramWrapper::getXAxis() |
915 | 0 | { |
916 | 0 | if( ! m_xXAxis.is()) |
917 | 0 | m_xXAxis = new AxisWrapper( AxisWrapper::X_AXIS, m_spChart2ModelContact ); |
918 | 0 | return m_xXAxis; |
919 | 0 | } |
920 | | |
921 | | Reference< beans::XPropertySet > SAL_CALL DiagramWrapper::getXMainGrid() |
922 | 0 | { |
923 | 0 | Reference< beans::XPropertySet > xRet; |
924 | 0 | Reference< XAxis > xAxis( getAxis(0) ); |
925 | 0 | if( xAxis.is() ) |
926 | 0 | xRet = xAxis->getMajorGrid(); |
927 | 0 | return xRet; |
928 | 0 | } |
929 | | |
930 | | Reference< beans::XPropertySet > SAL_CALL DiagramWrapper::getXHelpGrid() |
931 | 0 | { |
932 | 0 | Reference< beans::XPropertySet > xRet; |
933 | 0 | Reference< XAxis > xAxis( getAxis(0) ); |
934 | 0 | if( xAxis.is() ) |
935 | 0 | xRet = xAxis->getMinorGrid(); |
936 | 0 | return xRet; |
937 | 0 | } |
938 | | |
939 | | // ____ XTwoAxisYSupplier ____ |
940 | | Reference< beans::XPropertySet > SAL_CALL DiagramWrapper::getSecondaryYAxis() |
941 | 0 | { |
942 | 0 | if( ! m_xSecondYAxis.is()) |
943 | 0 | m_xSecondYAxis = new AxisWrapper( AxisWrapper::SECOND_Y_AXIS, m_spChart2ModelContact ); |
944 | 0 | return m_xSecondYAxis; |
945 | 0 | } |
946 | | |
947 | | // ____ XAxisYSupplier (base of XTwoAxisYSupplier) ____ |
948 | | Reference< drawing::XShape > SAL_CALL DiagramWrapper::getYAxisTitle() |
949 | 0 | { |
950 | 0 | Reference< drawing::XShape > xRet; |
951 | 0 | Reference< XAxis > xAxis( getAxis(1) ); |
952 | 0 | if( xAxis.is() ) |
953 | 0 | xRet.set( xAxis->getAxisTitle(), uno::UNO_QUERY ); |
954 | 0 | return xRet; |
955 | 0 | } |
956 | | |
957 | | Reference< beans::XPropertySet > SAL_CALL DiagramWrapper::getYAxis() |
958 | 0 | { |
959 | 0 | if( ! m_xYAxis.is()) |
960 | 0 | m_xYAxis = new AxisWrapper( AxisWrapper::Y_AXIS, m_spChart2ModelContact ); |
961 | 0 | return m_xYAxis; |
962 | 0 | } |
963 | | |
964 | | Reference< beans::XPropertySet > SAL_CALL DiagramWrapper::getYMainGrid() |
965 | 0 | { |
966 | 0 | Reference< beans::XPropertySet > xRet; |
967 | 0 | Reference< XAxis > xAxis( getAxis(1) ); |
968 | 0 | if( xAxis.is() ) |
969 | 0 | xRet = xAxis->getMajorGrid(); |
970 | 0 | return xRet; |
971 | 0 | } |
972 | | |
973 | | Reference< beans::XPropertySet > SAL_CALL DiagramWrapper::getYHelpGrid() |
974 | 0 | { |
975 | 0 | Reference< beans::XPropertySet > xRet; |
976 | 0 | Reference< XAxis > xAxis( getAxis(1) ); |
977 | 0 | if( xAxis.is() ) |
978 | 0 | xRet = xAxis->getMinorGrid(); |
979 | 0 | return xRet; |
980 | 0 | } |
981 | | |
982 | | // ____ XSecondAxisTitleSupplier ____ |
983 | | Reference< drawing::XShape > SAL_CALL DiagramWrapper::getSecondXAxisTitle() |
984 | 0 | { |
985 | 0 | Reference< drawing::XShape > xRet; |
986 | 0 | Reference< XAxis > xAxis( getSecondaryAxis(0) ); |
987 | 0 | if( xAxis.is() ) |
988 | 0 | xRet.set( xAxis->getAxisTitle(), uno::UNO_QUERY ); |
989 | 0 | return xRet; |
990 | 0 | } |
991 | | |
992 | | Reference< drawing::XShape > SAL_CALL DiagramWrapper::getSecondYAxisTitle() |
993 | 0 | { |
994 | 0 | Reference< drawing::XShape > xRet; |
995 | 0 | Reference< XAxis > xAxis( getSecondaryAxis(1) ); |
996 | 0 | if( xAxis.is() ) |
997 | 0 | xRet.set( xAxis->getAxisTitle(), uno::UNO_QUERY ); |
998 | 0 | return xRet; |
999 | 0 | } |
1000 | | |
1001 | | // ____ XStatisticDisplay ____ |
1002 | | Reference< |
1003 | | beans::XPropertySet > SAL_CALL DiagramWrapper::getUpBar() |
1004 | 0 | { |
1005 | 0 | if( !m_xUpBarWrapper.is() ) |
1006 | 0 | { |
1007 | 0 | m_xUpBarWrapper = new UpDownBarWrapper( true, m_spChart2ModelContact ); |
1008 | 0 | } |
1009 | 0 | return m_xUpBarWrapper; |
1010 | 0 | } |
1011 | | |
1012 | | Reference< |
1013 | | beans::XPropertySet > SAL_CALL DiagramWrapper::getDownBar() |
1014 | 0 | { |
1015 | 0 | if( !m_xDownBarWrapper.is() ) |
1016 | 0 | { |
1017 | 0 | m_xDownBarWrapper = new UpDownBarWrapper( false, m_spChart2ModelContact ); |
1018 | 0 | } |
1019 | 0 | return m_xDownBarWrapper; |
1020 | 0 | } |
1021 | | |
1022 | | Reference< |
1023 | | beans::XPropertySet > SAL_CALL DiagramWrapper::getMinMaxLine() |
1024 | 0 | { |
1025 | 0 | if( !m_xMinMaxLineWrapper.is() ) |
1026 | 0 | { |
1027 | 0 | m_xMinMaxLineWrapper = new MinMaxLineWrapper( m_spChart2ModelContact ); |
1028 | 0 | } |
1029 | 0 | return m_xMinMaxLineWrapper; |
1030 | 0 | } |
1031 | | |
1032 | | // ____ X3DDisplay ____ |
1033 | | Reference< beans::XPropertySet > SAL_CALL DiagramWrapper::getWall() |
1034 | 0 | { |
1035 | 0 | if( !m_xWall.is() ) |
1036 | 0 | { |
1037 | 0 | m_xWall = new WallFloorWrapper( true, m_spChart2ModelContact ); |
1038 | 0 | } |
1039 | 0 | return m_xWall; |
1040 | 0 | } |
1041 | | |
1042 | | Reference< |
1043 | | beans::XPropertySet > SAL_CALL DiagramWrapper::getFloor() |
1044 | 0 | { |
1045 | 0 | if( !m_xFloor.is() ) |
1046 | 0 | { |
1047 | 0 | m_xFloor = new WallFloorWrapper( false, m_spChart2ModelContact ); |
1048 | 0 | } |
1049 | 0 | return m_xFloor; |
1050 | 0 | } |
1051 | | |
1052 | | // ____ X3DDefaultSetter ____ |
1053 | | void SAL_CALL DiagramWrapper::set3DSettingsToDefault() |
1054 | 0 | { |
1055 | 0 | rtl::Reference< ::chart::Diagram > x3DDefaultSetter( m_spChart2ModelContact->getDiagram() ); |
1056 | 0 | if( x3DDefaultSetter.is() ) |
1057 | 0 | x3DDefaultSetter->set3DSettingsToDefault(); |
1058 | 0 | } |
1059 | | |
1060 | | void SAL_CALL DiagramWrapper::setDefaultRotation() |
1061 | 0 | { |
1062 | 0 | rtl::Reference< ::chart::Diagram > x3DDefaultSetter( m_spChart2ModelContact->getDiagram() ); |
1063 | 0 | if( x3DDefaultSetter.is() ) |
1064 | 0 | x3DDefaultSetter->setDefaultRotation(); |
1065 | 0 | } |
1066 | | |
1067 | | void SAL_CALL DiagramWrapper::setDefaultIllumination() |
1068 | 0 | { |
1069 | 0 | rtl::Reference< ::chart::Diagram > x3DDefaultSetter( m_spChart2ModelContact->getDiagram() ); |
1070 | 0 | if( x3DDefaultSetter.is() ) |
1071 | 0 | x3DDefaultSetter->setDefaultIllumination(); |
1072 | 0 | } |
1073 | | |
1074 | | // ____ XComponent ____ |
1075 | | void SAL_CALL DiagramWrapper::dispose() |
1076 | 0 | { |
1077 | 0 | std::unique_lock g(m_aMutex); |
1078 | 0 | m_aEventListenerContainer.disposeAndClear( g, lang::EventObject( static_cast< ::cppu::OWeakObject* >( this ))); |
1079 | |
|
1080 | 0 | DisposeHelper::DisposeAndClear( m_xXAxis ); |
1081 | 0 | DisposeHelper::DisposeAndClear( m_xYAxis ); |
1082 | 0 | DisposeHelper::DisposeAndClear( m_xZAxis ); |
1083 | 0 | DisposeHelper::DisposeAndClear( m_xSecondXAxis ); |
1084 | 0 | DisposeHelper::DisposeAndClear( m_xSecondYAxis ); |
1085 | 0 | DisposeHelper::DisposeAndClear( m_xWall ); |
1086 | 0 | DisposeHelper::DisposeAndClear( m_xFloor ); |
1087 | 0 | DisposeHelper::DisposeAndClear( m_xMinMaxLineWrapper ); |
1088 | 0 | DisposeHelper::DisposeAndClear( m_xUpBarWrapper ); |
1089 | 0 | DisposeHelper::DisposeAndClear( m_xDownBarWrapper ); |
1090 | |
|
1091 | 0 | clearWrappedPropertySet(); |
1092 | 0 | } |
1093 | | |
1094 | | void SAL_CALL DiagramWrapper::addEventListener( |
1095 | | const Reference< lang::XEventListener >& xListener ) |
1096 | 0 | { |
1097 | 0 | std::unique_lock g(m_aMutex); |
1098 | 0 | m_aEventListenerContainer.addInterface( g, xListener ); |
1099 | 0 | } |
1100 | | |
1101 | | void SAL_CALL DiagramWrapper::removeEventListener( |
1102 | | const Reference< lang::XEventListener >& aListener ) |
1103 | 0 | { |
1104 | 0 | std::unique_lock g(m_aMutex); |
1105 | 0 | m_aEventListenerContainer.removeInterface( g, aListener ); |
1106 | 0 | } |
1107 | | |
1108 | | namespace { |
1109 | | |
1110 | | //PROP_DIAGRAM_DATAROW_SOURCE |
1111 | | class WrappedDataRowSourceProperty : public WrappedProperty |
1112 | | { |
1113 | | public: |
1114 | | explicit WrappedDataRowSourceProperty(std::shared_ptr<Chart2ModelContact> spChart2ModelContact); |
1115 | | |
1116 | | virtual void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override; |
1117 | | |
1118 | | virtual css::uno::Any getPropertyValue( const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override; |
1119 | | |
1120 | | virtual css::uno::Any getPropertyDefault( const css::uno::Reference< css::beans::XPropertyState >& xInnerPropertyState ) const override; |
1121 | | |
1122 | | private: //member |
1123 | | std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact; |
1124 | | mutable Any m_aOuterValue; |
1125 | | }; |
1126 | | |
1127 | | } |
1128 | | |
1129 | | WrappedDataRowSourceProperty::WrappedDataRowSourceProperty(std::shared_ptr<Chart2ModelContact> spChart2ModelContact) |
1130 | 0 | : WrappedProperty(u"DataRowSource"_ustr,OUString()) |
1131 | 0 | , m_spChart2ModelContact(std::move( spChart2ModelContact )) |
1132 | 0 | { |
1133 | 0 | m_aOuterValue = WrappedDataRowSourceProperty::getPropertyDefault( nullptr ); |
1134 | 0 | } |
1135 | | |
1136 | | void WrappedDataRowSourceProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const |
1137 | 0 | { |
1138 | 0 | css::chart::ChartDataRowSource eChartDataRowSource = css::chart::ChartDataRowSource_ROWS; |
1139 | 0 | if( ! (rOuterValue >>= eChartDataRowSource) ) |
1140 | 0 | { |
1141 | 0 | sal_Int32 nNew = sal_Int32(css::chart::ChartDataRowSource_ROWS); |
1142 | 0 | if( !(rOuterValue >>= nNew) ) |
1143 | 0 | throw lang::IllegalArgumentException( u"Property DataRowSource requires css::chart::ChartDataRowSource value"_ustr, nullptr, 0 ); |
1144 | 0 | eChartDataRowSource = css::chart::ChartDataRowSource(nNew); |
1145 | 0 | } |
1146 | | |
1147 | 0 | m_aOuterValue = rOuterValue; |
1148 | |
|
1149 | 0 | bool bNewUseColumns = eChartDataRowSource == css::chart::ChartDataRowSource_COLUMNS; |
1150 | |
|
1151 | 0 | OUString aRangeString; |
1152 | 0 | bool bUseColumns = true; |
1153 | 0 | bool bFirstCellAsLabel = true; |
1154 | 0 | bool bHasCategories = true; |
1155 | 0 | uno::Sequence< sal_Int32 > aSequenceMapping; |
1156 | |
|
1157 | 0 | if( DataSourceHelper::detectRangeSegmentation( |
1158 | 0 | m_spChart2ModelContact->getDocumentModel(), aRangeString, aSequenceMapping, bUseColumns |
1159 | 0 | , bFirstCellAsLabel, bHasCategories ) ) |
1160 | 0 | { |
1161 | 0 | if( bUseColumns != bNewUseColumns ) |
1162 | 0 | { |
1163 | 0 | aSequenceMapping.realloc(0); |
1164 | 0 | DataSourceHelper::setRangeSegmentation( |
1165 | 0 | m_spChart2ModelContact->getDocumentModel(), aSequenceMapping, bNewUseColumns , bFirstCellAsLabel , bHasCategories); |
1166 | 0 | } |
1167 | 0 | } |
1168 | 0 | } |
1169 | | |
1170 | | Any WrappedDataRowSourceProperty::getPropertyValue( const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const |
1171 | 0 | { |
1172 | 0 | OUString aRangeString; |
1173 | 0 | bool bUseColumns = true; |
1174 | 0 | bool bFirstCellAsLabel = true; |
1175 | 0 | bool bHasCategories = true; |
1176 | 0 | uno::Sequence< sal_Int32 > aSequenceMapping; |
1177 | |
|
1178 | 0 | if( DataSourceHelper::detectRangeSegmentation( |
1179 | 0 | m_spChart2ModelContact->getDocumentModel(), aRangeString, aSequenceMapping, bUseColumns |
1180 | 0 | , bFirstCellAsLabel, bHasCategories ) ) |
1181 | 0 | { |
1182 | 0 | css::chart::ChartDataRowSource eChartDataRowSource = css::chart::ChartDataRowSource_ROWS; |
1183 | 0 | if(bUseColumns) |
1184 | 0 | eChartDataRowSource = css::chart::ChartDataRowSource_COLUMNS; |
1185 | |
|
1186 | 0 | m_aOuterValue <<= eChartDataRowSource; |
1187 | 0 | } |
1188 | |
|
1189 | 0 | return m_aOuterValue; |
1190 | 0 | } |
1191 | | |
1192 | | Any WrappedDataRowSourceProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const |
1193 | 0 | { |
1194 | 0 | Any aRet; |
1195 | 0 | aRet <<= css::chart::ChartDataRowSource_COLUMNS; |
1196 | 0 | return aRet; |
1197 | 0 | } |
1198 | | |
1199 | | namespace { |
1200 | | |
1201 | | //PROP_DIAGRAM_STACKED |
1202 | | //PROP_DIAGRAM_DEEP |
1203 | | //PROP_DIAGRAM_PERCENT_STACKED |
1204 | | class WrappedStackingProperty : public WrappedProperty |
1205 | | { |
1206 | | public: |
1207 | | WrappedStackingProperty(StackMode eStackMode, std::shared_ptr<Chart2ModelContact> spChart2ModelContact); |
1208 | | |
1209 | | virtual void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override; |
1210 | | |
1211 | | virtual css::uno::Any getPropertyValue( const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override; |
1212 | | |
1213 | | virtual css::uno::Any getPropertyDefault( const css::uno::Reference< css::beans::XPropertyState >& xInnerPropertyState ) const override; |
1214 | | |
1215 | | protected: //methods |
1216 | | bool detectInnerValue( StackMode& eInnerStackMode ) const; |
1217 | | |
1218 | | private: //member |
1219 | | std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact; |
1220 | | const StackMode m_eStackMode; |
1221 | | mutable Any m_aOuterValue; |
1222 | | }; |
1223 | | |
1224 | | } |
1225 | | |
1226 | | WrappedStackingProperty::WrappedStackingProperty(StackMode eStackMode, std::shared_ptr<Chart2ModelContact> spChart2ModelContact) |
1227 | 0 | : WrappedProperty(OUString(),OUString()) |
1228 | 0 | , m_spChart2ModelContact(std::move( spChart2ModelContact )) |
1229 | 0 | , m_eStackMode( eStackMode ) |
1230 | 0 | { |
1231 | 0 | switch( m_eStackMode ) |
1232 | 0 | { |
1233 | 0 | case StackMode::YStacked: |
1234 | 0 | m_aOuterName = "Stacked"; |
1235 | 0 | break; |
1236 | 0 | case StackMode::YStackedPercent: |
1237 | 0 | m_aOuterName = "Percent"; |
1238 | 0 | break; |
1239 | 0 | case StackMode::ZStacked: |
1240 | 0 | m_aOuterName = "Deep"; |
1241 | 0 | break; |
1242 | 0 | default: |
1243 | 0 | OSL_FAIL( "unexpected stack mode" ); |
1244 | 0 | break; |
1245 | 0 | } |
1246 | 0 | } |
1247 | | |
1248 | | bool WrappedStackingProperty::detectInnerValue( StackMode& eStackMode ) const |
1249 | 0 | { |
1250 | 0 | bool bHasDetectableInnerValue = false; |
1251 | 0 | bool bIsAmbiguous = false; |
1252 | 0 | rtl::Reference<Diagram> xDiagram = m_spChart2ModelContact->getDiagram(); |
1253 | 0 | eStackMode = xDiagram ? xDiagram->getStackMode( bHasDetectableInnerValue, bIsAmbiguous ) : StackMode::NONE; |
1254 | 0 | return bHasDetectableInnerValue; |
1255 | 0 | } |
1256 | | |
1257 | | void WrappedStackingProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const |
1258 | 0 | { |
1259 | 0 | bool bNewValue = false; |
1260 | 0 | if( ! (rOuterValue >>= bNewValue) ) |
1261 | 0 | throw lang::IllegalArgumentException( u"Stacking Properties require boolean values"_ustr, nullptr, 0 ); |
1262 | | |
1263 | 0 | StackMode eInnerStackMode; |
1264 | 0 | bool bHasDetectableInnerValue = detectInnerValue( eInnerStackMode ); |
1265 | |
|
1266 | 0 | if( !bHasDetectableInnerValue ) |
1267 | 0 | { |
1268 | 0 | m_aOuterValue = rOuterValue; |
1269 | 0 | return; |
1270 | 0 | } |
1271 | | |
1272 | 0 | if( bNewValue && eInnerStackMode == m_eStackMode ) |
1273 | 0 | return; |
1274 | 0 | if( !bNewValue && eInnerStackMode != m_eStackMode ) |
1275 | 0 | return; |
1276 | | |
1277 | 0 | rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); |
1278 | 0 | if( xDiagram.is() ) |
1279 | 0 | { |
1280 | 0 | StackMode eNewStackMode = bNewValue ? m_eStackMode : StackMode::NONE; |
1281 | 0 | xDiagram->setStackMode( eNewStackMode ); |
1282 | 0 | } |
1283 | 0 | } |
1284 | | |
1285 | | Any WrappedStackingProperty::getPropertyValue( const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const |
1286 | 0 | { |
1287 | 0 | StackMode eInnerStackMode; |
1288 | 0 | if( detectInnerValue( eInnerStackMode ) ) |
1289 | 0 | { |
1290 | 0 | bool bValue = (eInnerStackMode == m_eStackMode); |
1291 | 0 | return Any(bValue); |
1292 | 0 | } |
1293 | 0 | return m_aOuterValue; |
1294 | 0 | } |
1295 | | |
1296 | | Any WrappedStackingProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const |
1297 | 0 | { |
1298 | 0 | Any aRet; |
1299 | 0 | aRet <<= false; |
1300 | 0 | return aRet; |
1301 | 0 | } |
1302 | | |
1303 | | namespace { |
1304 | | |
1305 | | //PROP_DIAGRAM_THREE_D |
1306 | | class WrappedDim3DProperty : public WrappedProperty |
1307 | | { |
1308 | | public: |
1309 | | explicit WrappedDim3DProperty(std::shared_ptr<Chart2ModelContact> spChart2ModelContact); |
1310 | | |
1311 | | virtual void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override; |
1312 | | |
1313 | | virtual css::uno::Any getPropertyValue( const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override; |
1314 | | |
1315 | | virtual css::uno::Any getPropertyDefault( const css::uno::Reference< css::beans::XPropertyState >& xInnerPropertyState ) const override; |
1316 | | |
1317 | | private: //member |
1318 | | std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact; |
1319 | | mutable Any m_aOuterValue; |
1320 | | }; |
1321 | | |
1322 | | } |
1323 | | |
1324 | | WrappedDim3DProperty::WrappedDim3DProperty(std::shared_ptr<Chart2ModelContact> spChart2ModelContact) |
1325 | 0 | : WrappedProperty(u"Dim3D"_ustr,OUString()) |
1326 | 0 | , m_spChart2ModelContact(std::move( spChart2ModelContact )) |
1327 | 0 | { |
1328 | 0 | m_aOuterValue = WrappedDim3DProperty::getPropertyDefault( nullptr ); |
1329 | 0 | } |
1330 | | |
1331 | | void WrappedDim3DProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const |
1332 | 0 | { |
1333 | 0 | bool bNew3D = false; |
1334 | 0 | if( ! (rOuterValue >>= bNew3D) ) |
1335 | 0 | throw lang::IllegalArgumentException( u"Property Dim3D requires boolean value"_ustr, nullptr, 0 ); |
1336 | | |
1337 | 0 | m_aOuterValue = rOuterValue; |
1338 | |
|
1339 | 0 | rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); |
1340 | 0 | if( !xDiagram.is() ) |
1341 | 0 | return; |
1342 | | |
1343 | 0 | bool bOld3D = xDiagram->getDimension() == 3; |
1344 | 0 | if( bOld3D != bNew3D ) |
1345 | 0 | xDiagram->setDimension( bNew3D ? 3 : 2 ); |
1346 | 0 | } |
1347 | | |
1348 | | Any WrappedDim3DProperty::getPropertyValue( const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const |
1349 | 0 | { |
1350 | 0 | rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); |
1351 | 0 | if( xDiagram.is() ) |
1352 | 0 | { |
1353 | 0 | bool b3D = xDiagram->getDimension() == 3; |
1354 | 0 | m_aOuterValue <<= b3D; |
1355 | 0 | } |
1356 | 0 | return m_aOuterValue; |
1357 | 0 | } |
1358 | | |
1359 | | Any WrappedDim3DProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const |
1360 | 0 | { |
1361 | 0 | Any aRet; |
1362 | 0 | aRet <<= false; |
1363 | 0 | return aRet; |
1364 | 0 | } |
1365 | | |
1366 | | namespace { |
1367 | | |
1368 | | //PROP_DIAGRAM_VERTICAL |
1369 | | class WrappedVerticalProperty : public WrappedProperty |
1370 | | { |
1371 | | public: |
1372 | | explicit WrappedVerticalProperty(std::shared_ptr<Chart2ModelContact> spChart2ModelContact); |
1373 | | |
1374 | | virtual void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override; |
1375 | | |
1376 | | virtual css::uno::Any getPropertyValue( const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override; |
1377 | | |
1378 | | virtual css::uno::Any getPropertyDefault( const css::uno::Reference< css::beans::XPropertyState >& xInnerPropertyState ) const override; |
1379 | | |
1380 | | private: //member |
1381 | | std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact; |
1382 | | mutable Any m_aOuterValue; |
1383 | | }; |
1384 | | |
1385 | | } |
1386 | | |
1387 | | WrappedVerticalProperty::WrappedVerticalProperty(std::shared_ptr<Chart2ModelContact> spChart2ModelContact) |
1388 | 0 | : WrappedProperty(u"Vertical"_ustr,OUString()) |
1389 | 0 | , m_spChart2ModelContact(std::move( spChart2ModelContact )) |
1390 | 0 | { |
1391 | 0 | m_aOuterValue = WrappedVerticalProperty::getPropertyDefault( nullptr ); |
1392 | 0 | } |
1393 | | |
1394 | | void WrappedVerticalProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const |
1395 | 0 | { |
1396 | 0 | bool bNewVertical = false; |
1397 | 0 | if( ! (rOuterValue >>= bNewVertical) ) |
1398 | 0 | throw lang::IllegalArgumentException( u"Property Vertical requires boolean value"_ustr, nullptr, 0 ); |
1399 | | |
1400 | 0 | m_aOuterValue = rOuterValue; |
1401 | |
|
1402 | 0 | rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); |
1403 | 0 | if( !xDiagram.is() ) |
1404 | 0 | return; |
1405 | | |
1406 | 0 | bool bFound = false; |
1407 | 0 | bool bAmbiguous = false; |
1408 | 0 | bool bOldVertical = xDiagram->getVertical( bFound, bAmbiguous ); |
1409 | 0 | if( bFound && ( bOldVertical != bNewVertical || bAmbiguous ) ) |
1410 | 0 | xDiagram->setVertical( bNewVertical ); |
1411 | 0 | } |
1412 | | |
1413 | | Any WrappedVerticalProperty::getPropertyValue( const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const |
1414 | 0 | { |
1415 | 0 | rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); |
1416 | 0 | if( xDiagram.is() ) |
1417 | 0 | { |
1418 | 0 | bool bFound = false; |
1419 | 0 | bool bAmbiguous = false; |
1420 | 0 | bool bVertical = xDiagram->getVertical( bFound, bAmbiguous ); |
1421 | 0 | if( bFound ) |
1422 | 0 | m_aOuterValue <<= bVertical; |
1423 | 0 | } |
1424 | 0 | return m_aOuterValue; |
1425 | 0 | } |
1426 | | |
1427 | | Any WrappedVerticalProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const |
1428 | 0 | { |
1429 | 0 | Any aRet; |
1430 | 0 | aRet <<= false; |
1431 | 0 | return aRet; |
1432 | 0 | } |
1433 | | |
1434 | | namespace { |
1435 | | |
1436 | | //PROP_DIAGRAM_NUMBER_OF_LINES |
1437 | | class WrappedNumberOfLinesProperty : public WrappedProperty |
1438 | | { |
1439 | | public: |
1440 | | explicit WrappedNumberOfLinesProperty(std::shared_ptr<Chart2ModelContact> spChart2ModelContact); |
1441 | | |
1442 | | virtual void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override; |
1443 | | |
1444 | | virtual css::uno::Any getPropertyValue( const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override; |
1445 | | |
1446 | | virtual css::uno::Any getPropertyDefault( const css::uno::Reference< css::beans::XPropertyState >& xInnerPropertyState ) const override; |
1447 | | |
1448 | | protected: //methods |
1449 | | bool detectInnerValue( uno::Any& rInnerValue ) const; |
1450 | | |
1451 | | private: //member |
1452 | | std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact; |
1453 | | mutable Any m_aOuterValue; |
1454 | | }; |
1455 | | |
1456 | | } |
1457 | | |
1458 | | WrappedNumberOfLinesProperty::WrappedNumberOfLinesProperty(std::shared_ptr<Chart2ModelContact> spChart2ModelContact) |
1459 | 0 | : WrappedProperty(u"NumberOfLines"_ustr,OUString()) |
1460 | 0 | , m_spChart2ModelContact(std::move( spChart2ModelContact )) |
1461 | 0 | , m_aOuterValue( getPropertyDefault(nullptr) ) |
1462 | 0 | { |
1463 | 0 | } |
1464 | | |
1465 | | bool WrappedNumberOfLinesProperty::detectInnerValue( uno::Any& rInnerValue ) const |
1466 | 0 | { |
1467 | 0 | sal_Int32 nNumberOfLines = 0; |
1468 | 0 | bool bHasDetectableInnerValue = false; |
1469 | 0 | rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); |
1470 | 0 | rtl::Reference< ChartModel > xChartDoc( m_spChart2ModelContact->getDocumentModel() ); |
1471 | 0 | if( xDiagram.is() && xChartDoc.is() ) |
1472 | 0 | { |
1473 | 0 | std::vector< rtl::Reference< DataSeries > > aSeriesVector = |
1474 | 0 | xDiagram->getDataSeries(); |
1475 | 0 | if( !aSeriesVector.empty() ) |
1476 | 0 | { |
1477 | 0 | rtl::Reference< ::chart::ChartTypeManager > xChartTypeManager = xChartDoc->getTypeManager(); |
1478 | 0 | Diagram::tTemplateWithServiceName aTemplateAndService = |
1479 | 0 | xDiagram->getTemplate( xChartTypeManager ); |
1480 | 0 | if( aTemplateAndService.sServiceName == "com.sun.star.chart2.template.ColumnWithLine" ) |
1481 | 0 | { |
1482 | 0 | try |
1483 | 0 | { |
1484 | 0 | uno::Reference< beans::XPropertySet > xProp( static_cast<cppu::OWeakObject*>(aTemplateAndService.xChartTypeTemplate.get()), uno::UNO_QUERY ); |
1485 | 0 | xProp->getPropertyValue( m_aOuterName ) >>= nNumberOfLines; |
1486 | 0 | bHasDetectableInnerValue = true; |
1487 | 0 | } |
1488 | 0 | catch( const uno::Exception & ) |
1489 | 0 | { |
1490 | 0 | DBG_UNHANDLED_EXCEPTION("chart2"); |
1491 | 0 | } |
1492 | 0 | } |
1493 | 0 | } |
1494 | 0 | } |
1495 | 0 | if(bHasDetectableInnerValue) |
1496 | 0 | rInnerValue <<= nNumberOfLines; |
1497 | 0 | return bHasDetectableInnerValue; |
1498 | 0 | } |
1499 | | |
1500 | | void WrappedNumberOfLinesProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const |
1501 | 0 | { |
1502 | 0 | sal_Int32 nNewValue; |
1503 | 0 | if( ! (rOuterValue >>= nNewValue) ) |
1504 | 0 | throw lang::IllegalArgumentException( u"property NumberOfLines requires sal_Int32 value"_ustr, nullptr, 0 ); |
1505 | | |
1506 | 0 | m_aOuterValue = rOuterValue; |
1507 | |
|
1508 | 0 | rtl::Reference< ChartModel > xChartDoc( m_spChart2ModelContact->getDocumentModel() ); |
1509 | 0 | rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); |
1510 | 0 | if( !xChartDoc || !xDiagram ) |
1511 | 0 | return; |
1512 | 0 | sal_Int32 nDimension = xDiagram->getDimension(); |
1513 | 0 | if( nDimension != 2 ) |
1514 | 0 | return; |
1515 | | |
1516 | 0 | rtl::Reference< ::chart::ChartTypeManager > xChartTypeManager = xChartDoc->getTypeManager(); |
1517 | 0 | Diagram::tTemplateWithServiceName aTemplateAndService = |
1518 | 0 | xDiagram->getTemplate( xChartTypeManager ); |
1519 | |
|
1520 | 0 | rtl::Reference< ChartTypeTemplate > xTemplate; |
1521 | 0 | if( aTemplateAndService.sServiceName == "com.sun.star.chart2.template.ColumnWithLine" ) |
1522 | 0 | { |
1523 | 0 | if( nNewValue != 0 ) |
1524 | 0 | { |
1525 | 0 | xTemplate = aTemplateAndService.xChartTypeTemplate; |
1526 | 0 | try |
1527 | 0 | { |
1528 | 0 | sal_Int32 nOldValue = 0; |
1529 | 0 | uno::Reference< beans::XPropertySet > xProp( static_cast<cppu::OWeakObject*>(xTemplate.get()), uno::UNO_QUERY ); |
1530 | 0 | xProp->getPropertyValue( m_aOuterName ) >>= nOldValue; |
1531 | 0 | if( nOldValue == nNewValue ) |
1532 | 0 | return; |
1533 | 0 | } |
1534 | 0 | catch( const uno::Exception & ) |
1535 | 0 | { |
1536 | 0 | DBG_UNHANDLED_EXCEPTION("chart2"); |
1537 | 0 | } |
1538 | 0 | } |
1539 | 0 | else |
1540 | 0 | { |
1541 | 0 | xTemplate = xChartTypeManager->createTemplate(u"com.sun.star.chart2.template.Column"_ustr); |
1542 | 0 | } |
1543 | 0 | } |
1544 | 0 | else if( aTemplateAndService.sServiceName == "com.sun.star.chart2.template.Column" ) |
1545 | 0 | { |
1546 | 0 | if( nNewValue == 0 ) |
1547 | 0 | return; |
1548 | 0 | xTemplate = xChartTypeManager->createTemplate( u"com.sun.star.chart2.template.ColumnWithLine"_ustr ); |
1549 | 0 | } |
1550 | | |
1551 | 0 | if(!xTemplate.is()) |
1552 | 0 | return; |
1553 | | |
1554 | 0 | try |
1555 | 0 | { |
1556 | | // locked controllers |
1557 | 0 | ControllerLockGuardUNO aCtrlLockGuard( m_spChart2ModelContact->getDocumentModel() ); |
1558 | 0 | uno::Reference< beans::XPropertySet > xProp( static_cast<cppu::OWeakObject*>(xTemplate.get()), uno::UNO_QUERY ); |
1559 | 0 | xProp->setPropertyValue( u"NumberOfLines"_ustr, uno::Any(nNewValue) ); |
1560 | 0 | xTemplate->changeDiagram( xDiagram ); |
1561 | 0 | } |
1562 | 0 | catch( const uno::Exception & ) |
1563 | 0 | { |
1564 | 0 | DBG_UNHANDLED_EXCEPTION("chart2"); |
1565 | 0 | } |
1566 | 0 | } |
1567 | | |
1568 | | Any WrappedNumberOfLinesProperty::getPropertyValue( const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const |
1569 | 0 | { |
1570 | 0 | Any aRet; |
1571 | 0 | if( !detectInnerValue( aRet ) ) |
1572 | 0 | aRet = m_aOuterValue; |
1573 | 0 | return aRet; |
1574 | 0 | } |
1575 | | |
1576 | | Any WrappedNumberOfLinesProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const |
1577 | 0 | { |
1578 | 0 | Any aRet; |
1579 | 0 | aRet <<= sal_Int32( 0 ); |
1580 | 0 | return aRet; |
1581 | 0 | } |
1582 | | |
1583 | | namespace { |
1584 | | |
1585 | | //PROP_DIAGRAM_ATTRIBUTED_DATA_POINTS |
1586 | | class WrappedAttributedDataPointsProperty : public WrappedProperty |
1587 | | { |
1588 | | public: |
1589 | | explicit WrappedAttributedDataPointsProperty(std::shared_ptr<Chart2ModelContact> spChart2ModelContact); |
1590 | | |
1591 | | virtual void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override; |
1592 | | |
1593 | | virtual css::uno::Any getPropertyValue( const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override; |
1594 | | |
1595 | | virtual css::uno::Any getPropertyDefault( const css::uno::Reference< css::beans::XPropertyState >& xInnerPropertyState ) const override; |
1596 | | |
1597 | | private: //member |
1598 | | std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact; |
1599 | | mutable Any m_aOuterValue; |
1600 | | }; |
1601 | | |
1602 | | } |
1603 | | |
1604 | | WrappedAttributedDataPointsProperty::WrappedAttributedDataPointsProperty(std::shared_ptr<Chart2ModelContact> spChart2ModelContact) |
1605 | 0 | : WrappedProperty(u"AttributedDataPoints"_ustr,OUString()) |
1606 | 0 | , m_spChart2ModelContact(std::move( spChart2ModelContact )) |
1607 | 0 | { |
1608 | 0 | m_aOuterValue = WrappedAttributedDataPointsProperty::getPropertyDefault( nullptr ); |
1609 | 0 | } |
1610 | | |
1611 | | void WrappedAttributedDataPointsProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const |
1612 | 0 | { |
1613 | 0 | uno::Sequence< uno::Sequence< sal_Int32 > > aNewValue; |
1614 | 0 | if( ! (rOuterValue >>= aNewValue) ) |
1615 | 0 | throw lang::IllegalArgumentException( u"Property AttributedDataPoints requires value of type uno::Sequence< uno::Sequence< sal_Int32 > >"_ustr, nullptr, 0 ); |
1616 | | |
1617 | 0 | m_aOuterValue = rOuterValue; |
1618 | |
|
1619 | 0 | rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); |
1620 | |
|
1621 | 0 | if( !xDiagram ) |
1622 | 0 | return; |
1623 | | |
1624 | 0 | std::vector< rtl::Reference< DataSeries > > aSeriesVector = |
1625 | 0 | xDiagram->getDataSeries(); |
1626 | 0 | sal_Int32 i = 0; |
1627 | 0 | for (auto const& series : aSeriesVector) |
1628 | 0 | { |
1629 | 0 | uno::Any aVal; |
1630 | 0 | if( i < aNewValue.getLength() ) |
1631 | 0 | aVal <<= aNewValue[i]; |
1632 | 0 | else |
1633 | 0 | { |
1634 | | //set empty sequence |
1635 | 0 | uno::Sequence< sal_Int32 > aSeq; |
1636 | 0 | aVal <<= aSeq; |
1637 | 0 | } |
1638 | 0 | series->setFastPropertyValue( PROP_DATASERIES_ATTRIBUTED_DATA_POINTS, aVal ); // "AttributedDataPoints" |
1639 | 0 | ++i; |
1640 | 0 | } |
1641 | 0 | } |
1642 | | |
1643 | | Any WrappedAttributedDataPointsProperty::getPropertyValue( const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const |
1644 | 0 | { |
1645 | 0 | rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); |
1646 | |
|
1647 | 0 | if( xDiagram ) |
1648 | 0 | { |
1649 | 0 | std::vector< rtl::Reference< DataSeries > > aSeriesVector = |
1650 | 0 | xDiagram->getDataSeries(); |
1651 | |
|
1652 | 0 | uno::Sequence< uno::Sequence< sal_Int32 > > aResult( aSeriesVector.size() ); |
1653 | 0 | auto aResultRange = asNonConstRange(aResult); |
1654 | 0 | sal_Int32 i = 0; |
1655 | 0 | for (auto const& series : aSeriesVector) |
1656 | 0 | { |
1657 | 0 | uno::Any aVal( |
1658 | 0 | series->getFastPropertyValue(PROP_DATASERIES_ATTRIBUTED_DATA_POINTS)); // "AttributedDataPoints" |
1659 | 0 | uno::Sequence< sal_Int32 > aSeq; |
1660 | 0 | if( aVal >>= aSeq ) |
1661 | 0 | aResultRange[ i ] = std::move(aSeq); |
1662 | 0 | ++i; |
1663 | 0 | } |
1664 | 0 | m_aOuterValue <<= aResult; |
1665 | 0 | } |
1666 | 0 | return m_aOuterValue; |
1667 | 0 | } |
1668 | | |
1669 | | Any WrappedAttributedDataPointsProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const |
1670 | 0 | { |
1671 | 0 | Any aRet; |
1672 | 0 | uno::Sequence< uno::Sequence< sal_Int32 > > aSeq; |
1673 | 0 | aRet <<= aSeq; |
1674 | 0 | return aRet; |
1675 | 0 | } |
1676 | | |
1677 | | namespace { |
1678 | | |
1679 | | //PROP_DIAGRAM_SOLIDTYPE |
1680 | | class WrappedSolidTypeProperty : public WrappedProperty |
1681 | | { |
1682 | | public: |
1683 | | explicit WrappedSolidTypeProperty(std::shared_ptr<Chart2ModelContact> spChart2ModelContact); |
1684 | | |
1685 | | virtual void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override; |
1686 | | |
1687 | | virtual css::uno::Any getPropertyValue( const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override; |
1688 | | |
1689 | | virtual css::uno::Any getPropertyDefault( const css::uno::Reference< css::beans::XPropertyState >& xInnerPropertyState ) const override; |
1690 | | |
1691 | | private: //member |
1692 | | std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact; |
1693 | | mutable Any m_aOuterValue; |
1694 | | }; |
1695 | | |
1696 | | } |
1697 | | |
1698 | | WrappedSolidTypeProperty::WrappedSolidTypeProperty(std::shared_ptr<Chart2ModelContact> spChart2ModelContact) |
1699 | 0 | : WrappedProperty( u"SolidType"_ustr, OUString() ) |
1700 | 0 | , m_spChart2ModelContact(std::move( spChart2ModelContact )) |
1701 | 0 | { |
1702 | 0 | m_aOuterValue = WrappedSolidTypeProperty::getPropertyDefault( nullptr ); |
1703 | 0 | } |
1704 | | |
1705 | | void WrappedSolidTypeProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const |
1706 | 0 | { |
1707 | 0 | sal_Int32 nNewSolidType = css::chart::ChartSolidType::RECTANGULAR_SOLID; |
1708 | 0 | if( ! (rOuterValue >>= nNewSolidType) ) |
1709 | 0 | throw lang::IllegalArgumentException( u"Property SolidType requires integer value"_ustr, nullptr, 0 ); |
1710 | | |
1711 | 0 | m_aOuterValue = rOuterValue; |
1712 | |
|
1713 | 0 | rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); |
1714 | 0 | if( !xDiagram.is() ) |
1715 | 0 | return; |
1716 | | |
1717 | 0 | bool bFound = false; |
1718 | 0 | bool bAmbiguous = false; |
1719 | 0 | sal_Int32 nOldSolidType = xDiagram->getGeometry3D( bFound, bAmbiguous ); |
1720 | 0 | if( bFound && ( nOldSolidType != nNewSolidType || bAmbiguous ) ) |
1721 | 0 | xDiagram->setGeometry3D( nNewSolidType ); |
1722 | 0 | } |
1723 | | |
1724 | | Any WrappedSolidTypeProperty::getPropertyValue( const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const |
1725 | 0 | { |
1726 | 0 | rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); |
1727 | 0 | if( xDiagram.is() ) |
1728 | 0 | { |
1729 | 0 | bool bFound = false; |
1730 | 0 | bool bAmbiguous = false; |
1731 | 0 | sal_Int32 nGeometry = xDiagram->getGeometry3D( bFound, bAmbiguous ); |
1732 | 0 | if( bFound ) |
1733 | 0 | m_aOuterValue <<= nGeometry; |
1734 | 0 | } |
1735 | 0 | return m_aOuterValue; |
1736 | 0 | } |
1737 | | |
1738 | | Any WrappedSolidTypeProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const |
1739 | 0 | { |
1740 | 0 | return uno::Any( css::chart::ChartSolidType::RECTANGULAR_SOLID ); |
1741 | 0 | } |
1742 | | |
1743 | | namespace { |
1744 | | |
1745 | | class WrappedAutomaticSizeProperty : public WrappedProperty |
1746 | | { |
1747 | | public: |
1748 | | WrappedAutomaticSizeProperty(); |
1749 | | |
1750 | | virtual void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override; |
1751 | | |
1752 | | virtual css::uno::Any getPropertyValue( const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override; |
1753 | | |
1754 | | virtual css::uno::Any getPropertyDefault( const css::uno::Reference< css::beans::XPropertyState >& xInnerPropertyState ) const override; |
1755 | | }; |
1756 | | |
1757 | | } |
1758 | | |
1759 | | WrappedAutomaticSizeProperty::WrappedAutomaticSizeProperty() |
1760 | 0 | : WrappedProperty( u"AutomaticSize"_ustr, OUString() ) |
1761 | 0 | { |
1762 | 0 | } |
1763 | | |
1764 | | void WrappedAutomaticSizeProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const |
1765 | 0 | { |
1766 | 0 | if( !xInnerPropertySet.is() ) |
1767 | 0 | return; |
1768 | | |
1769 | 0 | bool bNewValue = true; |
1770 | 0 | if( ! (rOuterValue >>= bNewValue) ) |
1771 | 0 | throw lang::IllegalArgumentException( u"Property AutomaticSize requires value of type boolean"_ustr, nullptr, 0 ); |
1772 | | |
1773 | 0 | try |
1774 | 0 | { |
1775 | 0 | if( bNewValue ) |
1776 | 0 | { |
1777 | 0 | Any aRelativeSize( xInnerPropertySet->getPropertyValue( u"RelativeSize"_ustr ) ); |
1778 | 0 | if( aRelativeSize.hasValue() ) |
1779 | 0 | xInnerPropertySet->setPropertyValue( u"RelativeSize"_ustr, Any() ); |
1780 | 0 | } |
1781 | 0 | } |
1782 | 0 | catch( const uno::Exception & ) |
1783 | 0 | { |
1784 | 0 | DBG_UNHANDLED_EXCEPTION("chart2"); |
1785 | 0 | } |
1786 | 0 | } |
1787 | | |
1788 | | Any WrappedAutomaticSizeProperty::getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const |
1789 | 0 | { |
1790 | 0 | Any aRet( getPropertyDefault( Reference< beans::XPropertyState >( xInnerPropertySet, uno::UNO_QUERY ) ) ); |
1791 | 0 | if( xInnerPropertySet.is() ) |
1792 | 0 | { |
1793 | 0 | Any aRelativeSize( xInnerPropertySet->getPropertyValue( u"RelativeSize"_ustr ) ); |
1794 | 0 | if( !aRelativeSize.hasValue() ) |
1795 | 0 | aRet <<= true; |
1796 | 0 | } |
1797 | 0 | return aRet; |
1798 | 0 | } |
1799 | | |
1800 | | Any WrappedAutomaticSizeProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const |
1801 | 0 | { |
1802 | 0 | Any aRet; |
1803 | 0 | aRet <<= false; |
1804 | 0 | return aRet; |
1805 | 0 | } |
1806 | | |
1807 | | namespace { |
1808 | | |
1809 | | //PROP_DIAGRAM_INCLUDE_HIDDEN_CELLS |
1810 | | class WrappedIncludeHiddenCellsProperty : public WrappedProperty |
1811 | | { |
1812 | | public: |
1813 | | explicit WrappedIncludeHiddenCellsProperty(std::shared_ptr<Chart2ModelContact> spChart2ModelContact); |
1814 | | |
1815 | | virtual void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override; |
1816 | | virtual Any getPropertyValue(const Reference<beans::XPropertySet>& xInnerPropertySet) const override; |
1817 | | |
1818 | | private: //member |
1819 | | std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact; |
1820 | | }; |
1821 | | |
1822 | | } |
1823 | | |
1824 | | WrappedIncludeHiddenCellsProperty::WrappedIncludeHiddenCellsProperty(std::shared_ptr<Chart2ModelContact> spChart2ModelContact) |
1825 | 0 | : WrappedProperty(u"IncludeHiddenCells"_ustr,u"IncludeHiddenCells"_ustr) |
1826 | 0 | , m_spChart2ModelContact(std::move( spChart2ModelContact )) |
1827 | 0 | { |
1828 | 0 | } |
1829 | | |
1830 | | void WrappedIncludeHiddenCellsProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const |
1831 | 0 | { |
1832 | 0 | bool bNewValue = false; |
1833 | 0 | if( ! (rOuterValue >>= bNewValue) ) |
1834 | 0 | throw lang::IllegalArgumentException( u"Property IncludeHiddenCells requires boolean value"_ustr, nullptr, 0 ); |
1835 | | |
1836 | 0 | m_spChart2ModelContact->getDocumentModel()->setIncludeHiddenCells(bNewValue); |
1837 | 0 | } |
1838 | | |
1839 | | Any WrappedIncludeHiddenCellsProperty::getPropertyValue( const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const |
1840 | 0 | { |
1841 | 0 | bool bValue = m_spChart2ModelContact->getDocumentModel()->isIncludeHiddenCells(); |
1842 | 0 | return uno::Any(bValue); |
1843 | 0 | } |
1844 | | |
1845 | | // ____ XDiagramProvider ____ |
1846 | | Reference< chart2::XDiagram > SAL_CALL DiagramWrapper::getDiagram() |
1847 | 0 | { |
1848 | 0 | return m_spChart2ModelContact->getDiagram(); |
1849 | 0 | } |
1850 | | |
1851 | | rtl::Reference< ::chart::Diagram > DiagramWrapper::getUnderlyingDiagram() |
1852 | 0 | { |
1853 | 0 | return m_spChart2ModelContact->getDiagram(); |
1854 | 0 | } |
1855 | | |
1856 | | void SAL_CALL DiagramWrapper::setDiagram( |
1857 | | const Reference< chart2::XDiagram >& /*xDiagram*/ ) |
1858 | 0 | { |
1859 | | //@todo: remove this method from interface |
1860 | 0 | OSL_FAIL("DiagramWrapper::setDiagram is not implemented, should be removed and not be called" ); |
1861 | 0 | } |
1862 | | |
1863 | | Reference< beans::XPropertySet > DiagramWrapper::getInnerPropertySet() |
1864 | 0 | { |
1865 | 0 | return m_spChart2ModelContact->getDiagram(); |
1866 | 0 | } |
1867 | | |
1868 | | const Sequence< beans::Property >& DiagramWrapper::getPropertySequence() |
1869 | 0 | { |
1870 | 0 | return StaticDiagramWrapperPropertyArray(); |
1871 | 0 | } |
1872 | | |
1873 | | std::vector< std::unique_ptr<WrappedProperty> > DiagramWrapper::createWrappedProperties() |
1874 | 0 | { |
1875 | 0 | std::vector< std::unique_ptr<WrappedProperty> > aWrappedProperties; |
1876 | |
|
1877 | 0 | WrappedAxisAndGridExistenceProperties::addWrappedProperties( aWrappedProperties, m_spChart2ModelContact ); |
1878 | 0 | WrappedAxisTitleExistenceProperties::addWrappedProperties( aWrappedProperties, m_spChart2ModelContact ); |
1879 | 0 | WrappedAxisLabelExistenceProperties::addWrappedProperties( aWrappedProperties, m_spChart2ModelContact ); |
1880 | 0 | WrappedSceneProperty::addWrappedProperties( aWrappedProperties, m_spChart2ModelContact ); |
1881 | 0 | WrappedIgnoreProperties::addIgnoreFillProperties( aWrappedProperties ); |
1882 | 0 | WrappedIgnoreProperties::addIgnoreLineProperties( aWrappedProperties ); |
1883 | 0 | WrappedStatisticProperties::addWrappedPropertiesForDiagram( aWrappedProperties, m_spChart2ModelContact ); |
1884 | 0 | WrappedSymbolProperties::addWrappedPropertiesForDiagram( aWrappedProperties, m_spChart2ModelContact ); |
1885 | 0 | WrappedDataCaptionProperties::addWrappedPropertiesForDiagram( aWrappedProperties, m_spChart2ModelContact ); |
1886 | 0 | WrappedSplineProperties::addWrappedProperties( aWrappedProperties, m_spChart2ModelContact ); |
1887 | 0 | WrappedStockProperties::addWrappedProperties( aWrappedProperties, m_spChart2ModelContact ); |
1888 | 0 | WrappedAutomaticPositionProperties::addWrappedProperties( aWrappedProperties ); |
1889 | |
|
1890 | 0 | aWrappedProperties.emplace_back( new WrappedDataRowSourceProperty( m_spChart2ModelContact ) ); |
1891 | 0 | aWrappedProperties.emplace_back( new WrappedStackingProperty( StackMode::YStacked,m_spChart2ModelContact ) ); |
1892 | 0 | aWrappedProperties.emplace_back( new WrappedStackingProperty( StackMode::YStackedPercent, m_spChart2ModelContact ) ); |
1893 | 0 | aWrappedProperties.emplace_back( new WrappedStackingProperty( StackMode::ZStacked, m_spChart2ModelContact ) ); |
1894 | 0 | aWrappedProperties.emplace_back( new WrappedDim3DProperty( m_spChart2ModelContact ) ); |
1895 | 0 | aWrappedProperties.emplace_back( new WrappedVerticalProperty( m_spChart2ModelContact ) ); |
1896 | 0 | aWrappedProperties.emplace_back( new WrappedNumberOfLinesProperty( m_spChart2ModelContact ) ); |
1897 | 0 | aWrappedProperties.emplace_back( new WrappedAttributedDataPointsProperty( m_spChart2ModelContact ) ); |
1898 | 0 | aWrappedProperties.emplace_back( new WrappedProperty( u"StackedBarsConnected"_ustr, u"ConnectBars"_ustr ) ); |
1899 | 0 | aWrappedProperties.emplace_back( new WrappedSolidTypeProperty( m_spChart2ModelContact ) ); |
1900 | 0 | aWrappedProperties.emplace_back( new WrappedAutomaticSizeProperty() ); |
1901 | 0 | aWrappedProperties.emplace_back( new WrappedIncludeHiddenCellsProperty( m_spChart2ModelContact ) ); |
1902 | |
|
1903 | 0 | return aWrappedProperties; |
1904 | 0 | } |
1905 | | |
1906 | | OUString SAL_CALL DiagramWrapper::getImplementationName() |
1907 | 0 | { |
1908 | 0 | return u"com.sun.star.comp.chart.Diagram"_ustr; |
1909 | 0 | } |
1910 | | |
1911 | | sal_Bool SAL_CALL DiagramWrapper::supportsService( const OUString& rServiceName ) |
1912 | 0 | { |
1913 | 0 | return cppu::supportsService(this, rServiceName); |
1914 | 0 | } |
1915 | | |
1916 | | css::uno::Sequence< OUString > SAL_CALL DiagramWrapper::getSupportedServiceNames() |
1917 | 0 | { |
1918 | 0 | return { |
1919 | 0 | u"com.sun.star.chart.Diagram"_ustr, |
1920 | 0 | u"com.sun.star.xml.UserDefinedAttributesSupplier"_ustr, |
1921 | 0 | u"com.sun.star.chart.StackableDiagram"_ustr, |
1922 | 0 | u"com.sun.star.chart.ChartAxisXSupplier"_ustr, |
1923 | 0 | u"com.sun.star.chart.ChartAxisYSupplier"_ustr, |
1924 | 0 | u"com.sun.star.chart.ChartAxisZSupplier"_ustr, |
1925 | 0 | u"com.sun.star.chart.ChartTwoAxisXSupplier"_ustr, |
1926 | 0 | u"com.sun.star.chart.ChartTwoAxisYSupplier"_ustr |
1927 | 0 | }; |
1928 | 0 | } |
1929 | | |
1930 | | } // namespace chart |
1931 | | |
1932 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |