[Libreoffice-commits] core.git: Branch 'feature/polynomialregression' - 4 commits - chart2/source offapi/com oox/source sc/source

Tomaž Vajngerl quikee at gmail.com
Fri Jun 28 14:13:18 PDT 2013


 chart2/source/controller/dialogs/dlg_InsertTrendline.src                 |    2 
 chart2/source/controller/dialogs/res_Trendline.cxx                       |   56 +++++
 chart2/source/controller/dialogs/res_Trendline.hxx                       |    6 
 chart2/source/controller/dialogs/res_Trendline_IDs.hrc                   |    5 
 chart2/source/controller/dialogs/res_Trendline_tmpl.hrc                  |   45 +++-
 chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx |   72 +++++++
 chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx      |   57 +++++
 chart2/source/inc/PolynomialRegressionCurveCalculator.hxx                |   30 +--
 chart2/source/inc/RegressionCurveCalculator.hxx                          |   63 +++---
 chart2/source/tools/PolynomialRegressionCurveCalculator.cxx              |   96 ++++++----
 chart2/source/tools/RegressionCurveCalculator.cxx                        |   28 +-
 chart2/source/tools/RegressionCurveModel.cxx                             |   18 +
 chart2/source/view/charttypes/VSeriesPlotter.cxx                         |   13 -
 chart2/source/view/main/ChartItemPool.cxx                                |   14 -
 offapi/com/sun/star/chart2/XRegressionCurveCalculator.idl                |    3 
 oox/source/drawingml/chart/seriesconverter.cxx                           |    7 
 oox/source/export/chartexport.cxx                                        |   14 +
 oox/source/token/properties.txt                                          |    2 
 sc/source/filter/excel/xechart.cxx                                       |    5 
 sc/source/filter/excel/xichart.cxx                                       |   14 +
 sc/source/filter/inc/xlchart.hxx                                         |    2 
 21 files changed, 435 insertions(+), 117 deletions(-)

New commits:
commit c552b2c507a3df6adc968b81b375a13fcb89f50d
Author: Tomaž Vajngerl <quikee at gmail.com>
Date:   Fri Jun 28 22:58:15 2013 +0200

    Force intercept import/export for binary MS office format.
    
    Change-Id: I301762b94b4471e8bb144b63892afdf7f68fed77

diff --git a/sc/source/filter/excel/xechart.cxx b/sc/source/filter/excel/xechart.cxx
index b0e13ac..b403bab 100644
--- a/sc/source/filter/excel/xechart.cxx
+++ b/sc/source/filter/excel/xechart.cxx
@@ -1731,6 +1731,11 @@ bool XclExpChSerTrendLine::Convert( Reference< XRegressionCurve > xRegCurve, sal
 
     aCurveProp.GetProperty(maData.mfForecastFor,  EXC_CHPROP_EXTRAPOLATE_FORWARD);
     aCurveProp.GetProperty(maData.mfForecastBack, EXC_CHPROP_EXTRAPOLATE_BACKWARD);
+    sal_Bool bIsForceIntercept = false;
+    aCurveProp.GetProperty(bIsForceIntercept,  EXC_CHPROP_FORCE_INTERCEPT);
+    if (bIsForceIntercept)
+        aCurveProp.GetProperty(maData.mfIntercept, EXC_CHPROP_INTERCEPT_VALUE);
+
 
     // line formatting
     XclChDataPointPos aPointPos( nSeriesIdx );
diff --git a/sc/source/filter/excel/xichart.cxx b/sc/source/filter/excel/xichart.cxx
index 6ae9237..d2cca4a 100644
--- a/sc/source/filter/excel/xichart.cxx
+++ b/sc/source/filter/excel/xichart.cxx
@@ -195,6 +195,13 @@ void lclConvertTimeInterval( Any& rInterval, sal_uInt16 nValue, bool bAuto, sal_
         rInterval <<= cssc::TimeInterval( nValue, lclGetApiTimeUnit( nTimeUnit ) );
 }
 
+bool lcl_IsForceIntercept(double intercept)
+{
+    sal_math_Double* pIntercept = reinterpret_cast<sal_math_Double*>(&intercept);
+    return (pIntercept->w32_parts.msw != 0xFFFFFFFF ||
+            pIntercept->w32_parts.lsw != 0xFFFFFFFF);
+}
+
 } // namespace
 
 // Common =====================================================================
@@ -1650,6 +1657,13 @@ Reference< XRegressionCurve > XclImpChSerTrendLine::CreateRegressionCurve() cons
         aPropSet.SetProperty(EXC_CHPROP_EXTRAPOLATE_FORWARD, maData.mfForecastFor);
         aPropSet.SetProperty(EXC_CHPROP_EXTRAPOLATE_BACKWARD, maData.mfForecastBack);
 
+        sal_Bool bForceIntercept = lcl_IsForceIntercept(maData.mfIntercept);
+        aPropSet.SetProperty(EXC_CHPROP_FORCE_INTERCEPT, bForceIntercept);
+        if (bForceIntercept)
+        {
+            aPropSet.SetProperty(EXC_CHPROP_INTERCEPT_VALUE, maData.mfIntercept);
+        }
+
         // #i83100# show equation and correlation coefficient
         ScfPropertySet aLabelProp( xRegCurve->getEquationProperties() );
         aLabelProp.SetBoolProperty( EXC_CHPROP_SHOWEQUATION, maData.mnShowEquation != 0 );
diff --git a/sc/source/filter/inc/xlchart.hxx b/sc/source/filter/inc/xlchart.hxx
index b13d932..4354b5c 100644
--- a/sc/source/filter/inc/xlchart.hxx
+++ b/sc/source/filter/inc/xlchart.hxx
@@ -87,10 +87,12 @@ class XclRoot;
 #define EXC_CHPROP_EXTRAPOLATE_BACKWARD     "ExtrapolateBackward"
 #define EXC_CHPROP_FILLBITMAPMODE           "FillBitmapMode"
 #define EXC_CHPROP_FILLSTYLE                "FillStyle"
+#define EXC_CHPROP_FORCE_INTERCEPT          "ForceIntercept"
 #define EXC_CHPROP_GAPWIDTHSEQ              "GapwidthSequence"
 #define EXC_CHPROP_GEOMETRY3D               "Geometry3D"
 #define EXC_CHPROP_HASMAINTITLE             "HasMainTitle"
 #define EXC_CHPROP_INCLUDEHIDDENCELLS       "IncludeHiddenCells"
+#define EXC_CHPROP_INTERCEPT_VALUE          "InterceptValue"
 #define EXC_CHPROP_JAPANESE                 "Japanese"
 #define EXC_CHPROP_LABEL                    "Label"
 #define EXC_CHPROP_LABELPLACEMENT           "LabelPlacement"
commit bcecad10e2346b919a4cea80d27d9c04c6f50422
Author: Tomaž Vajngerl <quikee at gmail.com>
Date:   Fri Jun 28 22:56:48 2013 +0200

    Force intercept export for OOXML
    
    Change-Id: I5ec993a6aba0c0bb3b9f77ef6fb9e00680dfa574

diff --git a/oox/source/export/chartexport.cxx b/oox/source/export/chartexport.cxx
index ede6cec..516639b 100644
--- a/oox/source/export/chartexport.cxx
+++ b/oox/source/export/chartexport.cxx
@@ -2570,6 +2570,20 @@ void ChartExport::exportTrendlines( Reference< chart2::XDataSeries > xSeries )
                     XML_val, OString::number(aExtrapolateBackward).getStr(),
                     FSEND );
 
