diff options
author | Attila Szűcs <attila.szucs@collabora.com> | 2024-06-13 21:33:13 +0200 |
---|---|---|
committer | Caolán McNamara <caolan.mcnamara@collabora.com> | 2024-06-18 09:49:07 +0200 |
commit | ada05b8874aa2c5161550dbc87d79b47f40f0df8 (patch) | |
tree | df87258587618575c9740737c7f2da9319db9714 /oox | |
parent | 62c99a31de22561e0e38dd10f3b3fd2b6dd9971d (diff) |
tdf#161607 Chart: import-export LeaderLines data
Implemented Importexport of some leaderLines data
(color and width of the lines) from/to OOXML.
It now supports only the solidFill color.
Used properties: "LineColor" and "LineWidth"
Change-Id: Ib33392d0404e1186328176fd93322e02b4006f3c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168974
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Tested-by: Jenkins
Tested-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Diffstat (limited to 'oox')
-rw-r--r-- | oox/source/drawingml/chart/seriesconverter.cxx | 29 | ||||
-rw-r--r-- | oox/source/export/chartexport.cxx | 34 |
2 files changed, 63 insertions, 0 deletions
diff --git a/oox/source/drawingml/chart/seriesconverter.cxx b/oox/source/drawingml/chart/seriesconverter.cxx index 4efe54f3c2e8..b3c8b51c16b9 100644 --- a/oox/source/drawingml/chart/seriesconverter.cxx +++ b/oox/source/drawingml/chart/seriesconverter.cxx @@ -212,6 +212,28 @@ void importBorderProperties( PropertySet& rPropSet, Shape& rShape, const Graphic rPropSet.setProperty(PROP_LabelBorderColor, uno::Any(nColor)); } +void lcl_ImportLeaderLineProperties(PropertySet& rPropSet, Shape& rShape, + const GraphicHelper& rGraphicHelper) +{ + LineProperties& rLP = rShape.getLineProperties(); + // no fill has the same effect as no line so skip it + if (rLP.maLineFill.moFillType.has_value() && rLP.maLineFill.moFillType.value() == XML_noFill) + return; + + if (rLP.moLineWidth.has_value()) + { + sal_Int32 nWidth = convertEmuToHmm(rLP.moLineWidth.value()); + rPropSet.setProperty(PROP_LineWidth, uno::Any(nWidth)); + } + + if (rLP.maLineFill.moFillType.has_value() && rLP.maLineFill.moFillType.value() == XML_solidFill) + { + const Color& aColor = rLP.maLineFill.maFillColor; + ::Color nColor = aColor.getColor(rGraphicHelper); + rPropSet.setProperty(PROP_LineColor, uno::Any(nColor)); + } +} + void importFillProperties( PropertySet& rPropSet, Shape& rShape, const GraphicHelper& rGraphicHelper, ModelObjectHelper& rModelObjHelper ) { FillProperties& rFP = rShape.getFillProperties(); @@ -467,6 +489,13 @@ void DataLabelsConverter::convertFromModel( const Reference< XDataSeries >& rxDa if( !mrModel.mbShowLeaderLines ) aPropSet.setProperty( PROP_ShowCustomLeaderLines, false ); + if (mrModel.mxLeaderLines) + { + // Import leaderline properties (SolidFill color, and width) + lcl_ImportLeaderLineProperties(aPropSet, *mrModel.mxLeaderLines, + getFilter().getGraphicHelper()); + } + // data point label settings for (auto const& pointLabel : mrModel.maPointLabels) { diff --git a/oox/source/export/chartexport.cxx b/oox/source/export/chartexport.cxx index b1db415aeef2..c63c8497daf1 100644 --- a/oox/source/export/chartexport.cxx +++ b/oox/source/export/chartexport.cxx @@ -4102,6 +4102,40 @@ void ChartExport::exportDataLabels( xPropSet->getPropertyValue(u"ShowCustomLeaderLines"_ustr) >>= bShowLeaderLines; pFS->singleElement(FSNS(XML_c, XML_showLeaderLines), XML_val, ToPsz10(bShowLeaderLines)); + // LeaderLine color, and width + util::Color aLineColor = -1; + xPropSet->getPropertyValue(u"LineColor"_ustr) >>= aLineColor; + // Line width + sal_Int32 nLineWidth = -1; + xPropSet->getPropertyValue(u"LineWidth"_ustr) >>= nLineWidth; + + if (aLineColor > 0 || nLineWidth > 0) + { + pFS->startElement(FSNS(XML_c, XML_leaderLines)); + pFS->startElement(FSNS(XML_c, XML_spPr)); + + if (nLineWidth > 0) + pFS->startElement(FSNS(XML_a, XML_ln), XML_w, + OString::number(convertHmmToEmu(nLineWidth))); + else + pFS->startElement(FSNS(XML_a, XML_ln)); + + if (aLineColor != -1) + { + pFS->startElement(FSNS(XML_a, XML_solidFill)); + + OString aStr = I32SHEX(aLineColor); + pFS->singleElement(FSNS(XML_a, XML_srgbClr), XML_val, aStr); + + pFS->endElement(FSNS(XML_a, XML_solidFill)); + } + + pFS->endElement(FSNS(XML_a, XML_ln)); + pFS->endElement(FSNS(XML_c, XML_spPr)); + pFS->endElement(FSNS(XML_c, XML_leaderLines)); + } + + // Export leader line if( eChartType != chart::TYPEID_PIE ) { |