[Libreoffice-commits] core.git: Branch 'libreoffice-4-0' - cppcanvas/source
Jan Holesovsky
kendy at collabora.com
Tue Nov 26 02:06:30 PST 2013
cppcanvas/source/mtfrenderer/emfplus.cxx | 51 +++++++++++++++++++++++++++++--
1 file changed, 49 insertions(+), 2 deletions(-)
New commits:
commit d1f3dc8b43f65c6c16b6f58f3d5ee84f22001163
Author: Jan Holesovsky <kendy at collabora.com>
Date: Fri Nov 22 12:01:15 2013 +0100
EMF+: Implement line dashing.
Conflicts:
cppcanvas/source/mtfrenderer/emfplus.cxx
Change-Id: I9eb21c0a8b5baa5b0080845f61b12fc65034d959
Reviewed-on: https://gerrit.libreoffice.org/6803
Reviewed-by: Andras Timar <andras.timar at collabora.com>
Tested-by: Andras Timar <andras.timar at collabora.com>
diff --git a/cppcanvas/source/mtfrenderer/emfplus.cxx b/cppcanvas/source/mtfrenderer/emfplus.cxx
index b0acbd3..4968a6f 100644
--- a/cppcanvas/source/mtfrenderer/emfplus.cxx
+++ b/cppcanvas/source/mtfrenderer/emfplus.cxx
@@ -92,6 +92,13 @@
#define EmfPlusRegionInitialStateEmpty 0x10000002
#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;
+
#if OSL_DEBUG_LEVEL > 1
#define EMFP_DEBUG(x) x
#else
@@ -610,6 +617,34 @@ namespace cppcanvas
{
EMFP_DEBUG (if (width == 0.0) printf ("EMF+\tTODO: pen with zero width - using minimal which might not be correct\n"));
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 )
@@ -645,7 +680,10 @@ namespace cppcanvas
mitterLimit = 0;
if (penFlags & 32)
+ {
s >> dashStyle;
+ SAL_INFO("cppcanvas.emf", "EMF+\t\tdashStyle: 0x" << std::hex << dashStyle);
+ }
else
dashStyle = 0;
@@ -659,14 +697,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)
More information about the Libreoffice-commits
mailing list