diff options
author | Michael Stahl <Michael.Stahl@cib.de> | 2020-05-12 14:32:05 +0200 |
---|---|---|
committer | Michael Stahl <michael.stahl@cib.de> | 2020-05-19 10:21:44 +0200 |
commit | 58c013516694b1083abdbc76300ed003f6a456c5 (patch) | |
tree | 072ef5adf37f27823bd371ff5f28b70d90516d66 /xmloff | |
parent | 444c7c736be7545344298a9cbb3a69886edc5ecb (diff) |
xmloff: ODF export: additional ODF 1.3 chart features
* OFFICE-3662 chart:interpolation additional values
* OFFICE-3958 chart regression curve: polynomial
* OFFICE-3959 chart regression curve: moving-average
None of these are exported in ODF 1.2 extended because they require
additional values for standard attributes, which isn't valid.
Change-Id: I920cc44dbde46687b570c1296c7d8926f0a1a9c6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94064
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@cib.de>
Diffstat (limited to 'xmloff')
-rw-r--r-- | xmloff/inc/XMLChartPropertySetMapper.hxx | 6 | ||||
-rw-r--r-- | xmloff/qa/unit/uxmloff.cxx | 2 | ||||
-rw-r--r-- | xmloff/source/chart/PropertyMap.hxx | 49 | ||||
-rw-r--r-- | xmloff/source/chart/PropertyMaps.cxx | 26 | ||||
-rw-r--r-- | xmloff/source/chart/SchXMLExport.cxx | 2 | ||||
-rw-r--r-- | xmloff/source/style/xmlstyle.cxx | 2 |
6 files changed, 61 insertions, 26 deletions
diff --git a/xmloff/inc/XMLChartPropertySetMapper.hxx b/xmloff/inc/XMLChartPropertySetMapper.hxx index 49979d44f6b8..74a71509cce1 100644 --- a/xmloff/inc/XMLChartPropertySetMapper.hxx +++ b/xmloff/inc/XMLChartPropertySetMapper.hxx @@ -31,7 +31,11 @@ class SvXMLExport; class XMLChartPropHdlFactory final : public XMLPropertyHandlerFactory { +private: + SvXMLExport const*const m_pExport; + public: + XMLChartPropHdlFactory(SvXMLExport const*); virtual ~XMLChartPropHdlFactory() override; virtual const XMLPropertyHandler* GetPropertyHandler( sal_Int32 nType ) const override; }; @@ -39,7 +43,7 @@ public: class XMLChartPropertySetMapper final : public XMLPropertySetMapper { public: - explicit XMLChartPropertySetMapper( bool bForExport ); + explicit XMLChartPropertySetMapper(SvXMLExport const* pExport); virtual ~XMLChartPropertySetMapper() override; }; diff --git a/xmloff/qa/unit/uxmloff.cxx b/xmloff/qa/unit/uxmloff.cxx index f2b3788ff17f..273eed259afe 100644 --- a/xmloff/qa/unit/uxmloff.cxx +++ b/xmloff/qa/unit/uxmloff.cxx @@ -71,7 +71,7 @@ void Test::testAutoStylePool() rtl::Reference< SvXMLAutoStylePoolP > xPool( new SvXMLAutoStylePoolP( *pExport ) ); rtl::Reference< XMLPropertySetMapper > xSetMapper( - new XMLChartPropertySetMapper( true) ); + new XMLChartPropertySetMapper(pExport.get()) ); rtl::Reference< XMLChartExportPropertyMapper > xExportPropMapper( new XMLChartExportPropertyMapper( xSetMapper, *pExport ) ); diff --git a/xmloff/source/chart/PropertyMap.hxx b/xmloff/source/chart/PropertyMap.hxx index 6d3c008e9fd4..aec009178b76 100644 --- a/xmloff/source/chart/PropertyMap.hxx +++ b/xmloff/source/chart/PropertyMap.hxx @@ -87,6 +87,7 @@ #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, false } #define MAP_ENTRY( a, ns, nm, t ) { a, sizeof(a)-1, XML_NAMESPACE_##ns, xmloff::token::nm, t|XML_TYPE_PROP_CHART, 0, SvtSaveOptions::ODFSVER_010, false } #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::ODFSVER_012, false } +#define MAP_ENTRY_ODF13( a, ns, nm, t ) { a, sizeof(a)-1, ns, xmloff::token::nm, t|XML_TYPE_PROP_CHART, 0, SvtSaveOptions::ODFSVER_013, false } #define MAP_ENTRY_ODF_EXT( a, ns, nm, t ) { a, sizeof(a)-1, XML_NAMESPACE_##ns, xmloff::token::nm, t|XML_TYPE_PROP_CHART, 0, SvtSaveOptions::ODFSVER_FUTURE_EXTENDED, false } #define MAP_ENTRY_ODF_EXT_IMPORT( a, ns, nm, t ) { a, sizeof(a)-1, XML_NAMESPACE_##ns, xmloff::token::nm, t|XML_TYPE_PROP_CHART, 0, SvtSaveOptions::ODFSVER_FUTURE_EXTENDED, true } #define MAP_CONTEXT( a, ns, nm, t, c ) { a, sizeof(a)-1, XML_NAMESPACE_##ns, xmloff::token::nm, t|XML_TYPE_PROP_CHART, c, SvtSaveOptions::ODFSVER_010, false } @@ -113,6 +114,7 @@ const XMLPropertyMapEntry aXMLChartPropMap[] = MAP_ENTRY( "Lines", CHART, XML_LINES, XML_TYPE_BOOL ), MAP_ENTRY( "Percent", CHART, XML_PERCENTAGE, XML_TYPE_BOOL ), MAP_ENTRY( "SolidType", CHART, XML_SOLID_TYPE, XML_SCH_TYPE_SOLID_TYPE ), + // ODF 1.3 OFFICE-3662 added values MAP_ENTRY( "SplineType", CHART, XML_INTERPOLATION, XML_SCH_TYPE_INTERPOLATION ), MAP_ENTRY( "Stacked", CHART, XML_STACKED, XML_TYPE_BOOL ), // type: "none", "automatic", "named-symbol" or "image" @@ -209,26 +211,29 @@ const XMLPropertyMapEntry aXMLChartPropMap[] = // regression curve properties MAP_SPECIAL( "RegressionType", CHART, XML_REGRESSION_TYPE, XML_TYPE_STRING, XML_SCH_CONTEXT_SPECIAL_REGRESSION_TYPE ), - MAP_ENTRY_ODF_EXT( "CurveName", LO_EXT, XML_REGRESSION_CURVE_NAME, XML_TYPE_STRING ), - MAP_ENTRY_ODF_EXT( "PolynomialDegree", LO_EXT, XML_REGRESSION_MAX_DEGREE, XML_TYPE_NUMBER ), - MAP_ENTRY_ODF_EXT( "MovingAveragePeriod", LO_EXT, XML_REGRESSION_PERIOD, XML_TYPE_NUMBER ), - MAP_ENTRY_ODF_EXT( "MovingAverageType", LO_EXT, XML_REGRESSION_MOVING_TYPE, XML_TYPE_STRING ), + // ODF 1.3 OFFICE-3958 + MAP_ENTRY_ODF13( "CurveName", XML_NAMESPACE_LO_EXT, XML_REGRESSION_CURVE_NAME, XML_TYPE_STRING ), + MAP_ENTRY_ODF13( "CurveName", XML_NAMESPACE_CHART, XML_REGRESSION_CURVE_NAME, XML_TYPE_STRING ), + MAP_ENTRY_ODF13( "PolynomialDegree", XML_NAMESPACE_LO_EXT, XML_REGRESSION_MAX_DEGREE, XML_TYPE_NUMBER ), + MAP_ENTRY_ODF13( "PolynomialDegree", XML_NAMESPACE_CHART, XML_REGRESSION_MAX_DEGREE, XML_TYPE_NUMBER ), + MAP_ENTRY_ODF13( "ForceIntercept", XML_NAMESPACE_LO_EXT, XML_REGRESSION_FORCE_INTERCEPT, XML_TYPE_BOOL ), + MAP_ENTRY_ODF13( "ForceIntercept", XML_NAMESPACE_CHART, XML_REGRESSION_FORCE_INTERCEPT, XML_TYPE_BOOL ), + MAP_ENTRY_ODF13( "InterceptValue", XML_NAMESPACE_LO_EXT, XML_REGRESSION_INTERCEPT_VALUE, XML_TYPE_DOUBLE ), + MAP_ENTRY_ODF13( "InterceptValue", XML_NAMESPACE_CHART, XML_REGRESSION_INTERCEPT_VALUE, XML_TYPE_DOUBLE ), + + // ODF 1.3 OFFICE-3959 + MAP_ENTRY_ODF13( "MovingAveragePeriod", XML_NAMESPACE_LO_EXT, XML_REGRESSION_PERIOD, XML_TYPE_NUMBER ), + MAP_ENTRY_ODF13( "MovingAveragePeriod", XML_NAMESPACE_CHART, XML_REGRESSION_PERIOD, XML_TYPE_NUMBER ), + MAP_ENTRY_ODF13( "MovingAverageType", XML_NAMESPACE_LO_EXT, XML_REGRESSION_MOVING_TYPE, XML_TYPE_STRING ), + MAP_ENTRY_ODF13( "MovingAverageType", XML_NAMESPACE_CHART, XML_REGRESSION_MOVING_TYPE, XML_TYPE_STRING ), + MAP_ENTRY_ODF_EXT( "ExtrapolateForward", LO_EXT, XML_REGRESSION_EXTRAPOLATE_FORWARD, XML_TYPE_DOUBLE ), MAP_ENTRY_ODF_EXT( "ExtrapolateBackward", LO_EXT, XML_REGRESSION_EXTRAPOLATE_BACKWARD, XML_TYPE_DOUBLE ), - MAP_ENTRY_ODF_EXT( "ForceIntercept", LO_EXT, XML_REGRESSION_FORCE_INTERCEPT, XML_TYPE_BOOL ), - MAP_ENTRY_ODF_EXT( "InterceptValue", LO_EXT, XML_REGRESSION_INTERCEPT_VALUE, XML_TYPE_DOUBLE ), - MAP_ENTRY_ODF_EXT( "XName", LO_EXT, XML_REGRESSION_X_NAME, XML_TYPE_STRING ), - MAP_ENTRY_ODF_EXT( "YName", LO_EXT, XML_REGRESSION_Y_NAME, XML_TYPE_STRING ), - - // import mapping for broken files - MAP_ENTRY_ODF_EXT_IMPORT( "CurveName", CHART, XML_REGRESSION_CURVE_NAME, XML_TYPE_STRING ), - MAP_ENTRY_ODF_EXT_IMPORT( "PolynomialDegree", CHART, XML_REGRESSION_MAX_DEGREE, XML_TYPE_NUMBER ), - MAP_ENTRY_ODF_EXT_IMPORT( "MovingAveragePeriod", CHART, XML_REGRESSION_PERIOD, XML_TYPE_NUMBER ), - MAP_ENTRY_ODF_EXT_IMPORT( "MovingAverageType", CHART, XML_REGRESSION_MOVING_TYPE, XML_TYPE_STRING ), MAP_ENTRY_ODF_EXT_IMPORT( "ExtrapolateForward", CHART, XML_REGRESSION_EXTRAPOLATE_FORWARD, XML_TYPE_DOUBLE ), MAP_ENTRY_ODF_EXT_IMPORT( "ExtrapolateBackward", CHART, XML_REGRESSION_EXTRAPOLATE_BACKWARD, XML_TYPE_DOUBLE ), - MAP_ENTRY_ODF_EXT_IMPORT( "ForceIntercept", CHART, XML_REGRESSION_FORCE_INTERCEPT, XML_TYPE_BOOL ), - MAP_ENTRY_ODF_EXT_IMPORT( "InterceptValue", CHART, XML_REGRESSION_INTERCEPT_VALUE, XML_TYPE_DOUBLE ), + + MAP_ENTRY_ODF_EXT( "XName", LO_EXT, XML_REGRESSION_X_NAME, XML_TYPE_STRING ), + MAP_ENTRY_ODF_EXT( "YName", LO_EXT, XML_REGRESSION_Y_NAME, XML_TYPE_STRING ), 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 @@ -316,7 +321,17 @@ const SvXMLEnumMapEntry<css::chart::ChartDataRowSource> aXMLChartDataRowSourceTy { ::xmloff::token::XML_TOKEN_INVALID, css::chart::ChartDataRowSource(0) } }; -const SvXMLEnumMapEntry<sal_Int32> aXMLChartInterpolationTypeEnumMap[] = +const SvXMLEnumMapEntry<sal_Int32> g_XMLChartInterpolationTypeEnumMap_ODF12[] = +{ + // this is neither an enum nor a constants group, but just a + // documented long property + { ::xmloff::token::XML_NONE, 0 }, + { ::xmloff::token::XML_CUBIC_SPLINE, 1 }, + { ::xmloff::token::XML_B_SPLINE, 2 }, + { ::xmloff::token::XML_TOKEN_INVALID, 0 } +}; + +const SvXMLEnumMapEntry<sal_Int32> g_XMLChartInterpolationTypeEnumMap[] = { // this is neither an enum nor a constants group, but just a // documented long property diff --git a/xmloff/source/chart/PropertyMaps.cxx b/xmloff/source/chart/PropertyMaps.cxx index 8e2dccaf8ec5..8701c0c0169e 100644 --- a/xmloff/source/chart/PropertyMaps.cxx +++ b/xmloff/source/chart/PropertyMaps.cxx @@ -88,6 +88,11 @@ SvXMLEnumMapEntry<drawing::FillStyle> const aFillStyleMap[] = // * XMLChartImportPropertyMapper // * SchXMLStyleExport +XMLChartPropHdlFactory::XMLChartPropHdlFactory(SvXMLExport const*const pExport) + : m_pExport(pExport) +{ +} + XMLChartPropHdlFactory::~XMLChartPropHdlFactory() { } @@ -146,7 +151,14 @@ const XMLPropertyHandler* XMLChartPropHdlFactory::GetPropertyHandler( sal_Int32 break; case XML_SCH_TYPE_INTERPOLATION: - pHdl = new XMLEnumPropertyHdl( aXMLChartInterpolationTypeEnumMap ); + if (m_pExport && m_pExport->getSaneDefaultVersion() < SvtSaveOptions::ODFSVER_013) + { + pHdl = new XMLEnumPropertyHdl(g_XMLChartInterpolationTypeEnumMap_ODF12); + } + else // ODF 1.3 OFFICE-3662 + { + pHdl = new XMLEnumPropertyHdl(g_XMLChartInterpolationTypeEnumMap); + } break; case XML_SCH_TYPE_SYMBOL_TYPE: pHdl = new XMLSymbolTypePropertyHdl( false ); @@ -178,8 +190,8 @@ const XMLPropertyHandler* XMLChartPropHdlFactory::GetPropertyHandler( sal_Int32 return pHdl; } -XMLChartPropertySetMapper::XMLChartPropertySetMapper( bool bForExport ) : - XMLPropertySetMapper( aXMLChartPropMap, new XMLChartPropHdlFactory, bForExport ) +XMLChartPropertySetMapper::XMLChartPropertySetMapper(SvXMLExport const*const pExport) + : XMLPropertySetMapper(aXMLChartPropMap, new XMLChartPropHdlFactory(pExport), pExport != nullptr) { } @@ -488,10 +500,14 @@ void XMLChartExportPropertyMapper::handleSpecialItem( sValueBuffer.append( GetXMLToken( XML_EXPONENTIAL )); else if (aServiceName == "com.sun.star.chart2.PotentialRegressionCurve") sValueBuffer.append( GetXMLToken( XML_POWER )); - else if (nCurrentVersion & SvtSaveOptions::ODFSVER_EXTENDED && aServiceName == "com.sun.star.chart2.PolynomialRegressionCurve") + else if (nCurrentVersion >= SvtSaveOptions::ODFSVER_013 && aServiceName == "com.sun.star.chart2.PolynomialRegressionCurve") + { // ODF 1.3 OFFICE-3958 sValueBuffer.append( GetXMLToken( XML_POLYNOMIAL )); - else if (nCurrentVersion & SvtSaveOptions::ODFSVER_EXTENDED && aServiceName == "com.sun.star.chart2.MovingAverageRegressionCurve") + } + else if (nCurrentVersion >= SvtSaveOptions::ODFSVER_013 && aServiceName == "com.sun.star.chart2.MovingAverageRegressionCurve") + { // ODF 1.3 OFFICE-3959 sValueBuffer.append( GetXMLToken( XML_MOVING_AVERAGE )); + } } break; diff --git a/xmloff/source/chart/SchXMLExport.cxx b/xmloff/source/chart/SchXMLExport.cxx index 2b4549889f2a..6ddc083b5db5 100644 --- a/xmloff/source/chart/SchXMLExport.cxx +++ b/xmloff/source/chart/SchXMLExport.cxx @@ -1036,7 +1036,7 @@ SchXMLExportHelper_Impl::SchXMLExportHelper_Impl( SvXMLAutoStylePoolP& rASPool ) : mrExport( rExport ), mrAutoStylePool( rASPool ), - mxPropertySetMapper( new XMLChartPropertySetMapper( true ) ), + mxPropertySetMapper( new XMLChartPropertySetMapper(&rExport) ), mxExpPropMapper( new XMLChartExportPropertyMapper( mxPropertySetMapper, rExport ) ), mbHasCategoryLabels( false ), mbRowSourceColumns( true ), diff --git a/xmloff/source/style/xmlstyle.cxx b/xmloff/source/style/xmlstyle.cxx index 8b8745d6325f..2c4fe5f01912 100644 --- a/xmloff/source/style/xmlstyle.cxx +++ b/xmloff/source/style/xmlstyle.cxx @@ -642,7 +642,7 @@ rtl::Reference < SvXMLImportPropertyMapper > SvXMLStylesContext::GetImportProper case XmlStyleFamily::SCH_CHART_ID: if( ! mxChartImpPropMapper.is() ) { - XMLPropertySetMapper *pPropMapper = new XMLChartPropertySetMapper( false ); + XMLPropertySetMapper *const pPropMapper = new XMLChartPropertySetMapper(nullptr); mxChartImpPropMapper = new XMLChartImportPropertyMapper( pPropMapper, GetImport() ); } xMapper = mxChartImpPropMapper; |