+            sal_Bool aForceIntercept = false;
+            xProperties->getPropertyValue( "ForceIntercept") >>= aForceIntercept;
+
+            if (aForceIntercept)
+            {
+                double aInterceptValue = 0.0;
+                xProperties->getPropertyValue( "InterceptValue") >>= aInterceptValue;
+
+                pFS->singleElement( FSNS( XML_c, XML_intercept ),
+                    XML_val, OString::number(aInterceptValue).getStr(),
+                    FSEND );
+            }
+
+
             // Equation properties
             Reference< XPropertySet > xEquationProperties( xRegCurve->getEquationProperties() );
 
commit 9ddbe8402b2a24f780eaabf3975c7bdf6fe82d19
Author: Tomaž Vajngerl <quikee at gmail.com>
Date:   Fri Jun 28 21:10:38 2013 +0200

    Force intercept support for ooxml.
    
    Change-Id: I065742bbe22f24169a99e33558399fe16c601238

diff --git a/oox/source/drawingml/chart/seriesconverter.cxx b/oox/source/drawingml/chart/seriesconverter.cxx
index a02e52a..cc05567 100644
--- a/oox/source/drawingml/chart/seriesconverter.cxx
+++ b/oox/source/drawingml/chart/seriesconverter.cxx
@@ -436,6 +436,13 @@ void TrendlineConverter::convertFromModel( const Reference< XDataSeries >& rxDat
             aPropSet.setProperty( PROP_PolynomialDegree, mrModel.mnOrder );
             aPropSet.setProperty( PROP_MovingAveragePeriod, mrModel.mnPeriod );
 
+            // Intercept
+            sal_Bool hasIntercept = mrModel.mfIntercept.has();
+            aPropSet.setProperty( PROP_ForceIntercept, hasIntercept);
+            if (hasIntercept)
+                aPropSet.setProperty( PROP_InterceptValue,  mrModel.mfIntercept.get());
+
+            // Extrapolation
             if (mrModel.mfForward.has())
                 aPropSet.setProperty( PROP_ExtrapolateForward, mrModel.mfForward.get() );
             if (mrModel.mfBackward.has())
diff --git a/oox/source/token/properties.txt b/oox/source/token/properties.txt
index e292d14..0acfe06 100644
--- a/oox/source/token/properties.txt
+++ b/oox/source/token/properties.txt
@@ -185,6 +185,7 @@ FooterHeight
 FooterIsDynamicHeight
 FooterIsOn
 FooterIsShared
+ForceIntercept
 FormulaConvention
 FrameIsAutomaticHeight
 Function
@@ -238,6 +239,7 @@ ImageURL
 IncludeHiddenCells
 InputMessage
 InputTitle
+InterceptValue
 IsActive
 IsAdjustHeightEnabled
 IsCaseSensitive
commit f6cbdcfa36456fe653c201b2c8551a47812871ea
Author: Tomaž Vajngerl <quikee at gmail.com>
Date:   Fri Jun 28 19:49:25 2013 +0200

    Force intercept for polynomial regression & dialog improvements
    
    Change-Id: I2f712d8b95b5fdeb05b93b5247aab9772a00cc70

diff --git a/chart2/source/controller/dialogs/dlg_InsertTrendline.src b/chart2/source/controller/dialogs/dlg_InsertTrendline.src
index baf7dd9..2b8b621 100644
--- a/chart2/source/controller/dialogs/dlg_InsertTrendline.src
+++ b/chart2/source/controller/dialogs/dlg_InsertTrendline.src
@@ -31,7 +31,7 @@ ModalDialog DLG_DATA_TRENDLINE
     HelpID = HID_INSERT_STATISTICS ;
     OutputSize = TRUE ;
     SVLook = TRUE ;
-    Size = MAP_APPFONT( DLG_DATA_TRENDLINE_RES_WIDTH + DLG_DATA_TRENDLINE_ADD_TO_RES, 172 );
+    Size = MAP_APPFONT( DLG_DATA_TRENDLINE_RES_WIDTH + DLG_DATA_TRENDLINE_ADD_TO_RES, 220 );
     Moveable = TRUE ;
     BUTTONS_OK_CANCEL_HELP_STACKED( DLG_DATA_TRENDLINE_RES_WIDTH + DLG_DATA_TRENDLINE_ADD_TO_RES )
     RESOURCE_TRENDLINE( DLG_DATA_TRENDLINE_RES_WIDTH, 22 )
diff --git a/chart2/source/controller/dialogs/res_Trendline.cxx b/chart2/source/controller/dialogs/res_Trendline.cxx
index 803c060..316282c 100644
--- a/chart2/source/controller/dialogs/res_Trendline.cxx
+++ b/chart2/source/controller/dialogs/res_Trendline.cxx
@@ -78,11 +78,15 @@ TrendlineResources::TrendlineResources( Window * pParent, const SfxItemSet& rInA
         m_aFIPolynomial(    pParent, SchResId( FI_POLYNOMIAL       )),
         m_aFIMovingAverage( pParent, SchResId( FI_MOVING_AVERAGE    )),
 
+        m_aFT_Degree(       pParent, SchResId( FT_DEGREE            )),
         m_aNF_Degree(       pParent, SchResId( NF_DEGREE            )),
+        m_aFT_Period(       pParent, SchResId( FT_PERIOD            )),
         m_aNF_Period(       pParent, SchResId( NF_PERIOD            )),
 
+        m_aFT_ExtrapolateForward(   pParent, SchResId( FT_EXTRAPOLATE_FORWARD            )),
         m_aNF_ExtrapolateForward(   pParent, SchResId( NF_EXTRAPOLATE_FORWARD            )),
-        m_aNF_ExtrapolateBackward(  pParent, SchResId( NF_EXTRAPOLATE_BACKWARD            )),
+        m_aFT_ExtrapolateBackward(  pParent, SchResId( FT_EXTRAPOLATE_BACKWARD           )),
+        m_aNF_ExtrapolateBackward(  pParent, SchResId( NF_EXTRAPOLATE_BACKWARD           )),
         m_aCB_SetIntercept(         pParent, SchResId( CB_SET_INTERCEPT          )),
         m_aNF_InterceptValue(       pParent, SchResId( NF_INTERCEPT_VALUE            )),
 
@@ -121,7 +125,7 @@ TrendlineResources::~TrendlineResources()
 long TrendlineResources::adjustControlSizes()
 {
     // calculate right edge
-    ::std::vector< long > aControlRightEdges;
+    std::vector< long > aControlRightEdges;
     aControlRightEdges.push_back( lcl_getRightEdge( m_aRBNone ));
     aControlRightEdges.push_back( lcl_getRightEdge( m_aRBLinear ));
     aControlRightEdges.push_back( lcl_getRightEdge( m_aRBLogarithmic ));
@@ -129,9 +133,18 @@ long TrendlineResources::adjustControlSizes()
     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_aNF_Degree ));
+    aControlRightEdges.push_back( lcl_getRightEdge( m_aNF_Period ));
+    aControlRightEdges.push_back( lcl_getRightEdge( m_aNF_ExtrapolateForward ));
+    aControlRightEdges.push_back( lcl_getRightEdge( m_aNF_ExtrapolateBackward ));
+    aControlRightEdges.push_back( lcl_getRightEdge( m_aNF_InterceptValue ));
+    aControlRightEdges.push_back( lcl_getRightEdge( m_aCB_SetIntercept ));
+
     aControlRightEdges.push_back( lcl_getRightEdge( m_aCBShowEquation ));
     aControlRightEdges.push_back( lcl_getRightEdge( m_aCBShowCorrelationCoeff ));
 
+
     lcl_AdjustControlSize( m_aRBNone );
     lcl_AdjustControlSize( m_aRBLinear );
     lcl_AdjustControlSize( m_aRBLogarithmic );
@@ -139,6 +152,14 @@ long TrendlineResources::adjustControlSizes()
     lcl_AdjustControlSize( m_aRBPower );
     lcl_AdjustControlSize( m_aRBPolynomial );
     lcl_AdjustControlSize( m_aRBMovingAverage );
+
+    lcl_AdjustControlSize( m_aNF_Degree );
+    lcl_AdjustControlSize( m_aNF_Period );
+    lcl_AdjustControlSize( m_aNF_ExtrapolateForward );
+    lcl_AdjustControlSize( m_aNF_ExtrapolateBackward );
+    lcl_AdjustControlSize( m_aNF_InterceptValue );
+    lcl_AdjustControlSize( m_aCB_SetIntercept );
+
     lcl_AdjustControlSize( m_aCBShowEquation );
     lcl_AdjustControlSize( m_aCBShowCorrelationCoeff );
 
@@ -240,6 +261,29 @@ void TrendlineResources::Reset( const SfxItemSet& rInAttrs )
         m_aNF_ExtrapolateBackward.SetValue( 0 );
     }
 
