Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / chart2 / source / controller / dialogs / ChartTypeDialogController.cxx
blobbbbd5a882f24417295e07edb727f8a81de575741
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <ChartTypeDialogController.hxx>
21 #include <ResId.hxx>
22 #include <strings.hrc>
23 #include <bitmaps.hlst>
24 #include <ChartModelHelper.hxx>
25 #include <DiagramHelper.hxx>
26 #include <ControllerLockGuard.hxx>
27 #include <AxisHelper.hxx>
28 #include <unonames.hxx>
30 #include <com/sun/star/chart2/DataPointGeometry3D.hpp>
31 #include <com/sun/star/chart2/XChartDocument.hpp>
33 #include <svtools/valueset.hxx>
34 #include <vcl/image.hxx>
35 #include <vcl/settings.hxx>
37 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
38 #include <tools/diagnose_ex.h>
40 namespace chart
42 using namespace ::com::sun::star;
43 using namespace ::com::sun::star::chart2;
45 ChartTypeParameter::ChartTypeParameter()
46 : nSubTypeIndex( 1 )
47 , bXAxisWithValues( false )
48 , b3DLook( false )
49 , bSymbols( true )
50 , bLines( true )
51 , eStackMode( GlobalStackMode_NONE )
52 , eCurveStyle( CurveStyle_LINES )
53 , nCurveResolution(20)
54 , nSplineOrder(3)
55 , nGeometry3D(DataPointGeometry3D::CUBOID)
56 , eThreeDLookScheme(ThreeDLookScheme_Realistic)
57 , bSortByXValues(false)
58 , mbRoundedEdge(false)
62 ChartTypeParameter::ChartTypeParameter( sal_Int32 SubTypeIndex, bool HasXAxisWithValues
63 , bool Is3DLook, GlobalStackMode nStackMode
64 , bool HasSymbols, bool HasLines
65 , CurveStyle nCurveStyle )
66 : nSubTypeIndex( SubTypeIndex )
67 , bXAxisWithValues( HasXAxisWithValues )
68 , b3DLook( Is3DLook )
69 , bSymbols( HasSymbols )
70 , bLines( HasLines )
71 , eStackMode( nStackMode )
72 , eCurveStyle( nCurveStyle )
73 , nCurveResolution(20)
74 , nSplineOrder(3)
75 , nGeometry3D(DataPointGeometry3D::CUBOID)
76 , eThreeDLookScheme(ThreeDLookScheme_Realistic)
77 , bSortByXValues(false)
78 , mbRoundedEdge(false)
82 bool ChartTypeParameter::mapsToSameService( const ChartTypeParameter& rParameter ) const
84 return mapsToSimilarService( rParameter, 0 );
86 bool ChartTypeParameter::mapsToSimilarService( const ChartTypeParameter& rParameter, sal_Int32 nTheHigherTheLess ) const
88 sal_Int32 nMax=7;
89 if(nTheHigherTheLess>nMax)
90 return true;
91 if( bXAxisWithValues!=rParameter.bXAxisWithValues )
92 return nTheHigherTheLess>nMax-1;
93 if( b3DLook!=rParameter.b3DLook )
94 return nTheHigherTheLess>nMax-2;
95 if( eStackMode!=rParameter.eStackMode )
96 return nTheHigherTheLess>nMax-3;
97 if( nSubTypeIndex!=rParameter.nSubTypeIndex )
98 return nTheHigherTheLess>nMax-4;
99 if( bSymbols!=rParameter.bSymbols )
100 return nTheHigherTheLess>nMax-5;
101 if( bLines!=rParameter.bLines )
102 return nTheHigherTheLess>nMax-6;
103 return true;
106 ChartTypeDialogController::ChartTypeDialogController()
107 : bSupportsXAxisWithValues(false)
108 , bSupports3D(true)
112 ChartTypeDialogController::~ChartTypeDialogController()
116 bool ChartTypeDialogController::isSubType( const OUString& rServiceName )
118 const tTemplateServiceChartTypeParameterMap& rTemplateMap = getTemplateMap();
119 tTemplateServiceChartTypeParameterMap::const_iterator aIt( rTemplateMap.find( rServiceName ));
120 return aIt != rTemplateMap.end();
122 ChartTypeParameter ChartTypeDialogController::getChartTypeParameterForService(
123 const OUString& rServiceName
124 , const uno::Reference< beans::XPropertySet >& xTemplateProps )
126 ChartTypeParameter aRet;
127 const tTemplateServiceChartTypeParameterMap& rTemplateMap = getTemplateMap();
128 tTemplateServiceChartTypeParameterMap::const_iterator aIt( rTemplateMap.find( rServiceName ));
129 if( aIt != rTemplateMap.end())
130 aRet = (*aIt).second;
131 if( xTemplateProps.is() )
135 xTemplateProps->getPropertyValue( CHART_UNONAME_CURVE_STYLE ) >>= aRet.eCurveStyle;
136 xTemplateProps->getPropertyValue( CHART_UNONAME_CURVE_RESOLUTION ) >>= aRet.nCurveResolution;
137 xTemplateProps->getPropertyValue( CHART_UNONAME_SPLINE_ORDER ) >>= aRet.nSplineOrder;
139 catch( uno::Exception & ex )
141 //not all templates need to support CurveStyle, CurveResolution or SplineOrder
142 ex.Context.is();//to have debug information without compilation warnings
147 xTemplateProps->getPropertyValue( "Geometry3D" ) >>= aRet.nGeometry3D;
149 catch( uno::Exception& ex )
151 //not all templates need to support Geometry3D
152 ex.Context.is();//to have debug information without compilation warnings
155 return aRet;
157 void ChartTypeDialogController::adjustSubTypeAndEnableControls( ChartTypeParameter& /*rParameter*/ )
160 void ChartTypeDialogController::adjustParameterToSubType( ChartTypeParameter& rParameter )
162 switch( rParameter.nSubTypeIndex )
164 case 2:
165 rParameter.eStackMode=GlobalStackMode_STACK_Y;
166 break;
167 case 3:
168 rParameter.eStackMode=GlobalStackMode_STACK_Y_PERCENT;
169 break;
170 case 4:
171 rParameter.eStackMode=GlobalStackMode_STACK_Z;
172 break;
173 default:
174 rParameter.eStackMode=GlobalStackMode_NONE;
175 break;
178 void ChartTypeDialogController::adjustParameterToMainType( ChartTypeParameter& rParameter )
180 bool bFoundSomeMatch=false;
182 rParameter.bXAxisWithValues = bSupportsXAxisWithValues;
183 if( rParameter.b3DLook && !bSupports3D )
184 rParameter.b3DLook = false;
185 if(!rParameter.b3DLook && rParameter.eStackMode==GlobalStackMode_STACK_Z)
186 rParameter.eStackMode = GlobalStackMode_NONE;
188 const tTemplateServiceChartTypeParameterMap& rMap = getTemplateMap();
189 for( sal_Int32 nMatchPrecision=0; nMatchPrecision<7 && !bFoundSomeMatch; nMatchPrecision++ )
191 for (auto const& elem : rMap)
193 if( rParameter.mapsToSimilarService( elem.second, nMatchPrecision ) )
195 //remind some values
196 ThreeDLookScheme aScheme = rParameter.eThreeDLookScheme;
197 sal_Int32 nCurveResolution = rParameter.nCurveResolution;
198 sal_Int32 nSplineOrder = rParameter.nSplineOrder;
199 CurveStyle eCurveStyle = rParameter.eCurveStyle;
200 sal_Int32 nGeometry3D = rParameter.nGeometry3D;
201 bool bSortByXValues = rParameter.bSortByXValues;
202 bool bRoundedEdge = rParameter.mbRoundedEdge;
204 rParameter = elem.second;
206 //some values should not be changed with charttype
207 rParameter.eThreeDLookScheme = aScheme;
208 rParameter.nCurveResolution = nCurveResolution;
209 rParameter.nSplineOrder =nSplineOrder;
210 rParameter.eCurveStyle = eCurveStyle;
211 rParameter.nGeometry3D = nGeometry3D;
212 rParameter.bSortByXValues = bSortByXValues;
213 rParameter.mbRoundedEdge = bRoundedEdge;
215 bFoundSomeMatch = true;
216 break;
220 if(!bFoundSomeMatch)
222 if(!rMap.empty())
223 rParameter = (*rMap.begin()).second;
224 else
225 rParameter = ChartTypeParameter();
228 OUString ChartTypeDialogController::getServiceNameForParameter( const ChartTypeParameter& rParameter ) const
230 ChartTypeParameter aParameter(rParameter);
231 if( aParameter.bXAxisWithValues )
232 aParameter.eStackMode = GlobalStackMode_NONE;
233 if(!aParameter.b3DLook && aParameter.eStackMode==GlobalStackMode_STACK_Z)
234 aParameter.eStackMode = GlobalStackMode_NONE;
235 const tTemplateServiceChartTypeParameterMap& rMap = getTemplateMap();
236 for (auto const& elem : rMap)
238 if( aParameter.mapsToSameService(elem.second) )
239 return elem.first;
242 OSL_FAIL( "ChartType not implemented yet - use fallback to similar type" );
243 for( sal_Int32 nMatchPrecision=1; nMatchPrecision<8; nMatchPrecision++ )
245 for (auto const& elem : rMap)
247 if( aParameter.mapsToSimilarService(elem.second, nMatchPrecision) )
248 return elem.first;
251 return OUString();
253 uno::Reference< XChartTypeTemplate > ChartTypeDialogController::getCurrentTemplate(
254 const ChartTypeParameter& rParameter
255 , const uno::Reference< lang::XMultiServiceFactory >& xTemplateManager ) const
257 uno::Reference< XChartTypeTemplate > xTemplate;
259 OUString aServiceName( getServiceNameForParameter( rParameter ) );
260 if(!aServiceName.isEmpty())
262 xTemplate.set( xTemplateManager->createInstance( aServiceName ), uno::UNO_QUERY );
263 if(xTemplate.is())
265 uno::Reference< beans::XPropertySet > xTemplateProps( xTemplate, uno::UNO_QUERY );
266 if(xTemplateProps.is())
270 xTemplateProps->setPropertyValue( CHART_UNONAME_CURVE_STYLE , uno::Any(rParameter.eCurveStyle) );
271 xTemplateProps->setPropertyValue( CHART_UNONAME_CURVE_RESOLUTION , uno::Any(rParameter.nCurveResolution) );
272 xTemplateProps->setPropertyValue( CHART_UNONAME_SPLINE_ORDER , uno::Any(rParameter.nSplineOrder) );
274 catch( uno::Exception & ex )
276 //not all templates need to support CurveStyle, CurveResolution or SplineOrder
277 ex.Context.is();//to have debug information without compilation warnings
281 xTemplateProps->setPropertyValue( "Geometry3D" , uno::Any(rParameter.nGeometry3D) );
283 catch( uno::Exception & ex )
285 //not all templates need to support Geometry3D
286 ex.Context.is();//to have debug information without compilation warnings
291 setTemplateProperties( xTemplateProps );
293 catch( const uno::Exception & )
295 DBG_UNHANDLED_EXCEPTION("chart2");
300 return xTemplate;
303 void ChartTypeDialogController::commitToModel( const ChartTypeParameter& rParameter
304 , const uno::Reference< XChartDocument >& xChartModel )
306 uno::Reference< lang::XMultiServiceFactory > xTemplateManager( xChartModel->getChartTypeManager(), uno::UNO_QUERY );
307 uno::Reference< XChartTypeTemplate > xTemplate( getCurrentTemplate( rParameter, xTemplateManager ) );
308 if(xTemplate.is())
310 // locked controllers
311 ControllerLockGuardUNO aCtrlLockGuard( xChartModel );
312 uno::Reference< XDiagram > xDiagram = ChartModelHelper::findDiagram( xChartModel );
313 DiagramHelper::tTemplateWithServiceName aTemplateWithService(
314 DiagramHelper::getTemplateForDiagram( xDiagram, xTemplateManager ));
315 if( aTemplateWithService.first.is())
316 aTemplateWithService.first->resetStyles( xDiagram );
317 xTemplate->changeDiagram( xDiagram );
318 if( AllSettings::GetMathLayoutRTL() )
319 AxisHelper::setRTLAxisLayout( AxisHelper::getCoordinateSystemByIndex( xDiagram, 0 ) );
320 if( rParameter.b3DLook )
321 ThreeDHelper::setScheme( xDiagram, rParameter.eThreeDLookScheme );
323 uno::Reference<beans::XPropertySet> xDiaProp(xDiagram, uno::UNO_QUERY);
324 if (xDiaProp.is())
326 xDiaProp->setPropertyValue(CHART_UNONAME_SORT_BY_XVALUES, uno::Any(rParameter.bSortByXValues));
330 void ChartTypeDialogController::fillSubTypeList( SvtValueSet& rSubTypeList, const ChartTypeParameter& /*rParameter*/ )
332 rSubTypeList.Clear();
334 bool ChartTypeDialogController::shouldShow_3DLookControl() const
336 return false;
338 bool ChartTypeDialogController::shouldShow_StackingControl() const
340 return false;
342 bool ChartTypeDialogController::shouldShow_SplineControl() const
344 return false;
346 bool ChartTypeDialogController::shouldShow_GeometryControl() const
348 return false;
350 bool ChartTypeDialogController::shouldShow_SortByXValuesResourceGroup() const
352 return false;
355 void ChartTypeDialogController::showExtraControls(weld::Builder* /*pBuilder*/)
358 void ChartTypeDialogController::hideExtraControls() const
361 void ChartTypeDialogController::fillExtraControls( const uno::Reference< XChartDocument >& /*xChartModel*/
362 , const uno::Reference< beans::XPropertySet >& /*xTemplateProps*/ ) const
365 void ChartTypeDialogController::setTemplateProperties( const uno::Reference< beans::XPropertySet >& /*xTemplateProps*/ ) const
369 ColumnOrBarChartDialogController_Base::ColumnOrBarChartDialogController_Base()
370 : ChartTypeDialogController()
373 ColumnOrBarChartDialogController_Base::~ColumnOrBarChartDialogController_Base()
376 bool ColumnOrBarChartDialogController_Base::shouldShow_3DLookControl() const
378 return true;
380 bool ColumnOrBarChartDialogController_Base::shouldShow_GeometryControl() const
382 return true;
384 void ColumnOrBarChartDialogController_Base::adjustSubTypeAndEnableControls( ChartTypeParameter& rParameter )
386 if(rParameter.nSubTypeIndex>3 && !rParameter.b3DLook)
388 rParameter.nSubTypeIndex=1;
391 ColumnChartDialogController::ColumnChartDialogController()
394 ColumnChartDialogController::~ColumnChartDialogController()
397 OUString ColumnChartDialogController::getName()
399 return SchResId(STR_TYPE_COLUMN);
402 OUString ColumnChartDialogController::getImage()
404 return OUStringLiteral(BMP_TYPE_COLUMN);
407 const tTemplateServiceChartTypeParameterMap& ColumnChartDialogController::getTemplateMap() const
409 static tTemplateServiceChartTypeParameterMap s_aTemplateMap{
410 {"com.sun.star.chart2.template.Column" , ChartTypeParameter(1,false,false,GlobalStackMode_NONE)},
411 {"com.sun.star.chart2.template.StackedColumn" , ChartTypeParameter(2,false,false,GlobalStackMode_STACK_Y)},
412 {"com.sun.star.chart2.template.PercentStackedColumn" , ChartTypeParameter(3,false,false,GlobalStackMode_STACK_Y_PERCENT)},
413 {"com.sun.star.chart2.template.ThreeDColumnFlat" , ChartTypeParameter(1,false,true,GlobalStackMode_NONE)},
414 {"com.sun.star.chart2.template.StackedThreeDColumnFlat" , ChartTypeParameter(2,false,true,GlobalStackMode_STACK_Y)},
415 {"com.sun.star.chart2.template.PercentStackedThreeDColumnFlat" , ChartTypeParameter(3,false,true,GlobalStackMode_STACK_Y_PERCENT)},
416 {"com.sun.star.chart2.template.ThreeDColumnDeep" , ChartTypeParameter(4,false,true,GlobalStackMode_STACK_Z)}};
417 return s_aTemplateMap;
419 void ColumnChartDialogController::fillSubTypeList( SvtValueSet& rSubTypeList, const ChartTypeParameter& rParameter )
421 rSubTypeList.Clear();
423 if( rParameter.b3DLook )
425 switch(rParameter.nGeometry3D)
427 case DataPointGeometry3D::CYLINDER:
428 rSubTypeList.InsertItem(1, Image(StockImage::Yes, BMP_SAEULE_3D_1));
429 rSubTypeList.InsertItem(2, Image(StockImage::Yes, BMP_SAEULE_3D_2));
430 rSubTypeList.InsertItem(3, Image(StockImage::Yes, BMP_SAEULE_3D_3));
431 rSubTypeList.InsertItem(4, Image(StockImage::Yes, BMP_SAEULE_3D_4));
432 break;
433 case DataPointGeometry3D::CONE:
434 rSubTypeList.InsertItem(1, Image(StockImage::Yes, BMP_KEGEL_3D_1));
435 rSubTypeList.InsertItem(2, Image(StockImage::Yes, BMP_KEGEL_3D_2));
436 rSubTypeList.InsertItem(3, Image(StockImage::Yes, BMP_KEGEL_3D_3));
437 rSubTypeList.InsertItem(4, Image(StockImage::Yes, BMP_KEGEL_3D_4));
438 break;
439 case DataPointGeometry3D::PYRAMID:
440 rSubTypeList.InsertItem(1, Image(StockImage::Yes, BMP_PYRAMID_3D_1));
441 rSubTypeList.InsertItem(2, Image(StockImage::Yes, BMP_PYRAMID_3D_2));
442 rSubTypeList.InsertItem(3, Image(StockImage::Yes, BMP_PYRAMID_3D_3));
443 rSubTypeList.InsertItem(4, Image(StockImage::Yes, BMP_PYRAMID_3D_4));
444 break;
445 default: //DataPointGeometry3D::CUBOID:
446 rSubTypeList.InsertItem(1, Image(StockImage::Yes, BMP_COLUMNS_3D_1));
447 rSubTypeList.InsertItem(2, Image(StockImage::Yes, BMP_COLUMNS_3D_2));
448 rSubTypeList.InsertItem(3, Image(StockImage::Yes, BMP_COLUMNS_3D_3));
449 rSubTypeList.InsertItem(4, Image(StockImage::Yes, BMP_COLUMNS_3D));
450 break;
453 else
455 rSubTypeList.InsertItem(1, Image(StockImage::Yes, BMP_COLUMNS_2D_1));
456 rSubTypeList.InsertItem(2, Image(StockImage::Yes, BMP_COLUMNS_2D_2));
457 rSubTypeList.InsertItem(3, Image(StockImage::Yes, BMP_COLUMNS_2D_3));
460 rSubTypeList.SetItemText( 1, SchResId( STR_NORMAL ) );
461 rSubTypeList.SetItemText( 2, SchResId( STR_STACKED ) );
462 rSubTypeList.SetItemText( 3, SchResId( STR_PERCENT ) );
463 rSubTypeList.SetItemText( 4, SchResId( STR_DEEP ) );
466 BarChartDialogController::BarChartDialogController()
470 BarChartDialogController::~BarChartDialogController()
474 OUString BarChartDialogController::getName()
476 return SchResId(STR_TYPE_BAR);
479 OUString BarChartDialogController::getImage()
481 return OUStringLiteral(BMP_TYPE_BAR);
484 const tTemplateServiceChartTypeParameterMap& BarChartDialogController::getTemplateMap() const
486 static tTemplateServiceChartTypeParameterMap s_aTemplateMap{
487 {"com.sun.star.chart2.template.Bar" , ChartTypeParameter(1,false,false,GlobalStackMode_NONE)},
488 {"com.sun.star.chart2.template.StackedBar" , ChartTypeParameter(2,false,false,GlobalStackMode_STACK_Y)},
489 {"com.sun.star.chart2.template.PercentStackedBar" , ChartTypeParameter(3,false,false,GlobalStackMode_STACK_Y_PERCENT)},
490 {"com.sun.star.chart2.template.ThreeDBarFlat" , ChartTypeParameter(1,false,true,GlobalStackMode_NONE)},
491 {"com.sun.star.chart2.template.StackedThreeDBarFlat" , ChartTypeParameter(2,false,true,GlobalStackMode_STACK_Y)},
492 {"com.sun.star.chart2.template.PercentStackedThreeDBarFlat" , ChartTypeParameter(3,false,true,GlobalStackMode_STACK_Y_PERCENT)},
493 {"com.sun.star.chart2.template.ThreeDBarDeep" , ChartTypeParameter(4,false,true,GlobalStackMode_STACK_Z)}};
494 return s_aTemplateMap;
496 void BarChartDialogController::fillSubTypeList( SvtValueSet& rSubTypeList, const ChartTypeParameter& rParameter )
498 rSubTypeList.Clear();
500 if( rParameter.b3DLook )
502 switch(rParameter.nGeometry3D)
504 case DataPointGeometry3D::CYLINDER:
505 rSubTypeList.InsertItem(1, Image(StockImage::Yes, BMP_ROEHRE_3D_1));
506 rSubTypeList.InsertItem(2, Image(StockImage::Yes, BMP_ROEHRE_3D_2));
507 rSubTypeList.InsertItem(3, Image(StockImage::Yes, BMP_ROEHRE_3D_3));
508 rSubTypeList.InsertItem(4, Image(StockImage::Yes, BMP_ROEHRE_3D_4));
509 break;
510 case DataPointGeometry3D::CONE:
511 rSubTypeList.InsertItem(1, Image(StockImage::Yes, BMP_KEGELQ_3D_1));
512 rSubTypeList.InsertItem(2, Image(StockImage::Yes, BMP_KEGELQ_3D_2));
513 rSubTypeList.InsertItem(3, Image(StockImage::Yes, BMP_KEGELQ_3D_3));
514 rSubTypeList.InsertItem(4, Image(StockImage::Yes, BMP_KEGELQ_3D_4));
515 break;
516 case DataPointGeometry3D::PYRAMID:
517 rSubTypeList.InsertItem(1, Image(StockImage::Yes, BMP_PYRAMIDQ_3D_1));
518 rSubTypeList.InsertItem(2, Image(StockImage::Yes, BMP_PYRAMIDQ_3D_2));
519 rSubTypeList.InsertItem(3, Image(StockImage::Yes, BMP_PYRAMIDQ_3D_3));
520 rSubTypeList.InsertItem(4, Image(StockImage::Yes, BMP_PYRAMIDQ_3D_4));
521 break;
522 default: //DataPointGeometry3D::CUBOID:
523 rSubTypeList.InsertItem(1, Image(StockImage::Yes, BMP_BARS_3D_1));
524 rSubTypeList.InsertItem(2, Image(StockImage::Yes, BMP_BARS_3D_2));
525 rSubTypeList.InsertItem(3, Image(StockImage::Yes, BMP_BARS_3D_3));
526 rSubTypeList.InsertItem(4, Image(StockImage::Yes, BMP_BARS_3D));
527 break;
530 else
532 rSubTypeList.InsertItem(1, Image(StockImage::Yes, BMP_BARS_2D_1));
533 rSubTypeList.InsertItem(2, Image(StockImage::Yes, BMP_BARS_2D_2));
534 rSubTypeList.InsertItem(3, Image(StockImage::Yes, BMP_BARS_2D_3));
536 rSubTypeList.SetItemText( 1, SchResId( STR_NORMAL ) );
537 rSubTypeList.SetItemText( 2, SchResId( STR_STACKED ) );
538 rSubTypeList.SetItemText( 3, SchResId( STR_PERCENT ) );
539 rSubTypeList.SetItemText( 4, SchResId( STR_DEEP ) );
542 PieChartDialogController::PieChartDialogController()
546 PieChartDialogController::~PieChartDialogController()
550 OUString PieChartDialogController::getName()
552 return SchResId(STR_TYPE_PIE);
555 OUString PieChartDialogController::getImage()
557 return OUStringLiteral(BMP_TYPE_PIE);
560 const tTemplateServiceChartTypeParameterMap& PieChartDialogController::getTemplateMap() const
562 static tTemplateServiceChartTypeParameterMap s_aTemplateMap{
563 {"com.sun.star.chart2.template.Pie" , ChartTypeParameter(1,false,false)},
564 {"com.sun.star.chart2.template.PieAllExploded" , ChartTypeParameter(2,false,false)},
565 {"com.sun.star.chart2.template.Donut" , ChartTypeParameter(3,false,false)},
566 {"com.sun.star.chart2.template.DonutAllExploded" , ChartTypeParameter(4,false,false)},
567 {"com.sun.star.chart2.template.ThreeDPie" , ChartTypeParameter(1,false,true)},
568 {"com.sun.star.chart2.template.ThreeDPieAllExploded" , ChartTypeParameter(2,false,true)},
569 {"com.sun.star.chart2.template.ThreeDDonut" , ChartTypeParameter(3,false,true)},
570 {"com.sun.star.chart2.template.ThreeDDonutAllExploded" , ChartTypeParameter(4,false,true)}};
571 return s_aTemplateMap;
573 void PieChartDialogController::fillSubTypeList( SvtValueSet& rSubTypeList, const ChartTypeParameter& rParameter )
575 rSubTypeList.Clear();
577 if( rParameter.b3DLook )
579 rSubTypeList.InsertItem(1, Image(StockImage::Yes, BMP_CIRCLES_3D));
580 rSubTypeList.InsertItem(2, Image(StockImage::Yes, BMP_CIRCLES_3D_EXPLODED));
581 rSubTypeList.InsertItem(3, Image(StockImage::Yes, BMP_DONUT_3D));
582 rSubTypeList.InsertItem(4, Image(StockImage::Yes, BMP_DONUT_3D_EXPLODED));
584 else
586 rSubTypeList.InsertItem(1, Image(StockImage::Yes, BMP_CIRCLES_2D));
587 rSubTypeList.InsertItem(2, Image(StockImage::Yes, BMP_CIRCLES_2D_EXPLODED));
588 rSubTypeList.InsertItem(3, Image(StockImage::Yes, BMP_DONUT_2D));
589 rSubTypeList.InsertItem(4, Image(StockImage::Yes, BMP_DONUT_2D_EXPLODED));
591 rSubTypeList.SetItemText( 1, SchResId( STR_NORMAL ) );
592 rSubTypeList.SetItemText( 2, SchResId( STR_PIE_EXPLODED ) );
593 rSubTypeList.SetItemText( 3, SchResId( STR_DONUT ) );
594 rSubTypeList.SetItemText( 4, SchResId( STR_DONUT_EXPLODED ) );
597 bool PieChartDialogController::shouldShow_3DLookControl() const
599 return true;
602 void PieChartDialogController::adjustParameterToSubType( ChartTypeParameter& rParameter )
604 if(rParameter.eStackMode==GlobalStackMode_STACK_Z)
605 rParameter.eStackMode = GlobalStackMode_NONE;
608 LineChartDialogController::LineChartDialogController()
612 LineChartDialogController::~LineChartDialogController()
616 OUString LineChartDialogController::getName()
618 return SchResId(STR_TYPE_LINE);
621 OUString LineChartDialogController::getImage()
623 return OUStringLiteral(BMP_TYPE_LINE);
626 const tTemplateServiceChartTypeParameterMap& LineChartDialogController::getTemplateMap() const
628 static tTemplateServiceChartTypeParameterMap s_aTemplateMap{
629 {"com.sun.star.chart2.template.Symbol" , ChartTypeParameter(1,false,false,GlobalStackMode_NONE,true,false)},
630 {"com.sun.star.chart2.template.StackedSymbol" , ChartTypeParameter(1,false,false,GlobalStackMode_STACK_Y,true,false)},
631 {"com.sun.star.chart2.template.PercentStackedSymbol" , ChartTypeParameter(1,false,false,GlobalStackMode_STACK_Y_PERCENT,true,false)},
632 {"com.sun.star.chart2.template.LineSymbol" , ChartTypeParameter(2,false,false,GlobalStackMode_NONE,true,true)},
633 {"com.sun.star.chart2.template.StackedLineSymbol" , ChartTypeParameter(2,false,false,GlobalStackMode_STACK_Y,true,true)},
634 {"com.sun.star.chart2.template.PercentStackedLineSymbol" , ChartTypeParameter(2,false,false,GlobalStackMode_STACK_Y_PERCENT,true,true)},
635 {"com.sun.star.chart2.template.Line" , ChartTypeParameter(3,false,false,GlobalStackMode_NONE,false,true)},
636 {"com.sun.star.chart2.template.StackedLine" , ChartTypeParameter(3,false,false,GlobalStackMode_STACK_Y,false,true)},
637 {"com.sun.star.chart2.template.PercentStackedLine" , ChartTypeParameter(3,false,false,GlobalStackMode_STACK_Y_PERCENT,false,true)},
638 {"com.sun.star.chart2.template.StackedThreeDLine" , ChartTypeParameter(4,false,true,GlobalStackMode_STACK_Y,false,true)},
639 {"com.sun.star.chart2.template.PercentStackedThreeDLine" , ChartTypeParameter(4,false,true,GlobalStackMode_STACK_Y_PERCENT,false,true)},
640 {"com.sun.star.chart2.template.ThreeDLineDeep" , ChartTypeParameter(4,false,true,GlobalStackMode_STACK_Z,false,true)}};
641 return s_aTemplateMap;
643 void LineChartDialogController::fillSubTypeList( SvtValueSet& rSubTypeList, const ChartTypeParameter& rParameter )
645 rSubTypeList.Clear();
647 switch( rParameter.eCurveStyle )
649 case CurveStyle_CUBIC_SPLINES:
650 case CurveStyle_B_SPLINES:
651 if( rParameter.eStackMode == GlobalStackMode_NONE || rParameter.eStackMode == GlobalStackMode_STACK_Z )
653 rSubTypeList.InsertItem(1, Image(StockImage::Yes, BMP_POINTS_XCATEGORY));
654 rSubTypeList.InsertItem(2, Image(StockImage::Yes, BMP_LINE_P_XCATEGORY_SMOOTH));
655 rSubTypeList.InsertItem(3, Image(StockImage::Yes, BMP_LINE_O_XCATEGORY_SMOOTH));
656 rSubTypeList.InsertItem(4, Image(StockImage::Yes, BMP_LINE3D_XCATEGORY_SMOOTH));
658 else
660 rSubTypeList.InsertItem(1, Image(StockImage::Yes, BMP_POINTS_STACKED));
661 rSubTypeList.InsertItem(2, Image(StockImage::Yes, BMP_LINE_P_STACKED_SMOOTH));
662 rSubTypeList.InsertItem(3, Image(StockImage::Yes, BMP_LINE_O_STACKED_SMOOTH));
663 rSubTypeList.InsertItem(4, Image(StockImage::Yes, BMP_LINE3D_STACKED_SMOOTH));
665 break;
666 case CurveStyle_STEP_START:
667 case CurveStyle_STEP_END:
668 case CurveStyle_STEP_CENTER_X:
669 case CurveStyle_STEP_CENTER_Y:
670 if( rParameter.eStackMode == GlobalStackMode_NONE || rParameter.eStackMode == GlobalStackMode_STACK_Z )
672 rSubTypeList.InsertItem(1, Image(StockImage::Yes, BMP_POINTS_XCATEGORY));
673 rSubTypeList.InsertItem(2, Image(StockImage::Yes, BMP_LINE_P_XCATEGORY_STEPPED));
674 rSubTypeList.InsertItem(3, Image(StockImage::Yes, BMP_LINE_O_XCATEGORY_STEPPED));
675 rSubTypeList.InsertItem(4, Image(StockImage::Yes, BMP_LINE3D_XCATEGORY_STEPPED));
677 else
679 rSubTypeList.InsertItem(1, Image(StockImage::Yes, BMP_POINTS_STACKED));
680 rSubTypeList.InsertItem(2, Image(StockImage::Yes, BMP_LINE_P_STACKED_STEPPED));
681 rSubTypeList.InsertItem(3, Image(StockImage::Yes, BMP_LINE_O_STACKED_STEPPED));
682 rSubTypeList.InsertItem(4, Image(StockImage::Yes, BMP_LINE3D_STACKED_STEPPED));
684 break;
685 default: // includes CurveStyle_LINES
686 //direct lines
687 if( rParameter.eStackMode == GlobalStackMode_NONE || rParameter.eStackMode == GlobalStackMode_STACK_Z )
689 rSubTypeList.InsertItem(1, Image(StockImage::Yes, BMP_POINTS_XCATEGORY));
690 rSubTypeList.InsertItem(2, Image(StockImage::Yes, BMP_LINE_P_XCATEGORY));
691 rSubTypeList.InsertItem(3, Image(StockImage::Yes, BMP_LINE_O_XCATEGORY));
692 rSubTypeList.InsertItem(4, Image(StockImage::Yes, BMP_LINE3D_XCATEGORY));
694 else
696 rSubTypeList.InsertItem(1, Image(StockImage::Yes, BMP_POINTS_STACKED));
697 rSubTypeList.InsertItem(2, Image(StockImage::Yes, BMP_LINE_P_STACKED));
698 rSubTypeList.InsertItem(3, Image(StockImage::Yes, BMP_LINE_O_STACKED));
699 rSubTypeList.InsertItem(4, Image(StockImage::Yes, BMP_LINE3D_STACKED));
703 rSubTypeList.SetItemText( 1, SchResId( STR_POINTS_ONLY ) );
704 rSubTypeList.SetItemText( 2, SchResId( STR_POINTS_AND_LINES ) );
705 rSubTypeList.SetItemText( 3, SchResId( STR_LINES_ONLY ) );
706 rSubTypeList.SetItemText( 4, SchResId( STR_LINES_3D ) );
708 bool LineChartDialogController::shouldShow_StackingControl() const
710 return true;
712 bool LineChartDialogController::shouldShow_SplineControl() const
714 return true;
716 void LineChartDialogController::adjustParameterToSubType( ChartTypeParameter& rParameter )
718 rParameter.b3DLook = false;
720 switch( rParameter.nSubTypeIndex )
722 case 2:
723 rParameter.bSymbols = true;
724 rParameter.bLines = true;
725 break;
726 case 3:
727 rParameter.bSymbols = false;
728 rParameter.bLines = true;
729 break;
730 case 4:
731 rParameter.bSymbols = false;
732 rParameter.bLines = true;
733 rParameter.b3DLook = true;
734 if( rParameter.eStackMode == GlobalStackMode_NONE )
735 rParameter.eStackMode = GlobalStackMode_STACK_Z;
736 break;
737 default:
738 rParameter.bSymbols = true;
739 rParameter.bLines = false;
740 break;
743 if(!rParameter.b3DLook && rParameter.eStackMode == GlobalStackMode_STACK_Z )
744 rParameter.eStackMode = GlobalStackMode_NONE;
746 void LineChartDialogController::adjustParameterToMainType( ChartTypeParameter& rParameter )
748 if( rParameter.b3DLook && rParameter.eStackMode == GlobalStackMode_NONE )
749 rParameter.eStackMode = GlobalStackMode_STACK_Z;
751 ChartTypeDialogController::adjustParameterToMainType( rParameter );
754 XYChartDialogController::XYChartDialogController()
756 bSupportsXAxisWithValues = true;
759 XYChartDialogController::~XYChartDialogController()
763 OUString XYChartDialogController::getName()
765 return SchResId(STR_TYPE_XY);
768 OUString XYChartDialogController::getImage()
770 return OUStringLiteral(BMP_TYPE_XY);
773 const tTemplateServiceChartTypeParameterMap& XYChartDialogController::getTemplateMap() const
775 static tTemplateServiceChartTypeParameterMap s_aTemplateMap{
776 {"com.sun.star.chart2.template.ScatterSymbol" , ChartTypeParameter(1,true,false,GlobalStackMode_NONE,true,false)},
777 {"com.sun.star.chart2.template.ScatterLineSymbol" , ChartTypeParameter(2,true,false,GlobalStackMode_NONE,true,true)},
778 {"com.sun.star.chart2.template.ScatterLine" , ChartTypeParameter(3,true,false,GlobalStackMode_NONE,false,true)},
779 {"com.sun.star.chart2.template.ThreeDScatter" , ChartTypeParameter(4,true,true,GlobalStackMode_NONE,false,true)}};
780 return s_aTemplateMap;
783 void XYChartDialogController::fillSubTypeList( SvtValueSet& rSubTypeList, const ChartTypeParameter& rParameter )
785 rSubTypeList.Clear();
787 switch (rParameter.eCurveStyle)
789 case CurveStyle_CUBIC_SPLINES:
790 case CurveStyle_B_SPLINES:
792 rSubTypeList.InsertItem(1, Image(StockImage::Yes, BMP_POINTS_XVALUES));
793 rSubTypeList.InsertItem(2, Image(StockImage::Yes, BMP_LINE_P_XVALUES_SMOOTH));
794 rSubTypeList.InsertItem(3, Image(StockImage::Yes, BMP_LINE_O_XVALUES_SMOOTH));
795 rSubTypeList.InsertItem(4, Image(StockImage::Yes, BMP_LINE3D_XVALUES_SMOOTH));
796 break;
798 case CurveStyle_STEP_START:
799 case CurveStyle_STEP_END:
800 case CurveStyle_STEP_CENTER_X:
801 case CurveStyle_STEP_CENTER_Y:
803 rSubTypeList.InsertItem(1, Image(StockImage::Yes, BMP_POINTS_XVALUES));
804 rSubTypeList.InsertItem(2, Image(StockImage::Yes, BMP_LINE_P_XVALUES_STEPPED));
805 rSubTypeList.InsertItem(3, Image(StockImage::Yes, BMP_LINE_O_XVALUES_STEPPED));
806 rSubTypeList.InsertItem(4, Image(StockImage::Yes, BMP_LINE3D_XVALUES_STEPPED));
807 break;
809 default: // includes CurveStyle_LINES
810 rSubTypeList.InsertItem(1, Image(StockImage::Yes, BMP_POINTS_XVALUES));
811 rSubTypeList.InsertItem(2, Image(StockImage::Yes, BMP_LINE_P_XVALUES));
812 rSubTypeList.InsertItem(3, Image(StockImage::Yes, BMP_LINE_O_XVALUES));
813 rSubTypeList.InsertItem(4, Image(StockImage::Yes, BMP_LINE3D_XVALUES));
816 rSubTypeList.SetItemText( 1, SchResId( STR_POINTS_ONLY ) );
817 rSubTypeList.SetItemText( 2, SchResId( STR_POINTS_AND_LINES ) );
818 rSubTypeList.SetItemText( 3, SchResId( STR_LINES_ONLY ) );
819 rSubTypeList.SetItemText( 4, SchResId( STR_LINES_3D ) );
821 bool XYChartDialogController::shouldShow_SplineControl() const
823 return true;
825 bool XYChartDialogController::shouldShow_SortByXValuesResourceGroup() const
827 return true;
829 void XYChartDialogController::adjustParameterToSubType( ChartTypeParameter& rParameter )
831 rParameter.eStackMode=GlobalStackMode_NONE;
832 rParameter.b3DLook = false;
833 rParameter.bXAxisWithValues = true;
835 switch( rParameter.nSubTypeIndex )
837 case 2:
838 rParameter.bSymbols = true;
839 rParameter.bLines = true;
840 break;
841 case 3:
842 rParameter.bSymbols = false;
843 rParameter.bLines = true;
844 break;
845 case 4:
846 rParameter.bSymbols = false;
847 rParameter.bLines = true;
848 rParameter.b3DLook = true;
849 rParameter.eStackMode=GlobalStackMode_STACK_Z;
850 break;
851 default:
852 rParameter.bSymbols = true;
853 rParameter.bLines = false;
854 break;
858 AreaChartDialogController::AreaChartDialogController()
862 AreaChartDialogController::~AreaChartDialogController()
866 OUString AreaChartDialogController::getName()
868 return SchResId(STR_TYPE_AREA);
871 OUString AreaChartDialogController::getImage()
873 return OUStringLiteral(BMP_TYPE_AREA);
876 bool AreaChartDialogController::shouldShow_3DLookControl() const
878 return true;
881 const tTemplateServiceChartTypeParameterMap& AreaChartDialogController::getTemplateMap() const
883 static tTemplateServiceChartTypeParameterMap s_aTemplateMap{
884 {"com.sun.star.chart2.template.Area" , ChartTypeParameter(1,false,false,GlobalStackMode_NONE)},
885 {"com.sun.star.chart2.template.ThreeDArea" , ChartTypeParameter(1,false,true,GlobalStackMode_STACK_Z)},
886 {"com.sun.star.chart2.template.StackedArea" , ChartTypeParameter(2,false,false,GlobalStackMode_STACK_Y)},
887 {"com.sun.star.chart2.template.StackedThreeDArea" , ChartTypeParameter(2,false,true,GlobalStackMode_STACK_Y)},
888 {"com.sun.star.chart2.template.PercentStackedArea" , ChartTypeParameter(3,false,false,GlobalStackMode_STACK_Y_PERCENT)},
889 {"com.sun.star.chart2.template.PercentStackedThreeDArea" , ChartTypeParameter(3,false,true,GlobalStackMode_STACK_Y_PERCENT)}};
890 return s_aTemplateMap;
893 void AreaChartDialogController::fillSubTypeList( SvtValueSet& rSubTypeList, const ChartTypeParameter& rParameter )
895 rSubTypeList.Clear();
897 if( rParameter.b3DLook )
899 rSubTypeList.InsertItem(1, Image(StockImage::Yes, BMP_AREAS_3D));
900 rSubTypeList.InsertItem(2, Image(StockImage::Yes, BMP_AREAS_3D_1));
901 rSubTypeList.InsertItem(3, Image(StockImage::Yes, BMP_AREAS_3D_2));
903 else
905 rSubTypeList.InsertItem(1, Image(StockImage::Yes, BMP_AREAS_2D_1));
906 rSubTypeList.InsertItem(2, Image(StockImage::Yes, BMP_AREAS_2D));
907 rSubTypeList.InsertItem(3, Image(StockImage::Yes, BMP_AREAS_2D_3));
910 rSubTypeList.SetItemText( 1, SchResId( rParameter.b3DLook ? STR_DEEP : STR_NORMAL ) );
911 rSubTypeList.SetItemText( 2, SchResId( STR_STACKED ) );
912 rSubTypeList.SetItemText( 3, SchResId( STR_PERCENT ) );
914 void AreaChartDialogController::adjustParameterToSubType( ChartTypeParameter& rParameter )
916 rParameter.eCurveStyle = CurveStyle_LINES;
918 if( rParameter.nSubTypeIndex>3 )
919 rParameter.nSubTypeIndex = 1;
920 switch( rParameter.nSubTypeIndex )
922 case 2:
923 rParameter.eStackMode=GlobalStackMode_STACK_Y;
924 break;
925 case 3:
926 rParameter.eStackMode=GlobalStackMode_STACK_Y_PERCENT;
927 break;
928 default:
929 if( rParameter.b3DLook )
930 rParameter.eStackMode=GlobalStackMode_STACK_Z;
931 else
932 rParameter.eStackMode=GlobalStackMode_NONE;
933 break;
936 void AreaChartDialogController::adjustParameterToMainType( ChartTypeParameter& rParameter )
938 if( rParameter.b3DLook && rParameter.eStackMode == GlobalStackMode_NONE )
939 rParameter.eStackMode = GlobalStackMode_STACK_Z;
941 ChartTypeDialogController::adjustParameterToMainType( rParameter );
944 NetChartDialogController::NetChartDialogController()
946 bSupports3D = false;
949 NetChartDialogController::~NetChartDialogController()
953 OUString NetChartDialogController::getName()
955 return SchResId(STR_TYPE_NET);
958 OUString NetChartDialogController::getImage()
960 return OUStringLiteral(BMP_TYPE_NET);
963 bool NetChartDialogController::shouldShow_StackingControl() const
965 return true;
968 const tTemplateServiceChartTypeParameterMap& NetChartDialogController::getTemplateMap() const
970 static tTemplateServiceChartTypeParameterMap s_aTemplateMap{
971 //@todo need templates with symbols only
972 {"com.sun.star.chart2.template.NetSymbol" , ChartTypeParameter(1,false,false,GlobalStackMode_NONE,true,false)},
973 {"com.sun.star.chart2.template.StackedNetSymbol" , ChartTypeParameter(1,false,false,GlobalStackMode_STACK_Y,true,false)},
974 {"com.sun.star.chart2.template.PercentStackedNetSymbol" ,ChartTypeParameter(1,false,false,GlobalStackMode_STACK_Y_PERCENT,true,false)},
976 {"com.sun.star.chart2.template.Net" , ChartTypeParameter(2,false,false,GlobalStackMode_NONE,true,true)},
977 {"com.sun.star.chart2.template.StackedNet" , ChartTypeParameter(2,false,false,GlobalStackMode_STACK_Y,true,true)},
978 {"com.sun.star.chart2.template.PercentStackedNet" , ChartTypeParameter(2,false,false,GlobalStackMode_STACK_Y_PERCENT,true,true)},
980 {"com.sun.star.chart2.template.NetLine" , ChartTypeParameter(3,false,false,GlobalStackMode_NONE,false,true)},
981 {"com.sun.star.chart2.template.StackedNetLine" , ChartTypeParameter(3,false,false,GlobalStackMode_STACK_Y,false,true)},
982 {"com.sun.star.chart2.template.PercentStackedNetLine" , ChartTypeParameter(3,false,false,GlobalStackMode_STACK_Y_PERCENT,false,true)},
984 {"com.sun.star.chart2.template.FilledNet" , ChartTypeParameter(4,false,false,GlobalStackMode_NONE,false,false)},
985 {"com.sun.star.chart2.template.StackedFilledNet" , ChartTypeParameter(4,false,false,GlobalStackMode_STACK_Y,false,false)},
986 {"com.sun.star.chart2.template.PercentStackedFilledNet" ,ChartTypeParameter(4,false,false,GlobalStackMode_STACK_Y_PERCENT,false,false)}};
987 return s_aTemplateMap;
989 void NetChartDialogController::fillSubTypeList( SvtValueSet& rSubTypeList, const ChartTypeParameter& rParameter )
991 rSubTypeList.Clear();
993 if( rParameter.eStackMode == GlobalStackMode_NONE )
995 rSubTypeList.InsertItem(1, Image(StockImage::Yes, BMP_NET_SYMB));
996 rSubTypeList.InsertItem(2, Image(StockImage::Yes, BMP_NET_LINESYMB));
997 rSubTypeList.InsertItem(3, Image(StockImage::Yes, BMP_NET));
998 rSubTypeList.InsertItem(4, Image(StockImage::Yes, BMP_NET_FILL));
1000 else
1002 rSubTypeList.InsertItem(1, Image(StockImage::Yes, BMP_NET_SYMB_STACK));
1003 rSubTypeList.InsertItem(2, Image(StockImage::Yes, BMP_NET_LINESYMB_STACK));
1004 rSubTypeList.InsertItem(3, Image(StockImage::Yes, BMP_NET_STACK));
1005 rSubTypeList.InsertItem(4, Image(StockImage::Yes, BMP_NET_FILL_STACK));
1008 rSubTypeList.SetItemText( 1, SchResId( STR_POINTS_ONLY ) );
1009 rSubTypeList.SetItemText( 2, SchResId( STR_POINTS_AND_LINES ) );
1010 rSubTypeList.SetItemText( 3, SchResId( STR_LINES_ONLY ) );
1011 rSubTypeList.SetItemText( 4, SchResId( STR_FILLED ) );
1013 void NetChartDialogController::adjustParameterToSubType( ChartTypeParameter& rParameter )
1015 rParameter.b3DLook = false;
1016 if(rParameter.eStackMode==GlobalStackMode_STACK_Z)
1017 rParameter.eStackMode = GlobalStackMode_NONE;
1019 switch( rParameter.nSubTypeIndex )
1021 case 2:
1022 rParameter.bSymbols = true;
1023 rParameter.bLines = true;
1024 break;
1025 case 3:
1026 rParameter.bSymbols = false;
1027 rParameter.bLines = true;
1028 break;
1029 case 4:
1030 rParameter.bSymbols = false;
1031 rParameter.bLines = false;
1032 break;
1033 default:
1034 rParameter.bSymbols = true;
1035 rParameter.bLines = false;
1036 break;
1039 StockChartDialogController::StockChartDialogController()
1041 bSupports3D = false;
1044 StockChartDialogController::~StockChartDialogController()
1048 OUString StockChartDialogController::getName()
1050 return SchResId(STR_TYPE_STOCK);
1053 OUString StockChartDialogController::getImage()
1055 return OUStringLiteral(BMP_TYPE_STOCK);
1058 const tTemplateServiceChartTypeParameterMap& StockChartDialogController::getTemplateMap() const
1060 static tTemplateServiceChartTypeParameterMap s_aTemplateMap{
1061 {"com.sun.star.chart2.template.StockLowHighClose" , ChartTypeParameter(1)},
1062 {"com.sun.star.chart2.template.StockOpenLowHighClose" , ChartTypeParameter(2)},
1063 {"com.sun.star.chart2.template.StockVolumeLowHighClose" , ChartTypeParameter(3)},
1064 {"com.sun.star.chart2.template.StockVolumeOpenLowHighClose" ,ChartTypeParameter(4)}};
1065 return s_aTemplateMap;
1068 void StockChartDialogController::fillSubTypeList( SvtValueSet& rSubTypeList, const ChartTypeParameter& /*rParameter*/ )
1070 rSubTypeList.Clear();
1071 rSubTypeList.InsertItem(1, Image(StockImage::Yes, BMP_STOCK_1));
1072 rSubTypeList.InsertItem(2, Image(StockImage::Yes, BMP_STOCK_2));
1073 rSubTypeList.InsertItem(3, Image(StockImage::Yes, BMP_STOCK_3));
1074 rSubTypeList.InsertItem(4, Image(StockImage::Yes, BMP_STOCK_4));
1076 rSubTypeList.SetItemText( 1, SchResId(STR_STOCK_1) );
1077 rSubTypeList.SetItemText( 2, SchResId(STR_STOCK_2) );
1078 rSubTypeList.SetItemText( 3, SchResId(STR_STOCK_3) );
1079 rSubTypeList.SetItemText( 4, SchResId(STR_STOCK_4) );
1082 void StockChartDialogController::adjustParameterToSubType( ChartTypeParameter& rParameter )
1084 rParameter.b3DLook = false;
1085 rParameter.eStackMode = GlobalStackMode_NONE;
1088 CombiColumnLineChartDialogController::CombiColumnLineChartDialogController()
1090 bSupports3D = false;
1093 OUString CombiColumnLineChartDialogController::getName()
1095 return SchResId(STR_TYPE_COMBI_COLUMN_LINE);
1098 OUString CombiColumnLineChartDialogController::getImage()
1100 return OUStringLiteral(BMP_TYPE_COLUMN_LINE);
1103 const tTemplateServiceChartTypeParameterMap& CombiColumnLineChartDialogController::getTemplateMap() const
1105 static tTemplateServiceChartTypeParameterMap s_aTemplateMap{
1106 {"com.sun.star.chart2.template.ColumnWithLine" , ChartTypeParameter(1)},
1107 {"com.sun.star.chart2.template.StackedColumnWithLine" , ChartTypeParameter(2,false,false,GlobalStackMode_STACK_Y)}};
1108 return s_aTemplateMap;
1111 void CombiColumnLineChartDialogController::fillSubTypeList( SvtValueSet& rSubTypeList, const ChartTypeParameter& /*rParameter*/ )
1113 rSubTypeList.Clear();
1114 rSubTypeList.InsertItem(1, Image(StockImage::Yes, BMP_COLUMN_LINE));
1115 rSubTypeList.InsertItem(2, Image(StockImage::Yes, BMP_COLUMN_LINE_STACKED));
1117 rSubTypeList.SetItemText(1, SchResId(STR_LINE_COLUMN));
1118 rSubTypeList.SetItemText(2, SchResId(STR_LINE_STACKEDCOLUMN));
1121 void CombiColumnLineChartDialogController::showExtraControls(weld::Builder* pBuilder)
1123 if (!m_xFT_NumberOfLines)
1125 m_xFT_NumberOfLines = pBuilder->weld_label("nolinesft");
1127 if (!m_xMF_NumberOfLines)
1129 m_xMF_NumberOfLines = pBuilder->weld_spin_button("nolines");
1131 m_xMF_NumberOfLines->set_increments(1, 10);
1132 m_xMF_NumberOfLines->set_range(1, 100);
1134 m_xMF_NumberOfLines->connect_value_changed( LINK( this, CombiColumnLineChartDialogController, ChangeLineCountHdl ) );
1137 m_xFT_NumberOfLines->show();
1138 m_xMF_NumberOfLines->show();
1141 void CombiColumnLineChartDialogController::hideExtraControls() const
1143 if (m_xFT_NumberOfLines)
1144 m_xFT_NumberOfLines->hide();
1145 if (m_xMF_NumberOfLines)
1146 m_xMF_NumberOfLines->hide();
1149 void CombiColumnLineChartDialogController::fillExtraControls(
1150 const uno::Reference< XChartDocument >& xChartModel
1151 , const uno::Reference< beans::XPropertySet >& xTemplateProps ) const
1153 if (!m_xMF_NumberOfLines)
1154 return;
1156 uno::Reference< frame::XModel > xModel = xChartModel;
1158 uno::Reference< XDiagram > xDiagram = ChartModelHelper::findDiagram( xModel );
1159 if(!xDiagram.is())
1160 return;
1162 sal_Int32 nNumLines = 0;
1164 if(xTemplateProps.is())
1168 xTemplateProps->getPropertyValue( "NumberOfLines" ) >>= nNumLines;
1170 catch( const uno::Exception & )
1172 DBG_UNHANDLED_EXCEPTION("chart2");
1175 if( nNumLines < 0 )
1176 nNumLines = 0;
1177 m_xMF_NumberOfLines->set_value(nNumLines);
1179 sal_Int32 nMaxLines = ChartModelHelper::getDataSeries( xModel ).size() - 1;
1180 if( nMaxLines < 0 )
1181 nMaxLines = 0;
1182 m_xMF_NumberOfLines->set_max(nMaxLines);
1184 void CombiColumnLineChartDialogController::setTemplateProperties( const uno::Reference< beans::XPropertySet >& xTemplateProps ) const
1186 if( xTemplateProps.is() )
1188 sal_Int32 nNumLines = m_xMF_NumberOfLines->get_value();
1189 xTemplateProps->setPropertyValue( "NumberOfLines" , uno::Any(nNumLines) );
1193 IMPL_LINK_NOARG(CombiColumnLineChartDialogController, ChangeLineCountHdl, weld::SpinButton&, void)
1195 if( m_pChangeListener )
1196 m_pChangeListener->stateChanged();
1198 void CombiColumnLineChartDialogController::adjustParameterToSubType( ChartTypeParameter& rParameter )
1200 rParameter.b3DLook = false;
1201 if(rParameter.eStackMode==GlobalStackMode_STACK_Z)
1202 rParameter.eStackMode = GlobalStackMode_NONE;
1204 switch( rParameter.nSubTypeIndex )
1206 case 2:
1207 rParameter.eStackMode=GlobalStackMode_STACK_Y;
1208 break;
1209 default:
1210 rParameter.eStackMode=GlobalStackMode_NONE;
1211 break;
1215 BubbleChartDialogController::BubbleChartDialogController()
1219 BubbleChartDialogController::~BubbleChartDialogController()
1223 OUString BubbleChartDialogController::getName()
1225 return SchResId(STR_TYPE_BUBBLE);
1228 OUString BubbleChartDialogController::getImage()
1230 return OUStringLiteral(BMP_TYPE_BUBBLE);
1233 const tTemplateServiceChartTypeParameterMap& BubbleChartDialogController::getTemplateMap() const
1235 static tTemplateServiceChartTypeParameterMap s_aTemplateMap{
1236 {"com.sun.star.chart2.template.Bubble" , ChartTypeParameter(1,true)}};
1237 return s_aTemplateMap;
1239 void BubbleChartDialogController::fillSubTypeList( SvtValueSet& rSubTypeList, const ChartTypeParameter& /*rParameter*/ )
1241 rSubTypeList.Clear();
1242 rSubTypeList.InsertItem(1, Image(StockImage::Yes, BMP_BUBBLE_1));
1244 rSubTypeList.SetItemText( 1, SchResId(STR_BUBBLE_1) );
1246 void BubbleChartDialogController::adjustParameterToSubType( ChartTypeParameter& rParameter )
1248 rParameter.b3DLook = false;
1249 rParameter.eStackMode = GlobalStackMode_NONE;
1251 } //namespace chart
1253 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */