[Libreoffice-commits] core.git: Branch 'feature/polynomialregression' - 2 commits - chart2/source

Tomaž Vajngerl quikee at gmail.com
Sun Jun 30 04:32:30 PDT 2013


 chart2/source/controller/dialogs/Strings_Statistic.src                   |    8 
 chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx |   30 +--
 chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx      |   24 +-
 chart2/source/controller/main/ChartController_Insert.cxx                 |   86 +++++-----
 chart2/source/inc/RegressionCurveHelper.hxx                              |   79 ++++-----
 chart2/source/tools/RegressionCurveHelper.cxx                            |   48 ++---
 6 files changed, 142 insertions(+), 133 deletions(-)

New commits:
commit cb0392bd0034c72f4bb2572089e38094b1c3163c
Author: Tomaž Vajngerl <quikee at gmail.com>
Date:   Sun Jun 30 13:27:24 2013 +0200

    Add legend name for polynomial and moving average trendlines.
    
    Change-Id: I111c82c66f1ee29dae50470fc08bb66c79da0652

diff --git a/chart2/source/controller/dialogs/Strings_Statistic.src b/chart2/source/controller/dialogs/Strings_Statistic.src
index bdbd736..7469f66 100644
--- a/chart2/source/controller/dialogs/Strings_Statistic.src
+++ b/chart2/source/controller/dialogs/Strings_Statistic.src
@@ -57,6 +57,14 @@ String STR_REGRESSION_POWER
 {
     Text [ en-US ] = "Power (%SERIESNAME)" ;
 };
