Commit fc6e4976 authored by Boris Kocherov's avatar Boris Kocherov

add yformat handler.

support converting docy<-->docx , xlsy<-->xlsx, ppty<-->pptx .
The binary files which are needed for conversion are absent in
repository.
Binaries will be downloaded by slapos from
lab.nexedi.com/bk/DocumentServer.
parent f05f03ae
...@@ -42,6 +42,11 @@ from cloudooo.handler.ooo.monitor import monitor_sleeping_time ...@@ -42,6 +42,11 @@ from cloudooo.handler.ooo.monitor import monitor_sleeping_time
from cloudooo.util import logger from cloudooo.util import logger
from psutil import pid_exists from psutil import pid_exists
try:
from cloudooo.handler.yformat.handler import Handler as YformatHandler
from cloudooo.handler.yformat.handler import yformat_map
except ImportError:
yformat_map = None
class Handler(object): class Handler(object):
"""OOO Handler is used to access the one Document and OpenOffice. """OOO Handler is used to access the one Document and OpenOffice.
...@@ -53,6 +58,13 @@ class Handler(object): ...@@ -53,6 +58,13 @@ class Handler(object):
def __init__(self, base_folder_url, data, source_format, **kw): def __init__(self, base_folder_url, data, source_format, **kw):
"""Creates document in file system and loads it in OOo.""" """Creates document in file system and loads it in OOo."""
if yformat_map:
if source_format in yformat_map:
logger.debug("OooConvert: xlsy > xlsx")
yformat = YformatHandler(base_folder_url, data, source_format, **kw)
destination_format = yformat_map[source_format]
data = yformat.convert(destination_format=destination_format)
source_format = destination_format
self.document = FileSystemDocument(base_folder_url, self.document = FileSystemDocument(base_folder_url,
data, data,
source_format) source_format)
...@@ -154,6 +166,11 @@ class Handler(object): ...@@ -154,6 +166,11 @@ class Handler(object):
Keyword Arguments: Keyword Arguments:
destination_format -- extension of document as String destination_format -- extension of document as String
""" """
yformat = False
if yformat_map:
if destination_format in yformat_map:
yformat = destination_format
destination_format = yformat_map[destination_format]
logger.debug("OooConvert: %s > %s" % (self.source_format, destination_format)) logger.debug("OooConvert: %s > %s" % (self.source_format, destination_format))
kw['source_format'] = self.source_format kw['source_format'] = self.source_format
if destination_format: if destination_format:
...@@ -170,6 +187,14 @@ class Handler(object): ...@@ -170,6 +187,14 @@ class Handler(object):
self.document.reload(url) self.document.reload(url)
content = self.document.getContent(self.zip) content = self.document.getContent(self.zip)
self.document.trash() self.document.trash()
if yformat:
logger.debug("OooConvert: xlsx > xlsy")
source_format = destination_format
kw['destination_format'] = yformat
yformat = YformatHandler(self.document.base_folder_url,
content, source_format)
content = yformat.convert(**kw)
return content return content
def getMetadata(self, base_document=False): def getMetadata(self, base_document=False):
......
...@@ -37,6 +37,11 @@ from cloudooo.interfaces.mimemapper import IMimemapper ...@@ -37,6 +37,11 @@ from cloudooo.interfaces.mimemapper import IMimemapper
from types import InstanceType from types import InstanceType
import json import json
try:
from cloudooo.handler.yformat.handler import yformat_service_map
except ImportError:
yformat_service_map = {}
class MimeMapper(object): class MimeMapper(object):
"""Load all filters from OOo. You can get the filter you want or all """Load all filters from OOo. You can get the filter you want or all
...@@ -226,6 +231,9 @@ class MimeMapper(object): ...@@ -226,6 +231,9 @@ class MimeMapper(object):
'pdf': ['com.sun.star.drawing.DrawingDocument'], 'pdf': ['com.sun.star.drawing.DrawingDocument'],
'xls': ['com.sun.star.sheet.SpreadsheetDocument'], 'xls': ['com.sun.star.sheet.SpreadsheetDocument'],
}) })
self._doc_type_list_by_extension.update((ext, [service, ]) for ext, service in yformat_service_map.iteritems())
for ext, service in yformat_service_map.iteritems():
self._extension_list_by_type[service].append((ext, ext.capitalize()))
self.document_service_list = self._extension_list_by_type.keys() self.document_service_list = self._extension_list_by_type.keys()
self._loaded = True self._loaded = True
......
...@@ -42,6 +42,7 @@ text_expected_tuple = ( ...@@ -42,6 +42,7 @@ text_expected_tuple = (
# ('png', 'PNG - Portable Network Graphic'), # ('png', 'PNG - Portable Network Graphic'),
('rtf', 'Rich Text'), ('rtf', 'Rich Text'),
('txt', 'Text - Choose Encoding'), ('txt', 'Text - Choose Encoding'),
('docy', 'Docy'),
) )
global_expected_tuple = ( global_expected_tuple = (
...@@ -109,6 +110,7 @@ presentation_expected_tuple = ( ...@@ -109,6 +110,7 @@ presentation_expected_tuple = (
('tif', 'TIFF - Tagged Image File Format'), ('tif', 'TIFF - Tagged Image File Format'),
('wmf', 'WMF - Windows Metafile'), ('wmf', 'WMF - Windows Metafile'),
('xpm', 'XPM - X PixMap'), ('xpm', 'XPM - X PixMap'),
('ppty', 'Ppty'),
) )
spreadsheet_expected_tuple = ( spreadsheet_expected_tuple = (
...@@ -121,6 +123,7 @@ spreadsheet_expected_tuple = ( ...@@ -121,6 +123,7 @@ spreadsheet_expected_tuple = (
('xls', 'Microsoft Excel 97-2003'), ('xls', 'Microsoft Excel 97-2003'),
('ms.xlsx', 'Microsoft Excel 2007-2013 XML'), ('ms.xlsx', 'Microsoft Excel 2007-2013 XML'),
('xlsx', 'Office Open XML Spreadsheet'), ('xlsx', 'Office Open XML Spreadsheet'),
('xlsy', 'Xlsy'),
) )
math_expected_tuple = ( math_expected_tuple = (
......
##############################################################################
#
# Copyright (c) 2009-2011 Nexedi SA and Contributors. All Rights Reserved.
# Gabriel M. Monnerat <gabriel@tiolive.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# guarantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from xml.etree import ElementTree
from os.path import join, dirname, realpath
from subprocess import Popen, PIPE
from tempfile import NamedTemporaryFile
import sys
from zope.interface import implements
from cloudooo.interfaces.handler import IHandler
from cloudooo.file import File
from cloudooo.util import logger
AVS_OFFICESTUDIO_FILE_UNKNOWN = "0"
AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCX = "65"
AVS_OFFICESTUDIO_FILE_PRESENTATION_PPTX = "129"
AVS_OFFICESTUDIO_FILE_PRESENTATION_PPSX = "132"
AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSX = "257"
AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_PDF = "513"
AVS_OFFICESTUDIO_FILE_TEAMLAB_DOCY = "4097"
AVS_OFFICESTUDIO_FILE_TEAMLAB_XLSY = "4098"
AVS_OFFICESTUDIO_FILE_TEAMLAB_PPTY = "4099"
AVS_OFFICESTUDIO_FILE_CANVAS_WORD = "8193"
AVS_OFFICESTUDIO_FILE_CANVAS_SPREADSHEET = "8194"
AVS_OFFICESTUDIO_FILE_CANVAS_PRESENTATION = "8195"
AVS_OFFICESTUDIO_FILE_OTHER_HTMLZIP = "2051"
AVS_OFFICESTUDIO_FILE_OTHER_ZIP = "2057"
Ext2Formats = {
"docy": AVS_OFFICESTUDIO_FILE_CANVAS_WORD,
"docx": AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCX,
"xlsy": AVS_OFFICESTUDIO_FILE_CANVAS_SPREADSHEET,
"xlsx": AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSX,
"ppty": AVS_OFFICESTUDIO_FILE_CANVAS_PRESENTATION,
"pptx": AVS_OFFICESTUDIO_FILE_PRESENTATION_PPTX,
}
dir_name = dirname(realpath(sys.argv[0]))
#dir_name = join(dirname(realpath(__file__)), 'bin')
converter_bin = join(dir_name, 'x2t')
converter_lib_dirname = join(dir_name, 'lib')
yformat_map = {
'docy': 'docx',
'xlsy': 'xlsx',
'ppty': 'pptx',
}
yformat_service_map = {
'docy': 'com.sun.star.text.TextDocument',
'xlsy': 'com.sun.star.sheet.SpreadsheetDocument',
'ppty': 'com.sun.star.presentation.PresentationDocument',
}
class Handler(object):
"""ImageMagic Handler is used to handler images."""
implements(IHandler)
def __init__(self, base_folder_url, data, source_format, **kw):
"""
base_folder_url(string)
The requested url for data base folder
data(string)
The opened and readed file into a string
source_format(string)
The source format of the inputed file"""
self.base_folder_url = base_folder_url
self.file = File(base_folder_url, data, source_format)
self.environment = kw.get("env", {})
self.environment['LD_LIBRARY_PATH'] = converter_lib_dirname
def convert(self, destination_format=None, **kw):
""" Convert the inputed file to output as format that were informed """
logger.debug("yformat convert x2t: %s > %s" % (self.file.source_format, destination_format))
in_format = Ext2Formats.get(self.file.source_format)
out_format = Ext2Formats.get(destination_format)
with NamedTemporaryFile(suffix='.%s' % destination_format, dir=self.base_folder_url) as output_file:
config = {
# 'm_sKey': 'from',
'm_sFileFrom': self.file.getUrl(),
'm_nFormatFrom': in_format,
'm_sFileTo': output_file.name,
'm_nFormatTo': out_format,
# 'm_bPaid': 'true',
# 'm_bEmbeddedFonts': 'false',
# 'm_bFromChanges': 'false',
# 'm_sFontDir': '/usr/share/fonts',
# 'm_sThemeDir': '/var/www/onlyoffice/documentserver/FileConverterService/presentationthemes',
}
with NamedTemporaryFile(suffix=".xml", dir=self.base_folder_url) as temp_xml:
root = ElementTree.Element('root')
for key, value in config.items():
ElementTree.SubElement(root, key).text = value
ElementTree.ElementTree(root).write(temp_xml, encoding='utf-8', xml_declaration=True, default_namespace=None,
method="xml")
temp_xml.flush()
p = Popen([converter_bin, temp_xml.name],
env=self.environment,
stdout=PIPE,
stderr=PIPE,
)
# stdout, stderr = p.communicate()
ret = p.wait()
# logger.debug(stdout)
# logger.debug(stderr)
logger.debug("yformat convert x2t return:{}".format(ret))
self.file.trash()
return open(output_file.name).read()
def getMetadata(self, base_document=False):
"""Returns a dictionary with all metadata of document.
along with the metadata.
"""
raise NotImplementedError
def setMetadata(self, metadata={}):
"""Returns image with new metadata.
Keyword arguments:
metadata -- expected an dictionary with metadata.
"""
raise NotImplementedError
XLSY;v2;5883;BAKAAgAAA+cHAAAEAwgAAAD3FgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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AAAACBQAAAAIAAAAAAxgAAAD6+wAFAAAAAgAAAAACBwAAAPoAAAAAAPsEAAAAAAkGAAAAAAEAAAABCUoAAAAARQAAAPr7AQAAAAACFwAAAAMSAAAAAA0AAAABCAAAAPoA/wH/Av/7AxgAAAD6+wAFAAAAAgAAAAACBwAAAPoAAAAAAPsEAAAAAAsAAAAAGAYAAAACAQAAAAAAAAAA
\ No newline at end of file
##############################################################################
#
# Copyright (c) 2009-2010 Nexedi SA and Contributors. All Rights Reserved.
# Gabriel M. Monnerat <gabriel@tiolive.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# guarantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import magic
from cloudooo.handler.yformat.handler import Handler
from cloudooo.handler.ooo.handler import Handler as OOOHandler
from cloudooo.tests.handlerTestCase import HandlerTestCase, make_suite
OPENOFFICE = True
class TestHandler(HandlerTestCase):
def afterSetUp(self):
self.kw = dict(env=dict(PATH=self.env_path))
def testConvertXLSXtoXLSYandBack(self):
"""Test conversion of xlsx to xlsy and back"""
xlsx_orig_file = open("data/test.xlsx").read()
xlsy_file = Handler(self.tmp_url, xlsx_orig_file, "xlsx", **self.kw).convert("xlsy")
xlsx_file = Handler(self.tmp_url, xlsy_file, "xlsy", **self.kw).convert("xlsx")
# magic not correctly determinate mime for xlsx files. i used ods, because it simple.
ods_file = OOOHandler(self.tmp_url, xlsx_file, "xlsx", **self.kw).convert("ods")
mime = magic.Magic(mime=True)
ods_mimetype = mime.from_buffer(ods_file)
self.assertEquals("application/vnd.oasis.opendocument.spreadsheet", ods_mimetype)
def testgetMetadataFromImage(self):
"""Test getMetadata not implemented form yformats"""
handler = Handler(self.tmp_url, "", "xlsy", **self.kw)
self.assertRaises(NotImplementedError, handler.getMetadata)
def testsetMetadata(self):
"""Test setMetadata not implemented for yformats"""
handler = Handler(self.tmp_url, "", "xlsy", **self.kw)
self.assertRaises(NotImplementedError, handler.setMetadata)
def test_suite():
return make_suite(TestHandler)
...@@ -83,6 +83,9 @@ application/x-openoffice-gdimetafile ...@@ -83,6 +83,9 @@ application/x-openoffice-gdimetafile
application/emf emf application/emf emf
application/x-emf emf application/x-emf emf
application/octet-stream met application/octet-stream met
application/yformat.docy docy
application/yformat.xlsy xlsy
application/yformat.ppty ppty
# #
# Image # Image
# #
......
...@@ -47,6 +47,8 @@ openoffice_port = 4062 ...@@ -47,6 +47,8 @@ openoffice_port = 4062
# Priority matters, first match take precedence on next lines. # Priority matters, first match take precedence on next lines.
mimetype_registry = mimetype_registry =
application/pdf * pdf application/pdf * pdf
application/vnd.openxmlformats-officedocument.* application/yformat.* yformat
application/yformat.* application/vnd.openxmlformats-officedocument.* yformat
application/vnd.oasis.opendocument* * ooo application/vnd.oasis.opendocument* * ooo
application/vnd.sun.xml* * ooo application/vnd.sun.xml* * ooo
text/* * ooo text/* * ooo
......
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