1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 <ChartTypeManager.hxx>
22 #include <ChartTypeTemplate.hxx>
24 #include <strings.hrc>
25 #include <bitmaps.hlst>
26 #include <ChartModelHelper.hxx>
27 #include <DataSeries.hxx>
28 #include <DataSeriesHelper.hxx>
29 #include <Diagram.hxx>
30 #include <ControllerLockGuard.hxx>
31 #include <AxisHelper.hxx>
32 #include <unonames.hxx>
33 #include <BaseCoordinateSystem.hxx>
34 #include <ChartModel.hxx>
36 #include <com/sun/star/chart2/DataPointGeometry3D.hpp>
38 #include <svtools/valueset.hxx>
39 #include <vcl/image.hxx>
40 #include <vcl/settings.hxx>
42 #include <comphelper/diagnose_ex.hxx>
46 using namespace ::com::sun::star
;
47 using namespace ::com::sun::star::chart2
;
49 ChartTypeParameter::ChartTypeParameter()
51 , bXAxisWithValues( false )
55 , eStackMode( GlobalStackMode_NONE
)
56 , eCurveStyle( CurveStyle_LINES
)
57 , nCurveResolution(20)
59 , nGeometry3D(DataPointGeometry3D::CUBOID
)
60 , eThreeDLookScheme(ThreeDLookScheme::ThreeDLookScheme_Realistic
)
61 , bSortByXValues(false)
62 , mbRoundedEdge(false)
66 ChartTypeParameter::ChartTypeParameter( sal_Int32 SubTypeIndex
, bool HasXAxisWithValues
67 , bool Is3DLook
, GlobalStackMode nStackMode
68 , bool HasSymbols
, bool HasLines
69 , CurveStyle nCurveStyle
)
70 : nSubTypeIndex( SubTypeIndex
)
71 , bXAxisWithValues( HasXAxisWithValues
)
73 , bSymbols( HasSymbols
)
75 , eStackMode( nStackMode
)
76 , eCurveStyle( nCurveStyle
)
77 , nCurveResolution(20)
79 , nGeometry3D(DataPointGeometry3D::CUBOID
)
80 , eThreeDLookScheme(ThreeDLookScheme::ThreeDLookScheme_Realistic
)
81 , bSortByXValues(false)
82 , mbRoundedEdge(false)
86 bool ChartTypeParameter::mapsToSameService( const ChartTypeParameter
& rParameter
) const
88 return mapsToSimilarService( rParameter
, 0 );
90 bool ChartTypeParameter::mapsToSimilarService( const ChartTypeParameter
& rParameter
, sal_Int32 nTheHigherTheLess
) const
93 if(nTheHigherTheLess
>nMax
)
95 if( bXAxisWithValues
!=rParameter
.bXAxisWithValues
)
96 return nTheHigherTheLess
>nMax
-1;
97 if( b3DLook
!=rParameter
.b3DLook
)
98 return nTheHigherTheLess
>nMax
-2;
99 if( eStackMode
!=rParameter
.eStackMode
)
100 return nTheHigherTheLess
>nMax
-3;
101 if( nSubTypeIndex
!=rParameter
.nSubTypeIndex
)
102 return nTheHigherTheLess
>nMax
-4;
103 if( bSymbols
!=rParameter
.bSymbols
)
104 return nTheHigherTheLess
>nMax
-5;
105 if( bLines
!=rParameter
.bLines
)
106 return nTheHigherTheLess
>nMax
-6;
110 ChartTypeDialogController::ChartTypeDialogController()
111 : bSupportsXAxisWithValues(false)
116 ChartTypeDialogController::~ChartTypeDialogController()
120 bool ChartTypeDialogController::isSubType( const OUString
& rServiceName
)
122 const tTemplateServiceChartTypeParameterMap
& rTemplateMap
= getTemplateMap();
123 tTemplateServiceChartTypeParameterMap::const_iterator
aIt( rTemplateMap
.find( rServiceName
));
124 return aIt
!= rTemplateMap
.end();
126 ChartTypeParameter
ChartTypeDialogController::getChartTypeParameterForService(
127 const OUString
& rServiceName
128 , const uno::Reference
< beans::XPropertySet
>& xTemplateProps
)
130 ChartTypeParameter aRet
;
131 const tTemplateServiceChartTypeParameterMap
& rTemplateMap
= getTemplateMap();
132 tTemplateServiceChartTypeParameterMap::const_iterator
aIt( rTemplateMap
.find( rServiceName
));
133 if( aIt
!= rTemplateMap
.end())
134 aRet
= (*aIt
).second
;
135 if( xTemplateProps
.is() )
139 xTemplateProps
->getPropertyValue( CHART_UNONAME_CURVE_STYLE
) >>= aRet
.eCurveStyle
;
140 xTemplateProps
->getPropertyValue( CHART_UNONAME_CURVE_RESOLUTION
) >>= aRet
.nCurveResolution
;
141 xTemplateProps
->getPropertyValue( CHART_UNONAME_SPLINE_ORDER
) >>= aRet
.nSplineOrder
;
143 catch( uno::Exception
& ex
)
145 //not all templates need to support CurveStyle, CurveResolution or SplineOrder
146 ex
.Context
.is();//to have debug information without compilation warnings
151 xTemplateProps
->getPropertyValue( u
"Geometry3D"_ustr
) >>= aRet
.nGeometry3D
;
153 catch( uno::Exception
& ex
)
155 //not all templates need to support Geometry3D
156 ex
.Context
.is();//to have debug information without compilation warnings
161 void ChartTypeDialogController::adjustSubTypeAndEnableControls( ChartTypeParameter
& /*rParameter*/ )
164 void ChartTypeDialogController::adjustParameterToSubType( ChartTypeParameter
& rParameter
)
166 switch( rParameter
.nSubTypeIndex
)
169 rParameter
.eStackMode
=GlobalStackMode_STACK_Y
;
172 rParameter
.eStackMode
=GlobalStackMode_STACK_Y_PERCENT
;
175 rParameter
.eStackMode
=GlobalStackMode_STACK_Z
;
178 rParameter
.eStackMode
=GlobalStackMode_NONE
;
182 void ChartTypeDialogController::adjustParameterToMainType( ChartTypeParameter
& rParameter
)
184 bool bFoundSomeMatch
=false;
186 rParameter
.bXAxisWithValues
= bSupportsXAxisWithValues
;
187 if( rParameter
.b3DLook
&& !bSupports3D
)
188 rParameter
.b3DLook
= false;
189 if(!rParameter
.b3DLook
&& rParameter
.eStackMode
==GlobalStackMode_STACK_Z
)
190 rParameter
.eStackMode
= GlobalStackMode_NONE
;
192 const tTemplateServiceChartTypeParameterMap
& rMap
= getTemplateMap();
193 for( sal_Int32 nMatchPrecision
=0; nMatchPrecision
<7 && !bFoundSomeMatch
; nMatchPrecision
++ )
195 for (auto const& elem
: rMap
)
197 if( rParameter
.mapsToSimilarService( elem
.second
, nMatchPrecision
) )
200 ThreeDLookScheme aScheme
= rParameter
.eThreeDLookScheme
;
201 sal_Int32 nCurveResolution
= rParameter
.nCurveResolution
;
202 sal_Int32 nSplineOrder
= rParameter
.nSplineOrder
;
203 CurveStyle eCurveStyle
= rParameter
.eCurveStyle
;
204 sal_Int32 nGeometry3D
= rParameter
.nGeometry3D
;
205 bool bSortByXValues
= rParameter
.bSortByXValues
;
206 bool bRoundedEdge
= rParameter
.mbRoundedEdge
;
208 rParameter
= elem
.second
;
210 //some values should not be changed with charttype
211 rParameter
.eThreeDLookScheme
= aScheme
;
212 rParameter
.nCurveResolution
= nCurveResolution
;
213 rParameter
.nSplineOrder
=nSplineOrder
;
214 rParameter
.eCurveStyle
= eCurveStyle
;
215 rParameter
.nGeometry3D
= nGeometry3D
;
216 rParameter
.bSortByXValues
= bSortByXValues
;
217 rParameter
.mbRoundedEdge
= bRoundedEdge
;
219 bFoundSomeMatch
= true;
227 rParameter
= (*rMap
.begin()).second
;
229 rParameter
= ChartTypeParameter();
232 OUString
ChartTypeDialogController::getServiceNameForParameter( const ChartTypeParameter
& rParameter
) const
234 ChartTypeParameter
aParameter(rParameter
);
235 if( aParameter
.bXAxisWithValues
)
236 aParameter
.eStackMode
= GlobalStackMode_NONE
;
237 if(!aParameter
.b3DLook
&& aParameter
.eStackMode
==GlobalStackMode_STACK_Z
)
238 aParameter
.eStackMode
= GlobalStackMode_NONE
;
239 const tTemplateServiceChartTypeParameterMap
& rMap
= getTemplateMap();
240 for (auto const& elem
: rMap
)
242 if( aParameter
.mapsToSameService(elem
.second
) )
246 OSL_FAIL( "ChartType not implemented yet - use fallback to similar type" );
247 for( sal_Int32 nMatchPrecision
=1; nMatchPrecision
<8; nMatchPrecision
++ )
249 for (auto const& elem
: rMap
)
251 if( aParameter
.mapsToSimilarService(elem
.second
, nMatchPrecision
) )
257 rtl::Reference
< ChartTypeTemplate
> ChartTypeDialogController::getCurrentTemplate(
258 const ChartTypeParameter
& rParameter
259 , const rtl::Reference
< ChartTypeManager
>& xTemplateManager
) const
261 rtl::Reference
< ChartTypeTemplate
> xTemplate
;
263 OUString
aServiceName( getServiceNameForParameter( rParameter
) );
264 if(!aServiceName
.isEmpty())
266 xTemplate
= xTemplateManager
->createTemplate( aServiceName
);
269 uno::Reference
< beans::XPropertySet
> xTemplateProps( static_cast<cppu::OWeakObject
*>(xTemplate
.get()), uno::UNO_QUERY
);
270 if(xTemplateProps
.is())
274 xTemplateProps
->setPropertyValue( CHART_UNONAME_CURVE_STYLE
, uno::Any(rParameter
.eCurveStyle
) );
275 xTemplateProps
->setPropertyValue( CHART_UNONAME_CURVE_RESOLUTION
, uno::Any(rParameter
.nCurveResolution
) );
276 xTemplateProps
->setPropertyValue( CHART_UNONAME_SPLINE_ORDER
, uno::Any(rParameter
.nSplineOrder
) );
278 catch( uno::Exception
& ex
)
280 //not all templates need to support CurveStyle, CurveResolution or SplineOrder
281 ex
.Context
.is();//to have debug information without compilation warnings
285 xTemplateProps
->setPropertyValue( u
"Geometry3D"_ustr
, uno::Any(rParameter
.nGeometry3D
) );
287 catch( uno::Exception
& ex
)
289 //not all templates need to support Geometry3D
290 ex
.Context
.is();//to have debug information without compilation warnings
295 setTemplateProperties( xTemplateProps
);
297 catch( const uno::Exception
& )
299 DBG_UNHANDLED_EXCEPTION("chart2");
307 void ChartTypeDialogController::commitToModel( const ChartTypeParameter
& rParameter
308 , const rtl::Reference
<::chart::ChartModel
>& xChartModel
309 , const uno::Reference
<beans::XPropertySet
>& xTemplateProps
)
311 rtl::Reference
< ::chart::ChartTypeManager
> xTemplateManager
= xChartModel
->getTypeManager();
312 rtl::Reference
< ::chart::ChartTypeTemplate
> xTemplate( getCurrentTemplate( rParameter
, xTemplateManager
) );
316 // locked controllers
317 ControllerLockGuardUNO
aCtrlLockGuard( xChartModel
);
318 rtl::Reference
< Diagram
> xDiagram
= xChartModel
->getFirstChartDiagram();
319 Diagram::tTemplateWithServiceName aTemplateWithService
;
321 aTemplateWithService
= xDiagram
->getTemplate( xTemplateManager
);
322 if( aTemplateWithService
.xChartTypeTemplate
.is())
323 aTemplateWithService
.xChartTypeTemplate
->resetStyles2( xDiagram
);
324 xTemplate
->changeDiagram( xDiagram
);
325 if( AllSettings::GetMathLayoutRTL() )
326 AxisHelper::setRTLAxisLayout( AxisHelper::getCoordinateSystemByIndex( xDiagram
, 0 ) );
327 if( rParameter
.b3DLook
)
328 xDiagram
->setScheme( rParameter
.eThreeDLookScheme
);
332 xDiagram
->setPropertyValue(CHART_UNONAME_SORT_BY_XVALUES
, uno::Any(rParameter
.bSortByXValues
));
336 if (xTemplateProps
.is()) {
337 xTemplateProps
->getPropertyValue(u
"SplitPos"_ustr
) >>= nSplitPos
;
338 xDiagram
->setPropertyValue(u
"SplitPos"_ustr
, uno::Any(nSplitPos
));
341 catch( uno::Exception
& ex
)
343 //not all templates need to support SplitPos
344 ex
.Context
.is();//to have debug information without compilation warnings
349 void ChartTypeDialogController::fillSubTypeList( ValueSet
& rSubTypeList
, const ChartTypeParameter
& /*rParameter*/ )
351 rSubTypeList
.Clear();
353 bool ChartTypeDialogController::shouldShow_3DLookControl() const
357 bool ChartTypeDialogController::shouldShow_StackingControl() const
361 bool ChartTypeDialogController::shouldShow_SplineControl() const
365 bool ChartTypeDialogController::shouldShow_GeometryControl() const
369 bool ChartTypeDialogController::shouldShow_SortByXValuesResourceGroup() const
374 void ChartTypeDialogController::showExtraControls(weld::Builder
* /*pBuilder*/)
377 void ChartTypeDialogController::hideExtraControls() const
380 void ChartTypeDialogController::fillExtraControls( const rtl::Reference
<::chart::ChartModel
>& /*xChartModel*/
381 , const uno::Reference
< beans::XPropertySet
>& /*xTemplateProps*/ ) const
384 void ChartTypeDialogController::setTemplateProperties( const uno::Reference
< beans::XPropertySet
>& /*xTemplateProps*/ ) const
388 ColumnOrBarChartDialogController_Base::ColumnOrBarChartDialogController_Base()
391 ColumnOrBarChartDialogController_Base::~ColumnOrBarChartDialogController_Base()
394 bool ColumnOrBarChartDialogController_Base::shouldShow_3DLookControl() const
398 bool ColumnOrBarChartDialogController_Base::shouldShow_GeometryControl() const
402 void ColumnOrBarChartDialogController_Base::adjustSubTypeAndEnableControls( ChartTypeParameter
& rParameter
)
404 if(rParameter
.nSubTypeIndex
>3 && !rParameter
.b3DLook
)
406 rParameter
.nSubTypeIndex
=1;
409 ColumnChartDialogController::ColumnChartDialogController()
412 ColumnChartDialogController::~ColumnChartDialogController()
415 OUString
ColumnChartDialogController::getName()
417 return SchResId(STR_TYPE_COLUMN
);
420 OUString
ColumnChartDialogController::getImage()
422 return BMP_TYPE_COLUMN
;
425 const tTemplateServiceChartTypeParameterMap
& ColumnChartDialogController::getTemplateMap() const
427 static tTemplateServiceChartTypeParameterMap s_aTemplateMap
{
428 {"com.sun.star.chart2.template.Column" , ChartTypeParameter(1,false,false,GlobalStackMode_NONE
)},
429 {"com.sun.star.chart2.template.StackedColumn" , ChartTypeParameter(2,false,false,GlobalStackMode_STACK_Y
)},
430 {"com.sun.star.chart2.template.PercentStackedColumn" , ChartTypeParameter(3,false,false,GlobalStackMode_STACK_Y_PERCENT
)},
431 {"com.sun.star.chart2.template.ThreeDColumnFlat" , ChartTypeParameter(1,false,true,GlobalStackMode_NONE
)},
432 {"com.sun.star.chart2.template.StackedThreeDColumnFlat" , ChartTypeParameter(2,false,true,GlobalStackMode_STACK_Y
)},
433 {"com.sun.star.chart2.template.PercentStackedThreeDColumnFlat" , ChartTypeParameter(3,false,true,GlobalStackMode_STACK_Y_PERCENT
)},
434 {"com.sun.star.chart2.template.ThreeDColumnDeep" , ChartTypeParameter(4,false,true,GlobalStackMode_STACK_Z
)}};
435 return s_aTemplateMap
;
437 void ColumnChartDialogController::fillSubTypeList( ValueSet
& rSubTypeList
, const ChartTypeParameter
& rParameter
)
439 rSubTypeList
.Clear();
441 if( rParameter
.b3DLook
)
443 switch(rParameter
.nGeometry3D
)
445 case DataPointGeometry3D::CYLINDER
:
446 rSubTypeList
.InsertItem(1, Image(StockImage::Yes
, BMP_SAEULE_3D_1
));
447 rSubTypeList
.InsertItem(2, Image(StockImage::Yes
, BMP_SAEULE_3D_2
));
448 rSubTypeList
.InsertItem(3, Image(StockImage::Yes
, BMP_SAEULE_3D_3
));
449 rSubTypeList
.InsertItem(4, Image(StockImage::Yes
, BMP_SAEULE_3D_4
));
451 case DataPointGeometry3D::CONE
:
452 rSubTypeList
.InsertItem(1, Image(StockImage::Yes
, BMP_KEGEL_3D_1
));
453 rSubTypeList
.InsertItem(2, Image(StockImage::Yes
, BMP_KEGEL_3D_2
));
454 rSubTypeList
.InsertItem(3, Image(StockImage::Yes
, BMP_KEGEL_3D_3
));
455 rSubTypeList
.InsertItem(4, Image(StockImage::Yes
, BMP_KEGEL_3D_4
));
457 case DataPointGeometry3D::PYRAMID
:
458 rSubTypeList
.InsertItem(1, Image(StockImage::Yes
, BMP_PYRAMID_3D_1
));
459 rSubTypeList
.InsertItem(2, Image(StockImage::Yes
, BMP_PYRAMID_3D_2
));
460 rSubTypeList
.InsertItem(3, Image(StockImage::Yes
, BMP_PYRAMID_3D_3
));
461 rSubTypeList
.InsertItem(4, Image(StockImage::Yes
, BMP_PYRAMID_3D_4
));
463 default: //DataPointGeometry3D::CUBOID:
464 rSubTypeList
.InsertItem(1, Image(StockImage::Yes
, BMP_COLUMNS_3D_1
));
465 rSubTypeList
.InsertItem(2, Image(StockImage::Yes
, BMP_COLUMNS_3D_2
));
466 rSubTypeList
.InsertItem(3, Image(StockImage::Yes
, BMP_COLUMNS_3D_3
));
467 rSubTypeList
.InsertItem(4, Image(StockImage::Yes
, BMP_COLUMNS_3D
));
473 rSubTypeList
.InsertItem(1, Image(StockImage::Yes
, BMP_COLUMNS_2D_1
));
474 rSubTypeList
.InsertItem(2, Image(StockImage::Yes
, BMP_COLUMNS_2D_2
));
475 rSubTypeList
.InsertItem(3, Image(StockImage::Yes
, BMP_COLUMNS_2D_3
));
478 rSubTypeList
.SetItemText( 1, SchResId( STR_NORMAL
) );
479 rSubTypeList
.SetItemText( 2, SchResId( STR_STACKED
) );
480 rSubTypeList
.SetItemText( 3, SchResId( STR_PERCENT
) );
481 rSubTypeList
.SetItemText( 4, SchResId( STR_DEEP
) );
484 BarChartDialogController::BarChartDialogController()
488 BarChartDialogController::~BarChartDialogController()
492 OUString
BarChartDialogController::getName()
494 return SchResId(STR_TYPE_BAR
);
497 OUString
BarChartDialogController::getImage()
502 const tTemplateServiceChartTypeParameterMap
& BarChartDialogController::getTemplateMap() const
504 static tTemplateServiceChartTypeParameterMap s_aTemplateMap
{
505 {"com.sun.star.chart2.template.Bar" , ChartTypeParameter(1,false,false,GlobalStackMode_NONE
)},
506 {"com.sun.star.chart2.template.StackedBar" , ChartTypeParameter(2,false,false,GlobalStackMode_STACK_Y
)},
507 {"com.sun.star.chart2.template.PercentStackedBar" , ChartTypeParameter(3,false,false,GlobalStackMode_STACK_Y_PERCENT
)},
508 {"com.sun.star.chart2.template.ThreeDBarFlat" , ChartTypeParameter(1,false,true,GlobalStackMode_NONE
)},
509 {"com.sun.star.chart2.template.StackedThreeDBarFlat" , ChartTypeParameter(2,false,true,GlobalStackMode_STACK_Y
)},
510 {"com.sun.star.chart2.template.PercentStackedThreeDBarFlat" , ChartTypeParameter(3,false,true,GlobalStackMode_STACK_Y_PERCENT
)},
511 {"com.sun.star.chart2.template.ThreeDBarDeep" , ChartTypeParameter(4,false,true,GlobalStackMode_STACK_Z
)}};
512 return s_aTemplateMap
;
514 void BarChartDialogController::fillSubTypeList( ValueSet
& rSubTypeList
, const ChartTypeParameter
& rParameter
)
516 rSubTypeList
.Clear();
518 if( rParameter
.b3DLook
)
520 switch(rParameter
.nGeometry3D
)
522 case DataPointGeometry3D::CYLINDER
:
523 rSubTypeList
.InsertItem(1, Image(StockImage::Yes
, BMP_ROEHRE_3D_1
));
524 rSubTypeList
.InsertItem(2, Image(StockImage::Yes
, BMP_ROEHRE_3D_2
));
525 rSubTypeList
.InsertItem(3, Image(StockImage::Yes
, BMP_ROEHRE_3D_3
));
526 rSubTypeList
.InsertItem(4, Image(StockImage::Yes
, BMP_ROEHRE_3D_4
));
528 case DataPointGeometry3D::CONE
:
529 rSubTypeList
.InsertItem(1, Image(StockImage::Yes
, BMP_KEGELQ_3D_1
));
530 rSubTypeList
.InsertItem(2, Image(StockImage::Yes
, BMP_KEGELQ_3D_2
));
531 rSubTypeList
.InsertItem(3, Image(StockImage::Yes
, BMP_KEGELQ_3D_3
));
532 rSubTypeList
.InsertItem(4, Image(StockImage::Yes
, BMP_KEGELQ_3D_4
));
534 case DataPointGeometry3D::PYRAMID
:
535 rSubTypeList
.InsertItem(1, Image(StockImage::Yes
, BMP_PYRAMIDQ_3D_1
));
536 rSubTypeList
.InsertItem(2, Image(StockImage::Yes
, BMP_PYRAMIDQ_3D_2
));
537 rSubTypeList
.InsertItem(3, Image(StockImage::Yes
, BMP_PYRAMIDQ_3D_3
));
538 rSubTypeList
.InsertItem(4, Image(StockImage::Yes
, BMP_PYRAMIDQ_3D_4
));
540 default: //DataPointGeometry3D::CUBOID:
541 rSubTypeList
.InsertItem(1, Image(StockImage::Yes
, BMP_BARS_3D_1
));
542 rSubTypeList
.InsertItem(2, Image(StockImage::Yes
, BMP_BARS_3D_2
));
543 rSubTypeList
.InsertItem(3, Image(StockImage::Yes
, BMP_BARS_3D_3
));
544 rSubTypeList
.InsertItem(4, Image(StockImage::Yes
, BMP_BARS_3D
));
550 rSubTypeList
.InsertItem(1, Image(StockImage::Yes
, BMP_BARS_2D_1
));
551 rSubTypeList
.InsertItem(2, Image(StockImage::Yes
, BMP_BARS_2D_2
));
552 rSubTypeList
.InsertItem(3, Image(StockImage::Yes
, BMP_BARS_2D_3
));
554 rSubTypeList
.SetItemText( 1, SchResId( STR_NORMAL
) );
555 rSubTypeList
.SetItemText( 2, SchResId( STR_STACKED
) );
556 rSubTypeList
.SetItemText( 3, SchResId( STR_PERCENT
) );
557 rSubTypeList
.SetItemText( 4, SchResId( STR_DEEP
) );
560 HistogramChartDialogController::HistogramChartDialogController()
565 HistogramChartDialogController::~HistogramChartDialogController()
569 OUString
HistogramChartDialogController::getName()
571 return SchResId(STR_TYPE_HISTOGRAM
);
574 OUString
HistogramChartDialogController::getImage()
576 return BMP_TYPE_HISTOGRAM
;
579 const tTemplateServiceChartTypeParameterMap
& HistogramChartDialogController::getTemplateMap() const
581 static tTemplateServiceChartTypeParameterMap s_aTemplateMap
{
582 {"com.sun.star.chart2.template.Histogram" , ChartTypeParameter(1, false, false, GlobalStackMode_NONE
)}
584 return s_aTemplateMap
;
586 void HistogramChartDialogController::fillSubTypeList(ValueSet
& rSubTypeList
, const ChartTypeParameter
& /*rParameter*/)
588 rSubTypeList
.Clear();
589 rSubTypeList
.InsertItem(1, Image(StockImage::Yes
, BMP_HISTOGRAM
));
590 rSubTypeList
.SetItemText(1, SchResId(STR_HISTOGRAM
));
593 void HistogramChartDialogController::adjustParameterToSubType(ChartTypeParameter
& rParameter
)
595 rParameter
.b3DLook
= false;
597 switch (rParameter
.nSubTypeIndex
)
603 // Standard Histogram
604 rParameter
.eStackMode
= GlobalStackMode_NONE
; // Ensure no stacking
605 rParameter
.bXAxisWithValues
= false; // Standard histogram may not need X-axis values
606 // Set default bin width or other relevant properties if needed
612 // PieChartDialogController
615 PieChartDialogController::PieChartDialogController()
619 PieChartDialogController::~PieChartDialogController()
623 OUString
PieChartDialogController::getName()
625 return SchResId(STR_TYPE_PIE
);
628 OUString
PieChartDialogController::getImage()
633 const tTemplateServiceChartTypeParameterMap
& PieChartDialogController::getTemplateMap() const
635 static tTemplateServiceChartTypeParameterMap s_aTemplateMap
{
636 {"com.sun.star.chart2.template.Pie" , ChartTypeParameter(1,false,false)},
637 {"com.sun.star.chart2.template.PieAllExploded" , ChartTypeParameter(2,false,false)},
638 {"com.sun.star.chart2.template.Donut" , ChartTypeParameter(3,false,false)},
639 {"com.sun.star.chart2.template.DonutAllExploded" , ChartTypeParameter(4,false,false)},
640 {"com.sun.star.chart2.template.ThreeDPie" , ChartTypeParameter(1,false,true)},
641 {"com.sun.star.chart2.template.ThreeDPieAllExploded" , ChartTypeParameter(2,false,true)},
642 {"com.sun.star.chart2.template.ThreeDDonut" , ChartTypeParameter(3,false,true)},
643 {"com.sun.star.chart2.template.ThreeDDonutAllExploded" , ChartTypeParameter(4,false,true)}};
644 return s_aTemplateMap
;
646 void PieChartDialogController::fillSubTypeList( ValueSet
& rSubTypeList
, const ChartTypeParameter
& rParameter
)
648 rSubTypeList
.Clear();
650 if( rParameter
.b3DLook
)
652 rSubTypeList
.InsertItem(1, Image(StockImage::Yes
, BMP_CIRCLES_3D
));
653 rSubTypeList
.InsertItem(2, Image(StockImage::Yes
, BMP_CIRCLES_3D_EXPLODED
));
654 rSubTypeList
.InsertItem(3, Image(StockImage::Yes
, BMP_DONUT_3D
));
655 rSubTypeList
.InsertItem(4, Image(StockImage::Yes
, BMP_DONUT_3D_EXPLODED
));
659 rSubTypeList
.InsertItem(1, Image(StockImage::Yes
, BMP_CIRCLES_2D
));
660 rSubTypeList
.InsertItem(2, Image(StockImage::Yes
, BMP_CIRCLES_2D_EXPLODED
));
661 rSubTypeList
.InsertItem(3, Image(StockImage::Yes
, BMP_DONUT_2D
));
662 rSubTypeList
.InsertItem(4, Image(StockImage::Yes
, BMP_DONUT_2D_EXPLODED
));
664 rSubTypeList
.SetItemText( 1, SchResId( STR_NORMAL
) );
665 rSubTypeList
.SetItemText( 2, SchResId( STR_PIE_EXPLODED
) );
666 rSubTypeList
.SetItemText( 3, SchResId( STR_DONUT
) );
667 rSubTypeList
.SetItemText( 4, SchResId( STR_DONUT_EXPLODED
) );
670 bool PieChartDialogController::shouldShow_3DLookControl() const
675 void PieChartDialogController::adjustParameterToSubType( ChartTypeParameter
& rParameter
)
677 if(rParameter
.eStackMode
==GlobalStackMode_STACK_Z
)
678 rParameter
.eStackMode
= GlobalStackMode_NONE
;
682 // OfPieChartDialogController
685 OfPieChartDialogController::OfPieChartDialogController()
689 OfPieChartDialogController::~OfPieChartDialogController()
693 OUString
OfPieChartDialogController::getName()
695 return SchResId(STR_TYPE_OFPIE
);
698 OUString
OfPieChartDialogController::getImage()
700 return BMP_TYPE_OFPIE
;
703 const tTemplateServiceChartTypeParameterMap
& OfPieChartDialogController::getTemplateMap() const
705 static tTemplateServiceChartTypeParameterMap s_aTemplateMap
{
706 {"com.sun.star.chart2.template.BarOfPie" , ChartTypeParameter(1,false,false)},
707 {"com.sun.star.chart2.template.PieOfPie" , ChartTypeParameter(2,false,false)}};
708 return s_aTemplateMap
;
710 void OfPieChartDialogController::fillSubTypeList( ValueSet
& rSubTypeList
, const ChartTypeParameter
& /*rParameter*/ )
712 rSubTypeList
.Clear();
714 rSubTypeList
.InsertItem(1, Image(StockImage::Yes
, BMP_BAR_OF_PIE
));
715 rSubTypeList
.InsertItem(2, Image(StockImage::Yes
, BMP_PIE_OF_PIE
));
716 rSubTypeList
.SetItemText( 1, SchResId( STR_BAR_OF_PIE
) );
717 rSubTypeList
.SetItemText( 2, SchResId( STR_PIE_OF_PIE
) );
720 bool OfPieChartDialogController::shouldShow_3DLookControl() const
726 void OfPieChartDialogController::adjustParameterToSubType( ChartTypeParameter
& rParameter
)
728 if(rParameter
.eStackMode
==GlobalStackMode_STACK_Z
)
729 rParameter
.eStackMode
= GlobalStackMode_NONE
;
732 void OfPieChartDialogController::showExtraControls(weld::Builder
* pBuilder
)
734 if (!m_xFT_CompositeSize
)
736 m_xFT_CompositeSize
= pBuilder
->weld_label(u
"compositesizeft"_ustr
);
737 assert(m_xFT_CompositeSize
);
739 if (!m_xMF_CompositeSize
)
741 m_xMF_CompositeSize
= pBuilder
->weld_spin_button(u
"compositesize"_ustr
);
742 assert(m_xMF_CompositeSize
);
744 m_xMF_CompositeSize
->set_increments(1, 10);
745 m_xMF_CompositeSize
->set_range(2, 100);
747 m_xMF_CompositeSize
->connect_value_changed( LINK( this,
748 OfPieChartDialogController
, ChangeCompositeSizeHdl
) );
749 m_xMF_CompositeSize
->set_sensitive(true);
752 m_xFT_CompositeSize
->show();
753 m_xMF_CompositeSize
->show();
756 void OfPieChartDialogController::hideExtraControls() const
758 if (m_xFT_CompositeSize
)
759 m_xFT_CompositeSize
->hide();
760 if (m_xMF_CompositeSize
)
761 m_xMF_CompositeSize
->hide();
764 void OfPieChartDialogController::fillExtraControls(
765 const rtl::Reference
<::chart::ChartModel
>& xChartModel
766 , const uno::Reference
< beans::XPropertySet
>& xTemplateProps
) const
768 if (!m_xMF_CompositeSize
)
771 rtl::Reference
< Diagram
> xDiagram
= xChartModel
->getFirstChartDiagram();
775 sal_Int32 nCompositeSize
= 2;
777 if(xTemplateProps
.is())
781 xTemplateProps
->getPropertyValue( u
"SplitPos"_ustr
) >>= nCompositeSize
;
783 catch( const uno::Exception
& )
785 DBG_UNHANDLED_EXCEPTION("chart2");
788 if( nCompositeSize
< 2 )
790 m_xMF_CompositeSize
->set_value(nCompositeSize
);
792 // Limit based on number of entries in the series
793 const std::vector
< rtl::Reference
< DataSeries
> > dataSeriesVec
=
794 ChartModelHelper::getDataSeries( xChartModel
);
795 if (!dataSeriesVec
.empty()) {
796 const rtl::Reference
<DataSeries
>& ds
= dataSeriesVec
[0];
797 const DataSeries::tDataSequenceContainer data
= ds
->getDataSequences2();
798 const std::vector
< uno::Reference
< chart2::data::XLabeledDataSequence
> > aValuesSeries(
799 DataSeriesHelper::getAllDataSequencesByRole( data
, u
"values"_ustr
) );
801 assert(!aValuesSeries
.empty());
803 const uno::Reference
< chart2::data::XDataSequence
> xSeq( aValuesSeries
.front()->getValues() );
805 // Allow all but one entry to be aggregated in the composite wedge
806 sal_Int32 nMaxCompositeSize
= xSeq
->getData().getLength() - 1;
808 if( nMaxCompositeSize
< 2 )
809 nMaxCompositeSize
= 2;
810 m_xMF_CompositeSize
->set_max(nMaxCompositeSize
);
814 void OfPieChartDialogController::setTemplateProperties( const uno::Reference
< beans::XPropertySet
>& xTemplateProps
) const
816 if( xTemplateProps
.is())
818 sal_Int32 nCompositeSize
= m_xMF_CompositeSize
->get_value();
819 xTemplateProps
->setPropertyValue( u
"SplitPos"_ustr
, uno::Any(nCompositeSize
) );
823 IMPL_LINK_NOARG(OfPieChartDialogController
, ChangeCompositeSizeHdl
, weld::SpinButton
&, void)
825 if( m_pChangeListener
)
826 m_pChangeListener
->stateChanged();
830 // LineChartDialogController
833 LineChartDialogController::LineChartDialogController()
837 LineChartDialogController::~LineChartDialogController()
841 OUString
LineChartDialogController::getName()
843 return SchResId(STR_TYPE_LINE
);
846 OUString
LineChartDialogController::getImage()
848 return BMP_TYPE_LINE
;
851 const tTemplateServiceChartTypeParameterMap
& LineChartDialogController::getTemplateMap() const
853 static tTemplateServiceChartTypeParameterMap s_aTemplateMap
{
854 {"com.sun.star.chart2.template.Symbol" , ChartTypeParameter(1,false,false,GlobalStackMode_NONE
,true,false)},
855 {"com.sun.star.chart2.template.StackedSymbol" , ChartTypeParameter(1,false,false,GlobalStackMode_STACK_Y
,true,false)},
856 {"com.sun.star.chart2.template.PercentStackedSymbol" , ChartTypeParameter(1,false,false,GlobalStackMode_STACK_Y_PERCENT
,true,false)},
857 {"com.sun.star.chart2.template.LineSymbol" , ChartTypeParameter(2,false,false,GlobalStackMode_NONE
,true,true)},
858 {"com.sun.star.chart2.template.StackedLineSymbol" , ChartTypeParameter(2,false,false,GlobalStackMode_STACK_Y
,true,true)},
859 {"com.sun.star.chart2.template.PercentStackedLineSymbol" , ChartTypeParameter(2,false,false,GlobalStackMode_STACK_Y_PERCENT
,true,true)},
860 {"com.sun.star.chart2.template.Line" , ChartTypeParameter(3,false,false,GlobalStackMode_NONE
,false,true)},
861 {"com.sun.star.chart2.template.StackedLine" , ChartTypeParameter(3,false,false,GlobalStackMode_STACK_Y
,false,true)},
862 {"com.sun.star.chart2.template.PercentStackedLine" , ChartTypeParameter(3,false,false,GlobalStackMode_STACK_Y_PERCENT
,false,true)},
863 {"com.sun.star.chart2.template.StackedThreeDLine" , ChartTypeParameter(4,false,true,GlobalStackMode_STACK_Y
,false,true)},
864 {"com.sun.star.chart2.template.PercentStackedThreeDLine" , ChartTypeParameter(4,false,true,GlobalStackMode_STACK_Y_PERCENT
,false,true)},
865 {"com.sun.star.chart2.template.ThreeDLineDeep" , ChartTypeParameter(4,false,true,GlobalStackMode_STACK_Z
,false,true)}};
866 return s_aTemplateMap
;
868 void LineChartDialogController::fillSubTypeList( ValueSet
& rSubTypeList
, const ChartTypeParameter
& rParameter
)
870 rSubTypeList
.Clear();
872 switch( rParameter
.eCurveStyle
)
874 case CurveStyle_CUBIC_SPLINES
:
875 case CurveStyle_B_SPLINES
:
876 if( rParameter
.eStackMode
== GlobalStackMode_NONE
|| rParameter
.eStackMode
== GlobalStackMode_STACK_Z
)
878 rSubTypeList
.InsertItem(1, Image(StockImage::Yes
, BMP_POINTS_XCATEGORY
));
879 rSubTypeList
.InsertItem(2, Image(StockImage::Yes
, BMP_LINE_P_XCATEGORY_SMOOTH
));
880 rSubTypeList
.InsertItem(3, Image(StockImage::Yes
, BMP_LINE_O_XCATEGORY_SMOOTH
));
881 rSubTypeList
.InsertItem(4, Image(StockImage::Yes
, BMP_LINE3D_XCATEGORY_SMOOTH
));
885 rSubTypeList
.InsertItem(1, Image(StockImage::Yes
, BMP_POINTS_STACKED
));
886 rSubTypeList
.InsertItem(2, Image(StockImage::Yes
, BMP_LINE_P_STACKED_SMOOTH
));
887 rSubTypeList
.InsertItem(3, Image(StockImage::Yes
, BMP_LINE_O_STACKED_SMOOTH
));
888 rSubTypeList
.InsertItem(4, Image(StockImage::Yes
, BMP_LINE3D_STACKED_SMOOTH
));
891 case CurveStyle_STEP_START
:
892 case CurveStyle_STEP_END
:
893 case CurveStyle_STEP_CENTER_X
:
894 case CurveStyle_STEP_CENTER_Y
:
895 if( rParameter
.eStackMode
== GlobalStackMode_NONE
|| rParameter
.eStackMode
== GlobalStackMode_STACK_Z
)
897 rSubTypeList
.InsertItem(1, Image(StockImage::Yes
, BMP_POINTS_XCATEGORY
));
898 rSubTypeList
.InsertItem(2, Image(StockImage::Yes
, BMP_LINE_P_XCATEGORY_STEPPED
));
899 rSubTypeList
.InsertItem(3, Image(StockImage::Yes
, BMP_LINE_O_XCATEGORY_STEPPED
));
900 rSubTypeList
.InsertItem(4, Image(StockImage::Yes
, BMP_LINE3D_XCATEGORY_STEPPED
));
904 rSubTypeList
.InsertItem(1, Image(StockImage::Yes
, BMP_POINTS_STACKED
));
905 rSubTypeList
.InsertItem(2, Image(StockImage::Yes
, BMP_LINE_P_STACKED_STEPPED
));
906 rSubTypeList
.InsertItem(3, Image(StockImage::Yes
, BMP_LINE_O_STACKED_STEPPED
));
907 rSubTypeList
.InsertItem(4, Image(StockImage::Yes
, BMP_LINE3D_STACKED_STEPPED
));
910 default: // includes CurveStyle_LINES
912 if( rParameter
.eStackMode
== GlobalStackMode_NONE
|| rParameter
.eStackMode
== GlobalStackMode_STACK_Z
)
914 rSubTypeList
.InsertItem(1, Image(StockImage::Yes
, BMP_POINTS_XCATEGORY
));
915 rSubTypeList
.InsertItem(2, Image(StockImage::Yes
, BMP_LINE_P_XCATEGORY
));
916 rSubTypeList
.InsertItem(3, Image(StockImage::Yes
, BMP_LINE_O_XCATEGORY
));
917 rSubTypeList
.InsertItem(4, Image(StockImage::Yes
, BMP_LINE3D_XCATEGORY
));
921 rSubTypeList
.InsertItem(1, Image(StockImage::Yes
, BMP_POINTS_STACKED
));
922 rSubTypeList
.InsertItem(2, Image(StockImage::Yes
, BMP_LINE_P_STACKED
));
923 rSubTypeList
.InsertItem(3, Image(StockImage::Yes
, BMP_LINE_O_STACKED
));
924 rSubTypeList
.InsertItem(4, Image(StockImage::Yes
, BMP_LINE3D_STACKED
));
928 rSubTypeList
.SetItemText( 1, SchResId( STR_POINTS_ONLY
) );
929 rSubTypeList
.SetItemText( 2, SchResId( STR_POINTS_AND_LINES
) );
930 rSubTypeList
.SetItemText( 3, SchResId( STR_LINES_ONLY
) );
931 rSubTypeList
.SetItemText( 4, SchResId( STR_LINES_3D
) );
933 bool LineChartDialogController::shouldShow_StackingControl() const
937 bool LineChartDialogController::shouldShow_SplineControl() const
941 void LineChartDialogController::adjustParameterToSubType( ChartTypeParameter
& rParameter
)
943 rParameter
.b3DLook
= false;
945 switch( rParameter
.nSubTypeIndex
)
948 rParameter
.bSymbols
= true;
949 rParameter
.bLines
= true;
952 rParameter
.bSymbols
= false;
953 rParameter
.bLines
= true;
956 rParameter
.bSymbols
= false;
957 rParameter
.bLines
= true;
958 rParameter
.b3DLook
= true;
959 if( rParameter
.eStackMode
== GlobalStackMode_NONE
)
960 rParameter
.eStackMode
= GlobalStackMode_STACK_Z
;
963 rParameter
.bSymbols
= true;
964 rParameter
.bLines
= false;
968 if(!rParameter
.b3DLook
&& rParameter
.eStackMode
== GlobalStackMode_STACK_Z
)
969 rParameter
.eStackMode
= GlobalStackMode_NONE
;
971 void LineChartDialogController::adjustParameterToMainType( ChartTypeParameter
& rParameter
)
973 if( rParameter
.b3DLook
&& rParameter
.eStackMode
== GlobalStackMode_NONE
)
974 rParameter
.eStackMode
= GlobalStackMode_STACK_Z
;
976 ChartTypeDialogController::adjustParameterToMainType( rParameter
);
979 XYChartDialogController::XYChartDialogController()
981 bSupportsXAxisWithValues
= true;
984 XYChartDialogController::~XYChartDialogController()
988 OUString
XYChartDialogController::getName()
990 return SchResId(STR_TYPE_XY
);
993 OUString
XYChartDialogController::getImage()
998 const tTemplateServiceChartTypeParameterMap
& XYChartDialogController::getTemplateMap() const
1000 static tTemplateServiceChartTypeParameterMap s_aTemplateMap
{
1001 {"com.sun.star.chart2.template.ScatterSymbol" , ChartTypeParameter(1,true,false,GlobalStackMode_NONE
,true,false)},
1002 {"com.sun.star.chart2.template.ScatterLineSymbol" , ChartTypeParameter(2,true,false,GlobalStackMode_NONE
,true,true)},
1003 {"com.sun.star.chart2.template.ScatterLine" , ChartTypeParameter(3,true,false,GlobalStackMode_NONE
,false,true)},
1004 {"com.sun.star.chart2.template.ThreeDScatter" , ChartTypeParameter(4,true,true,GlobalStackMode_NONE
,false,true)}};
1005 return s_aTemplateMap
;
1008 void XYChartDialogController::fillSubTypeList( ValueSet
& rSubTypeList
, const ChartTypeParameter
& rParameter
)
1010 rSubTypeList
.Clear();
1012 switch (rParameter
.eCurveStyle
)
1014 case CurveStyle_CUBIC_SPLINES
:
1015 case CurveStyle_B_SPLINES
:
1017 rSubTypeList
.InsertItem(1, Image(StockImage::Yes
, BMP_POINTS_XVALUES
));
1018 rSubTypeList
.InsertItem(2, Image(StockImage::Yes
, BMP_LINE_P_XVALUES_SMOOTH
));
1019 rSubTypeList
.InsertItem(3, Image(StockImage::Yes
, BMP_LINE_O_XVALUES_SMOOTH
));
1020 rSubTypeList
.InsertItem(4, Image(StockImage::Yes
, BMP_LINE3D_XVALUES_SMOOTH
));
1023 case CurveStyle_STEP_START
:
1024 case CurveStyle_STEP_END
:
1025 case CurveStyle_STEP_CENTER_X
:
1026 case CurveStyle_STEP_CENTER_Y
:
1028 rSubTypeList
.InsertItem(1, Image(StockImage::Yes
, BMP_POINTS_XVALUES
));
1029 rSubTypeList
.InsertItem(2, Image(StockImage::Yes
, BMP_LINE_P_XVALUES_STEPPED
));
1030 rSubTypeList
.InsertItem(3, Image(StockImage::Yes
, BMP_LINE_O_XVALUES_STEPPED
));
1031 rSubTypeList
.InsertItem(4, Image(StockImage::Yes
, BMP_LINE3D_XVALUES_STEPPED
));
1034 default: // includes CurveStyle_LINES
1035 rSubTypeList
.InsertItem(1, Image(StockImage::Yes
, BMP_POINTS_XVALUES
));
1036 rSubTypeList
.InsertItem(2, Image(StockImage::Yes
, BMP_LINE_P_XVALUES
));
1037 rSubTypeList
.InsertItem(3, Image(StockImage::Yes
, BMP_LINE_O_XVALUES
));
1038 rSubTypeList
.InsertItem(4, Image(StockImage::Yes
, BMP_LINE3D_XVALUES
));
1041 rSubTypeList
.SetItemText( 1, SchResId( STR_POINTS_ONLY
) );
1042 rSubTypeList
.SetItemText( 2, SchResId( STR_POINTS_AND_LINES
) );
1043 rSubTypeList
.SetItemText( 3, SchResId( STR_LINES_ONLY
) );
1044 rSubTypeList
.SetItemText( 4, SchResId( STR_LINES_3D
) );
1046 bool XYChartDialogController::shouldShow_SplineControl() const
1050 bool XYChartDialogController::shouldShow_SortByXValuesResourceGroup() const
1054 void XYChartDialogController::adjustParameterToSubType( ChartTypeParameter
& rParameter
)
1056 rParameter
.eStackMode
=GlobalStackMode_NONE
;
1057 rParameter
.b3DLook
= false;
1058 rParameter
.bXAxisWithValues
= true;
1060 switch( rParameter
.nSubTypeIndex
)
1063 rParameter
.bSymbols
= true;
1064 rParameter
.bLines
= true;
1067 rParameter
.bSymbols
= false;
1068 rParameter
.bLines
= true;
1071 rParameter
.bSymbols
= false;
1072 rParameter
.bLines
= true;
1073 rParameter
.b3DLook
= true;
1074 rParameter
.eStackMode
=GlobalStackMode_STACK_Z
;
1077 rParameter
.bSymbols
= true;
1078 rParameter
.bLines
= false;
1083 AreaChartDialogController::AreaChartDialogController()
1087 AreaChartDialogController::~AreaChartDialogController()
1091 OUString
AreaChartDialogController::getName()
1093 return SchResId(STR_TYPE_AREA
);
1096 OUString
AreaChartDialogController::getImage()
1098 return BMP_TYPE_AREA
;
1101 bool AreaChartDialogController::shouldShow_3DLookControl() const
1106 const tTemplateServiceChartTypeParameterMap
& AreaChartDialogController::getTemplateMap() const
1108 static tTemplateServiceChartTypeParameterMap s_aTemplateMap
{
1109 {"com.sun.star.chart2.template.Area" , ChartTypeParameter(1,false,false,GlobalStackMode_NONE
)},
1110 {"com.sun.star.chart2.template.ThreeDArea" , ChartTypeParameter(1,false,true,GlobalStackMode_STACK_Z
)},
1111 {"com.sun.star.chart2.template.StackedArea" , ChartTypeParameter(2,false,false,GlobalStackMode_STACK_Y
)},
1112 {"com.sun.star.chart2.template.StackedThreeDArea" , ChartTypeParameter(2,false,true,GlobalStackMode_STACK_Y
)},
1113 {"com.sun.star.chart2.template.PercentStackedArea" , ChartTypeParameter(3,false,false,GlobalStackMode_STACK_Y_PERCENT
)},
1114 {"com.sun.star.chart2.template.PercentStackedThreeDArea" , ChartTypeParameter(3,false,true,GlobalStackMode_STACK_Y_PERCENT
)}};
1115 return s_aTemplateMap
;
1118 void AreaChartDialogController::fillSubTypeList( ValueSet
& rSubTypeList
, const ChartTypeParameter
& rParameter
)
1120 rSubTypeList
.Clear();
1122 if( rParameter
.b3DLook
)
1124 rSubTypeList
.InsertItem(1, Image(StockImage::Yes
, BMP_AREAS_3D
));
1125 rSubTypeList
.InsertItem(2, Image(StockImage::Yes
, BMP_AREAS_3D_1
));
1126 rSubTypeList
.InsertItem(3, Image(StockImage::Yes
, BMP_AREAS_3D_2
));
1130 rSubTypeList
.InsertItem(1, Image(StockImage::Yes
, BMP_AREAS_2D_1
));
1131 rSubTypeList
.InsertItem(2, Image(StockImage::Yes
, BMP_AREAS_2D
));
1132 rSubTypeList
.InsertItem(3, Image(StockImage::Yes
, BMP_AREAS_2D_3
));
1135 rSubTypeList
.SetItemText( 1, SchResId( rParameter
.b3DLook
? STR_DEEP
: STR_NORMAL
) );
1136 rSubTypeList
.SetItemText( 2, SchResId( STR_STACKED
) );
1137 rSubTypeList
.SetItemText( 3, SchResId( STR_PERCENT
) );
1139 void AreaChartDialogController::adjustParameterToSubType( ChartTypeParameter
& rParameter
)
1141 rParameter
.eCurveStyle
= CurveStyle_LINES
;
1143 if( rParameter
.nSubTypeIndex
>3 )
1144 rParameter
.nSubTypeIndex
= 1;
1145 switch( rParameter
.nSubTypeIndex
)
1148 rParameter
.eStackMode
=GlobalStackMode_STACK_Y
;
1151 rParameter
.eStackMode
=GlobalStackMode_STACK_Y_PERCENT
;
1154 if( rParameter
.b3DLook
)
1155 rParameter
.eStackMode
=GlobalStackMode_STACK_Z
;
1157 rParameter
.eStackMode
=GlobalStackMode_NONE
;
1161 void AreaChartDialogController::adjustParameterToMainType( ChartTypeParameter
& rParameter
)
1163 if( rParameter
.b3DLook
&& rParameter
.eStackMode
== GlobalStackMode_NONE
)
1164 rParameter
.eStackMode
= GlobalStackMode_STACK_Z
;
1166 ChartTypeDialogController::adjustParameterToMainType( rParameter
);
1169 NetChartDialogController::NetChartDialogController()
1171 bSupports3D
= false;
1174 NetChartDialogController::~NetChartDialogController()
1178 OUString
NetChartDialogController::getName()
1180 return SchResId(STR_TYPE_NET
);
1183 OUString
NetChartDialogController::getImage()
1185 return BMP_TYPE_NET
;
1188 bool NetChartDialogController::shouldShow_StackingControl() const
1193 const tTemplateServiceChartTypeParameterMap
& NetChartDialogController::getTemplateMap() const
1195 static tTemplateServiceChartTypeParameterMap s_aTemplateMap
{
1196 //@todo need templates with symbols only
1197 {"com.sun.star.chart2.template.NetSymbol" , ChartTypeParameter(1,false,false,GlobalStackMode_NONE
,true,false)},
1198 {"com.sun.star.chart2.template.StackedNetSymbol" , ChartTypeParameter(1,false,false,GlobalStackMode_STACK_Y
,true,false)},
1199 {"com.sun.star.chart2.template.PercentStackedNetSymbol" ,ChartTypeParameter(1,false,false,GlobalStackMode_STACK_Y_PERCENT
,true,false)},
1201 {"com.sun.star.chart2.template.Net" , ChartTypeParameter(2,false,false,GlobalStackMode_NONE
,true,true)},
1202 {"com.sun.star.chart2.template.StackedNet" , ChartTypeParameter(2,false,false,GlobalStackMode_STACK_Y
,true,true)},
1203 {"com.sun.star.chart2.template.PercentStackedNet" , ChartTypeParameter(2,false,false,GlobalStackMode_STACK_Y_PERCENT
,true,true)},
1205 {"com.sun.star.chart2.template.NetLine" , ChartTypeParameter(3,false,false,GlobalStackMode_NONE
,false,true)},
1206 {"com.sun.star.chart2.template.StackedNetLine" , ChartTypeParameter(3,false,false,GlobalStackMode_STACK_Y
,false,true)},
1207 {"com.sun.star.chart2.template.PercentStackedNetLine" , ChartTypeParameter(3,false,false,GlobalStackMode_STACK_Y_PERCENT
,false,true)},
1209 {"com.sun.star.chart2.template.FilledNet" , ChartTypeParameter(4,false,false,GlobalStackMode_NONE
,false,false)},
1210 {"com.sun.star.chart2.template.StackedFilledNet" , ChartTypeParameter(4,false,false,GlobalStackMode_STACK_Y
,false,false)},
1211 {"com.sun.star.chart2.template.PercentStackedFilledNet" ,ChartTypeParameter(4,false,false,GlobalStackMode_STACK_Y_PERCENT
,false,false)}};
1212 return s_aTemplateMap
;
1214 void NetChartDialogController::fillSubTypeList( ValueSet
& rSubTypeList
, const ChartTypeParameter
& rParameter
)
1216 rSubTypeList
.Clear();
1218 if( rParameter
.eStackMode
== GlobalStackMode_NONE
)
1220 rSubTypeList
.InsertItem(1, Image(StockImage::Yes
, BMP_NET_SYMB
));
1221 rSubTypeList
.InsertItem(2, Image(StockImage::Yes
, BMP_NET_LINESYMB
));
1222 rSubTypeList
.InsertItem(3, Image(StockImage::Yes
, BMP_NET
));
1223 rSubTypeList
.InsertItem(4, Image(StockImage::Yes
, BMP_NET_FILL
));
1227 rSubTypeList
.InsertItem(1, Image(StockImage::Yes
, BMP_NET_SYMB_STACK
));
1228 rSubTypeList
.InsertItem(2, Image(StockImage::Yes
, BMP_NET_LINESYMB_STACK
));
1229 rSubTypeList
.InsertItem(3, Image(StockImage::Yes
, BMP_NET_STACK
));
1230 rSubTypeList
.InsertItem(4, Image(StockImage::Yes
, BMP_NET_FILL_STACK
));
1233 rSubTypeList
.SetItemText( 1, SchResId( STR_POINTS_ONLY
) );
1234 rSubTypeList
.SetItemText( 2, SchResId( STR_POINTS_AND_LINES
) );
1235 rSubTypeList
.SetItemText( 3, SchResId( STR_LINES_ONLY
) );
1236 rSubTypeList
.SetItemText( 4, SchResId( STR_FILLED
) );
1238 void NetChartDialogController::adjustParameterToSubType( ChartTypeParameter
& rParameter
)
1240 rParameter
.b3DLook
= false;
1241 if(rParameter
.eStackMode
==GlobalStackMode_STACK_Z
)
1242 rParameter
.eStackMode
= GlobalStackMode_NONE
;
1244 switch( rParameter
.nSubTypeIndex
)
1247 rParameter
.bSymbols
= true;
1248 rParameter
.bLines
= true;
1251 rParameter
.bSymbols
= false;
1252 rParameter
.bLines
= true;
1255 rParameter
.bSymbols
= false;
1256 rParameter
.bLines
= false;
1259 rParameter
.bSymbols
= true;
1260 rParameter
.bLines
= false;
1264 StockChartDialogController::StockChartDialogController()
1266 bSupports3D
= false;
1269 StockChartDialogController::~StockChartDialogController()
1273 OUString
StockChartDialogController::getName()
1275 return SchResId(STR_TYPE_STOCK
);
1278 OUString
StockChartDialogController::getImage()
1280 return BMP_TYPE_STOCK
;
1283 const tTemplateServiceChartTypeParameterMap
& StockChartDialogController::getTemplateMap() const
1285 static tTemplateServiceChartTypeParameterMap s_aTemplateMap
{
1286 {"com.sun.star.chart2.template.StockLowHighClose" , ChartTypeParameter(1)},
1287 {"com.sun.star.chart2.template.StockOpenLowHighClose" , ChartTypeParameter(2)},
1288 {"com.sun.star.chart2.template.StockVolumeLowHighClose" , ChartTypeParameter(3)},
1289 {"com.sun.star.chart2.template.StockVolumeOpenLowHighClose" ,ChartTypeParameter(4)}};
1290 return s_aTemplateMap
;
1293 void StockChartDialogController::fillSubTypeList( ValueSet
& rSubTypeList
, const ChartTypeParameter
& /*rParameter*/ )
1295 rSubTypeList
.Clear();
1296 rSubTypeList
.InsertItem(1, Image(StockImage::Yes
, BMP_STOCK_1
));
1297 rSubTypeList
.InsertItem(2, Image(StockImage::Yes
, BMP_STOCK_2
));
1298 rSubTypeList
.InsertItem(3, Image(StockImage::Yes
, BMP_STOCK_3
));
1299 rSubTypeList
.InsertItem(4, Image(StockImage::Yes
, BMP_STOCK_4
));
1301 rSubTypeList
.SetItemText( 1, SchResId(STR_STOCK_1
) );
1302 rSubTypeList
.SetItemText( 2, SchResId(STR_STOCK_2
) );
1303 rSubTypeList
.SetItemText( 3, SchResId(STR_STOCK_3
) );
1304 rSubTypeList
.SetItemText( 4, SchResId(STR_STOCK_4
) );
1307 void StockChartDialogController::adjustParameterToSubType( ChartTypeParameter
& rParameter
)
1309 rParameter
.b3DLook
= false;
1310 rParameter
.eStackMode
= GlobalStackMode_NONE
;
1313 CombiColumnLineChartDialogController::CombiColumnLineChartDialogController()
1315 bSupports3D
= false;
1318 OUString
CombiColumnLineChartDialogController::getName()
1320 return SchResId(STR_TYPE_COMBI_COLUMN_LINE
);
1323 OUString
CombiColumnLineChartDialogController::getImage()
1325 return BMP_TYPE_COLUMN_LINE
;
1328 const tTemplateServiceChartTypeParameterMap
& CombiColumnLineChartDialogController::getTemplateMap() const
1330 static tTemplateServiceChartTypeParameterMap s_aTemplateMap
{
1331 {"com.sun.star.chart2.template.ColumnWithLine" , ChartTypeParameter(1)},
1332 {"com.sun.star.chart2.template.StackedColumnWithLine" , ChartTypeParameter(2,false,false,GlobalStackMode_STACK_Y
)}};
1333 return s_aTemplateMap
;
1336 void CombiColumnLineChartDialogController::fillSubTypeList( ValueSet
& rSubTypeList
, const ChartTypeParameter
& /*rParameter*/ )
1338 rSubTypeList
.Clear();
1339 rSubTypeList
.InsertItem(1, Image(StockImage::Yes
, BMP_COLUMN_LINE
));
1340 rSubTypeList
.InsertItem(2, Image(StockImage::Yes
, BMP_COLUMN_LINE_STACKED
));
1342 rSubTypeList
.SetItemText(1, SchResId(STR_LINE_COLUMN
));
1343 rSubTypeList
.SetItemText(2, SchResId(STR_LINE_STACKEDCOLUMN
));
1346 void CombiColumnLineChartDialogController::showExtraControls(weld::Builder
* pBuilder
)
1348 if (!m_xFT_NumberOfLines
)
1350 m_xFT_NumberOfLines
= pBuilder
->weld_label(u
"nolinesft"_ustr
);
1352 if (!m_xMF_NumberOfLines
)
1354 m_xMF_NumberOfLines
= pBuilder
->weld_spin_button(u
"nolines"_ustr
);
1356 m_xMF_NumberOfLines
->set_increments(1, 10);
1357 m_xMF_NumberOfLines
->set_range(1, 100);
1359 m_xMF_NumberOfLines
->connect_value_changed( LINK( this, CombiColumnLineChartDialogController
, ChangeLineCountHdl
) );
1362 m_xFT_NumberOfLines
->show();
1363 m_xMF_NumberOfLines
->show();
1366 void CombiColumnLineChartDialogController::hideExtraControls() const
1368 if (m_xFT_NumberOfLines
)
1369 m_xFT_NumberOfLines
->hide();
1370 if (m_xMF_NumberOfLines
)
1371 m_xMF_NumberOfLines
->hide();
1374 void CombiColumnLineChartDialogController::fillExtraControls(
1375 const rtl::Reference
<::chart::ChartModel
>& xChartModel
1376 , const uno::Reference
< beans::XPropertySet
>& xTemplateProps
) const
1378 if (!m_xMF_NumberOfLines
)
1381 rtl::Reference
< Diagram
> xDiagram
= xChartModel
->getFirstChartDiagram();
1385 sal_Int32 nNumLines
= 0;
1387 if(xTemplateProps
.is())
1391 xTemplateProps
->getPropertyValue( u
"NumberOfLines"_ustr
) >>= nNumLines
;
1393 catch( const uno::Exception
& )
1395 DBG_UNHANDLED_EXCEPTION("chart2");
1400 m_xMF_NumberOfLines
->set_value(nNumLines
);
1402 sal_Int32 nMaxLines
= ChartModelHelper::getDataSeries( xChartModel
).size() - 1;
1405 m_xMF_NumberOfLines
->set_max(nMaxLines
);
1407 void CombiColumnLineChartDialogController::setTemplateProperties( const uno::Reference
< beans::XPropertySet
>& xTemplateProps
) const
1409 if( xTemplateProps
.is() )
1411 sal_Int32 nNumLines
= m_xMF_NumberOfLines
->get_value();
1412 xTemplateProps
->setPropertyValue( u
"NumberOfLines"_ustr
, uno::Any(nNumLines
) );
1416 IMPL_LINK_NOARG(CombiColumnLineChartDialogController
, ChangeLineCountHdl
, weld::SpinButton
&, void)
1418 if( m_pChangeListener
)
1419 m_pChangeListener
->stateChanged();
1421 void CombiColumnLineChartDialogController::adjustParameterToSubType( ChartTypeParameter
& rParameter
)
1423 rParameter
.b3DLook
= false;
1424 if(rParameter
.eStackMode
==GlobalStackMode_STACK_Z
)
1425 rParameter
.eStackMode
= GlobalStackMode_NONE
;
1427 switch( rParameter
.nSubTypeIndex
)
1430 rParameter
.eStackMode
=GlobalStackMode_STACK_Y
;
1433 rParameter
.eStackMode
=GlobalStackMode_NONE
;
1438 BubbleChartDialogController::BubbleChartDialogController()
1442 BubbleChartDialogController::~BubbleChartDialogController()
1446 OUString
BubbleChartDialogController::getName()
1448 return SchResId(STR_TYPE_BUBBLE
);
1451 OUString
BubbleChartDialogController::getImage()
1453 return BMP_TYPE_BUBBLE
;
1456 const tTemplateServiceChartTypeParameterMap
& BubbleChartDialogController::getTemplateMap() const
1458 static tTemplateServiceChartTypeParameterMap s_aTemplateMap
{
1459 {"com.sun.star.chart2.template.Bubble" , ChartTypeParameter(1,true)}};
1460 return s_aTemplateMap
;
1462 void BubbleChartDialogController::fillSubTypeList( ValueSet
& rSubTypeList
, const ChartTypeParameter
& /*rParameter*/ )
1464 rSubTypeList
.Clear();
1465 rSubTypeList
.InsertItem(1, Image(StockImage::Yes
, BMP_BUBBLE_1
));
1467 rSubTypeList
.SetItemText( 1, SchResId(STR_BUBBLE_1
) );
1469 void BubbleChartDialogController::adjustParameterToSubType( ChartTypeParameter
& rParameter
)
1471 rParameter
.b3DLook
= false;
1472 rParameter
.eStackMode
= GlobalStackMode_NONE
;
1476 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */