Bump for 3.6-28
[LibreOffice.git] / chart2 / source / tools / ChartTypeHelper.cxx
blobbb57b15ed2f68859d6ae58d2956206207356428a
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
30 #include "ChartTypeHelper.hxx"
31 #include "DiagramHelper.hxx"
32 #include "DataSeriesHelper.hxx"
33 #include "macros.hxx"
34 #include "servicenames_charttypes.hxx"
36 #include <com/sun/star/beans/XPropertySet.hpp>
37 #include <com/sun/star/chart/DataLabelPlacement.hpp>
38 #include <com/sun/star/chart2/XDataSeriesContainer.hpp>
39 #include <com/sun/star/chart/MissingValueTreatment.hpp>
41 //.............................................................................
42 using namespace ::com::sun::star;
43 using namespace ::com::sun::star::chart2;
45 //.............................................................................
46 namespace chart
49 bool ChartTypeHelper::isSupportingAxisSideBySide(
50 const uno::Reference< chart2::XChartType >& xChartType, sal_Int32 nDimensionCount )
52 bool bResult = false;
54 if( xChartType.is() &&
55 nDimensionCount < 3 )
57 bool bFound=false;
58 bool bAmbiguous=false;
59 StackMode eStackMode = DiagramHelper::getStackModeFromChartType( xChartType, bFound, bAmbiguous, 0 );
60 if( eStackMode == StackMode_NONE && !bAmbiguous )
62 rtl::OUString aChartTypeName = xChartType->getChartType();
63 bResult = ( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_COLUMN) ||
64 aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_BAR) );
68 return bResult;
71 sal_Bool ChartTypeHelper::isSupportingGeometryProperties( const uno::Reference< XChartType >& xChartType, sal_Int32 nDimensionCount )
73 //form tab only for 3D-bar and 3D-column charts.
75 //@todo ask charttype itself --> need model change first
76 if(xChartType.is())
78 if(nDimensionCount==3)
80 rtl::OUString aChartTypeName = xChartType->getChartType();
81 if( aChartTypeName.equals(CHART2_SERVICE_NAME_CHARTTYPE_BAR) )
82 return sal_True;
83 if( aChartTypeName.equals(CHART2_SERVICE_NAME_CHARTTYPE_COLUMN) )
84 return sal_True;
87 return sal_False;
90 sal_Bool ChartTypeHelper::isSupportingStatisticProperties( const uno::Reference< XChartType >& xChartType, sal_Int32 nDimensionCount )
92 //3D charts, pie, net and stock do not support statistic properties
94 //@todo ask charttype itself (and series? --> stock chart?) --> need model change first
95 if(xChartType.is())
97 if(nDimensionCount==3)
98 return sal_False;
100 rtl::OUString aChartTypeName = xChartType->getChartType();
101 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_PIE) )
102 return sal_False;
103 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_NET) )
104 return sal_False;
105 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_FILLED_NET) )
106 return sal_False;
107 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK) )
108 return sal_False;
109 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_BUBBLE) ) //todo: BubbleChart support error bars and trend lines
110 return sal_False;
112 return sal_True;
115 sal_Bool ChartTypeHelper::isSupportingRegressionProperties( const uno::Reference< XChartType >& xChartType, sal_Int32 nDimensionCount )
117 // note: old chart: only scatter chart
118 return isSupportingStatisticProperties( xChartType, nDimensionCount );
121 sal_Bool ChartTypeHelper::isSupportingAreaProperties( const uno::Reference< XChartType >& xChartType, sal_Int32 nDimensionCount )
123 //2D line charts, net and stock do not support area properties
125 //@todo ask charttype itself --> need model change first
126 if(xChartType.is())
128 if(nDimensionCount==2)
130 rtl::OUString aChartTypeName = xChartType->getChartType();
131 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_LINE) )
132 return sal_False;
133 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_SCATTER) )
134 return sal_False;
135 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_NET) )
136 return sal_False;
137 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK) )
138 return sal_False;
141 return sal_True;
144 sal_Bool ChartTypeHelper::isSupportingSymbolProperties( const uno::Reference< XChartType >& xChartType, sal_Int32 nDimensionCount )
146 //2D line charts, 2D scatter charts and 2D net charts do support symbols
148 //@todo ask charttype itself --> need model change first
149 if(xChartType.is())
151 if(nDimensionCount==3)
152 return sal_False;
154 rtl::OUString aChartTypeName = xChartType->getChartType();
155 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_LINE) )
156 return sal_True;
157 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_SCATTER) )
158 return sal_True;
159 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_NET) )
160 return sal_True;
162 return sal_False;
165 sal_Bool ChartTypeHelper::isSupportingMainAxis( const uno::Reference< XChartType >& xChartType, sal_Int32 nDimensionCount, sal_Int32 nDimensionIndex )
167 //pie charts do not support axis at all
168 //no 3rd axis for 2D charts
170 //@todo ask charttype itself --> need model change first
171 if(xChartType.is())
173 rtl::OUString aChartTypeName = xChartType->getChartType();
174 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_PIE) )
175 return sal_False;
177 if( nDimensionIndex == 2 )
178 return nDimensionCount == 3;
180 return sal_True;
183 sal_Bool ChartTypeHelper::isSupportingSecondaryAxis( const uno::Reference< XChartType >& xChartType, sal_Int32 nDimensionCount, sal_Int32 /*nDimensionIndex*/ )
185 //3D, pie and net charts do not support a secondary axis at all
187 //@todo ask charttype itself --> need model change first
188 if(xChartType.is())
190 if(nDimensionCount==3)
191 return sal_False;
193 rtl::OUString aChartTypeName = xChartType->getChartType();
194 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_PIE) )
195 return sal_False;
196 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_NET) )
197 return sal_False;
198 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_FILLED_NET) )
199 return sal_False;
201 return sal_True;
204 sal_Bool ChartTypeHelper::isSupportingOverlapAndGapWidthProperties(
205 const uno::Reference< XChartType >& xChartType, sal_Int32 nDimensionCount )
207 //2D bar charts do support a this special properties
209 //@todo ask charttype itself --> need model change first
210 if(xChartType.is())
212 if(nDimensionCount==3)
213 return sal_False;
215 rtl::OUString aChartTypeName = xChartType->getChartType();
216 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_COLUMN) )
217 return sal_True;
218 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_BAR) )
219 return sal_True;
221 return sal_False;
224 sal_Bool ChartTypeHelper::isSupportingBarConnectors(
225 const uno::Reference< chart2::XChartType >& xChartType, sal_Int32 nDimensionCount )
227 //2D bar charts with stacked series support this
229 //@todo ask charttype itself --> need model change first
230 if(xChartType.is())
232 if(nDimensionCount==3)
233 return sal_False;
235 bool bFound=false;
236 bool bAmbiguous=false;
237 StackMode eStackMode = DiagramHelper::getStackModeFromChartType( xChartType, bFound, bAmbiguous, 0 );
238 if( eStackMode != StackMode_Y_STACKED || bAmbiguous )
239 return sal_False;
241 rtl::OUString aChartTypeName = xChartType->getChartType();
242 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_COLUMN) )
243 return sal_True;
244 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_BAR) )
245 return sal_True; // note: old chart was false here
247 return sal_False;
250 uno::Sequence < sal_Int32 > ChartTypeHelper::getSupportedLabelPlacements( const uno::Reference< chart2::XChartType >& xChartType
251 , sal_Int32 nDimensionCount, sal_Bool bSwapXAndY
252 , const uno::Reference< chart2::XDataSeries >& xSeries )
254 (void)nDimensionCount;
256 uno::Sequence < sal_Int32 > aRet;
257 if( !xChartType.is() )
258 return aRet;
260 rtl::OUString aChartTypeName = xChartType->getChartType();
261 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_PIE) )
263 bool bDonut = false;
264 uno::Reference< beans::XPropertySet > xChartTypeProp( xChartType, uno::UNO_QUERY_THROW );
265 if(xChartTypeProp.is())
266 xChartTypeProp->getPropertyValue( C2U("UseRings")) >>= bDonut;
268 if(!bDonut)
270 aRet.realloc(4);
271 sal_Int32* pSeq = aRet.getArray();
272 *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::AVOID_OVERLAP;
273 *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::OUTSIDE;
274 *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::INSIDE;
275 *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::CENTER;
277 else
279 aRet.realloc(1);
280 sal_Int32* pSeq = aRet.getArray();
281 *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::CENTER;
284 else if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_SCATTER)
285 || aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_LINE)
286 || aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_BUBBLE)
289 aRet.realloc(5);
290 sal_Int32* pSeq = aRet.getArray();
291 *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::TOP;
292 *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::BOTTOM;
293 *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::LEFT;
294 *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::RIGHT;
295 *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::CENTER;
297 else if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_COLUMN)
298 || aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_BAR) )
301 bool bStacked = false;
303 uno::Reference< beans::XPropertySet > xSeriesProp( xSeries, uno::UNO_QUERY );
304 chart2::StackingDirection eStacking = chart2::StackingDirection_NO_STACKING;
305 xSeriesProp->getPropertyValue( C2U("StackingDirection") ) >>= eStacking;
306 bStacked = (chart2::StackingDirection_Y_STACKING == eStacking);
309 aRet.realloc( bStacked ? 3 : 6 );
310 sal_Int32* pSeq = aRet.getArray();
311 if(!bStacked)
313 if(bSwapXAndY)
315 *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::RIGHT;
316 *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::LEFT;
318 else
320 *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::TOP;
321 *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::BOTTOM;
324 *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::CENTER;
325 if(!bStacked)
326 *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::OUTSIDE;
327 *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::INSIDE;
328 *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::NEAR_ORIGIN;
330 else if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_AREA) )
332 aRet.realloc(1);
333 sal_Int32* pSeq = aRet.getArray();
334 *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::TOP;
336 else if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_NET) )
338 aRet.realloc(6);
339 sal_Int32* pSeq = aRet.getArray();
340 *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::OUTSIDE;
341 *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::TOP;
342 *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::BOTTOM;
343 *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::LEFT;
344 *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::RIGHT;
345 *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::CENTER;
347 else if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_FILLED_NET) )
349 aRet.realloc(1);
350 sal_Int32* pSeq = aRet.getArray();
351 *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::OUTSIDE;
353 else if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK) )
355 aRet.realloc( 1 );
356 sal_Int32* pSeq = aRet.getArray();
357 *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::OUTSIDE;
359 else
361 OSL_FAIL( "unknown charttype" );
364 return aRet;
367 sal_Bool ChartTypeHelper::isSupportingRightAngledAxes( const uno::Reference< chart2::XChartType >& xChartType )
369 if(xChartType.is())
371 rtl::OUString aChartTypeName = xChartType->getChartType();
372 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_PIE) )
373 return sal_False;
375 return sal_True;
378 bool ChartTypeHelper::isSupportingStartingAngle( const uno::Reference< chart2::XChartType >& xChartType )
380 if(xChartType.is())
382 rtl::OUString aChartTypeName = xChartType->getChartType();
383 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_PIE) )
384 return true;
386 return false;
388 bool ChartTypeHelper::isSupportingBaseValue( const uno::Reference< chart2::XChartType >& xChartType )
390 if(xChartType.is())
392 rtl::OUString aChartTypeName = xChartType->getChartType();
393 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_COLUMN)
394 || aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_BAR)
395 || aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_AREA)
397 return true;
399 return false;
402 bool ChartTypeHelper::isSupportingAxisPositioning( const uno::Reference< chart2::XChartType >& xChartType, sal_Int32 nDimensionCount, sal_Int32 nDimensionIndex )
404 if(xChartType.is())
406 rtl::OUString aChartTypeName = xChartType->getChartType();
407 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_NET) )
408 return false;
409 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_FILLED_NET) )
410 return false;
412 if( nDimensionCount==3 )
413 return nDimensionIndex<2;
414 return true;
417 bool ChartTypeHelper::isSupportingDateAxis( const uno::Reference< chart2::XChartType >& xChartType, sal_Int32 /*nDimensionCount*/, sal_Int32 nDimensionIndex )
419 if( nDimensionIndex!=0 )
420 return false;
421 if( xChartType.is() )
423 sal_Int32 nType = ChartTypeHelper::getAxisType( xChartType, nDimensionIndex );
424 if( nType != AxisType::CATEGORY )
425 return false;
426 rtl::OUString aChartTypeName = xChartType->getChartType();
427 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_PIE) )
428 return false;
429 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_NET) )
430 return false;
431 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_FILLED_NET) )
432 return false;
434 return true;
437 bool ChartTypeHelper::shiftCategoryPosAtXAxisPerDefault( const uno::Reference< chart2::XChartType >& xChartType )
439 if(xChartType.is())
441 rtl::OUString aChartTypeName = xChartType->getChartType();
442 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_COLUMN)
443 || aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_BAR)
444 || aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK) )
445 return true;
447 return false;
450 bool ChartTypeHelper::noBordersForSimpleScheme( const uno::Reference< chart2::XChartType >& xChartType )
452 if(xChartType.is())
454 rtl::OUString aChartTypeName = xChartType->getChartType();
455 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_PIE) )
456 return sal_True;
458 return sal_False;
461 sal_Int32 ChartTypeHelper::getDefaultDirectLightColor( bool bSimple, const uno::Reference< chart2::XChartType >& xChartType )
463 sal_Int32 nRet = static_cast< sal_Int32 >( 0x808080 ); // grey
464 if( xChartType .is() )
466 rtl::OUString aChartType = xChartType->getChartType();
467 if( aChartType.equals(CHART2_SERVICE_NAME_CHARTTYPE_PIE) )
469 if( bSimple )
470 nRet = static_cast< sal_Int32 >( 0x333333 ); // grey80
471 else
472 nRet = static_cast< sal_Int32 >( 0xb3b3b3 ); // grey30
474 else if( aChartType.equals(CHART2_SERVICE_NAME_CHARTTYPE_LINE)
475 || aChartType.equals(CHART2_SERVICE_NAME_CHARTTYPE_SCATTER) )
476 nRet = static_cast< sal_Int32 >( 0x666666 ); // grey60
478 return nRet;
481 sal_Int32 ChartTypeHelper::getDefaultAmbientLightColor( bool bSimple, const uno::Reference< chart2::XChartType >& xChartType )
483 sal_Int32 nRet = static_cast< sal_Int32 >( 0x999999 ); // grey40
484 if( xChartType .is() )
486 rtl::OUString aChartType = xChartType->getChartType();
487 if( aChartType.equals(CHART2_SERVICE_NAME_CHARTTYPE_PIE) )
489 if( bSimple )
490 nRet = static_cast< sal_Int32 >( 0xcccccc ); // grey20
491 else
492 nRet = static_cast< sal_Int32 >( 0x666666 ); // grey60
495 return nRet;
498 drawing::Direction3D ChartTypeHelper::getDefaultSimpleLightDirection( const uno::Reference< chart2::XChartType >& xChartType )
500 drawing::Direction3D aRet(0.0, 0.0, 1.0);
501 if( xChartType .is() )
503 rtl::OUString aChartType = xChartType->getChartType();
504 if( aChartType.equals(CHART2_SERVICE_NAME_CHARTTYPE_PIE) )
505 aRet = drawing::Direction3D(0.0, 0.8, 0.5);
506 else if( aChartType.equals(CHART2_SERVICE_NAME_CHARTTYPE_LINE)
507 || aChartType.equals(CHART2_SERVICE_NAME_CHARTTYPE_SCATTER) )
508 aRet = drawing::Direction3D(0.9, 0.5, 0.05);
510 return aRet;
513 drawing::Direction3D ChartTypeHelper::getDefaultRealisticLightDirection( const uno::Reference< chart2::XChartType >& xChartType )
515 drawing::Direction3D aRet(0.0, 0.0, 1.0);
516 if( xChartType .is() )
518 rtl::OUString aChartType = xChartType->getChartType();
519 if( aChartType.equals(CHART2_SERVICE_NAME_CHARTTYPE_PIE) )
520 aRet = drawing::Direction3D(0.6, 0.6, 0.6);
521 else if( aChartType.equals(CHART2_SERVICE_NAME_CHARTTYPE_LINE)
522 || aChartType.equals(CHART2_SERVICE_NAME_CHARTTYPE_SCATTER) )
523 aRet = drawing::Direction3D(0.9, 0.5, 0.05);
525 return aRet;
528 sal_Int32 ChartTypeHelper::getAxisType( const uno::Reference<
529 XChartType >& xChartType, sal_Int32 nDimensionIndex )
531 //retruned is a constant from constant group ::com::sun::star::chart2::AxisType
533 //@todo ask charttype itself --> need model change first
534 if(!xChartType.is())
535 return AxisType::CATEGORY;
537 rtl::OUString aChartTypeName = xChartType->getChartType();
538 if(2==nDimensionIndex)//z-axis
539 return AxisType::SERIES;
540 if(1==nDimensionIndex)//y-axis
541 return AxisType::REALNUMBER;
542 if(0==nDimensionIndex)//x-axis
544 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_SCATTER)
545 || aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_BUBBLE) )
546 return AxisType::REALNUMBER;
547 return AxisType::CATEGORY;
549 return AxisType::CATEGORY;
552 sal_Int32 ChartTypeHelper::getNumberOfDisplayedSeries(
553 const uno::Reference< XChartType >& xChartType,
554 sal_Int32 nNumberOfSeries )
556 if( xChartType.is() )
560 rtl::OUString aChartTypeName = xChartType->getChartType();
561 if( aChartTypeName.equals(CHART2_SERVICE_NAME_CHARTTYPE_PIE))
563 uno::Reference< beans::XPropertySet > xChartTypeProp( xChartType, uno::UNO_QUERY_THROW );
564 bool bDonut = false;
565 if( (xChartTypeProp->getPropertyValue( C2U("UseRings")) >>= bDonut)
566 && !bDonut )
568 return nNumberOfSeries>0 ? 1 : 0;
572 catch( const uno::Exception & ex )
574 ASSERT_EXCEPTION( ex );
577 return nNumberOfSeries;
580 uno::Sequence < sal_Int32 > ChartTypeHelper::getSupportedMissingValueTreatments( const uno::Reference< XChartType >& xChartType )
582 uno::Sequence < sal_Int32 > aRet;
583 if( !xChartType.is() )
584 return aRet;
586 bool bStacked = false;
587 bool bFound=false;
588 bool bAmbiguous=false;
589 StackMode eStackMode = DiagramHelper::getStackModeFromChartType( xChartType, bFound, bAmbiguous, 0 );
590 bStacked = bFound && (StackMode_Y_STACKED == eStackMode);
592 rtl::OUString aChartTypeName = xChartType->getChartType();
593 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_COLUMN) ||
594 aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_BAR) ||
595 aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_BUBBLE) )
597 aRet.realloc( 2 );
598 sal_Int32* pSeq = aRet.getArray();
599 *pSeq++ = ::com::sun::star::chart::MissingValueTreatment::LEAVE_GAP;
600 *pSeq++ = ::com::sun::star::chart::MissingValueTreatment::USE_ZERO;
602 else if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_AREA) )
604 aRet.realloc( bStacked ? 1 : 2 );
605 sal_Int32* pSeq = aRet.getArray();
606 *pSeq++ = ::com::sun::star::chart::MissingValueTreatment::USE_ZERO;
607 if( !bStacked )
608 *pSeq++ = ::com::sun::star::chart::MissingValueTreatment::CONTINUE;
610 else if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_LINE) ||
611 aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_NET) ||
612 aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_FILLED_NET) )
614 aRet.realloc( bStacked ? 2 : 3 );
615 sal_Int32* pSeq = aRet.getArray();
616 *pSeq++ = ::com::sun::star::chart::MissingValueTreatment::LEAVE_GAP;
617 *pSeq++ = ::com::sun::star::chart::MissingValueTreatment::USE_ZERO;
618 if( !bStacked )
619 *pSeq++ = ::com::sun::star::chart::MissingValueTreatment::CONTINUE;
621 else if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_SCATTER) )
623 aRet.realloc( 3 );
624 sal_Int32* pSeq = aRet.getArray();
625 *pSeq++ = ::com::sun::star::chart::MissingValueTreatment::CONTINUE;
626 *pSeq++ = ::com::sun::star::chart::MissingValueTreatment::LEAVE_GAP;
627 *pSeq++ = ::com::sun::star::chart::MissingValueTreatment::USE_ZERO;
629 else if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_PIE) ||
630 aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK) )
632 aRet.realloc( 0 );
634 else
636 OSL_FAIL( "unknown charttype" );
639 return aRet;
642 bool ChartTypeHelper::isSeriesInFrontOfAxisLine( const uno::Reference< XChartType >& xChartType )
644 if( xChartType.is() )
646 rtl::OUString aChartTypeName = xChartType->getChartType();
647 if( aChartTypeName.match( CHART2_SERVICE_NAME_CHARTTYPE_FILLED_NET ) )
648 return false;
650 return true;
653 rtl::OUString ChartTypeHelper::getRoleOfSequenceForYAxisNumberFormatDetection( const uno::Reference< XChartType >& xChartType )
655 rtl::OUString aRet( C2U( "values-y" ) );
656 if( !xChartType.is() )
657 return aRet;
658 rtl::OUString aChartTypeName = xChartType->getChartType();
659 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK) )
660 aRet = xChartType->getRoleOfSequenceForSeriesLabel();
661 return aRet;
664 rtl::OUString ChartTypeHelper::getRoleOfSequenceForDataLabelNumberFormatDetection( const uno::Reference< XChartType >& xChartType )
666 rtl::OUString aRet( C2U( "values-y" ) );
667 if( !xChartType.is() )
668 return aRet;
669 rtl::OUString aChartTypeName = xChartType->getChartType();
670 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK)
671 || aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_BUBBLE) )
672 aRet = xChartType->getRoleOfSequenceForSeriesLabel();
673 return aRet;
676 bool ChartTypeHelper::shouldLabelNumberFormatKeyBeDetectedFromYAxis( const uno::Reference< XChartType >& xChartType )
678 bool bRet = true;
679 rtl::OUString aChartTypeName = xChartType->getChartType();
680 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_BUBBLE) )
681 bRet = false;
682 return bRet;
685 bool ChartTypeHelper::isSupportingOnlyDeepStackingFor3D( const uno::Reference< XChartType >& xChartType )
687 bool bRet = false;
688 if( !xChartType.is() )
689 return bRet;
691 rtl::OUString aChartTypeName = xChartType->getChartType();
692 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_LINE) ||
693 aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_SCATTER) ||
694 aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_AREA) )
696 bRet = true;
698 return bRet;
701 //.............................................................................
702 } //namespace chart
703 //.............................................................................
705 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */