Commit 5ef3cd6e authored by Tristan Cavelier's avatar Tristan Cavelier

Handle application/x-asc-*+zip mimetypes

parent d9878156
......@@ -202,21 +202,21 @@ class Handler(object):
"""Returns a list content_type and their titles which are supported
by enabled handlers.
[('application/x-asc-text', 'OnlyOffice Text Document'),
[('application/x-asc-text+zip', 'OnlyOffice Text Document'),
...
]
"""
source_mimetype = parseContentType(source_mimetype).gettype()
if source_mimetype in ("docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document"):
return [("application/x-asc-text", "OnlyOffice Text Document")]
if source_mimetype in ("docy", "application/x-asc-text"):
return [("application/x-asc-text+zip", "OnlyOffice Text Document")]
if source_mimetype in ("docy", "application/x-asc-text+zip", "application/x-asc-text"):
return [("application/vnd.openxmlformats-officedocument.wordprocessingml.document", "Word 2007 Document")]
if source_mimetype in ("xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"):
return [("application/x-asc-spreadsheet", "OnlyOffice Spreadsheet")]
if source_mimetype in ("xlsy", "application/x-asc-spreadsheet"):
return [("application/x-asc-spreadsheet+zip", "OnlyOffice Spreadsheet")]
if source_mimetype in ("xlsy", "application/x-asc-spreadsheet+zip", "application/x-asc-spreadsheet"):
return [("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "Excel 2007 Spreadsheet")]
if source_mimetype in ("pptx", "application/vnd.openxmlformats-officedocument.presentationml.presentation"):
return [("application/x-asc-presentation", "OnlyOffice Presentation")]
if source_mimetype in ("ppty", "application/x-asc-presentation"):
return [("application/x-asc-presentation+zip", "OnlyOffice Presentation")]
if source_mimetype in ("ppty", "application/x-asc-presentation+zip", "application/x-asc-presentation"):
return [("application/vnd.openxmlformats-officedocument.presentationml.presentation", "PowerPoint 2007 Presentation")]
return []
......@@ -103,6 +103,12 @@ class TestHandler(HandlerTestCase):
None of the types below define any mimetype parameter to not ignore so far.
"""
get = Handler.getAllowedConversionFormatList
self.assertEquals(get("application/x-asc-text+zip;ignored=param"),
[("application/vnd.openxmlformats-officedocument.wordprocessingml.document", "Word 2007 Document")])
self.assertEquals(get("application/x-asc-spreadsheet+zip;ignored=param"),
[("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "Excel 2007 Spreadsheet")])
self.assertEquals(get("application/x-asc-presentation+zip;ignored=param"),
[("application/vnd.openxmlformats-officedocument.presentationml.presentation", "PowerPoint 2007 Presentation")])
self.assertEquals(get("application/x-asc-text;ignored=param"),
[("application/vnd.openxmlformats-officedocument.wordprocessingml.document", "Word 2007 Document")])
self.assertEquals(get("application/x-asc-spreadsheet;ignored=param"),
......@@ -110,11 +116,11 @@ class TestHandler(HandlerTestCase):
self.assertEquals(get("application/x-asc-presentation;ignored=param"),
[("application/vnd.openxmlformats-officedocument.presentationml.presentation", "PowerPoint 2007 Presentation")])
self.assertEquals(get("application/vnd.openxmlformats-officedocument.wordprocessingml.document;ignored=param"),
[("application/x-asc-text", "OnlyOffice Text Document")])
[("application/x-asc-text+zip", "OnlyOffice Text Document")])
self.assertEquals(get("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;ignored=param"),
[("application/x-asc-spreadsheet", "OnlyOffice Spreadsheet")])
[("application/x-asc-spreadsheet+zip", "OnlyOffice Spreadsheet")])
self.assertEquals(get("application/vnd.openxmlformats-officedocument.presentationml.presentation;ignored=param"),
[("application/x-asc-presentation", "OnlyOffice Presentation")])
[("application/x-asc-presentation+zip", "OnlyOffice Presentation")])
def test_suite():
return make_suite(TestHandler)
......@@ -65,9 +65,9 @@ def BBB_guess_type(url):
split = base.split(".")
ext = '' if len(split) == 1 else split[-1]
return {
"docy": ("application/x-asc-text", None),
"xlsy": ("application/x-asc-spreadsheet", None),
"ppty": ("application/x-asc-presentation", None),
"docy": ("application/x-asc-text+zip", None),
"xlsy": ("application/x-asc-spreadsheet+zip", None),
"ppty": ("application/x-asc-presentation+zip", None),
}.get(ext, None) or guess_type(url)
def BBB_guess_extension(mimetype, title=None):
......
......@@ -56,7 +56,7 @@ application/vnd.oasis.opendocument.database
application/vnd.oasis.opendocument.image odi
application/vnd.ms-word.document.macroEnabled.12 docm
application/vnd.openxmlformats-officedocument.wordprocessingml.document docx
application/x-asc-text docy
application/x-asc-text+zip docy
application/vnd.openxmlformats-officedocument.wordprocessingml.template dotx
application/vnd.ms-powerpoint.template.macroEnabled.12 potm
application/vnd.openxmlformats-officedocument.presentationml.template potx
......@@ -65,12 +65,12 @@ application/vnd.ms-powerpoint.slideshow.macroEnabled.12
application/vnd.openxmlformats-officedocument.presentationml.slideshow ppsx
application/vnd.ms-powerpoint.presentation.macroEnabled.12 pptm
application/vnd.openxmlformats-officedocument.presentationml.presentation pptx
application/x-asc-presentation ppty
application/x-asc-presentation+zip ppty
application/vnd.ms-excel.addin.macroEnabled.12 xlam
application/vnd.ms-excel.sheet.binary.macroEnabled.12 xlsb
application/vnd.ms-excel.sheet.macroEnabled.12 xlsm
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet xlsx
application/x-asc-spreadsheet xlsy
application/x-asc-spreadsheet+zip xlsy
application/vnd.ms-excel.template.macroEnabled.12 xltm
application/vnd.openxmlformats-officedocument.spreadsheetml.template xltx
application/x-msmetafile wmf
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment