diff options
author | Kurt Nordback <kurt.nordback@protonmail.com> | 2024-07-17 17:07:05 -0600 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2024-11-26 01:34:07 +0100 |
commit | b10d331c1c9801adbf6d014d9348bb0a4dad3d2c (patch) | |
tree | 7fa23c258510338aedc321294e6962555f2f9265 /xmloff/source | |
parent | 7c7e7da1538c1ed0c65821e18233ec9dcdc6cd2b (diff) |
tdf#161800 - I/O of '# of values in second plot' parameter not supported
Add support for input and output of 'split position' parameter (number of entries
in second plot) for of-pie charts. In OOXML this uses the supported split-pos
tag. For ODF I added an extension in loext namespace for this parameter.
This commit also includes simple tests for the I/O functionality in OOXML and
ODF.
Change-Id: I00ff59db721867fa836eb99b6677350040d005dd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170666
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'xmloff/source')
-rw-r--r-- | xmloff/source/chart/SchXMLChartContext.cxx | 9 | ||||
-rw-r--r-- | xmloff/source/chart/SchXMLChartContext.hxx | 1 | ||||
-rw-r--r-- | xmloff/source/chart/SchXMLExport.cxx | 37 |
3 files changed, 44 insertions, 3 deletions
diff --git a/xmloff/source/chart/SchXMLChartContext.cxx b/xmloff/source/chart/SchXMLChartContext.cxx index c79071dac166..a6cd20a3d54f 100644 --- a/xmloff/source/chart/SchXMLChartContext.cxx +++ b/xmloff/source/chart/SchXMLChartContext.cxx @@ -232,7 +232,8 @@ SchXMLChartContext::SchXMLChartContext( SchXMLImportHelper& rImpHelper, mbRowHasLabels( false ), meDataRowSource( chart::ChartDataRowSource_COLUMNS ), mbIsStockChart( false ), - mPieSubType(css::chart2::PieChartSubType_NONE) + mPieSubType(css::chart2::PieChartSubType_NONE), + mfPieSplitPos(2.0) { } @@ -400,6 +401,9 @@ void SchXMLChartContext::startFastElement( sal_Int32 /*nElement*/, mPieSubType = css::chart2::PieChartSubType_PIE; } break; + case XML_ELEMENT(LO_EXT, XML_SPLIT_POSITION): + mfPieSplitPos = aIter.toDouble(); + break; default: XMLOFF_WARN_UNKNOWN("xmloff", aIter); } @@ -748,12 +752,13 @@ void SchXMLChartContext::endFastElement(sal_Int32 ) // cleanup: remove empty chart type groups lcl_removeEmptyChartTypeGroups( xNewDoc ); - // Handle sub-pie type. Is this the right place to do this? + // Handle of-pie paramters. Is this the right place to do this? if (maChartTypeServiceName == "com.sun.star.chart2.PieChartType") { Reference< chart2::XDiagram> xDia(xNewDoc->getFirstDiagram()); uno::Reference< beans::XPropertySet > xDiaProp( xDia, uno::UNO_QUERY ); if( xDiaProp.is()) { xDiaProp->setPropertyValue(u"SubPieType"_ustr, uno::Any(mPieSubType)); + xDiaProp->setPropertyValue(u"SplitPos"_ustr, uno::Any(mfPieSplitPos)); } } diff --git a/xmloff/source/chart/SchXMLChartContext.hxx b/xmloff/source/chart/SchXMLChartContext.hxx index b7f94fa6c986..563ae2ebe8e1 100644 --- a/xmloff/source/chart/SchXMLChartContext.hxx +++ b/xmloff/source/chart/SchXMLChartContext.hxx @@ -101,6 +101,7 @@ private: css::chart::ChartDataRowSource meDataRowSource; bool mbIsStockChart; css::chart2::PieChartSubType mPieSubType; + double mfPieSplitPos; OUString msCategoriesAddress; OUString msChartAddress; diff --git a/xmloff/source/chart/SchXMLExport.cxx b/xmloff/source/chart/SchXMLExport.cxx index 4e3fa02b7651..f58904997ce6 100644 --- a/xmloff/source/chart/SchXMLExport.cxx +++ b/xmloff/source/chart/SchXMLExport.cxx @@ -114,7 +114,6 @@ using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::Any; using ::std::vector; - namespace { /** @@ -1287,11 +1286,47 @@ void SchXMLExportHelper_Impl::parseDocument( Reference< chart::XChartDocument > XML_NAMESPACE_CHART, GetXMLToken(eXMLChartType )) ); } + bool bIsOfPie = false; // Handle subtype for of-pie charts if (sChartType == u"com.sun.star.chart.BarOfPieDiagram") { mrExport.AddAttribute(XML_NAMESPACE_LO_EXT, XML_SUB_BAR, OUString::boolean(true)); + bIsOfPie = true; } else if (sChartType == u"com.sun.star.chart.PieOfPieDiagram") { mrExport.AddAttribute(XML_NAMESPACE_LO_EXT, XML_SUB_PIE, OUString::boolean(true)); + bIsOfPie = true; + } + + if (bIsOfPie) { + + // Find the split position. We have to dig deep into the + // structure tree to get it, which is awkward. Part of the + // problem is that the split position is sort of a series-level + // parameter, but is generally handled at the chart level since + // of-pie charts have only a single series. + double fSplitPos = 2.0; + + Reference< chart2::XCoordinateSystemContainer > xBCooSysCnt( xNewDiagram, uno::UNO_QUERY ); + if (xBCooSysCnt.is()) { + const Sequence< Reference< chart2::XCoordinateSystem > > + aCooSysSeq( xBCooSysCnt->getCoordinateSystems()); + for (const auto& rCooSys : aCooSysSeq ) { + Reference< chart2::XChartTypeContainer > xCTCnt( rCooSys, uno::UNO_QUERY ); + if( ! xCTCnt.is()) + continue; + const Sequence< Reference< chart2::XChartType > > aCTSeq( xCTCnt->getChartTypes()); + for (const auto& rChartType : aCTSeq ) { + Reference< beans::XPropertySet > xCTProp( rChartType, uno::UNO_QUERY ); + + if (xCTProp.is()) { + xCTProp->getPropertyValue(u"SplitPos"_ustr) >>= fSplitPos; + } + } + } + } + + // Insert split position for of-pie chart + mrExport.AddAttribute(XML_NAMESPACE_LO_EXT, XML_SPLIT_POSITION, + OUString::number(fSplitPos)); } //column-mapping or row-mapping |