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