+    if( rInAttrs.GetItemState( SCHATTR_REGRESSION_INTERCEPT_VALUE, sal_True, &pPoolItem ) == SFX_ITEM_SET )
+    {
+        double nValue = static_cast< const SvxDoubleItem * >( pPoolItem )->GetValue() * 10000;
+        m_aNF_InterceptValue.SetValue( (sal_Int64) nValue );
+    }
+    else
+    {
+        m_aNF_InterceptValue.SetValue( 0 );
+    }
+
+    aState = rInAttrs.GetItemState( SCHATTR_REGRESSION_SET_INTERCEPT, sal_True, &pPoolItem );
+    if( aState == SFX_ITEM_DONTCARE )
+    {
+        m_aCB_SetIntercept.EnableTriState( sal_True );
+        m_aCB_SetIntercept.SetState( STATE_DONTKNOW );
+    }
+    else
+    {
+        m_aCB_SetIntercept.EnableTriState( sal_False );
+        if( aState == SFX_ITEM_SET )
+            m_aCB_SetIntercept.Check( static_cast< const SfxBoolItem * >( pPoolItem )->GetValue());
+    }
+
     aState = rInAttrs.GetItemState( SCHATTR_REGRESSION_SHOW_EQUATION, sal_True, &pPoolItem );
     if( aState == SFX_ITEM_DONTCARE )
     {
@@ -300,8 +344,10 @@ sal_Bool TrendlineResources::FillItemSet(SfxItemSet& rOutAttrs) const
 {
     if( m_bTrendLineUnique )
         rOutAttrs.Put( SvxChartRegressItem( m_eTrendLineType, SCHATTR_REGRESSION_TYPE ));
+
     if( m_aCBShowEquation.GetState() != STATE_DONTKNOW )
         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() ));
 
@@ -317,6 +363,12 @@ sal_Bool TrendlineResources::FillItemSet(SfxItemSet& rOutAttrs) const
     double aExtrapolateBackwardValue = m_aNF_ExtrapolateBackward.GetValue() / 100.0;
     rOutAttrs.Put(SvxDoubleItem( aExtrapolateBackwardValue, SCHATTR_REGRESSION_EXTRAPOLATE_BACKWARD ) );
 
+    if( m_aCB_SetIntercept.GetState() != STATE_DONTKNOW )
+        rOutAttrs.Put( SfxBoolItem( SCHATTR_REGRESSION_SET_INTERCEPT, m_aCB_SetIntercept.IsChecked() ));
+
+    double aInterceptValue = m_aNF_InterceptValue.GetValue() / 10000.0;
+    rOutAttrs.Put(SvxDoubleItem( aInterceptValue, SCHATTR_REGRESSION_INTERCEPT_VALUE ) );
+
     return sal_True;
 }
 
diff --git a/chart2/source/controller/dialogs/res_Trendline.hxx b/chart2/source/controller/dialogs/res_Trendline.hxx
index bbabc7b..1ff8ca0 100644
--- a/chart2/source/controller/dialogs/res_Trendline.hxx
+++ b/chart2/source/controller/dialogs/res_Trendline.hxx
@@ -60,11 +60,17 @@ private:
     FixedImage  m_aFIPolynomial;
     FixedImage  m_aFIMovingAverage;
 
+    FixedText         m_aFT_Degree;
     NumericField      m_aNF_Degree;
+    FixedText         m_aFT_Period;
     NumericField      m_aNF_Period;
 
+    FixedText         m_aFT_ExtrapolateForward;
     NumericField      m_aNF_ExtrapolateForward;
+
+    FixedText         m_aFT_ExtrapolateBackward;
     NumericField      m_aNF_ExtrapolateBackward;
+
     CheckBox          m_aCB_SetIntercept;
     NumericField      m_aNF_InterceptValue;
 
diff --git a/chart2/source/controller/dialogs/res_Trendline_IDs.hrc b/chart2/source/controller/dialogs/res_Trendline_IDs.hrc
index aa54569..cb9e8d8 100644
--- a/chart2/source/controller/dialogs/res_Trendline_IDs.hrc
+++ b/chart2/source/controller/dialogs/res_Trendline_IDs.hrc
@@ -34,6 +34,11 @@
 #define NF_EXTRAPOLATE_BACKWARD 4
 #define NF_INTERCEPT_VALUE 5
 
+#define FT_DEGREE 1
+#define FT_PERIOD 2
+#define FT_EXTRAPOLATE_FORWARD 3
+#define FT_EXTRAPOLATE_BACKWARD 4
+
 #define RB_NONE 1
 #define RB_LINEAR 2
 #define RB_LOGARITHMIC 3
diff --git a/chart2/source/controller/dialogs/res_Trendline_tmpl.hrc b/chart2/source/controller/dialogs/res_Trendline_tmpl.hrc
index 950726d..ff6498c 100644
--- a/chart2/source/controller/dialogs/res_Trendline_tmpl.hrc
+++ b/chart2/source/controller/dialogs/res_Trendline_tmpl.hrc
@@ -111,10 +111,16 @@ FixedImage FI_MOVING_AVERAGE \
     Pos = MAP_APPFONT( 110, 62 + yoffset ); \
     Size = MAP_APPFONT( 18, 18 ); \
 }; \
+FixedText FT_DEGREE \
+{ \
+    Pos = MAP_APPFONT ( 110, 44 + yoffset  ) ; \
+    Size = MAP_APPFONT ( 20 , 12 ) ; \
+    Text [ en-US ] = "Degree"; \
+}; \
 NumericField NF_DEGREE \
 { \
     Border = TRUE ; \
-    Pos = MAP_APPFONT ( 110, 44 + yoffset  ) ; \
+    Pos = MAP_APPFONT ( 132, 42 + yoffset  ) ; \
     Size = MAP_APPFONT ( 28 , 12 ) ; \
     TabStop = TRUE ; \
     Repeat = TRUE ; \
@@ -124,10 +130,16 @@ NumericField NF_DEGREE \
     Minimum = 2 ; \
     Maximum = 100 ; \
 }; \
+FixedText FT_PERIOD \
+{ \
+    Pos = MAP_APPFONT ( 110, 88 + yoffset  ) ; \
+    Size = MAP_APPFONT ( 20 , 12 ) ; \
+    Text [ en-US ] = "Period"; \
+}; \
 NumericField NF_PERIOD \
 { \
     Border = TRUE ; \
-    Pos = MAP_APPFONT ( 110, 88 + yoffset  ) ; \
+    Pos = MAP_APPFONT ( 132, 86 + yoffset  ) ; \
     Size = MAP_APPFONT ( 28 , 12 ) ; \
     TabStop = TRUE ; \
     Repeat = TRUE ; \
@@ -143,11 +155,17 @@ FixedLine FL_EQUATION \
     Size = MAP_APPFONT( availablewidth - 12, 8 ); \
     Text[ en-US ] = "Options"; \
 }; \
