docbox_processing/office/
libreoffice.rs

1/// List of supported convertable formats
2pub const LIBREOFFICE_CONVERTABLE_FORMATS: &[&str] = &[
3    // .dotm
4    "application/vnd.ms-word.template.macroenabled.12",
5    // .xlsb
6    "application/vnd.ms-excel.sheet.binary.macroenabled.12",
7    // .xlsm
8    "application/vnd.ms-excel.sheet.macroenabled.12",
9    // .xltm
10    "application/vnd.ms-excel.template.macroenabled.12",
11    // .ods
12    "application/vnd.oasis.opendocument.spreadsheet",
13    "text/html",
14    "application/msword",
15    "application/vnd.oasis.opendocument.text-flat-xml",
16    "application/rtf",
17    "application/vnd.sun.xml.writer",
18    "application/vnd.wordperfect",
19    "application/vnd.ms-works",
20    "application/x-mswrite",
21    "application/clarisworks",
22    "application/macwriteii",
23    "application/x-abiword",
24    "application/x-t602",
25    "application/vnd.lotus-wordpro",
26    "application/x-hwp",
27    "application/vnd.sun.xml.writer.template",
28    "application/pdf",
29    "application/vnd.oasis.opendocument.text",
30    "application/vnd.oasis.opendocument.text-template",
31    "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
32    "application/vnd.openxmlformats-officedocument.wordprocessingml.template",
33    "application/vnd.openxmlformats-officedocument.wordprocessingml.slideshow",
34    "application/vnd.openxmlformats-officedocument.presentationml.presentation",
35    "application/vnd.oasis.opendocument.presentation",
36    "application/x-fictionbook+xml",
37    "application/x-aportisdoc",
38    "application/prs.plucker",
39    "application/x-iwork-pages-sffpages",
40    "application/vnd.palm",
41    "application/epub+zip",
42    "application/x-pocket-word",
43    "application/vnd.oasis.opendocument.spreadsheet-flat-xml",
44    "application/vnd.lotus-1-2-3",
45    "application/vnd.ms-excel",
46    "text/spreadsheet",
47    "application/vnd.sun.xml.calc",
48    "application/vnd.sun.xml.calc.template",
49    "application/x-gnumeric",
50    "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
51    "application/vnd.ms-excel.sheet.macroEnabled.12",
52    "application/vnd.openxmlformats-officedocument.spreadsheetml.template",
53    "application/clarisworks",
54    "application/x-iwork-numbers-sffnumbers",
55    "application/mathml+xml",
56    "application/vnd.sun.xml.math",
57    "application/vnd.oasis.opendocument.formula",
58    "application/vnd.sun.xml.base",
59    "image/jpeg",
60    "image/png",
61    "image/svg+xml",
62    "image/webp",
63    "application/docbook+xml",
64    "application/xhtml+xml",
65];
66
67/// Checks if the provided mime is included in the known convertable mime types
68pub fn is_known_libreoffice_pdf_convertable(mime: &mime::Mime) -> bool {
69    // We don't want to send images through the office converter
70    mime.type_() != mime::IMAGE &&
71    // Must be in the convertable formats list
72    LIBREOFFICE_CONVERTABLE_FORMATS.contains(&mime.essence_str())
73}