From bae42fd6dac1d6fa8330eeede66ec22cddb82311 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Tue, 14 May 2013 14:09:29 +0200 Subject: fdo#46808, Convert chart2::RegressionEquation service to new style The service already existed, it just needed an IDL file Change-Id: I56b7079b098a7615dfb24598d15fe7d57691f317 --- xmloff/source/chart/SchXMLPlotAreaContext.cxx | 64 ++++++++++++--------------- 1 file changed, 28 insertions(+), 36 deletions(-) (limited to 'xmloff/source') diff --git a/xmloff/source/chart/SchXMLPlotAreaContext.cxx b/xmloff/source/chart/SchXMLPlotAreaContext.cxx index a8663f5437a4..d8b56b2cb44b 100644 --- a/xmloff/source/chart/SchXMLPlotAreaContext.cxx +++ b/xmloff/source/chart/SchXMLPlotAreaContext.cxx @@ -39,7 +39,6 @@ #include #include - #include #include #include @@ -47,14 +46,13 @@ #include #include #include - +#include +#include +#include +#include #include #include #include -#include -#include -#include - #include #include #include @@ -1316,42 +1314,36 @@ void SchXMLEquationContext::StartElement( const uno::Reference< xml::sax::XAttri if( !sAutoStyleName.isEmpty() || bShowEquation || bShowRSquare ) { - uno::Reference< beans::XPropertySet > xEqProp; - uno::Reference< lang::XMultiServiceFactory > xFact( comphelper::getProcessServiceFactory(), uno::UNO_QUERY ); - if( xFact.is()) - xEqProp.set( xFact->createInstance( - OUString( "com.sun.star.chart2.RegressionEquation" )), uno::UNO_QUERY ); - if( xEqProp.is()) + uno::Reference< beans::XPropertySet > xEqProp = chart2::RegressionEquation::create( comphelper::getProcessComponentContext() ); + + if( !sAutoStyleName.isEmpty() ) { - if( !sAutoStyleName.isEmpty() ) + const SvXMLStylesContext* pStylesCtxt = mrImportHelper.GetAutoStylesContext(); + if( pStylesCtxt ) { - const SvXMLStylesContext* pStylesCtxt = mrImportHelper.GetAutoStylesContext(); - if( pStylesCtxt ) - { - const SvXMLStyleContext* pStyle = pStylesCtxt->FindStyleChildContext( - mrImportHelper.GetChartFamilyID(), sAutoStyleName ); - // note: SvXMLStyleContext::FillPropertySet is not const - XMLPropStyleContext * pPropStyleContext = - const_cast< XMLPropStyleContext * >( dynamic_cast< const XMLPropStyleContext * >( pStyle )); + const SvXMLStyleContext* pStyle = pStylesCtxt->FindStyleChildContext( + mrImportHelper.GetChartFamilyID(), sAutoStyleName ); + // note: SvXMLStyleContext::FillPropertySet is not const + XMLPropStyleContext * pPropStyleContext = + const_cast< XMLPropStyleContext * >( dynamic_cast< const XMLPropStyleContext * >( pStyle )); - if( pPropStyleContext ) - pPropStyleContext->FillPropertySet( xEqProp ); - } + if( pPropStyleContext ) + pPropStyleContext->FillPropertySet( xEqProp ); } - xEqProp->setPropertyValue( OUString( "ShowEquation"), uno::makeAny( bShowEquation )); - xEqProp->setPropertyValue( OUString( "ShowCorrelationCoefficient"), uno::makeAny( bShowRSquare )); + } + xEqProp->setPropertyValue( OUString( "ShowEquation"), uno::makeAny( bShowEquation )); + xEqProp->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 )); - } - SAL_WARN_IF( mrRegressionStyle.meType != DataRowPointStyle::REGRESSION, "xmloff.chart", "mrRegressionStyle.meType != DataRowPointStyle::REGRESSION" ); - mrRegressionStyle.m_xEquationProperties.set( xEqProp ); + 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 )); } + SAL_WARN_IF( mrRegressionStyle.meType != DataRowPointStyle::REGRESSION, "xmloff.chart", "mrRegressionStyle.meType != DataRowPointStyle::REGRESSION" ); + mrRegressionStyle.m_xEquationProperties.set( xEqProp ); } } -- cgit