diff --git a/app/src/main/java/at/tomtasche/reader/background/CoreWrapper.java b/app/src/main/java/at/tomtasche/reader/background/CoreWrapper.java index eeceebe9bc0c..bcecd270203a 100644 --- a/app/src/main/java/at/tomtasche/reader/background/CoreWrapper.java +++ b/app/src/main/java/at/tomtasche/reader/background/CoreWrapper.java @@ -107,20 +107,20 @@ public static class CoreResult { public String extension; } - public class CoreCouldNotOpenException extends RuntimeException {} + public static class CoreCouldNotOpenException extends RuntimeException {} - public class CoreEncryptedException extends RuntimeException {} + public static class CoreEncryptedException extends RuntimeException {} - public class CoreCouldNotTranslateException extends RuntimeException {} + public static class CoreCouldNotTranslateException extends RuntimeException {} - public class CoreUnexpectedFormatException extends RuntimeException {} + public static class CoreUnexpectedFormatException extends RuntimeException {} - public class CoreUnexpectedErrorCodeException extends RuntimeException {} + public static class CoreUnexpectedErrorCodeException extends RuntimeException {} - public class CoreUnknownErrorException extends RuntimeException {} + public static class CoreUnknownErrorException extends RuntimeException {} - public class CoreCouldNotEditException extends RuntimeException {} + public static class CoreCouldNotEditException extends RuntimeException {} - public class CoreCouldNotSaveException extends RuntimeException {} + public static class CoreCouldNotSaveException extends RuntimeException {} } diff --git a/app/src/main/java/at/tomtasche/reader/background/OdfLoader.java b/app/src/main/java/at/tomtasche/reader/background/OdfLoader.java index e3c931dd2a17..7746957ea3ba 100644 --- a/app/src/main/java/at/tomtasche/reader/background/OdfLoader.java +++ b/app/src/main/java/at/tomtasche/reader/background/OdfLoader.java @@ -81,8 +81,12 @@ private void translate(Options options, Result result) throws Exception { CoreWrapper.CoreResult coreResult = lastCore.parse(coreOptions); String coreExtension = coreResult.extension; - // "unnamed" refers to default of Meta::typeToString - if (coreExtension != null && !coreExtension.equals("unnamed")) { + if (coreResult.exception == null && "pdf".equals(coreExtension)) { + // some PDFs do not cause an error in the core + // https://github.com/opendocument-app/OpenDocument.droid/issues/348#issuecomment-2446888981 + throw new CoreWrapper.CoreCouldNotTranslateException(); + } else if (!"unnamed".equals(coreExtension)) { + // "unnamed" refers to default of Meta::typeToString options.fileExtension = coreExtension; String fileType = MimeTypeMap.getSingleton().getMimeTypeFromExtension(coreExtension);