merged tag ooo/OOO330_m14
[LibreOffice.git] / chart2 / source / tools / ChartTypeHelper.cxx
blobb851a3864b9775c13b1da84fe43c65b748f711e3
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_chart2.hxx"
31 #include "ChartTypeHelper.hxx"
32 #include "DiagramHelper.hxx"
33 #include "DataSeriesHelper.hxx"
34 #include "macros.hxx"
35 #include "servicenames_charttypes.hxx"
37 #include <com/sun/star/beans/XPropertySet.hpp>
38 #include <com/sun/star/chart/DataLabelPlacement.hpp>
39 #include <com/sun/star/chart2/XDataSeriesContainer.hpp>
40 #include <com/sun/star/chart/MissingValueTreatment.hpp>
42 //.............................................................................
43 using namespace ::com::sun::star;
44 using namespace ::com::sun::star::chart2;
46 //.............................................................................
47 namespace chart
50 bool ChartTypeHelper::isSupportingAxisSideBySide(
51 const uno::Reference< chart2::XChartType >& xChartType, sal_Int32 nDimensionCount )
53 bool bResult = false;
55 if( xChartType.is() &&
56 nDimensionCount < 3 )
58 bool bFound=false;
59 bool bAmbiguous=false;
60 StackMode eStackMode = DiagramHelper::getStackModeFromChartType( xChartType, bFound, bAmbiguous, 0 );
61 if( eStackMode == StackMode_NONE && !bAmbiguous )
63 rtl::OUString aChartTypeName = xChartType->getChartType();
64 bResult = ( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_COLUMN) ||
65 aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_BAR) );
69 return bResult;
72 sal_Bool ChartTypeHelper::isSupportingGeometryProperties( const uno::Reference< XChartType >& xChartType, sal_Int32 nDimensionCount )
74 //form tab only for 3D-bar and 3D-column charts.
76 //@todo ask charttype itself --> need model change first
77 if(xChartType.is())
79 if(nDimensionCount==3)
81 rtl::OUString aChartTypeName = xChartType->getChartType();
82 if( aChartTypeName.equals(CHART2_SERVICE_NAME_CHARTTYPE_BAR) )
83 return sal_True;
84 if( aChartTypeName.equals(CHART2_SERVICE_NAME_CHARTTYPE_COLUMN) )
85 return sal_True;
88 return sal_False;
91 sal_Bool ChartTypeHelper::isSupportingStatisticProperties( const uno::Reference< XChartType >& xChartType, sal_Int32 nDimensionCount )
93 //3D charts, pie, net and stock do not support statistic properties
95 //@todo ask charttype itself (and series? --> stock chart?) --> need model change first
96 if(xChartType.is())
98 if(nDimensionCount==3)
99 return sal_False;
101 rtl::OUString aChartTypeName = xChartType->getChartType();
102 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_PIE) )
103 return sal_False;
104 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_NET) )
105 return sal_False;
106 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_FILLED_NET) )
107 return sal_False;
108 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK) )
109 return sal_False;
110 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_BUBBLE) ) //todo: BubbleChart support error bars and trend lines
111 return sal_False;
113 return sal_True;
116 sal_Bool ChartTypeHelper::isSupportingRegressionProperties( const uno::Reference< XChartType >& xChartType, sal_Int32 nDimensionCount )
118 // note: old chart: only scatter chart
119 return isSupportingStatisticProperties( xChartType, nDimensionCount );
122 sal_Bool ChartTypeHelper::isSupportingAreaProperties( const uno::Reference< XChartType >& xChartType, sal_Int32 nDimensionCount )
124 //2D line charts, net and stock do not support area properties
126 //@todo ask charttype itself --> need model change first
127 if(xChartType.is())
129 if(nDimensionCount==2)
131 rtl::OUString aChartTypeName = xChartType->getChartType();
132 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_LINE) )
133 return sal_False;
134 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_SCATTER) )
135 return sal_False;
136 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_NET) )
137 return sal_False;
138 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK) )
139 return sal_False;
142 return sal_True;
145 sal_Bool ChartTypeHelper::isSupportingSymbolProperties( const uno::Reference< XChartType >& xChartType, sal_Int32 nDimensionCount )
147 //2D line charts, 2D scatter charts and 2D net charts do support symbols
149 //@todo ask charttype itself --> need model change first
150 if(xChartType.is())
152 if(nDimensionCount==3)
153 return sal_False;
155 rtl::OUString aChartTypeName = xChartType->getChartType();
156 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_LINE) )
157 return sal_True;
158 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_SCATTER) )
159 return sal_True;
160 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_NET) )
161 return sal_True;
163 return sal_False;
166 sal_Bool ChartTypeHelper::isSupportingMainAxis( const uno::Reference< XChartType >& xChartType, sal_Int32 nDimensionCount, sal_Int32 nDimensionIndex )
168 //pie charts do not support axis at all
169 //no 3rd axis for 2D charts
171 //@todo ask charttype itself --> need model change first
172 if(xChartType.is())
174 rtl::OUString aChartTypeName = xChartType->getChartType();
175 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_PIE) )
176 return sal_False;
178 if( nDimensionIndex == 2 )
179 return nDimensionCount == 3;
181 return sal_True;
184 sal_Bool ChartTypeHelper::isSupportingSecondaryAxis( const uno::Reference< XChartType >& xChartType, sal_Int32 nDimensionCount, sal_Int32 /*nDimensionIndex*/ )
186 //3D, pie and net charts do not support a secondary axis at all
188 //@todo ask charttype itself --> need model change first
189 if(xChartType.is())
191 if(nDimensionCount==3)
192 return sal_False;
194 rtl::OUString aChartTypeName = xChartType->getChartType();
195 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_PIE) )
196 return sal_False;
197 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_NET) )
198 return sal_False;
199 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_FILLED_NET) )
200 return sal_False;
202 return sal_True;
205 sal_Bool ChartTypeHelper::isSupportingOverlapAndGapWidthProperties(
206 const uno::Reference< XChartType >& xChartType, sal_Int32 nDimensionCount )
208 //2D bar charts do support a this special properties
210 //@todo ask charttype itself --> need model change first
211 if(xChartType.is())
213 if(nDimensionCount==3)
214 return sal_False;
216 rtl::OUString aChartTypeName = xChartType->getChartType();
217 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_COLUMN) )
218 return sal_True;
219 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_BAR) )
220 return sal_True;
222 return sal_False;
225 sal_Bool ChartTypeHelper::isSupportingBarConnectors(
226 const uno::Reference< chart2::XChartType >& xChartType, sal_Int32 nDimensionCount )
228 //2D bar charts with stacked series support this
230 //@todo ask charttype itself --> need model change first
231 if(xChartType.is())
233 if(nDimensionCount==3)
234 return sal_False;
236 bool bFound=false;
237 bool bAmbiguous=false;
238 StackMode eStackMode = DiagramHelper::getStackModeFromChartType( xChartType, bFound, bAmbiguous, 0 );
239 if( eStackMode != StackMode_Y_STACKED || bAmbiguous )
240 return sal_False;
242 rtl::OUString aChartTypeName = xChartType->getChartType();
243 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_COLUMN) )
244 return sal_True;
245 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_BAR) )
246 return sal_True; // note: old chart was false here
248 return sal_False;
251 uno::Sequence < sal_Int32 > ChartTypeHelper::getSupportedLabelPlacements( const uno::Reference< chart2::XChartType >& xChartType
252 , sal_Int32 nDimensionCount, sal_Bool bSwapXAndY
253 , const uno::Reference< chart2::XDataSeries >& xSeries )
255 (void)nDimensionCount;
257 uno::Sequence < sal_Int32 > aRet;
258 if( !xChartType.is() )
259 return aRet;
261 rtl::OUString aChartTypeName = xChartType->getChartType();
262 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_PIE) )
264 bool bDonut = false;
265 uno::Reference< beans::XPropertySet > xChartTypeProp( xChartType, uno::UNO_QUERY_THROW );
266 if(xChartTypeProp.is())
267 xChartTypeProp->getPropertyValue( C2U("UseRings")) >>= bDonut;
269 if(!bDonut)
271 aRet.realloc(4);
272 sal_Int32* pSeq = aRet.getArray();
273 *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::AVOID_OVERLAP;
274 *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::OUTSIDE;
275 *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::INSIDE;
276 *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::CENTER;
278 else
280 aRet.realloc(1);
281 sal_Int32* pSeq = aRet.getArray();
282 *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::CENTER;
285 else if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_SCATTER)
286 || aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_LINE)
287 || aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_BUBBLE)
290 aRet.realloc(5);
291 sal_Int32* pSeq = aRet.getArray();
292 *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::TOP;
293 *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::BOTTOM;
294 *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::LEFT;
295 *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::RIGHT;
296 *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::CENTER;
298 else if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_COLUMN)
299 || aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_BAR) )
302 bool bStacked = false;
304 uno::Reference< beans::XPropertySet > xSeriesProp( xSeries, uno::UNO_QUERY );
305 chart2::StackingDirection eStacking = chart2::StackingDirection_NO_STACKING;
306 xSeriesProp->getPropertyValue( C2U("StackingDirection") ) >>= eStacking;
307 bStacked = (chart2::StackingDirection_Y_STACKING == eStacking);
310 aRet.realloc( bStacked ? 3 : 6 );
311 sal_Int32* pSeq = aRet.getArray();
312 if(!bStacked)
314 if(bSwapXAndY)
316 *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::RIGHT;
317 *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::LEFT;
319 else
321 *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::TOP;
322 *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::BOTTOM;
325 *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::CENTER;
326 if(!bStacked)
327 *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::OUTSIDE;
328 *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::INSIDE;
329 *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::NEAR_ORIGIN;
331 else if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_AREA) )
333 aRet.realloc(1);
334 sal_Int32* pSeq = aRet.getArray();
335 *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::TOP;
337 else if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_NET) )
339 aRet.realloc(6);
340 sal_Int32* pSeq = aRet.getArray();
341 *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::OUTSIDE;
342 *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::TOP;
343 *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::BOTTOM;
344 *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::LEFT;
345 *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::RIGHT;
346 *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::CENTER;
348 else if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_FILLED_NET) )
350 aRet.realloc(1);
351 sal_Int32* pSeq = aRet.getArray();
352 *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::OUTSIDE;
354 else if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK) )
356 aRet.realloc( 1 );
357 sal_Int32* pSeq = aRet.getArray();
358 *pSeq++ = ::com::sun::star::chart::DataLabelPlacement::OUTSIDE;
360 else
362 OSL_ENSURE( false, "unknown charttype" );
365 return aRet;
368 sal_Bool ChartTypeHelper::isSupportingRightAngledAxes( const uno::Reference< chart2::XChartType >& xChartType )
370 if(xChartType.is())
372 rtl::OUString aChartTypeName = xChartType->getChartType();
373 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_PIE) )
374 return sal_False;
376 return sal_True;
379 bool ChartTypeHelper::isSupportingStartingAngle( const uno::Reference< chart2::XChartType >& xChartType )
381 if(xChartType.is())
383 rtl::OUString aChartTypeName = xChartType->getChartType();
384 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_PIE) )
385 return true;
387 return false;
389 bool ChartTypeHelper::isSupportingBaseValue( const uno::Reference< chart2::XChartType >& xChartType )
391 if(xChartType.is())
393 rtl::OUString aChartTypeName = xChartType->getChartType();
394 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_COLUMN)
395 || aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_BAR)
396 || aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_AREA)
398 return true;
400 return false;
403 bool ChartTypeHelper::isSupportingAxisPositioning( const uno::Reference< chart2::XChartType >& xChartType, sal_Int32 nDimensionCount, sal_Int32 nDimensionIndex )
405 if(xChartType.is())
407 rtl::OUString aChartTypeName = xChartType->getChartType();
408 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_NET) )
409 return false;
410 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_FILLED_NET) )
411 return false;
413 if( nDimensionCount==3 )
414 return nDimensionIndex<2;
415 return true;
418 bool ChartTypeHelper::shiftTicksAtXAxisPerDefault( const uno::Reference< chart2::XChartType >& xChartType )
420 if(xChartType.is())
422 rtl::OUString aChartTypeName = xChartType->getChartType();
423 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_COLUMN)
424 || aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_BAR) )
425 return true;
427 return false;
430 bool ChartTypeHelper::noBordersForSimpleScheme( const uno::Reference< chart2::XChartType >& xChartType )
432 if(xChartType.is())
434 rtl::OUString aChartTypeName = xChartType->getChartType();
435 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_PIE) )
436 return sal_True;
438 return sal_False;
441 //static
442 sal_Int32 ChartTypeHelper::getDefaultDirectLightColor( bool bSimple, const uno::Reference< chart2::XChartType >& xChartType )
444 sal_Int32 nRet = static_cast< sal_Int32 >( 0x808080 ); // grey
445 if( xChartType .is() )
447 rtl::OUString aChartType = xChartType->getChartType();
448 if( aChartType.equals(CHART2_SERVICE_NAME_CHARTTYPE_PIE) )
450 if( bSimple )
451 nRet = static_cast< sal_Int32 >( 0x333333 ); // grey80
452 else
453 nRet = static_cast< sal_Int32 >( 0xb3b3b3 ); // grey30
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;
462 //static
463 sal_Int32 ChartTypeHelper::getDefaultAmbientLightColor( bool bSimple, const uno::Reference< chart2::XChartType >& xChartType )
465 sal_Int32 nRet = static_cast< sal_Int32 >( 0x999999 ); // grey40
466 if( xChartType .is() )
468 rtl::OUString aChartType = xChartType->getChartType();
469 if( aChartType.equals(CHART2_SERVICE_NAME_CHARTTYPE_PIE) )
471 if( bSimple )
472 nRet = static_cast< sal_Int32 >( 0xcccccc ); // grey20
473 else
474 nRet = static_cast< sal_Int32 >( 0x666666 ); // grey60
477 return nRet;
480 drawing::Direction3D ChartTypeHelper::getDefaultSimpleLightDirection( const uno::Reference< chart2::XChartType >& xChartType )
482 drawing::Direction3D aRet(0.0, 0.0, 1.0);
483 if( xChartType .is() )
485 rtl::OUString aChartType = xChartType->getChartType();
486 if( aChartType.equals(CHART2_SERVICE_NAME_CHARTTYPE_PIE) )
487 aRet = drawing::Direction3D(0.0, 0.8, 0.5);
488 else if( aChartType.equals(CHART2_SERVICE_NAME_CHARTTYPE_LINE)
489 || aChartType.equals(CHART2_SERVICE_NAME_CHARTTYPE_SCATTER) )
490 aRet = drawing::Direction3D(0.9, 0.5, 0.05);
492 return aRet;
495 drawing::Direction3D ChartTypeHelper::getDefaultRealisticLightDirection( const uno::Reference< chart2::XChartType >& xChartType )
497 drawing::Direction3D aRet(0.0, 0.0, 1.0);
498 if( xChartType .is() )
500 rtl::OUString aChartType = xChartType->getChartType();
501 if( aChartType.equals(CHART2_SERVICE_NAME_CHARTTYPE_PIE) )
502 aRet = drawing::Direction3D(0.6, 0.6, 0.6);
503 else if( aChartType.equals(CHART2_SERVICE_NAME_CHARTTYPE_LINE)
504 || aChartType.equals(CHART2_SERVICE_NAME_CHARTTYPE_SCATTER) )
505 aRet = drawing::Direction3D(0.9, 0.5, 0.05);
507 return aRet;
510 sal_Int32 ChartTypeHelper::getAxisType( const uno::Reference<
511 XChartType >& xChartType, sal_Int32 nDimensionIndex )
513 //retruned is a constant from constant group ::com::sun::star::chart2::AxisType
515 //@todo ask charttype itself --> need model change first
516 if(!xChartType.is())
517 return AxisType::CATEGORY;
519 rtl::OUString aChartTypeName = xChartType->getChartType();
520 if(2==nDimensionIndex)//z-axis
521 return AxisType::SERIES;
522 if(1==nDimensionIndex)//y-axis
523 return AxisType::REALNUMBER;
524 if(0==nDimensionIndex)//x-axis
526 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_SCATTER)
527 || aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_BUBBLE) )
528 return AxisType::REALNUMBER;
529 return AxisType::CATEGORY;
531 return AxisType::CATEGORY;
534 sal_Int32 ChartTypeHelper::getNumberOfDisplayedSeries(
535 const uno::Reference< XChartType >& xChartType,
536 sal_Int32 nNumberOfSeries )
538 if( xChartType.is() )
542 rtl::OUString aChartTypeName = xChartType->getChartType();
543 if( aChartTypeName.equals(CHART2_SERVICE_NAME_CHARTTYPE_PIE))
545 uno::Reference< beans::XPropertySet > xChartTypeProp( xChartType, uno::UNO_QUERY_THROW );
546 bool bDonut = false;
547 if( (xChartTypeProp->getPropertyValue( C2U("UseRings")) >>= bDonut)
548 && !bDonut )
550 return nNumberOfSeries>0 ? 1 : 0;
554 catch( const uno::Exception & ex )
556 ASSERT_EXCEPTION( ex );
559 return nNumberOfSeries;
562 uno::Sequence < sal_Int32 > ChartTypeHelper::getSupportedMissingValueTreatments( const uno::Reference< XChartType >& xChartType )
564 uno::Sequence < sal_Int32 > aRet;
565 if( !xChartType.is() )
566 return aRet;
568 bool bStacked = false;
569 bool bFound=false;
570 bool bAmbiguous=false;
571 StackMode eStackMode = DiagramHelper::getStackModeFromChartType( xChartType, bFound, bAmbiguous, 0 );
572 bStacked = bFound && (StackMode_Y_STACKED == eStackMode);
574 rtl::OUString aChartTypeName = xChartType->getChartType();
575 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_COLUMN) ||
576 aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_BAR) ||
577 aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_BUBBLE) )
579 aRet.realloc( 2 );
580 sal_Int32* pSeq = aRet.getArray();
581 *pSeq++ = ::com::sun::star::chart::MissingValueTreatment::LEAVE_GAP;
582 *pSeq++ = ::com::sun::star::chart::MissingValueTreatment::USE_ZERO;
584 else if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_AREA) )
586 aRet.realloc( bStacked ? 1 : 2 );
587 sal_Int32* pSeq = aRet.getArray();
588 *pSeq++ = ::com::sun::star::chart::MissingValueTreatment::USE_ZERO;
589 if( !bStacked )
590 *pSeq++ = ::com::sun::star::chart::MissingValueTreatment::CONTINUE;
592 else if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_LINE) ||
593 aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_NET) ||
594 aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_FILLED_NET) )
596 aRet.realloc( bStacked ? 2 : 3 );
597 sal_Int32* pSeq = aRet.getArray();
598 *pSeq++ = ::com::sun::star::chart::MissingValueTreatment::LEAVE_GAP;
599 *pSeq++ = ::com::sun::star::chart::MissingValueTreatment::USE_ZERO;
600 if( !bStacked )
601 *pSeq++ = ::com::sun::star::chart::MissingValueTreatment::CONTINUE;
603 else if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_SCATTER) )
605 aRet.realloc( 3 );
606 sal_Int32* pSeq = aRet.getArray();
607 *pSeq++ = ::com::sun::star::chart::MissingValueTreatment::CONTINUE;
608 *pSeq++ = ::com::sun::star::chart::MissingValueTreatment::LEAVE_GAP;
609 *pSeq++ = ::com::sun::star::chart::MissingValueTreatment::USE_ZERO;
611 else if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_PIE) ||
612 aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK) )
614 aRet.realloc( 0 );
616 else
618 OSL_ENSURE( false, "unknown charttype" );
621 return aRet;
624 bool ChartTypeHelper::isSeriesInFrontOfAxisLine( const uno::Reference< XChartType >& xChartType )
626 if( xChartType.is() )
628 rtl::OUString aChartTypeName = xChartType->getChartType();
629 if( aChartTypeName.match( CHART2_SERVICE_NAME_CHARTTYPE_FILLED_NET ) )
630 return false;
632 return true;
635 rtl::OUString ChartTypeHelper::getRoleOfSequenceForYAxisNumberFormatDetection( const uno::Reference< XChartType >& xChartType )
637 rtl::OUString aRet( C2U( "values-y" ) );
638 if( !xChartType.is() )
639 return aRet;
640 rtl::OUString aChartTypeName = xChartType->getChartType();
641 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK) )
642 aRet = xChartType->getRoleOfSequenceForSeriesLabel();
643 return aRet;
646 rtl::OUString ChartTypeHelper::getRoleOfSequenceForDataLabelNumberFormatDetection( const uno::Reference< XChartType >& xChartType )
648 rtl::OUString aRet( C2U( "values-y" ) );
649 if( !xChartType.is() )
650 return aRet;
651 rtl::OUString aChartTypeName = xChartType->getChartType();
652 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK)
653 || aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_BUBBLE) )
654 aRet = xChartType->getRoleOfSequenceForSeriesLabel();
655 return aRet;
658 bool ChartTypeHelper::shouldLabelNumberFormatKeyBeDetectedFromYAxis( const uno::Reference< XChartType >& xChartType )
660 bool bRet = true;
661 rtl::OUString aChartTypeName = xChartType->getChartType();
662 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_BUBBLE) )
663 bRet = false;
664 return bRet;
667 bool ChartTypeHelper::isSupportingOnlyDeepStackingFor3D( const uno::Reference< XChartType >& xChartType )
669 bool bRet = false;
670 if( !xChartType.is() )
671 return bRet;
673 rtl::OUString aChartTypeName = xChartType->getChartType();
674 if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_LINE) ||
675 aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_SCATTER) ||
676 aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_AREA) )
678 bRet = true;
680 return bRet;
683 //.............................................................................
684 } //namespace chart
685 //.............................................................................