+FixedText FT_EXTRAPOLATE_FORWARD \
+{ \
+    Pos = MAP_APPFONT ( 10, 120 + yoffset  ) ; \
+    Size = MAP_APPFONT ( 70 , 12 ) ; \
+    Text [ en-US ] = "Extrapolate ~forward"; \
+}; \
 NumericField NF_EXTRAPOLATE_FORWARD \
 { \
     Border = TRUE ; \
-    Pos = MAP_APPFONT ( 20, 120 + yoffset  ) ; \
-    Size = MAP_APPFONT ( 28 , 12 ) ; \
+    Pos = MAP_APPFONT ( 80, 118 + yoffset  ) ; \
+    Size = MAP_APPFONT ( 40 , 12 ) ; \
     TabStop = TRUE ; \
     Repeat = TRUE ; \
     Spin = TRUE ; \
@@ -157,11 +175,17 @@ NumericField NF_EXTRAPOLATE_FORWARD \
     Maximum = 10000 ; \
     DecimalDigits = 2 ; \
 }; \
+FixedText FT_EXTRAPOLATE_BACKWARD \
+{ \
+    Pos = MAP_APPFONT ( 10, 134 + yoffset  ) ; \
+    Size = MAP_APPFONT ( 70 , 12 ) ; \
+    Text [ en-US ] = "Extrapolate ~backward"; \
+}; \
 NumericField NF_EXTRAPOLATE_BACKWARD \
 { \
     Border = TRUE ; \
-    Pos = MAP_APPFONT ( 20, 134 + yoffset  ) ; \
-    Size = MAP_APPFONT ( 28 , 12 ) ; \
+    Pos = MAP_APPFONT ( 80, 132 + yoffset  ) ; \
+    Size = MAP_APPFONT ( 40 , 12 ) ; \
     TabStop = TRUE ; \
     Repeat = TRUE ; \
     Spin = TRUE ; \
@@ -175,17 +199,18 @@ CheckBox CB_SET_INTERCEPT \
 { \
     HelpId = HID_SCH_TRENDLINE_SHOW_EQUATION; \
     Pos = MAP_APPFONT( 10, 148 + yoffset ); \
-    Size = MAP_APPFONT( 60, 10 ); \
+    Size = MAP_APPFONT( 60, 12 ); \
     TabStop = TRUE; \
-    Text[ en-US ] = "Set ~intercept"; \
+    Text[ en-US ] = "Force ~intercept"; \
 }; \
 NumericField NF_INTERCEPT_VALUE \
 { \
     Border = TRUE ; \
-    Pos = MAP_APPFONT ( 75, 148 + yoffset  ) ; \
+    Pos = MAP_APPFONT ( 80, 146 + yoffset  ) ; \
     Size = MAP_APPFONT ( 40 , 12 ) ; \
     TabStop = TRUE ; \
-    Spin = FALSE ; \
+    Spin = TRUE ; \
+    SpinSize = 1000 ; \
     DecimalDigits = 4 ; \
 }; \
 CheckBox CB_SHOW_EQUATION \
diff --git a/chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx b/chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx
index 3ea1c0d..011853f 100644
--- a/chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx
+++ b/chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx
@@ -261,11 +261,49 @@ bool RegressionCurveItemConverter::ApplySpecialItem(
 
         case SCHATTR_REGRESSION_SET_INTERCEPT:
         {
+            if( xCurve.is())
+            {
+                sal_Bool bNewValue = static_cast< sal_Bool >(
+                    static_cast< const SfxBoolItem & >(
+                        rItemSet.Get( nWhichId )).GetValue());
+
+                uno::Reference< beans::XPropertySet > xProperties( xCurve, uno::UNO_QUERY );
+                OSL_ASSERT( xProperties.is());
+                sal_Bool bOldValue = false;
+                if( xProperties.is() )
+                {
+                    xProperties->getPropertyValue( "ForceIntercept" ) >>= bOldValue;
+                    if (bOldValue != bNewValue)
+                    {
+                        xProperties->setPropertyValue( "ForceIntercept" , uno::makeAny( bNewValue ));
+                        bChanged = true;
+                    }
+                }
+            }
         }
         break;
 
         case SCHATTR_REGRESSION_INTERCEPT_VALUE:
         {
+            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( "InterceptValue" ) >>= aOldValue;
+                    if (aOldValue != aValue)
+                    {
+                        xProperties->setPropertyValue( "InterceptValue" , uno::makeAny( aValue ));
+                        bChanged = true;
+                    }
+                }
+            }
         }
         break;
 
@@ -407,6 +445,40 @@ void RegressionCurveItemConverter::FillSpecialItem(
         }
         break;
 
