diff options
author | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-01-14 18:40:10 -0500 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-01-17 11:33:12 -0500 |
commit | 3136b39e0d76b0ea9a8dcf5a6fa054783b45a85d (patch) | |
tree | 22df324f9305d235bf11c207e561e5556279004a | |
parent | 2c702a31f07d7e83796602f2c412952692f66178 (diff) |
Use hairlines judiciously to draw very thin patterned strokes correctly.
This prevents some dashed or dotted lines from being skipped when printing
or in print preview.
Change-Id: I9d0a8ae743241d17d65935f4bf0d122e4313bff8
-rw-r--r-- | drawinglayer/source/primitive2d/borderlineprimitive2d.cxx | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/drawinglayer/source/primitive2d/borderlineprimitive2d.cxx b/drawinglayer/source/primitive2d/borderlineprimitive2d.cxx index c281d8e5f745..a8d774a5707d 100644 --- a/drawinglayer/source/primitive2d/borderlineprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/borderlineprimitive2d.cxx @@ -251,7 +251,6 @@ namespace drawinglayer const double fExt = getWidth(rViewInformation); // Extend a lot: it'll be clipped after const basegfx::B2DPoint aTmpStart(getStart() - (fExt * aVector)); const basegfx::B2DPoint aTmpEnd(getEnd() + (fExt * aVector)); - xRetval.realloc(1); // Get which is the line to show bool bIsSolidline = isSolidLine(); @@ -273,6 +272,7 @@ namespace drawinglayer aPolygon.append( getStart() ); aPolygon.append( getEnd() ); + xRetval.realloc(1); xRetval[0] = Primitive2DReference(new PolygonHairlinePrimitive2D( aPolygon, aColor)); @@ -308,8 +308,28 @@ namespace drawinglayer aDashed.setB2DPolygon( i, aClipped.getB2DPolygon( 0 ) ); } - xRetval[0] = Primitive2DReference(new PolyPolygonColorPrimitive2D( - basegfx::B2DPolyPolygon( aDashed ), aColor)); + sal_uInt32 n = aDashed.count(); + xRetval.realloc(n); + for (sal_uInt32 i = 0; i < n; ++i) + { + basegfx::B2DPolygon aDash = aDashed.getB2DPolygon(i); + if (bIsHairline) + { + // Convert a rectanglar polygon into a line. + basegfx::B2DPolygon aDash2; + basegfx::B2DRange aRange = aDash.getB2DRange(); + basegfx::B2DPoint aPt(aRange.getMinX(), aRange.getMinY()); + aDash2.append(basegfx::B2DPoint(aRange.getMinX(), aRange.getMinY())); + aDash2.append(basegfx::B2DPoint(aRange.getMaxX(), aRange.getMinY())); + xRetval[i] = Primitive2DReference( + new PolygonHairlinePrimitive2D(aDash2, aColor)); + } + else + { + xRetval[i] = Primitive2DReference( + new PolyPolygonColorPrimitive2D(basegfx::B2DPolyPolygon(aDash), aColor)); + } + } } } } |