[Libreoffice-commits] core.git: Branch 'feature/polynomialregression' - xmloff/Library_xo.mk xmloff/source

Tomaž Vajngerl quikee at gmail.com
Wed Jun 5 10:28:16 PDT 2013


 xmloff/Library_xo.mk                                       |    1 
 xmloff/source/chart/PropertyMap.hxx                        |    8 
 xmloff/source/chart/PropertyMaps.cxx                       |   40 ++
 xmloff/source/chart/SchXMLChartContext.cxx                 |   16 -
 xmloff/source/chart/SchXMLExport.cxx                       |  180 +++++++------
 xmloff/source/chart/SchXMLRegressionCurveObjectContext.cxx |   19 -
 xmloff/source/chart/SchXMLSeries2Context.cxx               |   78 +++--
 xmloff/source/chart/XMLRegressionTypePropertyHdl.cxx       |   62 ----
 xmloff/source/chart/XMLRegressionTypePropertyHdl.hxx       |   27 -
 9 files changed, 211 insertions(+), 220 deletions(-)

New commits:
commit fd3e61a6036ddc102c215f57c4149feb47265864
Author: Tomaž Vajngerl <quikee at gmail.com>
Date:   Wed Jun 5 19:22:57 2013 +0200

    ODT regression curves export refactored to use chart2 API
    
    Additionally fix import when regression-type is defined on series style.
    
    Change-Id: I194780619dc7b8a2b428867d4b5906180ee1fac1

