|
|
f0633d |
From 34de60961b098416b38af8e8595e2579b2b6bc66 Mon Sep 17 00:00:00 2001
|
|
|
f0633d |
From: Jan Holesovsky <kendy@collabora.com>
|
|
|
f0633d |
Date: Fri, 22 Nov 2013 12:01:15 +0100
|
|
|
f0633d |
Subject: [PATCH 004/109] EMF+: Implement line dashing.
|
|
|
f0633d |
|
|
|
f0633d |
Change-Id: I9eb21c0a8b5baa5b0080845f61b12fc65034d959
|
|
|
f0633d |
Reviewed-on: https://gerrit.libreoffice.org/6830
|
|
|
f0633d |
Reviewed-by: Andras Timar <andras.timar@collabora.com>
|
|
|
f0633d |
Tested-by: Andras Timar <andras.timar@collabora.com>
|
|
|
f0633d |
---
|
|
|
f0633d |
cppcanvas/source/mtfrenderer/emfplus.cxx | 51 ++++++++++++++++++++++++++++++--
|
|
|
f0633d |
1 file changed, 49 insertions(+), 2 deletions(-)
|
|
|
f0633d |
|
|
|
f0633d |
diff --git a/cppcanvas/source/mtfrenderer/emfplus.cxx b/cppcanvas/source/mtfrenderer/emfplus.cxx
|
|
|
f0633d |
index daed614..a1b6ebd 100644
|
|
|
f0633d |
--- a/cppcanvas/source/mtfrenderer/emfplus.cxx
|
|
|
f0633d |
+++ b/cppcanvas/source/mtfrenderer/emfplus.cxx
|
|
|
f0633d |
@@ -89,6 +89,13 @@
|
|
|
f0633d |
|
|
|
f0633d |
#define EmfPlusRegionInitialStateInfinite 0x10000003
|
|
|
f0633d |
|
|
|
f0633d |
+const sal_Int32 EmfPlusLineStyleSolid = 0x00000000;
|
|
|
f0633d |
+const sal_Int32 EmfPlusLineStyleDash = 0x00000001;
|
|
|
f0633d |
+const sal_Int32 EmfPlusLineStyleDot = 0x00000002;
|
|
|
f0633d |
+const sal_Int32 EmfPlusLineStyleDashDot = 0x00000003;
|
|
|
f0633d |
+const sal_Int32 EmfPlusLineStyleDashDotDot = 0x00000004;
|
|
|
f0633d |
+const sal_Int32 EmfPlusLineStyleCustom = 0x00000005;
|
|
|
f0633d |
+
|
|
|
f0633d |
using namespace ::com::sun::star;
|
|
|
f0633d |
using namespace ::basegfx;
|
|
|
f0633d |
|
|
|
f0633d |
@@ -614,6 +621,34 @@ namespace cppcanvas
|
|
|
f0633d |
}
|
|
|
f0633d |
#endif
|
|
|
f0633d |
rStrokeAttributes.StrokeWidth = fabs((rState.mapModeTransform * rR.MapSize (width == 0.0 ? 0.05 : width, 0)).getX());
|
|
|
f0633d |
+
|
|
|
f0633d |
+ // set dashing
|
|
|
f0633d |
+ if (dashStyle != EmfPlusLineStyleSolid)
|
|
|
f0633d |
+ {
|
|
|
f0633d |
+ const float dash[] = {3, 3};
|
|
|
f0633d |
+ const float dot[] = {1, 3};
|
|
|
f0633d |
+ const float dashdot[] = {3, 3, 1, 3};
|
|
|
f0633d |
+ const float dashdotdot[] = {3, 3, 1, 3, 1, 3};
|
|
|
f0633d |
+
|
|
|
f0633d |
+ sal_Int32 nLen = 0;
|
|
|
f0633d |
+ const float *pPattern;
|
|
|
f0633d |
+ switch (dashStyle)
|
|
|
f0633d |
+ {
|
|
|
f0633d |
+ case EmfPlusLineStyleDash: nLen = SAL_N_ELEMENTS(dash); pPattern = dash; break;
|
|
|
f0633d |
+ case EmfPlusLineStyleDot: nLen = SAL_N_ELEMENTS(dot); pPattern = dot; break;
|
|
|
f0633d |
+ case EmfPlusLineStyleDashDot: nLen = SAL_N_ELEMENTS(dashdot); pPattern = dashdot; break;
|
|
|
f0633d |
+ case EmfPlusLineStyleDashDotDot: nLen = SAL_N_ELEMENTS(dashdotdot); pPattern = dashdotdot; break;
|
|
|
f0633d |
+ case EmfPlusLineStyleCustom: nLen = dashPatternLen; pPattern = dashPattern; break;
|
|
|
f0633d |
+ }
|
|
|
f0633d |
+ if (nLen > 0)
|
|
|
f0633d |
+ {
|
|
|
f0633d |
+ uno::Sequence<double> aDashArray(nLen);
|
|
|
f0633d |
+ for (int i = 0; i < nLen; ++i)
|
|
|
f0633d |
+ aDashArray[i] = pPattern[i];
|
|
|
f0633d |
+
|
|
|
f0633d |
+ rStrokeAttributes.DashArray = aDashArray;
|
|
|
f0633d |
+ }
|
|
|
f0633d |
+ }
|
|
|
f0633d |
}
|
|
|
f0633d |
|
|
|
f0633d |
void Read (SvStream& s, ImplRenderer& rR, sal_Int32, sal_Int32 )
|
|
|
f0633d |
@@ -651,7 +686,10 @@ namespace cppcanvas
|
|
|
f0633d |
mitterLimit = 0;
|
|
|
f0633d |
|
|
|
f0633d |
if (penFlags & 32)
|
|
|
f0633d |
+ {
|
|
|
f0633d |
s >> dashStyle;
|
|
|
f0633d |
+ SAL_INFO("cppcanvas.emf", "EMF+\t\tdashStyle: 0x" << std::hex << dashStyle);
|
|
|
f0633d |
+ }
|
|
|
f0633d |
else
|
|
|
f0633d |
dashStyle = 0;
|
|
|
f0633d |
|
|
|
f0633d |
@@ -665,14 +703,23 @@ namespace cppcanvas
|
|
|
f0633d |
else
|
|
|
f0633d |
dashOffset = 0;
|
|
|
f0633d |
|
|
|
f0633d |
- if (penFlags & 256) {
|
|
|
f0633d |
+ if (penFlags & 256)
|
|
|
f0633d |
+ {
|
|
|
f0633d |
+ dashStyle = EmfPlusLineStyleCustom;
|
|
|
f0633d |
+
|
|
|
f0633d |
s >> dashPatternLen;
|
|
|
f0633d |
+ SAL_INFO("cppcanvas.emf", "EMF+\t\tdashPatternLen: " << dashPatternLen);
|
|
|
f0633d |
+
|
|
|
f0633d |
if( dashPatternLen<0 || sal_uInt32(dashPatternLen)>SAL_MAX_INT32/sizeof(float) )
|
|
|
f0633d |
dashPatternLen = SAL_MAX_INT32/sizeof(float);
|
|
|
f0633d |
dashPattern = new float [dashPatternLen];
|
|
|
f0633d |
for (i = 0; i < dashPatternLen; i++)
|
|
|
f0633d |
+ {
|
|
|
f0633d |
s >> dashPattern [i];
|
|
|
f0633d |
- } else
|
|
|
f0633d |
+ SAL_INFO("cppcanvas.emf", "EMF+\t\t\tdashPattern[" << i << "]: " << dashPattern[i]);
|
|
|
f0633d |
+ }
|
|
|
f0633d |
+ }
|
|
|
f0633d |
+ else
|
|
|
f0633d |
dashPatternLen = 0;
|
|
|
f0633d |
|
|
|
f0633d |
if (penFlags & 512)
|
|
|
f0633d |
--
|
|
|
f0633d |
1.8.4.2
|
|
|
f0633d |
|