]> source.dussan.org Git - poi.git/commitdiff
#60656 - Support export file that contains emf and render it correctly
authorAndreas Beeker <kiwiwings@apache.org>
Sun, 21 Oct 2018 22:42:03 +0000 (22:42 +0000)
committerAndreas Beeker <kiwiwings@apache.org>
Sun, 21 Oct 2018 22:42:03 +0000 (22:42 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/branches/hemf@1844524 13f79535-47bb-0310-9956-ffa450edef68

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

index e32c451e2a653471b5f9be55ac0f0b9a0589d3f1..011cb56ff75613cb873feabc2ec49391c2207806 100644 (file)
@@ -106,19 +106,21 @@ public class HemfGraphics extends HwmfGraphics {
         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) {
index 459a0b2ee3cc007bf2f129a2a04744240822ce3c..0eb6522e44701b1e9e5ae21e100af0640fe130f2 100644 (file)
 
 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
index 7a3bf470e0cfafa4812e2eb531e9973b4c8a57e6..5b19f9d1289612261b08280d8c0216c00345ddf0 100644 (file)
@@ -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),
index 97a81d910201230205ec1f5cd990696f7410b090..9f36812179ba47c595eca9b3429dd800cddf7cf4 100644 (file)
@@ -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 {