Search in sources :

Example 1 with OldFileFormatException

use of org.apache.poi.OldFileFormatException in project poi by apache.

the class SlideShowFactory method createSlideShow.

protected static SlideShow<?, ?> createSlideShow(String factoryClass, Object[] args) throws IOException, EncryptedDocumentException {
    try {
        Class<?> clazz = Thread.currentThread().getContextClassLoader().loadClass(factoryClass);
        Class<?>[] argsClz = new Class<?>[args.length];
        int i = 0;
        for (Object o : args) {
            Class<?> c = o.getClass();
            if (Boolean.class.isAssignableFrom(c)) {
                c = boolean.class;
            } else if (InputStream.class.isAssignableFrom(c)) {
                c = InputStream.class;
            }
            argsClz[i++] = c;
        }
        Method m = clazz.getMethod("createSlideShow", argsClz);
        return (SlideShow<?, ?>) m.invoke(null, args);
    } catch (InvocationTargetException e) {
        Throwable t = e.getCause();
        if (t instanceof IOException) {
            throw (IOException) t;
        } else if (t instanceof EncryptedDocumentException) {
            throw (EncryptedDocumentException) t;
        } else if (t instanceof OldFileFormatException) {
            throw (OldFileFormatException) t;
        } else {
            throw new IOException(t);
        }
    } catch (Exception e) {
        throw new IOException(e);
    }
}
Also used : EncryptedDocumentException(org.apache.poi.EncryptedDocumentException) PushbackInputStream(java.io.PushbackInputStream) InputStream(java.io.InputStream) OldFileFormatException(org.apache.poi.OldFileFormatException) Method(java.lang.reflect.Method) IOException(java.io.IOException) InvocationTargetException(java.lang.reflect.InvocationTargetException) OfficeXmlFileException(org.apache.poi.poifs.filesystem.OfficeXmlFileException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) InvocationTargetException(java.lang.reflect.InvocationTargetException) EncryptedDocumentException(org.apache.poi.EncryptedDocumentException) OldFileFormatException(org.apache.poi.OldFileFormatException)

Aggregations

FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 PushbackInputStream (java.io.PushbackInputStream)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Method (java.lang.reflect.Method)1 EncryptedDocumentException (org.apache.poi.EncryptedDocumentException)1 OldFileFormatException (org.apache.poi.OldFileFormatException)1 OfficeXmlFileException (org.apache.poi.poifs.filesystem.OfficeXmlFileException)1