Commit 72da57bf authored by Jérome Perrin's avatar Jérome Perrin

ooo: target libreoffice 7.5

( tested with 7.5.2.2 )
parent fbd8591e
...@@ -85,6 +85,7 @@ class MimeMapper: ...@@ -85,6 +85,7 @@ class MimeMapper:
alternative_extension_dict = { alternative_extension_dict = {
'Microsoft Excel 2007 XML':'ms.xlsx', 'Microsoft Excel 2007 XML':'ms.xlsx',
'Microsoft Excel 2007-2013 XML':'ms.xlsx', 'Microsoft Excel 2007-2013 XML':'ms.xlsx',
'Excel 2007–365':'ms.xlsx',
'Microsoft Excel 5.0':'5.xls', 'Microsoft Excel 5.0':'5.xls',
'Microsoft Excel 95':'95.xls', 'Microsoft Excel 95':'95.xls',
'Microsoft PowerPoint 2007 XML AutoPlay':'ms.ppsx', 'Microsoft PowerPoint 2007 XML AutoPlay':'ms.ppsx',
...@@ -93,8 +94,10 @@ class MimeMapper: ...@@ -93,8 +94,10 @@ class MimeMapper:
'Microsoft PowerPoint 2007-2013 XML':'ms.pptx', 'Microsoft PowerPoint 2007-2013 XML':'ms.pptx',
'Microsoft Word 2007 XML':'ms.docx', 'Microsoft Word 2007 XML':'ms.docx',
'Microsoft Word 2007-2013 XML':'ms.docx', 'Microsoft Word 2007-2013 XML':'ms.docx',
'Word 2007–365':'ms.docx',
'Microsoft Word 6.0':'6.doc', 'Microsoft Word 6.0':'6.doc',
'Microsoft Word 95':'95.doc', 'Microsoft Word 95':'95.doc',
'TIFF - Tagged Image File Format': 'tiff',
} }
uno_path = kw.get("uno_path", environ.get('uno_path')) uno_path = kw.get("uno_path", environ.get('uno_path'))
office_binary_path = kw.get("office_binary_path", office_binary_path = kw.get("office_binary_path",
...@@ -115,14 +118,15 @@ class MimeMapper: ...@@ -115,14 +118,15 @@ class MimeMapper:
filter_dict, type_dict = json.loads(stdout) filter_dict, type_dict = json.loads(stdout)
ooo_disable_filter_list = kw.get("ooo_disable_filter_list") or [] + [ ooo_disable_filter_list = kw.get("ooo_disable_filter_list") or [] + [
# 'writer_jpg_Export', # Seems not working from cloudooo in Libre Office 4.3.3.2 # https://bugs.documentfoundation.org/show_bug.cgi?id=117252
# 'writer_png_Export', # Seems not working from cloudooo in Libre Office 4.3.3.2 'writer_web_jpg_Export',
# 'draw_eps_Export', # Seems not working from cloudooo in Libre Office 5.0.0.5 'writer_web_png_Export',
# 'impress_eps_Export', # Seems not working from cloudooo in Libre Office 5.0.0.5 'writer_web_webp_Export',
] ]
ooo_disable_filter_name_list = kw.get("ooo_disable_filter_name_list") or [] + [ ooo_disable_filter_name_list = kw.get("ooo_disable_filter_name_list") or [] + [
'Text', # Use 'Text - Choose Encoding' instead 'Text', # Use 'Text - Choose Encoding' instead
'Text (StarWriter/Web)', # Use 'Text - Choose Encoding (Writer/Web)' instead 'Text (StarWriter/Web)', # Use 'Text - Choose Encoding (Writer/Web)' instead
'ODF Drawing (Impress)', # broken for presentation
] ]
for filter_name, value in filter_dict.items(): for filter_name, value in filter_dict.items():
if filter_name in ooo_disable_filter_list: if filter_name in ooo_disable_filter_list:
...@@ -130,6 +134,8 @@ class MimeMapper: ...@@ -130,6 +134,8 @@ class MimeMapper:
ui_name = value.get('UIName') ui_name = value.get('UIName')
filter_type = value.get('Type') filter_type = value.get('Type')
filter_type_dict = type_dict.get(filter_type) filter_type_dict = type_dict.get(filter_type)
if not filter_type_dict:
continue
if not ui_name: if not ui_name:
ui_name = filter_type_dict.get("UIName") ui_name = filter_type_dict.get("UIName")
if ui_name in ooo_disable_filter_name_list or 'Template' in ui_name: if ui_name in ooo_disable_filter_name_list or 'Template' in ui_name:
......
...@@ -72,4 +72,9 @@ class TestAllFormatsERP5Compatibility(TestCase): ...@@ -72,4 +72,9 @@ class TestAllFormatsERP5Compatibility(TestCase):
data_output = data_output['data'] data_output = data_output['data']
file_type = self._getFileType(data_output) file_type = self._getFileType(data_output)
self.assertNotIn(": empty", file_type) self.assertNotIn(": empty", file_type)
if source_format != extension:
# when no filter exist for destination format, the document is not converted
# but silently returned in source format, the assertion below should detect
# this.
self.assertNotEqual(source_mimetype, file_type)
...@@ -49,9 +49,14 @@ class TestAllowedExtensions(TestCase): ...@@ -49,9 +49,14 @@ class TestAllowedExtensions(TestCase):
ui_name. The request is by document type as text""" ui_name. The request is by document type as text"""
text_request = {'document_type': "text"} text_request = {'document_type': "text"}
text_allowed_list = self.proxy.getAllowedExtensionList(text_request) text_allowed_list = self.proxy.getAllowedExtensionList(text_request)
# XXX slightly different allowed formats with document_type !?
_text_expected_tuple = text_expected_tuple + (
('docm', 'Word 2007–365 VBA'),
('webp', 'WEBP - WebP Image'),
)
self.assertEqual( self.assertEqual(
sorted([tuple(x) for x in text_allowed_list]), sorted([tuple(x) for x in text_allowed_list]),
sorted(text_expected_tuple)) sorted(_text_expected_tuple))
def testGetAllowedPresentationExtensionListByType(self): def testGetAllowedPresentationExtensionListByType(self):
"""Verify if getAllowedExtensionList returns is a list with extension and """Verify if getAllowedExtensionList returns is a list with extension and
...@@ -59,14 +64,17 @@ class TestAllowedExtensions(TestCase): ...@@ -59,14 +64,17 @@ class TestAllowedExtensions(TestCase):
request_dict = {'document_type': "presentation"} request_dict = {'document_type': "presentation"}
presentation_allowed_list = self.proxy.getAllowedExtensionList(request_dict) presentation_allowed_list = self.proxy.getAllowedExtensionList(request_dict)
self.assertTrue(presentation_allowed_list) self.assertTrue(presentation_allowed_list)
for arg in presentation_allowed_list: self.assertEqual(
self.assertIn(tuple(arg), presentation_expected_tuple) sorted([tuple(x) for x in presentation_allowed_list]),
sorted(presentation_expected_tuple))
def testGetAllowedExtensionListByExtension(self): def testGetAllowedExtensionListByExtension(self):
"""Verify if getAllowedExtensionList returns is a list with extension and """Verify if getAllowedExtensionList returns is a list with extension and
ui_name. The request is by extension""" ui_name. The request is by extension"""
doc_allowed_list = self.proxy.getAllowedExtensionList({'extension': "doc"}) doc_allowed_list = self.proxy.getAllowedExtensionList({'extension': "doc"})
self.assertEqual(sorted([tuple(x) for x in doc_allowed_list]), sorted(text_expected_tuple)) self.assertEqual(
sorted([tuple(x) for x in doc_allowed_list]),
sorted(text_expected_tuple))
def testGetAllowedExtensionListByMimetype(self): def testGetAllowedExtensionListByMimetype(self):
"""Verify if getAllowedExtensionList returns is a list with extension and """Verify if getAllowedExtensionList returns is a list with extension and
......
...@@ -99,7 +99,7 @@ class TestUnoMimeMapper(HandlerTestCase): ...@@ -99,7 +99,7 @@ class TestUnoMimeMapper(HandlerTestCase):
def testWithoutOpenOffice(self): def testWithoutOpenOffice(self):
"""Test when the openoffice is stopped""" """Test when the openoffice is stopped"""
error_msg = "couldn\'t connect to socket (Success)\n" error_msg = "couldn\'t connect to socket"
hostname, host = openoffice.getAddress() hostname, host = openoffice.getAddress()
openoffice.stop() openoffice.stop()
python = path.join(self.office_binary_path, "python") python = path.join(self.office_binary_path, "python")
......
...@@ -80,9 +80,11 @@ def BBB_guess_extension(mimetype, title=None): ...@@ -80,9 +80,11 @@ def BBB_guess_extension(mimetype, title=None):
"Flat XML ODF Text Document": ".fodt", "Flat XML ODF Text Document": ".fodt",
"MET - OS/2 Metafile": ".met", "MET - OS/2 Metafile": ".met",
"Microsoft Excel 2007-2013 XML": ".ms.xlsx", "Microsoft Excel 2007-2013 XML": ".ms.xlsx",
"Excel 2007–365": ".ms.xlsx",
"Microsoft PowerPoint 2007-2013 XML": ".ms.pptx", "Microsoft PowerPoint 2007-2013 XML": ".ms.pptx",
"Microsoft PowerPoint 2007-2013 XML AutoPlay": ".ms.ppsx", "Microsoft PowerPoint 2007-2013 XML AutoPlay": ".ms.ppsx",
"Microsoft Word 2007-2013 XML": ".ms.docx", "Microsoft Word 2007-2013 XML": ".ms.docx",
"Word 2007–365": ".ms.docx",
}.get(title, None) or { }.get(title, None) or {
# mediatype : extension # mediatype : extension
"application/msword": ".doc", "application/msword": ".doc",
......
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