From c6b408b232dfde2e2ba4d930a57ca57d84a7b25f Mon Sep 17 00:00:00 2001 From: Andreas Beeker Date: Sun, 15 Nov 2020 21:49:24 +0000 Subject: #64716 - wmf display error - close polygons - reset current path location on emf modifyworldtransform - mirror text if the affinetransform is negative scaled git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1883460 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/org/apache/poi/hemf/record/emf/HemfDraw.java | 15 +++++++++++++++ .../src/org/apache/poi/hemf/record/emf/HemfMisc.java | 1 + .../src/org/apache/poi/hemf/record/emf/HemfText.java | 2 +- .../src/org/apache/poi/hwmf/draw/HwmfGraphics.java | 1 + .../src/org/apache/poi/hwmf/record/HwmfDraw.java | 17 +++++++++++++++++ .../src/org/apache/poi/hwmf/record/HwmfText.java | 5 +++++ 6 files changed, 40 insertions(+), 1 deletion(-) (limited to 'src/scratchpad') diff --git a/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfDraw.java b/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfDraw.java index f49926871f..02366a5b8d 100644 --- a/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfDraw.java +++ b/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfDraw.java @@ -205,6 +205,11 @@ public final class HemfDraw { return bounds; } + @Override + protected boolean addClose() { + return false; + } + @Override public Map> getGenericProperties() { return GenericRecordUtil.getGenericProperties( @@ -352,6 +357,11 @@ public final class HemfDraw { // The line segments SHOULD be drawn using the current pen. return FillDrawStyle.DRAW; } + + @Override + protected boolean addClose() { + return false; + } } /** @@ -952,6 +962,11 @@ public final class HemfDraw { return bounds; } + @Override + protected boolean addClose() { + return false; + } + @Override public Map> getGenericProperties() { return GenericRecordUtil.getGenericProperties( diff --git a/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfMisc.java b/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfMisc.java index 51dd125930..996a44f08e 100644 --- a/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfMisc.java +++ b/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfMisc.java @@ -831,6 +831,7 @@ public class HemfMisc { break; } ctx.updateWindowMapMode(); + ctx.getProperties().setLocation(0,0); } @Override diff --git a/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfText.java b/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfText.java index c10c004f51..9a8f629afc 100644 --- a/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfText.java +++ b/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfText.java @@ -95,7 +95,7 @@ public class HemfText { // A WMF PointL object that specifies the coordinates of the reference point used to position the string. // The reference point is defined by the last EMR_SETTEXTALIGN record. - // If no such record has been set, the default alignment is TA_LEFT,TA_TOP. + // If no such record has been set, the defaulint alignment is TA_LEFT,TA_TOP. size += readPointL(leis, reference); // A 32-bit unsigned integer that specifies the number of characters in the string. stringLength = (int)leis.readUInt(); diff --git a/src/scratchpad/src/org/apache/poi/hwmf/draw/HwmfGraphics.java b/src/scratchpad/src/org/apache/poi/hwmf/draw/HwmfGraphics.java index 48790f8e0a..dbca6ef9cf 100644 --- a/src/scratchpad/src/org/apache/poi/hwmf/draw/HwmfGraphics.java +++ b/src/scratchpad/src/org/apache/poi/hwmf/draw/HwmfGraphics.java @@ -495,6 +495,7 @@ public class HwmfGraphics implements HwmfCharsetAware { if (scale != null) { graphicsCtx.scale(scale.getWidth() < 0 ? -1 : 1, scale.getHeight() < 0 ? -1 : 1); } + graphicsCtx.scale(at.getScaleX() < 0 ? -1 : 1, at.getScaleY() < 0 ? -1 : 1); graphicsCtx.translate(dst.getX(), dst.getY()); graphicsCtx.setColor(prop.getTextColor().getColor()); graphicsCtx.drawString(as.getIterator(), 0, 0); diff --git a/src/scratchpad/src/org/apache/poi/hwmf/record/HwmfDraw.java b/src/scratchpad/src/org/apache/poi/hwmf/record/HwmfDraw.java index 38089ca7ab..19dee4e871 100644 --- a/src/scratchpad/src/org/apache/poi/hwmf/record/HwmfDraw.java +++ b/src/scratchpad/src/org/apache/poi/hwmf/record/HwmfDraw.java @@ -158,6 +158,11 @@ public final class HwmfDraw { } } + if (addClose()) { + // polygons are closed / polylines not + poly.closePath(); + } + return LittleEndianConsts.SHORT_SIZE+numberofPoints*LittleEndianConsts.INT_SIZE; } @@ -185,6 +190,13 @@ public final class HwmfDraw { return poly; } + /** + * @return {@code true} if the path needs to be closed + */ + protected boolean addClose() { + return true; + } + @Override public Map> getGenericProperties() { return GenericRecordUtil.getGenericProperties("poly", this::getPoly); @@ -206,6 +218,11 @@ public final class HwmfDraw { protected FillDrawStyle getFillDrawStyle() { return FillDrawStyle.DRAW; } + + @Override + protected boolean addClose() { + return false; + } } /** diff --git a/src/scratchpad/src/org/apache/poi/hwmf/record/HwmfText.java b/src/scratchpad/src/org/apache/poi/hwmf/record/HwmfText.java index cc29087c69..07c7636a29 100644 --- a/src/scratchpad/src/org/apache/poi/hwmf/record/HwmfText.java +++ b/src/scratchpad/src/org/apache/poi/hwmf/record/HwmfText.java @@ -469,6 +469,10 @@ public class HwmfText { return bounds; } + public WmfExtTextOutOptions getOptions() { + return options; + } + protected boolean isUnicode() { return false; } @@ -491,6 +495,7 @@ public class HwmfText { return GenericRecordUtil.getGenericProperties( "reference", this::getReference, "bounds", this::getBounds, + "options", this::getOptions, "text", this::getGenericText, "dx", () -> dx ); -- cgit v1.2.3