diff options
author | Chr. Rossmanith <ChrRossmanith@gmx.de> | 2015-11-10 21:17:54 +0100 |
---|---|---|
committer | Thorsten Behrens <Thorsten.Behrens@CIB.de> | 2015-11-11 00:51:40 +0000 |
commit | 591903a1b1b64e68322f7454d3e61b2503028b9a (patch) | |
tree | a96b93536e29cb17c85dc56be5f6ec5dddd497a8 | |
parent | f019f5d6fe05b15a83a7fea40d9448de2fabb00d (diff) |
tdf#51165: handle mixture of open and closed polygons in a path
Change-Id: I66c7fb2b627d3380c09b6e5e495905bed67c2824
Reviewed-on: https://gerrit.libreoffice.org/19860
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
-rw-r--r-- | filter/source/svg/svgreader.cxx | 54 |
1 files changed, 49 insertions, 5 deletions
diff --git a/filter/source/svg/svgreader.cxx b/filter/source/svg/svgreader.cxx index e30acf39b39d..04d8e01606e5 100644 --- a/filter/source/svg/svgreader.cxx +++ b/filter/source/svg/svgreader.cxx @@ -128,6 +128,35 @@ double colorDiffSquared(const ARGBColor& rCol1, const ARGBColor& rCol2) + square(rCol1.b-rCol2.b); } +/** + check whether a polypolygon contains both open and closed + polygons +**/ +bool PolyPolygonIsMixedOpenAndClosed( const basegfx::B2DPolyPolygon& rPoly ) +{ + bool bRetval(false); + bool bOpen(false); + bool bClosed(false); + + // PolyPolygon is mixed open and closed if there is more than one + // polygon and there are both closed and open polygons. + for( sal_uInt32 a(0L); !bRetval && a < rPoly.count(); a++ ) + { + if ( (rPoly.getB2DPolygon(a)).isClosed() ) + { + bClosed = true; + } + else + { + bOpen = true; + } + + bRetval = (bClosed && bOpen); + } + + return bRetval; +} + typedef std::map<OUString,sal_Size> ElementRefMapType; struct AnnotatingVisitor @@ -1366,11 +1395,26 @@ struct ShapeWritingVisitor aPoly.setClosed(true); } - writePathShape(xAttrs, - xUnoAttrs, - xElem, - sStyleId, - aPoly); + // tdf#51165: rendering of paths with open and closed polygons is not implemented + // split mixed polypolygons into single polygons and add them one by one + if( PolyPolygonIsMixedOpenAndClosed(aPoly) ) + { + for( sal_uInt32 i(0L); i<aPoly.count(); ++i ) { + writePathShape(xAttrs, + xUnoAttrs, + xElem, + sStyleId, + basegfx::B2DPolyPolygon(aPoly.getB2DPolygon(i))); + } + } + else + { + writePathShape(xAttrs, + xUnoAttrs, + xElem, + sStyleId, + aPoly); + } break; } case XML_CIRCLE: |