From ae9f37ba753519ae4a2ae6384d052d417359602f Mon Sep 17 00:00:00 2001 From: Mark Hung Date: Sun, 21 Oct 2018 00:04:33 +0800 Subject: tdf#100236 Implement linestyles with dash and dots. Allow append dashes to have dash and dot line styles. Segment length parameters were taken from cppcanvas, also restructure the code to use the same appendDashes function. Change-Id: I17c0796dbe722c4c6d5e91d0e318570a52a2514c Reviewed-on: https://gerrit.libreoffice.org/62084 Tested-by: Jenkins Reviewed-by: Mark Hung --- cppcanvas/source/mtfrenderer/mtftools.cxx | 197 ++++++++++++++---------------- 1 file changed, 93 insertions(+), 104 deletions(-) (limited to 'cppcanvas') diff --git a/cppcanvas/source/mtfrenderer/mtftools.cxx b/cppcanvas/source/mtfrenderer/mtftools.cxx index 75c7d6069146..0680e05f3ca8 100644 --- a/cppcanvas/source/mtfrenderer/mtftools.cxx +++ b/cppcanvas/source/mtfrenderer/mtftools.cxx @@ -319,28 +319,92 @@ namespace cppcanvas ::basegfx::B2DRectangle( nX1, nY1, nX2, nY2 ) ) ); } - void appendDashes( ::basegfx::B2DPolyPolygon& o_rPoly, + bool appendDashes( ::basegfx::B2DPolyPolygon& o_rPoly, const double nX, - const double nY, + double nY, const double nLineWidth, - const double nLineHeight, - const double nDashWidth, - const double nDashSkip ) + double nLineHeight, + sal_Int8 nLineStyle, + bool bIsOverline) { - const sal_Int32 nNumLoops( - static_cast< sal_Int32 >( - std::max( 1.0, - nLineWidth / nDashSkip ) + .5) ); + static const int aDottedArray[] = { 1, 1, 0}; // DOTTED LINE + static const int aDotDashArray[] = { 1, 1, 4, 1, 0}; // DASHDOT + static const int aDashDotDotArray[] = { 1, 1, 1, 1, 4, 1, 0}; // DASHDOTDOT + static const int aDashedArray[] = { 5, 2, 0}; // DASHED LINE + static const int aLongDashArray[] = { 7, 2, 0}; // LONGDASH + const int *pArray = nullptr; + bool bIsBold = false; + + switch(nLineStyle) + { + case LINESTYLE_BOLDDOTTED: + bIsBold = true; + BOOST_FALLTHROUGH; + case LINESTYLE_DOTTED: + pArray = aDottedArray; + break; + + case LINESTYLE_BOLDDASH: + bIsBold = true; + BOOST_FALLTHROUGH; + case LINESTYLE_DASH: + pArray = aDashedArray; + break; + + case LINESTYLE_BOLDLONGDASH: + bIsBold = true; + BOOST_FALLTHROUGH; + case LINESTYLE_LONGDASH: + pArray = aLongDashArray; + break; + + case LINESTYLE_BOLDDASHDOT: + bIsBold = true; + BOOST_FALLTHROUGH; + case LINESTYLE_DASHDOT: + pArray = aDotDashArray; + break; + case LINESTYLE_BOLDDASHDOTDOT: + bIsBold = true; + BOOST_FALLTHROUGH; + case LINESTYLE_DASHDOTDOT: + pArray = aDashDotDotArray; + break; + } - double x = nX; - for( sal_Int32 i=0; i