+String STR_REGRESSION_POLYNOMIAL
+{
+    Text [ en-US ] = "Polynomial (%SERIESNAME)" ;
+};
+String STR_REGRESSION_MOVING_AVERAGE
+{
+    Text [ en-US ] = "Moving average (%SERIESNAME)" ;
+};
 
 String STR_REGRESSION_MEAN
 {
diff --git a/chart2/source/tools/RegressionCurveHelper.cxx b/chart2/source/tools/RegressionCurveHelper.cxx
index 551541b..a3b3cc8 100644
--- a/chart2/source/tools/RegressionCurveHelper.cxx
+++ b/chart2/source/tools/RegressionCurveHelper.cxx
@@ -593,7 +593,7 @@ OUString RegressionCurveHelper::getUINameForRegressionCurve( const Reference< XR
 {
     OUString aResult;
     Reference< lang::XServiceName > xServiceName( xRegressionCurve, uno::UNO_QUERY );
-    if( ! xServiceName.is())
+    if(!xServiceName.is())
         return aResult;
 
     OUString aServiceName( xServiceName->getServiceName());
@@ -629,20 +629,19 @@ OUString RegressionCurveHelper::getUINameForRegressionCurve( const Reference< XR
     return aResult;
 }
 
-::std::vector< Reference< chart2::XRegressionCurve > >
+std::vector< Reference< chart2::XRegressionCurve > >
     RegressionCurveHelper::getAllRegressionCurvesNotMeanValueLine(
         const Reference< chart2::XDiagram > & xDiagram )
 {
-    ::std::vector< Reference< chart2::XRegressionCurve > > aResult;
-    ::std::vector< Reference< chart2::XDataSeries > > aSeries( DiagramHelper::getDataSeriesFromDiagram( xDiagram ));
-    for( ::std::vector< Reference< chart2::XDataSeries > >::iterator aIt( aSeries.begin());
+    std::vector< Reference< chart2::XRegressionCurve > > aResult;
+    std::vector< Reference< chart2::XDataSeries > > aSeries( DiagramHelper::getDataSeriesFromDiagram( xDiagram ));
+    for( std::vector< Reference< chart2::XDataSeries > >::iterator aIt( aSeries.begin());
          aIt != aSeries.end(); ++aIt )
     {
-        Reference< chart2::XRegressionCurveContainer > xCurveCnt( *aIt, uno::UNO_QUERY );
-        if( xCurveCnt.is())
+        Reference< chart2::XRegressionCurveContainer > xContainer( *aIt, uno::UNO_QUERY );
+        if(xContainer.is())
         {
-            uno::Sequence< uno::Reference< chart2::XRegressionCurve > > aCurves(
-                xCurveCnt->getRegressionCurves());
+            uno::Sequence< uno::Reference< chart2::XRegressionCurve > > aCurves(xContainer->getRegressionCurves());
             for( sal_Int32 i = 0; i < aCurves.getLength(); ++i )
             {
                 if( ! isMeanValueLine( aCurves[i] ))
commit dea5ae729dfe46e97aaa733af6245c9451a7a1be
Author: Tomaž Vajngerl <quikee at gmail.com>
Date:   Sun Jun 30 13:21:18 2013 +0200

    Insert new trendline instead of changing the existing one.
    
    Change-Id: Ic7cbfa55c7b2e42eb21400b2fca34724a72de701

diff --git a/chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx b/chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx
index 9c4f1bf..6e9e8b1 100644
--- a/chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx
+++ b/chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx
@@ -76,8 +76,8 @@ namespace wrapper
 {
 
 RegressionCurveItemConverter::RegressionCurveItemConverter(
-    const uno::Reference< beans::XPropertySet > & rPropertySet,
-    const uno::Reference< chart2::XRegressionCurveContainer > & xRegCurveCnt,
+    const uno::Reference< beans::XPropertySet >& rPropertySet,
+    const uno::Reference< chart2::XRegressionCurveContainer >& xContainer,
     SfxItemPool& rItemPool,
     SdrModel& rDrawModel,
     const uno::Reference< lang::XMultiServiceFactory > & xNamedPropertyContainerFactory ) :
@@ -86,7 +86,7 @@ RegressionCurveItemConverter::RegressionCurveItemConverter(
                                   rPropertySet, rItemPool, rDrawModel,
                                   xNamedPropertyContainerFactory,
                                   GraphicPropertyItemConverter::LINE_PROPERTIES )),
-        m_xCurveContainer( xRegCurveCnt )
+        m_xCurveContainer( xContainer )
 {}
 
 RegressionCurveItemConverter::~RegressionCurveItemConverter()
@@ -146,11 +146,13 @@ bool RegressionCurveItemConverter::ApplySpecialItem(
                     // for which this converter was created. Not optimal, but
                     // currently the only way to handle the type in the
                     // regression curve properties dialog
-                    RegressionCurveHelper::changeRegressionCurveType(
-                        lcl_convertRegressionType( eNewRegress ),
-                        m_xCurveContainer,
-                        xCurve,
-                        uno::Reference< uno::XComponentContext >());
+                    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;
                 }
             }
@@ -167,9 +169,9 @@ bool RegressionCurveItemConverter::ApplySpecialItem(
 
                 uno::Reference< beans::XPropertySet > xProperties( xCurve, uno::UNO_QUERY );
                 OSL_ASSERT( xProperties.is());
-                sal_Int32 aOldDegree = 1;
                 if( xProperties.is() )
                 {
+                    sal_Int32 aOldDegree = 2;
                     xProperties->getPropertyValue( "PolynomialDegree" ) >>= aOldDegree;
                     if (aOldDegree != aDegree)
                     {
@@ -191,9 +193,9 @@ bool RegressionCurveItemConverter::ApplySpecialItem(
 
                 uno::Reference< beans::XPropertySet > xProperties( xCurve, uno::UNO_QUERY );
                 OSL_ASSERT( xProperties.is());
-                sal_Int32 aOldPeriod = 2;
                 if( xProperties.is() )
                 {
+                    sal_Int32 aOldPeriod = 2;
                     xProperties->getPropertyValue( "MovingAveragePeriod" ) >>= aOldPeriod;
                     if (aOldPeriod != aPeriod)
                     {
@@ -215,9 +217,9 @@ bool RegressionCurveItemConverter::ApplySpecialItem(
 
                 uno::Reference< beans::XPropertySet > xProperties( xCurve, uno::UNO_QUERY );
                 OSL_ASSERT( xProperties.is());
-                double aOldValue = 0.0;
                 if( xProperties.is() )
                 {
+                    double aOldValue = 0.0;
                     xProperties->getPropertyValue( "ExtrapolateForward" ) >>= aOldValue;
                     if (aOldValue != aValue)
                     {
@@ -239,9 +241,9 @@ bool RegressionCurveItemConverter::ApplySpecialItem(
 
                 uno::Reference< beans::XPropertySet > xProperties( xCurve, uno::UNO_QUERY );
                 OSL_ASSERT( xProperties.is());
-                double aOldValue = 0.0;
                 if( xProperties.is() )
                 {
+                    double aOldValue = 0.0;
                     xProperties->getPropertyValue( "ExtrapolateBackward" ) >>= aOldValue;
                     if (aOldValue != aValue)
                     {
@@ -263,9 +265,9 @@ bool RegressionCurveItemConverter::ApplySpecialItem(
 
                 uno::Reference< beans::XPropertySet > xProperties( xCurve, uno::UNO_QUERY );
                 OSL_ASSERT( xProperties.is());
-                sal_Bool bOldValue = false;
                 if( xProperties.is() )
                 {
+                    sal_Bool bOldValue = false;
                     xProperties->getPropertyValue( "ForceIntercept" ) >>= bOldValue;
                     if (bOldValue != bNewValue)
                     {
@@ -287,9 +289,9 @@ bool RegressionCurveItemConverter::ApplySpecialItem(
 
                 uno::Reference< beans::XPropertySet > xProperties( xCurve, uno::UNO_QUERY );
                 OSL_ASSERT( xProperties.is());
-                double aOldValue = 0.0;
                 if( xProperties.is() )
                 {
+                    double aOldValue = 0.0;
                     xProperties->getPropertyValue( "InterceptValue" ) >>= aOldValue;
                     if (aOldValue != aValue)
                     {
diff --git a/chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx b/chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx
index 2a8ebc8e..c3d7135 100644
--- a/chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx
+++ b/chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx
@@ -415,33 +415,35 @@ bool StatisticsItemConverter::ApplySpecialItem(
                 static_cast< const SvxChartRegressItem& >(
                     rItemSet.Get( nWhichId )).GetValue();
 
-            uno::Reference< chart2::XRegressionCurve > xRegressionCurve( GetPropertySet(), uno::UNO_QUERY );
-            uno::Reference< chart2::XRegressionCurveContainer > xRegressionCurveContainer( GetPropertySet(), uno::UNO_QUERY );
+            uno::Reference< chart2::XRegressionCurve > xCurve( GetPropertySet(), uno::UNO_QUERY );
+            uno::Reference< chart2::XRegressionCurveContainer > xContainer( GetPropertySet(), uno::UNO_QUERY );
 
             if( eRegress == CHREGRESS_NONE )
             {
-                if ( xRegressionCurve.is() )
+                if ( xContainer.is() )
                 {
-                    xRegressionCurveContainer->removeRegressionCurve( xRegressionCurve );
+                    xContainer->removeRegressionCurve( xCurve );
                     bChanged = true;
                 }
             }
             else
             {
-                if ( xRegressionCurve.is() )
+                if ( xCurve.is() )
                 {
                     SvxChartRegress eOldRegress(
                         static_cast< SvxChartRegress >(
                             static_cast< sal_Int32 >(
-                                RegressionCurveHelper::getRegressionType( xRegressionCurve ))));
+                                RegressionCurveHelper::getRegressionType( xCurve ))));
 
                     if( eOldRegress != eRegress )
                     {
-                        RegressionCurveHelper::changeRegressionCurveType(
-                            lcl_convertRegressionType( eRegress ),
-                            xRegressionCurveContainer,
-                            xRegressionCurve,
-                            uno::Reference< uno::XComponentContext >());
+                        xCurve = RegressionCurveHelper::changeRegressionCurveType(
+                                                lcl_convertRegressionType( eRegress ),
+                                                xContainer,
+                                                xCurve,
+                                                uno::Reference< uno::XComponentContext >());
+                        uno::Reference< beans::XPropertySet > xProperties( xCurve, uno::UNO_QUERY );
+                        resetPropertySet( xProperties );
                         bChanged = true;
                     }
                 }
diff --git a/chart2/source/controller/main/ChartController_Insert.cxx b/chart2/source/controller/main/ChartController_Insert.cxx
index 6461a8a..86123f8 100644
--- a/chart2/source/controller/main/ChartController_Insert.cxx
+++ b/chart2/source/controller/main/ChartController_Insert.cxx
@@ -409,55 +409,59 @@ void ChartController::executeDispatch_InsertMenu_Trendlines()
 
 void ChartController::executeDispatch_InsertTrendline()
 {
-    uno::Reference< chart2::XRegressionCurveContainer > xRegCurveCnt(
+    uno::Reference< chart2::XRegressionCurveContainer > xRegressionCurveContainer(
         ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getModel()), uno::UNO_QUERY );
-    if( xRegCurveCnt.is())
-    {
-        UndoLiveUpdateGuard aUndoGuard(
-            ActionDescriptionProvider::createDescription(
-                ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_CURVE ))),
-            m_xUndoManager );
 
-        // add a linear curve
+    if( !xRegressionCurveContainer.is() )
+        return;
+
+    UndoLiveUpdateGuard aUndoGuard(
+        ActionDescriptionProvider::createDescription(
+            ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_CURVE ))),
+        m_xUndoManager );
+
+    // add a linear curve
+    uno::Reference< chart2::XRegressionCurve > xCurve =
         RegressionCurveHelper::addRegressionCurve(
-            RegressionCurveHelper::REGRESSION_TYPE_LINEAR, xRegCurveCnt, m_xCC );
+            RegressionCurveHelper::REGRESSION_TYPE_LINEAR,
+            xRegressionCurveContainer,
+            m_xCC );
 
-        // get an appropriate item converter
-        uno::Reference< chart2::XRegressionCurve > xCurve(
-            RegressionCurveHelper::getFirstCurveNotMeanValueLine( xRegCurveCnt ));
-        uno::Reference< beans::XPropertySet > xCurveProp( xCurve, uno::UNO_QUERY );
-        if( !xCurveProp.is())
-            return;
-        wrapper::RegressionCurveItemConverter aItemConverter(
-            xCurveProp, xRegCurveCnt, m_pDrawModelWrapper->getSdrModel().GetItemPool(),
-            m_pDrawModelWrapper->getSdrModel(),
-            uno::Reference< lang::XMultiServiceFactory >( getModel(), uno::UNO_QUERY ));
+    // get an appropriate item converter
+    uno::Reference< beans::XPropertySet > xProperties( xCurve, uno::UNO_QUERY );
 
-        // open dialog
-        SfxItemSet aItemSet = aItemConverter.CreateEmptyItemSet();
-        aItemConverter.FillItemSet( aItemSet );
-        ObjectPropertiesDialogParameter aDialogParameter = ObjectPropertiesDialogParameter(
-            ObjectIdentifier::createDataCurveCID(
-                ObjectIdentifier::getSeriesParticleFromCID( m_aSelection.getSelectedCID()),
-                RegressionCurveHelper::getRegressionCurveIndex( xRegCurveCnt, xCurve ), false ));
-        aDialogParameter.init( getModel() );
-        ViewElementListProvider aViewElementListProvider( m_pDrawModelWrapper.get());
-        SolarMutexGuard aGuard;
-        SchAttribTabDlg aDialog( m_pChartWindow, &aItemSet, &aDialogParameter, &aViewElementListProvider,
-                              uno::Reference< util::XNumberFormatsSupplier >( getModel(), uno::UNO_QUERY ));
+    if( !xProperties.is())
+        return;
 
-        // note: when a user pressed "OK" but didn't change any settings in the
-        // dialog, the SfxTabDialog returns "Cancel"
-        if( aDialog.Execute() == RET_OK || aDialog.DialogWasClosedWithOK())
+    wrapper::RegressionCurveItemConverter aItemConverter(
+        xProperties, xRegressionCurveContainer, m_pDrawModelWrapper->getSdrModel().GetItemPool(),
+        m_pDrawModelWrapper->getSdrModel(),
+        uno::Reference< lang::XMultiServiceFactory >( getModel(), uno::UNO_QUERY ));
+
+    // open dialog
+    SfxItemSet aItemSet = aItemConverter.CreateEmptyItemSet();
+    aItemConverter.FillItemSet( aItemSet );
+    ObjectPropertiesDialogParameter aDialogParameter = ObjectPropertiesDialogParameter(
+        ObjectIdentifier::createDataCurveCID(
+            ObjectIdentifier::getSeriesParticleFromCID( m_aSelection.getSelectedCID()),
+            RegressionCurveHelper::getRegressionCurveIndex( xRegressionCurveContainer, xCurve ), false ));
+    aDialogParameter.init( getModel() );
+    ViewElementListProvider aViewElementListProvider( m_pDrawModelWrapper.get());
+    SolarMutexGuard aGuard;
+    SchAttribTabDlg aDialog( m_pChartWindow, &aItemSet, &aDialogParameter, &aViewElementListProvider,
+                          uno::Reference< util::XNumberFormatsSupplier >( getModel(), uno::UNO_QUERY ));
+
+    // note: when a user pressed "OK" but didn't change any settings in the
+    // dialog, the SfxTabDialog returns "Cancel"
+    if( aDialog.Execute() == RET_OK || aDialog.DialogWasClosedWithOK())
+    {
+        const SfxItemSet* pOutItemSet = aDialog.GetOutputItemSet();
+        if( pOutItemSet )
         {
-            const SfxItemSet* pOutItemSet = aDialog.GetOutputItemSet();
-            if( pOutItemSet )
-            {
-                ControllerLockGuard aCLGuard( getModel() );
-                aItemConverter.ApplyItemSet( *pOutItemSet );
-            }
-            aUndoGuard.commit();
+            ControllerLockGuard aCLGuard( getModel() );
+            aItemConverter.ApplyItemSet( *pOutItemSet );
         }
+        aUndoGuard.commit();
     }
 }
 
diff --git a/chart2/source/inc/RegressionCurveHelper.hxx b/chart2/source/inc/RegressionCurveHelper.hxx
index 5f209dd..4efa6f4 100644
--- a/chart2/source/inc/RegressionCurveHelper.hxx
+++ b/chart2/source/inc/RegressionCurveHelper.hxx
@@ -101,73 +101,64 @@ public:
     /** Returns the first regression curve found that is not of type
         mean-value line
      */
-    static ::com::sun::star::uno::Reference<
-            ::com::sun::star::chart2::XRegressionCurve >
+    static com::sun::star::uno::Reference<com::sun::star::chart2::XRegressionCurve >
         getFirstCurveNotMeanValueLine(
-            const ::com::sun::star::uno::Reference<
-                ::com::sun::star::chart2::XRegressionCurveContainer > & xRegCnt );
+            const com::sun::star::uno::Reference<
+                com::sun::star::chart2::XRegressionCurveContainer >& xCurveContainer );
 
     /** Returns the type of the first regression curve found that is not of type
         mean-value line
      */
     static tRegressionType getFirstRegressTypeNotMeanValueLine(
-        const ::com::sun::star::uno::Reference<
-            ::com::sun::star::chart2::XRegressionCurveContainer > & xRegCnt );
+        const com::sun::star::uno::Reference<
+            com::sun::star::chart2::XRegressionCurveContainer >& xCurveContainer );
 
     static tRegressionType getRegressionType(
-        const ::com::sun::star::uno::Reference<
-            ::com::sun::star::chart2::XRegressionCurve > & xCurve );
+        const com::sun::star::uno::Reference<
+            com::sun::star::chart2::XRegressionCurve >& xCurve );
 
     /** @param xPropertySource is taken as source to copy all properties from if
                not null
         @param xEquationProperties is set at the new regression curve as
                equation properties if not null
     */
-    static void addRegressionCurve( tRegressionType eType,
-            ::com::sun::star::uno::Reference<
-                ::com::sun::star::chart2::XRegressionCurveContainer > & xRegCnt,
-            const ::com::sun::star::uno::Reference<
-                ::com::sun::star::uno::XComponentContext > & xContext,
-            const ::com::sun::star::uno::Reference<
-                ::com::sun::star::beans::XPropertySet >& xPropertySource =
-                                ::com::sun::star::uno::Reference<
-                                    ::com::sun::star::beans::XPropertySet >(),
-            const ::com::sun::star::uno::Reference<
-                ::com::sun::star::beans::XPropertySet >& xEquationProperties =
-                                ::com::sun::star::uno::Reference<
-                                    ::com::sun::star::beans::XPropertySet >()
-        );
+    static com::sun::star::uno::Reference< com::sun::star::chart2::XRegressionCurve >
+        addRegressionCurve(
+            tRegressionType eType,
+            com::sun::star::uno::Reference<
+                com::sun::star::chart2::XRegressionCurveContainer >& xCurveContainer,
+            const com::sun::star::uno::Reference<
+                com::sun::star::uno::XComponentContext >& xContext,
+            const com::sun::star::uno::Reference<
+                com::sun::star::beans::XPropertySet >& xPropertySource =
+                    com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet >(),
+            const com::sun::star::uno::Reference<
+                com::sun::star::beans::XPropertySet >& xEquationProperties =
+                    com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet >() );
 
     static bool removeAllExceptMeanValueLine(
-        ::com::sun::star::uno::Reference<
-            ::com::sun::star::chart2::XRegressionCurveContainer > & xRegCnt );
+        com::sun::star::uno::Reference<
+            com::sun::star::chart2::XRegressionCurveContainer >& xCurveContainer );
 
     static void removeEquations(
-        ::com::sun::star::uno::Reference<
-            ::com::sun::star::chart2::XRegressionCurveContainer > & xRegCnt );
-
-    /** adds the given regression curve if there was none before. If there are
-        regression curves, the first one is replaced by the one given by the
-        type. All remaining curves are remnoved.
-
-        <p>This function ignores mean-value lines.</p>
-     */
-    static void changeRegressionCurveType(
-        tRegressionType eType,
-        com::sun::star::uno::Reference<
-            com::sun::star::chart2::XRegressionCurveContainer > & xRegressionCurveContainer,
         com::sun::star::uno::Reference<
-            com::sun::star::chart2::XRegressionCurve > & xRegressionCurve,
-        const com::sun::star::uno::Reference<
-            com::sun::star::uno::XComponentContext > & xContext );
+            com::sun::star::chart2::XRegressionCurveContainer >& xCurveContainer );
+
+    static com::sun::star::uno::Reference< com::sun::star::chart2::XRegressionCurve >
+        changeRegressionCurveType(
+            tRegressionType eType,
+            com::sun::star::uno::Reference<
+                com::sun::star::chart2::XRegressionCurveContainer > & xRegressionCurveContainer,
+            com::sun::star::uno::Reference<
+                com::sun::star::chart2::XRegressionCurve > & xRegressionCurve,
+            const com::sun::star::uno::Reference<
+                com::sun::star::uno::XComponentContext > & xContext );
 
     // ------------------------------------------------------------
 
     /// returns a calculator object for regression curves (used by the view)
-    static ::com::sun::star::uno::Reference<
-            ::com::sun::star::chart2::XRegressionCurveCalculator >
-        createRegressionCurveCalculatorByServiceName(
-            OUString aServiceName );
+    static com::sun::star::uno::Reference< com::sun::star::chart2::XRegressionCurveCalculator >
+        createRegressionCurveCalculatorByServiceName( OUString aServiceName );
 
     /** recalculates the regression parameters according to the data given in
         the data source.
diff --git a/chart2/source/tools/RegressionCurveHelper.cxx b/chart2/source/tools/RegressionCurveHelper.cxx
index 976d125..551541b 100644
--- a/chart2/source/tools/RegressionCurveHelper.cxx
+++ b/chart2/source/tools/RegressionCurveHelper.cxx
@@ -355,23 +355,24 @@ void RegressionCurveHelper::removeMeanValueLine(
     }
 }
 
-void RegressionCurveHelper::addRegressionCurve(
+uno::Reference< chart2::XRegressionCurve > RegressionCurveHelper::addRegressionCurve(
     tRegressionType eType,
-    uno::Reference< XRegressionCurveContainer > & xRegCnt,
-    const uno::Reference< XComponentContext > & /* xContext */,
+    uno::Reference< XRegressionCurveContainer >& xRegressionCurveContainer,
+    const uno::Reference< XComponentContext >& /* xContext */,
     const uno::Reference< beans::XPropertySet >& xPropertySource,
     const uno::Reference< beans::XPropertySet >& xEquationProperties )
 {
-    if( !xRegCnt.is() )
-        return;
+    uno::Reference< chart2::XRegressionCurve > xCurve;
+
+    if( !xRegressionCurveContainer.is() )
+        return xCurve;
 
     if( eType == REGRESSION_TYPE_NONE )
     {
         OSL_FAIL("don't create a regression curve of type none");
-        return;
+        return xCurve;
     }
 
-    uno::Reference< chart2::XRegressionCurve > xCurve;
     OUString aServiceName( lcl_getServiceNameForType( eType ));
     if( !aServiceName.isEmpty())
     {
@@ -389,17 +390,18 @@ void RegressionCurveHelper::addRegressionCurve(
                 comphelper::copyProperties( xPropertySource, xProperties );
             else
             {
-                uno::Reference< XPropertySet > xSeriesProp( xRegCnt, uno::UNO_QUERY );
+                uno::Reference< XPropertySet > xSeriesProp( xRegressionCurveContainer, uno::UNO_QUERY );
                 if( xSeriesProp.is())
                 {
                     xProperties->setPropertyValue( "LineColor",
                                              xSeriesProp->getPropertyValue( "Color"));
                 }
-//                 xProp->setPropertyValue( "LineWidth", uno::makeAny( sal_Int32( 100 )));
             }
         }
     }
-    xRegCnt->addRegressionCurve( xCurve );
+    xRegressionCurveContainer->addRegressionCurve( xCurve );
+
+    return xCurve;
 }
 
 /** removes all regression curves that are not of type mean value
@@ -472,14 +474,14 @@ void RegressionCurveHelper::removeEquations(
     }
 }
 
-void RegressionCurveHelper::changeRegressionCurveType(
+uno::Reference< XRegressionCurve > RegressionCurveHelper::changeRegressionCurveType(
     tRegressionType eType,
     uno::Reference< XRegressionCurveContainer > & xRegressionCurveContainer,
     uno::Reference< XRegressionCurve > & xRegressionCurve,
     const uno::Reference< XComponentContext > & xContext )
 {
     xRegressionCurveContainer->removeRegressionCurve( xRegressionCurve );
-    RegressionCurveHelper::addRegressionCurve(
+    return RegressionCurveHelper::addRegressionCurve(
             eType,
             xRegressionCurveContainer,
             xContext,
@@ -672,13 +674,14 @@ void RegressionCurveHelper::resetEquationPosition(
 }
 
 sal_Int32 RegressionCurveHelper::getRegressionCurveIndex(
-    const Reference< chart2::XRegressionCurveContainer > & xContainer,
-    const Reference< chart2::XRegressionCurve > & xCurve )
+    const Reference< chart2::XRegressionCurveContainer >& xContainer,
+    const Reference< chart2::XRegressionCurve >& xCurve )
 {
     if( xContainer.is())
     {
         uno::Sequence< uno::Reference< XRegressionCurve > > aCurves(
             xContainer->getRegressionCurves());
+
         for( sal_Int32 i = 0; i < aCurves.getLength(); ++i )
         {
             if( xCurve == aCurves[i] )


More information about the Libreoffice-commits mailing list