Update ooo320-m1
[ooovba.git] / chart2 / source / tools / ChartTypeHelper.cxx
blob23aa14136c4470787ed123c346e37008c33a439b
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ChartTypeHelper.cxx,v $
10 * $Revision: 1.22 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_chart2.hxx"
34 #include "ChartTypeHelper.hxx"
35 #include "DiagramHelper.hxx"
36 #include "DataSeriesHelper.hxx"
37 #include "macros.hxx"
38 #include "servicenames_charttypes.hxx"
40 #include <com/sun/star/beans/XPropertySet.hpp>
41 #include <com/sun/star/chart/DataLabelPlacement.hpp>
42 #include <com/sun/star/chart2/XDataSeriesContainer.hpp>
43 #include <com/sun/star/chart/MissingValueTreatment.hpp>
45 //.............................................................................
46 using namespace ::com::sun::star;
47 using namespace ::com::sun::star::chart2;
49 //.............................................................................
50 namespace chart
53 bool ChartTypeHelper::isSupportingAxisSideBySide(
54 const uno::Reference< chart2::XChartType >& xChartType, sal_Int32 nDimensionCount )
56 bool bResult = false;
58 if( xChartType.is() &&
59 nDimensionCount < 3 )
61 bool bFound=false;
62 bool bAmbiguous=false;
63 StackMode eStackMode = DiagramHelper::getStackModeFromChartType( xChartType, bFound, bAmbiguous, 0 );
64 if( eStackMode == StackMode_NONE && !bAmbiguous )
66 rtl::OUString aChartTypeName = xChartType->getChartType();
67 bResult = ( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_COLUMN) ||
68 aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_BAR) );
72 return bResult;
75 sal_Bool ChartTypeHelper::isSupportingGeometryProperties( const uno::Reference< XChartType >& xChartType, sal_Int32 nDimensionCount )
77 //form tab only for 3D-bar and 3D-column charts.
79 //@todo ask charttype itself --> need model change first
80 if(xChartType.is())
82 if(nDimensionCount==3)
84 rtl::OUString aChartTypeName = xChartType->getChartType();
85 if( aChartTypeName.equals(CHART2_SERVICE_NAME_CHARTTYPE_BAR) )
86 return sal_True;
87 if( aChartTypeName.equals(CHART2_SERVICE_NAME_CHARTTYPE_COLUMN) )
88 return sal_True;
91 return sal_False;
94 sal_Bool ChartTypeHelper::isSupportingStatisticProperties( const uno::Reference< XChartType >& xChartType, sal_Int32 nDimensionCount )
96 //3D charts, pie, net and stock do not support statistic properties
98 //@todo ask charttype itself (and series? --> stock chart?) --> need model change first
99 if(xChartType.is())
101 if(nDimensionCount==3)
102 return sal_False;
104 rtl::OUString aChartTypeName = xChartType->getChartType();
105 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_PIE) )
106 return sal_False;
107 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_NET) )
108 return sal_False;
109 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_FILLED_NET) )
110 return sal_False;
111 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK) )
112 return sal_False;
113 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_BUBBLE) ) //todo: BubbleChart support error bars and trend lines
114 return sal_False;
116 return sal_True;
119 sal_Bool ChartTypeHelper::isSupportingRegressionProperties( const uno::Reference< XChartType >& xChartType, sal_Int32 nDimensionCount )
121 // note: old chart: only scatter chart
122 return isSupportingStatisticProperties( xChartType, nDimensionCount );
125 sal_Bool ChartTypeHelper::isSupportingAreaProperties( const uno::Reference< XChartType >& xChartType, sal_Int32 nDimensionCount )
127 //2D line charts, net and stock do not support area properties
129 //@todo ask charttype itself --> need model change first
130 if(xChartType.is())
132 if(nDimensionCount==2)
134 rtl::OUString aChartTypeName = xChartType->getChartType();
135 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_LINE) )
136 return sal_False;
137 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_SCATTER) )
138 return sal_False;
139 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_NET) )
140 return sal_False;
141 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK) )
142 return sal_False;
145 return sal_True;
148 sal_Bool ChartTypeHelper::isSupportingSymbolProperties( const uno::Reference< XChartType >& xChartType, sal_Int32 nDimensionCount )
150 //2D line charts, 2D scatter charts and 2D net charts do support symbols
152 //@todo ask charttype itself --> need model change first
153 if(xChartType.is())
155 if(nDimensionCount==3)
156 return sal_False;
158 rtl::OUString aChartTypeName = xChartType->getChartType();
159 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_LINE) )
160 return sal_True;
161 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_SCATTER) )
162 return sal_True;
163 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_NET) )
164 return sal_True;
166 return sal_False;
169 sal_Bool ChartTypeHelper::isSupportingMainAxis( const uno::Reference< XChartType >& xChartType, sal_Int32 nDimensionCount, sal_Int32 nDimensionIndex )
171 //pie charts do not support axis at all
172 //no 3rd axis for 2D charts
174 //@todo ask charttype itself --> need model change first
175 if(xChartType.is())
177 rtl::OUString aChartTypeName = xChartType->getChartType();
178 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_PIE) )
179 return sal_False;
181 if( nDimensionIndex == 2 )
182 return nDimensionCount == 3;
184 return sal_True;
187 sal_Bool ChartTypeHelper::isSupportingSecondaryAxis( const uno::Reference< XChartType >& xChartType, sal_Int32 nDimensionCount, sal_Int32 /*nDimensionIndex*/ )
189 //3D, pie and net charts do not support a secondary axis at all
191 //@todo ask charttype itself --> need model change first
192 if(xChartType.is())
194 if(nDimensionCount==3)
195 return sal_False;
197 rtl::OUString aChartTypeName = xChartType->getChartType();
198 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_PIE) )
199 return sal_False;
200 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_NET) )
201 return sal_False;
202 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_FILLED_NET) )
203 return sal_False;
205 return sal_True;
208 sal_Bool ChartTypeHelper::isSupportingOverlapAndGapWidthProperties(
209 const uno::Reference< XChartType >& xChartType, sal_Int32 nDimensionCount )
211 //2D bar charts do support a this special properties
213 //@todo ask charttype itself --> need model change first
214 if(xChartType.is())
216 if(nDimensionCount==3)
217 return sal_False;
219 rtl::OUString aChartTypeName = xChartType->getChartType();
220 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_COLUMN) )
221 return sal_True;
222 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_BAR) )
223 return sal_True;
225 return sal_False;
228 sal_Bool ChartTypeHelper::isSupportingBarConnectors(
229 const uno::Reference< chart2::XChartType >& xChartType, sal_Int32 nDimensionCount )
231 //2D bar charts with stacked series support this
233 //@todo ask charttype itself --> need model change first
234 if(xChartType.is())
236 if(nDimensionCount==3)
237 return sal_False;
239 bool bFound=false;
240 bool bAmbiguous=false;
241 StackMode eStackMode = DiagramHelper::getStackModeFromChartType( xChartType, bFound, bAmbiguous, 0 );
242 if( eStackMode != StackMode_Y_STACKED || bAmbiguous )
243 return sal_False;
245 rtl::OUString aChartTypeName = xChartType->getChartType();
246 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_COLUMN) )
247 return sal_True;
248 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_BAR) )
249 return sal_True; // note: old chart was false here
251 return sal_False;
254 uno::Sequence < sal_Int32 > ChartTypeHelper::getSupportedLabelPlacements( const uno::Reference< chart2::XChartType >& xChartType
255 , sal_Int32 nDimensionCount, sal_Bool bSwapXAndY
256 , const uno::Reference< chart2::XDataSeries >& xSeries )
258 (void)nDimensionCount;
260 uno::Sequence < sal_Int32 > aRet;
261 if( !xChartType.is() )
262 return aRet;
264 rtl::OUString aChartTypeName = xChartType->getChartType();
265 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_PIE) )
267 bool bDonut = false;
268 uno::Reference< beans::XPropertySet > xChartTypeProp( xChartType, uno::UNO_QUERY_THROW );
269 if(xChartTypeProp.is())
270 xChartTypeProp->getPropertyValue( C2U("UseRings")) >>= bDonut;
272 if(!bDonut)
274 aRet.realloc(4);
275 sal_Int32* pSeq = aRet.getArray();
276 *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::AVOID_OVERLAP;
277 *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::OUTSIDE;
278 *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::INSIDE;
279 *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::CENTER;
281 else
283 aRet.realloc(1);
284 sal_Int32* pSeq = aRet.getArray();
285 *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::CENTER;
288 else if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_SCATTER)
289 || aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_LINE)
290 || aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_BUBBLE)
293 aRet.realloc(5);
294 sal_Int32* pSeq = aRet.getArray();
295 *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::TOP;
296 *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::BOTTOM;
297 *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::LEFT;
298 *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::RIGHT;
299 *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::CENTER;
301 else if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_COLUMN)
302 || aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_BAR) )
305 bool bStacked = false;
307 uno::Reference< beans::XPropertySet > xSeriesProp( xSeries, uno::UNO_QUERY );
308 chart2::StackingDirection eStacking = chart2::StackingDirection_NO_STACKING;
309 xSeriesProp->getPropertyValue( C2U("StackingDirection") ) >>= eStacking;
310 bStacked = (chart2::StackingDirection_Y_STACKING == eStacking);
313 aRet.realloc( bStacked ? 3 : 6 );
314 sal_Int32* pSeq = aRet.getArray();
315 if(!bStacked)
317 if(bSwapXAndY)
319 *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::RIGHT;
320 *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::LEFT;
322 else
324 *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::TOP;
325 *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::BOTTOM;
328 *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::CENTER;
329 if(!bStacked)
330 *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::OUTSIDE;
331 *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::INSIDE;
332 *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::NEAR_ORIGIN;
334 else if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_AREA) )
336 aRet.realloc(1);
337 sal_Int32* pSeq = aRet.getArray();
338 *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::TOP;
340 else if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_NET) )
342 aRet.realloc(6);
343 sal_Int32* pSeq = aRet.getArray();
344 *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::OUTSIDE;
345 *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::TOP;
346 *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::BOTTOM;
347 *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::LEFT;
348 *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::RIGHT;
349 *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::CENTER;
351 else if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_FILLED_NET) )
353 aRet.realloc(1);
354 sal_Int32* pSeq = aRet.getArray();
355 *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::OUTSIDE;
357 else if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK) )
359 aRet.realloc( 1 );
360 sal_Int32* pSeq = aRet.getArray();
361 *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::OUTSIDE;
363 else
365 OSL_ENSURE( false, "unknown charttype" );
368 return aRet;
371 sal_Bool ChartTypeHelper::isSupportingRightAngledAxes( const uno::Reference< chart2::XChartType >& xChartType )
373 if(xChartType.is())
375 rtl::OUString aChartTypeName = xChartType->getChartType();
376 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_PIE) )
377 return sal_False;
379 return sal_True;
382 bool ChartTypeHelper::isSupportingStartingAngle( const uno::Reference< chart2::XChartType >& xChartType )
384 if(xChartType.is())
386 rtl::OUString aChartTypeName = xChartType->getChartType();
387 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_PIE) )
388 return true;
390 return false;
392 bool ChartTypeHelper::isSupportingBaseValue( const uno::Reference< chart2::XChartType >& xChartType )
394 if(xChartType.is())
396 rtl::OUString aChartTypeName = xChartType->getChartType();
397 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_COLUMN)
398 || aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_BAR)
399 || aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_AREA)
401 return true;
403 return false;
406 bool ChartTypeHelper::isSupportingAxisPositioning( const uno::Reference< chart2::XChartType >& xChartType, sal_Int32 nDimensionCount, sal_Int32 nDimensionIndex )
408 if(xChartType.is())
410 rtl::OUString aChartTypeName = xChartType->getChartType();
411 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_NET) )
412 return false;
413 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_FILLED_NET) )
414 return false;
416 if( nDimensionCount==3 )
417 return nDimensionIndex<2;
418 return true;
421 bool ChartTypeHelper::shiftTicksAtXAxisPerDefault( const uno::Reference< chart2::XChartType >& xChartType )
423 if(xChartType.is())
425 rtl::OUString aChartTypeName = xChartType->getChartType();
426 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_COLUMN)
427 || aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_BAR) )
428 return true;
430 return false;
433 bool ChartTypeHelper::noBordersForSimpleScheme( const uno::Reference< chart2::XChartType >& xChartType )
435 if(xChartType.is())
437 rtl::OUString aChartTypeName = xChartType->getChartType();
438 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_PIE) )
439 return sal_True;
441 return sal_False;
444 //static
445 sal_Int32 ChartTypeHelper::getDefaultDirectLightColor( bool bSimple, const uno::Reference< chart2::XChartType >& xChartType )
447 if( bSimple )
449 sal_Int32 nRet = static_cast< sal_Int32 >( 0x999999 ); // grey40
450 if( xChartType .is() )
452 rtl::OUString aChartType = xChartType->getChartType();
453 if( aChartType.equals(CHART2_SERVICE_NAME_CHARTTYPE_PIE) )
454 nRet = static_cast< sal_Int32 >( 0x333333 ); // grey80
455 else if( aChartType.equals(CHART2_SERVICE_NAME_CHARTTYPE_LINE)
456 || aChartType.equals(CHART2_SERVICE_NAME_CHARTTYPE_SCATTER) )
457 nRet = static_cast< sal_Int32 >( 0x666666 ); // grey60
459 return nRet;
461 return static_cast< sal_Int32 >( 0xb3b3b3 ); // grey30
464 //static
465 sal_Int32 ChartTypeHelper::getDefaultAmbientLightColor( bool bSimple, const uno::Reference< chart2::XChartType >& xChartType )
467 if( bSimple )
469 sal_Int32 nRet = static_cast< sal_Int32 >( 0x999999 ); // grey40
470 if( xChartType .is() )
472 rtl::OUString aChartType = xChartType->getChartType();
473 if( aChartType.equals(CHART2_SERVICE_NAME_CHARTTYPE_PIE) )
474 nRet = static_cast< sal_Int32 >( 0xcccccc ); // grey20
476 return nRet;
478 return static_cast< sal_Int32 >( 0x666666 ); // grey60
481 drawing::Direction3D ChartTypeHelper::getDefaultSimpleLightDirection( const uno::Reference< chart2::XChartType >& xChartType )
483 //drawing::Direction3D aRet(0.0, 0.0, 1.0);
484 drawing::Direction3D aRet(-0.2, 0.7, 0.6);
485 if( xChartType .is() )
487 rtl::OUString aChartType = xChartType->getChartType();
488 if( aChartType.equals(CHART2_SERVICE_NAME_CHARTTYPE_PIE) )
489 aRet = drawing::Direction3D(0.0, 0.8, 0.5);
490 else if( aChartType.equals(CHART2_SERVICE_NAME_CHARTTYPE_LINE)
491 || aChartType.equals(CHART2_SERVICE_NAME_CHARTTYPE_SCATTER) )
492 aRet = drawing::Direction3D(0.9, 0.5, 0.05);
494 return aRet;
497 drawing::Direction3D ChartTypeHelper::getDefaultRealisticLightDirection( const uno::Reference< chart2::XChartType >& xChartType )
499 drawing::Direction3D aRet(-0.1, 0.6, 0.8);
500 if( xChartType .is() )
502 rtl::OUString aChartType = xChartType->getChartType();
503 if( aChartType.equals(CHART2_SERVICE_NAME_CHARTTYPE_PIE) )
504 aRet = drawing::Direction3D(0.6, 0.6, 0.6);
505 else if( aChartType.equals(CHART2_SERVICE_NAME_CHARTTYPE_LINE)
506 || aChartType.equals(CHART2_SERVICE_NAME_CHARTTYPE_SCATTER) )
507 aRet = drawing::Direction3D(0.9, 0.5, 0.05);
509 return aRet;
512 sal_Int32 ChartTypeHelper::getAxisType( const uno::Reference<
513 XChartType >& xChartType, sal_Int32 nDimensionIndex )
515 //retruned is a constant from constant group ::com::sun::star::chart2::AxisType
517 //@todo ask charttype itself --> need model change first
518 if(!xChartType.is())
519 return AxisType::CATEGORY;
521 rtl::OUString aChartTypeName = xChartType->getChartType();
522 if(2==nDimensionIndex)//z-axis
523 return AxisType::SERIES;
524 if(1==nDimensionIndex)//y-axis
525 return AxisType::REALNUMBER;
526 if(0==nDimensionIndex)//x-axis
528 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_SCATTER)
529 || aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_BUBBLE) )
530 return AxisType::REALNUMBER;
531 return AxisType::CATEGORY;
533 return AxisType::CATEGORY;
536 sal_Int32 ChartTypeHelper::getNumberOfDisplayedSeries(
537 const uno::Reference< XChartType >& xChartType,
538 sal_Int32 nNumberOfSeries )
540 if( xChartType.is() )
544 rtl::OUString aChartTypeName = xChartType->getChartType();
545 if( aChartTypeName.equals(CHART2_SERVICE_NAME_CHARTTYPE_PIE))
547 uno::Reference< beans::XPropertySet > xChartTypeProp( xChartType, uno::UNO_QUERY_THROW );
548 bool bDonut = false;
549 if( (xChartTypeProp->getPropertyValue( C2U("UseRings")) >>= bDonut)
550 && !bDonut )
552 return 1;
556 catch( const uno::Exception & ex )
558 ASSERT_EXCEPTION( ex );
561 return nNumberOfSeries;
564 uno::Sequence < sal_Int32 > ChartTypeHelper::getSupportedMissingValueTreatments( const uno::Reference< XChartType >& xChartType )
566 uno::Sequence < sal_Int32 > aRet;
567 if( !xChartType.is() )
568 return aRet;
570 bool bStacked = false;
571 bool bFound=false;
572 bool bAmbiguous=false;
573 StackMode eStackMode = DiagramHelper::getStackModeFromChartType( xChartType, bFound, bAmbiguous, 0 );
574 bStacked = bFound && (StackMode_Y_STACKED == eStackMode);
576 rtl::OUString aChartTypeName = xChartType->getChartType();
577 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_COLUMN) ||
578 aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_BAR) ||
579 aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_BUBBLE) )
581 aRet.realloc( 2 );
582 sal_Int32* pSeq = aRet.getArray();
583 *pSeq++ = ::com::sun::star::chart::MissingValueTreatment::LEAVE_GAP;
584 *pSeq++ = ::com::sun::star::chart::MissingValueTreatment::USE_ZERO;
586 else if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_AREA) )
588 aRet.realloc( bStacked ? 1 : 2 );
589 sal_Int32* pSeq = aRet.getArray();
590 *pSeq++ = ::com::sun::star::chart::MissingValueTreatment::USE_ZERO;
591 if( !bStacked )
592 *pSeq++ = ::com::sun::star::chart::MissingValueTreatment::CONTINUE;
594 else if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_LINE) ||
595 aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_NET) ||
596 aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_FILLED_NET) )
598 aRet.realloc( bStacked ? 2 : 3 );
599 sal_Int32* pSeq = aRet.getArray();
600 *pSeq++ = ::com::sun::star::chart::MissingValueTreatment::LEAVE_GAP;
601 *pSeq++ = ::com::sun::star::chart::MissingValueTreatment::USE_ZERO;
602 if( !bStacked )
603 *pSeq++ = ::com::sun::star::chart::MissingValueTreatment::CONTINUE;
605 else if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_SCATTER) )
607 aRet.realloc( 3 );
608 sal_Int32* pSeq = aRet.getArray();
609 *pSeq++ = ::com::sun::star::chart::MissingValueTreatment::CONTINUE;
610 *pSeq++ = ::com::sun::star::chart::MissingValueTreatment::LEAVE_GAP;
611 *pSeq++ = ::com::sun::star::chart::MissingValueTreatment::USE_ZERO;
613 else if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_PIE) ||
614 aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK) )
616 aRet.realloc( 0 );
618 else
620 OSL_ENSURE( false, "unknown charttype" );
623 return aRet;
626 bool ChartTypeHelper::isSeriesInFrontOfAxisLine( const uno::Reference< XChartType >& xChartType )
628 if( xChartType.is() )
630 rtl::OUString aChartTypeName = xChartType->getChartType();
631 if( aChartTypeName.match( CHART2_SERVICE_NAME_CHARTTYPE_FILLED_NET ) )
632 return false;
634 return true;
637 rtl::OUString ChartTypeHelper::getRoleOfSequenceForYAxisNumberFormatDetection( const uno::Reference< XChartType >& xChartType )
639 rtl::OUString aRet( C2U( "values-y" ) );
640 if( !xChartType.is() )
641 return aRet;
642 rtl::OUString aChartTypeName = xChartType->getChartType();
643 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK) )
644 aRet = xChartType->getRoleOfSequenceForSeriesLabel();
645 return aRet;
648 rtl::OUString ChartTypeHelper::getRoleOfSequenceForDataLabelNumberFormatDetection( const uno::Reference< XChartType >& xChartType )
650 rtl::OUString aRet( C2U( "values-y" ) );
651 if( !xChartType.is() )
652 return aRet;
653 rtl::OUString aChartTypeName = xChartType->getChartType();
654 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK)
655 || aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_BUBBLE) )
656 aRet = xChartType->getRoleOfSequenceForSeriesLabel();
657 return aRet;
660 bool ChartTypeHelper::shouldLabelNumberFormatKeyBeDetectedFromYAxis( const uno::Reference< XChartType >& xChartType )
662 bool bRet = true;
663 rtl::OUString aChartTypeName = xChartType->getChartType();
664 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_BUBBLE) )
665 bRet = false;
666 return bRet;
669 bool ChartTypeHelper::isSupportingOnlyDeepStackingFor3D( const uno::Reference< XChartType >& xChartType )
671 bool bRet = false;
672 if( !xChartType.is() )
673 return bRet;
675 rtl::OUString aChartTypeName = xChartType->getChartType();
676 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_LINE) ||
677 aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_SCATTER) ||
678 aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_AREA) )
680 bRet = true;
682 return bRet;
685 //.............................................................................
686 } //namespace chart
687 //.............................................................................