From b63d1e56621d7a2369717d21d46cfee19be8e4bf Mon Sep 17 00:00:00 2001 From: Markus Mohrhard Date: Tue, 26 Feb 2013 07:38:06 +0100 Subject: get at least the y-error-bar import working again, fdo#60083 This still does not help with the x-error-bars but it is a first step in the right direction. There are still some nasty problems around the different possibilities how the error bar information can be stored in the file. Change-Id: I8022fbfc8d372c9863d236253a2a63364198bfc8 --- xmloff/source/chart/SchXMLPlotAreaContext.cxx | 140 ++++++++++++++++---------- 1 file changed, 87 insertions(+), 53 deletions(-) diff --git a/xmloff/source/chart/SchXMLPlotAreaContext.cxx b/xmloff/source/chart/SchXMLPlotAreaContext.cxx index 2028d5e63e7e..4778e29120d0 100644 --- a/xmloff/source/chart/SchXMLPlotAreaContext.cxx +++ b/xmloff/source/chart/SchXMLPlotAreaContext.cxx @@ -1037,6 +1037,90 @@ SchXMLStatisticsObjectContext::~SchXMLStatisticsObjectContext() { } +namespace { + +void SetErrorBarPropertiesFromStyleName( const OUString& aStyleName, uno::Reference< beans::XPropertySet> xBarProp, + SchXMLImportHelper& rImportHelper) +{ + const SvXMLStylesContext* pStylesCtxt = rImportHelper.GetAutoStylesContext(); + const SvXMLStyleContext* pStyle = pStylesCtxt->FindStyleChildContext(rImportHelper.GetChartFamilyID(), + aStyleName); + + XMLPropStyleContext * pSeriesStyleContext = + const_cast< XMLPropStyleContext * >( dynamic_cast< const XMLPropStyleContext * >( pStyle )); + + uno::Any aAny = SchXMLTools::getPropertyFromContext("ErrorBarStyle", + pSeriesStyleContext,pStylesCtxt); + + if ( aAny.hasValue() ) + { + sal_Int32 aBarStyle = com::sun::star::chart::ErrorBarStyle::NONE; + aAny >>= aBarStyle; + + aAny = SchXMLTools::getPropertyFromContext("ShowPositiveError", + pSeriesStyleContext,pStylesCtxt); + + if(aAny.hasValue()) + xBarProp->setPropertyValue("ShowPositiveError",aAny); + + aAny = SchXMLTools::getPropertyFromContext("ShowNegativeError", + pSeriesStyleContext,pStylesCtxt); + + if(aAny.hasValue()) + xBarProp->setPropertyValue("ShowNegativeError",aAny); + + aAny = SchXMLTools::getPropertyFromContext("PositiveError", + pSeriesStyleContext, pStylesCtxt); + + if(aAny.hasValue()) + xBarProp->setPropertyValue("PositiveError", aAny); + else + { + aAny = SchXMLTools::getPropertyFromContext("ConstantErrorHigh", + pSeriesStyleContext, pStylesCtxt); + + if(aAny.hasValue()) + xBarProp->setPropertyValue("PositiveError", aAny); + } + + aAny = SchXMLTools::getPropertyFromContext("NegativeError", + pSeriesStyleContext, pStylesCtxt); + + if(aAny.hasValue()) + xBarProp->setPropertyValue("NegativeError", aAny); + else + { + aAny = SchXMLTools::getPropertyFromContext("ConstantErrorLow", + pSeriesStyleContext, pStylesCtxt); + + if(aAny.hasValue()) + xBarProp->setPropertyValue("NegativeError", aAny); + } + + switch(aBarStyle) + { + case com::sun::star::chart::ErrorBarStyle::ERROR_MARGIN: + { + aAny = SchXMLTools::getPropertyFromContext("NegativeError", + pSeriesStyleContext,pStylesCtxt); + + xBarProp->setPropertyValue("NegativeError",aAny); + + aAny = SchXMLTools::getPropertyFromContext("PositiveError", + pSeriesStyleContext,pStylesCtxt); + + xBarProp->setPropertyValue("PositiveError",aAny); + } + break; + default: + break; + } + } +} + +} + + void SchXMLStatisticsObjectContext::StartElement( const uno::Reference< xml::sax::XAttributeList >& xAttrList ) { sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0; @@ -1096,15 +1180,10 @@ void SchXMLStatisticsObjectContext::StartElement( const uno::Reference< xml::sax xBarProp->setPropertyValue("ShowPositiveError",uno::makeAny(sal_True)); xBarProp->setPropertyValue("ShowNegativeError",uno::makeAny(sal_True)); - const SvXMLStylesContext* pStylesCtxt = mrImportHelper.GetAutoStylesContext(); - const SvXMLStyleContext* pStyle = pStylesCtxt->FindStyleChildContext( - mrImportHelper.GetChartFamilyID(), sAutoStyleName ); - // note: SvXMLStyleContext::FillPropertySet is not const - XMLPropStyleContext * pErrorStyleContext = - const_cast< XMLPropStyleContext * >( dynamic_cast< const XMLPropStyleContext * >( pStyle )); - - pErrorStyleContext->FillPropertySet( xBarProp ); + // first import defaults from parent style + SetErrorBarPropertiesFromStyleName( maSeriesStyleName, xBarProp, mrImportHelper ); + SetErrorBarPropertiesFromStyleName( sAutoStyleName, xBarProp, mrImportHelper ); uno::Reference< chart2::XChartDocument > xDoc(GetImport().GetModel(),uno::UNO_QUERY); @@ -1120,51 +1199,6 @@ void SchXMLStatisticsObjectContext::StartElement( const uno::Reference< xml::sax } else { - /// Keep 0DF12 and below support - pStyle = pStylesCtxt->FindStyleChildContext(mrImportHelper.GetChartFamilyID(), - maSeriesStyleName); - - XMLPropStyleContext * pSeriesStyleContext = - const_cast< XMLPropStyleContext * >( dynamic_cast< const XMLPropStyleContext * >( pStyle )); - - uno::Any aAny = SchXMLTools::getPropertyFromContext("ErrorBarStyle", - pSeriesStyleContext,pStylesCtxt); - - if ( aAny.hasValue() ) - { - sal_Int32 aBarStyle = com::sun::star::chart::ErrorBarStyle::NONE; - aAny >>= aBarStyle; - - aAny = SchXMLTools::getPropertyFromContext("ShowPositiveError", - pSeriesStyleContext,pStylesCtxt); - - xBarProp->setPropertyValue("ShowPositiveError",aAny); - - aAny = SchXMLTools::getPropertyFromContext("ShowNegativeError", - pSeriesStyleContext,pStylesCtxt); - - xBarProp->setPropertyValue("ShowNegativeError",aAny); - - switch(aBarStyle) - { - case com::sun::star::chart::ErrorBarStyle::ERROR_MARGIN: - { - aAny = SchXMLTools::getPropertyFromContext("NegativeError", - pSeriesStyleContext,pStylesCtxt); - - xBarProp->setPropertyValue("NegativeError",aAny); - - aAny = SchXMLTools::getPropertyFromContext("PositiveError", - pSeriesStyleContext,pStylesCtxt); - - xBarProp->setPropertyValue("PositiveError",aAny); - } - break; - default: - break; - } - } - aStyle.m_xErrorYProperties.set( xBarProp ); } } -- cgit v1.2.3