[Libreoffice-commits] core.git: 7 commits - chart2/source chart2/uiconfig include/oox include/xmloff oox/source sc/source xmloff/source

Tomaž Vajngerl quikee at gmail.com
Sun Nov 24 10:44:25 PST 2013


 chart2/source/controller/dialogs/res_Trendline.cxx                       |   56 -
 chart2/source/controller/dialogs/res_Trendline.hxx                       |    1 
 chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx |  393 ++--------
 chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx      |  207 +----
 chart2/source/inc/chartview/ChartSfxItemIds.hxx                          |    3 
 chart2/source/tools/RegressionCurveHelper.cxx                            |   12 
 chart2/source/tools/RegressionCurveModel.cxx                             |    9 
 chart2/source/view/main/ChartItemPool.cxx                                |    3 
 chart2/uiconfig/ui/tp_Trendline.ui                                       |   45 -
 include/oox/drawingml/chart/seriesmodel.hxx                              |    2 
 include/xmloff/xmltoken.hxx                                              |    1 
 oox/source/drawingml/chart/seriesconverter.cxx                           |    2 
 oox/source/export/chartexport.cxx                                        |   28 
 oox/source/token/properties.txt                                          |    1 
 sc/source/filter/excel/xechart.cxx                                       |   11 
 sc/source/filter/excel/xichart.cxx                                       |   22 
 sc/source/filter/inc/xechart.hxx                                         |    2 
 sc/source/filter/inc/xichart.hxx                                         |    5 
 sc/source/filter/inc/xlchart.hxx                                         |    1 
 xmloff/source/chart/PropertyMap.hxx                                      |    1 
 xmloff/source/core/xmltoken.cxx                                          |    1 
 21 files changed, 346 insertions(+), 460 deletions(-)

New commits:
commit 288719571eb617613ba9724f394a257a17d43a81
Author: Tomaž Vajngerl <quikee at gmail.com>
Date:   Sun Nov 24 19:40:27 2013 +0100

    Support regression curve name in old binary XLS XP/2k/2k3 format.
    
    Change-Id: Ie6f2fd3cce70e4789805e788846d3beb64620a4b

diff --git a/sc/source/filter/excel/xechart.cxx b/sc/source/filter/excel/xechart.cxx
index 26deac3..f68bf67 100644
--- a/sc/source/filter/excel/xechart.cxx
+++ b/sc/source/filter/excel/xechart.cxx
@@ -972,6 +972,11 @@ sal_uInt16 XclExpChSourceLink::ConvertDataSequence( Reference< XDataSequence > x
     return ulimit_cast< sal_uInt16 >( nValueCount, EXC_CHDATAFORMAT_MAXPOINTCOUNT );
 }
 
