Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 :
21 : #include "ChartTypeHelper.hxx"
22 : #include "DiagramHelper.hxx"
23 : #include "DataSeriesHelper.hxx"
24 : #include "macros.hxx"
25 : #include "servicenames_charttypes.hxx"
26 :
27 : #include <com/sun/star/beans/XPropertySet.hpp>
28 : #include <com/sun/star/chart/DataLabelPlacement.hpp>
29 : #include <com/sun/star/chart2/XDataSeriesContainer.hpp>
30 : #include <com/sun/star/chart/MissingValueTreatment.hpp>
31 :
32 : //.............................................................................
33 : using namespace ::com::sun::star;
34 : using namespace ::com::sun::star::chart2;
35 :
36 : //.............................................................................
37 : namespace chart
38 : {
39 :
40 0 : bool ChartTypeHelper::isSupportingAxisSideBySide(
41 : const uno::Reference< chart2::XChartType >& xChartType, sal_Int32 nDimensionCount )
42 : {
43 0 : bool bResult = false;
44 :
45 0 : if( xChartType.is() &&
46 : nDimensionCount < 3 )
47 : {
48 0 : bool bFound=false;
49 0 : bool bAmbiguous=false;
50 0 : StackMode eStackMode = DiagramHelper::getStackModeFromChartType( xChartType, bFound, bAmbiguous, 0 );
51 0 : if( eStackMode == StackMode_NONE && !bAmbiguous )
52 : {
53 0 : rtl::OUString aChartTypeName = xChartType->getChartType();
54 0 : bResult = ( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_COLUMN) ||
55 0 : aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_BAR) );
56 : }
57 : }
58 :
59 0 : return bResult;
60 : }
61 :
62 0 : sal_Bool ChartTypeHelper::isSupportingGeometryProperties( const uno::Reference< XChartType >& xChartType, sal_Int32 nDimensionCount )
63 : {
64 : //form tab only for 3D-bar and 3D-column charts.
65 :
66 : //@todo ask charttype itself --> need model change first
67 0 : if(xChartType.is())
68 : {
69 0 : if(nDimensionCount==3)
70 : {
71 0 : rtl::OUString aChartTypeName = xChartType->getChartType();
72 0 : if( aChartTypeName.equals(CHART2_SERVICE_NAME_CHARTTYPE_BAR) )
73 0 : return sal_True;
74 0 : if( aChartTypeName.equals(CHART2_SERVICE_NAME_CHARTTYPE_COLUMN) )
75 0 : return sal_True;
76 : }
77 : }
78 0 : return sal_False;
79 : }
80 :
81 123 : sal_Bool ChartTypeHelper::isSupportingStatisticProperties( const uno::Reference< XChartType >& xChartType, sal_Int32 nDimensionCount )
82 : {
83 : //3D charts, pie, net and stock do not support statistic properties
84 :
85 : //@todo ask charttype itself (and series? --> stock chart?) --> need model change first
86 123 : if(xChartType.is())
87 : {
88 123 : if(nDimensionCount==3)
89 0 : return sal_False;
90 :
91 123 : rtl::OUString aChartTypeName = xChartType->getChartType();
92 123 : if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_PIE) )
93 0 : return sal_False;
94 123 : if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_NET) )
95 0 : return sal_False;
96 123 : if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_FILLED_NET) )
97 0 : return sal_False;
98 123 : if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK) )
99 0 : return sal_False;
100 123 : if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_BUBBLE) ) //todo: BubbleChart support error bars and trend lines
101 0 : return sal_False;
102 : }
103 123 : return sal_True;
104 : }
105 :
106 0 : sal_Bool ChartTypeHelper::isSupportingRegressionProperties( const uno::Reference< XChartType >& xChartType, sal_Int32 nDimensionCount )
107 : {
108 : // note: old chart: only scatter chart
109 0 : return isSupportingStatisticProperties( xChartType, nDimensionCount );
110 : }
111 :
112 0 : sal_Bool ChartTypeHelper::isSupportingAreaProperties( const uno::Reference< XChartType >& xChartType, sal_Int32 nDimensionCount )
113 : {
114 : //2D line charts, net and stock do not support area properties
115 :
116 : //@todo ask charttype itself --> need model change first
117 0 : if(xChartType.is())
118 : {
119 0 : if(nDimensionCount==2)
120 : {
121 0 : rtl::OUString aChartTypeName = xChartType->getChartType();
122 0 : if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_LINE) )
123 0 : return sal_False;
124 0 : if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_SCATTER) )
125 0 : return sal_False;
126 0 : if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_NET) )
127 0 : return sal_False;
128 0 : if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK) )
129 0 : return sal_False;
130 : }
131 : }
132 0 : return sal_True;
133 : }
134 :
135 0 : sal_Bool ChartTypeHelper::isSupportingSymbolProperties( const uno::Reference< XChartType >& xChartType, sal_Int32 nDimensionCount )
136 : {
137 : //2D line charts, 2D scatter charts and 2D net charts do support symbols
138 :
139 : //@todo ask charttype itself --> need model change first
140 0 : if(xChartType.is())
141 : {
142 0 : if(nDimensionCount==3)
143 0 : return sal_False;
144 :
145 0 : rtl::OUString aChartTypeName = xChartType->getChartType();
146 0 : if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_LINE) )
147 0 : return sal_True;
148 0 : if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_SCATTER) )
149 0 : return sal_True;
150 0 : if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_NET) )
151 0 : return sal_True;
152 : }
153 0 : return sal_False;
154 : }
155 :
156 287 : sal_Bool ChartTypeHelper::isSupportingMainAxis( const uno::Reference< XChartType >& xChartType, sal_Int32 nDimensionCount, sal_Int32 nDimensionIndex )
157 : {
158 : //pie charts do not support axis at all
159 : //no 3rd axis for 2D charts
160 :
161 : //@todo ask charttype itself --> need model change first
162 287 : if(xChartType.is())
163 : {
164 287 : rtl::OUString aChartTypeName = xChartType->getChartType();
165 287 : if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_PIE) )
166 0 : return sal_False;
167 :
168 287 : if( nDimensionIndex == 2 )
169 41 : return nDimensionCount == 3;
170 : }
171 246 : return sal_True;
172 : }
173 :
174 82 : sal_Bool ChartTypeHelper::isSupportingSecondaryAxis( const uno::Reference< XChartType >& xChartType, sal_Int32 nDimensionCount, sal_Int32 /*nDimensionIndex*/ )
175 : {
176 : //3D, pie and net charts do not support a secondary axis at all
177 :
178 : //@todo ask charttype itself --> need model change first
179 82 : if(xChartType.is())
180 : {
181 82 : if(nDimensionCount==3)
182 0 : return sal_False;
183 :
184 82 : rtl::OUString aChartTypeName = xChartType->getChartType();
185 82 : if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_PIE) )
186 0 : return sal_False;
187 82 : if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_NET) )
188 0 : return sal_False;
189 82 : if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_FILLED_NET) )
190 0 : return sal_False;
191 : }
192 82 : return sal_True;
193 : }
194 :
195 0 : sal_Bool ChartTypeHelper::isSupportingOverlapAndGapWidthProperties(
196 : const uno::Reference< XChartType >& xChartType, sal_Int32 nDimensionCount )
197 : {
198 : //2D bar charts do support a this special properties
199 :
200 : //@todo ask charttype itself --> need model change first
201 0 : if(xChartType.is())
202 : {
203 0 : if(nDimensionCount==3)
204 0 : return sal_False;
205 :
206 0 : rtl::OUString aChartTypeName = xChartType->getChartType();
207 0 : if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_COLUMN) )
208 0 : return sal_True;
209 0 : if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_BAR) )
210 0 : return sal_True;
211 : }
212 0 : return sal_False;
213 : }
214 :
215 0 : sal_Bool ChartTypeHelper::isSupportingBarConnectors(
216 : const uno::Reference< chart2::XChartType >& xChartType, sal_Int32 nDimensionCount )
217 : {
218 : //2D bar charts with stacked series support this
219 :
220 : //@todo ask charttype itself --> need model change first
221 0 : if(xChartType.is())
222 : {
223 0 : if(nDimensionCount==3)
224 0 : return sal_False;
225 :
226 0 : bool bFound=false;
227 0 : bool bAmbiguous=false;
228 0 : StackMode eStackMode = DiagramHelper::getStackModeFromChartType( xChartType, bFound, bAmbiguous, 0 );
229 0 : if( eStackMode != StackMode_Y_STACKED || bAmbiguous )
230 0 : return sal_False;
231 :
232 0 : rtl::OUString aChartTypeName = xChartType->getChartType();
233 0 : if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_COLUMN) )
234 0 : return sal_True;
235 0 : if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_BAR) )
236 0 : return sal_True; // note: old chart was false here
237 : }
238 0 : return sal_False;
239 : }
240 :
241 123 : uno::Sequence < sal_Int32 > ChartTypeHelper::getSupportedLabelPlacements( const uno::Reference< chart2::XChartType >& xChartType
242 : , sal_Int32 nDimensionCount, sal_Bool bSwapXAndY
243 : , const uno::Reference< chart2::XDataSeries >& xSeries )
244 : {
245 : (void)nDimensionCount;
246 :
247 123 : uno::Sequence < sal_Int32 > aRet;
248 123 : if( !xChartType.is() )
249 : return aRet;
250 :
251 123 : rtl::OUString aChartTypeName = xChartType->getChartType();
252 123 : if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_PIE) )
253 : {
254 0 : bool bDonut = false;
255 0 : uno::Reference< beans::XPropertySet > xChartTypeProp( xChartType, uno::UNO_QUERY_THROW );
256 0 : if(xChartTypeProp.is())
257 0 : xChartTypeProp->getPropertyValue( C2U("UseRings")) >>= bDonut;
258 :
259 0 : if(!bDonut)
260 : {
261 0 : aRet.realloc(4);
262 0 : sal_Int32* pSeq = aRet.getArray();
263 0 : *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::AVOID_OVERLAP;
264 0 : *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::OUTSIDE;
265 0 : *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::INSIDE;
266 0 : *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::CENTER;
267 : }
268 : else
269 : {
270 0 : aRet.realloc(1);
271 0 : sal_Int32* pSeq = aRet.getArray();
272 0 : *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::CENTER;
273 0 : }
274 : }
275 738 : else if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_SCATTER)
276 369 : || aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_LINE)
277 369 : || aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_BUBBLE)
278 : )
279 : {
280 0 : aRet.realloc(5);
281 0 : sal_Int32* pSeq = aRet.getArray();
282 0 : *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::TOP;
283 0 : *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::BOTTOM;
284 0 : *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::LEFT;
285 0 : *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::RIGHT;
286 0 : *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::CENTER;
287 : }
288 246 : else if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_COLUMN)
289 123 : || aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_BAR) )
290 : {
291 :
292 123 : bool bStacked = false;
293 : {
294 123 : uno::Reference< beans::XPropertySet > xSeriesProp( xSeries, uno::UNO_QUERY );
295 123 : chart2::StackingDirection eStacking = chart2::StackingDirection_NO_STACKING;
296 123 : xSeriesProp->getPropertyValue( C2U("StackingDirection") ) >>= eStacking;
297 123 : bStacked = (chart2::StackingDirection_Y_STACKING == eStacking);
298 : }
299 :
300 123 : aRet.realloc( bStacked ? 3 : 6 );
301 123 : sal_Int32* pSeq = aRet.getArray();
302 123 : if(!bStacked)
303 : {
304 123 : if(bSwapXAndY)
305 : {
306 0 : *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::RIGHT;
307 0 : *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::LEFT;
308 : }
309 : else
310 : {
311 123 : *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::TOP;
312 123 : *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::BOTTOM;
313 : }
314 : }
315 123 : *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::CENTER;
316 123 : if(!bStacked)
317 123 : *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::OUTSIDE;
318 123 : *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::INSIDE;
319 123 : *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::NEAR_ORIGIN;
320 : }
321 0 : else if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_AREA) )
322 : {
323 0 : aRet.realloc(1);
324 0 : sal_Int32* pSeq = aRet.getArray();
325 0 : *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::TOP;
326 : }
327 0 : else if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_NET) )
328 : {
329 0 : aRet.realloc(6);
330 0 : sal_Int32* pSeq = aRet.getArray();
331 0 : *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::OUTSIDE;
332 0 : *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::TOP;
333 0 : *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::BOTTOM;
334 0 : *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::LEFT;
335 0 : *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::RIGHT;
336 0 : *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::CENTER;
337 : }
338 0 : else if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_FILLED_NET) )
339 : {
340 0 : aRet.realloc(1);
341 0 : sal_Int32* pSeq = aRet.getArray();
342 0 : *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::OUTSIDE;
343 : }
344 0 : else if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK) )
345 : {
346 0 : aRet.realloc( 1 );
347 0 : sal_Int32* pSeq = aRet.getArray();
348 0 : *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::OUTSIDE;
349 : }
350 : else
351 : {
352 : OSL_FAIL( "unknown charttype" );
353 : }
354 :
355 123 : return aRet;
356 : }
357 :
358 0 : sal_Bool ChartTypeHelper::isSupportingRightAngledAxes( const uno::Reference< chart2::XChartType >& xChartType )
359 : {
360 0 : if(xChartType.is())
361 : {
362 0 : rtl::OUString aChartTypeName = xChartType->getChartType();
363 0 : if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_PIE) )
364 0 : return sal_False;
365 : }
366 0 : return sal_True;
367 : }
368 :
369 0 : bool ChartTypeHelper::isSupportingStartingAngle( const uno::Reference< chart2::XChartType >& xChartType )
370 : {
371 0 : if(xChartType.is())
372 : {
373 0 : rtl::OUString aChartTypeName = xChartType->getChartType();
374 0 : if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_PIE) )
375 0 : return true;
376 : }
377 0 : return false;
378 : }
379 0 : bool ChartTypeHelper::isSupportingBaseValue( const uno::Reference< chart2::XChartType >& xChartType )
380 : {
381 0 : if(xChartType.is())
382 : {
383 0 : rtl::OUString aChartTypeName = xChartType->getChartType();
384 0 : if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_COLUMN)
385 0 : || aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_BAR)
386 0 : || aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_AREA)
387 : )
388 0 : return true;
389 : }
390 0 : return false;
391 : }
392 :
393 0 : bool ChartTypeHelper::isSupportingAxisPositioning( const uno::Reference< chart2::XChartType >& xChartType, sal_Int32 nDimensionCount, sal_Int32 nDimensionIndex )
394 : {
395 0 : if(xChartType.is())
396 : {
397 0 : rtl::OUString aChartTypeName = xChartType->getChartType();
398 0 : if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_NET) )
399 0 : return false;
400 0 : if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_FILLED_NET) )
401 0 : return false;
402 : }
403 0 : if( nDimensionCount==3 )
404 0 : return nDimensionIndex<2;
405 0 : return true;
406 : }
407 :
408 451 : bool ChartTypeHelper::isSupportingDateAxis( const uno::Reference< chart2::XChartType >& xChartType, sal_Int32 /*nDimensionCount*/, sal_Int32 nDimensionIndex )
409 : {
410 451 : if( nDimensionIndex!=0 )
411 41 : return false;
412 410 : if( xChartType.is() )
413 : {
414 410 : sal_Int32 nType = ChartTypeHelper::getAxisType( xChartType, nDimensionIndex );
415 410 : if( nType != AxisType::CATEGORY )
416 0 : return false;
417 410 : rtl::OUString aChartTypeName = xChartType->getChartType();
418 410 : if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_PIE) )
419 0 : return false;
420 410 : if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_NET) )
421 0 : return false;
422 410 : if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_FILLED_NET) )
423 0 : return false;
424 : }
425 410 : return true;
426 : }
427 :
428 41 : bool ChartTypeHelper::shiftCategoryPosAtXAxisPerDefault( const uno::Reference< chart2::XChartType >& xChartType )
429 : {
430 41 : if(xChartType.is())
431 : {
432 41 : rtl::OUString aChartTypeName = xChartType->getChartType();
433 82 : if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_COLUMN)
434 41 : || aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_BAR)
435 41 : || aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK) )
436 41 : return true;
437 : }
438 0 : return false;
439 : }
440 :
441 0 : bool ChartTypeHelper::noBordersForSimpleScheme( const uno::Reference< chart2::XChartType >& xChartType )
442 : {
443 0 : if(xChartType.is())
444 : {
445 0 : rtl::OUString aChartTypeName = xChartType->getChartType();
446 0 : if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_PIE) )
447 0 : return sal_True;
448 : }
449 0 : return sal_False;
450 : }
451 :
452 42 : sal_Int32 ChartTypeHelper::getDefaultDirectLightColor( bool bSimple, const uno::Reference< chart2::XChartType >& xChartType )
453 : {
454 42 : sal_Int32 nRet = static_cast< sal_Int32 >( 0x808080 ); // grey
455 42 : if( xChartType .is() )
456 : {
457 41 : rtl::OUString aChartType = xChartType->getChartType();
458 41 : if( aChartType.equals(CHART2_SERVICE_NAME_CHARTTYPE_PIE) )
459 : {
460 0 : if( bSimple )
461 0 : nRet = static_cast< sal_Int32 >( 0x333333 ); // grey80
462 : else
463 0 : nRet = static_cast< sal_Int32 >( 0xb3b3b3 ); // grey30
464 : }
465 164 : else if( aChartType.equals(CHART2_SERVICE_NAME_CHARTTYPE_LINE)
466 123 : || aChartType.equals(CHART2_SERVICE_NAME_CHARTTYPE_SCATTER) )
467 0 : nRet = static_cast< sal_Int32 >( 0x666666 ); // grey60
468 : }
469 42 : return nRet;
470 : }
471 :
472 42 : sal_Int32 ChartTypeHelper::getDefaultAmbientLightColor( bool bSimple, const uno::Reference< chart2::XChartType >& xChartType )
473 : {
474 42 : sal_Int32 nRet = static_cast< sal_Int32 >( 0x999999 ); // grey40
475 42 : if( xChartType .is() )
476 : {
477 41 : rtl::OUString aChartType = xChartType->getChartType();
478 41 : if( aChartType.equals(CHART2_SERVICE_NAME_CHARTTYPE_PIE) )
479 : {
480 0 : if( bSimple )
481 0 : nRet = static_cast< sal_Int32 >( 0xcccccc ); // grey20
482 : else
483 0 : nRet = static_cast< sal_Int32 >( 0x666666 ); // grey60
484 41 : }
485 : }
486 42 : return nRet;
487 : }
488 :
489 1 : drawing::Direction3D ChartTypeHelper::getDefaultSimpleLightDirection( const uno::Reference< chart2::XChartType >& xChartType )
490 : {
491 1 : drawing::Direction3D aRet(0.0, 0.0, 1.0);
492 1 : if( xChartType .is() )
493 : {
494 0 : rtl::OUString aChartType = xChartType->getChartType();
495 0 : if( aChartType.equals(CHART2_SERVICE_NAME_CHARTTYPE_PIE) )
496 0 : aRet = drawing::Direction3D(0.0, 0.8, 0.5);
497 0 : else if( aChartType.equals(CHART2_SERVICE_NAME_CHARTTYPE_LINE)
498 0 : || aChartType.equals(CHART2_SERVICE_NAME_CHARTTYPE_SCATTER) )
499 0 : aRet = drawing::Direction3D(0.9, 0.5, 0.05);
500 : }
501 1 : return aRet;
502 : }
503 :
504 41 : drawing::Direction3D ChartTypeHelper::getDefaultRealisticLightDirection( const uno::Reference< chart2::XChartType >& xChartType )
505 : {
506 41 : drawing::Direction3D aRet(0.0, 0.0, 1.0);
507 41 : if( xChartType .is() )
508 : {
509 41 : rtl::OUString aChartType = xChartType->getChartType();
510 41 : if( aChartType.equals(CHART2_SERVICE_NAME_CHARTTYPE_PIE) )
511 0 : aRet = drawing::Direction3D(0.6, 0.6, 0.6);
512 164 : else if( aChartType.equals(CHART2_SERVICE_NAME_CHARTTYPE_LINE)
513 123 : || aChartType.equals(CHART2_SERVICE_NAME_CHARTTYPE_SCATTER) )
514 0 : aRet = drawing::Direction3D(0.9, 0.5, 0.05);
515 : }
516 41 : return aRet;
517 : }
518 :
519 410 : sal_Int32 ChartTypeHelper::getAxisType( const uno::Reference<
520 : XChartType >& xChartType, sal_Int32 nDimensionIndex )
521 : {
522 : //retruned is a constant from constant group ::com::sun::star::chart2::AxisType
523 :
524 : //@todo ask charttype itself --> need model change first
525 410 : if(!xChartType.is())
526 0 : return AxisType::CATEGORY;
527 :
528 410 : rtl::OUString aChartTypeName = xChartType->getChartType();
529 410 : if(2==nDimensionIndex)//z-axis
530 0 : return AxisType::SERIES;
531 410 : if(1==nDimensionIndex)//y-axis
532 0 : return AxisType::REALNUMBER;
533 410 : if(0==nDimensionIndex)//x-axis
534 : {
535 1640 : if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_SCATTER)
536 1230 : || aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_BUBBLE) )
537 0 : return AxisType::REALNUMBER;
538 410 : return AxisType::CATEGORY;
539 : }
540 0 : return AxisType::CATEGORY;
541 : }
542 :
543 0 : sal_Int32 ChartTypeHelper::getNumberOfDisplayedSeries(
544 : const uno::Reference< XChartType >& xChartType,
545 : sal_Int32 nNumberOfSeries )
546 : {
547 0 : if( xChartType.is() )
548 : {
549 : try
550 : {
551 0 : rtl::OUString aChartTypeName = xChartType->getChartType();
552 0 : if( aChartTypeName.equals(CHART2_SERVICE_NAME_CHARTTYPE_PIE))
553 : {
554 0 : uno::Reference< beans::XPropertySet > xChartTypeProp( xChartType, uno::UNO_QUERY_THROW );
555 0 : bool bDonut = false;
556 0 : if( (xChartTypeProp->getPropertyValue( C2U("UseRings")) >>= bDonut)
557 0 : && !bDonut )
558 : {
559 0 : return nNumberOfSeries>0 ? 1 : 0;
560 0 : }
561 0 : }
562 : }
563 0 : catch( const uno::Exception & ex )
564 : {
565 : ASSERT_EXCEPTION( ex );
566 : }
567 : }
568 0 : return nNumberOfSeries;
569 : }
570 :
571 82 : uno::Sequence < sal_Int32 > ChartTypeHelper::getSupportedMissingValueTreatments( const uno::Reference< XChartType >& xChartType )
572 : {
573 82 : uno::Sequence < sal_Int32 > aRet;
574 82 : if( !xChartType.is() )
575 : return aRet;
576 :
577 82 : bool bStacked = false;
578 82 : bool bFound=false;
579 82 : bool bAmbiguous=false;
580 82 : StackMode eStackMode = DiagramHelper::getStackModeFromChartType( xChartType, bFound, bAmbiguous, 0 );
581 82 : bStacked = bFound && (StackMode_Y_STACKED == eStackMode);
582 :
583 82 : rtl::OUString aChartTypeName = xChartType->getChartType();
584 164 : if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_COLUMN) ||
585 82 : aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_BAR) ||
586 82 : aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_BUBBLE) )
587 : {
588 82 : aRet.realloc( 2 );
589 82 : sal_Int32* pSeq = aRet.getArray();
590 82 : *pSeq++ = ::com::sun::star::chart::MissingValueTreatment::LEAVE_GAP;
591 82 : *pSeq++ = ::com::sun::star::chart::MissingValueTreatment::USE_ZERO;
592 : }
593 0 : else if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_AREA) )
594 : {
595 0 : aRet.realloc( bStacked ? 1 : 2 );
596 0 : sal_Int32* pSeq = aRet.getArray();
597 0 : *pSeq++ = ::com::sun::star::chart::MissingValueTreatment::USE_ZERO;
598 0 : if( !bStacked )
599 0 : *pSeq++ = ::com::sun::star::chart::MissingValueTreatment::CONTINUE;
600 : }
601 0 : else if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_LINE) ||
602 0 : aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_NET) ||
603 0 : aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_FILLED_NET) )
604 : {
605 0 : aRet.realloc( bStacked ? 2 : 3 );
606 0 : sal_Int32* pSeq = aRet.getArray();
607 0 : *pSeq++ = ::com::sun::star::chart::MissingValueTreatment::LEAVE_GAP;
608 0 : *pSeq++ = ::com::sun::star::chart::MissingValueTreatment::USE_ZERO;
609 0 : if( !bStacked )
610 0 : *pSeq++ = ::com::sun::star::chart::MissingValueTreatment::CONTINUE;
611 : }
612 0 : else if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_SCATTER) )
613 : {
614 0 : aRet.realloc( 3 );
615 0 : sal_Int32* pSeq = aRet.getArray();
616 0 : *pSeq++ = ::com::sun::star::chart::MissingValueTreatment::CONTINUE;
617 0 : *pSeq++ = ::com::sun::star::chart::MissingValueTreatment::LEAVE_GAP;
618 0 : *pSeq++ = ::com::sun::star::chart::MissingValueTreatment::USE_ZERO;
619 : }
620 0 : else if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_PIE) ||
621 0 : aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK) )
622 : {
623 0 : aRet.realloc( 0 );
624 : }
625 : else
626 : {
627 : OSL_FAIL( "unknown charttype" );
628 : }
629 :
630 82 : return aRet;
631 : }
632 :
633 41 : bool ChartTypeHelper::isSeriesInFrontOfAxisLine( const uno::Reference< XChartType >& xChartType )
634 : {
635 41 : if( xChartType.is() )
636 : {
637 41 : rtl::OUString aChartTypeName = xChartType->getChartType();
638 41 : if( aChartTypeName.match( CHART2_SERVICE_NAME_CHARTTYPE_FILLED_NET ) )
639 0 : return false;
640 : }
641 41 : return true;
642 : }
643 :
644 41 : rtl::OUString ChartTypeHelper::getRoleOfSequenceForYAxisNumberFormatDetection( const uno::Reference< XChartType >& xChartType )
645 : {
646 41 : rtl::OUString aRet( C2U( "values-y" ) );
647 41 : if( !xChartType.is() )
648 : return aRet;
649 41 : rtl::OUString aChartTypeName = xChartType->getChartType();
650 41 : if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK) )
651 0 : aRet = xChartType->getRoleOfSequenceForSeriesLabel();
652 41 : return aRet;
653 : }
654 :
655 123 : rtl::OUString ChartTypeHelper::getRoleOfSequenceForDataLabelNumberFormatDetection( const uno::Reference< XChartType >& xChartType )
656 : {
657 123 : rtl::OUString aRet( C2U( "values-y" ) );
658 123 : if( !xChartType.is() )
659 : return aRet;
660 123 : rtl::OUString aChartTypeName = xChartType->getChartType();
661 492 : if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK)
662 369 : || aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_BUBBLE) )
663 0 : aRet = xChartType->getRoleOfSequenceForSeriesLabel();
664 123 : return aRet;
665 : }
666 :
667 0 : bool ChartTypeHelper::shouldLabelNumberFormatKeyBeDetectedFromYAxis( const uno::Reference< XChartType >& xChartType )
668 : {
669 0 : bool bRet = true;
670 0 : rtl::OUString aChartTypeName = xChartType->getChartType();
671 0 : if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_BUBBLE) )
672 0 : bRet = false;
673 0 : return bRet;
674 : }
675 :
676 0 : bool ChartTypeHelper::isSupportingOnlyDeepStackingFor3D( const uno::Reference< XChartType >& xChartType )
677 : {
678 0 : bool bRet = false;
679 0 : if( !xChartType.is() )
680 0 : return bRet;
681 :
682 0 : rtl::OUString aChartTypeName = xChartType->getChartType();
683 0 : if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_LINE) ||
684 0 : aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_SCATTER) ||
685 0 : aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_AREA) )
686 : {
687 0 : bRet = true;
688 : }
689 0 : return bRet;
690 : }
691 :
692 : //.............................................................................
693 : } //namespace chart
694 : //.............................................................................
695 :
696 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|