diff --git a/xmloff/Library_xo.mk b/xmloff/Library_xo.mk
index 3196831..b3a100b 100644
--- a/xmloff/Library_xo.mk
+++ b/xmloff/Library_xo.mk
@@ -81,7 +81,6 @@ $(eval $(call gb_Library_add_exception_objects,xo,\
     xmloff/source/chart/XMLErrorBarStylePropertyHdl \
     xmloff/source/chart/XMLErrorIndicatorPropertyHdl \
     xmloff/source/chart/XMLLabelSeparatorContext \
-    xmloff/source/chart/XMLRegressionTypePropertyHdl \
     xmloff/source/chart/XMLSymbolImageContext \
     xmloff/source/chart/XMLSymbolTypePropertyHdl \
     xmloff/source/chart/XMLTextOrientationHdl \
diff --git a/xmloff/source/chart/PropertyMap.hxx b/xmloff/source/chart/PropertyMap.hxx
index a5f1bd2..0f48024 100644
--- a/xmloff/source/chart/PropertyMap.hxx
+++ b/xmloff/source/chart/PropertyMap.hxx
@@ -20,7 +20,7 @@
 #define _PROPERTYMAP_HXX_
 
 #include <xmloff/maptype.hxx>
-#include "xmloff/xmlnmspe.hxx"
+#include <xmloff/xmlnmspe.hxx>
 #include <xmloff/xmltoken.hxx>
 #include <xmloff/xmltypes.hxx>
 #include <xmloff/contextid.hxx>
@@ -38,7 +38,7 @@
 // custom types
 #define XML_SCH_TYPE_AXIS_ARRANGEMENT       ( XML_SCH_TYPES_START + 0 )
 #define XML_SCH_TYPE_ERROR_BAR_STYLE        ( XML_SCH_TYPES_START + 1 )
-#define XML_SCH_TYPE_REGRESSION_TYPE        ( XML_SCH_TYPES_START + 2 )
+// free
 #define XML_SCH_TYPE_SOLID_TYPE             ( XML_SCH_TYPES_START + 3 )
 #define XML_SCH_TYPE_ERROR_INDICATOR_UPPER  ( XML_SCH_TYPES_START + 4 )
 #define XML_SCH_TYPE_ERROR_INDICATOR_LOWER  ( XML_SCH_TYPES_START + 5 )
@@ -80,8 +80,8 @@
 #define XML_SCH_CONTEXT_SPECIAL_SYMBOL_IMAGE_NAME   ( XML_SCH_CTF_START + 22 )
 #define XML_SCH_CONTEXT_SPECIAL_SYMBOL_IMAGE        ( XML_SCH_CTF_START + 23 )
 #define XML_SCH_CONTEXT_SPECIAL_LABEL_SEPARATOR     ( XML_SCH_CTF_START + 24 )
-
 #define XML_SCH_CONTEXT_SPECIAL_ERRORBAR_RANGE      ( XML_SCH_CTF_START + 25 )
+#define XML_SCH_CONTEXT_SPECIAL_REGRESSION_TYPE     ( XML_SCH_CTF_START + 26 )
 
 #define MAP_FULL( ApiName, NameSpace, XMLTokenName, XMLType, ContextId, EarliestODFVersionForExport ) { ApiName, sizeof(ApiName)-1, XML_NAMESPACE_##NameSpace, xmloff::token::XMLTokenName, XMLType|XML_TYPE_PROP_CHART, ContextId, EarliestODFVersionForExport }
 #define MAP_ENTRY( a, ns, nm, t )            { a, sizeof(a)-1, XML_NAMESPACE_##ns, xmloff::token::nm, t|XML_TYPE_PROP_CHART, 0, SvtSaveOptions::ODFVER_010 }
@@ -183,7 +183,7 @@ const XMLPropertyMapEntry aXMLChartPropMap[] =
     MAP_ENTRY( "ShowNegativeError", CHART, XML_ERROR_LOWER_INDICATOR, XML_TYPE_BOOL),
     MAP_ENTRY( "ErrorBarStyle", CHART, XML_ERROR_CATEGORY, XML_SCH_TYPE_ERROR_BAR_STYLE ),
     MAP_ENTRY( "PercentageError", CHART, XML_ERROR_PERCENTAGE, XML_TYPE_DOUBLE ),
-    MAP_ENTRY( "RegressionType", CHART, XML_REGRESSION_TYPE, XML_SCH_TYPE_REGRESSION_TYPE ),
+    MAP_SPECIAL( "RegressionType", CHART, XML_REGRESSION_TYPE, XML_TYPE_STRING, XML_SCH_CONTEXT_SPECIAL_REGRESSION_TYPE ),
     MAP_SPECIAL_ODF12( "ErrorBarRangePositive", CHART, XML_ERROR_UPPER_RANGE, XML_TYPE_STRING, XML_SCH_CONTEXT_SPECIAL_ERRORBAR_RANGE ), // export only
     MAP_SPECIAL_ODF12( "ErrorBarRangeNegative", CHART, XML_ERROR_LOWER_RANGE, XML_TYPE_STRING, XML_SCH_CONTEXT_SPECIAL_ERRORBAR_RANGE ), // export only
 
diff --git a/xmloff/source/chart/PropertyMaps.cxx b/xmloff/source/chart/PropertyMaps.cxx
index 8f17023..5a400d3 100644
--- a/xmloff/source/chart/PropertyMaps.cxx
+++ b/xmloff/source/chart/PropertyMaps.cxx
@@ -35,7 +35,6 @@
 #include "XMLTextOrientationHdl.hxx"
 #include "XMLSymbolTypePropertyHdl.hxx"
 #include "XMLAxisPositionPropertyHdl.hxx"
-#include "XMLRegressionTypePropertyHdl.hxx"
 
 #include <xmloff/EnumPropertyHdl.hxx>
 #include <xmloff/XMLConstantsPropertyHandler.hxx>
@@ -118,10 +117,6 @@ const XMLPropertyHandler* XMLChartPropHdlFactory::GetPropertyHandler( sal_Int32
                                                ::getCppuType((const sal_Int32*)0) );
                 break;
 
-            case XML_SCH_TYPE_REGRESSION_TYPE:
-                pHdl = new XMLRegressionTypePropertyHdl( );
-                break;
-
             case XML_SCH_TYPE_ERROR_INDICATOR_LOWER:
                 pHdl = new XMLErrorIndicatorPropertyHdl( sal_False );
                 break;
@@ -467,6 +462,24 @@ void XMLChartExportPropertyMapper::handleSpecialItem(
                     sValueBuffer.append(convertRange(aRangeStr, mxChartDoc));
                 }
                 break;
+            case XML_SCH_CONTEXT_SPECIAL_REGRESSION_TYPE:
+                {
+                    OUString aServiceName;
+                    rProperty.maValue >>= aServiceName;
+                    if      (aServiceName == OUString("com.sun.star.chart2.LinearRegressionCurve"))
+                        sValueBuffer.append( GetXMLToken( XML_LINEAR ));
+                    else if (aServiceName == OUString("com.sun.star.chart2.LogarithmicRegressionCurve"))
+                        sValueBuffer.append( GetXMLToken( XML_LOGARITHMIC ));
+                    else if (aServiceName == OUString("com.sun.star.chart2.ExponentialRegressionCurve"))
+                        sValueBuffer.append( GetXMLToken( XML_EXPONENTIAL ));
+                    else if (aServiceName == OUString("com.sun.star.chart2.PotentialRegressionCurve"))
+                        sValueBuffer.append( GetXMLToken( XML_POWER ));
+                    else if (aServiceName == OUString("com.sun.star.chart2.PolynomialRegressionCurve"))
+                        sValueBuffer.append( GetXMLToken( XML_POLYNOMIAL ));
+                    else if (aServiceName == OUString("com.sun.star.chart2.MovingAverageRegressionCurve"))
+                        sValueBuffer.append( GetXMLToken( XML_MOVING_AVERAGE ));
+                }
+                break;
 
             default:
                 bHandled = sal_False;
@@ -626,6 +639,23 @@ bool XMLChartImportPropertyMapper::handleSpecialItem(
                 rProperty.maValue <<= mrImport.ResolveGraphicObjectURL( rValue, sal_False );
                 break;
 
+            case XML_SCH_CONTEXT_SPECIAL_REGRESSION_TYPE:
+            {
+                if      (IsXMLToken( rValue, XML_LINEAR ))
+                    rProperty.maValue <<= OUString("com.sun.star.chart2.LinearRegressionCurve");
+                else if (IsXMLToken( rValue, XML_LOGARITHMIC))
+                    rProperty.maValue <<= OUString("com.sun.star.chart2.LogarithmicRegressionCurve");
+                else if (IsXMLToken( rValue, XML_EXPONENTIAL))
+                    rProperty.maValue <<= OUString("com.sun.star.chart2.ExponentialRegressionCurve");
+                else if (IsXMLToken( rValue, XML_POWER))
+                    rProperty.maValue <<= OUString("com.sun.star.chart2.PotentialRegressionCurve");
+                else if (IsXMLToken( rValue, XML_POLYNOMIAL))
+                    rProperty.maValue <<= OUString("com.sun.star.chart2.PolynomialRegressionCurve");
+                else if (IsXMLToken( rValue, XML_MOVING_AVERAGE))
+                    rProperty.maValue <<= OUString("com.sun.star.chart2.MovingAverageRegressionCurve");
+            }
+            break;
+
             default:
                 bRet = sal_False;
                 break;
diff --git a/xmloff/source/chart/SchXMLChartContext.cxx b/xmloff/source/chart/SchXMLChartContext.cxx
index bb5f9d8..ba00934 100644
--- a/xmloff/source/chart/SchXMLChartContext.cxx
+++ b/xmloff/source/chart/SchXMLChartContext.cxx
@@ -882,14 +882,18 @@ void SchXMLChartContext::EndElement()
             //don't set series styles for donut charts
             if( !bSpecialHandlingForDonutChart )
             {
-                SchXMLSeries2Context::setStylesToSeries( maSeriesDefaultsAndStyles
-                                                         , pStylesCtxt, pStyle, sCurrStyleName, mrImportHelper, GetImport(), mbIsStockChart, maLSequencesPerIndex );
+                SchXMLSeries2Context::setStylesToSeries(
+                                        maSeriesDefaultsAndStyles, pStylesCtxt, pStyle,
+                                        sCurrStyleName, mrImportHelper, GetImport(),
+                                        mbIsStockChart, maLSequencesPerIndex );
                 // ... then set attributes for statistics (after their existence was set in the series)
-                SchXMLSeries2Context::setStylesToStatisticsObjects( maSeriesDefaultsAndStyles
-                            , pStylesCtxt, pStyle, sCurrStyleName );
+                SchXMLSeries2Context::setStylesToStatisticsObjects(
+                                        maSeriesDefaultsAndStyles, pStylesCtxt,
+                                        pStyle, sCurrStyleName );
 
-                SchXMLSeries2Context::setStylesToRegressionCurves( maSeriesDefaultsAndStyles
-                            , pStylesCtxt, pStyle, sCurrStyleName );
+                SchXMLSeries2Context::setStylesToRegressionCurves(
+                                        maSeriesDefaultsAndStyles, pStylesCtxt,
+                                        pStyle, sCurrStyleName );
             }
         }
 
diff --git a/xmloff/source/chart/SchXMLExport.cxx b/xmloff/source/chart/SchXMLExport.cxx
index 2eb8b2c..a42c302 100644
--- a/xmloff/source/chart/SchXMLExport.cxx
+++ b/xmloff/source/chart/SchXMLExport.cxx
@@ -2917,96 +2917,128 @@ void SchXMLExportHelper_Impl::exportRegressionCurve(
 
     std::vector< XMLPropertyState > aPropertyStates;
     std::vector< XMLPropertyState > aEquationPropertyStates;
-    Reference< beans::XPropertySet > xStatProp;
-    try
-    {
-        Any aPropAny( xSeriesProp->getPropertyValue(
-                          OUString(  "DataRegressionProperties" )));
-        aPropAny >>= xStatProp;
-    }
-    catch( const uno::Exception & rEx )
-    {
-        SAL_INFO("xmloff.chart", "Exception caught during Export of series - optional DataRegressionProperties not available: " << rEx.Message );
-    }
 
-    if( xStatProp.is() )
+    Reference< chart2::XRegressionCurveContainer > xRegressionCurveContainer( xSeries, uno::UNO_QUERY );
+    if( xRegressionCurveContainer.is() )
     {
-        Reference< chart2::XRegressionCurve > xRegCurve( SchXMLTools::getRegressionCurve( xSeries ));
-        Reference< beans::XPropertySet > xEquationProperties;
-        if( xRegCurve.is())
-            xEquationProperties.set( xRegCurve->getEquationProperties());
+        Sequence< Reference< chart2::XRegressionCurve > > aRegCurveSeq = xRegressionCurveContainer->getRegressionCurves();
 
-        bool bShowEquation = false;
-        bool bShowRSquared = false;
-        bool bExportEquation = false;
-        aPropertyStates = mxExpPropMapper->Filter( xStatProp );
-        if( xEquationProperties.is())
+        const Reference< chart2::XRegressionCurve >* pBeg = aRegCurveSeq.getConstArray();
+        const Reference< chart2::XRegressionCurve >* pEnd = pBeg + aRegCurveSeq.getLength();
+        const Reference< chart2::XRegressionCurve >* pIt;
+
+        for( pIt = pBeg; pIt != pEnd; pIt++ )
         {
-            xEquationProperties->getPropertyValue( OUString(  "ShowEquation" ))
-                >>= bShowEquation;
-            xEquationProperties->getPropertyValue( OUString(  "ShowCorrelationCoefficient" ))
-                >>= bShowRSquared;
-            bExportEquation = ( bShowEquation || bShowRSquared );
-            const SvtSaveOptions::ODFDefaultVersion nCurrentVersion( SvtSaveOptions().GetODFDefaultVersion() );
-            if( nCurrentVersion < SvtSaveOptions::ODFVER_012 )
-                bExportEquation=false;
-            if( bExportEquation )
+            Reference< chart2::XRegressionCurve > xRegCurve = *pIt;
+            if (!xRegCurve.is())
+                continue;
+
+            bool bShowEquation = false;
+            bool bShowRSquared = false;
+            bool bExportEquation = false;
+
+            Reference< beans::XPropertySet > xProperties( xRegCurve , uno::UNO_QUERY );
+
+            OUString aService;
+
+            Reference< lang::XServiceName > xServiceName( xProperties, uno::UNO_QUERY );
+            if( !xServiceName.is() )
+                continue;
+            aService = xServiceName->getServiceName();
+
+            aPropertyStates = mxExpPropMapper->Filter( xProperties );
+
+            // Add service name (which is regression type)
+            sal_Int32 nIndex = GetPropertySetMapper()->FindEntryIndex(XML_SCH_CONTEXT_SPECIAL_REGRESSION_TYPE);
+            XMLPropertyState property(nIndex,  uno::makeAny(aService));
+            aPropertyStates.push_back(property);
+
+            Reference< beans::XPropertySet > xEquationProperties;
+            if( xRegCurve.is())
+            {
+                xEquationProperties.set( xRegCurve->getEquationProperties() );
+            }
+
+            if( xEquationProperties.is())
             {
-                // number format
-                sal_Int32 nNumberFormat = 0;
-                if( ( xEquationProperties->getPropertyValue(
-                          OUString(  "NumberFormat" )) >>= nNumberFormat ) &&
-                    nNumberFormat != -1 )
+                xEquationProperties->getPropertyValue( OUString("ShowEquation")) >>= bShowEquation;
+                xEquationProperties->getPropertyValue( OUString("ShowCorrelationCoefficient")) >>= bShowRSquared;
+
+                bExportEquation = ( bShowEquation || bShowRSquared );
+                const SvtSaveOptions::ODFDefaultVersion nCurrentVersion( SvtSaveOptions().GetODFDefaultVersion() );
+                if( nCurrentVersion < SvtSaveOptions::ODFVER_012 )
+                {
+                    bExportEquation=false;
+                }
+                if( bExportEquation )
                 {
-                    mrExport.addDataStyle( nNumberFormat );
+                    // number format
+                    sal_Int32 nNumberFormat = 0;
+                    if( (xEquationProperties->getPropertyValue(OUString("NumberFormat")) >>= nNumberFormat ) &&
+                        nNumberFormat != -1 )
+                    {
+                        mrExport.addDataStyle( nNumberFormat );
+                    }
+                    aEquationPropertyStates = mxExpPropMapper->Filter( xEquationProperties );
                 }
-                aEquationPropertyStates = mxExpPropMapper->Filter( xEquationProperties );
             }
-        }
 
-        if( !aPropertyStates.empty() || bExportEquation )
-        {
-            // write element
-            if( bExportContent )
+            if( !aPropertyStates.empty() || bExportEquation )
             {
-                // add style name attribute
-                if( !aPropertyStates.empty())
-                    AddAutoStyleAttribute( aPropertyStates );
-                SvXMLElementExport aRegressionExport( mrExport, XML_NAMESPACE_CHART, XML_REGRESSION_CURVE, sal_True, sal_True );
-                if( bExportEquation )
+                // write element
+                if( bExportContent )
                 {
-                    // default is true
-                    if( !bShowEquation )
-                        mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_DISPLAY_EQUATION, XML_FALSE );
-                    // default is false
-                    if( bShowRSquared )
-                        mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_DISPLAY_R_SQUARE, XML_TRUE );
-
-                    // export position
-                    chart2::RelativePosition aRelativePosition;
-                    if( xEquationProperties->getPropertyValue(
-                            OUString( "RelativePosition")) >>= aRelativePosition )
+                    // add style name attribute
+                    if( !aPropertyStates.empty())
                     {
-                        double fX = aRelativePosition.Primary * rPageSize.Width;
-                        double fY = aRelativePosition.Secondary * rPageSize.Height;
-                        awt::Point aPos;
-                        aPos.X = static_cast< sal_Int32 >( ::rtl::math::round( fX ));
-                        aPos.Y = static_cast< sal_Int32 >( ::rtl::math::round( fY ));
-                        addPosition( aPos );
+                        AddAutoStyleAttribute( aPropertyStates );
                     }
 
-                    if( !aEquationPropertyStates.empty())
-                        AddAutoStyleAttribute( aEquationPropertyStates );
+                    SvXMLElementExport aRegressionExport( mrExport, XML_NAMESPACE_CHART, XML_REGRESSION_CURVE, sal_True, sal_True );
+                    if( bExportEquation )
+                    {
+                        // default is true
+                        if( !bShowEquation )
+                        {
+                            mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_DISPLAY_EQUATION, XML_FALSE );
+                        }
+                        // default is false
+                        if( bShowRSquared )
+                        {
+                            mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_DISPLAY_R_SQUARE, XML_TRUE );
+                        }
 
-                    SvXMLElementExport( mrExport, XML_NAMESPACE_CHART, XML_EQUATION, sal_True, sal_True );
+                        // export position
+                        chart2::RelativePosition aRelativePosition;
+                        if( xEquationProperties->getPropertyValue(OUString( "RelativePosition")) >>= aRelativePosition )
+                        {
+                            double fX = aRelativePosition.Primary * rPageSize.Width;
+                            double fY = aRelativePosition.Secondary * rPageSize.Height;
+                            awt::Point aPos;
+                            aPos.X = static_cast< sal_Int32 >( ::rtl::math::round( fX ));
+                            aPos.Y = static_cast< sal_Int32 >( ::rtl::math::round( fY ));
+                            addPosition( aPos );
+                        }
+
+                        if( !aEquationPropertyStates.empty())
+                        {
+                            AddAutoStyleAttribute( aEquationPropertyStates );
+                        }
+
+                        SvXMLElementExport( mrExport, XML_NAMESPACE_CHART, XML_EQUATION, sal_True, sal_True );
+                    }
+                }
+                else    // autostyles
+                {
+                    if( !aPropertyStates.empty())
+                    {
+                        CollectAutoStyle( aPropertyStates );
+                    }
+                    if( bExportEquation && !aEquationPropertyStates.empty())
+                    {
+                        CollectAutoStyle( aEquationPropertyStates );
+                    }
                 }
-            }
-            else    // autostyles
-            {
-                if( !aPropertyStates.empty())
-                    CollectAutoStyle( aPropertyStates );
-                if( bExportEquation && !aEquationPropertyStates.empty())
-                    CollectAutoStyle( aEquationPropertyStates );
             }
         }
     }
