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