poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kiwiwi...@apache.org
Subject svn commit: r1844524 - in /poi/branches/hemf/src/scratchpad/src/org/apache/poi/hemf: draw/HemfGraphics.java record/emf/HemfDraw.java record/emf/HemfRecordType.java record/emf/HemfText.java
Date Sun, 21 Oct 2018 22:42:03 GMT
Author: kiwiwings
Date: Sun Oct 21 22:42:03 2018
New Revision: 1844524

URL: http://svn.apache.org/viewvc?rev=1844524&view=rev
Log:
#60656 - Support export file that contains emf and render it correctly

Modified:
    poi/branches/hemf/src/scratchpad/src/org/apache/poi/hemf/draw/HemfGraphics.java
    poi/branches/hemf/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfDraw.java
    poi/branches/hemf/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfRecordType.java
    poi/branches/hemf/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfText.java

Modified: poi/branches/hemf/src/scratchpad/src/org/apache/poi/hemf/draw/HemfGraphics.java
URL: http://svn.apache.org/viewvc/poi/branches/hemf/src/scratchpad/src/org/apache/poi/hemf/draw/HemfGraphics.java?rev=1844524&r1=1844523&r2=1844524&view=diff
==============================================================================
--- poi/branches/hemf/src/scratchpad/src/org/apache/poi/hemf/draw/HemfGraphics.java (original)
+++ poi/branches/hemf/src/scratchpad/src/org/apache/poi/hemf/draw/HemfGraphics.java Sun Oct
21 22:42:03 2018
@@ -106,19 +106,21 @@ public class HemfGraphics extends HwmfGr
         final Path2D path;
         if (useBracket) {
             path = prop.getPath();
-            if (path.getCurrentPoint() == null) {
-                // workaround if a path has been started and no MoveTo command
-                // has been specified before the first lineTo/splineTo
-                final Point2D loc = prop.getLocation();
-                path.moveTo(loc.getX(), loc.getY());
-            }
         } else {
             path = new Path2D.Double();
             Point2D pnt = prop.getLocation();
             path.moveTo(pnt.getX(),pnt.getY());
         }
 
-        pathConsumer.accept(path);
+        try {
+            pathConsumer.accept(path);
+        } catch (Exception e) {
+            // workaround if a path has been started and no MoveTo command
+            // has been specified before the first lineTo/splineTo
+            final Point2D loc = prop.getLocation();
+            path.moveTo(loc.getX(), loc.getY());
+            pathConsumer.accept(path);
+        }
 
         prop.setLocation(path.getCurrentPoint());
         if (!useBracket) {

Modified: poi/branches/hemf/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfDraw.java
URL: http://svn.apache.org/viewvc/poi/branches/hemf/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfDraw.java?rev=1844524&r1=1844523&r2=1844524&view=diff
==============================================================================
--- poi/branches/hemf/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfDraw.java (original)
+++ poi/branches/hemf/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfDraw.java Sun
Oct 21 22:42:03 2018
@@ -17,10 +17,6 @@
 
 package org.apache.poi.hemf.record.emf;
 
-import static org.apache.poi.hwmf.record.HwmfBrushStyle.BS_NULL;
-import static org.apache.poi.hwmf.record.HwmfBrushStyle.BS_SOLID;
-
-import java.awt.Color;
 import java.awt.geom.Arc2D;
 import java.awt.geom.Area;
 import java.awt.geom.Dimension2D;
@@ -32,10 +28,8 @@ import java.io.IOException;
 
 import org.apache.poi.hemf.draw.HemfDrawProperties;
 import org.apache.poi.hemf.draw.HemfGraphics;
-import org.apache.poi.hwmf.record.HwmfColorRef;
 import org.apache.poi.hwmf.record.HwmfDraw;
 import org.apache.poi.hwmf.record.HwmfDraw.WmfSelectObject;
-import org.apache.poi.hwmf.record.HwmfPenStyle;
 import org.apache.poi.util.LittleEndianConsts;
 import org.apache.poi.util.LittleEndianInputStream;
 
@@ -242,6 +236,7 @@ public class HemfDraw {
                         // if this path is connected to the current position (= has no start
point)
                         // the first entry is a dummy entry and will be skipped later
                         poly.moveTo(0,0);
+                        poly.lineTo(pnt.getX(), pnt.getY());
                     }
                 } else {
                     poly.lineTo(pnt.getX(), pnt.getY());
@@ -952,7 +947,6 @@ public class HemfDraw {
                 path.closePath();
                 prop.setLocation(path.getCurrentPoint());
             }
-
         }
 
         @Override

Modified: poi/branches/hemf/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfRecordType.java
URL: http://svn.apache.org/viewvc/poi/branches/hemf/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfRecordType.java?rev=1844524&r1=1844523&r2=1844524&view=diff
==============================================================================
--- poi/branches/hemf/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfRecordType.java
(original)
+++ poi/branches/hemf/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfRecordType.java
Sun Oct 21 22:42:03 2018
@@ -106,8 +106,8 @@ public enum HemfRecordType {
     setDiBitsToDevice(0x00000050, HemfFill.EmfSetDiBitsToDevice::new),
     stretchDiBits(0x00000051, HemfFill.EmfStretchDiBits::new),
     extCreateFontIndirectW(0x00000052, HemfText.ExtCreateFontIndirectW::new),
-    exttextouta(0x00000053, HemfText.EmfExtTextOutA::new),
-    exttextoutw(0x00000054, HemfText.EmfExtTextOutW::new),
+    extTextOutA(0x00000053, HemfText.EmfExtTextOutA::new),
+    extTextOutW(0x00000054, HemfText.EmfExtTextOutW::new),
     polyBezier16(0x00000055, HemfDraw.EmfPolyBezier16::new),
     polygon16(0x00000056, HemfDraw.EmfPolygon16::new),
     polyline16(0x00000057, HemfDraw.EmfPolyline16::new),

Modified: poi/branches/hemf/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfText.java
URL: http://svn.apache.org/viewvc/poi/branches/hemf/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfText.java?rev=1844524&r1=1844523&r2=1844524&view=diff
==============================================================================
--- poi/branches/hemf/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfText.java (original)
+++ poi/branches/hemf/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfText.java Sun
Oct 21 22:42:03 2018
@@ -28,7 +28,6 @@ import java.awt.geom.Rectangle2D;
 import java.io.IOException;
 import java.nio.charset.Charset;
 
-import org.apache.commons.codec.Charsets;
 import org.apache.poi.hemf.draw.HemfGraphics;
 import org.apache.poi.hwmf.draw.HwmfGraphics;
 import org.apache.poi.hwmf.record.HwmfText;
@@ -38,7 +37,6 @@ import org.apache.poi.util.IOUtils;
 import org.apache.poi.util.Internal;
 import org.apache.poi.util.LittleEndianConsts;
 import org.apache.poi.util.LittleEndianInputStream;
-import org.apache.poi.util.LocaleUtil;
 import org.apache.poi.util.RecordFormatException;
 
 /**
@@ -72,7 +70,7 @@ public class HemfText {
 
         @Override
         public HemfRecordType getEmfRecordType() {
-            return HemfRecordType.exttextouta;
+            return HemfRecordType.extTextOutA;
         }
 
         @Override
@@ -209,7 +207,7 @@ public class HemfText {
 
         @Override
         public HemfRecordType getEmfRecordType() {
-            return HemfRecordType.exttextoutw;
+            return HemfRecordType.extTextOutW;
         }
 
         public String getText() throws IOException {



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


Mime
View raw message