Commit b472db7e authored by Boris Kocherov's avatar Boris Kocherov Committed by Romain Courteaud

x2t: getAllowedConversionFormatList return OnlyOffice types too

parent 405454a8
......@@ -205,16 +205,33 @@ class Handler(object):
]
"""
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/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")]
return [
("application/vnd.openxmlformats-officedocument.wordprocessingml.document", "Word 2007 Document"),
("application/vnd.oasis.opendocument.text", "ODF Text Document"),
]
if source_mimetype in ("xlsy", "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")]
return [
("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "Excel 2007 Spreadsheet"),
("application/vnd.oasis.opendocument.spreadsheet", "ODF Spreadsheet Document"),
]
if source_mimetype in ("ppty", "application/x-asc-presentation"):
return [("application/vnd.openxmlformats-officedocument.presentationml.presentation", "PowerPoint 2007 Presentation")]
return []
return [
("application/vnd.openxmlformats-officedocument.presentationml.presentation", "PowerPoint 2007 Presentation"),
("application/vnd.oasis.opendocument.presentation", "ODF Presentation Document"),
]
get_format_list = OOoHandler.getAllowedConversionFormatList
format_list = get_format_list(source_mimetype)
format_list_append = format_list.append
for f_type, _ in format_list:
if f_type == "application/vnd.openxmlformats-officedocument.wordprocessingml.document":
format_list_append(("application/x-asc-text", "OnlyOffice Text Document"))
break
if f_type == "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":
format_list_append(("application/x-asc-spreadsheet", "OnlyOffice Spreadsheet"))
break
if f_type == "application/vnd.openxmlformats-officedocument.presentationml.presentation":
format_list_append(("application/x-asc-presentation", "OnlyOffice Presentation"))
break
return format_list
......@@ -104,17 +104,14 @@ class TestHandler(HandlerTestCase):
"""
get = Handler.getAllowedConversionFormatList
self.assertEquals(get("application/x-asc-text;ignored=param"),
[("application/vnd.openxmlformats-officedocument.wordprocessingml.document", "Word 2007 Document")])
[("application/vnd.openxmlformats-officedocument.wordprocessingml.document", "Word 2007 Document"),
('application/vnd.oasis.opendocument.text', 'ODF Text Document')])
self.assertEquals(get("application/x-asc-spreadsheet;ignored=param"),
[("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "Excel 2007 Spreadsheet")])
[("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "Excel 2007 Spreadsheet"),
('application/vnd.oasis.opendocument.spreadsheet', 'ODF Spreadsheet Document')])
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")])
self.assertEquals(get("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;ignored=param"),
[("application/x-asc-spreadsheet", "OnlyOffice Spreadsheet")])
self.assertEquals(get("application/vnd.openxmlformats-officedocument.presentationml.presentation;ignored=param"),
[("application/x-asc-presentation", "OnlyOffice Presentation")])
[("application/vnd.openxmlformats-officedocument.presentationml.presentation", "PowerPoint 2007 Presentation"),
('application/vnd.oasis.opendocument.presentation', 'ODF Presentation Document')])
def test_suite():
return make_suite(TestHandler)
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