poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kiwiwi...@apache.org
Subject svn commit: r1881750 - /poi/trunk/src/scratchpad/src/org/apache/poi/hwmf/draw/HwmfGraphics.java
Date Tue, 15 Sep 2020 22:53:09 GMT
Author: kiwiwings
Date: Tue Sep 15 22:53:09 2020
New Revision: 1881750

URL: http://svn.apache.org/viewvc?rev=1881750&view=rev
Log:
#64716 - wmf display error - WmfExtTextOut - move current location to the end of the string
after its written to the GraphicsCtx

Modified:
    poi/trunk/src/scratchpad/src/org/apache/poi/hwmf/draw/HwmfGraphics.java

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwmf/draw/HwmfGraphics.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwmf/draw/HwmfGraphics.java?rev=1881750&r1=1881749&r2=1881750&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hwmf/draw/HwmfGraphics.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hwmf/draw/HwmfGraphics.java Tue Sep 15 22:53:09
2020
@@ -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 Hwm
 
         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 Hwm
             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);



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message