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 "tp_ChartType.hxx"
28 #include "tp_ChartType.hrc"
29 #include "Strings.hrc"
30 #include "ResId.hxx"
31 #include "ChartModelHelper.hxx"
32 #include "DiagramHelper.hxx"
33 #include "NoWarningThisInCTOR.hxx"
34 #include "res_BarGeometry.hxx"
35 #include "ControllerLockGuard.hxx"
36 #include "macros.hxx"
37
38 #ifndef _SVT_CONTROLDIMS_HRC_
39 #include <svtools/controldims.hrc>
40 #endif
41
42 // header for define RET_OK
43 #include <vcl/msgbox.hxx>
44 #include <tools/debug.hxx>
45
46 //for auto_ptr
47 #include <memory>
48
49 //.............................................................................
50 namespace chart
51 {
52 //.............................................................................
53 using namespace ::com::sun::star;
54 using namespace ::com::sun::star::chart2;
55
56 // macro for selecting a normal or high contrast bitmap the stack variable
57 // bIsHighContrast must exist and reflect the correct state
58 #define SELECT_BITMAP(name) Bitmap( SchResId( bIsHighContrast ? name ## _HC : name ))
59 #define SELECT_IMAGE(name) Image( SchResId( bIsHighContrast ? name ## _HC : name ))
60
61 //--------------------------------------------------------------------------
62 //--------------------------------------------------------------------------
63 //--------------------------------------------------------------------------
64
65 namespace
66 {
lcl_getDistance()67 long lcl_getDistance()
68 {
69 return 6;
70 }
71
lcl_getSortByXValues(const uno::Reference<chart2::XChartDocument> & xChartDoc)72 sal_Bool lcl_getSortByXValues( const uno::Reference< chart2::XChartDocument >& xChartDoc )
73 {
74 sal_Bool bRet = sal_False;
75 if( xChartDoc.is() )
76 {
77 try
78 {
79 uno::Reference< beans::XPropertySet > xDiaProp( xChartDoc->getFirstDiagram(), uno::UNO_QUERY_THROW );
80 xDiaProp->getPropertyValue( C2U( "SortByXValues" ) ) >>= bRet;
81 }
82 catch( const uno::Exception & ex )
83 {
84 ASSERT_EXCEPTION( ex );
85 }
86 }
87 return bRet;
88 }
89 }
90
91 //--------------------------------------------------------------------------
92 class AxisTypeResourceGroup : public ChangingResource
93 {
94 public:
95 AxisTypeResourceGroup( Window* pWindow );
96 virtual ~AxisTypeResourceGroup();
97
98 void showControls( bool bShow );
99 Point getPosition();
100 long getHeight();
101 void setPosition( const Point& rPoint );
102
103 void fillControls( const ChartTypeParameter& rParameter );
104 void fillParameter( ChartTypeParameter& rParameter );
105
106 private:
107 DECL_LINK( AxisTypeCheckHdl, CheckBox* );
108 private:
109 CheckBox m_aCB_XAxis_Categories;
110 };
AxisTypeResourceGroup(Window * pWindow)111 AxisTypeResourceGroup::AxisTypeResourceGroup( Window* pWindow )
112 : ChangingResource()
113 , m_aCB_XAxis_Categories( pWindow, SchResId( CB_X_AXIS_CATEGORIES ) )
114 {
115 m_aCB_XAxis_Categories.SetToggleHdl( LINK( this, AxisTypeResourceGroup, AxisTypeCheckHdl ) );
116 }
~AxisTypeResourceGroup()117 AxisTypeResourceGroup::~AxisTypeResourceGroup()
118 {
119 }
showControls(bool bShow)120 void AxisTypeResourceGroup::showControls( bool bShow )
121 {
122 m_aCB_XAxis_Categories.Show(bShow);
123 }
getPosition()124 Point AxisTypeResourceGroup::getPosition()
125 {
126 return m_aCB_XAxis_Categories.GetPosPixel();
127 }
getHeight()128 long AxisTypeResourceGroup::getHeight()
129 {
130 return m_aCB_XAxis_Categories.GetSizePixel().Height();
131 }
setPosition(const Point & rPoint)132 void AxisTypeResourceGroup::setPosition( const Point& rPoint )
133 {
134 m_aCB_XAxis_Categories.SetPosPixel(rPoint);
135 }
fillControls(const ChartTypeParameter & rParameter)136 void AxisTypeResourceGroup::fillControls( const ChartTypeParameter& rParameter )
137 {
138 m_aCB_XAxis_Categories.Check(!rParameter.bXAxisWithValues);
139 }
fillParameter(ChartTypeParameter & rParameter)140 void AxisTypeResourceGroup::fillParameter( ChartTypeParameter& rParameter )
141 {
142 rParameter.bXAxisWithValues = !m_aCB_XAxis_Categories.IsChecked();
143 }
IMPL_LINK(AxisTypeResourceGroup,AxisTypeCheckHdl,CheckBox *,EMPTYARG)144 IMPL_LINK( AxisTypeResourceGroup, AxisTypeCheckHdl, CheckBox*, EMPTYARG )
145 {
146 if( m_pChangeListener )
147 m_pChangeListener->stateChanged(this);
148 return 0;
149 }
150 //--------------------------------------------------------------------------
151
152 #define POS_3DSCHEME_SIMPLE 0
153 #define POS_3DSCHEME_REALISTIC 1
154
155 class Dim3DLookResourceGroup : public ChangingResource
156 {
157 public:
158 Dim3DLookResourceGroup( Window* pWindow );
159 virtual ~Dim3DLookResourceGroup();
160
161 void showControls( bool bShow );
162 long getHeight();
163 void setPosition( const Point& rPoint );
164
165 void fillControls( const ChartTypeParameter& rParameter );
166 void fillParameter( ChartTypeParameter& rParameter );
167
168 private:
169 DECL_LINK( Dim3DLookCheckHdl, CheckBox* );
170 DECL_LINK( SelectSchemeHdl, void* );
171
172 private:
173 CheckBox m_aCB_3DLook;
174 ListBox m_aLB_Scheme;
175 };
Dim3DLookResourceGroup(Window * pWindow)176 Dim3DLookResourceGroup::Dim3DLookResourceGroup( Window* pWindow )
177 : ChangingResource()
178 , m_aCB_3DLook( pWindow, SchResId( CB_3D_LOOK ) )
179 , m_aLB_Scheme( pWindow, SchResId( LB_3D_SCHEME ) )
180 {
181 m_aCB_3DLook.SetToggleHdl( LINK( this, Dim3DLookResourceGroup, Dim3DLookCheckHdl ) );
182
183 m_aLB_Scheme.InsertEntry(String(SchResId(STR_3DSCHEME_SIMPLE)));
184 m_aLB_Scheme.InsertEntry(String(SchResId(STR_3DSCHEME_REALISTIC)));
185 m_aLB_Scheme.SetDropDownLineCount(2);
186
187 m_aLB_Scheme.SetSelectHdl( LINK( this, Dim3DLookResourceGroup, SelectSchemeHdl ) );
188 m_aLB_Scheme.SetAccessibleName(m_aCB_3DLook.GetText());
189 m_aLB_Scheme.SetAccessibleRelationLabeledBy(&m_aCB_3DLook);
190 }
~Dim3DLookResourceGroup()191 Dim3DLookResourceGroup::~Dim3DLookResourceGroup()
192 {
193 }
showControls(bool bShow)194 void Dim3DLookResourceGroup::showControls( bool bShow )
195 {
196 m_aCB_3DLook.Show(bShow);
197 m_aLB_Scheme.Show(bShow);
198 }
getHeight()199 long Dim3DLookResourceGroup::getHeight()
200 {
201 return m_aCB_3DLook.GetSizePixel().Height() + m_aLB_Scheme.LogicToPixel( Size(0,2), MapMode(MAP_APPFONT) ).Height();
202 }
setPosition(const Point & rPoint)203 void Dim3DLookResourceGroup::setPosition( const Point& rPoint )
204 {
205 m_aCB_3DLook.SetPosPixel(rPoint);
206 Size aSize( m_aCB_3DLook.CalcMinimumSize() );
207 m_aCB_3DLook.SetPosSizePixel(rPoint,aSize);
208 Point aLBPos(rPoint);
209 aLBPos.X() += aSize.Width()
210 + m_aLB_Scheme.LogicToPixel( Size(6,0), MapMode(MAP_APPFONT) ).Width();
211 aLBPos.Y() -= m_aLB_Scheme.LogicToPixel( Size(0,2), MapMode(MAP_APPFONT) ).Height();
212 m_aLB_Scheme.SetPosPixel(aLBPos);
213 }
fillControls(const ChartTypeParameter & rParameter)214 void Dim3DLookResourceGroup::fillControls( const ChartTypeParameter& rParameter )
215 {
216 m_aCB_3DLook.Check(rParameter.b3DLook);
217 m_aLB_Scheme.Enable(rParameter.b3DLook);
218
219 if( rParameter.eThreeDLookScheme == ThreeDLookScheme_Simple )
220 m_aLB_Scheme.SelectEntryPos(POS_3DSCHEME_SIMPLE);
221 else if( rParameter.eThreeDLookScheme == ThreeDLookScheme_Realistic )
222 m_aLB_Scheme.SelectEntryPos(POS_3DSCHEME_REALISTIC);
223 else
224 m_aLB_Scheme.SetNoSelection();
225 }
fillParameter(ChartTypeParameter & rParameter)226 void Dim3DLookResourceGroup::fillParameter( ChartTypeParameter& rParameter )
227 {
228 rParameter.b3DLook = m_aCB_3DLook.IsChecked();
229 sal_uInt16 nPos = m_aLB_Scheme.GetSelectEntryPos();
230 if( POS_3DSCHEME_SIMPLE == nPos )
231 rParameter.eThreeDLookScheme = ThreeDLookScheme_Simple;
232 else if( POS_3DSCHEME_REALISTIC == nPos )
233 rParameter.eThreeDLookScheme = ThreeDLookScheme_Realistic;
234 else
235 rParameter.eThreeDLookScheme = ThreeDLookScheme_Unknown;
236 }
IMPL_LINK(Dim3DLookResourceGroup,Dim3DLookCheckHdl,CheckBox *,EMPTYARG)237 IMPL_LINK( Dim3DLookResourceGroup, Dim3DLookCheckHdl, CheckBox*, EMPTYARG )
238 {
239 if(m_pChangeListener)
240 m_pChangeListener->stateChanged(this);
241 return 0;
242 }
IMPL_LINK(Dim3DLookResourceGroup,SelectSchemeHdl,void *,EMPTYARG)243 IMPL_LINK( Dim3DLookResourceGroup, SelectSchemeHdl, void*, EMPTYARG )
244 {
245 if(m_pChangeListener)
246 m_pChangeListener->stateChanged(this);
247 return 0;
248 }
249
250 //--------------------------------------------------------------------------
251
252 class SortByXValuesResourceGroup : public ChangingResource
253 {
254 public:
255 SortByXValuesResourceGroup( Window* pWindow );
256 virtual ~SortByXValuesResourceGroup();
257
258 void showControls( bool bShow );
259 long getHeight();
260 void setPosition( const Point& rPoint );
261
262 void fillControls( const ChartTypeParameter& rParameter );
263 void fillParameter( ChartTypeParameter& rParameter );
264
265 private:
266 DECL_LINK( SortByXValuesCheckHdl, CheckBox* );
267
268 private:
269 CheckBox m_aCB_XValueSorting;
270 };
SortByXValuesResourceGroup(Window * pWindow)271 SortByXValuesResourceGroup::SortByXValuesResourceGroup( Window* pWindow )
272 : ChangingResource()
273 , m_aCB_XValueSorting( pWindow, SchResId( CB_XVALUE_SORTING ) )
274 {
275 m_aCB_XValueSorting.SetToggleHdl( LINK( this, SortByXValuesResourceGroup, SortByXValuesCheckHdl ) );
276 }
~SortByXValuesResourceGroup()277 SortByXValuesResourceGroup::~SortByXValuesResourceGroup()
278 {
279 }
showControls(bool bShow)280 void SortByXValuesResourceGroup::showControls( bool bShow )
281 {
282 m_aCB_XValueSorting.Show(bShow);
283 }
getHeight()284 long SortByXValuesResourceGroup::getHeight()
285 {
286 return m_aCB_XValueSorting.GetSizePixel().Height();
287 }
setPosition(const Point & rPoint)288 void SortByXValuesResourceGroup::setPosition( const Point& rPoint )
289 {
290 m_aCB_XValueSorting.SetPosPixel(rPoint);
291 }
fillControls(const ChartTypeParameter & rParameter)292 void SortByXValuesResourceGroup::fillControls( const ChartTypeParameter& rParameter )
293 {
294 m_aCB_XValueSorting.Check( rParameter.bSortByXValues );
295 }
fillParameter(ChartTypeParameter & rParameter)296 void SortByXValuesResourceGroup::fillParameter( ChartTypeParameter& rParameter )
297 {
298 rParameter.bSortByXValues = m_aCB_XValueSorting.IsChecked();
299 }
IMPL_LINK(SortByXValuesResourceGroup,SortByXValuesCheckHdl,CheckBox *,EMPTYARG)300 IMPL_LINK( SortByXValuesResourceGroup, SortByXValuesCheckHdl, CheckBox*, EMPTYARG )
301 {
302 if(m_pChangeListener)
303 m_pChangeListener->stateChanged(this);
304 return 0;
305 }
306 //--------------------------------------------------------------------------
307 class StackingResourceGroup : public ChangingResource
308 {
309 public:
310 StackingResourceGroup( Window* pWindow );
311 virtual ~StackingResourceGroup();
312
313 void showControls( bool bShow, bool bShowDeepStacking );
314 Point getPosition();
315 long getHeight();
316 void setPosition( const Point& rPoint );
317
318 void fillControls( const ChartTypeParameter& rParameter );
319 void fillParameter( ChartTypeParameter& rParameter );
320
321 private:
322 DECL_LINK( StackingChangeHdl, RadioButton* );
323 DECL_LINK( StackingEnableHdl, void* );
324
325 private:
326 CheckBox m_aCB_Stacked;
327 RadioButton m_aRB_Stack_Y;
328 RadioButton m_aRB_Stack_Y_Percent;
329 RadioButton m_aRB_Stack_Z;
330
331 bool m_bShowDeepStacking;
332 };
StackingResourceGroup(Window * pWindow)333 StackingResourceGroup::StackingResourceGroup( Window* pWindow )
334 : ChangingResource()
335 , m_aCB_Stacked( pWindow, SchResId( CB_STACKED ) )
336 , m_aRB_Stack_Y( pWindow, SchResId( RB_STACK_Y ) )
337 , m_aRB_Stack_Y_Percent( pWindow, SchResId( RB_STACK_Y_PERCENT ) )
338 , m_aRB_Stack_Z( pWindow, SchResId( RB_STACK_Z ) )
339 , m_bShowDeepStacking(true)
340 {
341 m_aCB_Stacked.SetToggleHdl( LINK( this, StackingResourceGroup, StackingEnableHdl ) );
342 m_aRB_Stack_Y.SetToggleHdl( LINK( this, StackingResourceGroup, StackingChangeHdl ) );
343 m_aRB_Stack_Y_Percent.SetToggleHdl( LINK( this, StackingResourceGroup, StackingChangeHdl ) );
344 m_aRB_Stack_Z.SetToggleHdl( LINK( this, StackingResourceGroup, StackingChangeHdl ) );
345 m_aRB_Stack_Y.SetAccessibleRelationMemberOf(&m_aCB_Stacked);
346 m_aRB_Stack_Y_Percent.SetAccessibleRelationMemberOf(&m_aCB_Stacked);
347 m_aRB_Stack_Z.SetAccessibleRelationMemberOf(&m_aCB_Stacked);
348 }
~StackingResourceGroup()349 StackingResourceGroup::~StackingResourceGroup()
350 {
351 }
showControls(bool bShow,bool bShowDeepStacking)352 void StackingResourceGroup::showControls( bool bShow, bool bShowDeepStacking )
353 {
354 m_bShowDeepStacking = bShowDeepStacking;
355 m_aCB_Stacked.Show(bShow);
356 m_aRB_Stack_Y.Show(bShow);
357 m_aRB_Stack_Y_Percent.Show(bShow);
358 m_aRB_Stack_Z.Show(bShow&&bShowDeepStacking);
359 }
getPosition()360 Point StackingResourceGroup::getPosition()
361 {
362 return m_aCB_Stacked.GetPosPixel();
363 }
getHeight()364 long StackingResourceGroup::getHeight()
365 {
366 RadioButton& rLastButton = m_bShowDeepStacking ? m_aRB_Stack_Z : m_aRB_Stack_Y_Percent;
367
368 long nHeight = rLastButton.GetPosPixel().Y()
369 - m_aCB_Stacked.GetPosPixel().Y();
370 nHeight += rLastButton.GetSizePixel().Height();
371 return nHeight;
372 }
setPosition(const Point & rPoint)373 void StackingResourceGroup::setPosition( const Point& rPoint )
374 {
375 Point aOld = this->getPosition();
376 long nDiffY = rPoint.Y() - aOld.Y();
377 long nDiffX = rPoint.X() - aOld.X();
378 m_aCB_Stacked.SetPosPixel( Point( aOld.X()+nDiffX, aOld.Y()+nDiffY ) );
379
380 aOld = m_aRB_Stack_Y.GetPosPixel();
381 m_aRB_Stack_Y.SetPosPixel( Point( aOld.X()+nDiffX, aOld.Y()+nDiffY ) );
382
383 aOld = m_aRB_Stack_Y_Percent.GetPosPixel();
384 m_aRB_Stack_Y_Percent.SetPosPixel( Point( aOld.X()+nDiffX, aOld.Y()+nDiffY ) );
385
386 aOld = m_aRB_Stack_Z.GetPosPixel();
387 m_aRB_Stack_Z.SetPosPixel( Point( aOld.X()+nDiffX, aOld.Y()+nDiffY ) );
388 }
fillControls(const ChartTypeParameter & rParameter)389 void StackingResourceGroup::fillControls( const ChartTypeParameter& rParameter )
390 {
391 m_aCB_Stacked.Check( rParameter.eStackMode!=GlobalStackMode_NONE
392 && rParameter.eStackMode!=GlobalStackMode_STACK_Z ); //todo remove this condition if z stacking radio button is really used
393 switch( rParameter.eStackMode )
394 {
395 case GlobalStackMode_STACK_Y:
396 m_aRB_Stack_Y.Check();
397 break;
398 case GlobalStackMode_STACK_Y_PERCENT:
399 m_aRB_Stack_Y_Percent.Check();
400 break;
401 case GlobalStackMode_STACK_Z:
402 //todo uncomment this condition if z stacking radio button is really used
403 /*
404 if( rParameter.b3DLook )
405 m_aRB_Stack_Z.Check();
406 else
407 */
408 m_aRB_Stack_Y.Check();
409 break;
410 default:
411 m_aRB_Stack_Y.Check();
412 break;
413 }
414 //dis/enabling
415 m_aCB_Stacked.Enable( !rParameter.bXAxisWithValues );
416 m_aRB_Stack_Y.Enable( m_aCB_Stacked.IsChecked() && !rParameter.bXAxisWithValues );
417 m_aRB_Stack_Y_Percent.Enable( m_aCB_Stacked.IsChecked() && !rParameter.bXAxisWithValues );
418 m_aRB_Stack_Z.Enable( m_aCB_Stacked.IsChecked() && rParameter.b3DLook );
419 }
fillParameter(ChartTypeParameter & rParameter)420 void StackingResourceGroup::fillParameter( ChartTypeParameter& rParameter )
421 {
422 if(!m_aCB_Stacked.IsChecked())
423 rParameter.eStackMode = GlobalStackMode_NONE;
424 else if(m_aRB_Stack_Y.IsChecked())
425 rParameter.eStackMode = GlobalStackMode_STACK_Y;
426 else if(m_aRB_Stack_Y_Percent.IsChecked())
427 rParameter.eStackMode = GlobalStackMode_STACK_Y_PERCENT;
428 else if(m_aRB_Stack_Z.IsChecked())
429 rParameter.eStackMode = GlobalStackMode_STACK_Z;
430 }
IMPL_LINK(StackingResourceGroup,StackingChangeHdl,RadioButton *,pRadio)431 IMPL_LINK( StackingResourceGroup, StackingChangeHdl, RadioButton*, pRadio )
432 {
433 //for each radio click there are coming two change events
434 //first uncheck of previous button -> ignore that call
435 //the second call gives the check of the new button
436 if( m_pChangeListener && pRadio && pRadio->IsChecked() )
437 m_pChangeListener->stateChanged(this);
438 return 0;
439 }
IMPL_LINK(StackingResourceGroup,StackingEnableHdl,void *,EMPTYARG)440 IMPL_LINK( StackingResourceGroup, StackingEnableHdl, void*, EMPTYARG )
441 {
442 if( m_pChangeListener )
443 m_pChangeListener->stateChanged(this);
444 return 0;
445 }
446 //--------------------------------------------------------------------------
447 class SplinePropertiesDialog : public ModalDialog
448 {
449 public:
450 SplinePropertiesDialog( Window* pParent );
451 virtual ~SplinePropertiesDialog();
452
453 void fillControls( const ChartTypeParameter& rParameter );
454 void fillParameter( ChartTypeParameter& rParameter, bool bSmoothLines );
455
456 virtual void StateChanged( StateChangedType nType );
457
458 private:
459 DECL_LINK( SplineModeRadioHdl, RadioButton* );
460
461 void adjustControlPositions();
462 void adjustSize();
463
464 private:
465 RadioButton m_aRB_Splines_Cubic;
466 RadioButton m_aRB_Splines_B;
467
468 FixedLine m_aFL_SplineSeparator;
469
470 FixedText m_aFT_SplineResolution;
471 MetricField m_aMF_SplineResolution;
472 FixedText m_aFT_SplineOrder;
473 MetricField m_aMF_SplineOrder;
474
475 FixedLine m_aFL_DialogButtons;
476 HelpButton m_aBP_Help;
477 OKButton m_aBP_OK;
478 CancelButton m_aBP_Cancel;
479 };
480
SplinePropertiesDialog(Window * pParent)481 SplinePropertiesDialog::SplinePropertiesDialog( Window* pParent )
482 : ModalDialog( pParent, SchResId( DLG_SPLINE_PROPERTIES ) )
483 , m_aRB_Splines_Cubic( this, SchResId( RB_SPLINES_CUBIC ) )
484 , m_aRB_Splines_B( this, SchResId( RB_SPLINES_B ) )
485 , m_aFL_SplineSeparator( this, SchResId( FL_SPLINE_SEPARATOR ) )
486 , m_aFT_SplineResolution( this, SchResId( FT_SPLINE_RESOLUTION ) )
487 , m_aMF_SplineResolution( this, SchResId( MF_SPLINE_RESOLUTION ) )
488 , m_aFT_SplineOrder( this, SchResId( FT_SPLINE_ORDER ) )
489 , m_aMF_SplineOrder( this, SchResId( MF_SPLINE_ORDER ) )
490 , m_aFL_DialogButtons( this, SchResId( FL_SPLINE_DIALOGBUTTONS ) )
491 , m_aBP_Help( this, SchResId(BTN_HELP) )
492 , m_aBP_OK( this, SchResId(BTN_OK) )
493 , m_aBP_Cancel( this, SchResId(BTN_CANCEL) )
494 {
495 FreeResource();
496
497 this->SetText( String( SchResId( STR_DLG_SMOOTH_LINE_PROPERTIES ) ) );
498
499 m_aRB_Splines_Cubic.SetToggleHdl( LINK( this, SplinePropertiesDialog, SplineModeRadioHdl ) );
500 m_aRB_Splines_B.SetToggleHdl( LINK( this, SplinePropertiesDialog, SplineModeRadioHdl ) );
501 }
502
~SplinePropertiesDialog()503 SplinePropertiesDialog::~SplinePropertiesDialog()
504 {
505 }
506
StateChanged(StateChangedType nType)507 void SplinePropertiesDialog::StateChanged( StateChangedType nType )
508 {
509 Dialog::StateChanged( nType );
510
511 if( nType == STATE_CHANGE_INITSHOW )
512 {
513 adjustControlPositions();
514 adjustSize();
515 }
516 }
517
adjustControlPositions()518 void SplinePropertiesDialog::adjustControlPositions()
519 {
520 //position of controls:
521 //----------------
522 //fixed line and Fixed texts as near as possible to radio controls
523 long nRBWidth = ::std::max( m_aRB_Splines_Cubic.CalcMinimumSize().Width(), m_aRB_Splines_B.CalcMinimumSize().Width());
524 long nFLXPos = m_aRB_Splines_Cubic.GetPosPixel().X()+nRBWidth+m_aFT_SplineOrder.LogicToPixel( Size(RSC_SP_CTRL_GROUP_X,0), MapMode(MAP_APPFONT) ).Width();
525 long nFTXPos = nFLXPos + m_aFL_SplineSeparator.GetSizePixel().Width() + m_aFT_SplineOrder.LogicToPixel( Size(RSC_SP_CTRL_GROUP_X,0), MapMode(MAP_APPFONT) ).Width();
526
527 m_aRB_Splines_Cubic.SetSizePixel( Size( nRBWidth, m_aRB_Splines_Cubic.GetSizePixel().Height() ) );
528 m_aRB_Splines_B.SetSizePixel( Size( nRBWidth, m_aRB_Splines_B.GetSizePixel().Height() ) );
529
530 m_aFL_SplineSeparator.SetPosPixel( Point( nFLXPos, m_aFL_SplineSeparator.GetPosPixel().Y() ) );
531
532 m_aFT_SplineOrder.SetPosPixel( Point( nFTXPos, m_aFT_SplineOrder.GetPosPixel().Y() ) );
533 m_aFT_SplineResolution.SetPosPixel( Point( nFTXPos, m_aFT_SplineResolution.GetPosPixel().Y() ) );
534
535 //----------------
536 //move metric controls as near to text as possible
537 long nFTWidth = ::std::max( m_aFT_SplineOrder.CalcMinimumSize().Width(), m_aFT_SplineResolution.CalcMinimumSize().Width());
538 long nMFXPos = m_aFT_SplineOrder.GetPosPixel().X()+nFTWidth+m_aFT_SplineOrder.LogicToPixel( Size(RSC_SP_CTRL_DESC_X,0), MapMode(MAP_APPFONT) ).Width();
539
540 m_aFT_SplineOrder.SetSizePixel( Size( nFTWidth, m_aFT_SplineOrder.GetSizePixel().Height() ) );
541 m_aFT_SplineResolution.SetSizePixel( Size( nFTWidth, m_aFT_SplineResolution.GetSizePixel().Height() ) );
542
543 m_aMF_SplineOrder.SetPosPixel( Point( nMFXPos, m_aMF_SplineOrder.GetPosPixel().Y() ) );
544 m_aMF_SplineResolution.SetPosPixel( Point( nMFXPos, m_aMF_SplineResolution.GetPosPixel().Y() ) );
545 }
546
adjustSize()547 void SplinePropertiesDialog::adjustSize()
548 {
549 Size aDlgSize( this->GetSizePixel() );
550 long nBorder = m_aRB_Splines_Cubic.GetPosPixel().X();
551 long nX = m_aMF_SplineOrder.GetPosPixel().X() + m_aMF_SplineOrder.GetSizePixel().Width();
552 if(aDlgSize.Width()< (nX+nBorder) )
553 {
554 aDlgSize.Width() = (nX+nBorder);
555 this->SetSizePixel(aDlgSize);
556
557 Size aLineSize( m_aFL_DialogButtons.GetSizePixel() );
558 aLineSize.Width() = aDlgSize.Width();
559 m_aFL_DialogButtons.SetSizePixel(aLineSize);
560 }
561 }
fillControls(const ChartTypeParameter & rParameter)562 void SplinePropertiesDialog::fillControls( const ChartTypeParameter& rParameter )
563 {
564 switch(rParameter.eCurveStyle)
565 {
566 case CurveStyle_CUBIC_SPLINES:
567 m_aRB_Splines_Cubic.Check();
568 break;
569 case CurveStyle_B_SPLINES:
570 m_aRB_Splines_B.Check();
571 break;
572 default:
573 m_aRB_Splines_Cubic.Check();
574 break;
575 }
576 m_aMF_SplineOrder.SetValue( rParameter.nSplineOrder );
577 m_aMF_SplineResolution.SetValue( rParameter.nCurveResolution );
578
579 //dis/enabling
580 m_aFT_SplineOrder.Enable(m_aRB_Splines_B.IsChecked());
581 m_aMF_SplineOrder.Enable(m_aRB_Splines_B.IsChecked());
582 }
fillParameter(ChartTypeParameter & rParameter,bool bSmoothLines)583 void SplinePropertiesDialog::fillParameter( ChartTypeParameter& rParameter, bool bSmoothLines )
584 {
585 if(!bSmoothLines)
586 rParameter.eCurveStyle=CurveStyle_LINES;
587 else if(m_aRB_Splines_Cubic.IsChecked())
588 rParameter.eCurveStyle=CurveStyle_CUBIC_SPLINES;
589 else if(m_aRB_Splines_B.IsChecked())
590 rParameter.eCurveStyle=CurveStyle_B_SPLINES;
591
592 rParameter.nCurveResolution = static_cast< sal_Int32 >( m_aMF_SplineResolution.GetValue());
593 rParameter.nSplineOrder = static_cast< sal_Int32 >( m_aMF_SplineOrder.GetValue());
594 }
IMPL_LINK(SplinePropertiesDialog,SplineModeRadioHdl,RadioButton *,EMPTYARG)595 IMPL_LINK( SplinePropertiesDialog, SplineModeRadioHdl, RadioButton*, EMPTYARG )
596 {
597 m_aFT_SplineOrder.Enable(m_aRB_Splines_B.IsChecked());
598 m_aMF_SplineOrder.Enable(m_aRB_Splines_B.IsChecked());
599 return 0;
600 }
601
602 //--------------------------------------------------------------------------
603
604 class SplineResourceGroup : public ChangingResource
605 {
606 public:
607 SplineResourceGroup( Window* pWindow );
608 virtual ~SplineResourceGroup();
609
610 void showControls( bool bShow );
611 Point getPosition();
612 long getHeight();
613 void setPosition( const Point& rPoint );
614
615 void fillControls( const ChartTypeParameter& rParameter );
616 void fillParameter( ChartTypeParameter& rParameter );
617
618 private:
619 DECL_LINK( SplineChangeHdl, void* );
620 DECL_LINK( SplineDetailsDialogHdl, void* );
621 SplinePropertiesDialog& getSplinePropertiesDialog();
622
623 private:
624 CheckBox m_aCB_Splines;
625 PushButton m_aPB_DetailsDialog;
626 ::std::auto_ptr< SplinePropertiesDialog > m_pSplinePropertiesDialog;
627 };
SplineResourceGroup(Window * pWindow)628 SplineResourceGroup::SplineResourceGroup( Window* pWindow )
629 : ChangingResource()
630 , m_aCB_Splines( pWindow, SchResId( CB_SPLINES ) )
631 , m_aPB_DetailsDialog( pWindow, SchResId( PB_SPLINE_DIALOG ) )
632 , m_pSplinePropertiesDialog()
633 {
634 m_aCB_Splines.SetToggleHdl( LINK( this, SplineResourceGroup, SplineChangeHdl ) );
635 m_aPB_DetailsDialog.SetClickHdl( LINK( this, SplineResourceGroup, SplineDetailsDialogHdl ) );
636 m_aPB_DetailsDialog.SetQuickHelpText( String( SchResId(STR_DLG_SMOOTH_LINE_PROPERTIES) ) );
637
638 Size aButtonSize( m_aPB_DetailsDialog.GetSizePixel() );
639 Size aMinSize( m_aPB_DetailsDialog.CalcMinimumSize() );
640 sal_Int32 nDistance = 10;
641 if( pWindow )
642 {
643 Size aDistanceSize( pWindow->LogicToPixel( Size(RSC_SP_CTRL_DESC_X,2), MapMode(MAP_APPFONT) ) );
644 nDistance = 2*aDistanceSize.Width();
645 }
646 aButtonSize.Width() = aMinSize.Width() + nDistance;
647 m_aPB_DetailsDialog.SetSizePixel( aButtonSize );
648 }
~SplineResourceGroup()649 SplineResourceGroup::~SplineResourceGroup()
650 {
651 }
getSplinePropertiesDialog()652 SplinePropertiesDialog& SplineResourceGroup::getSplinePropertiesDialog()
653 {
654 if( !m_pSplinePropertiesDialog.get() )
655 m_pSplinePropertiesDialog = ::std::auto_ptr< SplinePropertiesDialog >( new SplinePropertiesDialog( m_aPB_DetailsDialog.GetParent() ) );
656 return *m_pSplinePropertiesDialog;
657 }
showControls(bool bShow)658 void SplineResourceGroup::showControls( bool bShow )
659 {
660 m_aCB_Splines.Show(bShow);
661 m_aPB_DetailsDialog.Show(bShow);
662 }
getPosition()663 Point SplineResourceGroup::getPosition()
664 {
665 return m_aCB_Splines.GetPosPixel();
666 }
getHeight()667 long SplineResourceGroup::getHeight()
668 {
669 return m_aCB_Splines.GetSizePixel().Height() + m_aPB_DetailsDialog.LogicToPixel( Size(0,2), MapMode(MAP_APPFONT) ).Height();
670 }
setPosition(const Point & rPoint)671 void SplineResourceGroup::setPosition( const Point& rPoint )
672 {
673 Size aSize( m_aCB_Splines.CalcMinimumSize() );
674 Size aDistanceSize( m_aCB_Splines.LogicToPixel( Size(RSC_SP_CTRL_GROUP_X,1), MapMode(MAP_APPFONT) ) );
675 m_aCB_Splines.SetSizePixel( aSize );
676
677 Point aOld = this->getPosition();
678 long nDiffY = rPoint.Y() - aOld.Y();
679 long nDiffX = rPoint.X() - aOld.X();
680
681 Point aNew( aOld.X()+nDiffX, aOld.Y()+nDiffY );
682 m_aCB_Splines.SetPosPixel( aNew );
683
684 aNew.X() += ( aSize.Width() + aDistanceSize.Width() );
685 aNew.Y() -= 3*aDistanceSize.Height();
686 m_aPB_DetailsDialog.SetPosPixel( aNew );
687 }
688
fillControls(const ChartTypeParameter & rParameter)689 void SplineResourceGroup::fillControls( const ChartTypeParameter& rParameter )
690 {
691 m_aCB_Splines.Check( rParameter.eCurveStyle!=CurveStyle_LINES );
692 getSplinePropertiesDialog().fillControls( rParameter );
693 }
fillParameter(ChartTypeParameter & rParameter)694 void SplineResourceGroup::fillParameter( ChartTypeParameter& rParameter )
695 {
696 getSplinePropertiesDialog().fillParameter( rParameter, m_aCB_Splines.IsChecked() );
697 }
IMPL_LINK(SplineResourceGroup,SplineChangeHdl,void *,EMPTYARG)698 IMPL_LINK( SplineResourceGroup, SplineChangeHdl, void*, EMPTYARG )
699 {
700 if( m_pChangeListener )
701 m_pChangeListener->stateChanged(this);
702 return 0;
703 }
704
IMPL_LINK(SplineResourceGroup,SplineDetailsDialogHdl,void *,EMPTYARG)705 IMPL_LINK( SplineResourceGroup, SplineDetailsDialogHdl, void*, EMPTYARG )
706 {
707
708 ChartTypeParameter aOldParameter;
709 getSplinePropertiesDialog().fillParameter( aOldParameter, m_aCB_Splines.IsChecked() );
710
711 sal_Bool bOldSmoothLines = m_aCB_Splines.IsChecked();
712 m_aCB_Splines.Check();
713 if( RET_OK == getSplinePropertiesDialog().Execute() )
714 {
715 if( m_pChangeListener )
716 m_pChangeListener->stateChanged(this);
717 }
718 else
719 {
720 //restore old state:
721 m_aCB_Splines.Check( bOldSmoothLines );
722 getSplinePropertiesDialog().fillControls( aOldParameter );
723 }
724 return 0;
725 }
726
727 //--------------------------------------------------------------------------
728
729 class GeometryResourceGroup : public ChangingResource
730 {
731 public:
732 GeometryResourceGroup( Window* pWindow );
733 virtual ~GeometryResourceGroup();
734
735 void showControls( bool bShow );
736 long getHeight();
737 void setPosition( const Point& rPoint );
738
739 void fillControls( const ChartTypeParameter& rParameter );
740 void fillParameter( ChartTypeParameter& rParameter );
741
742 private:
743 DECL_LINK( GeometryChangeHdl, void* );
744
745 private:
746 BarGeometryResources m_aGeometryResources;
747 };
GeometryResourceGroup(Window * pWindow)748 GeometryResourceGroup::GeometryResourceGroup( Window* pWindow )
749 : ChangingResource()
750 , m_aGeometryResources( pWindow )
751 {
752 m_aGeometryResources.SetSelectHdl( LINK( this, GeometryResourceGroup, GeometryChangeHdl ) );
753 }
~GeometryResourceGroup()754 GeometryResourceGroup::~GeometryResourceGroup()
755 {
756 }
showControls(bool bShow)757 void GeometryResourceGroup::showControls( bool bShow )
758 {
759 m_aGeometryResources.Show(bShow);
760 }
getHeight()761 long GeometryResourceGroup::getHeight()
762 {
763 return m_aGeometryResources.GetSizePixel().Height();
764 }
setPosition(const Point & rPoint)765 void GeometryResourceGroup::setPosition( const Point& rPoint )
766 {
767 m_aGeometryResources.SetPosPixel( rPoint );
768 }
769
fillControls(const ChartTypeParameter & rParameter)770 void GeometryResourceGroup::fillControls( const ChartTypeParameter& rParameter )
771 {
772 sal_uInt16 nGeometry3D = static_cast<sal_uInt16>(rParameter.nGeometry3D);
773 m_aGeometryResources.SelectEntryPos(nGeometry3D);
774 m_aGeometryResources.Enable(rParameter.b3DLook);
775 }
fillParameter(ChartTypeParameter & rParameter)776 void GeometryResourceGroup::fillParameter( ChartTypeParameter& rParameter )
777 {
778 rParameter.nGeometry3D = 1;
779 if( m_aGeometryResources.GetSelectEntryCount() )
780 rParameter.nGeometry3D = m_aGeometryResources.GetSelectEntryPos();
781 }
IMPL_LINK(GeometryResourceGroup,GeometryChangeHdl,void *,EMPTYARG)782 IMPL_LINK( GeometryResourceGroup, GeometryChangeHdl, void*, EMPTYARG )
783 {
784 if( m_pChangeListener )
785 m_pChangeListener->stateChanged(this);
786 return 0;
787 }
788
789 //--------------------------------------------------------------------------
790 //--------------------------------------------------------------------------
791 //--------------------------------------------------------------------------
792
ChartTypeTabPage(Window * pParent,const uno::Reference<XChartDocument> & xChartModel,const uno::Reference<uno::XComponentContext> & xContext,bool bDoLiveUpdate,bool bHideDescription)793 ChartTypeTabPage::ChartTypeTabPage( Window* pParent
794 , const uno::Reference< XChartDocument >& xChartModel
795 , const uno::Reference< uno::XComponentContext >& xContext
796 , bool bDoLiveUpdate, bool bHideDescription )
797 : OWizardPage( pParent, SchResId(TP_CHARTTYPE) )
798 , m_aFT_ChooseType( this, SchResId( FT_CHARTTYPE ) )
799 , m_aMainTypeList( this, SchResId( LB_CHARTTYPE ) )
800 , m_aSubTypeList( this, SchResId( CT_CHARTVARIANT ) )
801 , m_pAxisTypeResourceGroup( new AxisTypeResourceGroup(this) )
802 , m_pDim3DLookResourceGroup( new Dim3DLookResourceGroup(this) )
803 , m_pStackingResourceGroup( new StackingResourceGroup(this) )
804 , m_pSplineResourceGroup( new SplineResourceGroup(this) )
805 , m_pGeometryResourceGroup( new GeometryResourceGroup( this ) )
806 , m_pSortByXValuesResourceGroup( new SortByXValuesResourceGroup( this ) )
807 , m_nYTopPos(0)
808 , m_xChartModel( xChartModel )
809 , m_xCC( xContext )
810 , m_aChartTypeDialogControllerList(0)
811 , m_pCurrentMainType(0)
812 , m_nChangingCalls(0)
813 , m_bDoLiveUpdate(bDoLiveUpdate)
814 , m_aTimerTriggeredControllerLock( uno::Reference< frame::XModel >( m_xChartModel, uno::UNO_QUERY ) )
815 {
816 FreeResource();
817
818 if( bHideDescription )
819 {
820 m_aFT_ChooseType.Hide();
821 long nYDiff = m_aMainTypeList.GetPosPixel().Y() - m_aFT_ChooseType.GetPosPixel().Y();
822
823 Point aOldPos( m_aMainTypeList.GetPosPixel() );
824 m_aMainTypeList.SetPosPixel( Point( aOldPos.X(), aOldPos.Y() - nYDiff ) );
825
826 aOldPos = m_aSubTypeList.GetPosPixel();
827 m_aSubTypeList.SetPosPixel( Point( aOldPos.X(), aOldPos.Y() - nYDiff ) );
828
829 aOldPos = m_pAxisTypeResourceGroup->getPosition();
830 m_pAxisTypeResourceGroup->setPosition( Point( aOldPos.X(), aOldPos.Y() - nYDiff ) );
831
832 Size aSize( this->GetSizePixel() );
833 this->SetSizePixel( Size( aSize.Width(), aSize.Height()-nYDiff+3 ) );
834 }
835 else
836 {
837 Font aFont( m_aFT_ChooseType.GetControlFont() );
838 aFont.SetWeight( WEIGHT_BOLD );
839 m_aFT_ChooseType.SetControlFont( aFont );
840
841 m_aFT_ChooseType.SetStyle( m_aFT_ChooseType.GetStyle() | WB_NOLABEL );
842 }
843
844 this->SetText( String(SchResId(STR_PAGE_CHARTTYPE)) );
845
846 m_aMainTypeList.SetStyle(m_aMainTypeList.GetStyle() | WB_ITEMBORDER | WB_DOUBLEBORDER | WB_FLATVALUESET | WB_3DLOOK );
847 m_aMainTypeList.SetSelectHdl( LINK( this, ChartTypeTabPage, SelectMainTypeHdl ) );
848 m_aSubTypeList.SetSelectHdl( LINK( this, ChartTypeTabPage, SelectSubTypeHdl ) );
849
850 m_aSubTypeList.SetStyle(m_aSubTypeList.GetStyle() |
851 WB_ITEMBORDER | WB_DOUBLEBORDER | WB_NAMEFIELD | WB_FLATVALUESET | WB_3DLOOK );
852 m_aSubTypeList.SetColCount(4);
853 m_aSubTypeList.SetLineCount(1);
854
855 bool bIsHighContrast = ( true && GetSettings().GetStyleSettings().GetHighContrastMode() );
856
857 bool bDisableComplexChartTypes = false;
858 uno::Reference< beans::XPropertySet > xProps( m_xChartModel, uno::UNO_QUERY );
859 if ( xProps.is() )
860 {
861 try
862 {
863 xProps->getPropertyValue( C2U( "DisableComplexChartTypes" ) ) >>= bDisableComplexChartTypes;
864 }
865 catch( uno::Exception& e )
866 {
867 ASSERT_EXCEPTION( e );
868 }
869 }
870
871 m_aChartTypeDialogControllerList.push_back(new ColumnChartDialogController() );
872 m_aChartTypeDialogControllerList.push_back(new BarChartDialogController() );
873 m_aChartTypeDialogControllerList.push_back(new PieChartDialogController() );
874 m_aChartTypeDialogControllerList.push_back(new AreaChartDialogController() );
875 m_aChartTypeDialogControllerList.push_back(new LineChartDialogController() );
876 if ( !bDisableComplexChartTypes )
877 {
878 m_aChartTypeDialogControllerList.push_back(new XYChartDialogController() );
879 m_aChartTypeDialogControllerList.push_back(new BubbleChartDialogController() );
880 }
881 m_aChartTypeDialogControllerList.push_back(new NetChartDialogController() );
882 if ( !bDisableComplexChartTypes )
883 {
884 m_aChartTypeDialogControllerList.push_back(new StockChartDialogController() );
885 }
886 m_aChartTypeDialogControllerList.push_back(new CombiColumnLineChartDialogController() );
887
888 ::std::vector< ChartTypeDialogController* >::const_iterator aIter = m_aChartTypeDialogControllerList.begin();
889 const ::std::vector< ChartTypeDialogController* >::const_iterator aEnd = m_aChartTypeDialogControllerList.end();
890 for( ; aIter != aEnd; aIter++ )
891 {
892 m_aMainTypeList.InsertEntry( (*aIter)->getName(), (*aIter)->getImage( bIsHighContrast ) );
893 (*aIter)->setChangeListener( this );
894 }
895
896 m_nYTopPos = m_pAxisTypeResourceGroup->getPosition().Y();
897
898 m_pAxisTypeResourceGroup->setChangeListener( this );
899 m_pDim3DLookResourceGroup->setChangeListener( this );
900 m_pStackingResourceGroup->setChangeListener( this );
901 m_pSplineResourceGroup->setChangeListener( this );
902 m_pGeometryResourceGroup->setChangeListener( this );
903 m_pSortByXValuesResourceGroup->setChangeListener( this );
904 }
905
~ChartTypeTabPage()906 ChartTypeTabPage::~ChartTypeTabPage()
907 {
908 //delete all dialog controller
909 ::std::vector< ChartTypeDialogController* >::const_iterator aIter = m_aChartTypeDialogControllerList.begin();
910 const ::std::vector< ChartTypeDialogController* >::const_iterator aEnd = m_aChartTypeDialogControllerList.end();
911 for( ; aIter != aEnd; aIter++ )
912 {
913 delete *aIter;
914 }
915 m_aChartTypeDialogControllerList.clear();
916
917 //delete all resource helper
918 delete m_pAxisTypeResourceGroup;
919 delete m_pDim3DLookResourceGroup;
920 delete m_pStackingResourceGroup;
921 delete m_pSplineResourceGroup;
922 delete m_pGeometryResourceGroup;
923 delete m_pSortByXValuesResourceGroup;
924 }
getCurrentParamter() const925 ChartTypeParameter ChartTypeTabPage::getCurrentParamter() const
926 {
927 ChartTypeParameter aParameter;
928 aParameter.nSubTypeIndex = static_cast<sal_Int32>( m_aSubTypeList.GetSelectItemId() );
929 m_pAxisTypeResourceGroup->fillParameter( aParameter );
930 m_pDim3DLookResourceGroup->fillParameter( aParameter );
931 m_pStackingResourceGroup->fillParameter( aParameter );
932 m_pSplineResourceGroup->fillParameter( aParameter );
933 m_pGeometryResourceGroup->fillParameter( aParameter );
934 m_pSortByXValuesResourceGroup->fillParameter( aParameter );
935 return aParameter;
936 }
commitToModel(const ChartTypeParameter & rParameter)937 void ChartTypeTabPage::commitToModel( const ChartTypeParameter& rParameter )
938 {
939 if( !m_pCurrentMainType )
940 return;
941
942 m_aTimerTriggeredControllerLock.startTimer();
943 ControllerLockGuard aLockedControllers( uno::Reference< frame::XModel >( m_xChartModel, uno::UNO_QUERY ) );
944 m_pCurrentMainType->commitToModel( rParameter, m_xChartModel );
945 }
stateChanged(ChangingResource *)946 void ChartTypeTabPage::stateChanged( ChangingResource* /*pResource*/ )
947 {
948 if(m_nChangingCalls)
949 return;
950 m_nChangingCalls++;
951
952 ChartTypeParameter aParameter( this->getCurrentParamter() );
953 if( m_pCurrentMainType )
954 {
955 m_pCurrentMainType->adjustParameterToSubType( aParameter );
956 m_pCurrentMainType->adjustSubTypeAndEnableControls( aParameter );
957 }
958 if( m_bDoLiveUpdate )
959 commitToModel( aParameter );
960
961 //detect the new ThreeDLookScheme
962 aParameter.eThreeDLookScheme = ThreeDHelper::detectScheme( ChartModelHelper::findDiagram( m_xChartModel ) );
963 aParameter.bSortByXValues = lcl_getSortByXValues( m_xChartModel );
964 //the controls have to be enabled/disabled accordingly
965 this->fillAllControls( aParameter );
966
967 m_nChangingCalls--;
968 }
getSelectedMainType()969 ChartTypeDialogController* ChartTypeTabPage::getSelectedMainType()
970 {
971 ChartTypeDialogController* pTypeController = 0;
972 ::std::vector< ChartTypeDialogController* >::size_type nM = static_cast< ::std::vector< ChartTypeDialogController* >::size_type >(
973 m_aMainTypeList.GetSelectEntryPos() );
974 if( nM<m_aChartTypeDialogControllerList.size() )
975 pTypeController = m_aChartTypeDialogControllerList[nM];
976 return pTypeController;
977 }
IMPL_LINK(ChartTypeTabPage,SelectSubTypeHdl,void *,EMPTYARG)978 IMPL_LINK( ChartTypeTabPage, SelectSubTypeHdl, void *, EMPTYARG )
979 {
980 if( m_pCurrentMainType )
981 {
982 ChartTypeParameter aParameter( this->getCurrentParamter() );
983 m_pCurrentMainType->adjustParameterToSubType( aParameter );
984 this->fillAllControls( aParameter, false );
985 if( m_bDoLiveUpdate )
986 commitToModel( aParameter );
987 }
988 return 0;
989 }
990
IMPL_LINK(ChartTypeTabPage,SelectMainTypeHdl,void *,EMPTYARG)991 IMPL_LINK( ChartTypeTabPage, SelectMainTypeHdl, void *, EMPTYARG )
992 {
993 ChartTypeParameter aParameter( this->getCurrentParamter() );
994
995 if( m_pCurrentMainType )
996 {
997 m_pCurrentMainType->adjustParameterToSubType( aParameter );
998 m_pCurrentMainType->hideExtraControls();
999 }
1000
1001 m_pCurrentMainType = this->getSelectedMainType();
1002 if( m_pCurrentMainType )
1003 {
1004 this->showAllControls(*m_pCurrentMainType);
1005
1006 m_pCurrentMainType->adjustParameterToMainType( aParameter );
1007 if( m_bDoLiveUpdate )
1008 commitToModel( aParameter );
1009 //detect the new ThreeDLookScheme
1010 aParameter.eThreeDLookScheme = ThreeDHelper::detectScheme( ChartModelHelper::findDiagram( m_xChartModel ) );
1011 if(!aParameter.b3DLook && aParameter.eThreeDLookScheme!=ThreeDLookScheme_Realistic )
1012 aParameter.eThreeDLookScheme=ThreeDLookScheme_Realistic;
1013
1014 aParameter.bSortByXValues = lcl_getSortByXValues( m_xChartModel );
1015 this->fillAllControls( aParameter );
1016 uno::Reference< beans::XPropertySet > xTemplateProps( this->getCurrentTemplate(), uno::UNO_QUERY );
1017 m_pCurrentMainType->fillExtraControls(aParameter,m_xChartModel,xTemplateProps);
1018 }
1019 return 0;
1020 }
1021
showAllControls(ChartTypeDialogController & rTypeController)1022 void ChartTypeTabPage::showAllControls( ChartTypeDialogController& rTypeController )
1023 {
1024 m_aSubTypeList.Show();
1025
1026 long nYPos = m_nYTopPos;
1027
1028 //------
1029 bool bShow = rTypeController.shouldShow_XAxisTypeControl();
1030 long nXPos = m_pAxisTypeResourceGroup->getPosition().X();
1031 m_pAxisTypeResourceGroup->showControls( bShow );
1032 if(bShow)
1033 {
1034 m_pAxisTypeResourceGroup->setPosition( Point( nXPos, nYPos ) );
1035 nYPos += m_pAxisTypeResourceGroup->getHeight() + lcl_getDistance();
1036 }
1037 //------
1038 bShow = rTypeController.shouldShow_3DLookControl();
1039 m_pDim3DLookResourceGroup->showControls( bShow );
1040 if(bShow)
1041 {
1042 m_pDim3DLookResourceGroup->setPosition( Point( nXPos, nYPos ) );
1043 nYPos += m_pDim3DLookResourceGroup->getHeight() + lcl_getDistance();
1044 }
1045 //------
1046 bShow = rTypeController.shouldShow_StackingControl();
1047 m_pStackingResourceGroup->showControls( bShow, rTypeController.shouldShow_DeepStackingControl() );
1048 if(bShow)
1049 {
1050 long nStackingXPos = nXPos;
1051 if( rTypeController.shouldShow_XAxisTypeControl() )
1052 nStackingXPos += this->LogicToPixel( Size(RSC_SP_CHK_TEXTINDENT,0), MapMode(MAP_APPFONT) ).Width();
1053 m_pStackingResourceGroup->setPosition( Point( nStackingXPos, nYPos ) );
1054 nYPos += m_pStackingResourceGroup->getHeight() + lcl_getDistance();
1055 }
1056 //------
1057 bShow = rTypeController.shouldShow_SplineControl();
1058 m_pSplineResourceGroup->showControls( bShow );
1059 if(bShow)
1060 {
1061 m_pSplineResourceGroup->setPosition( Point( nXPos, nYPos ) );
1062 nYPos += m_pSplineResourceGroup->getHeight() + lcl_getDistance();
1063 }
1064 //------
1065 bShow = rTypeController.shouldShow_GeometryControl();
1066 m_pGeometryResourceGroup->showControls( bShow );
1067 if(bShow)
1068 {
1069 m_pGeometryResourceGroup->setPosition( Point( nXPos+17, nYPos ) );
1070 nYPos += m_pGeometryResourceGroup->getHeight() + lcl_getDistance();
1071 }
1072 //------
1073 bShow = rTypeController.shouldShow_SortByXValuesResourceGroup();
1074 m_pSortByXValuesResourceGroup->showControls( bShow );
1075 if(bShow)
1076 {
1077 m_pSortByXValuesResourceGroup->setPosition( Point( nXPos, nYPos ) );
1078 nYPos += m_pSortByXValuesResourceGroup->getHeight() + lcl_getDistance();
1079 }
1080 //------
1081 Size aPageSize( this->GetSizePixel() );
1082 Size aRemainingSize = Size( aPageSize.Width()-nXPos, aPageSize.Height()-nYPos );
1083 rTypeController.showExtraControls( this, Point( nXPos, nYPos ), aRemainingSize );
1084 }
1085
fillAllControls(const ChartTypeParameter & rParameter,bool bAlsoResetSubTypeList)1086 void ChartTypeTabPage::fillAllControls( const ChartTypeParameter& rParameter, bool bAlsoResetSubTypeList )
1087 {
1088 m_nChangingCalls++;
1089 if( m_pCurrentMainType && bAlsoResetSubTypeList )
1090 {
1091 bool bIsHighContrast = ( true && GetSettings().GetStyleSettings().GetHighContrastMode() );
1092 m_pCurrentMainType->fillSubTypeList( m_aSubTypeList, bIsHighContrast, rParameter );
1093 }
1094 m_aSubTypeList.SelectItem( static_cast<sal_uInt16>( rParameter.nSubTypeIndex) );
1095 m_pAxisTypeResourceGroup->fillControls( rParameter );
1096 m_pDim3DLookResourceGroup->fillControls( rParameter );
1097 m_pStackingResourceGroup->fillControls( rParameter );
1098 m_pSplineResourceGroup->fillControls( rParameter );
1099 m_pGeometryResourceGroup->fillControls( rParameter );
1100 m_pSortByXValuesResourceGroup->fillControls( rParameter );
1101 m_nChangingCalls--;
1102 }
1103
initializePage()1104 void ChartTypeTabPage::initializePage()
1105 {
1106 if( !m_xChartModel.is() )
1107 return;
1108 uno::Reference< lang::XMultiServiceFactory > xTemplateManager( m_xChartModel->getChartTypeManager(), uno::UNO_QUERY );
1109 uno::Reference< frame::XModel > xModel( m_xChartModel, uno::UNO_QUERY);
1110 uno::Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( xModel ) );
1111 DiagramHelper::tTemplateWithServiceName aTemplate =
1112 DiagramHelper::getTemplateForDiagram( xDiagram, xTemplateManager );
1113 ::rtl::OUString aServiceName( aTemplate.second );
1114
1115 bool bFound = false;
1116
1117 ::std::vector< ChartTypeDialogController* >::iterator aIter = m_aChartTypeDialogControllerList.begin();
1118 const ::std::vector< ChartTypeDialogController* >::const_iterator aEnd = m_aChartTypeDialogControllerList.end();
1119 for( sal_uInt16 nM=0; aIter != aEnd; aIter++, nM++ )
1120 {
1121 if( (*aIter)->isSubType(aServiceName) )
1122 {
1123 bFound = true;
1124
1125 m_aMainTypeList.SelectEntryPos( nM );
1126 this->showAllControls( **aIter );
1127 uno::Reference< beans::XPropertySet > xTemplateProps( aTemplate.first, uno::UNO_QUERY );
1128 ChartTypeParameter aParameter = (*aIter)->getChartTypeParameterForService( aServiceName, xTemplateProps );
1129 m_pCurrentMainType = this->getSelectedMainType();
1130
1131 //set ThreeDLookScheme
1132 aParameter.eThreeDLookScheme = ThreeDHelper::detectScheme( xDiagram );
1133 if(!aParameter.b3DLook && aParameter.eThreeDLookScheme!=ThreeDLookScheme_Realistic )
1134 aParameter.eThreeDLookScheme=ThreeDLookScheme_Realistic;
1135
1136 aParameter.bSortByXValues = lcl_getSortByXValues( m_xChartModel );
1137
1138 this->fillAllControls( aParameter );
1139 if( m_pCurrentMainType )
1140 m_pCurrentMainType->fillExtraControls(aParameter,m_xChartModel,xTemplateProps);
1141 break;
1142 }
1143 }
1144
1145 if( !bFound )
1146 {
1147 m_aSubTypeList.Hide();
1148 m_pAxisTypeResourceGroup->showControls( false );
1149 m_pDim3DLookResourceGroup->showControls( false );
1150 m_pStackingResourceGroup->showControls( false, false );
1151 m_pSplineResourceGroup->showControls( false );
1152 m_pGeometryResourceGroup->showControls( false );
1153 m_pSortByXValuesResourceGroup->showControls( false );
1154 }
1155 }
1156
commitPage(::svt::WizardTypes::CommitPageReason)1157 sal_Bool ChartTypeTabPage::commitPage( ::svt::WizardTypes::CommitPageReason /*eReason*/ )
1158 {
1159 //commit changes to model
1160 if( !m_bDoLiveUpdate && m_pCurrentMainType )
1161 {
1162 ChartTypeParameter aParameter( this->getCurrentParamter() );
1163 m_pCurrentMainType->adjustParameterToSubType( aParameter );
1164 commitToModel( aParameter );
1165 }
1166
1167 return sal_True;//return false if this page should not be left
1168 }
1169
getCurrentTemplate() const1170 uno::Reference< XChartTypeTemplate > ChartTypeTabPage::getCurrentTemplate() const
1171 {
1172 if( m_pCurrentMainType && m_xChartModel.is() )
1173 {
1174 ChartTypeParameter aParameter( this->getCurrentParamter() );
1175 m_pCurrentMainType->adjustParameterToSubType( aParameter );
1176 uno::Reference< lang::XMultiServiceFactory > xTemplateManager( m_xChartModel->getChartTypeManager(), uno::UNO_QUERY );
1177 return m_pCurrentMainType->getCurrentTemplate( aParameter, xTemplateManager );
1178 }
1179 return 0;
1180 }
1181
1182 //.............................................................................
1183 } //namespace chart
1184 //.............................................................................
1185