From bc584fc5d8b06034f7acf229035483daf78a186e Mon Sep 17 00:00:00 2001 From: Luboš Luňák Date: Tue, 14 May 2013 19:46:43 +0200 Subject: detect whether a bezier shape is open or closed For open shapes e.g. fill does not work. Part of bnc#780044. Change-Id: Id0ce50e94ae86c0398f06b2a67e3fd13d487ae7a --- oox/source/vml/vmlshape.cxx | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'oox') diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx index 0af325d52233..2aa3bac1f83d 100644 --- a/oox/source/vml/vmlshape.cxx +++ b/oox/source/vml/vmlshape.cxx @@ -692,8 +692,8 @@ BezierShape::BezierShape(Drawing& rDrawing) Reference< XShape > BezierShape::implConvertAndInsert( const Reference< XShapes >& rxShapes, const awt::Rectangle& rShapeRect ) const { - Reference< XShape > xShape = SimpleShape::implConvertAndInsert( rxShapes, rShapeRect ); awt::Rectangle aCoordSys = getCoordSystem(); + PolyPolygonBezierCoords aBezierCoords; if( (aCoordSys.Width > 0) && (aCoordSys.Height > 0) ) { @@ -747,7 +747,6 @@ Reference< XShape > BezierShape::implConvertAndInsert( const Reference< XShapes } } - PolyPolygonBezierCoords aBezierCoords; aBezierCoords.Coordinates.realloc( aCoordLists.size() ); for ( unsigned int i = 0; i < aCoordLists.size(); i++ ) aBezierCoords.Coordinates[i] = ContainerHelper::vectorToSequence( aCoordLists[i] ); @@ -756,6 +755,18 @@ Reference< XShape > BezierShape::implConvertAndInsert( const Reference< XShapes for ( unsigned int i = 0; i < aFlagLists.size(); i++ ) aBezierCoords.Flags[i] = ContainerHelper::vectorToSequence( aFlagLists[i] ); + if( aCoordLists.front().front().X == aCoordLists.back().back().X + && aCoordLists.front().front().Y == aCoordLists.back().back().Y ) + { // HACK: If the shape is in fact closed, which can be found out only when the path is known, + // force to closed bezier shape (otherwise e.g. fill won't work). + const_cast< BezierShape* >( this )->setService( "com.sun.star.drawing.ClosedBezierShape" ); + } + } + + Reference< XShape > xShape = SimpleShape::implConvertAndInsert( rxShapes, rShapeRect ); + + if( aBezierCoords.Coordinates.hasElements()) + { PropertySet aPropSet( xShape ); aPropSet.setProperty( PROP_PolyPolygonBezier, aBezierCoords ); } -- cgit v1.2.3