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