+        case SCHATTR_REGRESSION_SET_INTERCEPT:
+        {
+            OSL_ASSERT( xCurve.is());
+            if( xCurve.is())
+            {
+                uno::Reference< beans::XPropertySet > xProperties( xCurve, uno::UNO_QUERY );
+                OSL_ASSERT( xProperties.is());
+                sal_Bool bForceIntercept = false;
+                if( xProperties.is() &&
+                    (xProperties->getPropertyValue( "ForceIntercept" ) >>= bForceIntercept))
+                {
+                    rOutItemSet.Put( SfxBoolItem( nWhichId, bForceIntercept ));
+                }
+            }
+        }
+        break;
+
+        case SCHATTR_REGRESSION_INTERCEPT_VALUE:
+        {
+            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( "InterceptValue" ) >>= 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 16ce0ce..c4b6896 100644
--- a/chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx
+++ b/chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx
@@ -511,6 +511,43 @@ bool StatisticsItemConverter::ApplySpecialItem(
         }
         break;
 
+        case SCHATTR_REGRESSION_SET_INTERCEPT:
+        {
+            uno::Reference< beans::XPropertySet > xProperties( lcl_getCurveProperties( GetPropertySet(), &rItemSet ));
+            if( xProperties.is())
+            {
+                sal_Bool aSetInterceptValue = false;
+                xProperties->getPropertyValue( "ForceIntercept" ) >>= aSetInterceptValue;
+                sal_Bool bNewValue =
+                    static_cast< const SfxBoolItem & >( rItemSet.Get( nWhichId )).GetValue();
+                if( aSetInterceptValue != bNewValue )
+                {
+                    xProperties->setPropertyValue( "ForceIntercept" , uno::makeAny( bNewValue ));
+                    bChanged = true;
+                }
+            }
+        }
+        break;
+        break;
+
+        case SCHATTR_REGRESSION_INTERCEPT_VALUE:
+        {
+            uno::Reference< beans::XPropertySet > xProperties( lcl_getCurveProperties( GetPropertySet(), &rItemSet ));
+            if( xProperties.is())
+            {
+                double aInterceptValue = 0.0;
+                xProperties->getPropertyValue( "InterceptValue" ) >>= aInterceptValue;
+                double aNewValue =
+                    static_cast< const SvxDoubleItem& >( rItemSet.Get( nWhichId )).GetValue();
+                if( aInterceptValue != aNewValue )
+                {
+                    xProperties->setPropertyValue( "InterceptValue" , uno::makeAny( aNewValue ));
+                    bChanged = true;
+                }
+            }
+        }
+        break;
+
         case SCHATTR_REGRESSION_SHOW_EQUATION:
         {
             uno::Reference< beans::XPropertySet > xEqProp( lcl_getEquationProperties( GetPropertySet(), &rItemSet ));
@@ -793,6 +830,26 @@ void StatisticsItemConverter::FillSpecialItem(
         }
         break;
 
+        case SCHATTR_REGRESSION_SET_INTERCEPT:
+        {
+            sal_Bool bForceIntercept = false;
+            uno::Reference< beans::XPropertySet > xProperties( lcl_getCurveProperties( GetPropertySet(), 0 ));
+            if( xProperties.is())
+                xProperties->getPropertyValue( "ForceIntercept" ) >>= bForceIntercept;
+            rOutItemSet.Put( SfxBoolItem( nWhichId, bForceIntercept ));
+        }
+        break;
+
+        case SCHATTR_REGRESSION_INTERCEPT_VALUE:
+        {
+            double aValue = 0.0;
+            uno::Reference< beans::XPropertySet > xProperties( lcl_getCurveProperties( GetPropertySet(), 0 ));
+            if( xProperties.is())
+                xProperties->getPropertyValue( "InterceptValue" ) >>= aValue;
+            rOutItemSet.Put( SvxDoubleItem( aValue, nWhichId ));
+        }
+        break;
+
         case SCHATTR_REGRESSION_SHOW_EQUATION:
         {
             bool bShowEq = false;
diff --git a/chart2/source/inc/PolynomialRegressionCurveCalculator.hxx b/chart2/source/inc/PolynomialRegressionCurveCalculator.hxx
index b3b38a9..803abb6 100644
--- a/chart2/source/inc/PolynomialRegressionCurveCalculator.hxx
+++ b/chart2/source/inc/PolynomialRegressionCurveCalculator.hxx
@@ -33,32 +33,30 @@ public:
 
 protected:
     virtual OUString ImplGetRepresentation(
-        const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& xNumFormatter,
-        ::sal_Int32 nNumberFormatKey ) const;
+        const com::sun::star::uno::Reference< com::sun::star::util::XNumberFormatter >& xNumFormatter,
+        sal_Int32 nNumberFormatKey ) const;
 
 private:
     // ____ XRegressionCurveCalculator ____
     virtual void SAL_CALL recalculateRegression(
-        const ::com::sun::star::uno::Sequence< double >& aXValues,
-        const ::com::sun::star::uno::Sequence< double >& aYValues )
-        throw (::com::sun::star::uno::RuntimeException);
+        const com::sun::star::uno::Sequence< double >& aXValues,
+        const com::sun::star::uno::Sequence< double >& aYValues )
+        throw (com::sun::star::uno::RuntimeException);
 
     virtual double SAL_CALL getCurveValue( double x )
-        throw (::com::sun::star::lang::IllegalArgumentException,
-               ::com::sun::star::uno::RuntimeException);
+        throw (com::sun::star::lang::IllegalArgumentException,
+               com::sun::star::uno::RuntimeException);
 
-    virtual ::com::sun::star::uno::Sequence< ::com::sun::star::geometry::RealPoint2D > SAL_CALL getCurveValues(
+    virtual ::com::sun::star::uno::Sequence< com::sun::star::geometry::RealPoint2D > SAL_CALL getCurveValues(
         double min,
         double max,
-        ::sal_Int32 nPointCount,
-        const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XScaling >& xScalingX,
-        const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XScaling >& xScalingY,
-        ::sal_Bool bMaySkipPointsInCalculation )
-        throw (::com::sun::star::lang::IllegalArgumentException,
-               ::com::sun::star::uno::RuntimeException);
+        sal_Int32 nPointCount,
+        const com::sun::star::uno::Reference< com::sun::star::chart2::XScaling >& xScalingX,
+        const com::sun::star::uno::Reference< com::sun::star::chart2::XScaling >& xScalingY,
+        sal_Bool bMaySkipPointsInCalculation )
+        throw (com::sun::star::lang::IllegalArgumentException,
+               com::sun::star::uno::RuntimeException);
 
-    double m_fSlope;
-    double m_fIntercept;
     std::vector<double> mResult;
 };
 
diff --git a/chart2/source/inc/RegressionCurveCalculator.hxx b/chart2/source/inc/RegressionCurveCalculator.hxx
index 0829543..a8cf124 100644
--- a/chart2/source/inc/RegressionCurveCalculator.hxx
+++ b/chart2/source/inc/RegressionCurveCalculator.hxx
@@ -28,64 +28,71 @@ namespace chart
 {
 
 class RegressionCurveCalculator : public
-    ::cppu::WeakImplHelper1< ::com::sun::star::chart2::XRegressionCurveCalculator >
+    cppu::WeakImplHelper1< com::sun::star::chart2::XRegressionCurveCalculator >
 {
 public:
     RegressionCurveCalculator();
     virtual ~RegressionCurveCalculator();
 
     static bool isLinearScaling(
-        const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XScaling > & xScaling );
+        const com::sun::star::uno::Reference< com::sun::star::chart2::XScaling >& xScaling );
+
     static bool isLogarithmicScaling(
-        const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XScaling > & xScaling );
+        const com::sun::star::uno::Reference< com::sun::star::chart2::XScaling >& xScaling );
 
 protected:
     virtual OUString ImplGetRepresentation(
-        const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& xNumFormatter,
-        ::sal_Int32 nNumberFormatKey ) const = 0;
+        const com::sun::star::uno::Reference< com::sun::star::util::XNumberFormatter >& xNumFormatter,
+        sal_Int32 nNumberFormatKey ) const = 0;
 
     OUString getFormattedString(
-        const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& xNumFormatter,
-        ::sal_Int32 nNumberFormatKey,
+        const com::sun::star::uno::Reference< com::sun::star::util::XNumberFormatter >& xNumFormatter,
+        sal_Int32 nNumberFormatKey,
         double fNumber ) const;
 
     double m_fCorrelationCoeffitient;
 
-    sal_Int32       mDegree;
-    double          mIntercept;
-    sal_Int32       mPeriod;
+    sal_Int32 mDegree;
+    sal_Bool  mForceIntercept;
+    double    mInterceptValue;
+    sal_Int32 mPeriod;
 
     // ____ XRegressionCurveCalculator ____
     virtual void SAL_CALL setRegressionProperties(
         sal_Int32 aDegree,
-        double aIntercept,
+        sal_Bool  aForceIntercept,
+        double    aInterceptValue,
         sal_Int32 aPeriod);
 
     virtual void SAL_CALL recalculateRegression(
-        const ::com::sun::star::uno::Sequence< double >& aXValues,
-        const ::com::sun::star::uno::Sequence< double >& aYValues )
-        throw (::com::sun::star::uno::RuntimeException) = 0;
+        const com::sun::star::uno::Sequence< double >& aXValues,
+        const com::sun::star::uno::Sequence< double >& aYValues )
+        throw (com::sun::star::uno::RuntimeException) = 0;
+
     virtual double SAL_CALL getCurveValue( double x )
-        throw (::com::sun::star::lang::IllegalArgumentException,
-               ::com::sun::star::uno::RuntimeException) = 0;
+        throw (com::sun::star::lang::IllegalArgumentException,
+               com::sun::star::uno::RuntimeException) = 0;
 
-    virtual ::com::sun::star::uno::Sequence< ::com::sun::star::geometry::RealPoint2D > SAL_CALL getCurveValues(
+    virtual com::sun::star::uno::Sequence< com::sun::star::geometry::RealPoint2D > SAL_CALL getCurveValues(
         double min,
         double max,
-        ::sal_Int32 nPointCount,
-        const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XScaling >& xScalingX,
-        const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XScaling >& xScalingY,
-        ::sal_Bool bMaySkipPointsInCalculation )
-        throw (::com::sun::star::lang::IllegalArgumentException,
-               ::com::sun::star::uno::RuntimeException);
+        sal_Int32 nPointCount,
+        const com::sun::star::uno::Reference< com::sun::star::chart2::XScaling >& xScalingX,
+        const com::sun::star::uno::Reference< com::sun::star::chart2::XScaling >& xScalingY,
+        sal_Bool bMaySkipPointsInCalculation )
+        throw (com::sun::star::lang::IllegalArgumentException,
+               com::sun::star::uno::RuntimeException);
+
     virtual double SAL_CALL getCorrelationCoefficient()
