1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <res_ErrorBar.hxx>
21 #include <bitmaps.hlst>
22 #include <RangeSelectionHelper.hxx>
23 #include <TabPageNotifiable.hxx>
26 #include <rtl/math.hxx>
27 #include <vcl/dialog.hxx>
28 #include <svl/stritem.hxx>
30 #define CHART_LB_FUNCTION_STD_ERROR 0
31 #define CHART_LB_FUNCTION_STD_DEV 1
32 #define CHART_LB_FUNCTION_VARIANCE 2
33 #define CHART_LB_FUNCTION_ERROR_MARGIN 3
35 using namespace ::com::sun::star
;
39 void lcl_enableRangeChoosing( bool bEnable
, Dialog
* pDialog
)
43 pDialog
->Show( !bEnable
);
44 pDialog
->SetModalInputMode( !bEnable
);
48 sal_uInt16
lcl_getLbEntryPosByErrorKind( SvxChartKindError eErrorKind
)
50 sal_uInt16 nResult
= 0;
53 // for these cases select the default in the list box
54 case SvxChartKindError::NONE
:
55 case SvxChartKindError::Percent
:
56 case SvxChartKindError::Const
:
57 case SvxChartKindError::Range
:
58 nResult
= CHART_LB_FUNCTION_STD_DEV
;
60 case SvxChartKindError::Variant
:
61 nResult
= CHART_LB_FUNCTION_VARIANCE
;
63 case SvxChartKindError::Sigma
:
64 nResult
= CHART_LB_FUNCTION_STD_DEV
;
66 case SvxChartKindError::BigError
:
67 nResult
= CHART_LB_FUNCTION_ERROR_MARGIN
;
69 case SvxChartKindError::StdError
:
70 nResult
= CHART_LB_FUNCTION_STD_ERROR
;
75 } // anonymous namespace
80 ErrorBarResources::ErrorBarResources( VclBuilderContainer
* pParent
, Dialog
* pParentDialog
,
81 const SfxItemSet
& rInAttrs
, bool bNoneAvailable
,
82 tErrorBarType eType
/* = ERROR_BAR_Y */ ) :
83 m_eErrorKind( SvxChartKindError::NONE
),
84 m_eIndicate( SvxChartIndicate::Both
),
85 m_bErrorKindUnique( true ),
86 m_bIndicatorUnique( true ),
87 m_bRangePosUnique( true ),
88 m_bRangeNegUnique( true ),
89 m_eErrorBarType( eType
),
90 m_nConstDecimalDigits( 1 ),
91 m_nConstSpinSize( 1 ),
94 m_pParentDialog( pParentDialog
),
95 m_pCurrentRangeChoosingField( nullptr ),
96 m_bHasInternalDataProvider( true ),
97 m_bEnableDataTableDialog( true )
99 pParent
->get(m_pRbNone
,"RB_NONE");
100 pParent
->get(m_pRbConst
, "RB_CONST");
101 pParent
->get(m_pRbPercent
, "RB_PERCENT");
102 pParent
->get(m_pRbFunction
, "RB_FUNCTION");
103 pParent
->get(m_pRbRange
, "RB_RANGE");
104 pParent
->get(m_pLbFunction
, "LB_FUNCTION");
106 pParent
->get(m_pFlParameters
, "framePARAMETERS");
107 pParent
->get(m_pBxPositive
, "boxPOSITIVE");
108 pParent
->get(m_pMfPositive
, "MF_POSITIVE");
109 pParent
->get(m_pEdRangePositive
, "ED_RANGE_POSITIVE");
110 pParent
->get(m_pIbRangePositive
, "IB_RANGE_POSITIVE");
111 pParent
->get(m_pBxNegative
, "boxNEGATIVE");
112 pParent
->get(m_pMfNegative
, "MF_NEGATIVE");
113 pParent
->get(m_pEdRangeNegative
, "ED_RANGE_NEGATIVE");
114 pParent
->get(m_pIbRangeNegative
, "IB_RANGE_NEGATIVE");
115 pParent
->get(m_pCbSyncPosNeg
, "CB_SYN_POS_NEG");
117 pParent
->get(m_pRbBoth
, "RB_BOTH");
118 pParent
->get(m_pRbPositive
, "RB_POSITIVE");
119 pParent
->get(m_pRbNegative
, "RB_NEGATIVE");
120 pParent
->get(m_pFiBoth
, "FI_BOTH");
121 pParent
->get(m_pFiPositive
, "FI_POSITIVE");
122 pParent
->get(m_pFiNegative
, "FI_NEGATIVE");
124 pParent
->get(m_pUIStringPos
, "STR_DATA_SELECT_RANGE_FOR_POSITIVE_ERRORBARS");
125 pParent
->get(m_pUIStringNeg
, "STR_DATA_SELECT_RANGE_FOR_NEGATIVE_ERRORBARS");
126 pParent
->get(m_pUIStringRbRange
, "STR_CONTROLTEXT_ERROR_BARS_FROM_DATA");
129 m_pRbNone
->SetClickHdl( LINK( this, ErrorBarResources
, CategoryChosen
));
133 m_pRbConst
->SetClickHdl( LINK( this, ErrorBarResources
, CategoryChosen
));
134 m_pRbPercent
->SetClickHdl( LINK( this, ErrorBarResources
, CategoryChosen
));
135 m_pRbFunction
->SetClickHdl( LINK( this, ErrorBarResources
, CategoryChosen
));
136 m_pRbRange
->SetClickHdl( LINK( this, ErrorBarResources
, CategoryChosen
));
137 m_pLbFunction
->SetSelectHdl( LINK( this, ErrorBarResources
, CategoryChosen2
));
139 m_pCbSyncPosNeg
->Check( false );
140 m_pCbSyncPosNeg
->SetToggleHdl( LINK( this, ErrorBarResources
, SynchronizePosAndNeg
));
142 m_pMfPositive
->SetModifyHdl( LINK( this, ErrorBarResources
, PosValueChanged
));
143 m_pEdRangePositive
->SetModifyHdl( LINK( this, ErrorBarResources
, RangeChanged
));
144 m_pEdRangeNegative
->SetModifyHdl( LINK( this, ErrorBarResources
, RangeChanged
));
146 m_pRbPositive
->SetClickHdl( LINK( this, ErrorBarResources
, IndicatorChanged
));
147 m_pRbNegative
->SetClickHdl( LINK( this, ErrorBarResources
, IndicatorChanged
));
148 m_pRbBoth
->SetClickHdl( LINK( this, ErrorBarResources
, IndicatorChanged
));
150 m_pIbRangePositive
->SetClickHdl( LINK( this, ErrorBarResources
, ChooseRange
));
151 m_pIbRangeNegative
->SetClickHdl( LINK( this, ErrorBarResources
, ChooseRange
));
157 ErrorBarResources::~ErrorBarResources()
161 void ErrorBarResources::SetErrorBarType( tErrorBarType eNewType
)
163 if( m_eErrorBarType
!= eNewType
)
165 m_eErrorBarType
= eNewType
;
170 void ErrorBarResources::SetChartDocumentForRangeChoosing(
171 const uno::Reference
< chart2::XChartDocument
> & xChartDocument
)
173 if( xChartDocument
.is())
175 m_bHasInternalDataProvider
= xChartDocument
->hasInternalDataProvider();
176 uno::Reference
< beans::XPropertySet
> xProps( xChartDocument
, uno::UNO_QUERY
);
181 xProps
->getPropertyValue("EnableDataTableDialog") >>= m_bEnableDataTableDialog
;
183 catch( const uno::Exception
& e
)
185 SAL_WARN("chart2", "Exception caught. " << e
);
189 m_apRangeSelectionHelper
.reset( new RangeSelectionHelper( xChartDocument
));
191 // has internal data provider => rename "cell range" to "from data"
192 OSL_ASSERT( m_apRangeSelectionHelper
.get());
193 if( m_bHasInternalDataProvider
)
195 m_pRbRange
->SetText(m_pUIStringRbRange
->GetText());
196 m_pRbRange
->SetHelpId( HID_SCH_ERROR_BARS_FROM_DATA
);
199 if( m_pRbRange
->IsChecked())
201 isRangeFieldContentValid( *m_pEdRangePositive
);
202 isRangeFieldContentValid( *m_pEdRangeNegative
);
206 void ErrorBarResources::SetAxisMinorStepWidthForErrorBarDecimals( double fMinorStepWidth
)
208 if( fMinorStepWidth
< 0 )
209 fMinorStepWidth
= -fMinorStepWidth
;
211 sal_Int32 nExponent
= static_cast< sal_Int32
>( ::rtl::math::approxFloor( log10( fMinorStepWidth
)));
214 // one digit precision more
215 m_nConstDecimalDigits
= static_cast< sal_uInt16
>( (-nExponent
) + 1 );
216 m_nConstSpinSize
= 10;
220 m_nConstDecimalDigits
= 0;
221 m_nConstSpinSize
= static_cast< sal_Int64
>( pow( 10.0, static_cast<int>(nExponent
) ));
225 void ErrorBarResources::UpdateControlStates()
228 bool bIsFunction
= m_pRbFunction
->IsChecked();
229 m_pLbFunction
->Enable( bIsFunction
);
232 m_pRbRange
->Enable( !m_bHasInternalDataProvider
|| m_bEnableDataTableDialog
);
233 bool bShowRange
= m_pRbRange
->IsChecked();
234 bool bCanChooseRange
=
236 m_apRangeSelectionHelper
.get() &&
237 m_apRangeSelectionHelper
->hasRangeSelection());
239 m_pMfPositive
->Show( ! bShowRange
);
240 m_pMfNegative
->Show( ! bShowRange
);
242 // use range but without range chooser => hide controls
243 m_pEdRangePositive
->Show( bShowRange
&& ! m_bHasInternalDataProvider
);
244 m_pIbRangePositive
->Show( bCanChooseRange
);
245 m_pEdRangeNegative
->Show( bShowRange
&& ! m_bHasInternalDataProvider
);
246 m_pIbRangeNegative
->Show( bCanChooseRange
);
248 bool bShowPosNegAndSync
= ! (bShowRange
&& m_bHasInternalDataProvider
);
249 m_pFlParameters
->Show( bShowPosNegAndSync
);
251 // unit for metric fields
253 ( m_pRbFunction
->IsChecked()) &&
254 ( m_pLbFunction
->GetSelectedEntryPos() == CHART_LB_FUNCTION_ERROR_MARGIN
));
255 bool bIsPercentage( m_pRbPercent
->IsChecked() || bIsErrorMargin
);
256 FieldUnit eFieldUnit
= FUNIT_NONE
;
260 eFieldUnit
= FUNIT_PERCENT
;
261 m_pMfPositive
->SetDecimalDigits( 1 );
262 m_pMfPositive
->SetSpinSize( 10 );
263 m_pMfNegative
->SetDecimalDigits( 1 );
264 m_pMfNegative
->SetSpinSize( 10 );
268 m_pMfPositive
->SetDecimalDigits( m_nConstDecimalDigits
);
269 m_pMfPositive
->SetSpinSize( m_nConstSpinSize
);
270 m_pMfNegative
->SetDecimalDigits( m_nConstDecimalDigits
);
271 m_pMfNegative
->SetSpinSize( m_nConstSpinSize
);
274 sal_Int32 nPlusValue
= static_cast< sal_Int32
>( m_fPlusValue
* pow(10.0,m_pMfPositive
->GetDecimalDigits()) );
275 sal_Int32 nMinusValue
= static_cast< sal_Int32
>( m_fMinusValue
* pow(10.0,m_pMfNegative
->GetDecimalDigits()) );
277 m_pMfPositive
->SetValue( nPlusValue
);
278 m_pMfNegative
->SetValue( nMinusValue
);
280 m_pMfPositive
->SetUnit(eFieldUnit
);
281 m_pMfNegative
->SetUnit(eFieldUnit
);
283 // positive and negative value fields
284 bool bPosEnabled
= ( m_pRbPositive
->IsChecked() || m_pRbBoth
->IsChecked());
285 bool bNegEnabled
= ( m_pRbNegative
->IsChecked() || m_pRbBoth
->IsChecked());
286 if( !( bPosEnabled
|| bNegEnabled
))
288 // all three controls are not checked -> ambiguous state
293 // functions with only one parameter
294 bool bOneParameterCategory
=
295 bIsErrorMargin
|| m_pRbPercent
->IsChecked();
296 if( bOneParameterCategory
)
298 m_pCbSyncPosNeg
->Check();
301 if( m_pCbSyncPosNeg
->IsChecked())
307 // all functions except error margin take no arguments
308 if( m_pRbFunction
->IsChecked() && ( m_pLbFunction
->GetSelectedEntryPos() != CHART_LB_FUNCTION_ERROR_MARGIN
))
314 // enable/disable pos/neg fields
315 m_pBxPositive
->Enable( bPosEnabled
);
316 m_pBxNegative
->Enable( bNegEnabled
);
319 m_pEdRangePositive
->Enable( bPosEnabled
);
320 m_pIbRangePositive
->Enable( bPosEnabled
);
321 m_pEdRangeNegative
->Enable( bNegEnabled
);
322 m_pIbRangeNegative
->Enable( bNegEnabled
);
326 m_pMfPositive
->Enable( bPosEnabled
);
327 m_pMfNegative
->Enable( bNegEnabled
);
330 m_pCbSyncPosNeg
->Enable( !bOneParameterCategory
&& ( bPosEnabled
|| bNegEnabled
));
332 // mark invalid entries in the range fields
333 if( bShowRange
&& ! m_bHasInternalDataProvider
)
335 isRangeFieldContentValid( *m_pEdRangePositive
);
336 isRangeFieldContentValid( *m_pEdRangeNegative
);
340 IMPL_LINK_NOARG( ErrorBarResources
, CategoryChosen2
, ListBox
&, void )
342 CategoryChosen(nullptr);
345 IMPL_LINK_NOARG( ErrorBarResources
, CategoryChosen
, Button
*, void )
347 m_bErrorKindUnique
= true;
348 SvxChartKindError eOldError
= m_eErrorKind
;
350 if( m_pRbNone
->IsChecked())
351 m_eErrorKind
= SvxChartKindError::NONE
;
352 else if( m_pRbConst
->IsChecked())
353 m_eErrorKind
= SvxChartKindError::Const
;
354 else if( m_pRbPercent
->IsChecked())
355 m_eErrorKind
= SvxChartKindError::Percent
;
356 else if( m_pRbRange
->IsChecked())
357 m_eErrorKind
= SvxChartKindError::Range
;
358 else if( m_pRbFunction
->IsChecked())
360 if( m_pLbFunction
->GetSelectedEntryCount() == 1 )
362 switch( m_pLbFunction
->GetSelectedEntryPos())
364 case CHART_LB_FUNCTION_STD_ERROR
:
365 m_eErrorKind
= SvxChartKindError::StdError
; break;
366 case CHART_LB_FUNCTION_STD_DEV
:
367 m_eErrorKind
= SvxChartKindError::Sigma
; break;
368 case CHART_LB_FUNCTION_VARIANCE
:
369 m_eErrorKind
= SvxChartKindError::Variant
; break;
370 case CHART_LB_FUNCTION_ERROR_MARGIN
:
371 m_eErrorKind
= SvxChartKindError::BigError
; break;
373 m_bErrorKindUnique
= false;
377 m_bErrorKindUnique
= false;
381 OSL_FAIL( "Unknown category chosen" );
382 m_bErrorKindUnique
= false;
386 if( m_eErrorKind
== SvxChartKindError::Range
&&
387 eOldError
!= SvxChartKindError::Range
)
389 m_pCbSyncPosNeg
->Check(
390 (!m_pEdRangePositive
->GetText().isEmpty()) &&
391 m_pEdRangePositive
->GetText() == m_pEdRangeNegative
->GetText());
393 // changed from range
394 else if( m_eErrorKind
!= SvxChartKindError::Range
&&
395 eOldError
== SvxChartKindError::Range
)
397 m_pCbSyncPosNeg
->Check( m_pMfPositive
->GetValue() == m_pMfNegative
->GetValue());
400 UpdateControlStates();
403 IMPL_LINK_NOARG(ErrorBarResources
, SynchronizePosAndNeg
, CheckBox
&, void)
405 UpdateControlStates();
406 PosValueChanged( *m_pMfPositive
);
409 IMPL_LINK_NOARG(ErrorBarResources
, PosValueChanged
, Edit
&, void)
411 if( m_pCbSyncPosNeg
->IsChecked())
413 if( m_pRbRange
->IsChecked())
415 m_pEdRangeNegative
->SetText( m_pEdRangePositive
->GetText());
416 m_bRangeNegUnique
= m_bRangePosUnique
;
419 m_pMfNegative
->SetValue( m_pMfPositive
->GetValue());
423 IMPL_LINK_NOARG(ErrorBarResources
, IndicatorChanged
, Button
*, void)
425 m_bIndicatorUnique
= true;
426 if( m_pRbBoth
->IsChecked())
427 m_eIndicate
= SvxChartIndicate::Both
;
428 else if( m_pRbPositive
->IsChecked())
429 m_eIndicate
= SvxChartIndicate::Up
;
430 else if( m_pRbNegative
->IsChecked())
431 m_eIndicate
= SvxChartIndicate::Down
;
433 m_bIndicatorUnique
= false;
435 UpdateControlStates();
438 IMPL_LINK( ErrorBarResources
, ChooseRange
, Button
*, pButton
, void )
440 OSL_ASSERT( m_apRangeSelectionHelper
.get());
441 if( ! m_apRangeSelectionHelper
.get())
443 OSL_ASSERT( m_pCurrentRangeChoosingField
== nullptr );
447 if( pButton
== m_pIbRangePositive
)
449 m_pCurrentRangeChoosingField
= m_pEdRangePositive
;
450 aUIString
= m_pUIStringPos
->GetText();
454 m_pCurrentRangeChoosingField
= m_pEdRangeNegative
;
455 aUIString
= m_pUIStringNeg
->GetText();
458 assert( m_pParentDialog
);
459 if( m_pParentDialog
)
461 lcl_enableRangeChoosing( true, m_pParentDialog
);
462 m_apRangeSelectionHelper
->chooseRange(
463 m_pCurrentRangeChoosingField
->GetText(),
467 m_pCurrentRangeChoosingField
= nullptr;
470 IMPL_LINK( ErrorBarResources
, RangeChanged
, Edit
&, rEdit
, void )
472 if( &rEdit
== m_pEdRangePositive
)
474 m_bRangePosUnique
= true;
475 PosValueChanged( *m_pMfPositive
);
479 m_bRangeNegUnique
= true;
482 isRangeFieldContentValid( rEdit
);
485 void ErrorBarResources::Reset(const SfxItemSet
& rInAttrs
)
487 const SfxPoolItem
*pPoolItem
= nullptr;
490 m_eErrorKind
= SvxChartKindError::NONE
;
491 SfxItemState aState
= rInAttrs
.GetItemState( SCHATTR_STAT_KIND_ERROR
, true, &pPoolItem
);
492 m_bErrorKindUnique
= ( aState
!= SfxItemState::DONTCARE
);
494 if( aState
== SfxItemState::SET
)
495 m_eErrorKind
= static_cast<const SvxChartKindErrorItem
*>(pPoolItem
)->GetValue();
497 m_pLbFunction
->SelectEntryPos( lcl_getLbEntryPosByErrorKind( m_eErrorKind
));
499 if( m_bErrorKindUnique
)
501 switch( m_eErrorKind
)
503 case SvxChartKindError::NONE
:
506 case SvxChartKindError::Percent
:
507 m_pRbPercent
->Check();
509 case SvxChartKindError::Const
:
512 case SvxChartKindError::StdError
:
513 case SvxChartKindError::Variant
:
514 case SvxChartKindError::Sigma
:
515 case SvxChartKindError::BigError
:
516 m_pRbFunction
->Check();
518 case SvxChartKindError::Range
:
525 m_pRbNone
->Check( false );
526 m_pRbConst
->Check( false );
527 m_pRbPercent
->Check( false );
528 m_pRbFunction
->Check( false );
532 aState
= rInAttrs
.GetItemState( SCHATTR_STAT_CONSTPLUS
, true, &pPoolItem
);
533 if( aState
== SfxItemState::SET
)
535 m_fPlusValue
= static_cast<const SvxDoubleItem
*>(pPoolItem
)->GetValue();
538 aState
= rInAttrs
.GetItemState( SCHATTR_STAT_CONSTMINUS
, true, &pPoolItem
);
539 if( aState
== SfxItemState::SET
)
541 m_fMinusValue
= static_cast<const SvxDoubleItem
*>(pPoolItem
)->GetValue();
543 if( m_eErrorKind
!= SvxChartKindError::Range
&&
544 m_fPlusValue
== m_fMinusValue
)
545 m_pCbSyncPosNeg
->Check();
549 aState
= rInAttrs
.GetItemState( SCHATTR_STAT_INDICATE
, true, &pPoolItem
);
550 m_bIndicatorUnique
= ( aState
!= SfxItemState::DONTCARE
);
551 if( aState
== SfxItemState::SET
)
552 m_eIndicate
= static_cast<const SvxChartIndicateItem
*>(pPoolItem
)->GetValue();
554 if( m_bIndicatorUnique
)
556 switch( m_eIndicate
)
558 case SvxChartIndicate::NONE
:
559 // no longer used, use both as default
560 m_eIndicate
= SvxChartIndicate::Both
;
561 SAL_FALLTHROUGH
; // to BOTH
562 case SvxChartIndicate::Both
:
563 m_pRbBoth
->Check(); break;
564 case SvxChartIndicate::Up
:
565 m_pRbPositive
->Check(); break;
566 case SvxChartIndicate::Down
:
567 m_pRbNegative
->Check(); break;
572 m_pRbBoth
->Check( false );
573 m_pRbPositive
->Check( false );
574 m_pRbNegative
->Check( false );
578 aState
= rInAttrs
.GetItemState( SCHATTR_STAT_RANGE_POS
, true, &pPoolItem
);
579 m_bRangePosUnique
= ( aState
!= SfxItemState::DONTCARE
);
580 if( aState
== SfxItemState::SET
)
582 OUString sRangePositive
= static_cast< const SfxStringItem
* >( pPoolItem
)->GetValue();
583 m_pEdRangePositive
->SetText( sRangePositive
);
586 aState
= rInAttrs
.GetItemState( SCHATTR_STAT_RANGE_NEG
, true, &pPoolItem
);
587 m_bRangeNegUnique
= ( aState
!= SfxItemState::DONTCARE
);
588 if( aState
== SfxItemState::SET
)
590 OUString sRangeNegative
= static_cast< const SfxStringItem
* >( pPoolItem
)->GetValue();
591 m_pEdRangeNegative
->SetText( sRangeNegative
);
592 if( m_eErrorKind
== SvxChartKindError::Range
&&
593 !sRangeNegative
.isEmpty() &&
594 sRangeNegative
== m_pEdRangePositive
->GetText() )
595 m_pCbSyncPosNeg
->Check();
598 UpdateControlStates();
601 bool ErrorBarResources::FillItemSet(SfxItemSet
& rOutAttrs
) const
603 if( m_bErrorKindUnique
)
604 rOutAttrs
.Put( SvxChartKindErrorItem( m_eErrorKind
, SCHATTR_STAT_KIND_ERROR
));
605 if( m_bIndicatorUnique
)
606 rOutAttrs
.Put( SvxChartIndicateItem( m_eIndicate
, SCHATTR_STAT_INDICATE
));
608 if( m_bErrorKindUnique
)
610 if( m_eErrorKind
== SvxChartKindError::Range
)
614 if( m_bHasInternalDataProvider
)
616 // the strings aPosRange/aNegRange have to be set to a non-empty
617 // arbitrary string to generate error-bar sequences
619 aNegRange
= aPosRange
;
623 aPosRange
= m_pEdRangePositive
->GetText();
624 if( m_pCbSyncPosNeg
->IsChecked())
625 aNegRange
= aPosRange
;
627 aNegRange
= m_pEdRangeNegative
->GetText();
630 if( m_bRangePosUnique
)
631 rOutAttrs
.Put( SfxStringItem( SCHATTR_STAT_RANGE_POS
, aPosRange
));
632 if( m_bRangeNegUnique
)
633 rOutAttrs
.Put( SfxStringItem( SCHATTR_STAT_RANGE_NEG
, aNegRange
));
635 else if( m_eErrorKind
== SvxChartKindError::Const
||
636 m_eErrorKind
== SvxChartKindError::Percent
||
637 m_eErrorKind
== SvxChartKindError::BigError
)
639 double fPosValue
= static_cast< double >( m_pMfPositive
->GetValue()) /
640 pow( 10.0, m_pMfPositive
->GetDecimalDigits());
641 double fNegValue
= 0.0;
643 if( m_pCbSyncPosNeg
->IsChecked())
644 fNegValue
= fPosValue
;
646 fNegValue
= static_cast< double >( m_pMfNegative
->GetValue()) /
647 pow( 10.0, m_pMfNegative
->GetDecimalDigits());
649 rOutAttrs
.Put( SvxDoubleItem( fPosValue
, SCHATTR_STAT_CONSTPLUS
));
650 rOutAttrs
.Put( SvxDoubleItem( fNegValue
, SCHATTR_STAT_CONSTMINUS
));
654 rOutAttrs
.Put( SfxBoolItem( SCHATTR_STAT_ERRORBAR_TYPE
, m_eErrorBarType
== ERROR_BAR_Y
));
659 void ErrorBarResources::FillValueSets()
661 if( m_eErrorBarType
== ERROR_BAR_Y
)
663 m_pFiNegative
->SetImage(Image(BitmapEx(BMP_INDICATE_DOWN
)));
664 m_pFiPositive
->SetImage(Image(BitmapEx(BMP_INDICATE_UP
)));
665 m_pFiBoth
->SetImage(Image(BitmapEx(BMP_INDICATE_BOTH_VERTI
)));
667 else if( m_eErrorBarType
== ERROR_BAR_X
)
669 m_pFiNegative
->SetImage(Image(BitmapEx(BMP_INDICATE_LEFT
)));
670 m_pFiPositive
->SetImage(Image(BitmapEx(BMP_INDICATE_RIGHT
)));
671 m_pFiBoth
->SetImage(Image(BitmapEx(BMP_INDICATE_BOTH_HORI
)));
675 void ErrorBarResources::listeningFinished(
676 const OUString
& rNewRange
)
678 OSL_ASSERT( m_apRangeSelectionHelper
.get());
679 if( ! m_apRangeSelectionHelper
.get())
682 // rNewRange becomes invalid after removing the listener
683 OUString
aRange( rNewRange
);
686 m_apRangeSelectionHelper
->stopRangeListening();
689 // if( m_pParentWindow )
691 // m_pParentWindow->ToTop();
692 // m_pParentWindow->GrabFocus();
695 if( m_pCurrentRangeChoosingField
)
697 m_pCurrentRangeChoosingField
->SetText( aRange
);
698 m_pCurrentRangeChoosingField
->GrabFocus();
699 PosValueChanged( *m_pMfPositive
);
702 m_pCurrentRangeChoosingField
= nullptr;
704 UpdateControlStates();
705 OSL_ASSERT( m_pParentDialog
);
706 if( m_pParentDialog
)
707 lcl_enableRangeChoosing( false, m_pParentDialog
);
710 void ErrorBarResources::disposingRangeSelection()
712 OSL_ASSERT( m_apRangeSelectionHelper
.get());
713 if( m_apRangeSelectionHelper
.get())
714 m_apRangeSelectionHelper
->stopRangeListening( false );
717 void ErrorBarResources::isRangeFieldContentValid( Edit
& rEdit
)
719 OUString
aRange( rEdit
.GetText());
720 bool bIsValid
= ( aRange
.isEmpty() ) ||
721 ( m_apRangeSelectionHelper
.get() &&
722 m_apRangeSelectionHelper
->verifyCellRange( aRange
));
724 if( bIsValid
|| !rEdit
.IsEnabled())
726 rEdit
.SetControlForeground();
727 rEdit
.SetControlBackground();
731 rEdit
.SetControlBackground( RANGE_SELECTION_INVALID_RANGE_BACKGROUND_COLOR
);
732 rEdit
.SetControlForeground( RANGE_SELECTION_INVALID_RANGE_FOREGROUND_COLOR
);
738 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */