poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kiwiwi...@apache.org
Subject svn commit: r1881838 - /poi/trunk/src/ooxml/java/org/apache/poi/xslf/util/PPTX2PNG.java
Date Sat, 19 Sep 2020 08:16:35 GMT
Author: kiwiwings
Date: Sat Sep 19 08:16:34 2020
New Revision: 1881838

URL: http://svn.apache.org/viewvc?rev=1881838&view=rev
Log:
#64716 - wmf display error - use FileMagic also for File-based input

Modified:
    poi/trunk/src/ooxml/java/org/apache/poi/xslf/util/PPTX2PNG.java

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/util/PPTX2PNG.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/util/PPTX2PNG.java?rev=1881838&r1=1881837&r2=1881838&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/util/PPTX2PNG.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/util/PPTX2PNG.java Sat Sep 19 08:16:34 2020
@@ -362,46 +362,42 @@ public final class PPTX2PNG {
         }
     }
 
+    private interface ProxyConsumer {
+        void parse(MFProxy proxy) throws IOException;
+    }
+
     @SuppressWarnings({"resource", "squid:S2095"})
     private MFProxy initProxy(File file) throws IOException {
         MFProxy proxy;
         final String fileName = file.getName().toLowerCase(Locale.ROOT);
+        FileMagic fm;
+        ProxyConsumer con;
         if ("stdin".equals(fileName)) {
             InputStream bis = FileMagic.prepareToCheckMagic(System.in);
-            FileMagic fm = FileMagic.valueOf(bis);
-            if (fm == FileMagic.UNKNOWN) {
-                fm = defaultFileType;
-            }
-            switch (fm) {
-                case EMF:
-                    proxy = new EMFHandler();
-                    break;
-                case WMF:
-                    proxy = new WMFHandler();
-                    break;
-                default:
-                    proxy = new PPTHandler();
-                    break;
-            }
-            proxy.setIgnoreParse(ignoreParse);
-            proxy.setQuite(quiet);
-            proxy.parse(bis);
+            fm = FileMagic.valueOf(bis);
+            con = (p) -> p.parse(bis);
         } else {
-            switch (fileName.contains(".") ? fileName.substring(fileName.lastIndexOf('.'))
: "") {
-                case ".emf":
-                    proxy = new EMFHandler();
-                    break;
-                case ".wmf":
-                    proxy = new WMFHandler();
-                    break;
-                default:
-                    proxy = new PPTHandler();
-                    break;
-            }
-            proxy.setIgnoreParse(ignoreParse);
-            proxy.setQuite(quiet);
-            proxy.parse(file);
+            fm = FileMagic.valueOf(file);
+            con = (p) -> p.parse(file);
+        }
+
+        if (fm == FileMagic.UNKNOWN) {
+            fm = defaultFileType;
+        }
+        switch (fm) {
+            case EMF:
+                proxy = new EMFHandler();
+                break;
+            case WMF:
+                proxy = new WMFHandler();
+                break;
+            default:
+                proxy = new PPTHandler();
+                break;
         }
+        proxy.setIgnoreParse(ignoreParse);
+        proxy.setQuite(quiet);
+        con.parse(proxy);
         proxy.setDefaultCharset(charset);
 
         return proxy;



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


Mime
View raw message