-        throw (::com::sun::star::uno::RuntimeException);
+        throw (com::sun::star::uno::RuntimeException);
+
     virtual OUString SAL_CALL getRepresentation()
-        throw (::com::sun::star::uno::RuntimeException);
+        throw (com::sun::star::uno::RuntimeException);
+
     virtual OUString SAL_CALL getFormattedRepresentation(
-        const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier >& xNumFmtSupplier,
-        ::sal_Int32 nNumberFormatKey )
-        throw (::com::sun::star::uno::RuntimeException);
+        const com::sun::star::uno::Reference< com::sun::star::util::XNumberFormatsSupplier >& xNumFmtSupplier,
+        sal_Int32 nNumberFormatKey )
+        throw (com::sun::star::uno::RuntimeException);
 };
 
 } //  namespace chart
diff --git a/chart2/source/tools/PolynomialRegressionCurveCalculator.cxx b/chart2/source/tools/PolynomialRegressionCurveCalculator.cxx
index f5717ab..0d3d4d1 100644
--- a/chart2/source/tools/PolynomialRegressionCurveCalculator.cxx
+++ b/chart2/source/tools/PolynomialRegressionCurveCalculator.cxx
@@ -25,7 +25,7 @@
 #include <rtl/ustrbuf.hxx>
 #include "gauss.hxx"
 
-using namespace ::com::sun::star;
+using namespace com::sun::star;
 
 
 namespace chart
