From 1ef7640148d35646f465d0d7026529b588cb4bcf Mon Sep 17 00:00:00 2001 From: Laurent Balland-Poirier Date: Mon, 2 Dec 2013 09:54:21 +0100 Subject: fdo#40314 Free value of intercept for trend line MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Intercept value field has been changed to FormattedField to support scientific notation and more than 4 digits after decimal point Change-Id: Idb2d27862ddabcdc96a036d93f1f3498cc6327df Reviewed-on: https://gerrit.libreoffice.org/6904 Reviewed-by: Tomaž Vajngerl Tested-by: Tomaž Vajngerl --- .../controller/dialogs/dlg_ObjectProperties.cxx | 9 +++++ chart2/source/controller/dialogs/res_Trendline.cxx | 43 ++++++++++++++-------- chart2/source/controller/dialogs/res_Trendline.hxx | 13 +++++-- chart2/source/controller/dialogs/tp_Trendline.cxx | 5 +++ chart2/source/controller/dialogs/tp_Trendline.hxx | 1 + chart2/uiconfig/ui/tp_Trendline.ui | 38 ++++++++----------- 6 files changed, 68 insertions(+), 41 deletions(-) diff --git a/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx b/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx index 05b554406b74..6e1974b1d56e 100644 --- a/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx +++ b/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx @@ -634,6 +634,15 @@ void SchAttribTabDlg::PageCreated(sal_uInt16 nId, SfxTabPage &rPage) m_pParameter->ProvidesBarConnectors() ); break; } + case TP_TRENDLINE: + { + TrendlineTabPage* pTrendlineTabPage = dynamic_cast< TrendlineTabPage* >( &rPage ); + if(pTrendlineTabPage) + { + pTrendlineTabPage->SetNumFormatter( m_pNumberFormatter ); + } + break; + } } } diff --git a/chart2/source/controller/dialogs/res_Trendline.cxx b/chart2/source/controller/dialogs/res_Trendline.cxx index 76be2972618e..e1b6a070ce29 100644 --- a/chart2/source/controller/dialogs/res_Trendline.cxx +++ b/chart2/source/controller/dialogs/res_Trendline.cxx @@ -33,9 +33,16 @@ namespace chart { +void lcl_setValue( FormattedField& rFmtField, double fValue ) +{ + rFmtField.SetValue( fValue ); + rFmtField.SetDefaultValue( fValue ); +} + TrendlineResources::TrendlineResources( Window * pParent, const SfxItemSet& rInAttrs ) : m_eTrendLineType( CHREGRESS_LINEAR ), - m_bTrendLineUnique( true ) + m_bTrendLineUnique( true ), + m_pNumFormatter(NULL) { SfxTabPage* pTabPage = reinterpret_cast(pParent); pTabPage->get(m_pRB_Linear,"linear"); @@ -50,7 +57,7 @@ TrendlineResources::TrendlineResources( Window * pParent, const SfxItemSet& rInA pTabPage->get(m_pNF_ExtrapolateForward,"extrapolateForward"); pTabPage->get(m_pNF_ExtrapolateBackward,"extrapolateBackward"); pTabPage->get(m_pCB_SetIntercept,"setIntercept"); - pTabPage->get(m_pNF_InterceptValue,"interceptValue"); + pTabPage->get(m_pFmtFld_InterceptValue,"interceptValue"); pTabPage->get(m_pCB_ShowEquation,"showEquation"); pTabPage->get(m_pCB_ShowCorrelationCoeff,"showCorrelationCoefficient"); pTabPage->get(m_pFI_Linear,"imageLinear"); @@ -69,17 +76,15 @@ TrendlineResources::TrendlineResources( Window * pParent, const SfxItemSet& rInA m_pRB_Polynomial->SetClickHdl( aLink ); m_pRB_MovingAverage->SetClickHdl( aLink ); - aLink = LINK(this, TrendlineResources, ChangeNumericField ); + aLink = LINK(this, TrendlineResources, ChangeValue ); m_pNF_Degree->SetModifyHdl( aLink ); m_pNF_Period->SetModifyHdl( aLink ); - m_pNF_InterceptValue->SetModifyHdl( aLink ); + m_pFmtFld_InterceptValue->SetModifyHdl( aLink ); m_pNF_ExtrapolateForward->SetMin( SAL_MIN_INT64 ); m_pNF_ExtrapolateForward->SetMax( SAL_MAX_INT64 ); m_pNF_ExtrapolateBackward->SetMin( SAL_MIN_INT64 ); m_pNF_ExtrapolateBackward->SetMax( SAL_MAX_INT64 ); - m_pNF_InterceptValue->SetMin( SAL_MIN_INT64 ); - m_pNF_InterceptValue->SetMax( SAL_MAX_INT64 ); Reset( rInAttrs ); UpdateControlStates(); @@ -174,15 +179,12 @@ void TrendlineResources::Reset( const SfxItemSet& rInAttrs ) m_pNF_ExtrapolateBackward->SetValue( 0 ); } + double nValue = 0.0;; if( rInAttrs.GetItemState( SCHATTR_REGRESSION_INTERCEPT_VALUE, sal_True, &pPoolItem ) == SFX_ITEM_SET ) { - double nValue = static_cast< const SvxDoubleItem * >( pPoolItem )->GetValue() * 10000; - m_pNF_InterceptValue->SetValue( (sal_Int64) nValue ); - } - else - { - m_pNF_InterceptValue->SetValue( 0 ); + nValue = ((const SvxDoubleItem*)pPoolItem)->GetValue() ; } + lcl_setValue( *m_pFmtFld_InterceptValue, nValue ); aState = rInAttrs.GetItemState( SCHATTR_REGRESSION_SET_INTERCEPT, sal_True, &pPoolItem ); if( aState == SFX_ITEM_DONTCARE ) @@ -280,7 +282,9 @@ sal_Bool TrendlineResources::FillItemSet(SfxItemSet& rOutAttrs) const if( m_pCB_SetIntercept->GetState() != STATE_DONTKNOW ) rOutAttrs.Put( SfxBoolItem( SCHATTR_REGRESSION_SET_INTERCEPT, m_pCB_SetIntercept->IsChecked() )); - double aInterceptValue = m_pNF_InterceptValue->GetValue() / 10000.0; + double aInterceptValue = 0.0; + sal_uInt32 nIndex = 0; + m_pNumFormatter->IsNumberFormat(m_pFmtFld_InterceptValue->GetText(),nIndex,aInterceptValue); rOutAttrs.Put(SvxDoubleItem( aInterceptValue, SCHATTR_REGRESSION_INTERCEPT_VALUE ) ); return sal_True; @@ -302,7 +306,7 @@ void TrendlineResources::UpdateControlStates() m_pNF_ExtrapolateForward->Enable(!bMovingAverage); m_pNF_ExtrapolateBackward->Enable(!bMovingAverage); m_pCB_SetIntercept->Enable(!bMovingAverage); - m_pNF_InterceptValue->Enable(!bMovingAverage); + m_pFmtFld_InterceptValue->Enable(!bMovingAverage); if(bMovingAverage) { m_pCB_ShowEquation->SetState( STATE_NOCHECK ); @@ -312,7 +316,7 @@ void TrendlineResources::UpdateControlStates() m_pCB_ShowCorrelationCoeff->Enable(!bMovingAverage); } -IMPL_LINK( TrendlineResources, ChangeNumericField, NumericField *, pNumericField) +IMPL_LINK( TrendlineResources, ChangeValue, void *, pNumericField) { if( pNumericField == m_pNF_Degree ) { @@ -330,7 +334,7 @@ IMPL_LINK( TrendlineResources, ChangeNumericField, NumericField *, pNumericField SelectTrendLine(m_pRB_MovingAverage); } } - else if( pNumericField == m_pNF_InterceptValue ) + else if( pNumericField == m_pFmtFld_InterceptValue ) { if( !m_pCB_SetIntercept->IsChecked() ) m_pCB_SetIntercept->Check(); @@ -340,6 +344,13 @@ IMPL_LINK( TrendlineResources, ChangeNumericField, NumericField *, pNumericField return 0; } +void TrendlineResources::SetNumFormatter( SvNumberFormatter* pFormatter ) +{ + m_pNumFormatter = pFormatter; + m_pFmtFld_InterceptValue->SetFormatter( m_pNumFormatter ); +} + + } // namespace chart /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/controller/dialogs/res_Trendline.hxx b/chart2/source/controller/dialogs/res_Trendline.hxx index 8dd2e2e37a32..37f25b9771f2 100644 --- a/chart2/source/controller/dialogs/res_Trendline.hxx +++ b/chart2/source/controller/dialogs/res_Trendline.hxx @@ -25,7 +25,10 @@ #include #include #include - +// header for class SvNumberformat +#include +// header for class FormattedField +#include namespace chart { @@ -40,6 +43,8 @@ public: void FillValueSets(); + void SetNumFormatter( SvNumberFormatter* pFormatter ); + private: RadioButton* m_pRB_Linear; RadioButton* m_pRB_Logarithmic; @@ -61,7 +66,7 @@ private: NumericField* m_pNF_ExtrapolateForward; NumericField* m_pNF_ExtrapolateBackward; CheckBox* m_pCB_SetIntercept; - NumericField* m_pNF_InterceptValue; + FormattedField* m_pFmtFld_InterceptValue; CheckBox* m_pCB_ShowEquation; CheckBox* m_pCB_ShowCorrelationCoeff; @@ -69,9 +74,11 @@ private: bool m_bTrendLineUnique; + SvNumberFormatter* m_pNumFormatter; + void UpdateControlStates(); DECL_LINK( SelectTrendLine, RadioButton * ); - DECL_LINK( ChangeNumericField, NumericField *); + DECL_LINK( ChangeValue, void *); }; } // namespace chart diff --git a/chart2/source/controller/dialogs/tp_Trendline.cxx b/chart2/source/controller/dialogs/tp_Trendline.cxx index 959f7eb24ede..cbe03b0fba96 100644 --- a/chart2/source/controller/dialogs/tp_Trendline.cxx +++ b/chart2/source/controller/dialogs/tp_Trendline.cxx @@ -58,6 +58,11 @@ void TrendlineTabPage::DataChanged( const DataChangedEvent& rDCEvt ) m_aTrendlineResources.FillValueSets(); } +void TrendlineTabPage::SetNumFormatter( SvNumberFormatter* pNumFormatter ) +{ + m_aTrendlineResources.SetNumFormatter( pNumFormatter ); +} + } //namespace chart /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/controller/dialogs/tp_Trendline.hxx b/chart2/source/controller/dialogs/tp_Trendline.hxx index 7c1ddf8f8b88..4e5114e87949 100644 --- a/chart2/source/controller/dialogs/tp_Trendline.hxx +++ b/chart2/source/controller/dialogs/tp_Trendline.hxx @@ -37,6 +37,7 @@ public: virtual void Reset( const SfxItemSet& rInAttrs ); virtual void DataChanged( const DataChangedEvent& rDCEvt ); + void SetNumFormatter( SvNumberFormatter* pFormatter ); private: TrendlineResources m_aTrendlineResources; diff --git a/chart2/uiconfig/ui/tp_Trendline.ui b/chart2/uiconfig/ui/tp_Trendline.ui index d0951457465b..b5a0fadf48f7 100644 --- a/chart2/uiconfig/ui/tp_Trendline.ui +++ b/chart2/uiconfig/ui/tp_Trendline.ui @@ -430,25 +430,6 @@ 1 - - - True - True - - True - adjustmentForwardBacward - 4 - - - - - - 1 - 3 - 1 - 1 - - Force _Intercept @@ -458,9 +439,6 @@ True 0 True - - - 0 @@ -532,6 +510,22 @@ 1 + + + True + True + + 0 + False + number + + + 1 + 3 + 1 + 1 + + -- cgit v1.2.3