diff options
author | Andreas Beeker <kiwiwings@apache.org> | 2020-09-15 22:53:09 +0000 |
---|---|---|
committer | Andreas Beeker <kiwiwings@apache.org> | 2020-09-15 22:53:09 +0000 |
commit | 69ddd04bd8a27d498dcaa333c28cd9976c14074f (patch) | |
tree | a5e6c1a7e47fa019ee4cc58e96c73ee7f760e8d3 /src/scratchpad | |
parent | f488a2f27032b0849c75dad636cb2284edb08d89 (diff) | |
download | poi-69ddd04bd8a27d498dcaa333c28cd9976c14074f.tar.gz poi-69ddd04bd8a27d498dcaa333c28cd9976c14074f.zip |
#64716 - wmf display error - WmfExtTextOut - move current location to the end of the string after its written to the GraphicsCtx
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1881750 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/scratchpad')
-rw-r--r-- | src/scratchpad/src/org/apache/poi/hwmf/draw/HwmfGraphics.java | 17 |
1 files changed, 17 insertions, 0 deletions
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 38b473da03..b849a55bfb 100644 --- a/src/scratchpad/src/org/apache/poi/hwmf/draw/HwmfGraphics.java +++ b/src/scratchpad/src/org/apache/poi/hwmf/draw/HwmfGraphics.java @@ -31,6 +31,7 @@ import java.awt.Shape; import java.awt.TexturePaint; import java.awt.font.FontRenderContext; import java.awt.font.GlyphVector; +import java.awt.font.LineBreakMeasurer; import java.awt.font.TextAttribute; import java.awt.font.TextLayout; import java.awt.geom.AffineTransform; @@ -475,6 +476,9 @@ public class HwmfGraphics implements HwmfCharsetAware { calculateDx(textString, dx, font, fontInfo, frc, as); + LineBreakMeasurer lbm = new LineBreakMeasurer(as.getIterator(), frc); + TextLayout textLayout = lbm.nextLayout(Integer.MAX_VALUE); + final double angle = Math.toRadians(-font.getEscapement()/10.); final Point2D dst = getRotatedOffset(angle, frc, as); @@ -494,6 +498,19 @@ public class HwmfGraphics implements HwmfCharsetAware { graphicsCtx.translate(dst.getX(), dst.getY()); graphicsCtx.setColor(prop.getTextColor().getColor()); graphicsCtx.drawString(as.getIterator(), 0, 0); + + // move current location to the end of string + AffineTransform atRev = new AffineTransform(); + atRev.translate(-dst.getX(), -dst.getY()); + if (scale != null) { + atRev.scale(scale.getWidth() < 0 ? 1 : -1, scale.getHeight() < 0 ? 1 : -1); + } + atRev.rotate(-angle); + + Point2D deltaX = new Point2D.Double(textLayout.getBounds().getWidth(), 0); + Point2D oldLoc = prop.getLocation(); + prop.setLocation(oldLoc.getX() + deltaX.getX(), oldLoc.getY() + deltaX.getY()); + } finally { graphicsCtx.setTransform(at); graphicsCtx.setClip(clipShape); |