@@ -43,66 +43,76 @@ void SAL_CALL PolynomialRegressionCurveCalculator::recalculateRegression(
     const uno::Sequence< double >& aYValues )
     throw (uno::RuntimeException)
 {
-    ::rtl::math::setNan( & m_fCorrelationCoeffitient );
+    rtl::math::setNan(&m_fCorrelationCoeffitient);
 
     RegressionCalculationHelper::tDoubleVectorPair aValues(
         RegressionCalculationHelper::cleanup( aXValues, aYValues, RegressionCalculationHelper::isValid()));
 
-    const double EPSILON( 1.0e-20 );
-
-    int aNumberOfPolyElements = mDegree + 1;
-    int aNumberOfPowers = 2 * aNumberOfPolyElements - 1;
+    int aNoElements = mForceIntercept ? mDegree : mDegree + 1;
+    int aNumberOfPowers = 2 * aNoElements - 1;
 
     std::vector<double> aPowers;
     aPowers.resize(aNumberOfPowers, 0.0);
 
-    int aNumberOfColumns = aNumberOfPolyElements;
-    int aNumberOfRows = aNumberOfPolyElements + 1;
+    int aNoColumns = aNoElements;
+    int aNoRows    = aNoElements + 1;
 
     std::vector<double> aMatrix;
-    aMatrix.resize(aNumberOfColumns*aNumberOfRows, 0.0);
+    aMatrix.resize(aNoColumns * aNoRows, 0.0);
 
-    const size_t aSizeOfValues = aValues.first.size();
+    const size_t aNoValues = aValues.first.size();
 
     double yAverage = 0.0;
 
-    aPowers[0] += aSizeOfValues;
-
-    for( size_t i = 0; i < aSizeOfValues; ++i )
+    for( size_t i = 0; i < aNoValues; ++i )
     {
         double x = aValues.first[i];
         double y = aValues.second[i];
 
-        for (int j = 1; j < aNumberOfPowers; j++) {
-            aPowers[j] += pow(x, j);
+        for (int j = 0; j < aNumberOfPowers; j++)
+        {
+            if (mForceIntercept)
+                aPowers[j] += std::pow(x, j + 2);
+            else
+                aPowers[j] += std::pow(x, j);
         }
 
-        for (int j = 0; j < aNumberOfPolyElements; j++) {
-            aMatrix[j * aNumberOfRows + aNumberOfPolyElements] += pow(x, j) * y;
+        for (int j = 0; j < aNoElements; j++)
+        {
+            if (mForceIntercept)
+                aMatrix[j * aNoRows + aNoElements] += std::pow(x, j + 1) * ( y - mInterceptValue );
+            else
+                aMatrix[j * aNoRows + aNoElements] += std::pow(x, j) * y;
         }
 
         yAverage += y;
     }
 
-    yAverage = yAverage / aSizeOfValues;
+    yAverage = yAverage / aNoValues;
 
-    for (int y = 0; y < aNumberOfPolyElements; y++) {
-        for (int x = 0; x < aNumberOfPolyElements; x++) {
-            aMatrix[y * aNumberOfRows + x] = aPowers[y + x];
+    for (int y = 0; y < aNoElements; y++)
+    {
+        for (int x = 0; x < aNoElements; x++)
+        {
+            aMatrix[y * aNoRows + x] = aPowers[y + x];
         }
     }
 
     mResult.clear();
-    mResult.resize(aNumberOfPolyElements, 0.0);
+    mResult.resize(aNoElements, 0.0);
 
-    solve(aMatrix, aNumberOfColumns, aNumberOfRows, mResult, EPSILON);
+    solve(aMatrix, aNoColumns, aNoRows, mResult, 1.0e-20);
 
-    // Calculate correlation coeffitient
+    // Set intercept value if force intercept is enabled
+    if (mForceIntercept) {
+        mResult.insert( mResult.begin(), mInterceptValue );
+    }
 
+    // Calculate correlation coeffitient
     double aSumError = 0.0;
     double aSumTotal = 0.0;
 
-    for( size_t i = 0; i < aSizeOfValues; ++i )
+    for( size_t i = 0; i < aNoValues; ++i )
     {
         double x = aValues.first[i];
         double yActual = aValues.second[i];
@@ -111,8 +121,11 @@ void SAL_CALL PolynomialRegressionCurveCalculator::recalculateRegression(
         aSumError += (yActual - yPredicted) * (yActual - yPredicted);
     }
 
-    m_fCorrelationCoeffitient = sqrt(1 - (aSumError / aSumTotal));
-
+    double aRSquared = 1.0 - (aSumError / aSumTotal);
+    if (aRSquared > 0.0)
+        m_fCorrelationCoeffitient = std::sqrt(aRSquared);
+    else
+        m_fCorrelationCoeffitient = 0.0;
 }
 
 double SAL_CALL PolynomialRegressionCurveCalculator::getCurveValue( double x )
@@ -130,7 +143,7 @@ double SAL_CALL PolynomialRegressionCurveCalculator::getCurveValue( double x )
     fResult = 0.0;
     for (size_t i = 0; i<mResult.size(); i++)
     {
-        fResult += mResult[i]*pow(x,i);
+        fResult += mResult[i] * std::pow(x, i);
     }
     return fResult;
 }
@@ -149,17 +162,34 @@ uno::Sequence< geometry::RealPoint2D > SAL_CALL PolynomialRegressionCurveCalcula
 
 OUString PolynomialRegressionCurveCalculator::ImplGetRepresentation(
     const uno::Reference< util::XNumberFormatter >& xNumFormatter,
-    ::sal_Int32 nNumberFormatKey ) const
+    sal_Int32 nNumberFormatKey ) const
 {
     OUStringBuffer aBuf( "f(x) = ");
 
-    for (int i=mResult.size()-1; i>=0; i--)
+    int aLastIndex = mResult.size() - 1;
+    for (int i = aLastIndex; i >= 0; i--)
     {
-        aBuf.append(getFormattedString( xNumFormatter, nNumberFormatKey, mResult[i] ));
-        if(i > 0) {
+        double aValue = mResult[i];
+        if (aValue == 0.0)
+        {
+            continue;
+        }
+        else if (aValue < 0.0)
+        {
+            aBuf.appendAscii( " - " );
+        }
+        else
+        {
+            if (i != aLastIndex)
+                aBuf.appendAscii( " + " );
+        }
+
+        aBuf.append( getFormattedString( xNumFormatter, nNumberFormatKey, std::abs( aValue ) ) );
+
+        if(i > 0)
+        {
             aBuf.appendAscii( "x^" );
             aBuf.append(i);
-            aBuf.append(" + ");
         }
     }
 
diff --git a/chart2/source/tools/RegressionCurveCalculator.cxx b/chart2/source/tools/RegressionCurveCalculator.cxx
index 461e504..8337d95 100644
--- a/chart2/source/tools/RegressionCurveCalculator.cxx
+++ b/chart2/source/tools/RegressionCurveCalculator.cxx
@@ -37,13 +37,14 @@ namespace chart
 {
 
 RegressionCurveCalculator::RegressionCurveCalculator() :
-        m_fCorrelationCoeffitient( 0.0 ),
+        m_fCorrelationCoeffitient(0.0),
         mDegree(2),
-        mIntercept(0.0),
+        mForceIntercept(false),
+        mInterceptValue(0.0),
         mPeriod(2)
 {
-    ::rtl::math::setNan( &m_fCorrelationCoeffitient );
-    ::rtl::math::setNan( &mIntercept );
+    rtl::math::setNan( &m_fCorrelationCoeffitient );
+    rtl::math::setNan( &mInterceptValue );
 }
 
 RegressionCurveCalculator::~RegressionCurveCalculator()
@@ -70,17 +71,19 @@ bool RegressionCurveCalculator::isLogarithmicScaling(
 
 void RegressionCurveCalculator::setRegressionProperties(
     sal_Int32   aDegree,
-    double      aIntercept,
+    sal_Bool    aForceIntercept,
+    double      aInterceptValue,
     sal_Int32   aPeriod)
 {
-    mDegree    = aDegree;
-    mIntercept = aIntercept;
-    mPeriod    = aPeriod;
+    mDegree = aDegree;
+    mForceIntercept = aForceIntercept;
+    mInterceptValue = aInterceptValue;
+    mPeriod  = aPeriod;
 }
 
 OUString RegressionCurveCalculator::getFormattedString(
     const Reference< util::XNumberFormatter >& xNumFormatter,
-    ::sal_Int32 nNumberFormatKey,
+    sal_Int32 nNumberFormatKey,
     double fNumber ) const
 {
     OUString aResult;
@@ -97,9 +100,8 @@ Sequence< geometry::RealPoint2D > SAL_CALL RegressionCurveCalculator::getCurveVa
     double min, double max, ::sal_Int32 nPointCount,
     const Reference< chart2::XScaling >& xScalingX,
     const Reference< chart2::XScaling >& /* xScalingY */,
-    ::sal_Bool /* bMaySkipPointsInCalculation */ )
-    throw (lang::IllegalArgumentException,
-           uno::RuntimeException)
+    sal_Bool /* bMaySkipPointsInCalculation */ )
+        throw (lang::IllegalArgumentException, uno::RuntimeException)
 {
     if( nPointCount < 2 )
         throw lang::IllegalArgumentException();
@@ -148,7 +150,7 @@ OUString SAL_CALL RegressionCurveCalculator::getRepresentation()
 
 OUString SAL_CALL RegressionCurveCalculator::getFormattedRepresentation(
     const Reference< util::XNumberFormatsSupplier > & xNumFmtSupplier,
-    ::sal_Int32 nNumberFormatKey )
+    sal_Int32 nNumberFormatKey )
     throw (uno::RuntimeException)
 {
     // create and prepare a number formatter
diff --git a/chart2/source/tools/RegressionCurveModel.cxx b/chart2/source/tools/RegressionCurveModel.cxx
index cd9b143..c98d592 100644
--- a/chart2/source/tools/RegressionCurveModel.cxx
+++ b/chart2/source/tools/RegressionCurveModel.cxx
@@ -60,7 +60,9 @@ enum
     PROPERTY_DEGREE,
     PROPERTY_PERIOD,
     PROPERTY_EXTRAPOLATE_FORWARD,
-    PROPERTY_EXTRAPOLATE_BACKWARD
+    PROPERTY_EXTRAPOLATE_BACKWARD,
+    PROPERTY_FORCE_INTERCEPT,
+    PROPERTY_INTERCEPT_VALUE
 };
 
 void lcl_AddPropertiesToVector(
@@ -93,6 +95,20 @@ void lcl_AddPropertiesToVector(
                 ::getCppuType( reinterpret_cast< const double* >(0) ),
                 beans::PropertyAttribute::BOUND |
                 beans::PropertyAttribute::MAYBEDEFAULT ));
+
+    rOutProperties.push_back(
+        Property( "ForceIntercept",
+                  PROPERTY_FORCE_INTERCEPT,
+                  ::getBooleanCppuType(),
+                  beans::PropertyAttribute::BOUND
+                  | beans::PropertyAttribute::MAYBEDEFAULT ));
+
+    rOutProperties.push_back(
+        Property( "InterceptValue",
+                PROPERTY_INTERCEPT_VALUE,
+                ::getCppuType( reinterpret_cast< const double* >(0) ),
+                beans::PropertyAttribute::BOUND |
+                beans::PropertyAttribute::MAYBEDEFAULT ));
 }
 
 struct StaticXXXDefaults_Initializer
diff --git a/chart2/source/view/charttypes/VSeriesPlotter.cxx b/chart2/source/view/charttypes/VSeriesPlotter.cxx
index 5c85e43..e8b4fa9 100644
--- a/chart2/source/view/charttypes/VSeriesPlotter.cxx
+++ b/chart2/source/view/charttypes/VSeriesPlotter.cxx
@@ -985,8 +985,9 @@ void VSeriesPlotter::createRegressionCurvesShapes( VDataSeries& rVDataSeries
         sal_Int32 aPeriod = 2;
         double aExtrapolateForward = 0.0;
         double aExtrapolateBackward = 0.0;
-        double aIntercept;
-        rtl::math::setNan(&aIntercept);
+        sal_Bool aForceIntercept = false;
+        double aInterceptValue;
+        rtl::math::setNan(&aInterceptValue);
 
         if ( xProperties.is() )
         {
@@ -994,10 +995,12 @@ void VSeriesPlotter::createRegressionCurvesShapes( VDataSeries& rVDataSeries
             xProperties->getPropertyValue( "MovingAveragePeriod") >>= aPeriod;
             xProperties->getPropertyValue( "ExtrapolateForward") >>= aExtrapolateForward;
             xProperties->getPropertyValue( "ExtrapolateBackward") >>= aExtrapolateBackward;
+            xProperties->getPropertyValue( "ForceIntercept") >>= aForceIntercept;
+            if (aForceIntercept)
+                xProperties->getPropertyValue( "InterceptValue") >>= aInterceptValue;
         }
 
-        uno::Reference< XRegressionCurveCalculator > xRegressionCurveCalculator(
-            aCurveList[nN]->getCalculator() );
+        uno::Reference< XRegressionCurveCalculator > xRegressionCurveCalculator( aCurveList[nN]->getCalculator() );
 
         if( ! xRegressionCurveCalculator.is())
             continue;
@@ -1009,7 +1012,7 @@ void VSeriesPlotter::createRegressionCurvesShapes( VDataSeries& rVDataSeries
         fMaxX += aExtrapolateForward;
         fMinX -= aExtrapolateBackward;
 
-        xRegressionCurveCalculator->setRegressionProperties(aDegree, aIntercept, aPeriod);
+        xRegressionCurveCalculator->setRegressionProperties(aDegree, aForceIntercept, aInterceptValue, aPeriod);
         xRegressionCurveCalculator->recalculateRegression( rVDataSeries.getAllX(), rVDataSeries.getAllY() );
 
         sal_Int32 nRegressionPointCount = 100; //@todo find a more optimal solution if more complicated curve types are introduced
diff --git a/chart2/source/view/main/ChartItemPool.cxx b/chart2/source/view/main/ChartItemPool.cxx
index abb05a2..60a9ba4 100644
--- a/chart2/source/view/main/ChartItemPool.cxx
+++ b/chart2/source/view/main/ChartItemPool.cxx
@@ -74,7 +74,7 @@ ChartItemPool::ChartItemPool():
     ppPoolDefaults[SCHATTR_STAT_INDICATE            - SCHATTR_START] = new SvxChartIndicateItem (CHINDICATE_NONE, SCHATTR_STAT_INDICATE);
     ppPoolDefaults[SCHATTR_STAT_RANGE_POS           - SCHATTR_START] = new SfxStringItem (SCHATTR_STAT_RANGE_POS, String());
     ppPoolDefaults[SCHATTR_STAT_RANGE_NEG           - SCHATTR_START] = new SfxStringItem (SCHATTR_STAT_RANGE_NEG, String());
-    ppPoolDefaults[SCHATTR_STAT_ERRORBAR_TYPE - SCHATTR_START] = new SfxBoolItem(SCHATTR_STAT_ERRORBAR_TYPE, true);
+    ppPoolDefaults[SCHATTR_STAT_ERRORBAR_TYPE       - SCHATTR_START] = new SfxBoolItem(SCHATTR_STAT_ERRORBAR_TYPE, true);
 
     ppPoolDefaults[SCHATTR_STYLE_DEEP     - SCHATTR_START] = new SfxBoolItem (SCHATTR_STYLE_DEEP, 0);
     ppPoolDefaults[SCHATTR_STYLE_3D       - SCHATTR_START] = new SfxBoolItem (SCHATTR_STYLE_3D, 0);
@@ -83,7 +83,7 @@ ChartItemPool::ChartItemPool():
     ppPoolDefaults[SCHATTR_STYLE_LINES    - SCHATTR_START] = new SfxBoolItem (SCHATTR_STYLE_LINES, 0);
     ppPoolDefaults[SCHATTR_STYLE_PERCENT  - SCHATTR_START] = new SfxBoolItem (SCHATTR_STYLE_PERCENT, 0);
     ppPoolDefaults[SCHATTR_STYLE_STACKED  - SCHATTR_START] = new SfxBoolItem (SCHATTR_STYLE_STACKED, 0);
-    ppPoolDefaults[SCHATTR_STYLE_SPLINES    - SCHATTR_START] = new SfxInt32Item (SCHATTR_STYLE_SPLINES, 0); //Bug: was Bool! test ->Fileformat (touches only 5's)
+    ppPoolDefaults[SCHATTR_STYLE_SPLINES  - SCHATTR_START] = new SfxInt32Item (SCHATTR_STYLE_SPLINES, 0); //Bug: was Bool! test ->Fileformat (touches only 5's)
     ppPoolDefaults[SCHATTR_STYLE_SYMBOL   - SCHATTR_START] = new SfxInt32Item (SCHATTR_STYLE_SYMBOL, 0);
     ppPoolDefaults[SCHATTR_STYLE_SHAPE    - SCHATTR_START] = new SfxInt32Item (SCHATTR_STYLE_SHAPE, 0);
 
@@ -152,11 +152,11 @@ ChartItemPool::ChartItemPool():
     ppPoolDefaults[SCHATTR_REGRESSION_TYPE                  - SCHATTR_START] = new SvxChartRegressItem  (CHREGRESS_NONE, SCHATTR_REGRESSION_TYPE);
     ppPoolDefaults[SCHATTR_REGRESSION_SHOW_EQUATION         - SCHATTR_START] = new SfxBoolItem(SCHATTR_REGRESSION_SHOW_EQUATION, 0);
     ppPoolDefaults[SCHATTR_REGRESSION_SHOW_COEFF            - SCHATTR_START] = new SfxBoolItem(SCHATTR_REGRESSION_SHOW_COEFF, 0);
-    ppPoolDefaults[SCHATTR_REGRESSION_DEGREE                - SCHATTR_START] = new SfxInt32Item( SCHATTR_REGRESSION_DEGREE, 2 );
-    ppPoolDefaults[SCHATTR_REGRESSION_PERIOD                - SCHATTR_START] = new SfxInt32Item( SCHATTR_REGRESSION_PERIOD, 2 );
-    ppPoolDefaults[SCHATTR_REGRESSION_EXTRAPOLATE_FORWARD   - SCHATTR_START] = new SvxDoubleItem( 0.0, SCHATTR_REGRESSION_EXTRAPOLATE_FORWARD );
-    ppPoolDefaults[SCHATTR_REGRESSION_EXTRAPOLATE_BACKWARD  - SCHATTR_START] = new SvxDoubleItem( 0.0, SCHATTR_REGRESSION_EXTRAPOLATE_BACKWARD );
-    ppPoolDefaults[SCHATTR_REGRESSION_SET_INTERCEPT         - SCHATTR_START] = new SfxBoolItem( SCHATTR_REGRESSION_SET_INTERCEPT, false );
+    ppPoolDefaults[SCHATTR_REGRESSION_DEGREE                - SCHATTR_START] = new SfxInt32Item(SCHATTR_REGRESSION_DEGREE, 2);
+    ppPoolDefaults[SCHATTR_REGRESSION_PERIOD                - SCHATTR_START] = new SfxInt32Item(SCHATTR_REGRESSION_PERIOD, 2);
+    ppPoolDefaults[SCHATTR_REGRESSION_EXTRAPOLATE_FORWARD   - SCHATTR_START] = new SvxDoubleItem(0.0, SCHATTR_REGRESSION_EXTRAPOLATE_FORWARD);
+    ppPoolDefaults[SCHATTR_REGRESSION_EXTRAPOLATE_BACKWARD  - SCHATTR_START] = new SvxDoubleItem(0.0, SCHATTR_REGRESSION_EXTRAPOLATE_BACKWARD);
+    ppPoolDefaults[SCHATTR_REGRESSION_SET_INTERCEPT         - SCHATTR_START] = new SfxBoolItem(SCHATTR_REGRESSION_SET_INTERCEPT, sal_False);
     ppPoolDefaults[SCHATTR_REGRESSION_INTERCEPT_VALUE       - SCHATTR_START] = new SvxDoubleItem( 0.0, SCHATTR_REGRESSION_INTERCEPT_VALUE);
 
     /**************************************************************************
diff --git a/offapi/com/sun/star/chart2/XRegressionCurveCalculator.idl b/offapi/com/sun/star/chart2/XRegressionCurveCalculator.idl
index b8831e3..9d2d3aa 100644
--- a/offapi/com/sun/star/chart2/XRegressionCurveCalculator.idl
+++ b/offapi/com/sun/star/chart2/XRegressionCurveCalculator.idl
@@ -38,7 +38,8 @@ interface XRegressionCurveCalculator : com::sun::star::uno::XInterface
 {
 
     void setRegressionProperties( [in] long degree,
-                                  [in] double intercept,
+                                  [in] boolean forceIntercept,
+                                  [in] double interceptValue,
                                   [in] long period);
 
     /** recalculates the parameters of the internal regression curve according to


More information about the Libreoffice-commits mailing list