diff options
author | Jan Holesovsky <kendy@collabora.com> | 2013-11-22 12:01:15 +0100 |
---|---|---|
committer | Jan Holesovsky <kendy@collabora.com> | 2013-11-25 14:10:46 +0100 |
commit | 40977516a515e21bc809a4d05f71be7dd481b1f7 (patch) | |
tree | 04bdd22210cc89852c66f31fcf3e69c45c9cc508 /cppcanvas | |
parent | 4ba2b2ae62276ab7b40ba5730d631ad4b3fd6ac8 (diff) |
EMF+: Implement line dashing.
Change-Id: I9eb21c0a8b5baa5b0080845f61b12fc65034d959
Diffstat (limited to 'cppcanvas')
-rw-r--r-- | cppcanvas/source/mtfrenderer/emfplus.cxx | 51 |
1 files changed, 49 insertions, 2 deletions
diff --git a/cppcanvas/source/mtfrenderer/emfplus.cxx b/cppcanvas/source/mtfrenderer/emfplus.cxx index be2bfbd4a716..9dc50d7fae7b 100644 --- a/cppcanvas/source/mtfrenderer/emfplus.cxx +++ b/cppcanvas/source/mtfrenderer/emfplus.cxx @@ -89,6 +89,13 @@ #define EmfPlusRegionInitialStateInfinite 0x10000003 +const sal_Int32 EmfPlusLineStyleSolid = 0x00000000; +const sal_Int32 EmfPlusLineStyleDash = 0x00000001; +const sal_Int32 EmfPlusLineStyleDot = 0x00000002; +const sal_Int32 EmfPlusLineStyleDashDot = 0x00000003; +const sal_Int32 EmfPlusLineStyleDashDotDot = 0x00000004; +const sal_Int32 EmfPlusLineStyleCustom = 0x00000005; + using namespace ::com::sun::star; using namespace ::basegfx; @@ -626,6 +633,34 @@ namespace cppcanvas } #endif rStrokeAttributes.StrokeWidth = fabs((rState.mapModeTransform * rR.MapSize (width == 0.0 ? 0.05 : width, 0)).getX()); + + // set dashing + if (dashStyle != EmfPlusLineStyleSolid) + { + const float dash[] = {3, 3}; + const float dot[] = {1, 3}; + const float dashdot[] = {3, 3, 1, 3}; + const float dashdotdot[] = {3, 3, 1, 3, 1, 3}; + + sal_Int32 nLen = 0; + const float *pPattern; + switch (dashStyle) + { + case EmfPlusLineStyleDash: nLen = SAL_N_ELEMENTS(dash); pPattern = dash; break; + case EmfPlusLineStyleDot: nLen = SAL_N_ELEMENTS(dot); pPattern = dot; break; + case EmfPlusLineStyleDashDot: nLen = SAL_N_ELEMENTS(dashdot); pPattern = dashdot; break; + case EmfPlusLineStyleDashDotDot: nLen = SAL_N_ELEMENTS(dashdotdot); pPattern = dashdotdot; break; + case EmfPlusLineStyleCustom: nLen = dashPatternLen; pPattern = dashPattern; break; + } + if (nLen > 0) + { + uno::Sequence<double> aDashArray(nLen); + for (int i = 0; i < nLen; ++i) + aDashArray[i] = pPattern[i]; + + rStrokeAttributes.DashArray = aDashArray; + } + } } void Read (SvStream& s, ImplRenderer& rR, sal_Int32, sal_Int32 ) @@ -663,7 +698,10 @@ namespace cppcanvas mitterLimit = 0; if (penFlags & 32) + { s >> dashStyle; + SAL_INFO("cppcanvas.emf", "EMF+\t\tdashStyle: 0x" << std::hex << dashStyle); + } else dashStyle = 0; @@ -677,14 +715,23 @@ namespace cppcanvas else dashOffset = 0; - if (penFlags & 256) { + if (penFlags & 256) + { + dashStyle = EmfPlusLineStyleCustom; + s >> dashPatternLen; + SAL_INFO("cppcanvas.emf", "EMF+\t\tdashPatternLen: " << dashPatternLen); + if( dashPatternLen<0 || sal_uInt32(dashPatternLen)>SAL_MAX_INT32/sizeof(float) ) dashPatternLen = SAL_MAX_INT32/sizeof(float); dashPattern = new float [dashPatternLen]; for (i = 0; i < dashPatternLen; i++) + { s >> dashPattern [i]; - } else + SAL_INFO("cppcanvas.emf", "EMF+\t\t\tdashPattern[" << i << "]: " << dashPattern[i]); + } + } + else dashPatternLen = 0; if (penFlags & 512) |