diff options
Diffstat (limited to 'chart2/source/controller')
10 files changed, 610 insertions, 43 deletions
diff --git a/chart2/source/controller/chartapiwrapper/WrappedStatisticProperties.cxx b/chart2/source/controller/chartapiwrapper/WrappedStatisticProperties.cxx index 23e7de1fbb19..cbb208b70576 100644 --- a/chart2/source/controller/chartapiwrapper/WrappedStatisticProperties.cxx +++ b/chart2/source/controller/chartapiwrapper/WrappedStatisticProperties.cxx @@ -76,6 +76,12 @@ Any lcl_getRegressionDefault() case RegressionCurveHelper::REGRESSION_TYPE_POWER: eRet = ::com::sun::star::chart::ChartRegressionCurveType_POWER; break; + case RegressionCurveHelper::REGRESSION_TYPE_POLYNOMIAL: + eRet = ::com::sun::star::chart::ChartRegressionCurveType_POLYNOMIAL; + break; + /*case RegressionCurveHelper::REGRESSION_TYPE_MOVING_AVERAGE: + eRet = ::com::sun::star::chart::ChartRegressionCurveType_MOVING_AVERAGE; + break;*/ default: eRet = ::com::sun::star::chart::ChartRegressionCurveType_NONE; break; @@ -100,6 +106,7 @@ RegressionCurveHelper::tRegressionType lcl_getRegressionType( ::com::sun::star:: eRet = RegressionCurveHelper::REGRESSION_TYPE_EXP; break; case ::com::sun::star::chart::ChartRegressionCurveType_POLYNOMIAL: + //case ::com::sun::star::chart::ChartRegressionCurveType_MOVING_AVERAGE: case ::com::sun::star::chart::ChartRegressionCurveType_POWER: eRet = RegressionCurveHelper::REGRESSION_TYPE_POWER; break; diff --git a/chart2/source/controller/dialogs/Bitmaps.hrc b/chart2/source/controller/dialogs/Bitmaps.hrc index ced4537dd396..bcf1f37b8b6c 100644 --- a/chart2/source/controller/dialogs/Bitmaps.hrc +++ b/chart2/source/controller/dialogs/Bitmaps.hrc @@ -210,11 +210,13 @@ #define BMP_INDICATE_LEFT (RID_APP_START + 99) //SchStatisticTabPage and SchDataStatisticsDlg part 2 -#define BMP_REGRESSION_NONE (RID_APP_START + 92) -#define BMP_REGRESSION_LINEAR (RID_APP_START + 93) -#define BMP_REGRESSION_LOG (RID_APP_START + 94) -#define BMP_REGRESSION_EXP (RID_APP_START + 95) -#define BMP_REGRESSION_POWER (RID_APP_START + 96) +#define BMP_REGRESSION_NONE (RID_APP_START + 92) +#define BMP_REGRESSION_LINEAR (RID_APP_START + 93) +#define BMP_REGRESSION_LOG (RID_APP_START + 94) +#define BMP_REGRESSION_EXP (RID_APP_START + 95) +#define BMP_REGRESSION_POWER (RID_APP_START + 96) +#define BMP_REGRESSION_POLYNOMIAL (RID_APP_START + 110) +#define BMP_REGRESSION_MOVING_AVERAGE (RID_APP_START + 111) // hide-button for range-choosing #define IMG_SELECTRANGE (RID_APP_START + 100) diff --git a/chart2/source/controller/dialogs/Bitmaps.src b/chart2/source/controller/dialogs/Bitmaps.src index e566ec4f3540..9ee63814eea4 100644 --- a/chart2/source/controller/dialogs/Bitmaps.src +++ b/chart2/source/controller/dialogs/Bitmaps.src @@ -581,6 +581,20 @@ Image BMP_REGRESSION_POWER File = "regpow.png" ; }; }; +Image BMP_REGRESSION_POLYNOMIAL +{ + ImageBitmap = Bitmap + { + File = "regpoly.png" ; + }; +}; +Image BMP_REGRESSION_MOVING_AVERAGE +{ + ImageBitmap = Bitmap + { + File = "regavg.png" ; + }; +}; //--------------------- Image IMG_SELECTRANGE { diff --git a/chart2/source/controller/dialogs/res_Trendline.cxx b/chart2/source/controller/dialogs/res_Trendline.cxx index e74a84a7e800..803c0606fe19 100644 --- a/chart2/source/controller/dialogs/res_Trendline.cxx +++ b/chart2/source/controller/dialogs/res_Trendline.cxx @@ -26,32 +26,33 @@ #include "Bitmaps.hrc" #include "chartview/ChartSfxItemIds.hxx" +#include <svl/intitem.hxx> + #include <vector> #include <algorithm> namespace { -template< class T > - long lcl_getRightEdge( T & rControl ) -{ - return rControl.CalcMinimumSize().Width() + rControl.GetPosPixel().X() - rControl.GetParent()->GetPosPixel().X(); -} -template< class T > - void lcl_AdjustControlSize( T & rControl ) -{ - Size aSize( rControl.GetSizePixel()); - aSize.setWidth( rControl.CalcMinimumSize().Width()); - rControl.SetSizePixel( aSize ); -} + template< class T > long lcl_getRightEdge( T & rControl ) + { + return rControl.CalcMinimumSize().Width() + rControl.GetPosPixel().X() - rControl.GetParent()->GetPosPixel().X(); + } -void lcl_AdjustControlSize( Control & rControl, long nRightEdge ) -{ - Size aSize( rControl.GetSizePixel()); - Point aPosition( rControl.GetPosPixel()); - aSize.setWidth( nRightEdge - aPosition.getX()); - rControl.SetSizePixel( aSize ); -} + template< class T > void lcl_AdjustControlSize( T & rControl ) + { + Size aSize( rControl.GetSizePixel()); + aSize.setWidth( rControl.CalcMinimumSize().Width()); + rControl.SetSizePixel( aSize ); + } + + void lcl_AdjustControlSize( Control & rControl, long nRightEdge ) + { + Size aSize( rControl.GetSizePixel()); + Point aPosition( rControl.GetPosPixel()); + aSize.setWidth( nRightEdge - aPosition.getX()); + rControl.SetSizePixel( aSize ); + } } // anonymous namespace @@ -61,17 +62,29 @@ namespace chart TrendlineResources::TrendlineResources( Window * pParent, const SfxItemSet& rInAttrs, bool bNoneAvailable ) : m_aFLType( pParent, SchResId( FL_TYPE )), - m_aRBNone( pParent, SchResId( RB_NONE )), - m_aRBLinear( pParent, SchResId( RB_LINEAR )), - m_aRBLogarithmic( pParent, SchResId( RB_LOGARITHMIC )), - m_aRBExponential( pParent, SchResId( RB_EXPONENTIAL )), - m_aRBPower( pParent, SchResId( RB_POWER )), - - m_aFINone( pParent, SchResId( FI_NONE )), - m_aFILinear( pParent, SchResId( FI_LINEAR )), - m_aFILogarithmic( pParent, SchResId( FI_LOGARITHMIC )), - m_aFIExponential( pParent, SchResId( FI_EXPONENTIAL )), - m_aFIPower( pParent, SchResId( FI_POWER )), + m_aRBNone( pParent, SchResId( RB_NONE )), + m_aRBLinear( pParent, SchResId( RB_LINEAR )), + m_aRBLogarithmic( pParent, SchResId( RB_LOGARITHMIC )), + m_aRBExponential( pParent, SchResId( RB_EXPONENTIAL )), + m_aRBPower( pParent, SchResId( RB_POWER )), + m_aRBPolynomial( pParent, SchResId( RB_POLYNOMIAL )), + m_aRBMovingAverage( pParent, SchResId( RB_MOVING_AVERAGE )), + + m_aFINone( pParent, SchResId( FI_NONE )), + m_aFILinear( pParent, SchResId( FI_LINEAR )), + m_aFILogarithmic( pParent, SchResId( FI_LOGARITHMIC )), + m_aFIExponential( pParent, SchResId( FI_EXPONENTIAL )), + m_aFIPower( pParent, SchResId( FI_POWER )), + m_aFIPolynomial( pParent, SchResId( FI_POLYNOMIAL )), + m_aFIMovingAverage( pParent, SchResId( FI_MOVING_AVERAGE )), + + m_aNF_Degree( pParent, SchResId( NF_DEGREE )), + m_aNF_Period( pParent, SchResId( NF_PERIOD )), + + m_aNF_ExtrapolateForward( pParent, SchResId( NF_EXTRAPOLATE_FORWARD )), + m_aNF_ExtrapolateBackward( pParent, SchResId( NF_EXTRAPOLATE_BACKWARD )), + m_aCB_SetIntercept( pParent, SchResId( CB_SET_INTERCEPT )), + m_aNF_InterceptValue( pParent, SchResId( NF_INTERCEPT_VALUE )), m_aFLEquation( pParent, SchResId( FL_EQUATION )), m_aCBShowEquation( pParent, SchResId( CB_SHOW_EQUATION )), @@ -92,6 +105,11 @@ TrendlineResources::TrendlineResources( Window * pParent, const SfxItemSet& rInA m_aRBLogarithmic.SetClickHdl( LINK(this, TrendlineResources, SelectTrendLine )); m_aRBExponential.SetClickHdl( LINK(this, TrendlineResources, SelectTrendLine )); m_aRBPower.SetClickHdl( LINK(this, TrendlineResources, SelectTrendLine )); + m_aRBPolynomial.SetClickHdl( LINK(this, TrendlineResources, SelectTrendLine )); + m_aRBMovingAverage.SetClickHdl( LINK(this, TrendlineResources, SelectTrendLine )); + + m_aNF_InterceptValue.SetMin( SAL_MIN_INT64 ); + m_aNF_InterceptValue.SetMax( SAL_MAX_INT64 ); Reset( rInAttrs ); UpdateControlStates(); @@ -109,6 +127,8 @@ long TrendlineResources::adjustControlSizes() aControlRightEdges.push_back( lcl_getRightEdge( m_aRBLogarithmic )); aControlRightEdges.push_back( lcl_getRightEdge( m_aRBExponential )); aControlRightEdges.push_back( lcl_getRightEdge( m_aRBPower )); + aControlRightEdges.push_back( lcl_getRightEdge( m_aRBPolynomial )); + aControlRightEdges.push_back( lcl_getRightEdge( m_aRBMovingAverage )); aControlRightEdges.push_back( lcl_getRightEdge( m_aCBShowEquation )); aControlRightEdges.push_back( lcl_getRightEdge( m_aCBShowCorrelationCoeff )); @@ -117,6 +137,8 @@ long TrendlineResources::adjustControlSizes() lcl_AdjustControlSize( m_aRBLogarithmic ); lcl_AdjustControlSize( m_aRBExponential ); lcl_AdjustControlSize( m_aRBPower ); + lcl_AdjustControlSize( m_aRBPolynomial ); + lcl_AdjustControlSize( m_aRBMovingAverage ); lcl_AdjustControlSize( m_aCBShowEquation ); lcl_AdjustControlSize( m_aCBShowCorrelationCoeff ); @@ -147,6 +169,10 @@ IMPL_LINK( TrendlineResources, SelectTrendLine, RadioButton *, pRadioButton ) m_eTrendLineType = CHREGRESS_EXP; else if( pRadioButton == &m_aRBPower ) m_eTrendLineType = CHREGRESS_POWER; + else if( pRadioButton == &m_aRBPolynomial ) + m_eTrendLineType = CHREGRESS_POLYNOMIAL; + else if( pRadioButton == &m_aRBMovingAverage ) + m_eTrendLineType = CHREGRESS_MOVING_AVERAGE; else if( pRadioButton == &m_aRBNone ) { OSL_ASSERT( m_bNoneAvailable ); @@ -169,7 +195,49 @@ void TrendlineResources::Reset( const SfxItemSet& rInAttrs ) { const SvxChartRegressItem * pItem = dynamic_cast< const SvxChartRegressItem * >( pPoolItem ); if( pItem ) + { m_eTrendLineType = pItem->GetValue(); + } + } + + if( rInAttrs.GetItemState( SCHATTR_REGRESSION_DEGREE, sal_True, &pPoolItem ) == SFX_ITEM_SET ) + { + sal_Int32 nDegree = static_cast< const SfxInt32Item * >( pPoolItem )->GetValue(); + m_aNF_Degree.SetValue( nDegree ); + } + else + { + m_aNF_Period.SetValue( 2 ); + } + + if( rInAttrs.GetItemState( SCHATTR_REGRESSION_PERIOD, sal_True, &pPoolItem ) == SFX_ITEM_SET ) + { + sal_Int32 nPeriod = static_cast< const SfxInt32Item * >( pPoolItem )->GetValue(); + m_aNF_Period.SetValue( nPeriod ); + } + else + { + m_aNF_Period.SetValue( 2 ); + } + + if( rInAttrs.GetItemState( SCHATTR_REGRESSION_EXTRAPOLATE_FORWARD, sal_True, &pPoolItem ) == SFX_ITEM_SET ) + { + double nValue = static_cast< const SvxDoubleItem * >( pPoolItem )->GetValue() * 100; + m_aNF_ExtrapolateForward.SetValue( (sal_Int64) nValue ); + } + else + { + m_aNF_ExtrapolateForward.SetValue( 0 ); + } + + if( rInAttrs.GetItemState( SCHATTR_REGRESSION_EXTRAPOLATE_BACKWARD, sal_True, &pPoolItem ) == SFX_ITEM_SET ) + { + double nValue = static_cast< const SvxDoubleItem * >( pPoolItem )->GetValue() * 100; + m_aNF_ExtrapolateBackward.SetValue( (sal_Int64) nValue ); + } + else + { + m_aNF_ExtrapolateBackward.SetValue( 0 ); } aState = rInAttrs.GetItemState( SCHATTR_REGRESSION_SHOW_EQUATION, sal_True, &pPoolItem ); @@ -214,6 +282,12 @@ void TrendlineResources::Reset( const SfxItemSet& rInAttrs ) case CHREGRESS_POWER : m_aRBPower.Check(); break; + case CHREGRESS_POLYNOMIAL : + m_aRBPolynomial.Check(); + break; + case CHREGRESS_MOVING_AVERAGE : + m_aRBMovingAverage.Check(); + break; case CHREGRESS_NONE: OSL_ASSERT( m_bNoneAvailable ); m_aRBNone.Check(); @@ -230,17 +304,32 @@ sal_Bool TrendlineResources::FillItemSet(SfxItemSet& rOutAttrs) const rOutAttrs.Put( SfxBoolItem( SCHATTR_REGRESSION_SHOW_EQUATION, m_aCBShowEquation.IsChecked() )); if( m_aCBShowCorrelationCoeff.GetState() != STATE_DONTKNOW ) rOutAttrs.Put( SfxBoolItem( SCHATTR_REGRESSION_SHOW_COEFF, m_aCBShowCorrelationCoeff.IsChecked() )); + + sal_Int32 aDegree = m_aNF_Degree.GetValue(); + rOutAttrs.Put(SfxInt32Item( SCHATTR_REGRESSION_DEGREE, aDegree ) ); + + sal_Int32 aPeriod = m_aNF_Period.GetValue(); + rOutAttrs.Put(SfxInt32Item( SCHATTR_REGRESSION_PERIOD, aPeriod ) ); + + double aExtrapolateForwardValue = m_aNF_ExtrapolateForward.GetValue() / 100.0; + rOutAttrs.Put(SvxDoubleItem( aExtrapolateForwardValue, SCHATTR_REGRESSION_EXTRAPOLATE_FORWARD ) ); + + double aExtrapolateBackwardValue = m_aNF_ExtrapolateBackward.GetValue() / 100.0; + rOutAttrs.Put(SvxDoubleItem( aExtrapolateBackwardValue, SCHATTR_REGRESSION_EXTRAPOLATE_BACKWARD ) ); + return sal_True; } void TrendlineResources::FillValueSets() { if( m_bNoneAvailable ) - m_aFINone.SetImage( Image( SchResId( BMP_REGRESSION_NONE ) ) ); - m_aFILinear.SetImage( Image( SchResId( BMP_REGRESSION_LINEAR ) ) ); - m_aFILogarithmic.SetImage( Image( SchResId( BMP_REGRESSION_LOG ) ) ); - m_aFIExponential.SetImage( Image( SchResId( BMP_REGRESSION_EXP ) ) ); - m_aFIPower.SetImage( Image( SchResId( BMP_REGRESSION_POWER ) ) ); + m_aFINone.SetImage( Image( SchResId( BMP_REGRESSION_NONE ) ) ); + m_aFILinear.SetImage( Image( SchResId( BMP_REGRESSION_LINEAR ) ) ); + m_aFILogarithmic.SetImage( Image( SchResId( BMP_REGRESSION_LOG ) ) ); + m_aFIExponential.SetImage( Image( SchResId( BMP_REGRESSION_EXP ) ) ); + m_aFIPower.SetImage( Image( SchResId( BMP_REGRESSION_POWER ) ) ); + m_aFIPolynomial.SetImage( Image( SchResId( BMP_REGRESSION_POLYNOMIAL ) ) ); + m_aFIMovingAverage.SetImage(Image( SchResId( BMP_REGRESSION_MOVING_AVERAGE ) ) ); } void TrendlineResources::UpdateControlStates() diff --git a/chart2/source/controller/dialogs/res_Trendline.hxx b/chart2/source/controller/dialogs/res_Trendline.hxx index 9c2230de6725..bbabc7b82cfa 100644 --- a/chart2/source/controller/dialogs/res_Trendline.hxx +++ b/chart2/source/controller/dialogs/res_Trendline.hxx @@ -24,6 +24,7 @@ #include <vcl/fixed.hxx> #include <svl/itemset.hxx> #include <svx/chrtitem.hxx> +#include <vcl/field.hxx> namespace chart { @@ -48,14 +49,27 @@ private: RadioButton m_aRBLogarithmic; RadioButton m_aRBExponential; RadioButton m_aRBPower; + RadioButton m_aRBPolynomial; + RadioButton m_aRBMovingAverage; FixedImage m_aFINone; FixedImage m_aFILinear; FixedImage m_aFILogarithmic; FixedImage m_aFIExponential; FixedImage m_aFIPower; + FixedImage m_aFIPolynomial; + FixedImage m_aFIMovingAverage; + + NumericField m_aNF_Degree; + NumericField m_aNF_Period; + + NumericField m_aNF_ExtrapolateForward; + NumericField m_aNF_ExtrapolateBackward; + CheckBox m_aCB_SetIntercept; + NumericField m_aNF_InterceptValue; FixedLine m_aFLEquation; + CheckBox m_aCBShowEquation; CheckBox m_aCBShowCorrelationCoeff; diff --git a/chart2/source/controller/dialogs/res_Trendline_IDs.hrc b/chart2/source/controller/dialogs/res_Trendline_IDs.hrc index ca3aae9af87e..aa545690ea64 100644 --- a/chart2/source/controller/dialogs/res_Trendline_IDs.hrc +++ b/chart2/source/controller/dialogs/res_Trendline_IDs.hrc @@ -25,14 +25,25 @@ #define FI_LOGARITHMIC 3 #define FI_EXPONENTIAL 4 #define FI_POWER 5 +#define FI_POLYNOMIAL 6 +#define FI_MOVING_AVERAGE 7 + +#define NF_DEGREE 1 +#define NF_PERIOD 2 +#define NF_EXTRAPOLATE_FORWARD 3 +#define NF_EXTRAPOLATE_BACKWARD 4 +#define NF_INTERCEPT_VALUE 5 #define RB_NONE 1 #define RB_LINEAR 2 #define RB_LOGARITHMIC 3 #define RB_EXPONENTIAL 4 #define RB_POWER 5 +#define RB_POLYNOMIAL 6 +#define RB_MOVING_AVERAGE 7 #define CB_SHOW_EQUATION 1 #define CB_SHOW_CORRELATION_COEFF 2 +#define CB_SET_INTERCEPT 3 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/controller/dialogs/res_Trendline_tmpl.hrc b/chart2/source/controller/dialogs/res_Trendline_tmpl.hrc index ee78cc90f5a1..950726d25c56 100644 --- a/chart2/source/controller/dialogs/res_Trendline_tmpl.hrc +++ b/chart2/source/controller/dialogs/res_Trendline_tmpl.hrc @@ -64,6 +64,18 @@ RadioButton RB_POWER \ Size = MAP_APPFONT( 100, 10 ); \ Text[ en-US ] = "~Power"; \ }; \ +RadioButton RB_POLYNOMIAL \ +{ \ + Pos = MAP_APPFONT( 130, 22 + yoffset ); \ + Size = MAP_APPFONT( 70, 10 ); \ + Text[ en-US ] = "~Polynomial"; \ +}; \ +RadioButton RB_MOVING_AVERAGE \ +{ \ + Pos = MAP_APPFONT( 130, 66 + yoffset ); \ + Size = MAP_APPFONT( 70, 10 ); \ + Text[ en-US ] = "~Moving Average"; \ +}; \ FixedImage FI_NONE \ { \ Pos = MAP_APPFONT( 10, 18 ); \ @@ -89,16 +101,97 @@ FixedImage FI_POWER \ Pos = MAP_APPFONT( 10, 84 + yoffset ); \ Size = MAP_APPFONT( 18, 18 ); \ }; \ +FixedImage FI_POLYNOMIAL \ +{ \ + Pos = MAP_APPFONT( 110, 18 + yoffset ); \ + Size = MAP_APPFONT( 18, 18 ); \ +}; \ +FixedImage FI_MOVING_AVERAGE \ +{ \ + Pos = MAP_APPFONT( 110, 62 + yoffset ); \ + Size = MAP_APPFONT( 18, 18 ); \ +}; \ +NumericField NF_DEGREE \ +{ \ + Border = TRUE ; \ + Pos = MAP_APPFONT ( 110, 44 + yoffset ) ; \ + Size = MAP_APPFONT ( 28 , 12 ) ; \ + TabStop = TRUE ; \ + Repeat = TRUE ; \ + Spin = TRUE ; \ + StrictFormat = TRUE ; \ + SpinSize = 1 ; \ + Minimum = 2 ; \ + Maximum = 100 ; \ +}; \ +NumericField NF_PERIOD \ +{ \ + Border = TRUE ; \ + Pos = MAP_APPFONT ( 110, 88 + yoffset ) ; \ + Size = MAP_APPFONT ( 28 , 12 ) ; \ + TabStop = TRUE ; \ + Repeat = TRUE ; \ + Spin = TRUE ; \ + StrictFormat = TRUE ; \ + SpinSize = 1 ; \ + Minimum = 2 ; \ + Maximum = 100 ; \ +}; \ FixedLine FL_EQUATION \ { \ Pos = MAP_APPFONT( 6, 108 + yoffset ); \ Size = MAP_APPFONT( availablewidth - 12, 8 ); \ - Text[ en-US ] = "Equation"; \ + Text[ en-US ] = "Options"; \ +}; \ +NumericField NF_EXTRAPOLATE_FORWARD \ +{ \ + Border = TRUE ; \ + Pos = MAP_APPFONT ( 20, 120 + yoffset ) ; \ + Size = MAP_APPFONT ( 28 , 12 ) ; \ + TabStop = TRUE ; \ + Repeat = TRUE ; \ + Spin = TRUE ; \ + StrictFormat = TRUE ; \ + SpinSize = 50 ; \ + Minimum = 0 ; \ + Maximum = 10000 ; \ + DecimalDigits = 2 ; \ +}; \ +NumericField NF_EXTRAPOLATE_BACKWARD \ +{ \ + Border = TRUE ; \ + Pos = MAP_APPFONT ( 20, 134 + yoffset ) ; \ + Size = MAP_APPFONT ( 28 , 12 ) ; \ + TabStop = TRUE ; \ + Repeat = TRUE ; \ + Spin = TRUE ; \ + StrictFormat = TRUE ; \ + SpinSize = 50 ; \ + Minimum = 0 ; \ + Maximum = 10000 ; \ + DecimalDigits = 2 ; \ +}; \ +CheckBox CB_SET_INTERCEPT \ +{ \ + HelpId = HID_SCH_TRENDLINE_SHOW_EQUATION; \ + Pos = MAP_APPFONT( 10, 148 + yoffset ); \ + Size = MAP_APPFONT( 60, 10 ); \ + TabStop = TRUE; \ + Text[ en-US ] = "Set ~intercept"; \ +}; \ +NumericField NF_INTERCEPT_VALUE \ +{ \ + Border = TRUE ; \ + Pos = MAP_APPFONT ( 75, 148 + yoffset ) ; \ + Size = MAP_APPFONT ( 40 , 12 ) ; \ + TabStop = TRUE ; \ + Spin = FALSE ; \ + DecimalDigits = 4 ; \ }; \ CheckBox CB_SHOW_EQUATION \ { \ HelpId = HID_SCH_TRENDLINE_SHOW_EQUATION; \ - Pos = MAP_APPFONT( 10, 120 + yoffset ); \ + Pos = MAP_APPFONT( 10, 162 + yoffset ); \ Size = MAP_APPFONT( availablewidth - 20, 10 ); \ TabStop = TRUE; \ Text[ en-US ] = "Show ~equation"; \ @@ -106,7 +199,7 @@ CheckBox CB_SHOW_EQUATION \ CheckBox CB_SHOW_CORRELATION_COEFF \ { \ HelpId = HID_SCH_TRENDLINE_SHOW_R_SQUARED; \ - Pos = MAP_APPFONT( 10, 134 + yoffset ); \ + Pos = MAP_APPFONT( 10, 176 + yoffset ); \ Size = MAP_APPFONT( availablewidth - 20, 10 ); \ TabStop = TRUE; \ Text[ en-US ] = "Show ~coefficient of determination (R²)"; \ diff --git a/chart2/source/controller/inc/HelpIds.hrc b/chart2/source/controller/inc/HelpIds.hrc index d48189cdeeab..26ee1c816070 100644 --- a/chart2/source/controller/inc/HelpIds.hrc +++ b/chart2/source/controller/inc/HelpIds.hrc @@ -120,6 +120,8 @@ #define HID_SCH_TRENDLINE_RB_LOGARITHMIC "CHART2_HID_SCH_TRENDLINE_RB_LOGARITHMIC" #define HID_SCH_TRENDLINE_RB_EXPONENTIAL "CHART2_HID_SCH_TRENDLINE_RB_EXPONENTIAL" #define HID_SCH_TRENDLINE_RB_POWER "CHART2_HID_SCH_TRENDLINE_RB_POWER" +#define HID_SCH_TRENDLINE_RB_POLYNOMIC "CHART2_HID_SCH_TRENDLINE_RB_POLYNOMIC" +#define HID_SCH_TRENDLINE_RB_MOVING_AVERAGE "CHART2_HID_SCH_TRENDLINE_RB_MOVING_AVERAGE" #define HID_SCH_TRENDLINE_SHOW_EQUATION "CHART2_HID_SCH_TRENDLINE_SHOW_EQUATION" #define HID_SCH_TRENDLINE_SHOW_R_SQUARED "CHART2_HID_SCH_TRENDLINE_SHOW_R_SQUARED" diff --git a/chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx b/chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx index fcf49d925ec2..3ea1c0dd4363 100644 --- a/chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx +++ b/chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx @@ -28,6 +28,7 @@ // for SfxBoolItem #include <svl/eitem.hxx> +#include <svl/intitem.hxx> #include <svx/chrtitem.hxx> #include <functional> @@ -55,6 +56,12 @@ namespace case CHREGRESS_POWER: eType = ::chart::RegressionCurveHelper::REGRESSION_TYPE_POWER; break; + case CHREGRESS_POLYNOMIAL: + eType = ::chart::RegressionCurveHelper::REGRESSION_TYPE_POLYNOMIAL; + break; + case CHREGRESS_MOVING_AVERAGE: + eType = ::chart::RegressionCurveHelper::REGRESSION_TYPE_MOVING_AVERAGE; + break; case CHREGRESS_NONE: break; } @@ -156,6 +163,112 @@ bool RegressionCurveItemConverter::ApplySpecialItem( } break; + case SCHATTR_REGRESSION_DEGREE: + { + if( xCurve.is()) + { + sal_Int32 aDegree = static_cast< sal_Int32 >( + static_cast< const SfxInt32Item & >( + rItemSet.Get( nWhichId )).GetValue()); + + uno::Reference< beans::XPropertySet > xProperties( xCurve, uno::UNO_QUERY ); + OSL_ASSERT( xProperties.is()); + sal_Int32 aOldDegree = 1; + if( xProperties.is() ) + { + xProperties->getPropertyValue( "PolynomialDegree" ) >>= aOldDegree; + if (aOldDegree != aDegree) + { + xProperties->setPropertyValue( "PolynomialDegree" , uno::makeAny( aDegree )); + bChanged = true; + } + } + } + } + break; + + case SCHATTR_REGRESSION_PERIOD: + { + if( xCurve.is()) + { + sal_Int32 aPeriod = static_cast< sal_Int32 >( + static_cast< const SfxInt32Item & >( + rItemSet.Get( nWhichId )).GetValue()); + + uno::Reference< beans::XPropertySet > xProperties( xCurve, uno::UNO_QUERY ); + OSL_ASSERT( xProperties.is()); + sal_Int32 aOldPeriod = 2; + if( xProperties.is() ) + { + xProperties->getPropertyValue( "MovingAveragePeriod" ) >>= aOldPeriod; + if (aOldPeriod != aPeriod) + { + xProperties->setPropertyValue( "MovingAveragePeriod" , uno::makeAny( aPeriod )); + bChanged = true; + } + } + } + } + break; + + case SCHATTR_REGRESSION_EXTRAPOLATE_FORWARD: + { + if( xCurve.is()) + { + double aValue = static_cast< double >( + static_cast< const SvxDoubleItem & >( + rItemSet.Get( nWhichId )).GetValue()); + + uno::Reference< beans::XPropertySet > xProperties( xCurve, uno::UNO_QUERY ); + OSL_ASSERT( xProperties.is()); + double aOldValue = 0.0; + if( xProperties.is() ) + { + xProperties->getPropertyValue( "ExtrapolateForward" ) >>= aOldValue; + if (aOldValue != aValue) + { + xProperties->setPropertyValue( "ExtrapolateForward" , uno::makeAny( aValue )); + bChanged = true; + } + } + } + } + break; + + case SCHATTR_REGRESSION_EXTRAPOLATE_BACKWARD: + { + if( xCurve.is()) + { + double aValue = static_cast< double >( + static_cast< const SvxDoubleItem & >( + rItemSet.Get( nWhichId )).GetValue()); + + uno::Reference< beans::XPropertySet > xProperties( xCurve, uno::UNO_QUERY ); + OSL_ASSERT( xProperties.is()); + double aOldValue = 0.0; + if( xProperties.is() ) + { + xProperties->getPropertyValue( "ExtrapolateBackward" ) >>= aOldValue; + if (aOldValue != aValue) + { + xProperties->setPropertyValue( "ExtrapolateBackward" , uno::makeAny( aValue )); + bChanged = true; + } + } + } + } + break; + + case SCHATTR_REGRESSION_SET_INTERCEPT: + { + } + break; + + case SCHATTR_REGRESSION_INTERCEPT_VALUE: + { + } + break; + case SCHATTR_REGRESSION_SHOW_EQUATION: { OSL_ASSERT( xCurve.is()); @@ -226,6 +339,74 @@ void RegressionCurveItemConverter::FillSpecialItem( } break; + case SCHATTR_REGRESSION_DEGREE: + { + OSL_ASSERT( xCurve.is()); + if( xCurve.is()) + { + uno::Reference< beans::XPropertySet > xProperties( xCurve, uno::UNO_QUERY ); + OSL_ASSERT( xProperties.is()); + sal_Int32 aDegree = 1; + if( xProperties.is() && + (xProperties->getPropertyValue( "PolynomialDegree" ) >>= aDegree)) + { + rOutItemSet.Put( SfxInt32Item( nWhichId, aDegree )); + } + } + } + break; + + case SCHATTR_REGRESSION_PERIOD: + { + OSL_ASSERT( xCurve.is()); + if( xCurve.is()) + { + uno::Reference< beans::XPropertySet > xProperties( xCurve, uno::UNO_QUERY ); + OSL_ASSERT( xProperties.is()); + sal_Int32 aPeriod = 2; + if( xProperties.is() && + (xProperties->getPropertyValue( "MovingAveragePeriod" ) >>= aPeriod)) + { + rOutItemSet.Put( SfxInt32Item( nWhichId, aPeriod )); + } + } + } + break; + + case SCHATTR_REGRESSION_EXTRAPOLATE_FORWARD: + { + OSL_ASSERT( xCurve.is()); + if( xCurve.is()) + { + uno::Reference< beans::XPropertySet > xProperties( xCurve, uno::UNO_QUERY ); + OSL_ASSERT( xProperties.is()); + double aValue = 0.0; + if( xProperties.is() && + (xProperties->getPropertyValue( "ExtrapolateForward" ) >>= aValue)) + { + rOutItemSet.Put( SvxDoubleItem( aValue, nWhichId )); + } + } + } + break; + + case SCHATTR_REGRESSION_EXTRAPOLATE_BACKWARD: + { + OSL_ASSERT( xCurve.is()); + if( xCurve.is()) + { + uno::Reference< beans::XPropertySet > xProperties( xCurve, uno::UNO_QUERY ); + OSL_ASSERT( xProperties.is()); + double aValue = 0.0; + if( xProperties.is() && + (xProperties->getPropertyValue( "ExtrapolateBackward" ) >>= aValue)) + { + rOutItemSet.Put( SvxDoubleItem( aValue, nWhichId )); + } + } + } + break; + case SCHATTR_REGRESSION_SHOW_EQUATION: { OSL_ASSERT( xCurve.is()); diff --git a/chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx b/chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx index 6cddc4e5cf10..16ce0ceac0e1 100644 --- a/chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx +++ b/chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx @@ -84,6 +84,12 @@ uno::Reference< beans::XPropertySet > lcl_GetErrorBar( case CHREGRESS_POWER: eType = ::chart::RegressionCurveHelper::REGRESSION_TYPE_POWER; break; + case CHREGRESS_POLYNOMIAL: + eType = ::chart::RegressionCurveHelper::REGRESSION_TYPE_POLYNOMIAL; + break; + case CHREGRESS_MOVING_AVERAGE: + eType = ::chart::RegressionCurveHelper::REGRESSION_TYPE_MOVING_AVERAGE; + break; case CHREGRESS_NONE: break; } @@ -164,6 +170,38 @@ uno::Reference< beans::XPropertySet > lcl_getEquationProperties( return uno::Reference< beans::XPropertySet >(); } +uno::Reference< beans::XPropertySet > lcl_getCurveProperties( + const uno::Reference< beans::XPropertySet > & xSeriesPropSet, const SfxItemSet * pItemSet ) +{ + bool bExists = true; + + // ensure that a trendline is on + if( pItemSet ) + { + SvxChartRegress eRegress = CHREGRESS_NONE; + const SfxPoolItem *pPoolItem = NULL; + if( pItemSet->GetItemState( SCHATTR_REGRESSION_TYPE, sal_True, &pPoolItem ) == SFX_ITEM_SET ) + { + eRegress = static_cast< const SvxChartRegressItem * >( pPoolItem )->GetValue(); + bExists = ( eRegress != CHREGRESS_NONE ); + } + } + + if( bExists ) + { + uno::Reference< chart2::XRegressionCurveContainer > xRegCnt( xSeriesPropSet, uno::UNO_QUERY ); + uno::Reference< chart2::XRegressionCurve > xCurve( + ::chart::RegressionCurveHelper::getFirstCurveNotMeanValueLine( xRegCnt )); + if( xCurve.is()) + { + uno::Reference< beans::XPropertySet > xProperties( xCurve, uno::UNO_QUERY ); + return xProperties; + } + } + + return uno::Reference< beans::XPropertySet >(); +} + } // anonymous namespace namespace chart @@ -188,6 +226,10 @@ StatisticsItemConverter::StatisticsItemConverter( static_cast< int >( CHREGRESS_EXP )); OSL_ASSERT( static_cast< int >( RegressionCurveHelper::REGRESSION_TYPE_POWER ) == static_cast< int >( CHREGRESS_POWER )); + OSL_ASSERT( static_cast< int >( RegressionCurveHelper::REGRESSION_TYPE_POLYNOMIAL ) == + static_cast< int >( CHREGRESS_POLYNOMIAL )); + OSL_ASSERT( static_cast< int >( RegressionCurveHelper::REGRESSION_TYPE_MOVING_AVERAGE ) == + static_cast< int >( CHREGRESS_MOVING_AVERAGE )); } StatisticsItemConverter::~StatisticsItemConverter() @@ -397,6 +439,78 @@ bool StatisticsItemConverter::ApplySpecialItem( } break; + case SCHATTR_REGRESSION_DEGREE: + { + uno::Reference< beans::XPropertySet > xProperties( lcl_getCurveProperties( GetPropertySet(), &rItemSet )); + if( xProperties.is()) + { + sal_Int32 aDegree = 1; + xProperties->getPropertyValue( "PolynomialDegree" ) >>= aDegree; + sal_Int32 aNewDegree = + static_cast< const SfxInt32Item & >( rItemSet.Get( nWhichId )).GetValue(); + if( aDegree != aNewDegree ) + { + xProperties->setPropertyValue( "PolynomialDegree" , uno::makeAny( aNewDegree )); + bChanged = true; + } + } + } + break; + + case SCHATTR_REGRESSION_PERIOD: + { + uno::Reference< beans::XPropertySet > xProperties( lcl_getCurveProperties( GetPropertySet(), &rItemSet )); + if( xProperties.is()) + { + sal_Int32 aPeriod = 2; + xProperties->getPropertyValue( "MovingAveragePeriod" ) >>= aPeriod; + sal_Int32 aNewPeriod = + static_cast< const SfxInt32Item & >( rItemSet.Get( nWhichId )).GetValue(); + if( aPeriod != aNewPeriod ) + { + xProperties->setPropertyValue( "MovingAveragePeriod" , uno::makeAny( aNewPeriod )); + bChanged = true; + } + } + } + break; + + case SCHATTR_REGRESSION_EXTRAPOLATE_FORWARD: + { + uno::Reference< beans::XPropertySet > xProperties( lcl_getCurveProperties( GetPropertySet(), &rItemSet )); + if( xProperties.is()) + { + double aExtrapolationValue = 0.0; + xProperties->getPropertyValue( "ExtrapolateForward" ) >>= aExtrapolationValue; + double aNewValue = + static_cast< const SvxDoubleItem & >( rItemSet.Get( nWhichId )).GetValue(); + if( aExtrapolationValue != aNewValue ) + { + xProperties->setPropertyValue( "ExtrapolateForward" , uno::makeAny( aNewValue )); + bChanged = true; + } + } + } + break; + + case SCHATTR_REGRESSION_EXTRAPOLATE_BACKWARD: + { + uno::Reference< beans::XPropertySet > xProperties( lcl_getCurveProperties( GetPropertySet(), &rItemSet )); + if( xProperties.is()) + { + double aExtrapolationValue = 0.0; + xProperties->getPropertyValue( "ExtrapolateBackward" ) >>= aExtrapolationValue; + double aNewValue = + static_cast< const SvxDoubleItem & >( rItemSet.Get( nWhichId )).GetValue(); + if( aExtrapolationValue != aNewValue ) + { + xProperties->setPropertyValue( "ExtrapolateBackward" , uno::makeAny( aNewValue )); + bChanged = true; + } + } + } + break; + case SCHATTR_REGRESSION_SHOW_EQUATION: { uno::Reference< beans::XPropertySet > xEqProp( lcl_getEquationProperties( GetPropertySet(), &rItemSet )); @@ -639,6 +753,46 @@ void StatisticsItemConverter::FillSpecialItem( } break; + case SCHATTR_REGRESSION_DEGREE: + { + sal_Int32 aDegree = 1; + uno::Reference< beans::XPropertySet > xProperties( lcl_getCurveProperties( GetPropertySet(), 0 )); + if( xProperties.is()) + xProperties->getPropertyValue( "PolynomialDegree" ) >>= aDegree; + rOutItemSet.Put( SfxInt32Item( nWhichId, aDegree )); + } + break; + + case SCHATTR_REGRESSION_PERIOD: + { + sal_Int32 aPeriod = 2; + uno::Reference< beans::XPropertySet > xProperties( lcl_getCurveProperties( GetPropertySet(), 0 )); + if( xProperties.is()) + xProperties->getPropertyValue( "MovingAveragePeriod" ) >>= aPeriod; + rOutItemSet.Put( SfxInt32Item( nWhichId, aPeriod )); + } + break; + + case SCHATTR_REGRESSION_EXTRAPOLATE_FORWARD: + { + double aValue = 0.0; + uno::Reference< beans::XPropertySet > xProperties( lcl_getCurveProperties( GetPropertySet(), 0 )); + if( xProperties.is()) + xProperties->getPropertyValue( "ExtrapolateForward" ) >>= aValue; + rOutItemSet.Put( SvxDoubleItem( aValue, nWhichId )); + } + break; + + case SCHATTR_REGRESSION_EXTRAPOLATE_BACKWARD: + { + double aValue = 0.0; + uno::Reference< beans::XPropertySet > xProperties( lcl_getCurveProperties( GetPropertySet(), 0 )); + if( xProperties.is()) + xProperties->getPropertyValue( "ExtrapolateBackward" ) >>= aValue; + rOutItemSet.Put( SvxDoubleItem( aValue, nWhichId )); + } + break; + case SCHATTR_REGRESSION_SHOW_EQUATION: { bool bShowEq = false; |