summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorRegényi Balázs <regenyi.balazs@nisz.hu>2020-10-12 09:58:35 +0200
committerLászló Németh <nemeth@numbertext.org>2020-10-13 15:19:57 +0200
commit9310e47e2ce71348a16e5412131946348833f4b2 (patch)
tree773c629522862d5382789325f78a46a12a042046 /oox
parentc35db66435cfecaa957b469d96ca70a31187a224 (diff)
tdf#101122 DOCX custom shape export: remove bad fill
of (simplified export) of not filled custom shapes by adding missing fill="none" to a:path. Note: in OpenDocument, unfilled shape path is defined by draw:enhanced-path command "F", see section 19.145 in ODF v1.2. Co-authored-by: Szabolcs Tóth Change-Id: I0be2aada3deb06828216e0441c91c389a673f87c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104205 Tested-by: László Németh <nemeth@numbertext.org> Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'oox')
-rw-r--r--oox/source/export/drawingml.cxx47
-rw-r--r--oox/source/export/shapes.cxx4
2 files changed, 48 insertions, 3 deletions
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index c19b030ad642..8b7c4add1f78 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -3582,7 +3582,8 @@ sal_Int32 DrawingML::GetCustomGeometryPointValue(
return nValue;
}
-void DrawingML::WritePolyPolygon( const tools::PolyPolygon& rPolyPolygon, const bool bClosed )
+void DrawingML::WritePolyPolygon(const css::uno::Reference<css::drawing::XShape>& rXShape,
+ const tools::PolyPolygon& rPolyPolygon, const bool bClosed)
{
// In case of Writer, the parent element is <wps:spPr>, and there the
// <a:custGeom> element is not optional.
@@ -3599,9 +3600,15 @@ void DrawingML::WritePolyPolygon( const tools::PolyPolygon& rPolyPolygon, const
const tools::Rectangle aRect( rPolyPolygon.GetBoundRect() );
+ // tdf#101122
+ std::optional<OString> sFill;
+ if (HasEnhancedCustomShapeSegmentCommand(rXShape, css::drawing::EnhancedCustomShapeSegmentCommand::NOFILL))
+ sFill = "none"; // for possible values see ST_PathFillMode in OOXML standard
+
// Put all polygons of rPolyPolygon in the same path element
// to subtract the overlapped areas.
mpFS->startElementNS( XML_a, XML_path,
+ XML_fill, sFill,
XML_w, OString::number(aRect.GetWidth()),
XML_h, OString::number(aRect.GetHeight()) );
@@ -4191,6 +4198,44 @@ void DrawingML::WriteSoftEdgeEffect(const css::uno::Reference<css::beans::XPrope
WriteShapeEffect("softEdge", aProps);
}
+bool DrawingML::HasEnhancedCustomShapeSegmentCommand(
+ const css::uno::Reference<css::drawing::XShape>& rXShape, const sal_Int16 nCommand)
+{
+ try
+ {
+ uno::Reference<beans::XPropertySet> xPropSet(rXShape, uno::UNO_QUERY_THROW);
+ if (!GetProperty(xPropSet, "CustomShapeGeometry"))
+ return false;
+ Sequence<PropertyValue> aCustomShapeGeometryProps;
+ mAny >>= aCustomShapeGeometryProps;
+ for (const beans::PropertyValue& rGeomProp : std::as_const(aCustomShapeGeometryProps))
+ {
+ if (rGeomProp.Name == "Path")
+ {
+ uno::Sequence<beans::PropertyValue> aPathProps;
+ rGeomProp.Value >>= aPathProps;
+ for (const beans::PropertyValue& rPathProp : std::as_const(aPathProps))
+ {
+ if (rPathProp.Name == "Segments")
+ {
+ uno::Sequence<drawing::EnhancedCustomShapeSegment> aSegments;
+ rPathProp.Value >>= aSegments;
+ for (const auto& rSegment : std::as_const(aSegments))
+ {
+ if (rSegment.Command == nCommand)
+ return true;
+ }
+ }
+ }
+ }
+ }
+ }
+ catch (const ::uno::Exception&)
+ {
+ }
+ return false;
+}
+
void DrawingML::WriteShape3DEffects( const Reference< XPropertySet >& xPropSet )
{
// check existence of the grab bag
diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index 00a44d3fccfa..2b1251660cee 100644
--- a/oox/source/export/shapes.cxx
+++ b/oox/source/export/shapes.cxx
@@ -427,7 +427,7 @@ ShapeExport& ShapeExport::WritePolyPolygonShape( const Reference< XShape >& xSha
// visual shape properties
pFS->startElementNS(mnXmlNamespace, XML_spPr);
WriteTransformation( aRect, XML_a );
- WritePolyPolygon( aPolyPolygon, bClosed );
+ WritePolyPolygon(xShape, aPolyPolygon, bClosed);
Reference< XPropertySet > xProps( xShape, UNO_QUERY );
if( xProps.is() ) {
if( bClosed )
@@ -845,7 +845,7 @@ ShapeExport& ShapeExport::WriteCustomShape( const Reference< XShape >& xShape )
bool bInvertRotation = bFlipH != bFlipV;
if (nRotation != 0)
aPolyPolygon.Rotate(Point(0,0), static_cast<sal_uInt16>(bInvertRotation ? nRotation/10 : 3600-nRotation/10));
- WritePolyPolygon( aPolyPolygon, false );
+ WritePolyPolygon(xShape, aPolyPolygon, false);
}
else if (bCustGeom)
{