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