diff --git a/xmloff/source/chart/SchXMLRegressionCurveObjectContext.cxx b/xmloff/source/chart/SchXMLRegressionCurveObjectContext.cxx
index 0e45160..acb0134 100644
--- a/xmloff/source/chart/SchXMLRegressionCurveObjectContext.cxx
+++ b/xmloff/source/chart/SchXMLRegressionCurveObjectContext.cxx
@@ -173,7 +173,7 @@ void SchXMLEquationContext::StartElement( const uno::Reference< xml::sax::XAttri
 
     if( !sAutoStyleName.isEmpty() || bShowEquation || bShowRSquare )
     {
-        uno::Reference< beans::XPropertySet > xEqProp = chart2::RegressionEquation::create( comphelper::getProcessComponentContext() );
+        uno::Reference< beans::XPropertySet > xEqationProperties = chart2::RegressionEquation::create( comphelper::getProcessComponentContext() );
 
         if( !sAutoStyleName.isEmpty() )
         {
@@ -182,26 +182,25 @@ void SchXMLEquationContext::StartElement( const uno::Reference< xml::sax::XAttri
             {
                 const SvXMLStyleContext* pStyle = pStylesCtxt->FindStyleChildContext(
                     mrImportHelper.GetChartFamilyID(), sAutoStyleName );
-                // note: SvXMLStyleContext::FillPropertySet is not const
-                XMLPropStyleContext * pPropStyleContext =
-                    const_cast< XMLPropStyleContext * >( dynamic_cast< const XMLPropStyleContext * >( pStyle ));
+
+                XMLPropStyleContext* pPropStyleContext =
+                    const_cast< XMLPropStyleContext* >( dynamic_cast< const XMLPropStyleContext* >( pStyle ));
 
                 if( pPropStyleContext )
-                    pPropStyleContext->FillPropertySet( xEqProp );
+                    pPropStyleContext->FillPropertySet( xEqationProperties );
             }
         }
-        xEqProp->setPropertyValue( OUString( "ShowEquation"), uno::makeAny( bShowEquation ));
-        xEqProp->setPropertyValue( OUString( "ShowCorrelationCoefficient"), uno::makeAny( bShowRSquare ));
+        xEqationProperties->setPropertyValue( OUString( "ShowEquation"), uno::makeAny( bShowEquation ));
+        xEqationProperties->setPropertyValue( OUString( "ShowCorrelationCoefficient"), uno::makeAny( bShowRSquare ));
 
         if( bHasXPos && bHasYPos )
         {
             chart2::RelativePosition aRelPos;
             aRelPos.Primary = static_cast< double >( aPosition.X ) / static_cast< double >( maChartSize.Width );
             aRelPos.Secondary = static_cast< double >( aPosition.Y ) / static_cast< double >( maChartSize.Height );
-            xEqProp->setPropertyValue( OUString(  "RelativePosition" ),
-                                       uno::makeAny( aRelPos ));
+            xEqationProperties->setPropertyValue( OUString(  "RelativePosition" ), uno::makeAny( aRelPos ));
         }
-        mrRegressionStyle.m_xEquationProperties.set( xEqProp );
+        mrRegressionStyle.m_xEquationProperties.set( xEqationProperties );
     }
 }
 
diff --git a/xmloff/source/chart/SchXMLSeries2Context.cxx b/xmloff/source/chart/SchXMLSeries2Context.cxx
index 45c7295..c13b5dd 100644
--- a/xmloff/source/chart/SchXMLSeries2Context.cxx
+++ b/xmloff/source/chart/SchXMLSeries2Context.cxx
@@ -241,6 +241,17 @@ Reference< chart2::data::XLabeledDataSequence2 > lcl_createAndAddSequenceToSerie
     return xLabeledSeq;
 }
 
