poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n...@apache.org
Subject svn commit: r1844116 - in /poi/trunk/src: java/org/apache/poi/ss/usermodel/WorkbookFactory.java ooxml/testcases/org/apache/poi/ss/TestWorkbookFactory.java
Date Wed, 17 Oct 2018 14:24:59 GMT
Author: nick
Date: Wed Oct 17 14:24:59 2018
New Revision: 1844116

URL: http://svn.apache.org/viewvc?rev=1844116&view=rev
Log:
#62831 Fix WorkbookFactory.create with a subclass of File, eg from JFileChooser

Modified:
    poi/trunk/src/java/org/apache/poi/ss/usermodel/WorkbookFactory.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/ss/TestWorkbookFactory.java

Modified: poi/trunk/src/java/org/apache/poi/ss/usermodel/WorkbookFactory.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/usermodel/WorkbookFactory.java?rev=1844116&r1=1844115&r2=1844116&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/usermodel/WorkbookFactory.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/usermodel/WorkbookFactory.java Wed Oct 17 14:24:59
2018
@@ -296,6 +296,11 @@ public class WorkbookFactory {
         return createWorkbook("org.apache.poi.xssf.usermodel.XSSFWorkbookFactory", args);
     }
 
+    /**
+     * Does the actual call to HSSF or XSSF to do the creation.
+     * Uses reflection, so that this class can be in the Core non-OOXML
+     *  POI jar without errors / broken references to the OOXML / XSSF code.
+     */
     private static Workbook createWorkbook(String factoryClass, Object args[]) throws IOException,
EncryptedDocumentException {
         try {
             Class<?> clazz = WorkbookFactory.class.getClassLoader().loadClass(factoryClass);
@@ -307,6 +312,8 @@ public class WorkbookFactory {
                     c = boolean.class;
                 } else if (InputStream.class.isAssignableFrom(c)) {
                     c = InputStream.class;
+                } else if (File.class.isAssignableFrom(c)) {
+                    c = File.class;
                 }
                 argsClz[i++] = c;
             }

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/ss/TestWorkbookFactory.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/ss/TestWorkbookFactory.java?rev=1844116&r1=1844115&r2=1844116&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/ss/TestWorkbookFactory.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/ss/TestWorkbookFactory.java Wed Oct 17 14:24:59
2018
@@ -17,18 +17,24 @@
 
 package org.apache.poi.ss;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
 import java.io.ByteArrayInputStream;
 import java.io.File;
+import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
-import java.io.FileNotFoundException;
 
 import org.apache.poi.EmptyFileException;
 import org.apache.poi.EncryptedDocumentException;
-import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.apache.poi.hssf.HSSFTestDataSamples;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.poi.openxml4j.opc.OPCPackage;
+import org.apache.poi.openxml4j.opc.PackageAccess;
 import org.apache.poi.poifs.filesystem.POIFSFileSystem;
 import org.apache.poi.ss.usermodel.Workbook;
 import org.apache.poi.ss.usermodel.WorkbookFactory;
@@ -36,10 +42,7 @@ import org.apache.poi.util.POILogFactory
 import org.apache.poi.util.POILogger;
 import org.apache.poi.util.TempFile;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
-import org.apache.poi.openxml4j.opc.OPCPackage;
-import org.apache.poi.openxml4j.opc.PackageAccess;
 import org.apache.poi.xssf.usermodel.XSSFWorkbookFactory;
-import org.junit.Ignore;
 import org.junit.Test;
 
 public final class TestWorkbookFactory {
@@ -393,7 +396,6 @@ public final class TestWorkbookFactory {
      *  to work for sub-classes of File too, eg JFileChooser
      */
     @Test
-    @Ignore
     public void testFileSubclass() throws Exception {
         Workbook wb;
         



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


Mime
View raw message