1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_chart2.hxx"
26 
27 #include "ChartTypeDialogController.hxx"
28 #include "ResId.hxx"
29 #include "HelpIds.hrc"
30 #include "Strings.hrc"
31 #include "Bitmaps.hrc"
32 #include "Bitmaps_HC.hrc"
33 #include "macros.hxx"
34 #include "ChartModelHelper.hxx"
35 #include "DiagramHelper.hxx"
36 #include "ControllerLockGuard.hxx"
37 #include "AxisHelper.hxx"
38 
39 #include <com/sun/star/chart2/DataPointGeometry3D.hpp>
40 #include <com/sun/star/chart2/PieChartOffsetMode.hpp>
41 #include <com/sun/star/chart2/XDataSeriesContainer.hpp>
42 
43 #ifndef _SVT_CONTROLDIMS_HRC_
44 #include <svtools/controldims.hrc>
45 #endif
46 // header for class Image
47 #include <vcl/image.hxx>
48 // header for class Bitmap
49 #include <vcl/bitmap.hxx>
50 #include <vcl/svapp.hxx>
51 
52 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
53 
54 //.............................................................................
55 namespace chart
56 {
57 //.............................................................................
58 using namespace ::com::sun::star;
59 using namespace ::com::sun::star::chart2;
60 
61 // macro for selecting a normal or high contrast bitmap the stack variable
62 // bIsHighContrast must exist and reflect the correct state
63 #define SELECT_BITMAP(name) Bitmap( SchResId( bIsHighContrast ? name ## _HC : name ))
64 #define SELECT_IMAGE(name) Image( SchResId( bIsHighContrast ? name ## _HC : name ))
65 
66 /*
67         ( C2U( "com.sun.star.chart2.template.Surface" ),                        CHSTYLE_3D_SURFACE)
68         ( C2U( "com.sun.star.chart2.template.Addin" ),                          CHSTYLE_ADDIN)
69 */
70 
ChartTypeParameter()71 ChartTypeParameter::ChartTypeParameter()
72                     : nSubTypeIndex( 1 )
73                     , bXAxisWithValues( false )
74                     , b3DLook( false )
75                     , bSymbols( true )
76                     , bLines( true )
77                     , eStackMode( GlobalStackMode_NONE )
78                     , eCurveStyle( CurveStyle_LINES )
79                     , nCurveResolution(20)
80                     , nSplineOrder(3)
81                     , nGeometry3D(DataPointGeometry3D::CUBOID)
82                     , eThreeDLookScheme(ThreeDLookScheme_Realistic)
83                     , bSortByXValues(sal_False)
84 {
85 }
86 
ChartTypeParameter(sal_Int32 SubTypeIndex,bool HasXAxisWithValues,bool Is3DLook,GlobalStackMode nStackMode,bool HasSymbols,bool HasLines,CurveStyle nCurveStyle)87 ChartTypeParameter::ChartTypeParameter( sal_Int32 SubTypeIndex, bool HasXAxisWithValues
88                     ,  bool Is3DLook,  GlobalStackMode nStackMode
89                     , bool HasSymbols, bool HasLines
90                     , CurveStyle nCurveStyle )
91                     : nSubTypeIndex( SubTypeIndex )
92                     , bXAxisWithValues( HasXAxisWithValues )
93                     , b3DLook( Is3DLook )
94                     , bSymbols( HasSymbols )
95                     , bLines( HasLines )
96                     , eStackMode( nStackMode )
97                     , eCurveStyle( nCurveStyle )
98                     , nCurveResolution(20)
99                     , nSplineOrder(3)
100                     , nGeometry3D(DataPointGeometry3D::CUBOID)
101                     , eThreeDLookScheme(ThreeDLookScheme_Realistic)
102                     , bSortByXValues(sal_False)
103 {
104 }
~ChartTypeParameter()105 ChartTypeParameter::~ChartTypeParameter()
106 {
107 }
108 
mapsToSameService(const ChartTypeParameter & rParameter) const109 bool ChartTypeParameter::mapsToSameService( const ChartTypeParameter& rParameter ) const
110 {
111     return this->mapsToSimilarService( rParameter, 0 );
112 }
mapsToSimilarService(const ChartTypeParameter & rParameter,sal_Int32 nTheHigherTheLess) const113 bool ChartTypeParameter::mapsToSimilarService( const ChartTypeParameter& rParameter, sal_Int32 nTheHigherTheLess ) const
114 {
115     sal_Int32 nMax=7;
116     if(nTheHigherTheLess>nMax)
117         return true;
118     if( this->bXAxisWithValues!=rParameter.bXAxisWithValues )
119         return nTheHigherTheLess>nMax-1;
120     if( this->b3DLook!=rParameter.b3DLook )
121         return nTheHigherTheLess>nMax-2;
122     if( this->eStackMode!=rParameter.eStackMode )
123         return nTheHigherTheLess>nMax-3;
124     if( this->nSubTypeIndex!=rParameter.nSubTypeIndex )
125         return nTheHigherTheLess>nMax-4;
126     if( this->bSymbols!=rParameter.bSymbols )
127         return nTheHigherTheLess>nMax-5;
128     if( this->bLines!=rParameter.bLines )
129         return nTheHigherTheLess>nMax-6;
130     return true;
131 }
132 
133 //-----------------------------------------------------------------------------
134 //-----------------------------------------------------------------------------
135 //-----------------------------------------------------------------------------
136 
ChartTypeDialogController()137 ChartTypeDialogController::ChartTypeDialogController()
138     : bSupportsXAxisWithValues(false)
139     , bSupports3D(true)
140 {
141 }
142 
~ChartTypeDialogController()143 ChartTypeDialogController::~ChartTypeDialogController()
144 {
145 }
getImage(bool)146 Image ChartTypeDialogController::getImage( bool /*bIsHighContrast*/ )
147 {
148     return Image();
149 }
isSubType(const rtl::OUString & rServiceName)150 bool ChartTypeDialogController::isSubType( const rtl::OUString& rServiceName )
151 {
152     const tTemplateServiceChartTypeParameterMap& rTemplateMap = this->getTemplateMap();
153     tTemplateServiceChartTypeParameterMap::const_iterator aIt( rTemplateMap.find( rServiceName ));
154     if( aIt != rTemplateMap.end())
155         return true;
156     return false;
157 }
getChartTypeParameterForService(const rtl::OUString & rServiceName,const uno::Reference<beans::XPropertySet> & xTemplateProps)158 ChartTypeParameter ChartTypeDialogController::getChartTypeParameterForService(
159                                                     const rtl::OUString& rServiceName
160                                                     , const uno::Reference< beans::XPropertySet >& xTemplateProps )
161 {
162     ChartTypeParameter aRet;
163     const tTemplateServiceChartTypeParameterMap& rTemplateMap = this->getTemplateMap();
164     tTemplateServiceChartTypeParameterMap::const_iterator aIt( rTemplateMap.find( rServiceName ));
165     if( aIt != rTemplateMap.end())
166         aRet = (*aIt).second;
167     if( xTemplateProps.is() )
168     {
169         try
170         {
171             xTemplateProps->getPropertyValue( C2U( "CurveStyle" )) >>= aRet.eCurveStyle;
172             xTemplateProps->getPropertyValue( C2U( "CurveResolution" )) >>= aRet.nCurveResolution;
173             xTemplateProps->getPropertyValue( C2U( "SplineOrder" )) >>= aRet.nSplineOrder;
174         }
175         catch( uno::Exception & ex )
176         {
177             //not all templates need to support CurveStyle, CurveResolution or SplineOrder
178             ex.Context.is();//to have debug information without compilation warnings
179         }
180 
181         try
182         {
183             xTemplateProps->getPropertyValue( C2U( "Geometry3D" )) >>= aRet.nGeometry3D;
184         }
185         catch( uno::Exception& ex )
186 	    {
187             //not all templates need to support CGeometry3D
188             ex.Context.is();//to have debug information without compilation warnings
189         }
190     }
191     return aRet;
192 }
adjustSubTypeAndEnableControls(ChartTypeParameter &)193 void ChartTypeDialogController::adjustSubTypeAndEnableControls( ChartTypeParameter& /*rParameter*/ )
194 {
195 }
adjustParameterToSubType(ChartTypeParameter & rParameter)196 void ChartTypeDialogController::adjustParameterToSubType( ChartTypeParameter& rParameter )
197 {
198     switch( rParameter.nSubTypeIndex )
199     {
200         case 2:
201             rParameter.eStackMode=GlobalStackMode_STACK_Y;
202             break;
203         case 3:
204             rParameter.eStackMode=GlobalStackMode_STACK_Y_PERCENT;
205             break;
206         case 4:
207             rParameter.eStackMode=GlobalStackMode_STACK_Z;
208             break;
209         default:
210             rParameter.eStackMode=GlobalStackMode_NONE;
211             break;
212     }
213 }
adjustParameterToMainType(ChartTypeParameter & rParameter)214 void ChartTypeDialogController::adjustParameterToMainType( ChartTypeParameter& rParameter )
215 {
216     bool bFoundSomeMatch=false;
217 
218     rParameter.bXAxisWithValues = bSupportsXAxisWithValues;
219     if( rParameter.b3DLook && !bSupports3D )
220         rParameter.b3DLook = false;
221     if(!rParameter.b3DLook && rParameter.eStackMode==GlobalStackMode_STACK_Z)
222         rParameter.eStackMode = GlobalStackMode_NONE;
223 
224     const tTemplateServiceChartTypeParameterMap& rMap = getTemplateMap();
225     tTemplateServiceChartTypeParameterMap::const_iterator       aIter = rMap.begin();
226     const tTemplateServiceChartTypeParameterMap::const_iterator aEnd  = rMap.end();
227     for( sal_Int32 nMatchPrecision=0; nMatchPrecision<7 && !bFoundSomeMatch; nMatchPrecision++ )
228     {
229         for( aIter = rMap.begin(); aIter != aEnd; aIter++ )
230         {
231             if( rParameter.mapsToSimilarService( (*aIter).second, nMatchPrecision ) )
232             {
233                 //remind some values
234                 ThreeDLookScheme aScheme = rParameter.eThreeDLookScheme;
235                 sal_Int32        nCurveResolution = rParameter.nCurveResolution;
236                 sal_Int32        nSplineOrder = rParameter.nSplineOrder;
237                 CurveStyle       eCurveStyle = rParameter.eCurveStyle;
238                 sal_Int32        nGeometry3D = rParameter.nGeometry3D;
239                 sal_Bool         bSortByXValues = rParameter.bSortByXValues;
240 
241                 rParameter = (*aIter).second;
242 
243                 //some values should not be changed with charttype
244                 rParameter.eThreeDLookScheme = aScheme;
245                 rParameter.nCurveResolution = nCurveResolution;
246                 rParameter.nSplineOrder =nSplineOrder;
247                 rParameter.eCurveStyle = eCurveStyle;
248                 rParameter.nGeometry3D = nGeometry3D;
249                 rParameter.bSortByXValues = bSortByXValues;
250 
251                 bFoundSomeMatch = true;
252                 break;
253             }
254         }
255     }
256     if(!bFoundSomeMatch)
257     {
258         if(rMap.begin()!=rMap.end())
259             rParameter = (*rMap.begin()).second;
260         else
261             rParameter = ChartTypeParameter();
262     }
263 }
getServiceNameForParameter(const ChartTypeParameter & rParameter) const264 rtl::OUString ChartTypeDialogController::getServiceNameForParameter( const ChartTypeParameter& rParameter ) const
265 {
266     ChartTypeParameter aParameter(rParameter);
267     if( aParameter.bXAxisWithValues )
268         aParameter.eStackMode = GlobalStackMode_NONE;
269     if(!aParameter.b3DLook && aParameter.eStackMode==GlobalStackMode_STACK_Z)
270         aParameter.eStackMode = GlobalStackMode_NONE;
271     const tTemplateServiceChartTypeParameterMap& rMap = getTemplateMap();
272     tTemplateServiceChartTypeParameterMap::const_iterator       aIter = rMap.begin();
273     const tTemplateServiceChartTypeParameterMap::const_iterator aEnd  = rMap.end();
274 	for( ; aIter != aEnd; aIter++ )
275     {
276         if( aParameter.mapsToSameService( (*aIter).second ) )
277             return (*aIter).first;
278     }
279 
280     OSL_ENSURE( false, "ChartType not implemented yet - use fallback to similar type" );
281     for( sal_Int32 nMatchPrecision=1; nMatchPrecision<8; nMatchPrecision++ )
282     {
283         for( aIter = rMap.begin(); aIter != aEnd; aIter++ )
284         {
285             if( aParameter.mapsToSimilarService( (*aIter).second, nMatchPrecision ) )
286                 return (*aIter).first;
287         }
288     }
289     return ::rtl::OUString();
290 }
getCurrentTemplate(const ChartTypeParameter & rParameter,const uno::Reference<lang::XMultiServiceFactory> & xTemplateManager) const291 uno::Reference< XChartTypeTemplate > ChartTypeDialogController::getCurrentTemplate(
292     const ChartTypeParameter& rParameter
293     , const uno::Reference< lang::XMultiServiceFactory >& xTemplateManager ) const
294 {
295     uno::Reference< XChartTypeTemplate > xTemplate(0);
296 
297     rtl::OUString aServiceName( this->getServiceNameForParameter( rParameter ) );
298     if( !aServiceName.isEmpty() )
299     {
300         xTemplate.set( xTemplateManager->createInstance( aServiceName ), uno::UNO_QUERY );
301         if(xTemplate.is())
302         {
303             uno::Reference< beans::XPropertySet > xTemplateProps( xTemplate, uno::UNO_QUERY );
304             if(xTemplateProps.is())
305             {
306                 try
307                 {
308                     xTemplateProps->setPropertyValue( C2U( "CurveStyle" ), uno::makeAny(rParameter.eCurveStyle) );
309                     xTemplateProps->setPropertyValue( C2U( "CurveResolution" ), uno::makeAny(rParameter.nCurveResolution) );
310                     xTemplateProps->setPropertyValue( C2U( "SplineOrder" ), uno::makeAny(rParameter.nSplineOrder) );
311                 }
312                 catch( uno::Exception & ex )
313                 {
314                     //not all templates need to support CurveStyle, CurveResolution or SplineOrder
315                     ex.Context.is();//to have debug information without compilation warnings
316                 }
317                 try
318                 {
319                     xTemplateProps->setPropertyValue( C2U( "Geometry3D" ), uno::makeAny(rParameter.nGeometry3D) );
320                 }
321                 catch( uno::Exception & ex )
322                 {
323                     //not all templates need to support Geometry3D
324                     ex.Context.is();//to have debug information without compilation warnings
325                 }
326                 try
327                 {
328                     this->setTemplateProperties( xTemplateProps );
329                 }
330                 catch( uno::Exception & ex )
331                 {
332                     ASSERT_EXCEPTION( ex );
333                 }
334             }
335         }
336     }
337     return xTemplate;
338 }
339 
commitToModel(const ChartTypeParameter & rParameter,const uno::Reference<XChartDocument> & xChartModel)340 bool ChartTypeDialogController::commitToModel( const ChartTypeParameter& rParameter
341                 , const uno::Reference< XChartDocument >& xChartModel )
342 {
343     uno::Reference< lang::XMultiServiceFactory > xTemplateManager( xChartModel->getChartTypeManager(), uno::UNO_QUERY );
344     uno::Reference< XChartTypeTemplate > xTemplate( this->getCurrentTemplate( rParameter, xTemplateManager ) );
345     if(xTemplate.is())
346     {
347         uno::Reference< frame::XModel > xModel( xChartModel, uno::UNO_QUERY);
348 
349         // /-- locked controllers
350         ControllerLockGuard aCtrlLockGuard( xModel );
351         uno::Reference< XDiagram > xDiagram = ChartModelHelper::findDiagram( xModel );
352         DiagramHelper::tTemplateWithServiceName aTemplateWithService(
353             DiagramHelper::getTemplateForDiagram( xDiagram, xTemplateManager ));
354         if( aTemplateWithService.first.is())
355             aTemplateWithService.first->resetStyles( xDiagram );
356         xTemplate->changeDiagram( xDiagram );
357         if( Application::GetSettings().GetLayoutRTL() )
358             AxisHelper::setRTLAxisLayout( AxisHelper::getCoordinateSystemByIndex( xDiagram, 0 ) );
359         if( rParameter.b3DLook )
360             ThreeDHelper::setScheme( xDiagram, rParameter.eThreeDLookScheme );
361 
362         //SortByXValues
363         {
364             uno::Reference< beans::XPropertySet > xDiaProp( xDiagram, uno::UNO_QUERY );
365             if( xDiaProp.is() )
366                 xDiaProp->setPropertyValue( C2U( "SortByXValues" ), uno::makeAny( rParameter.bSortByXValues ) );
367         }
368         // \-- locked controllers
369     }
370     return false;
371 }
fillSubTypeList(ValueSet & rSubTypeList,bool,const ChartTypeParameter &)372 void ChartTypeDialogController::fillSubTypeList( ValueSet& rSubTypeList, bool /*bIsHighContrast*/, const ChartTypeParameter& /*rParameter*/ )
373 {
374     rSubTypeList.Clear();
375 }
shouldShow_XAxisTypeControl() const376 bool ChartTypeDialogController::shouldShow_XAxisTypeControl() const
377 {
378     return false;
379 }
shouldShow_3DLookControl() const380 bool ChartTypeDialogController::shouldShow_3DLookControl() const
381 {
382     return false;
383 }
shouldShow_StackingControl() const384 bool ChartTypeDialogController::shouldShow_StackingControl() const
385 {
386     return false;
387 }
shouldShow_DeepStackingControl() const388 bool ChartTypeDialogController::shouldShow_DeepStackingControl() const
389 {
390     return false;
391 }
shouldShow_SplineControl() const392 bool ChartTypeDialogController::shouldShow_SplineControl() const
393 {
394     return false;
395 }
shouldShow_GeometryControl() const396 bool ChartTypeDialogController::shouldShow_GeometryControl() const
397 {
398     return false;
399 }
shouldShow_SortByXValuesResourceGroup() const400 bool ChartTypeDialogController::shouldShow_SortByXValuesResourceGroup() const
401 {
402     return false;
403 }
404 
showExtraControls(Window *,const Point &,const Size &)405 void ChartTypeDialogController::showExtraControls( Window* /*pParent*/, const Point& /*rPosition*/, const Size& /*rSize*/ )
406 {
407 }
hideExtraControls() const408 void ChartTypeDialogController::hideExtraControls() const
409 {
410 }
fillExtraControls(const ChartTypeParameter &,const uno::Reference<XChartDocument> &,const uno::Reference<beans::XPropertySet> &) const411 void ChartTypeDialogController::fillExtraControls( const ChartTypeParameter& /*rParameter*/
412                                                   , const uno::Reference< XChartDocument >& /*xChartModel*/
413                                                   , const uno::Reference< beans::XPropertySet >& /*xTemplateProps*/ ) const
414 {
415 }
setTemplateProperties(const uno::Reference<beans::XPropertySet> &) const416 void ChartTypeDialogController::setTemplateProperties( const uno::Reference< beans::XPropertySet >& /*xTemplateProps*/ ) const throw (uno::RuntimeException)
417 {
418 }
419 //--------------------------------------------------------------------------
420 
ColumnOrBarChartDialogController_Base()421 ColumnOrBarChartDialogController_Base::ColumnOrBarChartDialogController_Base()
422                                         : ChartTypeDialogController()
423 {
424 }
~ColumnOrBarChartDialogController_Base()425 ColumnOrBarChartDialogController_Base::~ColumnOrBarChartDialogController_Base()
426 {
427 }
shouldShow_3DLookControl() const428 bool ColumnOrBarChartDialogController_Base::shouldShow_3DLookControl() const
429 {
430     return true;
431 }
shouldShow_GeometryControl() const432 bool ColumnOrBarChartDialogController_Base::shouldShow_GeometryControl() const
433 {
434     return true;
435 }
adjustSubTypeAndEnableControls(ChartTypeParameter & rParameter)436 void ColumnOrBarChartDialogController_Base::adjustSubTypeAndEnableControls( ChartTypeParameter& rParameter )
437 {
438     if(rParameter.nSubTypeIndex>3 && !rParameter.b3DLook)
439     {
440         rParameter.nSubTypeIndex=1;
441     }
442 }
443 //--------------------------------------------------------------------------
ColumnChartDialogController()444 ColumnChartDialogController::ColumnChartDialogController()
445 {
446 }
~ColumnChartDialogController()447 ColumnChartDialogController::~ColumnChartDialogController()
448 {
449 }
getName()450 String ColumnChartDialogController::getName()
451 {
452     return String( SchResId( STR_TYPE_COLUMN ));
453 }
getImage(bool bIsHighContrast)454 Image ColumnChartDialogController::getImage( bool bIsHighContrast )
455 {
456     return SELECT_IMAGE( IMG_TYPE_COLUMN );
457 }
getTemplateMap() const458 const tTemplateServiceChartTypeParameterMap& ColumnChartDialogController::getTemplateMap() const
459 {
460     static tTemplateServiceChartTypeParameterMap m_aTemplateMap =
461     tTemplateServiceChartTypeParameterMap
462         ( C2U( "com.sun.star.chart2.template.Column" ),                         ChartTypeParameter(1,false,false,GlobalStackMode_NONE) )
463         ( C2U( "com.sun.star.chart2.template.StackedColumn" ),                  ChartTypeParameter(2,false,false,GlobalStackMode_STACK_Y) )
464         ( C2U( "com.sun.star.chart2.template.PercentStackedColumn" ),           ChartTypeParameter(3,false,false,GlobalStackMode_STACK_Y_PERCENT) )
465         ( C2U( "com.sun.star.chart2.template.ThreeDColumnFlat" ),               ChartTypeParameter(1,false,true,GlobalStackMode_NONE) )
466         ( C2U( "com.sun.star.chart2.template.StackedThreeDColumnFlat" ),        ChartTypeParameter(2,false,true,GlobalStackMode_STACK_Y) )
467         ( C2U( "com.sun.star.chart2.template.PercentStackedThreeDColumnFlat" ), ChartTypeParameter(3,false,true,GlobalStackMode_STACK_Y_PERCENT) )
468         ( C2U( "com.sun.star.chart2.template.ThreeDColumnDeep" ),               ChartTypeParameter(4,false,true,GlobalStackMode_STACK_Z) )
469         ;
470     return m_aTemplateMap;
471 }
fillSubTypeList(ValueSet & rSubTypeList,bool bIsHighContrast,const ChartTypeParameter & rParameter)472 void ColumnChartDialogController::fillSubTypeList( ValueSet& rSubTypeList, bool bIsHighContrast, const ChartTypeParameter& rParameter )
473 {
474     rSubTypeList.Clear();
475 
476     if( rParameter.b3DLook )
477     {
478         switch(rParameter.nGeometry3D)
479         {
480             case DataPointGeometry3D::CYLINDER:
481                 rSubTypeList.InsertItem( 1, SELECT_BITMAP( BMP_SAEULE_3D_1 ) );
482                 rSubTypeList.InsertItem( 2, SELECT_BITMAP( BMP_SAEULE_3D_2 ) );
483                 rSubTypeList.InsertItem( 3, SELECT_BITMAP( BMP_SAEULE_3D_3 ) );
484                 rSubTypeList.InsertItem( 4, SELECT_BITMAP( BMP_SAEULE_3D_4 ) );
485             break;
486             case DataPointGeometry3D::CONE:
487                 rSubTypeList.InsertItem( 1, SELECT_BITMAP( BMP_KEGEL_3D_1 ) );
488                 rSubTypeList.InsertItem( 2, SELECT_BITMAP( BMP_KEGEL_3D_2 ) );
489                 rSubTypeList.InsertItem( 3, SELECT_BITMAP( BMP_KEGEL_3D_3 ) );
490                 rSubTypeList.InsertItem( 4, SELECT_BITMAP( BMP_KEGEL_3D_4 ) );
491             break;
492             case DataPointGeometry3D::PYRAMID:
493                 rSubTypeList.InsertItem( 1, SELECT_BITMAP( BMP_PYRAMID_3D_1 ) );
494                 rSubTypeList.InsertItem( 2, SELECT_BITMAP( BMP_PYRAMID_3D_2 ) );
495                 rSubTypeList.InsertItem( 3, SELECT_BITMAP( BMP_PYRAMID_3D_3 ) );
496                 rSubTypeList.InsertItem( 4, SELECT_BITMAP( BMP_PYRAMID_3D_4 ) );
497             break;
498             default: //DataPointGeometry3D::CUBOID:
499                 rSubTypeList.InsertItem( 1, SELECT_BITMAP( BMP_COLUMNS_3D_1 ) );
500                 rSubTypeList.InsertItem( 2, SELECT_BITMAP( BMP_COLUMNS_3D_2 ) );
501                 rSubTypeList.InsertItem( 3, SELECT_BITMAP( BMP_COLUMNS_3D_3 ) );
502                 rSubTypeList.InsertItem( 4, SELECT_BITMAP( BMP_COLUMNS_3D ) );
503             break;
504         }
505     }
506     else
507     {
508         rSubTypeList.InsertItem( 1, SELECT_BITMAP( BMP_COLUMNS_2D_1 ) );
509         rSubTypeList.InsertItem( 2, SELECT_BITMAP( BMP_COLUMNS_2D_2 ) );
510         rSubTypeList.InsertItem( 3, SELECT_BITMAP( BMP_COLUMNS_2D_3 ) );
511     }
512 
513     rSubTypeList.SetItemText( 1, String( SchResId( STR_NORMAL )) );
514     rSubTypeList.SetItemText( 2, String( SchResId( STR_STACKED )) );
515     rSubTypeList.SetItemText( 3, String( SchResId( STR_PERCENT )) );
516     rSubTypeList.SetItemText( 4, String( SchResId( STR_DEEP )) );
517 }
518 
519 //--------------------------------------------------------------------------
520 
BarChartDialogController()521 BarChartDialogController::BarChartDialogController()
522 {
523 }
~BarChartDialogController()524 BarChartDialogController::~BarChartDialogController()
525 {
526 }
getName()527 String BarChartDialogController::getName()
528 {
529     return String( SchResId( STR_TYPE_BAR ));
530 }
getImage(bool bIsHighContrast)531 Image BarChartDialogController::getImage( bool bIsHighContrast )
532 {
533     return SELECT_IMAGE( IMG_TYPE_BAR );
534 }
getTemplateMap() const535 const tTemplateServiceChartTypeParameterMap& BarChartDialogController::getTemplateMap() const
536 {
537     static tTemplateServiceChartTypeParameterMap m_aTemplateMap =
538     tTemplateServiceChartTypeParameterMap
539         ( C2U( "com.sun.star.chart2.template.Bar" ),                         ChartTypeParameter(1,false,false,GlobalStackMode_NONE) )
540         ( C2U( "com.sun.star.chart2.template.StackedBar" ),                  ChartTypeParameter(2,false,false,GlobalStackMode_STACK_Y) )
541         ( C2U( "com.sun.star.chart2.template.PercentStackedBar" ),           ChartTypeParameter(3,false,false,GlobalStackMode_STACK_Y_PERCENT) )
542         ( C2U( "com.sun.star.chart2.template.ThreeDBarFlat" ),               ChartTypeParameter(1,false,true,GlobalStackMode_NONE) )
543         ( C2U( "com.sun.star.chart2.template.StackedThreeDBarFlat" ),        ChartTypeParameter(2,false,true,GlobalStackMode_STACK_Y) )
544         ( C2U( "com.sun.star.chart2.template.PercentStackedThreeDBarFlat" ), ChartTypeParameter(3,false,true,GlobalStackMode_STACK_Y_PERCENT) )
545         ( C2U( "com.sun.star.chart2.template.ThreeDBarDeep" ),               ChartTypeParameter(4,false,true,GlobalStackMode_STACK_Z) )
546         ;
547     return m_aTemplateMap;
548 }
fillSubTypeList(ValueSet & rSubTypeList,bool bIsHighContrast,const ChartTypeParameter & rParameter)549 void BarChartDialogController::fillSubTypeList( ValueSet& rSubTypeList, bool bIsHighContrast, const ChartTypeParameter& rParameter )
550 {
551     rSubTypeList.Clear();
552 
553     if( rParameter.b3DLook )
554     {
555         switch(rParameter.nGeometry3D)
556         {
557             case DataPointGeometry3D::CYLINDER:
558                 rSubTypeList.InsertItem( 1, SELECT_BITMAP( BMP_ROEHRE_3D_1 ) );
559                 rSubTypeList.InsertItem( 2, SELECT_BITMAP( BMP_ROEHRE_3D_2 ) );
560                 rSubTypeList.InsertItem( 3, SELECT_BITMAP( BMP_ROEHRE_3D_3 ) );
561                 rSubTypeList.InsertItem( 4, SELECT_BITMAP( BMP_ROEHRE_3D_4 ) );
562             break;
563             case DataPointGeometry3D::CONE:
564                 rSubTypeList.InsertItem( 1, SELECT_BITMAP( BMP_KEGELQ_3D_1 ) );
565                 rSubTypeList.InsertItem( 2, SELECT_BITMAP( BMP_KEGELQ_3D_2 ) );
566                 rSubTypeList.InsertItem( 3, SELECT_BITMAP( BMP_KEGELQ_3D_3 ) );
567                 rSubTypeList.InsertItem( 4, SELECT_BITMAP( BMP_KEGELQ_3D_4 ) );
568             break;
569             case DataPointGeometry3D::PYRAMID:
570                 rSubTypeList.InsertItem( 1, SELECT_BITMAP( BMP_PYRAMIDQ_3D_1 ) );
571                 rSubTypeList.InsertItem( 2, SELECT_BITMAP( BMP_PYRAMIDQ_3D_2 ) );
572                 rSubTypeList.InsertItem( 3, SELECT_BITMAP( BMP_PYRAMIDQ_3D_3 ) );
573                 rSubTypeList.InsertItem( 4, SELECT_BITMAP( BMP_PYRAMIDQ_3D_4 ) );
574             break;
575             default: //DataPointGeometry3D::CUBOID:
576                 rSubTypeList.InsertItem( 1, SELECT_BITMAP( BMP_BARS_3D_1 ) );
577                 rSubTypeList.InsertItem( 2, SELECT_BITMAP( BMP_BARS_3D_2 ) );
578                 rSubTypeList.InsertItem( 3, SELECT_BITMAP( BMP_BARS_3D_3 ) );
579                 rSubTypeList.InsertItem( 4, SELECT_BITMAP( BMP_BARS_3D ) );
580             break;
581         }
582     }
583     else
584     {
585         rSubTypeList.InsertItem( 1, SELECT_BITMAP( BMP_BARS_2D_1 ) );
586         rSubTypeList.InsertItem( 2, SELECT_BITMAP( BMP_BARS_2D_2 ) );
587         rSubTypeList.InsertItem( 3, SELECT_BITMAP( BMP_BARS_2D_3 ) );
588     }
589     rSubTypeList.SetItemText( 1, String( SchResId( STR_NORMAL )) );
590     rSubTypeList.SetItemText( 2, String( SchResId( STR_STACKED )) );
591     rSubTypeList.SetItemText( 3, String( SchResId( STR_PERCENT )) );
592     rSubTypeList.SetItemText( 4, String( SchResId( STR_DEEP )) );
593 }
594 
595 //--------------------------------------------------------------------------
596 
PieChartDialogController()597 PieChartDialogController::PieChartDialogController()
598 {
599 }
~PieChartDialogController()600 PieChartDialogController::~PieChartDialogController()
601 {
602 }
getName()603 String PieChartDialogController::getName()
604 {
605     return String( SchResId( STR_TYPE_PIE ));
606 }
getImage(bool bIsHighContrast)607 Image PieChartDialogController::getImage( bool bIsHighContrast )
608 {
609     return SELECT_IMAGE( IMG_TYPE_PIE );
610 }
getTemplateMap() const611 const tTemplateServiceChartTypeParameterMap& PieChartDialogController::getTemplateMap() const
612 {
613     static tTemplateServiceChartTypeParameterMap m_aTemplateMap =
614     tTemplateServiceChartTypeParameterMap
615     ( C2U( "com.sun.star.chart2.template.Pie" ),                    ChartTypeParameter(1,false,false) )
616     ( C2U( "com.sun.star.chart2.template.PieAllExploded" ),         ChartTypeParameter(2,false,false) )
617     ( C2U( "com.sun.star.chart2.template.Donut" ),                  ChartTypeParameter(3,false,false) )
618     ( C2U( "com.sun.star.chart2.template.DonutAllExploded" ),       ChartTypeParameter(4,false,false) )
619     ( C2U( "com.sun.star.chart2.template.ThreeDPie" ),              ChartTypeParameter(1,false,true) )
620     ( C2U( "com.sun.star.chart2.template.ThreeDPieAllExploded" ),   ChartTypeParameter(2,false,true) )
621     ( C2U( "com.sun.star.chart2.template.ThreeDDonut" ),            ChartTypeParameter(3,false,true) )
622     ( C2U( "com.sun.star.chart2.template.ThreeDDonutAllExploded" ), ChartTypeParameter(4,false,true) )
623     ;
624     return m_aTemplateMap;
625 }
fillSubTypeList(ValueSet & rSubTypeList,bool bIsHighContrast,const ChartTypeParameter & rParameter)626 void PieChartDialogController::fillSubTypeList( ValueSet& rSubTypeList, bool bIsHighContrast, const ChartTypeParameter& rParameter )
627 {
628     rSubTypeList.Clear();
629 
630     if( rParameter.b3DLook )
631     {
632         rSubTypeList.InsertItem( 1, SELECT_BITMAP( BMP_CIRCLES_3D ) );
633         rSubTypeList.InsertItem( 2, SELECT_BITMAP( BMP_CIRCLES_3D_EXPLODED ) );
634         rSubTypeList.InsertItem( 3, SELECT_BITMAP( BMP_DONUT_3D ) );
635         rSubTypeList.InsertItem( 4, SELECT_BITMAP( BMP_DONUT_3D_EXPLODED ) );
636     }
637     else
638     {
639         rSubTypeList.InsertItem( 1, SELECT_BITMAP( BMP_CIRCLES_2D ) );
640         rSubTypeList.InsertItem( 2, SELECT_BITMAP( BMP_CIRCLES_2D_EXPLODED ) );
641         rSubTypeList.InsertItem( 3, SELECT_BITMAP( BMP_DONUT_2D ) );
642         rSubTypeList.InsertItem( 4, SELECT_BITMAP( BMP_DONUT_2D_EXPLODED ) );
643     }
644     rSubTypeList.SetItemText( 1, String( SchResId( STR_NORMAL )) );
645     rSubTypeList.SetItemText( 2, String( SchResId( STR_PIE_EXPLODED )) );
646     rSubTypeList.SetItemText( 3, String( SchResId( STR_DONUT )) );
647     rSubTypeList.SetItemText( 4, String( SchResId( STR_DONUT_EXPLODED )) );
648 }
shouldShow_3DLookControl() const649 bool PieChartDialogController::shouldShow_3DLookControl() const
650 {
651     return true;
652 }
adjustParameterToSubType(ChartTypeParameter & rParameter)653 void PieChartDialogController::adjustParameterToSubType( ChartTypeParameter& rParameter )
654 {
655     if(rParameter.eStackMode==GlobalStackMode_STACK_Z)
656         rParameter.eStackMode = GlobalStackMode_NONE;
657 }
658 //--------------------------------------------------------------------------
LineChartDialogController()659 LineChartDialogController::LineChartDialogController()
660 {
661 }
~LineChartDialogController()662 LineChartDialogController::~LineChartDialogController()
663 {
664 }
getName()665 String LineChartDialogController::getName()
666 {
667     return String( SchResId( STR_TYPE_LINE ));
668 }
getImage(bool bIsHighContrast)669 Image LineChartDialogController::getImage( bool bIsHighContrast )
670 {
671     return SELECT_IMAGE( IMG_TYPE_LINE );
672 }
getTemplateMap() const673 const tTemplateServiceChartTypeParameterMap& LineChartDialogController::getTemplateMap() const
674 {
675     static tTemplateServiceChartTypeParameterMap m_aTemplateMap =
676     tTemplateServiceChartTypeParameterMap
677     //-------------------------------------------------------
678     ( C2U( "com.sun.star.chart2.template.Symbol" ),                     ChartTypeParameter(1,false,false,GlobalStackMode_NONE,true,false) )
679     ( C2U( "com.sun.star.chart2.template.StackedSymbol" ),              ChartTypeParameter(1,false,false,GlobalStackMode_STACK_Y,true,false) )
680     ( C2U( "com.sun.star.chart2.template.PercentStackedSymbol" ),       ChartTypeParameter(1,false,false,GlobalStackMode_STACK_Y_PERCENT,true,false) )
681     ( C2U( "com.sun.star.chart2.template.LineSymbol" ),                 ChartTypeParameter(2,false,false,GlobalStackMode_NONE,true,true) )
682     ( C2U( "com.sun.star.chart2.template.StackedLineSymbol" ),          ChartTypeParameter(2,false,false,GlobalStackMode_STACK_Y,true,true) )
683     ( C2U( "com.sun.star.chart2.template.PercentStackedLineSymbol" ),   ChartTypeParameter(2,false,false,GlobalStackMode_STACK_Y_PERCENT,true,true) )
684     ( C2U( "com.sun.star.chart2.template.Line" ),                       ChartTypeParameter(3,false,false,GlobalStackMode_NONE,false,true) )
685     ( C2U( "com.sun.star.chart2.template.StackedLine" ),                ChartTypeParameter(3,false,false,GlobalStackMode_STACK_Y,false,true) )
686     ( C2U( "com.sun.star.chart2.template.PercentStackedLine" ),         ChartTypeParameter(3,false,false,GlobalStackMode_STACK_Y_PERCENT,false,true) )
687     //-------------------------------------------------------
688     //( C2U( "com.sun.star.chart2.template.ThreeDLine" ),                 ChartTypeParameter(4,false,true,GlobalStackMode_NONE,false,true) )
689     ( C2U( "com.sun.star.chart2.template.StackedThreeDLine" ),          ChartTypeParameter(4,false,true,GlobalStackMode_STACK_Y,false,true) )
690     ( C2U( "com.sun.star.chart2.template.PercentStackedThreeDLine" ),   ChartTypeParameter(4,false,true,GlobalStackMode_STACK_Y_PERCENT,false,true) )
691     ( C2U( "com.sun.star.chart2.template.ThreeDLineDeep" ),             ChartTypeParameter(4,false,true,GlobalStackMode_STACK_Z,false,true) )
692     //-------------------------------------------------------
693     ;
694     return m_aTemplateMap;
695 }
fillSubTypeList(ValueSet & rSubTypeList,bool bIsHighContrast,const ChartTypeParameter & rParameter)696 void LineChartDialogController::fillSubTypeList( ValueSet& rSubTypeList, bool bIsHighContrast, const ChartTypeParameter& rParameter )
697 {
698     rSubTypeList.Clear();
699 
700     if( CurveStyle_LINES==rParameter.eCurveStyle )
701     {
702         //direct lines
703         if( GlobalStackMode_NONE == rParameter.eStackMode || GlobalStackMode_STACK_Z == rParameter.eStackMode )
704         {
705             rSubTypeList.InsertItem( 1, SELECT_BITMAP( BMP_POINTS_XCATEGORY ) );
706             rSubTypeList.InsertItem( 2, SELECT_BITMAP( BMP_LINE_P_XCATEGORY ) );
707             rSubTypeList.InsertItem( 3, SELECT_BITMAP( BMP_LINE_O_XCATEGORY ) );
708             rSubTypeList.InsertItem( 4, SELECT_BITMAP( BMP_LINE3D_XCATEGORY ) );
709         }
710         else
711         {
712             rSubTypeList.InsertItem( 1, SELECT_BITMAP( BMP_POINTS_STACKED ) );
713             rSubTypeList.InsertItem( 2, SELECT_BITMAP( BMP_LINE_P_STACKED ) );
714             rSubTypeList.InsertItem( 3, SELECT_BITMAP( BMP_LINE_O_STACKED ) );
715             rSubTypeList.InsertItem( 4, SELECT_BITMAP( BMP_LINE3D_STACKED ) );
716         }
717     }
718     else //CurveStyle_LINES
719     {
720         if( GlobalStackMode_NONE == rParameter.eStackMode || GlobalStackMode_STACK_Z == rParameter.eStackMode )
721         {
722             rSubTypeList.InsertItem( 1, SELECT_BITMAP( BMP_POINTS_XCATEGORY ) );
723             rSubTypeList.InsertItem( 2, SELECT_BITMAP( BMP_LINE_P_XCATEGORY_SMOOTH ) );
724             rSubTypeList.InsertItem( 3, SELECT_BITMAP( BMP_LINE_O_XCATEGORY_SMOOTH ) );
725             rSubTypeList.InsertItem( 4, SELECT_BITMAP( BMP_LINE3D_XCATEGORY_SMOOTH ) );
726         }
727         else
728         {
729             rSubTypeList.InsertItem( 1, SELECT_BITMAP( BMP_POINTS_STACKED ) );
730             rSubTypeList.InsertItem( 2, SELECT_BITMAP( BMP_LINE_P_STACKED_SMOOTH ) );
731             rSubTypeList.InsertItem( 3, SELECT_BITMAP( BMP_LINE_O_STACKED_SMOOTH ) );
732             rSubTypeList.InsertItem( 4, SELECT_BITMAP( BMP_LINE3D_STACKED_SMOOTH ) );
733         }
734     }
735 
736     rSubTypeList.SetItemText( 1, String( SchResId( STR_POINTS_ONLY )) );
737     rSubTypeList.SetItemText( 2, String( SchResId( STR_POINTS_AND_LINES )) );
738     rSubTypeList.SetItemText( 3, String( SchResId( STR_LINES_ONLY )) );
739     rSubTypeList.SetItemText( 4, String( SchResId( STR_LINES_3D )) );
740 }
shouldShow_StackingControl() const741 bool LineChartDialogController::shouldShow_StackingControl() const
742 {
743     return true;
744 }
shouldShow_DeepStackingControl() const745 bool LineChartDialogController::shouldShow_DeepStackingControl() const
746 {
747     return false;
748 }
shouldShow_SplineControl() const749 bool LineChartDialogController::shouldShow_SplineControl() const
750 {
751     return true;
752 }
adjustParameterToSubType(ChartTypeParameter & rParameter)753 void LineChartDialogController::adjustParameterToSubType( ChartTypeParameter& rParameter )
754 {
755     rParameter.b3DLook = false;
756 
757     switch( rParameter.nSubTypeIndex )
758     {
759         case 2:
760             rParameter.bSymbols = true;
761             rParameter.bLines = true;
762             break;
763         case 3:
764             rParameter.bSymbols = false;
765             rParameter.bLines = true;
766             break;
767         case 4:
768             rParameter.bSymbols = false;
769             rParameter.bLines = true;
770             rParameter.b3DLook = true;
771             if( rParameter.eStackMode == GlobalStackMode_NONE )
772                 rParameter.eStackMode = GlobalStackMode_STACK_Z;
773             break;
774         default:
775             rParameter.bSymbols = true;
776             rParameter.bLines = false;
777             break;
778     }
779 
780     if(!rParameter.b3DLook && rParameter.eStackMode == GlobalStackMode_STACK_Z )
781         rParameter.eStackMode = GlobalStackMode_NONE;
782 }
adjustParameterToMainType(ChartTypeParameter & rParameter)783 void LineChartDialogController::adjustParameterToMainType( ChartTypeParameter& rParameter )
784 {
785     if( rParameter.b3DLook && rParameter.eStackMode == GlobalStackMode_NONE )
786         rParameter.eStackMode = GlobalStackMode_STACK_Z;
787 
788     ChartTypeDialogController::adjustParameterToMainType( rParameter );
789 }
790 //--------------------------------------------------------------------------
XYChartDialogController()791 XYChartDialogController::XYChartDialogController()
792 {
793     bSupportsXAxisWithValues = true;
794 }
~XYChartDialogController()795 XYChartDialogController::~XYChartDialogController()
796 {
797 }
getName()798 String XYChartDialogController::getName()
799 {
800     return String( SchResId( STR_TYPE_XY ));
801 }
getImage(bool bIsHighContrast)802 Image XYChartDialogController::getImage( bool bIsHighContrast )
803 {
804     return SELECT_IMAGE( IMG_TYPE_XY );
805 }
getTemplateMap() const806 const tTemplateServiceChartTypeParameterMap& XYChartDialogController::getTemplateMap() const
807 {
808     static tTemplateServiceChartTypeParameterMap m_aTemplateMap =
809     tTemplateServiceChartTypeParameterMap
810     //-------------------------------------------------------
811     ( C2U( "com.sun.star.chart2.template.ScatterSymbol" ),              ChartTypeParameter(1,true,false,GlobalStackMode_NONE,true,false) )
812     ( C2U( "com.sun.star.chart2.template.ScatterLineSymbol" ),          ChartTypeParameter(2,true,false,GlobalStackMode_NONE,true,true) )
813     ( C2U( "com.sun.star.chart2.template.ScatterLine" ),                ChartTypeParameter(3,true,false,GlobalStackMode_NONE,false,true) )
814     ( C2U( "com.sun.star.chart2.template.ThreeDScatter" ),              ChartTypeParameter(4,true,true,GlobalStackMode_NONE,false,true) )
815     ;
816     return m_aTemplateMap;
817 }
fillSubTypeList(ValueSet & rSubTypeList,bool bIsHighContrast,const ChartTypeParameter & rParameter)818 void XYChartDialogController::fillSubTypeList( ValueSet& rSubTypeList, bool bIsHighContrast, const ChartTypeParameter& rParameter )
819 {
820     rSubTypeList.Clear();
821 
822     if( CurveStyle_LINES==rParameter.eCurveStyle )
823     {
824         rSubTypeList.InsertItem( 1, SELECT_BITMAP( BMP_POINTS_XVALUES ) );
825         rSubTypeList.InsertItem( 2, SELECT_BITMAP( BMP_LINE_P_XVALUES ) );
826         rSubTypeList.InsertItem( 3, SELECT_BITMAP( BMP_LINE_O_XVALUES ) );
827         rSubTypeList.InsertItem( 4, SELECT_BITMAP( BMP_LINE3D_XVALUES ) );
828     }
829     else //CurveStyle_LINES
830     {
831         //smooth lines
832         rSubTypeList.InsertItem( 1, SELECT_BITMAP( BMP_POINTS_XVALUES ) );
833         rSubTypeList.InsertItem( 2, SELECT_BITMAP( BMP_LINE_P_XVALUES_SMOOTH ) );
834         rSubTypeList.InsertItem( 3, SELECT_BITMAP( BMP_LINE_O_XVALUES_SMOOTH ) );
835         rSubTypeList.InsertItem( 4, SELECT_BITMAP( BMP_LINE3D_XVALUES_SMOOTH ) );
836     }
837 
838     rSubTypeList.SetItemText( 1, String( SchResId( STR_POINTS_ONLY )) );
839     rSubTypeList.SetItemText( 2, String( SchResId( STR_POINTS_AND_LINES )) );
840     rSubTypeList.SetItemText( 3, String( SchResId( STR_LINES_ONLY )) );
841     rSubTypeList.SetItemText( 4, String( SchResId( STR_LINES_3D )) );
842 }
shouldShow_SplineControl() const843 bool XYChartDialogController::shouldShow_SplineControl() const
844 {
845     return true;
846 }
shouldShow_SortByXValuesResourceGroup() const847 bool XYChartDialogController::shouldShow_SortByXValuesResourceGroup() const
848 {
849     return true;
850 }
adjustParameterToSubType(ChartTypeParameter & rParameter)851 void XYChartDialogController::adjustParameterToSubType( ChartTypeParameter& rParameter )
852 {
853     rParameter.eStackMode=GlobalStackMode_NONE;
854     rParameter.b3DLook = false;
855 
856     switch( rParameter.nSubTypeIndex )
857     {
858         case 2:
859             rParameter.bSymbols = true;
860             rParameter.bLines = true;
861             break;
862         case 3:
863             rParameter.bSymbols = false;
864             rParameter.bLines = true;
865             break;
866         case 4:
867             rParameter.bSymbols = false;
868             rParameter.bLines = true;
869             rParameter.b3DLook = true;
870             rParameter.eStackMode=GlobalStackMode_STACK_Z;
871             break;
872         default:
873             rParameter.bSymbols = true;
874             rParameter.bLines = false;
875             break;
876     }
877 }
878 //--------------------------------------------------------------------------
AreaChartDialogController()879 AreaChartDialogController::AreaChartDialogController()
880 {
881 }
~AreaChartDialogController()882 AreaChartDialogController::~AreaChartDialogController()
883 {
884 }
getName()885 String AreaChartDialogController::getName()
886 {
887     return String( SchResId( STR_TYPE_AREA ));
888 }
getImage(bool bIsHighContrast)889 Image AreaChartDialogController::getImage( bool bIsHighContrast )
890 {
891     return SELECT_IMAGE( IMG_TYPE_AREA );
892 }
shouldShow_3DLookControl() const893 bool AreaChartDialogController::shouldShow_3DLookControl() const
894 {
895     return true;
896 }
getTemplateMap() const897 const tTemplateServiceChartTypeParameterMap& AreaChartDialogController::getTemplateMap() const
898 {
899     static tTemplateServiceChartTypeParameterMap m_aTemplateMap =
900     tTemplateServiceChartTypeParameterMap
901     ( C2U( "com.sun.star.chart2.template.Area" ),                     ChartTypeParameter(1,false,false,GlobalStackMode_NONE) )
902     ( C2U( "com.sun.star.chart2.template.ThreeDArea" ),               ChartTypeParameter(1,false,true,GlobalStackMode_STACK_Z) )
903     ( C2U( "com.sun.star.chart2.template.StackedArea" ),              ChartTypeParameter(2,false,false,GlobalStackMode_STACK_Y) )
904     ( C2U( "com.sun.star.chart2.template.StackedThreeDArea" ),        ChartTypeParameter(2,false,true,GlobalStackMode_STACK_Y) )
905     ( C2U( "com.sun.star.chart2.template.PercentStackedArea" ),       ChartTypeParameter(3,false,false,GlobalStackMode_STACK_Y_PERCENT) )
906     ( C2U( "com.sun.star.chart2.template.PercentStackedThreeDArea" ), ChartTypeParameter(3,false,true,GlobalStackMode_STACK_Y_PERCENT) )
907     ;
908     return m_aTemplateMap;
909 }
fillSubTypeList(ValueSet & rSubTypeList,bool bIsHighContrast,const ChartTypeParameter & rParameter)910 void AreaChartDialogController::fillSubTypeList( ValueSet& rSubTypeList, bool bIsHighContrast, const ChartTypeParameter& rParameter )
911 {
912     rSubTypeList.Clear();
913 
914     if( rParameter.b3DLook )
915     {
916         rSubTypeList.InsertItem( 1, SELECT_BITMAP( BMP_AREAS_3D ) );
917         rSubTypeList.InsertItem( 2, SELECT_BITMAP( BMP_AREAS_3D_1 ) );
918         rSubTypeList.InsertItem( 3, SELECT_BITMAP( BMP_AREAS_3D_2 ) );
919     }
920     else
921     {
922         rSubTypeList.InsertItem( 1, SELECT_BITMAP( BMP_AREAS_2D_1 ) );
923         rSubTypeList.InsertItem( 2, SELECT_BITMAP( BMP_AREAS_2D ) );
924         rSubTypeList.InsertItem( 3, SELECT_BITMAP( BMP_AREAS_2D_3 ) );
925     }
926 
927     rSubTypeList.SetItemText( 1, String( SchResId( rParameter.b3DLook ? STR_DEEP : STR_NORMAL )) );
928     rSubTypeList.SetItemText( 2, String( SchResId( STR_STACKED )) );
929     rSubTypeList.SetItemText( 3, String( SchResId( STR_PERCENT )) );
930 }
adjustParameterToSubType(ChartTypeParameter & rParameter)931 void AreaChartDialogController::adjustParameterToSubType( ChartTypeParameter& rParameter )
932 {
933     rParameter.eCurveStyle = CurveStyle_LINES;
934 
935     if( rParameter.nSubTypeIndex>3 )
936         rParameter.nSubTypeIndex = 1;
937     switch( rParameter.nSubTypeIndex )
938     {
939         case 2:
940             rParameter.eStackMode=GlobalStackMode_STACK_Y;
941             break;
942         case 3:
943             rParameter.eStackMode=GlobalStackMode_STACK_Y_PERCENT;
944             break;
945         default:
946             if( rParameter.b3DLook )
947                 rParameter.eStackMode=GlobalStackMode_STACK_Z;
948             else
949                 rParameter.eStackMode=GlobalStackMode_NONE;
950             break;
951     }
952 }
adjustParameterToMainType(ChartTypeParameter & rParameter)953 void AreaChartDialogController::adjustParameterToMainType( ChartTypeParameter& rParameter )
954 {
955     if( rParameter.b3DLook && rParameter.eStackMode == GlobalStackMode_NONE )
956         rParameter.eStackMode = GlobalStackMode_STACK_Z;
957 
958     ChartTypeDialogController::adjustParameterToMainType( rParameter );
959 }
960 //--------------------------------------------------------------------------
NetChartDialogController()961 NetChartDialogController::NetChartDialogController()
962 {
963     bSupports3D = false;
964 }
~NetChartDialogController()965 NetChartDialogController::~NetChartDialogController()
966 {
967 }
getName()968 String NetChartDialogController::getName()
969 {
970     return String( SchResId( STR_TYPE_NET ));
971 }
getImage(bool bIsHighContrast)972 Image NetChartDialogController::getImage( bool bIsHighContrast )
973 {
974     return SELECT_IMAGE( IMG_TYPE_NET );
975 }
shouldShow_StackingControl() const976 bool NetChartDialogController::shouldShow_StackingControl() const
977 {
978     return true;
979 }
getTemplateMap() const980 const tTemplateServiceChartTypeParameterMap& NetChartDialogController::getTemplateMap() const
981 {
982     static tTemplateServiceChartTypeParameterMap m_aTemplateMap =
983     tTemplateServiceChartTypeParameterMap
984     //@todo need templates with symbols only
985     ( C2U( "com.sun.star.chart2.template.NetSymbol" ),              ChartTypeParameter(1,false,false,GlobalStackMode_NONE,true,false) )
986     ( C2U( "com.sun.star.chart2.template.StackedNetSymbol" ),       ChartTypeParameter(1,false,false,GlobalStackMode_STACK_Y,true,false) )
987     ( C2U( "com.sun.star.chart2.template.PercentStackedNetSymbol" ),ChartTypeParameter(1,false,false,GlobalStackMode_STACK_Y_PERCENT,true,false) )
988 
989     ( C2U( "com.sun.star.chart2.template.Net" ),                    ChartTypeParameter(2,false,false,GlobalStackMode_NONE,true,true) )
990     ( C2U( "com.sun.star.chart2.template.StackedNet" ),             ChartTypeParameter(2,false,false,GlobalStackMode_STACK_Y,true,true) )
991     ( C2U( "com.sun.star.chart2.template.PercentStackedNet" ),      ChartTypeParameter(2,false,false,GlobalStackMode_STACK_Y_PERCENT,true,true) )
992 
993     ( C2U( "com.sun.star.chart2.template.NetLine" ),                ChartTypeParameter(3,false,false,GlobalStackMode_NONE,false,true) )
994     ( C2U( "com.sun.star.chart2.template.StackedNetLine" ),         ChartTypeParameter(3,false,false,GlobalStackMode_STACK_Y,false,true) )
995     ( C2U( "com.sun.star.chart2.template.PercentStackedNetLine" ),  ChartTypeParameter(3,false,false,GlobalStackMode_STACK_Y_PERCENT,false,true) )
996 
997     ( C2U( "com.sun.star.chart2.template.FilledNet" ),            ChartTypeParameter(4,false,false,GlobalStackMode_NONE,false,false) )
998     ( C2U( "com.sun.star.chart2.template.StackedFilledNet" ),     ChartTypeParameter(4,false,false,GlobalStackMode_STACK_Y,false,false) )
999     ( C2U( "com.sun.star.chart2.template.PercentStackedFilledNet" ),ChartTypeParameter(4,false,false,GlobalStackMode_STACK_Y_PERCENT,false,false) )
1000     ;
1001     return m_aTemplateMap;
1002 }
fillSubTypeList(ValueSet & rSubTypeList,bool bIsHighContrast,const ChartTypeParameter & rParameter)1003 void NetChartDialogController::fillSubTypeList( ValueSet& rSubTypeList, bool bIsHighContrast, const ChartTypeParameter& rParameter )
1004 {
1005     rSubTypeList.Clear();
1006 
1007     if( GlobalStackMode_NONE == rParameter.eStackMode )
1008     {
1009         rSubTypeList.InsertItem( 1, SELECT_BITMAP( BMP_NET_SYMB ) );
1010         rSubTypeList.InsertItem( 2, SELECT_BITMAP( BMP_NET_LINESYMB ) );
1011         rSubTypeList.InsertItem( 3, SELECT_BITMAP( BMP_NET ) );
1012         rSubTypeList.InsertItem( 4, SELECT_BITMAP( BMP_NET_FILL ) );
1013     }
1014     else
1015     {
1016         rSubTypeList.InsertItem( 1, SELECT_BITMAP( BMP_NET_SYMB_STACK ) );
1017         rSubTypeList.InsertItem( 2, SELECT_BITMAP( BMP_NET_LINESYMB_STACK ) );
1018         rSubTypeList.InsertItem( 3, SELECT_BITMAP( BMP_NET_STACK ) );
1019         rSubTypeList.InsertItem( 4, SELECT_BITMAP( BMP_NET_FILL_STACK ) );
1020     }
1021 
1022     rSubTypeList.SetItemText( 1, String( SchResId( STR_POINTS_ONLY )) );
1023     rSubTypeList.SetItemText( 2, String( SchResId( STR_POINTS_AND_LINES )) );
1024     rSubTypeList.SetItemText( 3, String( SchResId( STR_LINES_ONLY )) );
1025     rSubTypeList.SetItemText( 4, String( SchResId( STR_FILLED )) );
1026 }
adjustParameterToSubType(ChartTypeParameter & rParameter)1027 void NetChartDialogController::adjustParameterToSubType( ChartTypeParameter& rParameter )
1028 {
1029     rParameter.b3DLook = false;
1030     if(rParameter.eStackMode==GlobalStackMode_STACK_Z)
1031         rParameter.eStackMode = GlobalStackMode_NONE;
1032 
1033     switch( rParameter.nSubTypeIndex )
1034     {
1035         case 2:
1036             rParameter.bSymbols = true;
1037             rParameter.bLines = true;
1038             break;
1039         case 3:
1040             rParameter.bSymbols = false;
1041             rParameter.bLines = true;
1042             break;
1043         case 4:
1044             rParameter.bSymbols = false;
1045             rParameter.bLines = false;
1046             break;
1047         default:
1048             rParameter.bSymbols = true;
1049             rParameter.bLines = false;
1050             break;
1051     }
1052 }
1053 //--------------------------------------------------------------------------
StockChartDialogController()1054 StockChartDialogController::StockChartDialogController()
1055 {
1056     bSupports3D = false;
1057 }
~StockChartDialogController()1058 StockChartDialogController::~StockChartDialogController()
1059 {
1060 }
getName()1061 String StockChartDialogController::getName()
1062 {
1063     return String( SchResId( STR_TYPE_STOCK ));
1064 }
getImage(bool bIsHighContrast)1065 Image StockChartDialogController::getImage( bool bIsHighContrast )
1066 {
1067     return SELECT_IMAGE( IMG_TYPE_STOCK );
1068 }
getTemplateMap() const1069 const tTemplateServiceChartTypeParameterMap& StockChartDialogController::getTemplateMap() const
1070 {
1071     static tTemplateServiceChartTypeParameterMap m_aTemplateMap =
1072     tTemplateServiceChartTypeParameterMap
1073     ( C2U( "com.sun.star.chart2.template.StockLowHighClose" ),          ChartTypeParameter(1) )
1074     ( C2U( "com.sun.star.chart2.template.StockOpenLowHighClose" ),      ChartTypeParameter(2) )
1075     ( C2U( "com.sun.star.chart2.template.StockVolumeLowHighClose" ),    ChartTypeParameter(3) )
1076     ( C2U( "com.sun.star.chart2.template.StockVolumeOpenLowHighClose" ),ChartTypeParameter(4) )
1077     ;
1078     return m_aTemplateMap;
1079 }
fillSubTypeList(ValueSet & rSubTypeList,bool bIsHighContrast,const ChartTypeParameter &)1080 void StockChartDialogController::fillSubTypeList( ValueSet& rSubTypeList, bool bIsHighContrast, const ChartTypeParameter& /*rParameter*/ )
1081 {
1082     rSubTypeList.Clear();
1083     rSubTypeList.InsertItem( 1, SELECT_BITMAP( BMP_STOCK_1 ) );
1084     rSubTypeList.InsertItem( 2, SELECT_BITMAP( BMP_STOCK_2 ) );
1085     rSubTypeList.InsertItem( 3, SELECT_BITMAP( BMP_STOCK_3 ) );
1086     rSubTypeList.InsertItem( 4, SELECT_BITMAP( BMP_STOCK_4 ) );
1087 
1088     rSubTypeList.SetItemText( 1, String( SchResId( STR_STOCK_1 )) );
1089     rSubTypeList.SetItemText( 2, String( SchResId( STR_STOCK_2 )) );
1090     rSubTypeList.SetItemText( 3, String( SchResId( STR_STOCK_3 )) );
1091     rSubTypeList.SetItemText( 4, String( SchResId( STR_STOCK_4 )) );
1092 }
adjustParameterToSubType(ChartTypeParameter & rParameter)1093 void StockChartDialogController::adjustParameterToSubType( ChartTypeParameter& rParameter )
1094 {
1095     rParameter.b3DLook = false;
1096     rParameter.eStackMode = GlobalStackMode_NONE;
1097 }
1098 //--------------------------------------------------------------------------
CombiColumnLineChartDialogController()1099 CombiColumnLineChartDialogController::CombiColumnLineChartDialogController()
1100                     : m_pFT_NumberOfLines(0)
1101                     , m_pMF_NumberOfLines(0)
1102 {
1103     bSupports3D = false;
1104 }
~CombiColumnLineChartDialogController()1105 CombiColumnLineChartDialogController::~CombiColumnLineChartDialogController()
1106 {
1107     if(m_pFT_NumberOfLines)
1108         delete m_pFT_NumberOfLines;
1109     if(m_pMF_NumberOfLines)
1110         delete m_pMF_NumberOfLines;
1111 }
getName()1112 String CombiColumnLineChartDialogController::getName()
1113 {
1114     return String( SchResId( STR_TYPE_COMBI_COLUMN_LINE ));
1115 }
getImage(bool bIsHighContrast)1116 Image CombiColumnLineChartDialogController::getImage( bool bIsHighContrast )
1117 {
1118     return SELECT_IMAGE( IMG_TYPE_COLUMN_LINE );
1119 }
getTemplateMap() const1120 const tTemplateServiceChartTypeParameterMap& CombiColumnLineChartDialogController::getTemplateMap() const
1121 {
1122     static tTemplateServiceChartTypeParameterMap m_aTemplateMap =
1123     tTemplateServiceChartTypeParameterMap
1124     ( C2U( "com.sun.star.chart2.template.ColumnWithLine" ),             ChartTypeParameter(1) )
1125     ( C2U( "com.sun.star.chart2.template.StackedColumnWithLine" ),      ChartTypeParameter(2,false,false,GlobalStackMode_STACK_Y) )
1126     ;
1127     return m_aTemplateMap;
1128 }
fillSubTypeList(ValueSet & rSubTypeList,bool bIsHighContrast,const ChartTypeParameter &)1129 void CombiColumnLineChartDialogController::fillSubTypeList( ValueSet& rSubTypeList, bool bIsHighContrast, const ChartTypeParameter& /*rParameter*/ )
1130 {
1131     rSubTypeList.Clear();
1132     rSubTypeList.InsertItem( 1, SELECT_BITMAP( BMP_COLUMN_LINE ) );
1133     rSubTypeList.InsertItem( 2, SELECT_BITMAP( BMP_COLUMN_LINE_STACKED ) );
1134 
1135     rSubTypeList.SetItemText( 1, String( SchResId( STR_LINE_COLUMN )) );
1136     rSubTypeList.SetItemText( 2, String( SchResId( STR_LINE_STACKEDCOLUMN )) );
1137 }
showExtraControls(Window * pParent,const Point & rPosition,const Size & rSize)1138 void CombiColumnLineChartDialogController::showExtraControls( Window* pParent, const Point& rPosition, const Size& rSize )
1139 {
1140     if(!m_pFT_NumberOfLines)
1141     {
1142         m_pFT_NumberOfLines = new FixedText(pParent,pParent->GetStyle());
1143         m_pFT_NumberOfLines->SetText( String( SchResId( STR_NUMBER_OF_LINES )) );
1144     }
1145     if(!m_pMF_NumberOfLines)
1146     {
1147         m_pMF_NumberOfLines = new MetricField(pParent,pParent->GetStyle() | WB_SPIN | WB_REPEAT | WB_BORDER );
1148         m_pMF_NumberOfLines->SetDefaultUnit( FUNIT_CUSTOM );
1149         m_pMF_NumberOfLines->SetUnit( FUNIT_CUSTOM );
1150         m_pMF_NumberOfLines->SetSpinSize(1);
1151         m_pMF_NumberOfLines->SetFirst( 1, FUNIT_CUSTOM );
1152         m_pMF_NumberOfLines->SetLast( 100, FUNIT_CUSTOM );
1153         m_pMF_NumberOfLines->SetMin( 1, FUNIT_CUSTOM );
1154         m_pMF_NumberOfLines->SetMax( 100, FUNIT_CUSTOM );
1155         m_pMF_NumberOfLines->SetHelpId( HID_SCH_NUM_OF_LINES );
1156 
1157         m_pMF_NumberOfLines->SetModifyHdl( LINK( this, CombiColumnLineChartDialogController, ChangeLineCountHdl ) );
1158     }
1159 
1160     Size aDistanceSize( pParent->LogicToPixel( Size(RSC_SP_CTRL_DESC_X,2), MapMode(MAP_APPFONT) ) );
1161     Size aMFSize( pParent->LogicToPixel( Size(20,RSC_CD_TEXTBOX_HEIGHT), MapMode(MAP_APPFONT) ) );
1162     m_pMF_NumberOfLines->SetSizePixel( aMFSize );
1163 
1164     Size aFTSize(m_pFT_NumberOfLines->CalcMinimumSize(rSize.Width()-aMFSize.Width()-aDistanceSize.Width()));
1165     m_pFT_NumberOfLines->SetSizePixel(aFTSize);
1166 
1167     m_pFT_NumberOfLines->SetPosPixel( Point( rPosition.X(), rPosition.Y()+aDistanceSize.Height()) );
1168     m_pMF_NumberOfLines->SetPosPixel( Point( rPosition.X()+aFTSize.Width()+aDistanceSize.Width(), rPosition.Y()) );
1169 
1170     m_pFT_NumberOfLines->Show();
1171     m_pMF_NumberOfLines->Show();
1172 	m_pMF_NumberOfLines->SetAccessibleName(m_pFT_NumberOfLines->GetText());
1173 	m_pMF_NumberOfLines->SetAccessibleRelationLabeledBy(m_pFT_NumberOfLines);
1174 }
hideExtraControls() const1175 void CombiColumnLineChartDialogController::hideExtraControls() const
1176 {
1177     if(m_pFT_NumberOfLines)
1178         m_pFT_NumberOfLines->Hide();
1179     if(m_pMF_NumberOfLines)
1180         m_pMF_NumberOfLines->Hide();
1181 }
fillExtraControls(const ChartTypeParameter &,const uno::Reference<XChartDocument> & xChartModel,const uno::Reference<beans::XPropertySet> & xTemplateProps) const1182 void CombiColumnLineChartDialogController::fillExtraControls( const ChartTypeParameter& /*rParameter*/
1183                 , const uno::Reference< XChartDocument >& xChartModel
1184                 , const uno::Reference< beans::XPropertySet >& xTemplateProps ) const
1185 {
1186     if(!m_pMF_NumberOfLines)
1187         return;
1188 
1189     uno::Reference< frame::XModel > xModel( xChartModel, uno::UNO_QUERY );
1190 
1191     uno::Reference< XDiagram > xDiagram = ChartModelHelper::findDiagram( xModel );
1192     if(!xDiagram.is())
1193         return;
1194 
1195     sal_Int32 nNumLines = 0;
1196 
1197     if(xTemplateProps.is())
1198     try
1199     {
1200         xTemplateProps->getPropertyValue( C2U("NumberOfLines") ) >>= nNumLines;
1201     }
1202     catch( uno::Exception & ex )
1203     {
1204         ASSERT_EXCEPTION( ex );
1205     }
1206     if( nNumLines < 0 )
1207         nNumLines = 0;
1208     m_pMF_NumberOfLines->SetValue( nNumLines );
1209 
1210     sal_Int32 nMaxLines = ChartModelHelper::getDataSeries( xModel ).size() - 1;
1211     if( nMaxLines < 0 )
1212         nMaxLines = 0;
1213     m_pMF_NumberOfLines->SetLast( nMaxLines );
1214     m_pMF_NumberOfLines->SetMax( nMaxLines );
1215 }
setTemplateProperties(const uno::Reference<beans::XPropertySet> & xTemplateProps) const1216 void CombiColumnLineChartDialogController::setTemplateProperties( const uno::Reference< beans::XPropertySet >& xTemplateProps ) const throw (uno::RuntimeException)
1217 {
1218     if( xTemplateProps.is() )
1219     {
1220         sal_Int32 nNumLines = static_cast< sal_Int32 >( m_pMF_NumberOfLines->GetValue());
1221         xTemplateProps->setPropertyValue( C2U( "NumberOfLines" ), uno::makeAny(nNumLines) );
1222     }
1223 }
1224 
IMPL_LINK(CombiColumnLineChartDialogController,ChangeLineCountHdl,void *,EMPTYARG)1225 IMPL_LINK( CombiColumnLineChartDialogController, ChangeLineCountHdl, void *, EMPTYARG )
1226 {
1227     if( m_pChangeListener )
1228         m_pChangeListener->stateChanged(this);
1229     return 0;
1230 }
adjustParameterToSubType(ChartTypeParameter & rParameter)1231 void CombiColumnLineChartDialogController::adjustParameterToSubType( ChartTypeParameter& rParameter )
1232 {
1233     rParameter.b3DLook = false;
1234     if(rParameter.eStackMode==GlobalStackMode_STACK_Z)
1235         rParameter.eStackMode = GlobalStackMode_NONE;
1236 
1237     switch( rParameter.nSubTypeIndex )
1238     {
1239         case 2:
1240             rParameter.eStackMode=GlobalStackMode_STACK_Y;
1241             break;
1242         default:
1243             rParameter.eStackMode=GlobalStackMode_NONE;
1244             break;
1245     }
1246 }
1247 //--------------------------------------------------------------------------
BubbleChartDialogController()1248 BubbleChartDialogController::BubbleChartDialogController()
1249 {
1250 }
~BubbleChartDialogController()1251 BubbleChartDialogController::~BubbleChartDialogController()
1252 {
1253 }
getName()1254 String BubbleChartDialogController::getName()
1255 {
1256     return String( SchResId( STR_TYPE_BUBBLE ));
1257 }
getImage(bool bIsHighContrast)1258 Image BubbleChartDialogController::getImage( bool bIsHighContrast )
1259 {
1260     return SELECT_IMAGE( IMG_TYPE_BUBBLE );
1261 }
getTemplateMap() const1262 const tTemplateServiceChartTypeParameterMap& BubbleChartDialogController::getTemplateMap() const
1263 {
1264     static tTemplateServiceChartTypeParameterMap m_aTemplateMap =
1265     tTemplateServiceChartTypeParameterMap
1266         ( C2U( "com.sun.star.chart2.template.Bubble" ),          ChartTypeParameter(1,true) ) ;
1267     return m_aTemplateMap;
1268 }
fillSubTypeList(ValueSet & rSubTypeList,bool bIsHighContrast,const ChartTypeParameter &)1269 void BubbleChartDialogController::fillSubTypeList( ValueSet& rSubTypeList, bool bIsHighContrast, const ChartTypeParameter& /*rParameter*/ )
1270 {
1271     rSubTypeList.Clear();
1272     rSubTypeList.InsertItem( 1, SELECT_BITMAP( BMP_BUBBLE_1 ) );
1273 
1274     rSubTypeList.SetItemText( 1, String( SchResId( STR_BUBBLE_1 )) );
1275 }
adjustParameterToSubType(ChartTypeParameter & rParameter)1276 void BubbleChartDialogController::adjustParameterToSubType( ChartTypeParameter& rParameter )
1277 {
1278     rParameter.b3DLook = false;
1279     rParameter.eStackMode = GlobalStackMode_NONE;
1280 }
1281 //.............................................................................
1282 } //namespace chart
1283 //.............................................................................
1284