+XMLPropStyleContext* lcl_GetStyleContext(
+                        const SvXMLStylesContext* pStylesCtxt,
+                        const SvXMLStyleContext*& rpStyle,
+                        OUString& rStyleName )
+{
+    rpStyle = pStylesCtxt->FindStyleChildContext( SchXMLImportHelper::GetChartFamilyID(), rStyleName );
+    XMLPropStyleContext* pPropStyleContext =
+                    const_cast< XMLPropStyleContext* >(dynamic_cast< const XMLPropStyleContext* >( rpStyle ));
+    return pPropStyleContext;
+}
+
 } // anonymous namespace
 
 // ================================================================================
@@ -850,58 +861,63 @@ void SchXMLSeries2Context::setStylesToRegressionCurves(
                                 SeriesDefaultsAndStyles& rSeriesDefaultsAndStyles,
                                 const SvXMLStylesContext* pStylesCtxt,
                                 const SvXMLStyleContext*& rpStyle,
-                                OUString& rCurrStyleName )
+                                OUString& rCurrentStyleName )
 {
     std::list< RegressionStyle >::iterator iStyle;
 
     // iterate over regession etc
-    for( iStyle = rSeriesDefaultsAndStyles.maRegressionStyleList.begin(); iStyle != rSeriesDefaultsAndStyles.maRegressionStyleList.end(); ++iStyle )
+    for( iStyle = rSeriesDefaultsAndStyles.maRegressionStyleList.begin(); iStyle != rSeriesDefaultsAndStyles.maRegressionStyleList.end(); iStyle++ )
     {
         try
         {
-            if( !(iStyle->msStyleName).isEmpty() )
+            OUString aServiceName;
+            XMLPropStyleContext* pPropStyleContext;
+
+            if (!rCurrentStyleName.isEmpty())
             {
-                if( !rCurrStyleName.equals( iStyle->msStyleName ) )
+                XMLPropStyleContext* pCurrent = lcl_GetStyleContext(pStylesCtxt, rpStyle, rCurrentStyleName);
+                if( pCurrent )
                 {
-                    rCurrStyleName = iStyle->msStyleName;
-                    rpStyle = pStylesCtxt->FindStyleChildContext(
-                        SchXMLImportHelper::GetChartFamilyID(), rCurrStyleName );
+                    pPropStyleContext = pCurrent;
+                    uno::Any aAny = SchXMLTools::getPropertyFromContext("RegressionType", pPropStyleContext, pStylesCtxt);
+                    if ( aAny.hasValue() )
+                    {
+                        aAny >>= aServiceName;
+                    }
                 }
+            }
 
-                XMLPropStyleContext* pPropStyleContext =
-                    const_cast< XMLPropStyleContext* >(
-                        dynamic_cast< const XMLPropStyleContext* >( rpStyle ));
-
-                if( pPropStyleContext )
+            if (!iStyle->msStyleName.isEmpty())
+            {
+                XMLPropStyleContext* pCurrent = lcl_GetStyleContext(pStylesCtxt, rpStyle, iStyle->msStyleName);
+                if( pCurrent )
                 {
+                    pPropStyleContext = pCurrent;
                     uno::Any aAny = SchXMLTools::getPropertyFromContext("RegressionType", pPropStyleContext, pStylesCtxt);
-
                     if ( aAny.hasValue() )
                     {
-                        OUString aServiceName;
                         aAny >>= aServiceName;
+                    }
+                }
+            }
 
-                        if( !aServiceName.isEmpty() )
-                        {
-                            Reference< lang::XMultiServiceFactory > xMSF( comphelper::getProcessServiceFactory(), uno::UNO_QUERY );
-                            Reference< chart2::XRegressionCurve > xRegCurve( xMSF->createInstance( aServiceName ), uno::UNO_QUERY_THROW );
-                            if( xRegCurve.is())
-                            {
-                                Reference< beans::XPropertySet > xCurveProperties( xRegCurve, uno::UNO_QUERY );
-                                pPropStyleContext->FillPropertySet( xCurveProperties );
-
-                                xRegCurve->setEquationProperties( iStyle->m_xEquationProperties );
-                            }
-
-                            Reference< chart2::XRegressionCurveContainer > xRegCurveCont( iStyle->m_xSeries, uno::UNO_QUERY_THROW );
-                            xRegCurveCont->addRegressionCurve( xRegCurve );
+            if( !aServiceName.isEmpty() )
+            {
+                Reference< lang::XMultiServiceFactory > xMSF( comphelper::getProcessServiceFactory(), uno::UNO_QUERY );
+                Reference< chart2::XRegressionCurve > xRegCurve( xMSF->createInstance( aServiceName ), uno::UNO_QUERY_THROW );
+                if( xRegCurve.is())
+                {
+                    Reference< beans::XPropertySet > xCurveProperties( xRegCurve, uno::UNO_QUERY );
+                    pPropStyleContext->FillPropertySet( xCurveProperties );
 
-                        }
-                    }
+                    xRegCurve->setEquationProperties( iStyle->m_xEquationProperties );
                 }
+
+                Reference< chart2::XRegressionCurveContainer > xRegCurveCont( iStyle->m_xSeries, uno::UNO_QUERY_THROW );
+                xRegCurveCont->addRegressionCurve( xRegCurve );
             }
         }
-        catch( const uno::Exception & rEx )
+        catch( const uno::Exception& rEx )
         {
             SAL_INFO("xmloff.chart", "Exception caught during setting styles to series: " << rEx.Message );
         }
diff --git a/xmloff/source/chart/XMLRegressionTypePropertyHdl.cxx b/xmloff/source/chart/XMLRegressionTypePropertyHdl.cxx
deleted file mode 100644
index 62e1ef7..0000000
--- a/xmloff/source/chart/XMLRegressionTypePropertyHdl.cxx
+++ /dev/null
@@ -1,62 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- */
-
-#include "XMLRegressionTypePropertyHdl.hxx"
-#include <xmloff/xmluconv.hxx>
-
-using namespace css;
-using namespace xmloff::token;
-
-XMLRegressionTypePropertyHdl::XMLRegressionTypePropertyHdl()
-{}
-
-XMLRegressionTypePropertyHdl::~XMLRegressionTypePropertyHdl()
-{}
-
-sal_Bool XMLRegressionTypePropertyHdl::importXML( const OUString& rStrImpValue,
-                                                  uno::Any& rValue, const SvXMLUnitConverter& /*rUnitConverter*/ ) const
-{
-    OUString aServiceName;
-
-    if      (IsXMLToken( rStrImpValue, XML_LINEAR ))
-    {
-        aServiceName = "com.sun.star.chart2.LinearRegressionCurve";
-    }
-    else if (IsXMLToken( rStrImpValue, XML_LOGARITHMIC))
-    {
-        aServiceName = "com.sun.star.chart2.LogarithmicRegressionCurve";
-    }
-    else if (IsXMLToken( rStrImpValue, XML_EXPONENTIAL))
-    {
-        aServiceName = "com.sun.star.chart2.ExponentialRegressionCurve";
-    }
-    else if (IsXMLToken( rStrImpValue, XML_POWER))
-    {
-        aServiceName = "com.sun.star.chart2.PotentialRegressionCurve";
-    }
-    else if (IsXMLToken( rStrImpValue, XML_POLYNOMIAL))
-    {
-        aServiceName = "com.sun.star.chart2.PolynomialRegressionCurve";
-    }
-    else if (IsXMLToken( rStrImpValue, XML_MOVING_AVERAGE))
-    {
-        aServiceName = "com.sun.star.chart2.MovingAverageRegressionCurve";
-    }
-    rValue <<= aServiceName;
-
-    return true;
-}
-
-sal_Bool XMLRegressionTypePropertyHdl::exportXML( OUString& /*rStrExpValue*/,
-                                              const uno::Any& /*rValue*/, const SvXMLUnitConverter& /*rUnitConverter*/ ) const
-{
-    return true;
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmloff/source/chart/XMLRegressionTypePropertyHdl.hxx b/xmloff/source/chart/XMLRegressionTypePropertyHdl.hxx
deleted file mode 100644
index c53544f..0000000
--- a/xmloff/source/chart/XMLRegressionTypePropertyHdl.hxx
+++ /dev/null
@@ -1,27 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- */
-
-#ifndef _XMLREGRESSIONTYPEPROPERTYHDL_HXX_
-#define _XMLREGRESSIONTYPEPROPERTYHDL_HXX_
-
-#include <xmloff/xmlprhdl.hxx>
-
-class XMLRegressionTypePropertyHdl : public XMLPropertyHandler
-{
-public:
-    XMLRegressionTypePropertyHdl();
-    virtual ~XMLRegressionTypePropertyHdl();
-
-    virtual sal_Bool importXML( const OUString& rStrImpValue, ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const;
-    virtual sal_Bool exportXML( OUString& rStrExpValue, const ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const;
-};
-
-#endif  // _XMLERRORBARSTYLEPROPERTYHDL_HXX_
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list