1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "DiagramWrapper.hxx"
21 #include <servicenames_charttypes.hxx>
22 #include "DataSeriesPointWrapper.hxx"
23 #include "AxisWrapper.hxx"
24 #include "Chart2ModelContact.hxx"
25 #include "WallFloorWrapper.hxx"
26 #include "MinMaxLineWrapper.hxx"
27 #include "UpDownBarWrapper.hxx"
28 #include <DiagramHelper.hxx>
29 #include <DataSourceHelper.hxx>
30 #include <ChartModelHelper.hxx>
31 #include <WrappedIgnoreProperty.hxx>
32 #include "WrappedAxisAndGridExistenceProperties.hxx"
33 #include "WrappedStatisticProperties.hxx"
34 #include "WrappedSymbolProperties.hxx"
35 #include "WrappedDataCaptionProperties.hxx"
36 #include "WrappedSplineProperties.hxx"
37 #include "WrappedStockProperties.hxx"
38 #include "WrappedSceneProperty.hxx"
39 #include <ControllerLockGuard.hxx>
40 #include <DisposeHelper.hxx>
41 #include "WrappedAutomaticPositionProperties.hxx"
42 #include <CommonConverters.hxx>
43 #include <unonames.hxx>
44 #include <comphelper/sequence.hxx>
45 #include <cppuhelper/supportsservice.hxx>
47 #include <com/sun/star/beans/PropertyAttribute.hpp>
48 #include <com/sun/star/chart/ChartDataRowSource.hpp>
49 #include <com/sun/star/chart2/RelativeSize.hpp>
50 #include <com/sun/star/chart2/RelativePosition.hpp>
51 #include <com/sun/star/chart2/XChartDocument.hpp>
52 #include <com/sun/star/chart/ChartSolidType.hpp>
53 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
54 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
56 #include <LinePropertiesHelper.hxx>
57 #include <FillProperties.hxx>
58 #include <UserDefinedProperties.hxx>
59 #include <SceneProperties.hxx>
63 #include <com/sun/star/lang/XServiceName.hpp>
64 #include <com/sun/star/util/XRefreshable.hpp>
65 #include <tools/diagnose_ex.h>
67 using namespace ::com::sun::star
;
68 using namespace ::chart::wrapper
;
70 using ::com::sun::star::uno::Reference
;
71 using ::com::sun::star::uno::Any
;
72 using ::com::sun::star::uno::Sequence
;
73 using ::com::sun::star::beans::Property
;
74 using ::com::sun::star::chart::XAxis
;
75 using ::osl::MutexGuard
;
82 PROP_DIAGRAM_ATTRIBUTED_DATA_POINTS
,
83 PROP_DIAGRAM_PERCENT_STACKED
,
86 PROP_DIAGRAM_SOLIDTYPE
,
88 PROP_DIAGRAM_VERTICAL
,
89 PROP_DIAGRAM_NUMBER_OF_LINES
,
90 PROP_DIAGRAM_STACKED_BARS_CONNECTED
,
91 PROP_DIAGRAM_DATAROW_SOURCE
,
93 PROP_DIAGRAM_GROUP_BARS_PER_AXIS
,
94 PROP_DIAGRAM_INCLUDE_HIDDEN_CELLS
,
96 PROP_DIAGRAM_SORT_BY_X_VALUES
,
98 PROP_DIAGRAM_STARTING_ANGLE
,
100 PROP_DIAGRAM_RIGHT_ANGLED_AXES
,
101 PROP_DIAGRAM_PERSPECTIVE
,
102 PROP_DIAGRAM_ROTATION_HORIZONTAL
,
103 PROP_DIAGRAM_ROTATION_VERTICAL
,
105 PROP_DIAGRAM_MISSING_VALUE_TREATMENT
,
107 PROP_DIAGRAM_HAS_X_AXIS
,
108 PROP_DIAGRAM_HAS_X_AXIS_DESCR
,
109 PROP_DIAGRAM_HAS_X_AXIS_TITLE
,
110 PROP_DIAGRAM_HAS_X_AXIS_GRID
,
111 PROP_DIAGRAM_HAS_X_AXIS_HELP_GRID
,
113 PROP_DIAGRAM_HAS_Y_AXIS
,
114 PROP_DIAGRAM_HAS_Y_AXIS_DESCR
,
115 PROP_DIAGRAM_HAS_Y_AXIS_TITLE
,
116 PROP_DIAGRAM_HAS_Y_AXIS_GRID
,
117 PROP_DIAGRAM_HAS_Y_AXIS_HELP_GRID
,
119 PROP_DIAGRAM_HAS_Z_AXIS
,
120 PROP_DIAGRAM_HAS_Z_AXIS_DESCR
,
121 PROP_DIAGRAM_HAS_Z_AXIS_TITLE
,
122 PROP_DIAGRAM_HAS_Z_AXIS_GRID
,
123 PROP_DIAGRAM_HAS_Z_AXIS_HELP_GRID
,
125 PROP_DIAGRAM_HAS_SECOND_X_AXIS
,
126 PROP_DIAGRAM_HAS_SECOND_X_AXIS_DESCR
,
128 PROP_DIAGRAM_HAS_SECOND_Y_AXIS
,
129 PROP_DIAGRAM_HAS_SECOND_Y_AXIS_DESCR
,
131 PROP_DIAGRAM_HAS_SECOND_X_AXIS_TITLE
,
132 PROP_DIAGRAM_HAS_SECOND_Y_AXIS_TITLE
,
134 PROP_DIAGRAM_AUTOMATIC_SIZE
,
135 PROP_DIAGRAM_DATATABLEHBORDER
,
136 PROP_DIAGRAM_DATATABLEVBORDER
,
137 PROP_DIAGRAM_DATATABLEOUTLINE
,
138 PROP_DIAGRAM_EXTERNALDATA
141 void lcl_AddPropertiesToVector(
142 std::vector
< Property
> & rOutProperties
)
144 rOutProperties
.emplace_back( "AttributedDataPoints",
145 PROP_DIAGRAM_ATTRIBUTED_DATA_POINTS
,
146 cppu::UnoType
<uno::Sequence
< uno::Sequence
< sal_Int32
> >>::get(),
147 beans::PropertyAttribute::BOUND
148 | beans::PropertyAttribute::MAYBEVOID
);
150 // see com.sun.star.chart.StackableDiagram
151 rOutProperties
.emplace_back( "Percent",
152 PROP_DIAGRAM_PERCENT_STACKED
,
153 cppu::UnoType
<bool>::get(),
154 beans::PropertyAttribute::BOUND
155 | beans::PropertyAttribute::MAYBEDEFAULT
);
156 rOutProperties
.emplace_back( "Stacked",
157 PROP_DIAGRAM_STACKED
,
158 cppu::UnoType
<bool>::get(),
159 beans::PropertyAttribute::BOUND
160 | beans::PropertyAttribute::MAYBEDEFAULT
);
162 rOutProperties
.emplace_back( "Dim3D",
163 PROP_DIAGRAM_THREE_D
,
164 cppu::UnoType
<bool>::get(),
165 beans::PropertyAttribute::BOUND
166 | beans::PropertyAttribute::MAYBEDEFAULT
);
168 // see com.sun.star.chart.Chart3DBarProperties
169 rOutProperties
.emplace_back( "SolidType",
170 PROP_DIAGRAM_SOLIDTYPE
,
171 cppu::UnoType
<sal_Int32
>::get(),
172 beans::PropertyAttribute::BOUND
173 | beans::PropertyAttribute::MAYBEDEFAULT
);
175 // see com.sun.star.chart.BarDiagram
176 rOutProperties
.emplace_back( "Deep",
178 cppu::UnoType
<bool>::get(),
179 beans::PropertyAttribute::BOUND
180 | beans::PropertyAttribute::MAYBEDEFAULT
);
181 rOutProperties
.emplace_back( "Vertical",
182 PROP_DIAGRAM_VERTICAL
,
183 cppu::UnoType
<bool>::get(),
184 beans::PropertyAttribute::BOUND
185 | beans::PropertyAttribute::MAYBEDEFAULT
);
186 rOutProperties
.emplace_back( "NumberOfLines",
187 PROP_DIAGRAM_NUMBER_OF_LINES
,
188 cppu::UnoType
<sal_Int32
>::get(),
189 beans::PropertyAttribute::BOUND
190 | beans::PropertyAttribute::MAYBEDEFAULT
);
191 rOutProperties
.emplace_back( "StackedBarsConnected",
192 PROP_DIAGRAM_STACKED_BARS_CONNECTED
,
193 cppu::UnoType
<bool>::get(),
194 beans::PropertyAttribute::BOUND
195 | beans::PropertyAttribute::MAYBEDEFAULT
);
197 rOutProperties
.emplace_back( "DataRowSource",
198 PROP_DIAGRAM_DATAROW_SOURCE
,
199 cppu::UnoType
<css::chart::ChartDataRowSource
>::get(),
200 beans::PropertyAttribute::BOUND
201 | beans::PropertyAttribute::MAYBEDEFAULT
);
203 rOutProperties
.emplace_back( "GroupBarsPerAxis",
204 PROP_DIAGRAM_GROUP_BARS_PER_AXIS
,
205 cppu::UnoType
<bool>::get(),
206 beans::PropertyAttribute::BOUND
207 | beans::PropertyAttribute::MAYBEDEFAULT
);
209 rOutProperties
.emplace_back( "IncludeHiddenCells",
210 PROP_DIAGRAM_INCLUDE_HIDDEN_CELLS
,
211 cppu::UnoType
<bool>::get(),
212 beans::PropertyAttribute::BOUND
213 | beans::PropertyAttribute::MAYBEDEFAULT
);
216 rOutProperties
.emplace_back( CHART_UNONAME_SORT_BY_XVALUES
,
217 PROP_DIAGRAM_SORT_BY_X_VALUES
,
218 cppu::UnoType
<bool>::get(),
219 beans::PropertyAttribute::BOUND
220 | beans::PropertyAttribute::MAYBEDEFAULT
);
222 //for pie and donut charts
223 rOutProperties
.emplace_back( "StartingAngle",
224 PROP_DIAGRAM_STARTING_ANGLE
,
225 cppu::UnoType
<sal_Int32
>::get(),
226 beans::PropertyAttribute::BOUND
227 | beans::PropertyAttribute::MAYBEDEFAULT
);
230 rOutProperties
.emplace_back( "RightAngledAxes",
231 PROP_DIAGRAM_RIGHT_ANGLED_AXES
,
232 cppu::UnoType
<bool>::get(),
233 beans::PropertyAttribute::BOUND
234 | beans::PropertyAttribute::MAYBEDEFAULT
);
236 rOutProperties
.emplace_back( "Perspective",
237 PROP_DIAGRAM_PERSPECTIVE
,
238 cppu::UnoType
<sal_Int32
>::get(),
239 beans::PropertyAttribute::MAYBEVOID
);
241 rOutProperties
.emplace_back( "RotationHorizontal",
242 PROP_DIAGRAM_ROTATION_HORIZONTAL
,
243 cppu::UnoType
<sal_Int32
>::get(),
244 beans::PropertyAttribute::MAYBEVOID
);
246 rOutProperties
.emplace_back( "RotationVertical",
247 PROP_DIAGRAM_ROTATION_VERTICAL
,
248 cppu::UnoType
<sal_Int32
>::get(),
249 beans::PropertyAttribute::MAYBEVOID
);
252 rOutProperties
.emplace_back( "HasXAxis",
253 PROP_DIAGRAM_HAS_X_AXIS
,
254 cppu::UnoType
<bool>::get(),
255 beans::PropertyAttribute::BOUND
256 | beans::PropertyAttribute::MAYBEDEFAULT
);
257 rOutProperties
.emplace_back( "HasXAxisDescription",
258 PROP_DIAGRAM_HAS_X_AXIS_DESCR
,
259 cppu::UnoType
<bool>::get(),
260 beans::PropertyAttribute::BOUND
261 | beans::PropertyAttribute::MAYBEDEFAULT
);
262 rOutProperties
.emplace_back( "HasXAxisTitle",
263 PROP_DIAGRAM_HAS_X_AXIS_TITLE
,
264 cppu::UnoType
<bool>::get(),
265 beans::PropertyAttribute::BOUND
266 | beans::PropertyAttribute::MAYBEDEFAULT
);
267 rOutProperties
.emplace_back( "HasXAxisGrid",
268 PROP_DIAGRAM_HAS_X_AXIS_GRID
,
269 cppu::UnoType
<bool>::get(),
270 beans::PropertyAttribute::BOUND
271 | beans::PropertyAttribute::MAYBEDEFAULT
);
272 rOutProperties
.emplace_back( "HasXAxisHelpGrid",
273 PROP_DIAGRAM_HAS_X_AXIS_HELP_GRID
,
274 cppu::UnoType
<bool>::get(),
275 beans::PropertyAttribute::BOUND
276 | beans::PropertyAttribute::MAYBEDEFAULT
);
279 rOutProperties
.emplace_back( "HasYAxis",
280 PROP_DIAGRAM_HAS_Y_AXIS
,
281 cppu::UnoType
<bool>::get(),
282 beans::PropertyAttribute::BOUND
283 | beans::PropertyAttribute::MAYBEDEFAULT
);
284 rOutProperties
.emplace_back( "HasYAxisDescription",
285 PROP_DIAGRAM_HAS_Y_AXIS_DESCR
,
286 cppu::UnoType
<bool>::get(),
287 beans::PropertyAttribute::BOUND
288 | beans::PropertyAttribute::MAYBEDEFAULT
);
289 rOutProperties
.emplace_back( "HasYAxisTitle",
290 PROP_DIAGRAM_HAS_Y_AXIS_TITLE
,
291 cppu::UnoType
<bool>::get(),
292 beans::PropertyAttribute::BOUND
293 | beans::PropertyAttribute::MAYBEDEFAULT
);
294 rOutProperties
.emplace_back( "HasYAxisGrid",
295 PROP_DIAGRAM_HAS_Y_AXIS_GRID
,
296 cppu::UnoType
<bool>::get(),
297 beans::PropertyAttribute::BOUND
298 | beans::PropertyAttribute::MAYBEDEFAULT
);
299 rOutProperties
.emplace_back( "HasYAxisHelpGrid",
300 PROP_DIAGRAM_HAS_Y_AXIS_HELP_GRID
,
301 cppu::UnoType
<bool>::get(),
302 beans::PropertyAttribute::BOUND
303 | beans::PropertyAttribute::MAYBEDEFAULT
);
306 rOutProperties
.emplace_back( "HasZAxis",
307 PROP_DIAGRAM_HAS_Z_AXIS
,
308 cppu::UnoType
<bool>::get(),
309 beans::PropertyAttribute::BOUND
310 | beans::PropertyAttribute::MAYBEDEFAULT
);
311 rOutProperties
.emplace_back( "HasZAxisDescription",
312 PROP_DIAGRAM_HAS_Z_AXIS_DESCR
,
313 cppu::UnoType
<bool>::get(),
314 beans::PropertyAttribute::BOUND
315 | beans::PropertyAttribute::MAYBEDEFAULT
);
316 rOutProperties
.emplace_back( "HasZAxisTitle",
317 PROP_DIAGRAM_HAS_Z_AXIS_TITLE
,
318 cppu::UnoType
<bool>::get(),
319 beans::PropertyAttribute::BOUND
320 | beans::PropertyAttribute::MAYBEDEFAULT
);
321 rOutProperties
.emplace_back( "HasZAxisGrid",
322 PROP_DIAGRAM_HAS_Z_AXIS_GRID
,
323 cppu::UnoType
<bool>::get(),
324 beans::PropertyAttribute::BOUND
325 | beans::PropertyAttribute::MAYBEDEFAULT
);
326 rOutProperties
.emplace_back( "HasZAxisHelpGrid",
327 PROP_DIAGRAM_HAS_Z_AXIS_HELP_GRID
,
328 cppu::UnoType
<bool>::get(),
329 beans::PropertyAttribute::BOUND
330 | beans::PropertyAttribute::MAYBEDEFAULT
);
333 rOutProperties
.emplace_back( "HasSecondaryXAxis",
334 PROP_DIAGRAM_HAS_SECOND_X_AXIS
,
335 cppu::UnoType
<bool>::get(),
336 beans::PropertyAttribute::BOUND
337 | beans::PropertyAttribute::MAYBEDEFAULT
);
338 rOutProperties
.emplace_back( "HasSecondaryXAxisDescription",
339 PROP_DIAGRAM_HAS_SECOND_X_AXIS_DESCR
,
340 cppu::UnoType
<bool>::get(),
341 beans::PropertyAttribute::BOUND
342 | beans::PropertyAttribute::MAYBEDEFAULT
);
345 rOutProperties
.emplace_back( "HasSecondaryYAxis",
346 PROP_DIAGRAM_HAS_SECOND_Y_AXIS
,
347 cppu::UnoType
<bool>::get(),
348 beans::PropertyAttribute::BOUND
349 | beans::PropertyAttribute::MAYBEDEFAULT
);
350 rOutProperties
.emplace_back( "HasSecondaryYAxisDescription",
351 PROP_DIAGRAM_HAS_SECOND_Y_AXIS_DESCR
,
352 cppu::UnoType
<bool>::get(),
353 beans::PropertyAttribute::BOUND
354 | beans::PropertyAttribute::MAYBEDEFAULT
);
356 // XSecondAxisTitleSupplier
357 rOutProperties
.emplace_back( "HasSecondaryXAxisTitle",
358 PROP_DIAGRAM_HAS_SECOND_X_AXIS_TITLE
,
359 cppu::UnoType
<bool>::get(),
360 beans::PropertyAttribute::BOUND
361 | beans::PropertyAttribute::MAYBEDEFAULT
);
362 rOutProperties
.emplace_back( "HasSecondaryYAxisTitle",
363 PROP_DIAGRAM_HAS_SECOND_Y_AXIS_TITLE
,
364 cppu::UnoType
<bool>::get(),
365 beans::PropertyAttribute::BOUND
366 | beans::PropertyAttribute::MAYBEDEFAULT
);
368 rOutProperties
.emplace_back( "MissingValueTreatment",
369 PROP_DIAGRAM_MISSING_VALUE_TREATMENT
,
370 cppu::UnoType
<sal_Int32
>::get(),
371 beans::PropertyAttribute::BOUND
372 | beans::PropertyAttribute::MAYBEVOID
);
374 rOutProperties
.emplace_back( "AutomaticSize",
375 PROP_DIAGRAM_AUTOMATIC_SIZE
,
376 cppu::UnoType
<bool>::get(),
377 beans::PropertyAttribute::BOUND
378 | beans::PropertyAttribute::MAYBEDEFAULT
);
379 rOutProperties
.emplace_back( "DataTableHBorder",
380 PROP_DIAGRAM_DATATABLEHBORDER
,
381 cppu::UnoType
<bool>::get(),
382 beans::PropertyAttribute::BOUND
383 | beans::PropertyAttribute::MAYBEDEFAULT
);
384 rOutProperties
.emplace_back( "DataTableVBorder",
385 PROP_DIAGRAM_DATATABLEVBORDER
,
386 cppu::UnoType
<bool>::get(),
387 beans::PropertyAttribute::BOUND
388 | beans::PropertyAttribute::MAYBEDEFAULT
);
389 rOutProperties
.emplace_back( "DataTableOutline",
390 PROP_DIAGRAM_DATATABLEOUTLINE
,
391 cppu::UnoType
<bool>::get(),
392 beans::PropertyAttribute::BOUND
393 | beans::PropertyAttribute::MAYBEDEFAULT
);
394 rOutProperties
.emplace_back( "ExternalData",
395 PROP_DIAGRAM_EXTERNALDATA
,
396 cppu::UnoType
<OUString
>::get(),
397 beans::PropertyAttribute::BOUND
398 | beans::PropertyAttribute::MAYBEVOID
);
401 struct StaticDiagramWrapperPropertyArray_Initializer
403 Sequence
< Property
>* operator()()
405 static Sequence
< Property
> aPropSeq( lcl_GetPropertySequence() );
410 static uno::Sequence
< Property
> lcl_GetPropertySequence()
412 std::vector
< css::beans::Property
> aProperties
;
413 lcl_AddPropertiesToVector( aProperties
);
414 ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties
);
415 ::chart::FillProperties::AddPropertiesToVector( aProperties
);
416 ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties
);
417 ::chart::SceneProperties::AddPropertiesToVector( aProperties
);
418 WrappedStatisticProperties::addProperties( aProperties
);
419 WrappedSymbolProperties::addProperties( aProperties
);
420 WrappedDataCaptionProperties::addProperties( aProperties
);
421 WrappedSplineProperties::addProperties( aProperties
);
422 WrappedStockProperties::addProperties( aProperties
);
423 WrappedAutomaticPositionProperties::addProperties( aProperties
);
425 std::sort( aProperties
.begin(), aProperties
.end(),
426 ::chart::PropertyNameLess() );
428 return comphelper::containerToSequence( aProperties
);
432 struct StaticDiagramWrapperPropertyArray
: public rtl::StaticAggregate
< Sequence
< Property
>, StaticDiagramWrapperPropertyArray_Initializer
>
436 bool lcl_isXYChart( const Reference
< chart2::XDiagram
>& rDiagram
)
439 Reference
< chart2::XChartType
> xChartType( ::chart::DiagramHelper::getChartTypeByIndex( rDiagram
, 0 ) );
440 if( xChartType
.is() )
442 OUString
aChartType( xChartType
->getChartType() );
443 if( aChartType
.equalsIgnoreAsciiCase(CHART2_SERVICE_NAME_CHARTTYPE_SCATTER
) )
449 sal_Int32
lcl_getNewAPIIndexForOldAPIIndex(
450 sal_Int32 nOldAPIIndex
451 , const Reference
< chart2::XDiagram
>& xDiagram
)
453 sal_Int32 nNewAPIIndex
= nOldAPIIndex
;
455 if( lcl_isXYChart( xDiagram
) )
457 if( nNewAPIIndex
>= 1 )
461 std::vector
< uno::Reference
< chart2::XDataSeries
> > aSeriesList(
462 ::chart::DiagramHelper::getDataSeriesFromDiagram( xDiagram
) );
463 if( nNewAPIIndex
>= static_cast<sal_Int32
>(aSeriesList
.size()) )
469 OUString
lcl_getDiagramType( const OUString
& rTemplateServiceName
)
471 const OUString
aPrefix("com.sun.star.chart2.template.");
473 if( rTemplateServiceName
.match( aPrefix
))
475 const OUString
aName( rTemplateServiceName
.copy( aPrefix
.getLength()));
477 // "Area" "StackedArea" "PercentStackedArea" "ThreeDArea"
478 // "StackedThreeDArea" "PercentStackedThreeDArea"
479 if( aName
.indexOf( "Area" ) != -1 )
480 return "com.sun.star.chart.AreaDiagram";
482 // "Pie" "PieAllExploded" "ThreeDPie" "ThreeDPieAllExploded"
483 if( aName
.indexOf( "Pie" ) != -1 )
484 return "com.sun.star.chart.PieDiagram";
486 // "Column" "StackedColumn" "PercentStackedColumn" "ThreeDColumnDeep"
487 // "ThreeDColumnFlat" "StackedThreeDColumnFlat"
488 // "PercentStackedThreeDColumnFlat" "Bar" "StackedBar"
489 // "PercentStackedBar" "ThreeDBarDeep" "ThreeDBarFlat"
490 // "StackedThreeDBarFlat" "PercentStackedThreeDBarFlat" "ColumnWithLine"
491 // "StackedColumnWithLine"
492 if( aName
.indexOf( "Column" ) != -1 || aName
.indexOf( "Bar" ) != -1 )
493 return "com.sun.star.chart.BarDiagram";
495 // "Donut" "DonutAllExploded" "ThreeDDonut" "ThreeDDonutAllExploded"
496 if( aName
.indexOf( "Donut" ) != -1 )
497 return "com.sun.star.chart.DonutDiagram";
499 // "ScatterLineSymbol" "ScatterLine" "ScatterSymbol" "ThreeDScatter"
500 if( aName
.indexOf( "Scatter" ) != -1 )
501 return "com.sun.star.chart.XYDiagram";
503 // "FilledNet" "StackedFilledNet" "PercentStackedFilledNet"
504 if( aName
.indexOf( "FilledNet" ) != -1 )
505 return "com.sun.star.chart.FilledNetDiagram";
507 // "Net" "NetSymbol" "NetLine" "StackedNet" "StackedNetSymbol"
508 // "StackedNetLine" "PercentStackedNet" "PercentStackedNetSymbol"
509 // "PercentStackedNetLine"
510 if( aName
.indexOf( "Net" ) != -1 )
511 return "com.sun.star.chart.NetDiagram";
513 // "StockLowHighClose" "StockOpenLowHighClose" "StockVolumeLowHighClose"
514 // "StockVolumeOpenLowHighClose"
515 if( aName
.indexOf( "Stock" ) != -1 )
516 return "com.sun.star.chart.StockDiagram";
518 if( aName
.indexOf( "Bubble" ) != -1 )
519 return "com.sun.star.chart.BubbleDiagram";
521 // Note: this must be checked after Bar, Net and Scatter
523 // "Symbol" "StackedSymbol" "PercentStackedSymbol" "Line" "StackedLine"
524 // "PercentStackedLine" "LineSymbol" "StackedLineSymbol"
525 // "PercentStackedLineSymbol" "ThreeDLine" "StackedThreeDLine"
526 // "PercentStackedThreeDLine" "ThreeDLineDeep"
527 if( aName
.indexOf( "Line" ) != -1 || aName
.indexOf( "Symbol" ) != -1 )
528 return "com.sun.star.chart.LineDiagram";
530 OSL_FAIL( "unknown template" );
536 typedef std::map
< OUString
, OUString
> tMakeStringStringMap
;
538 const tMakeStringStringMap
& lcl_getChartTypeNameMap()
540 static tMakeStringStringMap g_aChartTypeNameMap
{
541 {"com.sun.star.chart2.LineChartType", "com.sun.star.chart.LineDiagram"},
542 {"com.sun.star.chart2.AreaChartType", "com.sun.star.chart.AreaDiagram"},
543 {"com.sun.star.chart2.ColumnChartType", "com.sun.star.chart.BarDiagram"},
544 {"com.sun.star.chart2.PieChartType", "com.sun.star.chart.PieDiagram"},
545 {"com.sun.star.chart2.DonutChartType", "com.sun.star.chart.DonutDiagram"},
546 {"com.sun.star.chart2.ScatterChartType", "com.sun.star.chart.XYDiagram"},
547 {"com.sun.star.chart2.FilledNetChartType", "com.sun.star.chart.FilledNetDiagram"},
548 {"com.sun.star.chart2.NetChartType", "com.sun.star.chart.NetDiagram"},
549 {"com.sun.star.chart2.CandleStickChartType", "com.sun.star.chart.StockDiagram"},
550 {"com.sun.star.chart2.BubbleChartType", "com.sun.star.chart.BubbleDiagram"}
552 return g_aChartTypeNameMap
;
555 OUString
lcl_getOldChartTypeName( const OUString
& rNewChartTypeName
)
557 OUString
aOld(rNewChartTypeName
);
559 const tMakeStringStringMap
& rMap
= lcl_getChartTypeNameMap();
560 tMakeStringStringMap::const_iterator
aIt( rMap
.find( rNewChartTypeName
));
561 if( aIt
!= rMap
.end())
568 } // anonymous namespace
575 DiagramWrapper::DiagramWrapper(const std::shared_ptr
<Chart2ModelContact
>& spChart2ModelContact
)
576 : m_spChart2ModelContact(spChart2ModelContact
)
577 , m_aEventListenerContainer(m_aMutex
)
581 DiagramWrapper::~DiagramWrapper()
584 // ____ XDiagram ____
585 OUString SAL_CALL
DiagramWrapper::getDiagramType()
589 Reference
< chart2::XChartDocument
> xChartDoc( m_spChart2ModelContact
->getChart2Document() );
590 Reference
< chart2::XDiagram
> xDiagram( m_spChart2ModelContact
->getChart2Diagram() );
591 if( xChartDoc
.is() && xDiagram
.is() )
593 Reference
< beans::XPropertySet
> xChartDocProp( xChartDoc
, uno::UNO_QUERY
);
594 if( xChartDocProp
.is() )
596 uno::Reference
< util::XRefreshable
> xAddIn
;
597 if( xChartDocProp
->getPropertyValue( "AddIn" ) >>= xAddIn
)
599 uno::Reference
< lang::XServiceName
> xServiceName( xAddIn
, uno::UNO_QUERY
);
600 if( xServiceName
.is())
601 return xServiceName
->getServiceName();
605 Reference
< lang::XMultiServiceFactory
> xChartTypeManager( xChartDoc
->getChartTypeManager(), uno::UNO_QUERY
);
606 DiagramHelper::tTemplateWithServiceName aTemplateAndService
=
607 DiagramHelper::getTemplateForDiagram( xDiagram
, xChartTypeManager
);
609 aRet
= lcl_getDiagramType( aTemplateAndService
.second
);
614 // none of the standard templates matched
615 // use first chart type
616 Reference
< chart2::XChartType
> xChartType( DiagramHelper::getChartTypeByIndex( xDiagram
, 0 ) );
617 if( xChartType
.is() )
619 aRet
= xChartType
->getChartType();
620 if( !aRet
.isEmpty() )
621 aRet
= lcl_getOldChartTypeName( aRet
);
624 aRet
= "com.sun.star.chart.BarDiagram";
631 beans::XPropertySet
> SAL_CALL
DiagramWrapper::getDataRowProperties( sal_Int32 nRow
)
634 throw lang::IndexOutOfBoundsException("DataSeries index invalid",
635 static_cast< ::cppu::OWeakObject
* >( this ));
637 sal_Int32 nNewAPIIndex
= lcl_getNewAPIIndexForOldAPIIndex( nRow
, m_spChart2ModelContact
->getChart2Diagram() );
638 if( nNewAPIIndex
< 0 )
639 throw lang::IndexOutOfBoundsException("DataSeries index invalid",
640 static_cast< ::cppu::OWeakObject
* >( this ));
642 Reference
< beans::XPropertySet
> xRet( new DataSeriesPointWrapper(
643 DataSeriesPointWrapper::DATA_SERIES
, nNewAPIIndex
, 0, m_spChart2ModelContact
) );
648 beans::XPropertySet
> SAL_CALL
DiagramWrapper::getDataPointProperties( sal_Int32 nCol
, sal_Int32 nRow
)
650 if( nCol
< 0 || nRow
< 0 )
651 throw lang::IndexOutOfBoundsException("DataSeries index invalid",
652 static_cast< ::cppu::OWeakObject
* >( this ));
654 sal_Int32 nNewAPIIndex
= lcl_getNewAPIIndexForOldAPIIndex( nRow
, m_spChart2ModelContact
->getChart2Diagram() );
655 if( nNewAPIIndex
< 0 )
656 throw lang::IndexOutOfBoundsException("DataSeries index invalid",
657 static_cast< ::cppu::OWeakObject
* >( this ));
659 //todo: check borders of point index
661 Reference
< beans::XPropertySet
> xRet( new DataSeriesPointWrapper(
662 DataSeriesPointWrapper::DATA_POINT
, nNewAPIIndex
, nCol
, m_spChart2ModelContact
) );
667 // ____ XShape (base of XDiagram) ____
668 awt::Point SAL_CALL
DiagramWrapper::getPosition()
670 awt::Point aPosition
= ToPoint( m_spChart2ModelContact
->GetDiagramRectangleIncludingAxes() );
674 void SAL_CALL
DiagramWrapper::setPosition( const awt::Point
& aPosition
)
676 ControllerLockGuardUNO
aCtrlLockGuard( m_spChart2ModelContact
->getChartModel() );
677 Reference
< beans::XPropertySet
> xProp( getInnerPropertySet() );
680 awt::Size
aPageSize( m_spChart2ModelContact
->GetPageSize() );
682 chart2::RelativePosition aRelativePosition
;
683 aRelativePosition
.Anchor
= drawing::Alignment_TOP_LEFT
;
684 aRelativePosition
.Primary
= double(aPosition
.X
)/double(aPageSize
.Width
);
685 aRelativePosition
.Secondary
= double(aPosition
.Y
)/double(aPageSize
.Height
);
686 if( aRelativePosition
.Primary
< 0 || aRelativePosition
.Secondary
< 0 || aRelativePosition
.Primary
> 1 || aRelativePosition
.Secondary
> 1 )
688 OSL_FAIL("DiagramWrapper::setPosition called with a position out of range -> automatic values are taken instead" );
690 xProp
->setPropertyValue( "RelativePosition", aEmpty
);
693 xProp
->setPropertyValue( "RelativePosition", uno::Any(aRelativePosition
) );
694 xProp
->setPropertyValue( "PosSizeExcludeAxes", uno::Any(false) );
698 awt::Size SAL_CALL
DiagramWrapper::getSize()
700 awt::Size aSize
= ToSize( m_spChart2ModelContact
->GetDiagramRectangleIncludingAxes() );
704 void SAL_CALL
DiagramWrapper::setSize( const awt::Size
& aSize
)
706 ControllerLockGuardUNO
aCtrlLockGuard( m_spChart2ModelContact
->getChartModel() );
707 Reference
< beans::XPropertySet
> xProp( getInnerPropertySet() );
710 awt::Size
aPageSize( m_spChart2ModelContact
->GetPageSize() );
712 chart2::RelativeSize aRelativeSize
;
713 aRelativeSize
.Primary
= double(aSize
.Width
)/double(aPageSize
.Width
);
714 aRelativeSize
.Secondary
= double(aSize
.Height
)/double(aPageSize
.Height
);
716 if( aRelativeSize
.Primary
> 1 || aRelativeSize
.Secondary
> 1 )
718 OSL_FAIL("DiagramWrapper::setSize called with sizes bigger than page -> automatic values are taken instead" );
720 xProp
->setPropertyValue( "RelativeSize", aEmpty
);
724 xProp
->setPropertyValue( "RelativeSize", uno::Any(aRelativeSize
) );
725 xProp
->setPropertyValue( "PosSizeExcludeAxes", uno::Any(false) );
729 // ____ XShapeDescriptor (base of XShape) ____
730 OUString SAL_CALL
DiagramWrapper::getShapeType()
732 return "com.sun.star.chart.Diagram";
735 // ____ XDiagramPositioning ____
737 void SAL_CALL
DiagramWrapper::setAutomaticDiagramPositioning()
739 ControllerLockGuardUNO
aCtrlLockGuard( m_spChart2ModelContact
->getChartModel() );
740 uno::Reference
< beans::XPropertySet
> xDiaProps( getDiagram(), uno::UNO_QUERY
);
743 xDiaProps
->setPropertyValue( "RelativeSize", Any() );
744 xDiaProps
->setPropertyValue( "RelativePosition", Any() );
747 sal_Bool SAL_CALL
DiagramWrapper::isAutomaticDiagramPositioning( )
749 uno::Reference
< beans::XPropertySet
> xDiaProps( getDiagram(), uno::UNO_QUERY
);
752 Any
aRelativeSize( xDiaProps
->getPropertyValue( "RelativeSize" ) );
753 Any
aRelativePosition( xDiaProps
->getPropertyValue( "RelativePosition" ) );
754 if( aRelativeSize
.hasValue() && aRelativePosition
.hasValue() )
759 void SAL_CALL
DiagramWrapper::setDiagramPositionExcludingAxes( const awt::Rectangle
& rPositionRect
)
761 ControllerLockGuardUNO
aCtrlLockGuard( m_spChart2ModelContact
->getChartModel() );
762 DiagramHelper::setDiagramPositioning( m_spChart2ModelContact
->getChartModel(), rPositionRect
);
763 uno::Reference
< beans::XPropertySet
> xDiaProps( getDiagram(), uno::UNO_QUERY
);
765 xDiaProps
->setPropertyValue("PosSizeExcludeAxes", uno::Any(true) );
767 sal_Bool SAL_CALL
DiagramWrapper::isExcludingDiagramPositioning()
769 uno::Reference
< beans::XPropertySet
> xDiaProps( getDiagram(), uno::UNO_QUERY
);
772 Any
aRelativeSize( xDiaProps
->getPropertyValue( "RelativeSize" ) );
773 Any
aRelativePosition( xDiaProps
->getPropertyValue( "RelativePosition" ) );
774 if( aRelativeSize
.hasValue() && aRelativePosition
.hasValue() )
776 bool bPosSizeExcludeAxes
= false;
777 xDiaProps
->getPropertyValue( "PosSizeExcludeAxes" ) >>= bPosSizeExcludeAxes
;
778 return bPosSizeExcludeAxes
;
783 awt::Rectangle SAL_CALL
DiagramWrapper::calculateDiagramPositionExcludingAxes( )
785 return m_spChart2ModelContact
->GetDiagramRectangleExcludingAxes();
787 void SAL_CALL
DiagramWrapper::setDiagramPositionIncludingAxes( const awt::Rectangle
& rPositionRect
)
789 ControllerLockGuardUNO
aCtrlLockGuard( m_spChart2ModelContact
->getChartModel() );
790 DiagramHelper::setDiagramPositioning( m_spChart2ModelContact
->getChartModel(), rPositionRect
);
791 uno::Reference
< beans::XPropertySet
> xDiaProps( getDiagram(), uno::UNO_QUERY
);
793 xDiaProps
->setPropertyValue("PosSizeExcludeAxes", uno::Any(false) );
795 awt::Rectangle SAL_CALL
DiagramWrapper::calculateDiagramPositionIncludingAxes( )
797 return m_spChart2ModelContact
->GetDiagramRectangleIncludingAxes();
799 void SAL_CALL
DiagramWrapper::setDiagramPositionIncludingAxesAndAxisTitles( const awt::Rectangle
& rPositionRect
)
801 ControllerLockGuardUNO
aCtrlLockGuard( m_spChart2ModelContact
->getChartModel() );
802 awt::Rectangle
aRect( m_spChart2ModelContact
->SubstractAxisTitleSizes(rPositionRect
) );
803 DiagramWrapper::setDiagramPositionIncludingAxes( aRect
);
805 css::awt::Rectangle SAL_CALL
DiagramWrapper::calculateDiagramPositionIncludingAxesAndAxisTitles( )
807 return m_spChart2ModelContact
->GetDiagramRectangleIncludingTitle();
810 // ____ XAxisSupplier ____
811 Reference
< XAxis
> SAL_CALL
DiagramWrapper::getAxis( sal_Int32 nDimensionIndex
)
813 Reference
< XAxis
> xAxis
;
817 m_xXAxis
= new AxisWrapper( AxisWrapper::X_AXIS
, m_spChart2ModelContact
);
820 else if(nDimensionIndex
==1)
823 m_xYAxis
= new AxisWrapper( AxisWrapper::Y_AXIS
, m_spChart2ModelContact
);
826 else if(nDimensionIndex
==2)
829 m_xZAxis
= new AxisWrapper( AxisWrapper::Z_AXIS
, m_spChart2ModelContact
);
835 Reference
< XAxis
> SAL_CALL
DiagramWrapper::getSecondaryAxis( sal_Int32 nDimensionIndex
)
837 Reference
< XAxis
> xAxis
;
840 if( !m_xSecondXAxis
.is() )
841 m_xSecondXAxis
= new AxisWrapper( AxisWrapper::SECOND_X_AXIS
, m_spChart2ModelContact
);
842 xAxis
= m_xSecondXAxis
;
844 else if(nDimensionIndex
==1)
846 if( !m_xSecondYAxis
.is() )
847 m_xSecondYAxis
= new AxisWrapper( AxisWrapper::SECOND_Y_AXIS
, m_spChart2ModelContact
);
848 xAxis
= m_xSecondYAxis
;
853 // ____ XAxisZSupplier ____
854 Reference
< drawing::XShape
> SAL_CALL
DiagramWrapper::getZAxisTitle()
856 Reference
< drawing::XShape
> xRet
;
857 Reference
< XAxis
> xAxis( getAxis(2) );
859 xRet
.set( xAxis
->getAxisTitle(), uno::UNO_QUERY
);
863 Reference
< beans::XPropertySet
> SAL_CALL
DiagramWrapper::getZMainGrid()
865 Reference
< beans::XPropertySet
> xRet
;
866 Reference
< XAxis
> xAxis( getAxis(2) );
868 xRet
= xAxis
->getMajorGrid();
872 Reference
< beans::XPropertySet
> SAL_CALL
DiagramWrapper::getZHelpGrid()
874 Reference
< beans::XPropertySet
> xRet
;
875 Reference
< XAxis
> xAxis( getAxis(2) );
877 xRet
= xAxis
->getMinorGrid();
881 Reference
< beans::XPropertySet
> SAL_CALL
DiagramWrapper::getZAxis()
884 m_xZAxis
= new AxisWrapper( AxisWrapper::Z_AXIS
, m_spChart2ModelContact
);
885 return Reference
< beans::XPropertySet
>( m_xZAxis
, uno::UNO_QUERY
);
888 // ____ XTwoAxisXSupplier ____
889 Reference
< beans::XPropertySet
> SAL_CALL
DiagramWrapper::getSecondaryXAxis()
891 if( ! m_xSecondXAxis
.is())
892 m_xSecondXAxis
= new AxisWrapper( AxisWrapper::SECOND_X_AXIS
, m_spChart2ModelContact
);
893 return Reference
< beans::XPropertySet
>( m_xSecondXAxis
, uno::UNO_QUERY
);
896 // ____ XAxisXSupplier (base of XTwoAxisXSupplier) ____
897 Reference
< drawing::XShape
> SAL_CALL
DiagramWrapper::getXAxisTitle()
899 Reference
< drawing::XShape
> xRet
;
900 Reference
< XAxis
> xAxis( getAxis(0) );
902 xRet
.set( xAxis
->getAxisTitle(), uno::UNO_QUERY
);
906 Reference
< beans::XPropertySet
> SAL_CALL
DiagramWrapper::getXAxis()
909 m_xXAxis
= new AxisWrapper( AxisWrapper::X_AXIS
, m_spChart2ModelContact
);
910 return Reference
< beans::XPropertySet
>( m_xXAxis
, uno::UNO_QUERY
);
913 Reference
< beans::XPropertySet
> SAL_CALL
DiagramWrapper::getXMainGrid()
915 Reference
< beans::XPropertySet
> xRet
;
916 Reference
< XAxis
> xAxis( getAxis(0) );
918 xRet
= xAxis
->getMajorGrid();
922 Reference
< beans::XPropertySet
> SAL_CALL
DiagramWrapper::getXHelpGrid()
924 Reference
< beans::XPropertySet
> xRet
;
925 Reference
< XAxis
> xAxis( getAxis(0) );
927 xRet
= xAxis
->getMinorGrid();
931 // ____ XTwoAxisYSupplier ____
932 Reference
< beans::XPropertySet
> SAL_CALL
DiagramWrapper::getSecondaryYAxis()
934 if( ! m_xSecondYAxis
.is())
935 m_xSecondYAxis
= new AxisWrapper( AxisWrapper::SECOND_Y_AXIS
, m_spChart2ModelContact
);
936 return Reference
< beans::XPropertySet
>( m_xSecondYAxis
, uno::UNO_QUERY
);
939 // ____ XAxisYSupplier (base of XTwoAxisYSupplier) ____
940 Reference
< drawing::XShape
> SAL_CALL
DiagramWrapper::getYAxisTitle()
942 Reference
< drawing::XShape
> xRet
;
943 Reference
< XAxis
> xAxis( getAxis(1) );
945 xRet
.set( xAxis
->getAxisTitle(), uno::UNO_QUERY
);
949 Reference
< beans::XPropertySet
> SAL_CALL
DiagramWrapper::getYAxis()
952 m_xYAxis
= new AxisWrapper( AxisWrapper::Y_AXIS
, m_spChart2ModelContact
);
953 return Reference
< beans::XPropertySet
>( m_xYAxis
, uno::UNO_QUERY
);
956 Reference
< beans::XPropertySet
> SAL_CALL
DiagramWrapper::getYMainGrid()
958 Reference
< beans::XPropertySet
> xRet
;
959 Reference
< XAxis
> xAxis( getAxis(1) );
961 xRet
= xAxis
->getMajorGrid();
965 Reference
< beans::XPropertySet
> SAL_CALL
DiagramWrapper::getYHelpGrid()
967 Reference
< beans::XPropertySet
> xRet
;
968 Reference
< XAxis
> xAxis( getAxis(1) );
970 xRet
= xAxis
->getMinorGrid();
974 // ____ XSecondAxisTitleSupplier ____
975 Reference
< drawing::XShape
> SAL_CALL
DiagramWrapper::getSecondXAxisTitle()
977 Reference
< drawing::XShape
> xRet
;
978 Reference
< XAxis
> xAxis( getSecondaryAxis(0) );
980 xRet
.set( xAxis
->getAxisTitle(), uno::UNO_QUERY
);
984 Reference
< drawing::XShape
> SAL_CALL
DiagramWrapper::getSecondYAxisTitle()
986 Reference
< drawing::XShape
> xRet
;
987 Reference
< XAxis
> xAxis( getSecondaryAxis(1) );
989 xRet
.set( xAxis
->getAxisTitle(), uno::UNO_QUERY
);
993 // ____ XStatisticDisplay ____
995 beans::XPropertySet
> SAL_CALL
DiagramWrapper::getUpBar()
997 if( !m_xUpBarWrapper
.is() )
999 m_xUpBarWrapper
= new UpDownBarWrapper( true, m_spChart2ModelContact
);
1001 return m_xUpBarWrapper
;
1005 beans::XPropertySet
> SAL_CALL
DiagramWrapper::getDownBar()
1007 if( !m_xDownBarWrapper
.is() )
1009 m_xDownBarWrapper
= new UpDownBarWrapper( false, m_spChart2ModelContact
);
1011 return m_xDownBarWrapper
;
1015 beans::XPropertySet
> SAL_CALL
DiagramWrapper::getMinMaxLine()
1017 if( !m_xMinMaxLineWrapper
.is() )
1019 m_xMinMaxLineWrapper
= new MinMaxLineWrapper( m_spChart2ModelContact
);
1021 return m_xMinMaxLineWrapper
;
1024 // ____ X3DDisplay ____
1025 Reference
< beans::XPropertySet
> SAL_CALL
DiagramWrapper::getWall()
1029 m_xWall
= new WallFloorWrapper( true, m_spChart2ModelContact
);
1035 beans::XPropertySet
> SAL_CALL
DiagramWrapper::getFloor()
1037 if( !m_xFloor
.is() )
1039 m_xFloor
= new WallFloorWrapper( false, m_spChart2ModelContact
);
1044 // ____ X3DDefaultSetter ____
1045 void SAL_CALL
DiagramWrapper::set3DSettingsToDefault()
1047 Reference
< X3DDefaultSetter
> x3DDefaultSetter( m_spChart2ModelContact
->getChart2Diagram(), uno::UNO_QUERY
);
1048 if( x3DDefaultSetter
.is() )
1049 x3DDefaultSetter
->set3DSettingsToDefault();
1052 void SAL_CALL
DiagramWrapper::setDefaultRotation()
1054 Reference
< X3DDefaultSetter
> x3DDefaultSetter( m_spChart2ModelContact
->getChart2Diagram(), uno::UNO_QUERY
);
1055 if( x3DDefaultSetter
.is() )
1056 x3DDefaultSetter
->setDefaultRotation();
1059 void SAL_CALL
DiagramWrapper::setDefaultIllumination()
1061 Reference
< X3DDefaultSetter
> x3DDefaultSetter( m_spChart2ModelContact
->getChart2Diagram(), uno::UNO_QUERY
);
1062 if( x3DDefaultSetter
.is() )
1063 x3DDefaultSetter
->setDefaultIllumination();
1066 // ____ XComponent ____
1067 void SAL_CALL
DiagramWrapper::dispose()
1069 m_aEventListenerContainer
.disposeAndClear( lang::EventObject( static_cast< ::cppu::OWeakObject
* >( this )));
1071 MutexGuard
aGuard( m_aMutex
);
1073 DisposeHelper::DisposeAndClear( m_xXAxis
);
1074 DisposeHelper::DisposeAndClear( m_xYAxis
);
1075 DisposeHelper::DisposeAndClear( m_xZAxis
);
1076 DisposeHelper::DisposeAndClear( m_xSecondXAxis
);
1077 DisposeHelper::DisposeAndClear( m_xSecondYAxis
);
1078 DisposeHelper::DisposeAndClear( m_xWall
);
1079 DisposeHelper::DisposeAndClear( m_xFloor
);
1080 DisposeHelper::DisposeAndClear( m_xMinMaxLineWrapper
);
1081 DisposeHelper::DisposeAndClear( m_xUpBarWrapper
);
1082 DisposeHelper::DisposeAndClear( m_xDownBarWrapper
);
1084 clearWrappedPropertySet();
1087 void SAL_CALL
DiagramWrapper::addEventListener(
1088 const Reference
< lang::XEventListener
>& xListener
)
1090 m_aEventListenerContainer
.addInterface( xListener
);
1093 void SAL_CALL
DiagramWrapper::removeEventListener(
1094 const Reference
< lang::XEventListener
>& aListener
)
1096 m_aEventListenerContainer
.removeInterface( aListener
);
1099 //PROP_DIAGRAM_DATAROW_SOURCE
1100 class WrappedDataRowSourceProperty
: public WrappedProperty
1103 explicit WrappedDataRowSourceProperty(const std::shared_ptr
<Chart2ModelContact
>& spChart2ModelContact
);
1105 virtual void setPropertyValue( const css::uno::Any
& rOuterValue
, const css::uno::Reference
< css::beans::XPropertySet
>& xInnerPropertySet
) const override
;
1107 virtual css::uno::Any
getPropertyValue( const css::uno::Reference
< css::beans::XPropertySet
>& xInnerPropertySet
) const override
;
1109 virtual css::uno::Any
getPropertyDefault( const css::uno::Reference
< css::beans::XPropertyState
>& xInnerPropertyState
) const override
;
1112 std::shared_ptr
< Chart2ModelContact
> m_spChart2ModelContact
;
1113 mutable Any m_aOuterValue
;
1116 WrappedDataRowSourceProperty::WrappedDataRowSourceProperty(const std::shared_ptr
<Chart2ModelContact
>& spChart2ModelContact
)
1117 : WrappedProperty("DataRowSource",OUString())
1118 , m_spChart2ModelContact( spChart2ModelContact
)
1121 m_aOuterValue
= WrappedDataRowSourceProperty::getPropertyDefault( nullptr );
1124 void WrappedDataRowSourceProperty::setPropertyValue( const Any
& rOuterValue
, const Reference
< beans::XPropertySet
>& /*xInnerPropertySet*/ ) const
1126 css::chart::ChartDataRowSource eChartDataRowSource
= css::chart::ChartDataRowSource_ROWS
;
1127 if( ! (rOuterValue
>>= eChartDataRowSource
) )
1129 sal_Int32 nNew
= sal_Int32(css::chart::ChartDataRowSource_ROWS
);
1130 if( !(rOuterValue
>>= nNew
) )
1131 throw lang::IllegalArgumentException( "Property DataRowSource requires css::chart::ChartDataRowSource value", nullptr, 0 );
1132 eChartDataRowSource
= css::chart::ChartDataRowSource(nNew
);
1135 m_aOuterValue
= rOuterValue
;
1137 bool bNewUseColumns
= eChartDataRowSource
== css::chart::ChartDataRowSource_COLUMNS
;
1139 OUString aRangeString
;
1140 bool bUseColumns
= true;
1141 bool bFirstCellAsLabel
= true;
1142 bool bHasCategories
= true;
1143 uno::Sequence
< sal_Int32
> aSequenceMapping
;
1145 if( DataSourceHelper::detectRangeSegmentation(
1146 m_spChart2ModelContact
->getChartModel(), aRangeString
, aSequenceMapping
, bUseColumns
1147 , bFirstCellAsLabel
, bHasCategories
) )
1149 if( bUseColumns
!= bNewUseColumns
)
1151 aSequenceMapping
.realloc(0);
1152 DataSourceHelper::setRangeSegmentation(
1153 m_spChart2ModelContact
->getChartModel(), aSequenceMapping
, bNewUseColumns
, bFirstCellAsLabel
, bHasCategories
);
1158 Any
WrappedDataRowSourceProperty::getPropertyValue( const Reference
< beans::XPropertySet
>& /*xInnerPropertySet*/ ) const
1160 OUString aRangeString
;
1161 bool bUseColumns
= true;
1162 bool bFirstCellAsLabel
= true;
1163 bool bHasCategories
= true;
1164 uno::Sequence
< sal_Int32
> aSequenceMapping
;
1166 if( DataSourceHelper::detectRangeSegmentation(
1167 m_spChart2ModelContact
->getChartModel(), aRangeString
, aSequenceMapping
, bUseColumns
1168 , bFirstCellAsLabel
, bHasCategories
) )
1170 css::chart::ChartDataRowSource eChartDataRowSource
= css::chart::ChartDataRowSource_ROWS
;
1172 eChartDataRowSource
= css::chart::ChartDataRowSource_COLUMNS
;
1174 m_aOuterValue
<<= eChartDataRowSource
;
1177 return m_aOuterValue
;
1180 Any
WrappedDataRowSourceProperty::getPropertyDefault( const Reference
< beans::XPropertyState
>& /*xInnerPropertyState*/ ) const
1183 aRet
<<= css::chart::ChartDataRowSource_COLUMNS
;
1187 //PROP_DIAGRAM_STACKED
1189 //PROP_DIAGRAM_PERCENT_STACKED
1190 class WrappedStackingProperty
: public WrappedProperty
1193 WrappedStackingProperty(StackMode eStackMode
, const std::shared_ptr
<Chart2ModelContact
>& spChart2ModelContact
);
1195 virtual void setPropertyValue( const css::uno::Any
& rOuterValue
, const css::uno::Reference
< css::beans::XPropertySet
>& xInnerPropertySet
) const override
;
1197 virtual css::uno::Any
getPropertyValue( const css::uno::Reference
< css::beans::XPropertySet
>& xInnerPropertySet
) const override
;
1199 virtual css::uno::Any
getPropertyDefault( const css::uno::Reference
< css::beans::XPropertyState
>& xInnerPropertyState
) const override
;
1201 protected: //methods
1202 bool detectInnerValue( StackMode
& eInnerStackMode
) const;
1205 std::shared_ptr
< Chart2ModelContact
> m_spChart2ModelContact
;
1206 const StackMode m_eStackMode
;
1207 mutable Any m_aOuterValue
;
1210 WrappedStackingProperty::WrappedStackingProperty(StackMode eStackMode
, const std::shared_ptr
<Chart2ModelContact
>& spChart2ModelContact
)
1211 : WrappedProperty(OUString(),OUString())
1212 , m_spChart2ModelContact( spChart2ModelContact
)
1213 , m_eStackMode( eStackMode
)
1216 switch( m_eStackMode
)
1218 case StackMode::YStacked
:
1219 m_aOuterName
= "Stacked";
1221 case StackMode::YStackedPercent
:
1222 m_aOuterName
= "Percent";
1224 case StackMode::ZStacked
:
1225 m_aOuterName
= "Deep";
1228 OSL_FAIL( "unexpected stack mode" );
1233 bool WrappedStackingProperty::detectInnerValue( StackMode
& eStackMode
) const
1235 bool bHasDetectableInnerValue
= false;
1236 bool bIsAmbiguous
= false;
1237 eStackMode
= DiagramHelper::getStackMode( m_spChart2ModelContact
->getChart2Diagram()
1238 , bHasDetectableInnerValue
, bIsAmbiguous
);
1239 return bHasDetectableInnerValue
;
1242 void WrappedStackingProperty::setPropertyValue( const Any
& rOuterValue
, const Reference
< beans::XPropertySet
>& /*xInnerPropertySet*/ ) const
1244 bool bNewValue
= false;
1245 if( ! (rOuterValue
>>= bNewValue
) )
1246 throw lang::IllegalArgumentException( "Stacking Properties require boolean values", nullptr, 0 );
1248 StackMode eInnerStackMode
;
1249 bool bHasDetectableInnerValue
= detectInnerValue( eInnerStackMode
);
1251 if( !bHasDetectableInnerValue
)
1253 m_aOuterValue
= rOuterValue
;
1257 if( bNewValue
&& eInnerStackMode
== m_eStackMode
)
1259 if( !bNewValue
&& eInnerStackMode
!= m_eStackMode
)
1262 Reference
< chart2::XDiagram
> xDiagram( m_spChart2ModelContact
->getChart2Diagram() );
1265 StackMode eNewStackMode
= bNewValue
? m_eStackMode
: StackMode::NONE
;
1266 DiagramHelper::setStackMode( xDiagram
, eNewStackMode
);
1270 Any
WrappedStackingProperty::getPropertyValue( const Reference
< beans::XPropertySet
>& /*xInnerPropertySet*/ ) const
1272 StackMode eInnerStackMode
;
1273 if( detectInnerValue( eInnerStackMode
) )
1275 bool bValue
= (eInnerStackMode
== m_eStackMode
);
1278 return m_aOuterValue
;
1281 Any
WrappedStackingProperty::getPropertyDefault( const Reference
< beans::XPropertyState
>& /*xInnerPropertyState*/ ) const
1288 //PROP_DIAGRAM_THREE_D
1289 class WrappedDim3DProperty
: public WrappedProperty
1292 explicit WrappedDim3DProperty(const std::shared_ptr
<Chart2ModelContact
>& spChart2ModelContact
);
1294 virtual void setPropertyValue( const css::uno::Any
& rOuterValue
, const css::uno::Reference
< css::beans::XPropertySet
>& xInnerPropertySet
) const override
;
1296 virtual css::uno::Any
getPropertyValue( const css::uno::Reference
< css::beans::XPropertySet
>& xInnerPropertySet
) const override
;
1298 virtual css::uno::Any
getPropertyDefault( const css::uno::Reference
< css::beans::XPropertyState
>& xInnerPropertyState
) const override
;
1301 std::shared_ptr
< Chart2ModelContact
> m_spChart2ModelContact
;
1302 mutable Any m_aOuterValue
;
1305 WrappedDim3DProperty::WrappedDim3DProperty(const std::shared_ptr
<Chart2ModelContact
>& spChart2ModelContact
)
1306 : WrappedProperty("Dim3D",OUString())
1307 , m_spChart2ModelContact( spChart2ModelContact
)
1310 m_aOuterValue
= WrappedDim3DProperty::getPropertyDefault( nullptr );
1313 void WrappedDim3DProperty::setPropertyValue( const Any
& rOuterValue
, const Reference
< beans::XPropertySet
>& /*xInnerPropertySet*/ ) const
1315 bool bNew3D
= false;
1316 if( ! (rOuterValue
>>= bNew3D
) )
1317 throw lang::IllegalArgumentException( "Property Dim3D requires boolean value", nullptr, 0 );
1319 m_aOuterValue
= rOuterValue
;
1321 Reference
< chart2::XDiagram
> xDiagram( m_spChart2ModelContact
->getChart2Diagram() );
1322 if( !xDiagram
.is() )
1325 bool bOld3D
= DiagramHelper::getDimension( xDiagram
) == 3;
1326 if( bOld3D
!= bNew3D
)
1327 DiagramHelper::setDimension( xDiagram
, bNew3D
? 3 : 2 );
1330 Any
WrappedDim3DProperty::getPropertyValue( const Reference
< beans::XPropertySet
>& /*xInnerPropertySet*/ ) const
1332 Reference
< chart2::XDiagram
> xDiagram( m_spChart2ModelContact
->getChart2Diagram() );
1335 bool b3D
= DiagramHelper::getDimension( xDiagram
) == 3;
1336 m_aOuterValue
<<= b3D
;
1338 return m_aOuterValue
;
1341 Any
WrappedDim3DProperty::getPropertyDefault( const Reference
< beans::XPropertyState
>& /*xInnerPropertyState*/ ) const
1348 //PROP_DIAGRAM_VERTICAL
1349 class WrappedVerticalProperty
: public WrappedProperty
1352 explicit WrappedVerticalProperty(const std::shared_ptr
<Chart2ModelContact
>& spChart2ModelContact
);
1354 virtual void setPropertyValue( const css::uno::Any
& rOuterValue
, const css::uno::Reference
< css::beans::XPropertySet
>& xInnerPropertySet
) const override
;
1356 virtual css::uno::Any
getPropertyValue( const css::uno::Reference
< css::beans::XPropertySet
>& xInnerPropertySet
) const override
;
1358 virtual css::uno::Any
getPropertyDefault( const css::uno::Reference
< css::beans::XPropertyState
>& xInnerPropertyState
) const override
;
1361 std::shared_ptr
< Chart2ModelContact
> m_spChart2ModelContact
;
1362 mutable Any m_aOuterValue
;
1365 WrappedVerticalProperty::WrappedVerticalProperty(const std::shared_ptr
<Chart2ModelContact
>& spChart2ModelContact
)
1366 : WrappedProperty("Vertical",OUString())
1367 , m_spChart2ModelContact( spChart2ModelContact
)
1370 m_aOuterValue
= WrappedVerticalProperty::getPropertyDefault( nullptr );
1373 void WrappedVerticalProperty::setPropertyValue( const Any
& rOuterValue
, const Reference
< beans::XPropertySet
>& /*xInnerPropertySet*/ ) const
1375 bool bNewVertical
= false;
1376 if( ! (rOuterValue
>>= bNewVertical
) )
1377 throw lang::IllegalArgumentException( "Property Vertical requires boolean value", nullptr, 0 );
1379 m_aOuterValue
= rOuterValue
;
1381 Reference
< chart2::XDiagram
> xDiagram( m_spChart2ModelContact
->getChart2Diagram() );
1382 if( !xDiagram
.is() )
1385 bool bFound
= false;
1386 bool bAmbiguous
= false;
1387 bool bOldVertical
= DiagramHelper::getVertical( xDiagram
, bFound
, bAmbiguous
);
1388 if( bFound
&& ( bOldVertical
!= bNewVertical
|| bAmbiguous
) )
1389 DiagramHelper::setVertical( xDiagram
, bNewVertical
);
1392 Any
WrappedVerticalProperty::getPropertyValue( const Reference
< beans::XPropertySet
>& /*xInnerPropertySet*/ ) const
1394 Reference
< chart2::XDiagram
> xDiagram( m_spChart2ModelContact
->getChart2Diagram() );
1397 bool bFound
= false;
1398 bool bAmbiguous
= false;
1399 bool bVertical
= DiagramHelper::getVertical( xDiagram
, bFound
, bAmbiguous
);
1401 m_aOuterValue
<<= bVertical
;
1403 return m_aOuterValue
;
1406 Any
WrappedVerticalProperty::getPropertyDefault( const Reference
< beans::XPropertyState
>& /*xInnerPropertyState*/ ) const
1413 //PROP_DIAGRAM_NUMBER_OF_LINES
1414 class WrappedNumberOfLinesProperty
: public WrappedProperty
1417 explicit WrappedNumberOfLinesProperty(const std::shared_ptr
<Chart2ModelContact
>& spChart2ModelContact
);
1419 virtual void setPropertyValue( const css::uno::Any
& rOuterValue
, const css::uno::Reference
< css::beans::XPropertySet
>& xInnerPropertySet
) const override
;
1421 virtual css::uno::Any
getPropertyValue( const css::uno::Reference
< css::beans::XPropertySet
>& xInnerPropertySet
) const override
;
1423 virtual css::uno::Any
getPropertyDefault( const css::uno::Reference
< css::beans::XPropertyState
>& xInnerPropertyState
) const override
;
1425 protected: //methods
1426 bool detectInnerValue( uno::Any
& rInnerValue
) const;
1429 std::shared_ptr
< Chart2ModelContact
> m_spChart2ModelContact
;
1430 mutable Any m_aOuterValue
;
1433 WrappedNumberOfLinesProperty::WrappedNumberOfLinesProperty(const std::shared_ptr
<Chart2ModelContact
>& spChart2ModelContact
)
1434 : WrappedProperty("NumberOfLines",OUString())
1435 , m_spChart2ModelContact( spChart2ModelContact
)
1436 , m_aOuterValue( getPropertyDefault(nullptr) )
1440 bool WrappedNumberOfLinesProperty::detectInnerValue( uno::Any
& rInnerValue
) const
1442 sal_Int32 nNumberOfLines
= 0;
1443 bool bHasDetectableInnerValue
= false;
1444 Reference
< chart2::XDiagram
> xDiagram( m_spChart2ModelContact
->getChart2Diagram() );
1445 uno::Reference
< chart2::XChartDocument
> xChartDoc( m_spChart2ModelContact
->getChart2Document() );
1446 if( xDiagram
.is() && xChartDoc
.is() )
1448 std::vector
< uno::Reference
< chart2::XDataSeries
> > aSeriesVector(
1449 DiagramHelper::getDataSeriesFromDiagram( xDiagram
) );
1450 if( !aSeriesVector
.empty() )
1452 Reference
< lang::XMultiServiceFactory
> xFact( xChartDoc
->getChartTypeManager(), uno::UNO_QUERY
);
1453 DiagramHelper::tTemplateWithServiceName aTemplateAndService
=
1454 DiagramHelper::getTemplateForDiagram( xDiagram
, xFact
);
1455 if( aTemplateAndService
.second
== "com.sun.star.chart2.template.ColumnWithLine" )
1459 uno::Reference
< beans::XPropertySet
> xProp( aTemplateAndService
.first
, uno::UNO_QUERY
);
1460 xProp
->getPropertyValue( m_aOuterName
) >>= nNumberOfLines
;
1461 bHasDetectableInnerValue
= true;
1463 catch( const uno::Exception
& )
1465 DBG_UNHANDLED_EXCEPTION("chart2");
1470 if(bHasDetectableInnerValue
)
1471 rInnerValue
<<= nNumberOfLines
;
1472 return bHasDetectableInnerValue
;
1475 void WrappedNumberOfLinesProperty::setPropertyValue( const Any
& rOuterValue
, const Reference
< beans::XPropertySet
>& /*xInnerPropertySet*/ ) const
1477 sal_Int32 nNewValue
;
1478 if( ! (rOuterValue
>>= nNewValue
) )
1479 throw lang::IllegalArgumentException( "property NumberOfLines requires sal_Int32 value", nullptr, 0 );
1481 m_aOuterValue
= rOuterValue
;
1483 uno::Reference
< chart2::XChartDocument
> xChartDoc( m_spChart2ModelContact
->getChart2Document() );
1484 Reference
< chart2::XDiagram
> xDiagram( m_spChart2ModelContact
->getChart2Diagram() );
1485 sal_Int32 nDimension
= ::chart::DiagramHelper::getDimension( xDiagram
);
1486 if( xChartDoc
.is() && xDiagram
.is() && nDimension
== 2 )
1488 Reference
< lang::XMultiServiceFactory
> xFact( xChartDoc
->getChartTypeManager(), uno::UNO_QUERY
);
1489 DiagramHelper::tTemplateWithServiceName aTemplateAndService
=
1490 DiagramHelper::getTemplateForDiagram( xDiagram
, xFact
);
1492 uno::Reference
< chart2::XChartTypeTemplate
> xTemplate
;
1493 if( aTemplateAndService
.second
== "com.sun.star.chart2.template.ColumnWithLine" )
1495 if( nNewValue
!= 0 )
1497 xTemplate
.set( aTemplateAndService
.first
);
1500 sal_Int32 nOldValue
= 0;
1501 uno::Reference
< beans::XPropertySet
> xProp( xTemplate
, uno::UNO_QUERY
);
1502 xProp
->getPropertyValue( m_aOuterName
) >>= nOldValue
;
1503 if( nOldValue
== nNewValue
)
1506 catch( const uno::Exception
& )
1508 DBG_UNHANDLED_EXCEPTION("chart2");
1513 xTemplate
.set( xFact
->createInstance("com.sun.star.chart2.template.Column"), uno::UNO_QUERY
);
1516 else if( aTemplateAndService
.second
== "com.sun.star.chart2.template.Column" )
1518 if( nNewValue
== 0 )
1520 xTemplate
.set( xFact
->createInstance( "com.sun.star.chart2.template.ColumnWithLine" ), uno::UNO_QUERY
);
1527 // locked controllers
1528 ControllerLockGuardUNO
aCtrlLockGuard( m_spChart2ModelContact
->getChartModel() );
1529 uno::Reference
< beans::XPropertySet
> xProp( xTemplate
, uno::UNO_QUERY
);
1530 xProp
->setPropertyValue( "NumberOfLines", uno::Any(nNewValue
) );
1531 xTemplate
->changeDiagram( xDiagram
);
1533 catch( const uno::Exception
& )
1535 DBG_UNHANDLED_EXCEPTION("chart2");
1541 Any
WrappedNumberOfLinesProperty::getPropertyValue( const Reference
< beans::XPropertySet
>& /*xInnerPropertySet*/ ) const
1544 if( !detectInnerValue( aRet
) )
1545 aRet
= m_aOuterValue
;
1549 Any
WrappedNumberOfLinesProperty::getPropertyDefault( const Reference
< beans::XPropertyState
>& /*xInnerPropertyState*/ ) const
1552 aRet
<<= sal_Int32( 0 );
1556 //PROP_DIAGRAM_ATTRIBUTED_DATA_POINTS
1557 class WrappedAttributedDataPointsProperty
: public WrappedProperty
1560 explicit WrappedAttributedDataPointsProperty(const std::shared_ptr
<Chart2ModelContact
>& spChart2ModelContact
);
1562 virtual void setPropertyValue( const css::uno::Any
& rOuterValue
, const css::uno::Reference
< css::beans::XPropertySet
>& xInnerPropertySet
) const override
;
1564 virtual css::uno::Any
getPropertyValue( const css::uno::Reference
< css::beans::XPropertySet
>& xInnerPropertySet
) const override
;
1566 virtual css::uno::Any
getPropertyDefault( const css::uno::Reference
< css::beans::XPropertyState
>& xInnerPropertyState
) const override
;
1569 std::shared_ptr
< Chart2ModelContact
> m_spChart2ModelContact
;
1570 mutable Any m_aOuterValue
;
1573 WrappedAttributedDataPointsProperty::WrappedAttributedDataPointsProperty(const std::shared_ptr
<Chart2ModelContact
>& spChart2ModelContact
)
1574 : WrappedProperty("AttributedDataPoints",OUString())
1575 , m_spChart2ModelContact( spChart2ModelContact
)
1578 m_aOuterValue
= WrappedAttributedDataPointsProperty::getPropertyDefault( nullptr );
1581 void WrappedAttributedDataPointsProperty::setPropertyValue( const Any
& rOuterValue
, const Reference
< beans::XPropertySet
>& /*xInnerPropertySet*/ ) const
1583 uno::Sequence
< uno::Sequence
< sal_Int32
> > aNewValue
;
1584 if( ! (rOuterValue
>>= aNewValue
) )
1585 throw lang::IllegalArgumentException( "Property AttributedDataPoints requires value of type uno::Sequence< uno::Sequence< sal_Int32 > >", nullptr, 0 );
1587 m_aOuterValue
= rOuterValue
;
1589 Reference
< chart2::XDiagram
> xDiagram( m_spChart2ModelContact
->getChart2Diagram() );
1590 Reference
< beans::XPropertySet
> xDiaProp( xDiagram
, uno::UNO_QUERY
);
1592 if( xDiagram
.is() && xDiaProp
.is())
1594 std::vector
< Reference
< chart2::XDataSeries
> > aSeriesVector(
1595 ::chart::DiagramHelper::getDataSeriesFromDiagram( xDiagram
) );
1597 for (auto const& series
: aSeriesVector
)
1599 Reference
< beans::XPropertySet
> xProp(series
, uno::UNO_QUERY
);
1603 if( i
< aNewValue
.getLength() )
1604 aVal
<<= aNewValue
[i
];
1607 //set empty sequence
1608 uno::Sequence
< sal_Int32
> aSeq
;
1611 xProp
->setPropertyValue( "AttributedDataPoints", aVal
);
1618 Any
WrappedAttributedDataPointsProperty::getPropertyValue( const Reference
< beans::XPropertySet
>& /*xInnerPropertySet*/ ) const
1620 Reference
< chart2::XDiagram
> xDiagram( m_spChart2ModelContact
->getChart2Diagram() );
1621 Reference
< beans::XPropertySet
> xDiaProp( xDiagram
, uno::UNO_QUERY
);
1623 if( xDiagram
.is() && xDiaProp
.is())
1625 std::vector
< Reference
< chart2::XDataSeries
> > aSeriesVector(
1626 ::chart::DiagramHelper::getDataSeriesFromDiagram( xDiagram
) );
1628 uno::Sequence
< uno::Sequence
< sal_Int32
> > aResult( aSeriesVector
.size() );
1631 for (auto const& series
: aSeriesVector
)
1633 Reference
< beans::XPropertySet
> xProp(series
, uno::UNO_QUERY
);
1637 xProp
->getPropertyValue("AttributedDataPoints"));
1638 uno::Sequence
< sal_Int32
> aSeq
;
1640 aResult
[ i
] = aSeq
;
1644 m_aOuterValue
<<= aResult
;
1646 return m_aOuterValue
;
1649 Any
WrappedAttributedDataPointsProperty::getPropertyDefault( const Reference
< beans::XPropertyState
>& /*xInnerPropertyState*/ ) const
1652 uno::Sequence
< uno::Sequence
< sal_Int32
> > aSeq
;
1657 //PROP_DIAGRAM_SOLIDTYPE
1658 class WrappedSolidTypeProperty
: public WrappedProperty
1661 explicit WrappedSolidTypeProperty(const std::shared_ptr
<Chart2ModelContact
>& spChart2ModelContact
);
1663 virtual void setPropertyValue( const css::uno::Any
& rOuterValue
, const css::uno::Reference
< css::beans::XPropertySet
>& xInnerPropertySet
) const override
;
1665 virtual css::uno::Any
getPropertyValue( const css::uno::Reference
< css::beans::XPropertySet
>& xInnerPropertySet
) const override
;
1667 virtual css::uno::Any
getPropertyDefault( const css::uno::Reference
< css::beans::XPropertyState
>& xInnerPropertyState
) const override
;
1670 std::shared_ptr
< Chart2ModelContact
> m_spChart2ModelContact
;
1671 mutable Any m_aOuterValue
;
1674 WrappedSolidTypeProperty::WrappedSolidTypeProperty(const std::shared_ptr
<Chart2ModelContact
>& spChart2ModelContact
)
1675 : WrappedProperty( "SolidType", OUString() )
1676 , m_spChart2ModelContact( spChart2ModelContact
)
1679 m_aOuterValue
= WrappedSolidTypeProperty::getPropertyDefault( nullptr );
1682 void WrappedSolidTypeProperty::setPropertyValue( const Any
& rOuterValue
, const Reference
< beans::XPropertySet
>& /*xInnerPropertySet*/ ) const
1684 sal_Int32 nNewSolidType
= css::chart::ChartSolidType::RECTANGULAR_SOLID
;
1685 if( ! (rOuterValue
>>= nNewSolidType
) )
1686 throw lang::IllegalArgumentException( "Property SolidType requires integer value", nullptr, 0 );
1688 m_aOuterValue
= rOuterValue
;
1690 Reference
< chart2::XDiagram
> xDiagram( m_spChart2ModelContact
->getChart2Diagram() );
1691 if( !xDiagram
.is() )
1694 bool bFound
= false;
1695 bool bAmbiguous
= false;
1696 sal_Int32 nOldSolidType
= DiagramHelper::getGeometry3D( xDiagram
, bFound
, bAmbiguous
);
1697 if( bFound
&& ( nOldSolidType
!= nNewSolidType
|| bAmbiguous
) )
1698 DiagramHelper::setGeometry3D( xDiagram
, nNewSolidType
);
1701 Any
WrappedSolidTypeProperty::getPropertyValue( const Reference
< beans::XPropertySet
>& /*xInnerPropertySet*/ ) const
1703 Reference
< chart2::XDiagram
> xDiagram( m_spChart2ModelContact
->getChart2Diagram() );
1706 bool bFound
= false;
1707 bool bAmbiguous
= false;
1708 sal_Int32 nGeometry
= DiagramHelper::getGeometry3D( xDiagram
, bFound
, bAmbiguous
);
1710 m_aOuterValue
<<= nGeometry
;
1712 return m_aOuterValue
;
1715 Any
WrappedSolidTypeProperty::getPropertyDefault( const Reference
< beans::XPropertyState
>& /*xInnerPropertyState*/ ) const
1717 return uno::Any( css::chart::ChartSolidType::RECTANGULAR_SOLID
);
1720 class WrappedAutomaticSizeProperty
: public WrappedProperty
1723 WrappedAutomaticSizeProperty();
1725 virtual void setPropertyValue( const css::uno::Any
& rOuterValue
, const css::uno::Reference
< css::beans::XPropertySet
>& xInnerPropertySet
) const override
;
1727 virtual css::uno::Any
getPropertyValue( const css::uno::Reference
< css::beans::XPropertySet
>& xInnerPropertySet
) const override
;
1729 virtual css::uno::Any
getPropertyDefault( const css::uno::Reference
< css::beans::XPropertyState
>& xInnerPropertyState
) const override
;
1732 WrappedAutomaticSizeProperty::WrappedAutomaticSizeProperty()
1733 : WrappedProperty( "AutomaticSize", OUString() )
1737 void WrappedAutomaticSizeProperty::setPropertyValue( const Any
& rOuterValue
, const Reference
< beans::XPropertySet
>& xInnerPropertySet
) const
1739 if( xInnerPropertySet
.is() )
1741 bool bNewValue
= true;
1742 if( ! (rOuterValue
>>= bNewValue
) )
1743 throw lang::IllegalArgumentException( "Property AutomaticSize requires value of type boolean", nullptr, 0 );
1749 Any
aRelativeSize( xInnerPropertySet
->getPropertyValue( "RelativeSize" ) );
1750 if( aRelativeSize
.hasValue() )
1751 xInnerPropertySet
->setPropertyValue( "RelativeSize", Any() );
1754 catch( const uno::Exception
& )
1756 DBG_UNHANDLED_EXCEPTION("chart2");
1761 Any
WrappedAutomaticSizeProperty::getPropertyValue( const Reference
< beans::XPropertySet
>& xInnerPropertySet
) const
1763 Any
aRet( getPropertyDefault( Reference
< beans::XPropertyState
>( xInnerPropertySet
, uno::UNO_QUERY
) ) );
1764 if( xInnerPropertySet
.is() )
1766 Any
aRelativeSize( xInnerPropertySet
->getPropertyValue( "RelativeSize" ) );
1767 if( !aRelativeSize
.hasValue() )
1773 Any
WrappedAutomaticSizeProperty::getPropertyDefault( const Reference
< beans::XPropertyState
>& /*xInnerPropertyState*/ ) const
1780 //PROP_DIAGRAM_INCLUDE_HIDDEN_CELLS
1781 class WrappedIncludeHiddenCellsProperty
: public WrappedProperty
1784 explicit WrappedIncludeHiddenCellsProperty(const std::shared_ptr
<Chart2ModelContact
>& spChart2ModelContact
);
1786 virtual void setPropertyValue( const css::uno::Any
& rOuterValue
, const css::uno::Reference
< css::beans::XPropertySet
>& xInnerPropertySet
) const override
;
1787 virtual Any
getPropertyValue(const Reference
<beans::XPropertySet
>& xInnerPropertySet
) const override
;
1790 std::shared_ptr
< Chart2ModelContact
> m_spChart2ModelContact
;
1793 WrappedIncludeHiddenCellsProperty::WrappedIncludeHiddenCellsProperty(const std::shared_ptr
<Chart2ModelContact
>& spChart2ModelContact
)
1794 : WrappedProperty("IncludeHiddenCells","IncludeHiddenCells")
1795 , m_spChart2ModelContact( spChart2ModelContact
)
1799 void WrappedIncludeHiddenCellsProperty::setPropertyValue( const Any
& rOuterValue
, const Reference
< beans::XPropertySet
>& /*xInnerPropertySet*/ ) const
1801 bool bNewValue
= false;
1802 if( ! (rOuterValue
>>= bNewValue
) )
1803 throw lang::IllegalArgumentException( "Property IncludeHiddenCells requires boolean value", nullptr, 0 );
1805 ChartModelHelper::setIncludeHiddenCells( bNewValue
, *m_spChart2ModelContact
->getModel() );
1808 Any
WrappedIncludeHiddenCellsProperty::getPropertyValue( const Reference
< beans::XPropertySet
>& /*xInnerPropertySet*/ ) const
1810 bool bValue
= ChartModelHelper::isIncludeHiddenCells( m_spChart2ModelContact
->getChartModel() );
1811 return uno::Any(bValue
);
1814 // ____ XDiagramProvider ____
1815 Reference
< chart2::XDiagram
> SAL_CALL
DiagramWrapper::getDiagram()
1817 return m_spChart2ModelContact
->getChart2Diagram();
1820 void SAL_CALL
DiagramWrapper::setDiagram(
1821 const Reference
< chart2::XDiagram
>& /*xDiagram*/ )
1823 //@todo: remove this method from interface
1824 OSL_FAIL("DiagramWrapper::setDiagram is not implemented, should be removed and not be called" );
1827 Reference
< beans::XPropertySet
> DiagramWrapper::getInnerPropertySet()
1829 return Reference
< beans::XPropertySet
>( m_spChart2ModelContact
->getChart2Diagram(), uno::UNO_QUERY
);
1832 const Sequence
< beans::Property
>& DiagramWrapper::getPropertySequence()
1834 return *StaticDiagramWrapperPropertyArray::get();
1837 std::vector
< std::unique_ptr
<WrappedProperty
> > DiagramWrapper::createWrappedProperties()
1839 std::vector
< std::unique_ptr
<WrappedProperty
> > aWrappedProperties
;
1841 WrappedAxisAndGridExistenceProperties::addWrappedProperties( aWrappedProperties
, m_spChart2ModelContact
);
1842 WrappedAxisTitleExistenceProperties::addWrappedProperties( aWrappedProperties
, m_spChart2ModelContact
);
1843 WrappedAxisLabelExistenceProperties::addWrappedProperties( aWrappedProperties
, m_spChart2ModelContact
);
1844 WrappedSceneProperty::addWrappedProperties( aWrappedProperties
, m_spChart2ModelContact
);
1845 WrappedIgnoreProperties::addIgnoreFillProperties( aWrappedProperties
);
1846 WrappedIgnoreProperties::addIgnoreLineProperties( aWrappedProperties
);
1847 WrappedStatisticProperties::addWrappedPropertiesForDiagram( aWrappedProperties
, m_spChart2ModelContact
);
1848 WrappedSymbolProperties::addWrappedPropertiesForDiagram( aWrappedProperties
, m_spChart2ModelContact
);
1849 WrappedDataCaptionProperties::addWrappedPropertiesForDiagram( aWrappedProperties
, m_spChart2ModelContact
);
1850 WrappedSplineProperties::addWrappedProperties( aWrappedProperties
, m_spChart2ModelContact
);
1851 WrappedStockProperties::addWrappedProperties( aWrappedProperties
, m_spChart2ModelContact
);
1852 WrappedAutomaticPositionProperties::addWrappedProperties( aWrappedProperties
);
1854 aWrappedProperties
.emplace_back( new WrappedDataRowSourceProperty( m_spChart2ModelContact
) );
1855 aWrappedProperties
.emplace_back( new WrappedStackingProperty( StackMode::YStacked
,m_spChart2ModelContact
) );
1856 aWrappedProperties
.emplace_back( new WrappedStackingProperty( StackMode::YStackedPercent
, m_spChart2ModelContact
) );
1857 aWrappedProperties
.emplace_back( new WrappedStackingProperty( StackMode::ZStacked
, m_spChart2ModelContact
) );
1858 aWrappedProperties
.emplace_back( new WrappedDim3DProperty( m_spChart2ModelContact
) );
1859 aWrappedProperties
.emplace_back( new WrappedVerticalProperty( m_spChart2ModelContact
) );
1860 aWrappedProperties
.emplace_back( new WrappedNumberOfLinesProperty( m_spChart2ModelContact
) );
1861 aWrappedProperties
.emplace_back( new WrappedAttributedDataPointsProperty( m_spChart2ModelContact
) );
1862 aWrappedProperties
.emplace_back( new WrappedProperty( "StackedBarsConnected", "ConnectBars" ) );
1863 aWrappedProperties
.emplace_back( new WrappedSolidTypeProperty( m_spChart2ModelContact
) );
1864 aWrappedProperties
.emplace_back( new WrappedAutomaticSizeProperty() );
1865 aWrappedProperties
.emplace_back( new WrappedIncludeHiddenCellsProperty( m_spChart2ModelContact
) );
1867 return aWrappedProperties
;
1870 OUString SAL_CALL
DiagramWrapper::getImplementationName()
1872 return "com.sun.star.comp.chart.Diagram";
1875 sal_Bool SAL_CALL
DiagramWrapper::supportsService( const OUString
& rServiceName
)
1877 return cppu::supportsService(this, rServiceName
);
1880 css::uno::Sequence
< OUString
> SAL_CALL
DiagramWrapper::getSupportedServiceNames()
1883 "com.sun.star.chart.Diagram",
1884 "com.sun.star.xml.UserDefinedAttributesSupplier",
1885 "com.sun.star.chart.StackableDiagram",
1886 "com.sun.star.chart.ChartAxisXSupplier",
1887 "com.sun.star.chart.ChartAxisYSupplier",
1888 "com.sun.star.chart.ChartAxisZSupplier",
1889 "com.sun.star.chart.ChartTwoAxisXSupplier",
1890 "com.sun.star.chart.ChartTwoAxisYSupplier"
1894 } // namespace wrapper
1895 } // namespace chart
1897 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */