Skip to content

Commit 4ed7339

Browse files
committed
address #348
1 parent eae5539 commit 4ed7339

2 files changed

Lines changed: 14 additions & 10 deletions

File tree

app/src/main/java/at/tomtasche/reader/background/CoreWrapper.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -107,20 +107,20 @@ public static class CoreResult {
107107
public String extension;
108108
}
109109

110-
public class CoreCouldNotOpenException extends RuntimeException {}
110+
public static class CoreCouldNotOpenException extends RuntimeException {}
111111

112-
public class CoreEncryptedException extends RuntimeException {}
112+
public static class CoreEncryptedException extends RuntimeException {}
113113

114-
public class CoreCouldNotTranslateException extends RuntimeException {}
114+
public static class CoreCouldNotTranslateException extends RuntimeException {}
115115

116-
public class CoreUnexpectedFormatException extends RuntimeException {}
116+
public static class CoreUnexpectedFormatException extends RuntimeException {}
117117

118-
public class CoreUnexpectedErrorCodeException extends RuntimeException {}
118+
public static class CoreUnexpectedErrorCodeException extends RuntimeException {}
119119

120-
public class CoreUnknownErrorException extends RuntimeException {}
120+
public static class CoreUnknownErrorException extends RuntimeException {}
121121

122-
public class CoreCouldNotEditException extends RuntimeException {}
122+
public static class CoreCouldNotEditException extends RuntimeException {}
123123

124-
public class CoreCouldNotSaveException extends RuntimeException {}
124+
public static class CoreCouldNotSaveException extends RuntimeException {}
125125

126126
}

app/src/main/java/at/tomtasche/reader/background/OdfLoader.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,12 @@ private void translate(Options options, Result result) throws Exception {
8181
CoreWrapper.CoreResult coreResult = lastCore.parse(coreOptions);
8282

8383
String coreExtension = coreResult.extension;
84-
// "unnamed" refers to default of Meta::typeToString
85-
if (coreExtension != null && !coreExtension.equals("unnamed")) {
84+
if (coreResult.exception == null && "pdf".equals(coreExtension)) {
85+
// some PDFs do not cause an error in the core
86+
// https://github.com/opendocument-app/OpenDocument.droid/issues/348#issuecomment-2446888981
87+
throw new CoreWrapper.CoreCouldNotTranslateException();
88+
} else if (!"unnamed".equals(coreExtension)) {
89+
// "unnamed" refers to default of Meta::typeToString
8690
options.fileExtension = coreExtension;
8791

8892
String fileType = MimeTypeMap.getSingleton().getMimeTypeFromExtension(coreExtension);

0 commit comments

Comments
 (0)