diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2013-04-22 10:22:42 +0200 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2013-04-22 13:57:32 +0200 |
commit | 13861b853fd707c9f288197302fb76db32c8dc66 (patch) | |
tree | dd72f51eede06c98e2bd94d050b09106c3577105 /xmloff | |
parent | 4475e4f3d94f312798dd90f8a8b861f981e0fd22 (diff) |
get the handling of error bar ranges correct in xmloff
We finally produce valid files again for error bars export. Additionally
we don't export unnecessary attributes anymore.
Change-Id: Idc4b4259c47a945e3679dac1a9810cd9f1f05bac
Diffstat (limited to 'xmloff')
-rw-r--r-- | xmloff/inc/XMLChartPropertySetMapper.hxx | 4 | ||||
-rw-r--r-- | xmloff/source/chart/PropertyMap.hxx | 6 | ||||
-rw-r--r-- | xmloff/source/chart/PropertyMaps.cxx | 37 | ||||
-rw-r--r-- | xmloff/source/chart/SchXMLExport.cxx | 22 |
4 files changed, 47 insertions, 22 deletions
diff --git a/xmloff/inc/XMLChartPropertySetMapper.hxx b/xmloff/inc/XMLChartPropertySetMapper.hxx index 1c5db016279b..b5655c0db6fa 100644 --- a/xmloff/inc/XMLChartPropertySetMapper.hxx +++ b/xmloff/inc/XMLChartPropertySetMapper.hxx @@ -61,6 +61,7 @@ private: bool mbAdaptPercentage; SvXMLExport& mrExport; + com::sun::star::uno::Reference< com::sun::star::chart2::XChartDocument > mxChartDoc; protected: virtual void ContextFilter( @@ -89,6 +90,9 @@ public: virtual ~XMLChartExportPropertyMapper(); void setAdaptPercentage( bool bNewValue ); + + void setChartDoc( com::sun::star::uno::Reference< + com::sun::star::chart2::XChartDocument > xChartDoc ); }; // ---------------------------------------- diff --git a/xmloff/source/chart/PropertyMap.hxx b/xmloff/source/chart/PropertyMap.hxx index 3cb3b9dd00c4..526e2b7bf141 100644 --- a/xmloff/source/chart/PropertyMap.hxx +++ b/xmloff/source/chart/PropertyMap.hxx @@ -82,6 +82,8 @@ #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 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 } #define MAP_ENTRY_ODF12( a, ns, nm, t ) { a, sizeof(a)-1, XML_NAMESPACE_##ns, xmloff::token::nm, t|XML_TYPE_PROP_CHART, 0, SvtSaveOptions::ODFVER_012 } @@ -183,8 +185,8 @@ const XMLPropertyMapEntry aXMLChartPropMap[] = 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( "RegressionCurves", CHART, XML_REGRESSION_TYPE, XML_SCH_TYPE_REGRESSION_TYPE ), - MAP_ENTRY_ODF12( "ErrorBarRangePositive", CHART, XML_ERROR_UPPER_RANGE, XML_TYPE_STRING ), // export only - MAP_ENTRY_ODF12( "ErrorBarRangeNegative", CHART, XML_ERROR_LOWER_RANGE, XML_TYPE_STRING ), // export only + 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 // errorbars properties (chart2) MAP_ENTRY_ODF_EXT( "Weigth", CHART, XML_ERROR_STANDARD_WEIGTH, XML_TYPE_DOUBLE), diff --git a/xmloff/source/chart/PropertyMaps.cxx b/xmloff/source/chart/PropertyMaps.cxx index b6590c072c89..9962a09d0f5d 100644 --- a/xmloff/source/chart/PropertyMaps.cxx +++ b/xmloff/source/chart/PropertyMaps.cxx @@ -52,6 +52,8 @@ #include <com/sun/star/drawing/LineJoint.hpp> #include <com/sun/star/chart/ChartDataRowSource.hpp> #include <com/sun/star/chart/ChartAxisPosition.hpp> +#include <com/sun/star/chart2/XChartDocument.hpp> +#include <com/sun/star/chart2/data/XRangeXMLConversion.hpp> // header for any2enum #include <comphelper/extract.hxx> @@ -344,6 +346,22 @@ void XMLChartExportPropertyMapper::handleElementItem( } } +namespace { + +OUString convertRange( const OUString & rRange, const uno::Reference< chart2::XChartDocument > & xDoc ) +{ + OUString aResult = rRange; + if( !xDoc.is() ) + return aResult; + uno::Reference< chart2::data::XRangeXMLConversion > xConversion( + xDoc->getDataProvider(), uno::UNO_QUERY ); + if( xConversion.is()) + aResult = xConversion->convertRangeToXML( rRange ); + return aResult; +} + +} + void XMLChartExportPropertyMapper::handleSpecialItem( SvXMLAttributeList& rAttrList, const XMLPropertyState& rProperty, const SvXMLUnitConverter& rUnitConverter, @@ -440,6 +458,14 @@ void XMLChartExportPropertyMapper::handleSpecialItem( break; } + case XML_SCH_CONTEXT_SPECIAL_ERRORBAR_RANGE: + { + OUString aRangeStr; + rProperty.maValue >>= aRangeStr; + sValueBuffer.append(convertRange(aRangeStr, mxChartDoc)); + } + break; + default: bHandled = sal_False; break; @@ -460,6 +486,11 @@ void XMLChartExportPropertyMapper::handleSpecialItem( } } +void XMLChartExportPropertyMapper::setChartDoc( uno::Reference< chart2::XChartDocument > xChartDoc ) +{ + mxChartDoc = xChartDoc; +} + // ---------------------------------------- XMLChartImportPropertyMapper::XMLChartImportPropertyMapper( const UniReference< XMLPropertySetMapper >& rMapper, @@ -582,6 +613,12 @@ bool XMLChartImportPropertyMapper::handleSpecialItem( } break; + case XML_SCH_CONTEXT_SPECIAL_ERRORBAR_RANGE: + { + rProperty.maValue <<= rValue; + } + break; + // deprecated from 6.0 beta on case XML_SCH_CONTEXT_SPECIAL_SYMBOL_IMAGE_NAME: rProperty.maValue <<= mrImport.ResolveGraphicObjectURL( rValue, sal_False ); diff --git a/xmloff/source/chart/SchXMLExport.cxx b/xmloff/source/chart/SchXMLExport.cxx index 22dc3ac1e575..0b44488bd002 100644 --- a/xmloff/source/chart/SchXMLExport.cxx +++ b/xmloff/source/chart/SchXMLExport.cxx @@ -1145,6 +1145,8 @@ void SchXMLExportHelper_Impl::parseDocument( Reference< chart::XChartDocument >& return; } + mxExpPropMapper->setChartDoc(xNewDoc); + awt::Size aPageSize( getPageSize( xNewDoc )); if( bExportContent ) addSize( aPageSize ); @@ -3069,26 +3071,6 @@ void SchXMLExportHelper_Impl::exportErrorBar( const Reference<beans::XPropertySe for( ::std::vector< Reference< chart2::data::XDataSequence > >::const_iterator aIt( aErrorBarSequences.begin()); aIt != aErrorBarSequences.end(); ++aIt ) { - if ( nCurrentVersion > SvtSaveOptions::ODFVER_012 ) - { - OUString aRole, aRange; - Reference< beans::XPropertySet > xSeqProp( *aIt, uno::UNO_QUERY_THROW ); - xSeqProp->getPropertyValue("Role") >>= aRole; - - aRange = lcl_ConvertRange((*aIt)->getSourceRangeRepresentation(), xNewDoc ); - - if ( aRole.indexOf("positive") != -1 ) - { - if ( bPositive ) - mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_ERROR_UPPER_RANGE, aRange ); - } - else - { - if ( bNegative ) - mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_ERROR_LOWER_RANGE, aRange ); - } - } - m_aDataSequencesToExport.push_back( tLabelValuesDataPair( (uno::Reference< chart2::data::XDataSequence >)0, *aIt )); } |