Commit 00ad3250 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

try to provide appropriate filter list by both source_format and...

try to provide appropriate filter list by both source_format and destination_format, and always choose the right by by document_type computed by soffice itself.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk/utils@42580 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 000284fc
...@@ -132,18 +132,22 @@ class OOHandler: ...@@ -132,18 +132,22 @@ class OOHandler:
return stdout, stderr return stdout, stderr
def _serializeMimemapper(self, extension=None): def _serializeMimemapper(self, source_extension=None, destination_extension=None):
"""Serialize parts of mimemapper""" """Serialize parts of mimemapper"""
if extension is None: if destination_extension is None:
return json.dumps(dict(mimetype_by_filter_type=mimemapper._mimetype_by_filter_type)) return json.dumps(dict(mimetype_by_filter_type=mimemapper._mimetype_by_filter_type))
filter_list = [] filter_list = []
for service_type in mimemapper._doc_type_list_by_extension[extension]: service_type_list = mimemapper._doc_type_list_by_extension.get(
source_extension, mimemapper.extension_list_by_doc_type.keys())
for service_type in service_type_list:
for extension in mimemapper.extension_list_by_doc_type[service_type]: for extension in mimemapper.extension_list_by_doc_type[service_type]:
if extension == destination_extension:
filter_list.append((extension, filter_list.append((extension,
service_type, service_type,
mimemapper.getFilterName(extension, mimemapper.getFilterName(extension,
service_type))) service_type)))
logger.debug("Filter List: %r" % filter_list)
return json.dumps(dict(doc_type_list_by_extension=mimemapper._doc_type_list_by_extension, return json.dumps(dict(doc_type_list_by_extension=mimemapper._doc_type_list_by_extension,
filter_list=filter_list, filter_list=filter_list,
mimetype_by_filter_type=mimemapper._mimetype_by_filter_type)) mimetype_by_filter_type=mimemapper._mimetype_by_filter_type))
...@@ -158,7 +162,8 @@ class OOHandler: ...@@ -158,7 +162,8 @@ class OOHandler:
kw['source_format'] = self.source_format kw['source_format'] = self.source_format
if destination_format: if destination_format:
kw['destination_format'] = destination_format kw['destination_format'] = destination_format
kw['mimemapper'] = self._serializeMimemapper(self.source_format) kw['mimemapper'] = self._serializeMimemapper(self.source_format,
destination_format)
kw['refresh'] = json.dumps(self.refresh) kw['refresh'] = json.dumps(self.refresh)
try: try:
stdout, stderr = self._callUnoConverter(*['convert'], **kw) stdout, stderr = self._callUnoConverter(*['convert'], **kw)
......
...@@ -136,15 +136,9 @@ class UnoConverter(object): ...@@ -136,15 +136,9 @@ class UnoConverter(object):
return [property,] return [property,]
def _getFilterName(self, destination_format, type): def _getFilterName(self, destination_format, type):
document_type_list = mimemapper["doc_type_list_by_extension"].get(destination_format)
if type in document_type_list:
for filter_tuple in mimemapper["filter_list"]: for filter_tuple in mimemapper["filter_list"]:
if destination_format == filter_tuple[0] and filter_tuple[1] == type: if destination_format == filter_tuple[0] and filter_tuple[1] == type:
return filter_tuple[2] return filter_tuple[2]
else:
for filter_tuple in mimemapper["filter_list"]:
if destination_format == filter_tuple[0]:
return filter_tuple[2]
def _getPropertyToExport(self, destination_format=None): def _getPropertyToExport(self, destination_format=None):
"""Create the property according to the extension of the file.""" """Create the property according to the extension of the file."""
......
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