+void XclExpChSourceLink::ConvertString( OUString aString )
+{
+    mxString = XclExpStringHelper::CreateString( GetRoot(), aString, EXC_STR_FORCEUNICODE | EXC_STR_8BITLENGTH | EXC_STR_SEPARATEFORMATS );
+}
+
 sal_uInt16 XclExpChSourceLink::ConvertStringSequence( const Sequence< Reference< XFormattedString > >& rStringSeq )
 {
     mxString.reset();
@@ -2049,10 +2054,16 @@ bool XclExpChSeries::ConvertStockSeries( XDataSeriesRef xDataSeries,
 bool XclExpChSeries::ConvertTrendLine( const XclExpChSeries& rParent, Reference< XRegressionCurve > xRegCurve )
 {
     InitFromParent( rParent );
+
     mxTrendLine.reset( new XclExpChSerTrendLine( GetChRoot() ) );
     bool bOk = mxTrendLine->Convert( xRegCurve, mnSeriesIdx );
     if( bOk )
     {
+        OUString aName;
+        ScfPropertySet aProperties( xRegCurve );
+        aProperties.GetProperty(aName, EXC_CHPROP_CURVENAME);
+        mxTitleLink->ConvertString(aName);
+
         mxSeriesFmt = mxTrendLine->GetDataFormat();
         GetChartData().SetDataLabel( mxTrendLine->GetDataLabel() );
     }
diff --git a/sc/source/filter/excel/xichart.cxx b/sc/source/filter/excel/xichart.cxx
index d99c12c..a7103a2 100644
--- a/sc/source/filter/excel/xichart.cxx
+++ b/sc/source/filter/excel/xichart.cxx
@@ -1645,6 +1645,7 @@ Reference< XRegressionCurve > XclImpChSerTrendLine::CreateRegressionCurve() cons
         ScfPropertySet aPropSet( xRegCurve );
         mxDataFmt->ConvertLine( aPropSet, EXC_CHOBJTYPE_TRENDLINE );
 
+        aPropSet.SetProperty(EXC_CHPROP_CURVENAME, maTrendLineName);
         aPropSet.SetProperty(EXC_CHPROP_POLYNOMIAL_DEGREE, static_cast<sal_Int32> (maData.mnOrder) );
         aPropSet.SetProperty(EXC_CHPROP_MOVING_AVERAGE_PERIOD, static_cast<sal_Int32> (maData.mnOrder) );
         aPropSet.SetProperty(EXC_CHPROP_EXTRAPOLATE_FORWARD, maData.mfForecastFor);
@@ -1911,9 +1912,17 @@ void XclImpChSeries::FinalizeDataFormats()
 
         // copy series formatting to child objects
         for( XclImpChSerTrendLineList::iterator aLIt = maTrendLines.begin(), aLEnd = maTrendLines.end(); aLIt != aLEnd; ++aLIt )
-            (*aLIt)->SetDataFormat( mxSeriesFmt );
+        {
+            (*aLIt)->SetDataFormat(mxSeriesFmt);
+            if (mxTitleLink->HasString())
+            {
+                (*aLIt)->SetTrendlineName(mxTitleLink->GetString());
+            }
+        }
         for( XclImpChSerErrorBarMap::iterator aMIt = maErrorBars.begin(), aMEnd = maErrorBars.end(); aMIt != aMEnd; ++aMIt )
+        {
             aMIt->second->SetSeriesData( mxValueLink, mxSeriesFmt );
+        }
     }
     else if( XclImpChTypeGroup* pTypeGroup = GetChartData().GetTypeGroup( mnGroupIdx ).get() )
     {
@@ -2155,7 +2164,9 @@ void XclImpChSeries::ConvertTrendLines( Reference< XDataSeries > xDataSeries ) c
             {
                 Reference< XRegressionCurve > xRegCurve = (*aIt)->CreateRegressionCurve();
                 if( xRegCurve.is() )
+                {
                     xRegCurveCont->addRegressionCurve( xRegCurve );
+                }
             }
             catch( Exception& )
             {
diff --git a/sc/source/filter/inc/xechart.hxx b/sc/source/filter/inc/xechart.hxx
index 78f2fef..6884ddd1 100644
--- a/sc/source/filter/inc/xechart.hxx
+++ b/sc/source/filter/inc/xechart.hxx
@@ -406,6 +406,8 @@ public:
 public:
     explicit            XclExpChSourceLink( const XclExpChRoot& rRoot, sal_uInt8 nDestType );
 
+
+    void                ConvertString( OUString aString );
     /** Converts the passed source link, returns the number of linked values. */
     sal_uInt16          ConvertDataSequence( XDataSequenceRef xDataSeq, bool bSplitToColumns, sal_uInt16 nDefCount = 0 );
     /** Converts the passed sequence of formatted string objects, returns leading font index. */
diff --git a/sc/source/filter/inc/xichart.hxx b/sc/source/filter/inc/xichart.hxx
index 8ce7d03..04f48c7 100644
--- a/sc/source/filter/inc/xichart.hxx
+++ b/sc/source/filter/inc/xichart.hxx
@@ -736,11 +736,14 @@ public:
     /** Sets formatting information for the trend line. */
     inline void         SetDataFormat( XclImpChDataFormatRef xDataFmt ) { mxDataFmt = xDataFmt; }
 
+    inline void         SetTrendlineName( OUString aTrendlineName) { maTrendLineName = aTrendlineName; }
+
     /** Creates an API object representing this trend line. */
     XRegressionCurveRef CreateRegressionCurve() const;
 
 private:
-    XclChSerTrendLine   maData;             /// Contents of the CHSERTRENDLINE record.
+    OUString  maTrendLineName;
+    XclChSerTrendLine maData;               /// Contents of the CHSERTRENDLINE record.
     XclImpChDataFormatRef mxDataFmt;        /// Formatting settings of the trend line.
 };
 
diff --git a/sc/source/filter/inc/xlchart.hxx b/sc/source/filter/inc/xlchart.hxx
index 4354b5c..408d6d9 100644
--- a/sc/source/filter/inc/xlchart.hxx
+++ b/sc/source/filter/inc/xlchart.hxx
@@ -68,6 +68,7 @@ class XclRoot;
 #define EXC_CHPROP_CROSSOVERPOSITION        "CrossoverPosition"
 #define EXC_CHPROP_CROSSOVERVALUE           "CrossoverValue"
 #define EXC_CHPROP_CURVESTYLE               "CurveStyle"
+#define EXC_CHPROP_CURVENAME                "CurveName"
 #define EXC_CHPROP_D3DCAMERAGEOMETRY        "D3DCameraGeometry"
 #define EXC_CHPROP_D3DSCENEAMBIENTCOLOR     "D3DSceneAmbientColor"
 #define EXC_CHPROP_D3DSCENELIGHTON1         "D3DSceneLightOn1"
commit fdb6711835ceab636222d8ec5264d008c2621748
Author: Tomaž Vajngerl <quikee at gmail.com>
Date:   Sat Nov 23 21:26:05 2013 +0100

    Fix detection of force intercept in XLS 97/2000/XP format.
    
    NaN value indicates if the force intercept is enabled or not.
    
    Change-Id: I51d33a6e04a4b5832f241e7ae7ee6d2fbb32ea9b

diff --git a/sc/source/filter/excel/xichart.cxx b/sc/source/filter/excel/xichart.cxx
index 51e00c1..d99c12c 100644
--- a/sc/source/filter/excel/xichart.cxx
+++ b/sc/source/filter/excel/xichart.cxx
@@ -195,13 +195,6 @@ 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 =====================================================================
@@ -1657,7 +1650,7 @@ 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);
+        sal_Bool bForceIntercept = !rtl::math::isNan(maData.mfIntercept);
         aPropSet.SetProperty(EXC_CHPROP_FORCE_INTERCEPT, bForceIntercept);
         if (bForceIntercept)
         {
commit c86aed38b67ee5d1b842a7765e363015aea22fcc
Author: Tomaž Vajngerl <quikee at gmail.com>
Date:   Sat Nov 23 20:30:49 2013 +0100

    Support regression curve name in OOXML (import & export).
    
    Change-Id: I847e0df4f160e4b5078961a0e77c1e1e3fff9bd4

diff --git a/include/oox/drawingml/chart/seriesmodel.hxx b/include/oox/drawingml/chart/seriesmodel.hxx
index c374e52..1d426cb 100644
--- a/include/oox/drawingml/chart/seriesmodel.hxx
+++ b/include/oox/drawingml/chart/seriesmodel.hxx
@@ -148,7 +148,7 @@ struct TrendlineModel
 
     ShapeRef            mxShapeProp;        /// Trendline formatting.
     TrendlineLabelRef   mxLabel;            /// Trendline label text object.
-    OUString     maName;             /// User-defined name of the trendline.
+    OUString            maName;             /// User-defined name of the trendline.
     OptValue< double >  mfBackward;         /// Size of trendline before first data point.
     OptValue< double >  mfForward;          /// Size of trendline behind last data point.
     OptValue< double >  mfIntercept;        /// Crossing point with Y axis.
diff --git a/oox/source/drawingml/chart/seriesconverter.cxx b/oox/source/drawingml/chart/seriesconverter.cxx
index 1b56fef..5c85d99 100644
--- a/oox/source/drawingml/chart/seriesconverter.cxx
+++ b/oox/source/drawingml/chart/seriesconverter.cxx
@@ -433,6 +433,8 @@ void TrendlineConverter::convertFromModel( const Reference< XDataSeries >& rxDat
             Reference< XRegressionCurve > xRegCurve( createInstance( aServiceName ), UNO_QUERY_THROW );
             PropertySet aPropSet( xRegCurve );
 
+            // Name
+            aPropSet.setProperty( PROP_CurveName, mrModel.maName );
             aPropSet.setProperty( PROP_PolynomialDegree, mrModel.mnOrder );
             aPropSet.setProperty( PROP_MovingAveragePeriod, mrModel.mnPeriod );
 
diff --git a/oox/source/export/chartexport.cxx b/oox/source/export/chartexport.cxx
index fb8f2a9..9c004e0 100644
--- a/oox/source/export/chartexport.cxx
+++ b/oox/source/export/chartexport.cxx
@@ -1540,8 +1540,7 @@ void ChartExport::exportSeries( Reference< chart2::XChartType > xChartType, sal_
                     if( eChartType != chart::TYPEID_SCATTER && eChartType != chart::TYPEID_BAR )
                         exportDataLabels( uno::Reference< beans::XPropertySet >( aSeriesSeq[nSeriesIdx], uno::UNO_QUERY ), nSeriesLength );
 
-                    if( eChartType == chart::TYPEID_SCATTER )
-                        exportTrendlines( aSeriesSeq[nSeriesIdx] );
+                    exportTrendlines( aSeriesSeq[nSeriesIdx] );
 
                     //export error bars here
                     Reference< XPropertySet > xSeriesPropSet( xSource, uno::UNO_QUERY );
@@ -2523,14 +2522,22 @@ void ChartExport::exportTrendlines( Reference< chart2::XDataSeries > xSeries )
             if (!xRegCurve.is())
                 continue;
 
+            Reference< XPropertySet > xProperties( xRegCurve , uno::UNO_QUERY );
+
             pFS->startElement( FSNS( XML_c, XML_trendline ), FSEND );
 
-            Reference< XPropertySet > xProperties( xRegCurve , uno::UNO_QUERY );
+            OUString aName;
+            xProperties->getPropertyValue("CurveName") >>= aName;
+            if(!aName.isEmpty())
+            {
+                pFS->startElement( FSNS( XML_c, XML_name), FSEND);
+                pFS->writeEscaped(aName);
+                pFS->endElement( FSNS( XML_c, XML_name) );
+            }
 
             exportShapeProps( xProperties );
 
             OUString aService;
-
             Reference< lang::XServiceName > xServiceName( xProperties, UNO_QUERY );
             if( !xServiceName.is() )
                 continue;
@@ -2593,8 +2600,8 @@ void ChartExport::exportTrendlines( Reference< chart2::XDataSeries > xSeries )
             double aExtrapolateForward = 0.0;
             double aExtrapolateBackward = 0.0;
 
-            xProperties->getPropertyValue( "ExtrapolateForward") >>= aExtrapolateForward;
-            xProperties->getPropertyValue( "ExtrapolateBackward") >>= aExtrapolateBackward;
+            xProperties->getPropertyValue("ExtrapolateForward") >>= aExtrapolateForward;
+            xProperties->getPropertyValue("ExtrapolateBackward") >>= aExtrapolateBackward;
 
             pFS->singleElement( FSNS( XML_c, XML_forward ),
                     XML_val, OString::number(aExtrapolateForward).getStr(),
@@ -2605,29 +2612,28 @@ void ChartExport::exportTrendlines( Reference< chart2::XDataSeries > xSeries )
                     FSEND );
 
             sal_Bool aForceIntercept = false;
-            xProperties->getPropertyValue( "ForceIntercept") >>= aForceIntercept;
+            xProperties->getPropertyValue("ForceIntercept") >>= aForceIntercept;
 
             if (aForceIntercept)
             {
                 double aInterceptValue = 0.0;
-                xProperties->getPropertyValue( "InterceptValue") >>= aInterceptValue;
+                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() );
 
             // Show Equation
             sal_Bool aShowEquation = false;
-            xEquationProperties->getPropertyValue( "ShowEquation" ) >>= aShowEquation;
+            xEquationProperties->getPropertyValue("ShowEquation") >>= aShowEquation;
 
             // Show R^2
             sal_Bool aShowCorrelationCoefficient = false;
-            xEquationProperties->getPropertyValue( "ShowCorrelationCoefficient" ) >>= aShowCorrelationCoefficient;
+            xEquationProperties->getPropertyValue("ShowCorrelationCoefficient") >>= aShowCorrelationCoefficient;
 
             pFS->singleElement( FSNS( XML_c, XML_dispRSqr ),
                     XML_val, aShowCorrelationCoefficient ? "1" : "0",
diff --git a/oox/source/token/properties.txt b/oox/source/token/properties.txt
index d89ae44..b0001e3 100644
--- a/oox/source/token/properties.txt
+++ b/oox/source/token/properties.txt
@@ -109,6 +109,7 @@ CrossoverValue
 CursorPositionX
 CursorPositionY
 CurveStyle
+CurveName
 CustomShapeGeometry
 D3DSceneAmbientColor
 D3DSceneLightColor2
commit 2b243ba51e786b0993e66232144fd6a6ee9ef724
Author: Tomaž Vajngerl <quikee at gmail.com>
Date:   Sat Nov 23 18:09:33 2013 +0100

    Support regression curve name in ODF.
    
    Change-Id: Ic065d63eee507906febfa15eb6d5ae1e7de58280

diff --git a/include/xmloff/xmltoken.hxx b/include/xmloff/xmltoken.hxx
index bb585c6..f9196af 100644
--- a/include/xmloff/xmltoken.hxx
+++ b/include/xmloff/xmltoken.hxx
@@ -2158,6 +2158,7 @@ namespace xmloff { namespace token {
 
         XML_REGRESSION_CURVE,
         XML_REGRESSION_TYPE,
+        XML_REGRESSION_CURVE_NAME,
         XML_REGRESSION_EXTRAPOLATE_FORWARD,
         XML_REGRESSION_EXTRAPOLATE_BACKWARD,
         XML_REGRESSION_MAX_DEGREE,
diff --git a/xmloff/source/chart/PropertyMap.hxx b/xmloff/source/chart/PropertyMap.hxx
index 4bab098..a1efee2 100644
--- a/xmloff/source/chart/PropertyMap.hxx
+++ b/xmloff/source/chart/PropertyMap.hxx
@@ -185,6 +185,7 @@ const XMLPropertyMapEntry aXMLChartPropMap[] =
     // regression curve properties
     MAP_SPECIAL( "RegressionType", CHART, XML_REGRESSION_TYPE, XML_TYPE_STRING, XML_SCH_CONTEXT_SPECIAL_REGRESSION_TYPE ),
 
+    MAP_ENTRY_ODF_EXT( "CurveName", CHART, XML_REGRESSION_CURVE_NAME, XML_TYPE_STRING ),
     MAP_ENTRY_ODF_EXT( "PolynomialDegree", CHART, XML_REGRESSION_MAX_DEGREE, XML_TYPE_NUMBER ),
     MAP_ENTRY_ODF_EXT( "MovingAveragePeriod", CHART, XML_REGRESSION_PERIOD, XML_TYPE_NUMBER ),
     MAP_ENTRY_ODF_EXT( "MovingAverageType", CHART, XML_REGRESSION_MOVING_TYPE, XML_TYPE_STRING ),
diff --git a/xmloff/source/core/xmltoken.cxx b/xmloff/source/core/xmltoken.cxx
index dedb2b4..431e778 100644
--- a/xmloff/source/core/xmltoken.cxx
+++ b/xmloff/source/core/xmltoken.cxx
@@ -2168,6 +2168,7 @@ namespace xmloff { namespace token {
         TOKEN( "regression-curve",                XML_REGRESSION_CURVE ),
         TOKEN( "regression-type",                 XML_REGRESSION_TYPE ),
         // Extended regression curve properties - ODF 1.2 extended
+        TOKEN( "regression-name",                 XML_REGRESSION_CURVE_NAME ),
         TOKEN( "regression-extrapolate-forward",  XML_REGRESSION_EXTRAPOLATE_FORWARD ),
         TOKEN( "regression-extrapolate-backward", XML_REGRESSION_EXTRAPOLATE_BACKWARD ),
         TOKEN( "regression-max-degree",           XML_REGRESSION_MAX_DEGREE ),
commit 6f62f3f0af9ae8c1b00d0d620f306cae914a3861
Author: Tomaž Vajngerl <quikee at gmail.com>
Date:   Sat Nov 23 16:06:28 2013 +0100

    Custom name for a trend line (shown in legend).
    
    Previously, a trendline name was fixed to a combination of the
    trendline type and the name of the series. With this it is possible
    to add a custom name for the trendline, which is shown in the
    legend.
    
    Change-Id: I61eaaf14e6df45088abdf1f3e9c24877d26ae8a7

diff --git a/chart2/source/controller/dialogs/res_Trendline.cxx b/chart2/source/controller/dialogs/res_Trendline.cxx
index f8ba0fa..7a4c495 100644
--- a/chart2/source/controller/dialogs/res_Trendline.cxx
+++ b/chart2/source/controller/dialogs/res_Trendline.cxx
@@ -24,6 +24,7 @@
 #include "chartview/ChartSfxItemIds.hxx"
 
 #include <svl/intitem.hxx>
+#include <svl/stritem.hxx>
 #include <sfx2/tabdlg.hxx>
 
 #include <vector>
@@ -36,26 +37,28 @@ TrendlineResources::TrendlineResources( Window * pParent, const SfxItemSet& rInA
         m_eTrendLineType( CHREGRESS_LINEAR ),
         m_bTrendLineUnique( true )
 {
-    ((SfxTabPage*)pParent)->get(m_pRB_Linear,"linear");
-    ((SfxTabPage*)pParent)->get(m_pRB_Logarithmic,"logarithmic");
-    ((SfxTabPage*)pParent)->get(m_pRB_Exponential,"exponential");
-    ((SfxTabPage*)pParent)->get(m_pRB_Power,"power");
-    ((SfxTabPage*)pParent)->get(m_pRB_Polynomial,"polynomial");
-    ((SfxTabPage*)pParent)->get(m_pRB_MovingAverage,"movingAverage");
-    ((SfxTabPage*)pParent)->get(m_pNF_Degree,"degree");
-    ((SfxTabPage*)pParent)->get(m_pNF_Period,"period");
-    ((SfxTabPage*)pParent)->get(m_pNF_ExtrapolateForward,"extrapolateForward");
-    ((SfxTabPage*)pParent)->get(m_pNF_ExtrapolateBackward,"extrapolateBackward");
-    ((SfxTabPage*)pParent)->get(m_pCB_SetIntercept,"setIntercept");
-    ((SfxTabPage*)pParent)->get(m_pNF_InterceptValue,"interceptValue");
-    ((SfxTabPage*)pParent)->get(m_pCB_ShowEquation,"showEquation");
-    ((SfxTabPage*)pParent)->get(m_pCB_ShowCorrelationCoeff,"showCorrelationCoefficient");
-    ((SfxTabPage*)pParent)->get(m_pFI_Linear,"imageLinear");
-    ((SfxTabPage*)pParent)->get(m_pFI_Logarithmic,"imageLogarithmic");
-    ((SfxTabPage*)pParent)->get(m_pFI_Exponential,"imageExponential");
-    ((SfxTabPage*)pParent)->get(m_pFI_Power,"imagePower");
-    ((SfxTabPage*)pParent)->get(m_pFI_Polynomial,"imagePolynomial");
-    ((SfxTabPage*)pParent)->get(m_pFI_MovingAverage,"imageMovingAverage");
+    SfxTabPage* pTabPage = reinterpret_cast<SfxTabPage*>(pParent);
+    pTabPage->get(m_pRB_Linear,"linear");
+    pTabPage->get(m_pRB_Logarithmic,"logarithmic");
+    pTabPage->get(m_pRB_Exponential,"exponential");
+    pTabPage->get(m_pRB_Power,"power");
+    pTabPage->get(m_pRB_Polynomial,"polynomial");
+    pTabPage->get(m_pRB_MovingAverage,"movingAverage");
+    pTabPage->get(m_pNF_Degree,"degree");
+    pTabPage->get(m_pNF_Period,"period");
+    pTabPage->get(m_pEE_Name,"entry_name");
+    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_pCB_ShowEquation,"showEquation");
+    pTabPage->get(m_pCB_ShowCorrelationCoeff,"showCorrelationCoefficient");
+    pTabPage->get(m_pFI_Linear,"imageLinear");
+    pTabPage->get(m_pFI_Logarithmic,"imageLogarithmic");
+    pTabPage->get(m_pFI_Exponential,"imageExponential");
+    pTabPage->get(m_pFI_Power,"imagePower");
+    pTabPage->get(m_pFI_Polynomial,"imagePolynomial");
+    pTabPage->get(m_pFI_MovingAverage,"imageMovingAverage");
     FillValueSets();
 
     m_pRB_Linear->SetClickHdl( LINK(this, TrendlineResources, SelectTrendLine ));
@@ -104,6 +107,16 @@ void TrendlineResources::Reset( const SfxItemSet& rInAttrs )
 {
     const SfxPoolItem *pPoolItem = NULL;
 
+    if( rInAttrs.GetItemState( SCHATTR_REGRESSION_CURVE_NAME, sal_True, &pPoolItem ) == SFX_ITEM_SET )
+    {
+        OUString aName = static_cast< const SfxStringItem* >(pPoolItem)->GetValue();
+        m_pEE_Name->SetText(aName);
+    }
+    else
+    {
+        m_pEE_Name->SetText("");
+    }
+
     SfxItemState aState = rInAttrs.GetItemState( SCHATTR_REGRESSION_TYPE, sal_True, &pPoolItem );
     m_bTrendLineUnique = ( aState != SFX_ITEM_DONTCARE );
     if( aState == SFX_ITEM_SET )
@@ -243,6 +256,9 @@ sal_Bool TrendlineResources::FillItemSet(SfxItemSet& rOutAttrs) const
     if( m_pCB_ShowCorrelationCoeff->GetState() != STATE_DONTKNOW )
         rOutAttrs.Put( SfxBoolItem( SCHATTR_REGRESSION_SHOW_COEFF, m_pCB_ShowCorrelationCoeff->IsChecked() ));
 
+    OUString aName = m_pEE_Name->GetText();
+    rOutAttrs.Put(SfxStringItem(SCHATTR_REGRESSION_CURVE_NAME, aName));
+
     sal_Int32 aDegree = m_pNF_Degree->GetValue();
     rOutAttrs.Put(SfxInt32Item( SCHATTR_REGRESSION_DEGREE, aDegree ) );
 
diff --git a/chart2/source/controller/dialogs/res_Trendline.hxx b/chart2/source/controller/dialogs/res_Trendline.hxx
index 0c12d71..7aacb08 100644
--- a/chart2/source/controller/dialogs/res_Trendline.hxx
+++ b/chart2/source/controller/dialogs/res_Trendline.hxx
@@ -57,6 +57,7 @@ private:
 
     NumericField* m_pNF_Degree;
     NumericField* m_pNF_Period;
+    Edit*         m_pEE_Name;
     NumericField* m_pNF_ExtrapolateForward;
     NumericField* m_pNF_ExtrapolateBackward;
     CheckBox*     m_pCB_SetIntercept;
diff --git a/chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx b/chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx
index 6b28439..81f94d2 100644
--- a/chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx
+++ b/chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx
@@ -29,6 +29,7 @@
 // for SfxBoolItem
 #include <svl/eitem.hxx>
 #include <svl/intitem.hxx>
+#include <svl/stritem.hxx>
 #include <svx/chrtitem.hxx>
 
 #include <functional>
@@ -245,6 +246,13 @@ bool RegressionCurveItemConverter::ApplySpecialItem(
         }
         break;
 
+        case SCHATTR_REGRESSION_CURVE_NAME:
+        {
+            uno::Reference< beans::XPropertySet > xProperties( xCurve, uno::UNO_QUERY );
+            bChanged = lclConvertToPropertySet<OUString, SfxStringItem>(rItemSet, nWhichId, xProperties, "CurveName");
+        }
+        break;
+
         case SCHATTR_REGRESSION_SHOW_EQUATION:
         {
             uno::Reference< beans::XPropertySet > xEqProp( xCurve->getEquationProperties());
@@ -258,6 +266,7 @@ bool RegressionCurveItemConverter::ApplySpecialItem(
             bChanged = lclConvertToPropertySet<sal_Bool, SfxBoolItem>(rItemSet, nWhichId, xEqProp, "ShowCorrelationCoefficient");
         }
         break;
+
     }
     return bChanged;
 }
@@ -318,6 +327,12 @@ void RegressionCurveItemConverter::FillSpecialItem(sal_uInt16 nWhichId, SfxItemS
         }
         break;
 
+        case SCHATTR_REGRESSION_CURVE_NAME:
+        {
+            lclConvertToItemSet<OUString, SfxStringItem>(rOutItemSet, nWhichId, xProperties, "CurveName");
+        }
+        break;
+
         case SCHATTR_REGRESSION_SHOW_EQUATION:
         {
             lclConvertToItemSet<sal_Bool, SfxBoolItem>(rOutItemSet, nWhichId, xCurve->getEquationProperties(), "ShowEquation");
diff --git a/chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx b/chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx
index 3693ea5..506be48 100644
--- a/chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx
+++ b/chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx
@@ -526,7 +526,7 @@ bool StatisticsItemConverter::ApplySpecialItem(
         case SCHATTR_REGRESSION_SET_INTERCEPT:
         {
             uno::Reference< beans::XPropertySet > xProperties( lcl_getCurveProperties( GetPropertySet(), &rItemSet ));
-            bChanged = lclConvertToPropertySet<sal_Bool, SfxBoolItem>(rItemSet, nWhichId, xProperties, "InterceptValue");
+            bChanged = lclConvertToPropertySet<sal_Bool, SfxBoolItem>(rItemSet, nWhichId, xProperties, "ForceIntercept");
         }
         break;
 
@@ -537,6 +537,13 @@ bool StatisticsItemConverter::ApplySpecialItem(
         }
         break;
 
+        case SCHATTR_REGRESSION_CURVE_NAME:
+        {
+            uno::Reference< beans::XPropertySet > xProperties( lcl_getCurveProperties( GetPropertySet(), &rItemSet ));
+            bChanged = lclConvertToPropertySet<OUString, SfxStringItem>(rItemSet, nWhichId, xProperties, "CurveName");
+        }
+        break;
+
         case SCHATTR_REGRESSION_SHOW_EQUATION:
         {
             uno::Reference< beans::XPropertySet > xEqProp( lcl_getEquationProperties( GetPropertySet(), &rItemSet ));
@@ -800,6 +807,13 @@ void StatisticsItemConverter::FillSpecialItem(
         }
         break;
 
+        case SCHATTR_REGRESSION_CURVE_NAME:
+        {
+            uno::Reference< beans::XPropertySet > xProperties( lcl_getCurveProperties( GetPropertySet(), 0 ));
+            lclConvertToItemSet<OUString, SfxStringItem>(rOutItemSet, nWhichId, xProperties, "CurveName");
+        }
+        break;
+
         case SCHATTR_REGRESSION_SHOW_EQUATION:
         {
             uno::Reference< beans::XPropertySet > xEqProp( lcl_getEquationProperties( GetPropertySet(), 0 ));
diff --git a/chart2/source/inc/chartview/ChartSfxItemIds.hxx b/chart2/source/inc/chartview/ChartSfxItemIds.hxx
index 2b98848..7481cc8 100644
--- a/chart2/source/inc/chartview/ChartSfxItemIds.hxx
+++ b/chart2/source/inc/chartview/ChartSfxItemIds.hxx
@@ -167,7 +167,8 @@
 #define SCHATTR_REGRESSION_EXTRAPOLATE_BACKWARD (SCHATTR_REGRESSION_START + 6)
 #define SCHATTR_REGRESSION_SET_INTERCEPT        (SCHATTR_REGRESSION_START + 7)
 #define SCHATTR_REGRESSION_INTERCEPT_VALUE      (SCHATTR_REGRESSION_START + 8)
-#define SCHATTR_REGRESSION_END                   SCHATTR_REGRESSION_INTERCEPT_VALUE
+#define SCHATTR_REGRESSION_CURVE_NAME           (SCHATTR_REGRESSION_START + 9)
+#define SCHATTR_REGRESSION_END                   SCHATTR_REGRESSION_CURVE_NAME
 
 #define SCHATTR_END                     SCHATTR_REGRESSION_END
 
diff --git a/chart2/source/tools/RegressionCurveHelper.cxx b/chart2/source/tools/RegressionCurveHelper.cxx
index d93fb64..a19affd 100644
--- a/chart2/source/tools/RegressionCurveHelper.cxx
+++ b/chart2/source/tools/RegressionCurveHelper.cxx
@@ -590,6 +590,18 @@ OUString RegressionCurveHelper::getUINameForRegressionCurve( const Reference< XR
     if(!xServiceName.is())
         return aResult;
 
+    Reference<XPropertySet> xProperties( xRegressionCurve, uno::UNO_QUERY );
+    if( xProperties.is() )
+    {
+        OUString aValue = OUString();
+        if(xProperties->getPropertyValue("CurveName") >>= aValue)
+        {
+            if (!aValue.isEmpty())
+                return aValue;
+        }
+    }
+
+    // Did not get the curve name
     OUString aServiceName( xServiceName->getServiceName());
     if( aServiceName == "com.sun.star.chart2.MeanValueRegressionCurve" )
     {
diff --git a/chart2/source/tools/RegressionCurveModel.cxx b/chart2/source/tools/RegressionCurveModel.cxx
index fb182c0..2ff4f45 100644
--- a/chart2/source/tools/RegressionCurveModel.cxx
+++ b/chart2/source/tools/RegressionCurveModel.cxx
@@ -62,7 +62,8 @@ enum
     PROPERTY_EXTRAPOLATE_FORWARD,
     PROPERTY_EXTRAPOLATE_BACKWARD,
     PROPERTY_FORCE_INTERCEPT,
-    PROPERTY_INTERCEPT_VALUE
+    PROPERTY_INTERCEPT_VALUE,
+    PROPERTY_CURVE_NAME
 };
 
 void lcl_AddPropertiesToVector(
@@ -109,6 +110,12 @@ void lcl_AddPropertiesToVector(
                 ::getCppuType( reinterpret_cast< const double* >(0) ),
                 beans::PropertyAttribute::BOUND |
                 beans::PropertyAttribute::MAYBEDEFAULT ));
+
+    rOutProperties.push_back(
+        Property( "CurveName",
+                PROPERTY_CURVE_NAME,
+                ::getCppuType( reinterpret_cast< const OUString* >(0) ),
+                beans::PropertyAttribute::BOUND ));
 }
 
 struct StaticXXXDefaults_Initializer
diff --git a/chart2/source/view/main/ChartItemPool.cxx b/chart2/source/view/main/ChartItemPool.cxx
index b5c21d3..3718dad 100644
--- a/chart2/source/view/main/ChartItemPool.cxx
+++ b/chart2/source/view/main/ChartItemPool.cxx
@@ -157,6 +157,7 @@ ChartItemPool::ChartItemPool():
     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);
+    ppPoolDefaults[SCHATTR_REGRESSION_CURVE_NAME            - SCHATTR_START] = new SfxStringItem(SCHATTR_REGRESSION_CURVE_NAME, OUString());
 
     /**************************************************************************
     * ItemInfos
diff --git a/chart2/uiconfig/ui/tp_Trendline.ui b/chart2/uiconfig/ui/tp_Trendline.ui
index a8be284..d095145 100644
--- a/chart2/uiconfig/ui/tp_Trendline.ui
+++ b/chart2/uiconfig/ui/tp_Trendline.ui
@@ -376,7 +376,7 @@
                   </object>
                   <packing>
                     <property name="left_attach">0</property>
-                    <property name="top_attach">0</property>
+                    <property name="top_attach">1</property>
                     <property name="width">1</property>
                     <property name="height">1</property>
                   </packing>
@@ -392,7 +392,7 @@
                   </object>
                   <packing>
                     <property name="left_attach">0</property>
-                    <property name="top_attach">1</property>
+                    <property name="top_attach">2</property>
                     <property name="width">1</property>
                     <property name="height">1</property>
                   </packing>
@@ -410,7 +410,7 @@
                   </object>
                   <packing>
                     <property name="left_attach">1</property>
-                    <property name="top_attach">0</property>
+                    <property name="top_attach">1</property>
                     <property name="width">1</property>
                     <property name="height">1</property>
                   </packing>
@@ -425,7 +425,7 @@
                   </object>
                   <packing>
                     <property name="left_attach">1</property>
-                    <property name="top_attach">1</property>
+                    <property name="top_attach">2</property>
                     <property name="width">1</property>
                     <property name="height">1</property>
                   </packing>
@@ -444,7 +444,7 @@
                   </object>
                   <packing>
                     <property name="left_attach">1</property>
-                    <property name="top_attach">2</property>
+                    <property name="top_attach">3</property>
                     <property name="width">1</property>
                     <property name="height">1</property>
                   </packing>
@@ -464,7 +464,7 @@
                   </object>
                   <packing>
                     <property name="left_attach">0</property>
-                    <property name="top_attach">2</property>
+                    <property name="top_attach">3</property>
                     <property name="width">1</property>
                     <property name="height">1</property>
                   </packing>
@@ -481,7 +481,7 @@
                   </object>
                   <packing>
                     <property name="left_attach">0</property>
-                    <property name="top_attach">3</property>
+                    <property name="top_attach">4</property>
                     <property name="width">2</property>
                     <property name="height">1</property>
                   </packing>
@@ -498,11 +498,40 @@
                   </object>
                   <packing>
                     <property name="left_attach">0</property>
-                    <property name="top_attach">4</property>
+                    <property name="top_attach">5</property>
                     <property name="width">2</property>
                     <property name="height">1</property>
                   </packing>
                 </child>
+                <child>
+                  <object class="GtkLabel" id="label5">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="xalign">0</property>
+                    <property name="label" translatable="yes">Trendline Name</property>
+                    <property name="use_underline">True</property>
+                    <property name="mnemonic_widget">entry_name</property>
+                  </object>
+                  <packing>
+                    <property name="left_attach">0</property>
+                    <property name="top_attach">0</property>
+                    <property name="width">1</property>
+                    <property name="height">1</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkEntry" id="entry_name">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="invisible_char">•</property>
+                  </object>
+                  <packing>
+                    <property name="left_attach">1</property>
+                    <property name="top_attach">0</property>
+                    <property name="width">1</property>
+                    <property name="height">1</property>
+                  </packing>
+                </child>
               </object>
             </child>
           </object>
commit f58e03e7bb0016c1ca789f7e7b35933c95378121
Author: Tomaž Vajngerl <quikee at gmail.com>
Date:   Thu Nov 21 20:25:53 2013 +0100

    Simplify conversion from/to ItemSet/PropertySet for RegressionCurves
    
    Change-Id: I5ddf53f984508a88fd02063eb9f81cd05cf627c9

diff --git a/chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx b/chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx
index bce1e7f..6b28439 100644
--- a/chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx
+++ b/chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx
@@ -68,6 +68,51 @@ namespace
     return eType;
 }
 
+template <class T, class D>
+bool lclConvertToPropertySet(const SfxItemSet& rItemSet, sal_uInt16 nWhichId, uno::Reference<beans::XPropertySet> xProperties, OUString aPropertyID)
+{
+    OSL_ASSERT(xProperties.is());
+    if( xProperties.is() )
+    {
+        T aValue = static_cast<T>(static_cast<const D&>(rItemSet.Get( nWhichId )).GetValue());
+        T aOldValue = aValue;
+        bool aSuccess = xProperties->getPropertyValue( aPropertyID ) >>= aOldValue;
+        if (!aSuccess || aOldValue != aValue)
+        {
+            xProperties->setPropertyValue( aPropertyID , uno::makeAny( aValue ));
+            return true;
+        }
+    }
+    return false;
+}
+
+template <class T, class D>
+void lclConvertToItemSet(SfxItemSet& rItemSet, sal_uInt16 nWhichId, uno::Reference<beans::XPropertySet> xProperties, OUString aPropertyID)
+{
+    OSL_ASSERT(xProperties.is());
+    if( xProperties.is() )
+    {
+        T aValue = static_cast<T>(static_cast<const D&>(rItemSet.Get( nWhichId )).GetValue());
+        if(xProperties->getPropertyValue( aPropertyID ) >>= aValue)
+        {
+            rItemSet.Put(D( nWhichId, aValue ));
+        }
+    }
+}
+
+void lclConvertToItemSetDouble(SfxItemSet& rItemSet, sal_uInt16 nWhichId, uno::Reference<beans::XPropertySet> xProperties, OUString aPropertyID)
+{
+    OSL_ASSERT(xProperties.is());
+    if( xProperties.is() )
+    {
+        double aValue = static_cast<double>(static_cast<const SvxDoubleItem&>(rItemSet.Get( nWhichId )).GetValue());
+        if(xProperties->getPropertyValue( aPropertyID ) >>= aValue)
+        {
+            rItemSet.Put(SvxDoubleItem( aValue, nWhichId ));
+        }
+    }
+}
+
 } // anonymous namespace
 
 namespace chart
@@ -128,8 +173,8 @@ bool RegressionCurveItemConverter::ApplySpecialItem(
     uno::Reference< chart2::XRegressionCurve > xCurve( GetPropertySet(), uno::UNO_QUERY );
     bool bChanged = false;
 
-    OSL_ASSERT( xCurve.is());
-    if( !xCurve.is())
+    OSL_ASSERT(xCurve.is());
+    if(!xCurve.is())
         return false;
 
     switch( nWhichId )
@@ -151,7 +196,7 @@ bool RegressionCurveItemConverter::ApplySpecialItem(
                             m_xCurveContainer,
                             xCurve,
                             uno::Reference< uno::XComponentContext >());
-                uno::Reference< beans::XPropertySet > xProperties( xCurve, uno::UNO_QUERY );
+                uno::Reference<beans::XPropertySet> xProperties( xCurve, uno::UNO_QUERY );
                 resetPropertySet( xProperties );
                 bChanged = true;
             }
@@ -160,324 +205,128 @@ bool RegressionCurveItemConverter::ApplySpecialItem(
 
         case SCHATTR_REGRESSION_DEGREE:
         {
-            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());
-            if( xProperties.is() )
-            {
-                sal_Int32 aOldDegree = 2;
-                xProperties->getPropertyValue( "PolynomialDegree" ) >>= aOldDegree;
-                if (aOldDegree != aDegree)
-                {
-                    xProperties->setPropertyValue( "PolynomialDegree" , uno::makeAny( aDegree ));
-                    bChanged = true;
-                }
-            }
+            bChanged = lclConvertToPropertySet<sal_Int32, SfxInt32Item>(rItemSet, nWhichId, xProperties, OUString("PolynomialDegree"));
         }
         break;
 
         case SCHATTR_REGRESSION_PERIOD:
         {
-            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());
-            if( xProperties.is() )
-            {
-                sal_Int32 aOldPeriod = 2;
-                xProperties->getPropertyValue( "MovingAveragePeriod" ) >>= aOldPeriod;
-                if (aOldPeriod != aPeriod)
-                {
-                    xProperties->setPropertyValue( "MovingAveragePeriod" , uno::makeAny( aPeriod ));
-                    bChanged = true;
-                }
-            }
+            bChanged = lclConvertToPropertySet<sal_Int32, SfxInt32Item>(rItemSet, nWhichId, xProperties, "MovingAveragePeriod");
         }
         break;
 
         case SCHATTR_REGRESSION_EXTRAPOLATE_FORWARD:
         {
-            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());
-            if( xProperties.is() )
-            {
-                double aOldValue = 0.0;
-                xProperties->getPropertyValue( "ExtrapolateForward" ) >>= aOldValue;
-                if (aOldValue != aValue)
-                {
-                    xProperties->setPropertyValue( "ExtrapolateForward" , uno::makeAny( aValue ));
-                    bChanged = true;
-                }
-            }
+            bChanged = lclConvertToPropertySet<double, SvxDoubleItem>(rItemSet, nWhichId, xProperties, "ExtrapolateForward");
         }
         break;
 
         case SCHATTR_REGRESSION_EXTRAPOLATE_BACKWARD:
         {
-            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());
-            if( xProperties.is() )
-            {
-                double aOldValue = 0.0;
-                xProperties->getPropertyValue( "ExtrapolateBackward" ) >>= aOldValue;
-                if (aOldValue != aValue)
-                {
-                    xProperties->setPropertyValue( "ExtrapolateBackward" , uno::makeAny( aValue ));
-                    bChanged = true;
-                }
-            }
+            bChanged = lclConvertToPropertySet<double, SvxDoubleItem>(rItemSet, nWhichId, xProperties, "ExtrapolateBackward");
         }
         break;
 
         case SCHATTR_REGRESSION_SET_INTERCEPT:
         {
-            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());
-            if( xProperties.is() )
-            {
-                sal_Bool bOldValue = false;
-                xProperties->getPropertyValue( "ForceIntercept" ) >>= bOldValue;
-                if (bOldValue != bNewValue)
-                {
-                    xProperties->setPropertyValue( "ForceIntercept" , uno::makeAny( bNewValue ));
-                    bChanged = true;
-                }
-            }
+            bChanged = lclConvertToPropertySet<sal_Bool, SfxBoolItem>(rItemSet, nWhichId, xProperties, "ForceIntercept");
         }
         break;
 
         case SCHATTR_REGRESSION_INTERCEPT_VALUE:
         {
-            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());
-            if( xProperties.is() )
-            {
-                double aOldValue = 0.0;
-                xProperties->getPropertyValue( "InterceptValue" ) >>= aOldValue;
-                if (aOldValue != aValue)
-                {
-                    xProperties->setPropertyValue( "InterceptValue" , uno::makeAny( aValue ));
-                    bChanged = true;
-                }
-            }
+            bChanged = lclConvertToPropertySet<double, SvxDoubleItem>(rItemSet, nWhichId, xProperties, "InterceptValue");
         }
         break;
 
         case SCHATTR_REGRESSION_SHOW_EQUATION:
         {
-            bool bNewShow = static_cast< sal_Bool >(
-                static_cast< const SfxBoolItem & >(
-                    rItemSet.Get( nWhichId )).GetValue());
-
             uno::Reference< beans::XPropertySet > xEqProp( xCurve->getEquationProperties());
-            OSL_ASSERT( xEqProp.is());
-            bool bOldShow = false;
-            if( xEqProp.is() &&
-                (xEqProp->getPropertyValue( "ShowEquation" ) >>= bOldShow) &&
-                bOldShow != bNewShow )
-            {
-                xEqProp->setPropertyValue( "ShowEquation" , uno::makeAny( bNewShow ));
-                bChanged = true;
-            }
+            bChanged = lclConvertToPropertySet<sal_Bool, SfxBoolItem>(rItemSet, nWhichId, xEqProp, "ShowEquation");
         }
         break;
 
         case SCHATTR_REGRESSION_SHOW_COEFF:
         {
-            bool bNewShow = static_cast< sal_Bool >(
-                static_cast< const SfxBoolItem & >(
-                    rItemSet.Get( nWhichId )).GetValue());
-
             uno::Reference< beans::XPropertySet > xEqProp( xCurve->getEquationProperties());
-            OSL_ASSERT( xEqProp.is());
-            bool bOldShow = false;
-            if( xEqProp.is() &&
-                (xEqProp->getPropertyValue( "ShowCorrelationCoefficient" ) >>= bOldShow) &&
-                bOldShow != bNewShow )
-            {
-                xEqProp->setPropertyValue( "ShowCorrelationCoefficient" , uno::makeAny( bNewShow ));
-                bChanged = true;
-            }
+            bChanged = lclConvertToPropertySet<sal_Bool, SfxBoolItem>(rItemSet, nWhichId, xEqProp, "ShowCorrelationCoefficient");
         }
         break;
     }
     return bChanged;
 }
 
-void RegressionCurveItemConverter::FillSpecialItem(
-    sal_uInt16 nWhichId, SfxItemSet & rOutItemSet ) const
+void RegressionCurveItemConverter::FillSpecialItem(sal_uInt16 nWhichId, SfxItemSet& rOutItemSet ) const
     throw( uno::Exception )
 {
-    uno::Reference< chart2::XRegressionCurve > xCurve( GetPropertySet(), uno::UNO_QUERY );
+    uno::Reference<chart2::XRegressionCurve> xCurve(GetPropertySet(), uno::UNO_QUERY);
+    OSL_ASSERT(xCurve.is());
+    if(!xCurve.is())
+        return;
+
+    uno::Reference< beans::XPropertySet > xProperties( xCurve, uno::UNO_QUERY );
 
     switch( nWhichId )
     {
         case SCHATTR_REGRESSION_TYPE:
         {
-            OSL_ASSERT( xCurve.is());
-            if( xCurve.is())
-            {
-                SvxChartRegress eRegress = static_cast< SvxChartRegress >(
-                    static_cast< sal_Int32 >( RegressionCurveHelper::getRegressionType( xCurve )));
-                rOutItemSet.Put( SvxChartRegressItem( eRegress, SCHATTR_REGRESSION_TYPE ));
-            }
+            sal_Int32 aRegressionType = static_cast< sal_Int32 >(RegressionCurveHelper::getRegressionType(xCurve));
+            SvxChartRegress eRegress = static_cast< SvxChartRegress >(aRegressionType);
+            rOutItemSet.Put( SvxChartRegressItem( eRegress, SCHATTR_REGRESSION_TYPE ));
         }
         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 ));
-                }
-            }
+            lclConvertToItemSet<sal_Int32, SfxInt32Item>(rOutItemSet, nWhichId, xProperties, "PolynomialDegree");
         }
         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 ));
-                }
-            }
+            lclConvertToItemSet<sal_Int32, SfxInt32Item>(rOutItemSet, nWhichId, xProperties, "MovingAveragePeriod");
         }
         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 ));
-                }
-            }
+            lclConvertToItemSetDouble(rOutItemSet, nWhichId, xProperties, "ExtrapolateForward");
         }
         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 ));
-                }
-            }
+            lclConvertToItemSetDouble(rOutItemSet, nWhichId, xProperties, "ExtrapolateBackward");
         }
         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 ));
-                }
-            }
+            lclConvertToItemSet<sal_Bool, SfxBoolItem>(rOutItemSet, nWhichId, xProperties, "ForceIntercept");
         }
         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 ));
-                }
-            }
+            lclConvertToItemSetDouble(rOutItemSet, nWhichId, xProperties, "InterceptValue");
         }
         break;
 
         case SCHATTR_REGRESSION_SHOW_EQUATION:
         {
-            OSL_ASSERT( xCurve.is());
-            if( xCurve.is())
-            {
-                uno::Reference< beans::XPropertySet > xEqProp( xCurve->getEquationProperties());
-                OSL_ASSERT( xEqProp.is());
-                bool bShow = false;
-                if( xEqProp.is() &&
-                    (xEqProp->getPropertyValue( "ShowEquation" ) >>= bShow))
-                {
-                    rOutItemSet.Put( SfxBoolItem( nWhichId, bShow ));
-                }
-            }
+            lclConvertToItemSet<sal_Bool, SfxBoolItem>(rOutItemSet, nWhichId, xCurve->getEquationProperties(), "ShowEquation");
         }
         break;
 
         case SCHATTR_REGRESSION_SHOW_COEFF:
         {
-            OSL_ASSERT( xCurve.is());
-            if( xCurve.is())
-            {
-                uno::Reference< beans::XPropertySet > xEqProp( xCurve->getEquationProperties());
-                OSL_ASSERT( xEqProp.is());
-                bool bShow = false;
-                if( xEqProp.is() &&
-                    (xEqProp->getPropertyValue( "ShowCorrelationCoefficient" ) >>= bShow))
-                {
-                    rOutItemSet.Put( SfxBoolItem( nWhichId, bShow ));
-                }
-            }
+            lclConvertToItemSet<sal_Bool, SfxBoolItem>(rOutItemSet, nWhichId, xCurve->getEquationProperties(), "ShowCorrelationCoefficient");
         }
         break;
     }
diff --git a/chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx b/chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx
index bf4f050..3693ea5 100644
--- a/chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx
+++ b/chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx
@@ -201,6 +201,52 @@ uno::Reference< beans::XPropertySet > lcl_getCurveProperties(
     return uno::Reference< beans::XPropertySet >();
 }
 
+template <class T, class D>
+bool lclConvertToPropertySet(const SfxItemSet& rItemSet, sal_uInt16 nWhichId, uno::Reference<beans::XPropertySet> xProperties, OUString aPropertyID)
+{
+    OSL_ASSERT(xProperties.is());
+    if( xProperties.is() )
+    {
+        T aValue = static_cast<T>(static_cast<const D&>(rItemSet.Get( nWhichId )).GetValue());
+        T aOldValue = aValue;
+        bool aSuccess = xProperties->getPropertyValue( aPropertyID ) >>= aOldValue;
+        if (!aSuccess || aOldValue != aValue)
+        {
+            xProperties->setPropertyValue( aPropertyID , uno::makeAny( aValue ));
+            return true;
+        }
+    }
+    return false;
+}
+
+template <class T, class D>
+void lclConvertToItemSet(SfxItemSet& rItemSet, sal_uInt16 nWhichId, uno::Reference<beans::XPropertySet> xProperties, OUString aPropertyID)
+{
+    OSL_ASSERT(xProperties.is());
+    if( xProperties.is() )
+    {
+        T aValue = static_cast<T>(static_cast<const D&>(rItemSet.Get( nWhichId )).GetValue());
+        if(xProperties->getPropertyValue( aPropertyID ) >>= aValue)
+        {
+            rItemSet.Put(D( nWhichId, aValue ));
+        }
+    }
+}
+
+void lclConvertToItemSetDouble(SfxItemSet& rItemSet, sal_uInt16 nWhichId, uno::Reference<beans::XPropertySet> xProperties, OUString aPropertyID)
+{
+    OSL_ASSERT(xProperties.is());
+    if( xProperties.is() )
+    {
+        double aValue = static_cast<double>(static_cast<const SvxDoubleItem&>(rItemSet.Get( nWhichId )).GetValue());
+        if(xProperties->getPropertyValue( aPropertyID ) >>= aValue)
+        {
+            rItemSet.Put(SvxDoubleItem( aValue, nWhichId ));
+        }
+    }
+}
+
+
 } // anonymous namespace
 
 namespace chart
@@ -452,144 +498,56 @@ bool StatisticsItemConverter::ApplySpecialItem(
         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;
-                }
-            }
+            bChanged = lclConvertToPropertySet<sal_Int32, SfxInt32Item>(rItemSet, nWhichId, xProperties, "PolynomialDegree");
         }
         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;
-                }
-            }
+            bChanged = lclConvertToPropertySet<sal_Int32, SfxInt32Item>(rItemSet, nWhichId, xProperties, "MovingAveragePeriod");
         }
         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;
-                }
-            }
+            bChanged = lclConvertToPropertySet<double, SvxDoubleItem>(rItemSet, nWhichId, xProperties, "ExtrapolateForward");
         }
         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;
-                }
-            }
+            bChanged = lclConvertToPropertySet<double, SvxDoubleItem>(rItemSet, nWhichId, xProperties, "ExtrapolateBackward");
         }
         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;
-                }
-            }
+            bChanged = lclConvertToPropertySet<sal_Bool, SfxBoolItem>(rItemSet, nWhichId, xProperties, "InterceptValue");
         }
         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;
-                }
-            }
+            bChanged = lclConvertToPropertySet<double, SvxDoubleItem>(rItemSet, nWhichId, xProperties, "InterceptValue");
         }
         break;
 
         case SCHATTR_REGRESSION_SHOW_EQUATION:
         {
             uno::Reference< beans::XPropertySet > xEqProp( lcl_getEquationProperties( GetPropertySet(), &rItemSet ));
-            if( xEqProp.is())
-            {
-                bool bShowEq = false;
-                xEqProp->getPropertyValue( "ShowEquation" ) >>= bShowEq;
-                bool bNewShowEq =
-                    static_cast< const SfxBoolItem & >( rItemSet.Get( nWhichId )).GetValue();
-                if( bShowEq != bNewShowEq )
-                {
-                    xEqProp->setPropertyValue( "ShowEquation" , uno::makeAny( bNewShowEq ));
-                    bChanged = true;
-                }
-            }
+            bChanged = lclConvertToPropertySet<sal_Bool, SfxBoolItem>(rItemSet, nWhichId, xEqProp, "ShowEquation");
         }
         break;
 
         case SCHATTR_REGRESSION_SHOW_COEFF:
         {
             uno::Reference< beans::XPropertySet > xEqProp( lcl_getEquationProperties( GetPropertySet(), &rItemSet ));
-            if( xEqProp.is())
-            {
-                bool bShowCoeff = false;
-                xEqProp->getPropertyValue( "ShowCorrelationCoefficient" ) >>= bShowCoeff;
-                bool bNewShowCoeff =
-                    static_cast< const SfxBoolItem & >( rItemSet.Get( nWhichId )).GetValue();
-                if( bShowCoeff != bNewShowCoeff )
-                {
-                    xEqProp->setPropertyValue( "ShowCorrelationCoefficient" , uno::makeAny( bNewShowCoeff ));
-                    bChanged = true;
-                }
-            }
+            bChanged = lclConvertToPropertySet<sal_Bool, SfxBoolItem>(rItemSet, nWhichId, xEqProp, "ShowCorrelationCoefficient");
         }
         break;
 
@@ -801,81 +759,58 @@ void StatisticsItemConverter::FillSpecialItem(
 
         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 ));
+
+            uno::Reference<beans::XPropertySet> xProperties( lcl_getCurveProperties( GetPropertySet(), 0 ));
+            lclConvertToItemSet<sal_Int32, SfxInt32Item>(rOutItemSet, nWhichId, xProperties, "PolynomialDegree");
         }
         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 ));
+            lclConvertToItemSet<sal_Int32, SfxInt32Item>(rOutItemSet, nWhichId, xProperties, "MovingAveragePeriod");
         }
         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 ));
+            lclConvertToItemSetDouble(rOutItemSet, nWhichId, xProperties, "ExtrapolateForward");
         }
         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 ));
+            lclConvertToItemSetDouble(rOutItemSet, nWhichId, xProperties, "ExtrapolateBackward");
         }
         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 ));
+            lclConvertToItemSet<sal_Bool, SfxBoolItem>(rOutItemSet, nWhichId, xProperties, "ForceIntercept");
         }
         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 ));
+            lclConvertToItemSetDouble(rOutItemSet, nWhichId, xProperties, "InterceptValue");
         }
         break;
 
         case SCHATTR_REGRESSION_SHOW_EQUATION:
         {
-            bool bShowEq = false;
             uno::Reference< beans::XPropertySet > xEqProp( lcl_getEquationProperties( GetPropertySet(), 0 ));
-            if( xEqProp.is())
-                xEqProp->getPropertyValue( "ShowEquation" ) >>= bShowEq;
-            rOutItemSet.Put( SfxBoolItem( nWhichId, bShowEq ));
+            lclConvertToItemSet<sal_Bool, SfxBoolItem>(rOutItemSet, nWhichId, xEqProp, "ShowEquation");
         }
         break;
 
         case SCHATTR_REGRESSION_SHOW_COEFF:
         {
-            bool bShowCoeff = false;
             uno::Reference< beans::XPropertySet > xEqProp( lcl_getEquationProperties( GetPropertySet(), 0 ));
-            if( xEqProp.is())
-                xEqProp->getPropertyValue( "ShowCorrelationCoefficient" ) >>= bShowCoeff;
-            rOutItemSet.Put( SfxBoolItem( nWhichId, bShowCoeff ));
+            lclConvertToItemSet<sal_Bool, SfxBoolItem>(rOutItemSet, nWhichId, xEqProp, "ShowCorrelationCoefficient");
         }
         break;
 
diff --git a/chart2/source/view/main/ChartItemPool.cxx b/chart2/source/view/main/ChartItemPool.cxx
index ef480dd..b5c21d3 100644
--- a/chart2/source/view/main/ChartItemPool.cxx
+++ b/chart2/source/view/main/ChartItemPool.cxx
@@ -156,7 +156,7 @@ ChartItemPool::ChartItemPool():
     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);
+    ppPoolDefaults[SCHATTR_REGRESSION_INTERCEPT_VALUE       - SCHATTR_START] = new SvxDoubleItem(0.0, SCHATTR_REGRESSION_INTERCEPT_VALUE);
 
     /**************************************************************************
     * ItemInfos
commit 3af08dd27d45302d162974e671f50af8a11a9cea
Author: Tomaž Vajngerl <quikee at gmail.com>
Date:   Wed Nov 20 22:40:51 2013 +0100

    DRY-cleanup RegressionCurveItemConverter
    
    Change-Id: I8fb799b2efc81587252161ccadfa1dbd6b096bda

diff --git a/chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx b/chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx
index 2bf7900..bce1e7f 100644
--- a/chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx
+++ b/chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx
@@ -128,55 +128,52 @@ bool RegressionCurveItemConverter::ApplySpecialItem(
     uno::Reference< chart2::XRegressionCurve > xCurve( GetPropertySet(), uno::UNO_QUERY );
     bool bChanged = false;
 
+    OSL_ASSERT( xCurve.is());
+    if( !xCurve.is())
+        return false;
+
     switch( nWhichId )
     {
         case SCHATTR_REGRESSION_TYPE:
         {
-            OSL_ASSERT( xCurve.is());
-            if( xCurve.is())
+            SvxChartRegress eRegress = static_cast< SvxChartRegress >(
+                static_cast< sal_Int32 >( RegressionCurveHelper::getRegressionType( xCurve )));
+            SvxChartRegress eNewRegress = static_cast< const SvxChartRegressItem & >(
+                rItemSet.Get( nWhichId )).GetValue();
+            if( eRegress != eNewRegress )
             {
-                SvxChartRegress eRegress = static_cast< SvxChartRegress >(
-                    static_cast< sal_Int32 >( RegressionCurveHelper::getRegressionType( xCurve )));
-                SvxChartRegress eNewRegress = static_cast< const SvxChartRegressItem & >(
-                    rItemSet.Get( nWhichId )).GetValue();
-                if( eRegress != eNewRegress )
-                {
-                    // note that changing the regression type changes the object
-                    // for which this converter was created. Not optimal, but
-                    // currently the only way to handle the type in the
-                    // regression curve properties dialog
-                    xCurve = RegressionCurveHelper::changeRegressionCurveType(
-                                lcl_convertRegressionType( eNewRegress ),
-                                m_xCurveContainer,
-                                xCurve,
-                                uno::Reference< uno::XComponentContext >());
-                    uno::Reference< beans::XPropertySet > xProperties( xCurve, uno::UNO_QUERY );
-                    resetPropertySet( xProperties );
-                    bChanged = true;
-                }
+                // note that changing the regression type changes the object
+                // for which this converter was created. Not optimal, but
+                // currently the only way to handle the type in the
+                // regression curve properties dialog
+                xCurve = RegressionCurveHelper::changeRegressionCurveType(
+                            lcl_convertRegressionType( eNewRegress ),
+                            m_xCurveContainer,
+                            xCurve,
+                            uno::Reference< uno::XComponentContext >());
+                uno::Reference< beans::XPropertySet > xProperties( xCurve, uno::UNO_QUERY );
+                resetPropertySet( xProperties );
+                bChanged = true;
             }
         }
         break;
 
         case SCHATTR_REGRESSION_DEGREE:
         {
-            if( xCurve.is())
-            {
-                sal_Int32 aDegree = static_cast< sal_Int32 >(
-                    static_cast< const SfxInt32Item & >(
-                        rItemSet.Get( nWhichId )).GetValue());
+            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());
-                if( xProperties.is() )
+            uno::Reference< beans::XPropertySet > xProperties( xCurve, uno::UNO_QUERY );
+            OSL_ASSERT( xProperties.is());
+            if( xProperties.is() )
+            {
+                sal_Int32 aOldDegree = 2;
+                xProperties->getPropertyValue( "PolynomialDegree" ) >>= aOldDegree;
+                if (aOldDegree != aDegree)
                 {
-                    sal_Int32 aOldDegree = 2;
-                    xProperties->getPropertyValue( "PolynomialDegree" ) >>= aOldDegree;
-                    if (aOldDegree != aDegree)
-                    {
-                        xProperties->setPropertyValue( "PolynomialDegree" , uno::makeAny( aDegree ));
-                        bChanged = true;
-                    }
+                    xProperties->setPropertyValue( "PolynomialDegree" , uno::makeAny( aDegree ));
+                    bChanged = true;
                 }
             }
         }
@@ -184,23 +181,20 @@ bool RegressionCurveItemConverter::ApplySpecialItem(
 
         case SCHATTR_REGRESSION_PERIOD:
         {
-            if( xCurve.is())
-            {
-                sal_Int32 aPeriod = static_cast< sal_Int32 >(
-                    static_cast< const SfxInt32Item & >(
-                        rItemSet.Get( nWhichId )).GetValue());
+            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());
-                if( xProperties.is() )
+            uno::Reference< beans::XPropertySet > xProperties( xCurve, uno::UNO_QUERY );
+            OSL_ASSERT( xProperties.is());
+            if( xProperties.is() )
+            {
+                sal_Int32 aOldPeriod = 2;
+                xProperties->getPropertyValue( "MovingAveragePeriod" ) >>= aOldPeriod;
+                if (aOldPeriod != aPeriod)
                 {
-                    sal_Int32 aOldPeriod = 2;
-                    xProperties->getPropertyValue( "MovingAveragePeriod" ) >>= aOldPeriod;
-                    if (aOldPeriod != aPeriod)
-                    {
-                        xProperties->setPropertyValue( "MovingAveragePeriod" , uno::makeAny( aPeriod ));
-                        bChanged = true;
-                    }
+                    xProperties->setPropertyValue( "MovingAveragePeriod" , uno::makeAny( aPeriod ));
+                    bChanged = true;
                 }
             }
         }
@@ -208,23 +202,20 @@ bool RegressionCurveItemConverter::ApplySpecialItem(
 
         case SCHATTR_REGRESSION_EXTRAPOLATE_FORWARD:
         {
-            if( xCurve.is())
-            {
-                double aValue = static_cast< double >(
-                    static_cast< const SvxDoubleItem & >(
-                        rItemSet.Get( nWhichId )).GetValue());
+            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());
-                if( xProperties.is() )
+            uno::Reference< beans::XPropertySet > xProperties( xCurve, uno::UNO_QUERY );
+            OSL_ASSERT( xProperties.is());
+            if( xProperties.is() )
+            {
+                double aOldValue = 0.0;
+                xProperties->getPropertyValue( "ExtrapolateForward" ) >>= aOldValue;
+                if (aOldValue != aValue)
                 {
-                    double aOldValue = 0.0;
-                    xProperties->getPropertyValue( "ExtrapolateForward" ) >>= aOldValue;
-                    if (aOldValue != aValue)
-                    {
-                        xProperties->setPropertyValue( "ExtrapolateForward" , uno::makeAny( aValue ));
-                        bChanged = true;
-                    }
+                    xProperties->setPropertyValue( "ExtrapolateForward" , uno::makeAny( aValue ));
+                    bChanged = true;
                 }
             }
         }
@@ -232,23 +223,20 @@ bool RegressionCurveItemConverter::ApplySpecialItem(
 
         case SCHATTR_REGRESSION_EXTRAPOLATE_BACKWARD:
         {
-            if( xCurve.is())
-            {
-                double aValue = static_cast< double >(
-                    static_cast< const SvxDoubleItem & >(
-                        rItemSet.Get( nWhichId )).GetValue());
+            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());
-                if( xProperties.is() )
+            uno::Reference< beans::XPropertySet > xProperties( xCurve, uno::UNO_QUERY );
+            OSL_ASSERT( xProperties.is());
+            if( xProperties.is() )
+            {
+                double aOldValue = 0.0;
+                xProperties->getPropertyValue( "ExtrapolateBackward" ) >>= aOldValue;
+                if (aOldValue != aValue)
                 {
-                    double aOldValue = 0.0;
-                    xProperties->getPropertyValue( "ExtrapolateBackward" ) >>= aOldValue;
-                    if (aOldValue != aValue)
-                    {
-                        xProperties->setPropertyValue( "ExtrapolateBackward" , uno::makeAny( aValue ));
-                        bChanged = true;
-                    }
+                    xProperties->setPropertyValue( "ExtrapolateBackward" , uno::makeAny( aValue ));
+                    bChanged = true;
                 }
             }
         }
@@ -256,23 +244,20 @@ 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());
+            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());
-                if( xProperties.is() )
+            uno::Reference< beans::XPropertySet > xProperties( xCurve, uno::UNO_QUERY );
+            OSL_ASSERT( xProperties.is());
+            if( xProperties.is() )
+            {
+                sal_Bool bOldValue = false;
+                xProperties->getPropertyValue( "ForceIntercept" ) >>= bOldValue;
+                if (bOldValue != bNewValue)
                 {
-                    sal_Bool bOldValue = false;
-                    xProperties->getPropertyValue( "ForceIntercept" ) >>= bOldValue;
-                    if (bOldValue != bNewValue)
-                    {
-                        xProperties->setPropertyValue( "ForceIntercept" , uno::makeAny( bNewValue ));
-                        bChanged = true;
-                    }
+                    xProperties->setPropertyValue( "ForceIntercept" , uno::makeAny( bNewValue ));
+                    bChanged = true;
                 }
             }
         }
@@ -280,23 +265,20 @@ bool RegressionCurveItemConverter::ApplySpecialItem(
 
         case SCHATTR_REGRESSION_INTERCEPT_VALUE:
         {
-            if( xCurve.is())
-            {
-                double aValue = static_cast< double >(
-                    static_cast< const SvxDoubleItem & >(
-                        rItemSet.Get( nWhichId )).GetValue());
+            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());
-                if( xProperties.is() )
+            uno::Reference< beans::XPropertySet > xProperties( xCurve, uno::UNO_QUERY );
+            OSL_ASSERT( xProperties.is());
+            if( xProperties.is() )
+            {
+                double aOldValue = 0.0;
+                xProperties->getPropertyValue( "InterceptValue" ) >>= aOldValue;
+                if (aOldValue != aValue)
                 {
-                    double aOldValue = 0.0;
-                    xProperties->getPropertyValue( "InterceptValue" ) >>= aOldValue;
-                    if (aOldValue != aValue)
-                    {
-                        xProperties->setPropertyValue( "InterceptValue" , uno::makeAny( aValue ));
-                        bChanged = true;
-                    }
+                    xProperties->setPropertyValue( "InterceptValue" , uno::makeAny( aValue ));
+                    bChanged = true;
                 }
             }
         }
@@ -304,51 +286,42 @@ bool RegressionCurveItemConverter::ApplySpecialItem(
 
         case SCHATTR_REGRESSION_SHOW_EQUATION:
         {
-            OSL_ASSERT( xCurve.is());
-            if( xCurve.is())
+            bool bNewShow = static_cast< sal_Bool >(
+                static_cast< const SfxBoolItem & >(
+                    rItemSet.Get( nWhichId )).GetValue());
+
+            uno::Reference< beans::XPropertySet > xEqProp( xCurve->getEquationProperties());
+            OSL_ASSERT( xEqProp.is());
+            bool bOldShow = false;
+            if( xEqProp.is() &&
+                (xEqProp->getPropertyValue( "ShowEquation" ) >>= bOldShow) &&
+                bOldShow != bNewShow )
             {
-                bool bNewShow = static_cast< sal_Bool >(
-                    static_cast< const SfxBoolItem & >(
-                        rItemSet.Get( nWhichId )).GetValue());
-
-                uno::Reference< beans::XPropertySet > xEqProp( xCurve->getEquationProperties());
-                OSL_ASSERT( xEqProp.is());
-                bool bOldShow = false;
-                if( xEqProp.is() &&
-                    (xEqProp->getPropertyValue( "ShowEquation" ) >>= bOldShow) &&
-                    bOldShow != bNewShow )
-                {
-                    xEqProp->setPropertyValue( "ShowEquation" , uno::makeAny( bNewShow ));
-                    bChanged = true;
-                }
+                xEqProp->setPropertyValue( "ShowEquation" , uno::makeAny( bNewShow ));
+                bChanged = true;
             }
         }
         break;
 
         case SCHATTR_REGRESSION_SHOW_COEFF:
         {
-            OSL_ASSERT( xCurve.is());
-            if( xCurve.is())
+            bool bNewShow = static_cast< sal_Bool >(
+                static_cast< const SfxBoolItem & >(
+                    rItemSet.Get( nWhichId )).GetValue());
+
+            uno::Reference< beans::XPropertySet > xEqProp( xCurve->getEquationProperties());
+            OSL_ASSERT( xEqProp.is());
+            bool bOldShow = false;
+            if( xEqProp.is() &&
+                (xEqProp->getPropertyValue( "ShowCorrelationCoefficient" ) >>= bOldShow) &&
+                bOldShow != bNewShow )
             {
-                bool bNewShow = static_cast< sal_Bool >(
-                    static_cast< const SfxBoolItem & >(
-                        rItemSet.Get( nWhichId )).GetValue());
-
-                uno::Reference< beans::XPropertySet > xEqProp( xCurve->getEquationProperties());
-                OSL_ASSERT( xEqProp.is());
-                bool bOldShow = false;
-                if( xEqProp.is() &&
-                    (xEqProp->getPropertyValue( "ShowCorrelationCoefficient" ) >>= bOldShow) &&
-                    bOldShow != bNewShow )
-                {
-                    xEqProp->setPropertyValue( "ShowCorrelationCoefficient" , uno::makeAny( bNewShow ));
-                    bChanged = true;
-                }
+                xEqProp->setPropertyValue( "ShowCorrelationCoefficient" , uno::makeAny( bNewShow ));
+                bChanged = true;
             }
         }
         break;
     }
-
     return bChanged;
 }
 


More information about the Libreoffice-commits mailing list