diff options
author | Laurent Balland-Poirier <laurent.balland-poirier@laposte.net> | 2013-12-02 09:54:21 +0100 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2013-12-08 11:26:53 +0100 |
commit | b9edc19c2a858b0b164aff746568c690558f9d99 (patch) | |
tree | 12d95bfb8e98d75392d146ba62bf5d3ec237b895 | |
parent | f44099ee12b3caf3dbf977132b266f8230597141 (diff) |
fdo#40314 Free value of intercept for trend line
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 <quikee@gmail.com>
Tested-by: Tomaž Vajngerl <quikee@gmail.com>
-rw-r--r-- | chart2/source/controller/dialogs/dlg_ObjectProperties.cxx | 9 | ||||
-rw-r--r-- | chart2/source/controller/dialogs/res_Trendline.cxx | 43 | ||||
-rw-r--r-- | chart2/source/controller/dialogs/res_Trendline.hxx | 13 | ||||
-rw-r--r-- | chart2/source/controller/dialogs/tp_Trendline.cxx | 5 | ||||
-rw-r--r-- | chart2/source/controller/dialogs/tp_Trendline.hxx | 1 | ||||
-rw-r--r-- | 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<SfxTabPage*>(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 <svl/itemset.hxx> #include <svx/chrtitem.hxx> #include <vcl/field.hxx> - +// header for class SvNumberformat +#include <svl/zformat.hxx> +// header for class FormattedField +#include <svtools/fmtfield.hxx> 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 @@ -431,25 +431,6 @@ </packing> </child> <child> - <object class="GtkSpinButton" id="interceptValue"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="invisible_char">●</property> - <property name="invisible_char_set">True</property> - <property name="adjustment">adjustmentForwardBacward</property> - <property name="digits">4</property> - <accessibility> - <relation type="labelled-by" target="setIntercept"/> - </accessibility> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">3</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - <child> <object class="GtkCheckButton" id="setIntercept"> <property name="label" translatable="yes">Force _Intercept</property> <property name="visible">True</property> @@ -458,9 +439,6 @@ <property name="use_underline">True</property> <property name="xalign">0</property> <property name="draw_indicator">True</property> - <accessibility> - <relation type="label-for" target="interceptValue"/> - </accessibility> </object> <packing> <property name="left_attach">0</property> @@ -532,6 +510,22 @@ <property name="height">1</property> </packing> </child> + <child> + <object class="svtlo-FormattedField" id="interceptValue"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="invisible_char">●</property> + <property name="text" translatable="yes">0</property> + <property name="caps_lock_warning">False</property> + <property name="input_purpose">number</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">3</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> </object> </child> </object> |