diff options
author | Armin Le Grand (allotropia) <armin.le.grand.extern@allotropia.de> | 2022-10-27 15:08:50 +0200 |
---|---|---|
committer | Armin Le Grand <Armin.Le.Grand@me.com> | 2022-10-28 10:47:36 +0200 |
commit | 470201f392a019ef6f2b9e70377e66e47e839494 (patch) | |
tree | af0f59abf70e5b0e7423b60304cacea807b80a22 | |
parent | fb53e83372f139bceb5ebfaaae633875efeec240 (diff) |
tdf#145240 add flexibility to receiving PolyPolygons over UNO API
Make XMLShapeExport aware and use that PolyPolygons can be not
only in Bezier format, but also a sequence of Points
Change-Id: Ie00e87d35d4f8aa9d481b2800585c5a770bbbc0a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141935
Tested-by: Jenkins
Reviewed-by: Armin Le Grand <Armin.Le.Grand@me.com>
-rw-r--r-- | xmloff/source/draw/shapeexport.cxx | 42 |
1 files changed, 20 insertions, 22 deletions
diff --git a/xmloff/source/draw/shapeexport.cxx b/xmloff/source/draw/shapeexport.cxx index f975e4d1d1b2..f12958a9f650 100644 --- a/xmloff/source/draw/shapeexport.cxx +++ b/xmloff/source/draw/shapeexport.cxx @@ -2321,37 +2321,35 @@ void XMLShapeExport::ImpExportPolygonShape( // prepare name (with most used) enum ::xmloff::token::XMLTokenEnum eName(XML_PATH); - if(bBezier) + uno::Any aAny( xPropSet->getPropertyValue("Geometry") ); + basegfx::B2DPolyPolygon aPolyPolygon; + + // tdf#145240 the Any can contain PolyPolygonBezierCoords or PointSequenceSequence + // (see OWN_ATTR_BASE_GEOMETRY in SvxShapePolyPolygon::getPropertyValueImpl), + // so be more flexible in interpreting it. Try to access bezier first: { - // get PolygonBezier - uno::Any aAny( xPropSet->getPropertyValue("Geometry") ); auto pSourcePolyPolygon = o3tl::tryAccess<drawing::PolyPolygonBezierCoords>(aAny); + if(pSourcePolyPolygon && pSourcePolyPolygon->Coordinates.getLength()) { - const basegfx::B2DPolyPolygon aPolyPolygon( - basegfx::utils::UnoPolyPolygonBezierCoordsToB2DPolyPolygon( - *pSourcePolyPolygon)); + aPolyPolygon = basegfx::utils::UnoPolyPolygonBezierCoordsToB2DPolyPolygon(*pSourcePolyPolygon); + } + } - // complex polygon shape, write as svg:d - const OUString aPolygonString( - basegfx::utils::exportToSvgD( - aPolyPolygon, - true, // bUseRelativeCoordinates - false, // bDetectQuadraticBeziers: not used in old, but maybe activated now - true)); // bHandleRelativeNextPointCompatible + // if received no data, try to access point sequence second: + if(0 == aPolyPolygon.count()) + { + auto pSourcePolyPolygon = o3tl::tryAccess<drawing::PointSequenceSequence>(aAny); - // write point array - mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_D, aPolygonString); + if(pSourcePolyPolygon) + { + aPolyPolygon = basegfx::utils::UnoPointSequenceSequenceToB2DPolyPolygon(*pSourcePolyPolygon); } } - else - { - // get non-bezier polygon - uno::Any aAny( xPropSet->getPropertyValue("Geometry") ); - const basegfx::B2DPolyPolygon aPolyPolygon( - basegfx::utils::UnoPointSequenceSequenceToB2DPolyPolygon(*o3tl::doAccess<drawing::PointSequenceSequence>(aAny))); - if(!aPolyPolygon.areControlPointsUsed() && 1 == aPolyPolygon.count()) + if(aPolyPolygon.count()) + { + if(!bBezier && !aPolyPolygon.areControlPointsUsed() && 1 == aPolyPolygon.count()) { // simple polygon shape, can be written as svg:points sequence const basegfx::B2DPolygon& aPolygon(aPolyPolygon.getB2DPolygon(0)); |