From 7ed691047735c0a2e7ffe937c0086f4300cd285e Mon Sep 17 00:00:00 2001 From: Gabriel Monnerat <gabriel@tiolive.com> Date: Wed, 4 Aug 2010 13:21:15 +0000 Subject: [PATCH] fix compatibility between cloudooo and ERP5. When a presentation document is converted to html, ERP5 expects the main document in the format 'impr.html. And, add a test to validate it. git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk/utils@37475 20353a03-c40f-0410-a6d1-a30d3c3de9de --- cloudooo/bin/unoconverter.py | 12 +++++++++--- cloudooo/ooolib.py | 13 +++++++++++++ cloudooo/tests/testServer.py | 10 ++++++++++ 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/cloudooo/bin/unoconverter.py b/cloudooo/bin/unoconverter.py index 816e6a1..f92734a 100755 --- a/cloudooo/bin/unoconverter.py +++ b/cloudooo/bin/unoconverter.py @@ -93,6 +93,10 @@ class UnoConverter(object): property_list.append(property) property = ooolib.createProperty("FilterName", filter_name) property_list.append(property) + if destination_format == "html": + # XXX - condition to obtain a property that returns all images in png + # format + property_list.append(ooolib.createHTMLProperty()) return property_list else: return () @@ -109,11 +113,13 @@ class UnoConverter(object): self.document_type = module_manager.identify(uno_document) self.document_loaded = uno_document - def convert(self, destination_format=None): - """ """ + def convert(self, output_format=None): + """it converts a document to specific format""" + destination_format = "impr.html" if output_format == "html" else output_format output_url = mktemp(suffix='.%s' % destination_format, dir=self.document_dir_path) - property_list = self._getPropertyToExport(destination_format) + + property_list = self._getPropertyToExport(output_format) try: self.document_loaded.storeToURL(ooolib.systemPathToFileUrl(output_url), tuple(property_list)) diff --git a/cloudooo/ooolib.py b/cloudooo/ooolib.py index ee7c8c2..deb7ae6 100644 --- a/cloudooo/ooolib.py +++ b/cloudooo/ooolib.py @@ -60,6 +60,19 @@ def createProperty(name, value): property.Value = value return property +# XXX - method duplicated +def createHTMLProperty(): + """Returns a property to create all images in png format""" + setUpUnoEnvironment() + import uno + from com.sun.star.beans import PropertyValue + + property = PropertyValue('FilterData', 0, + uno.Any('[]com.sun.star.beans.PropertyValue', + (PropertyValue('IsExportNotes', 0, True, 0), + PropertyValue('Format', 0, 2, 0),),), 0) # PNG format + return property + def getServiceManager(host, port): """Get the ServiceManager from the running OpenOffice.org.""" setUpUnoEnvironment() diff --git a/cloudooo/tests/testServer.py b/cloudooo/tests/testServer.py index 670f556..89753ba 100644 --- a/cloudooo/tests/testServer.py +++ b/cloudooo/tests/testServer.py @@ -32,6 +32,7 @@ from subprocess import Popen, PIPE from xmlrpclib import ServerProxy, Fault from base64 import encodestring, decodestring from cloudoooTestCase import cloudoooTestCase, make_suite +from zipfile import ZipFile, is_zipfile from types import DictType class TestServer(cloudoooTestCase): @@ -421,6 +422,15 @@ at least v2.0 to extract\n' self.assertEquals(type(response_dict), DictType) self.assertNotEquals(response_dict['data'], '') self.assertEquals(response_dict['mime'], 'text/html') + output_url = "./output/zip.zip" + open(output_url, 'w').write(decodestring(response_dict['data'])) + self.assertTrue(is_zipfile(output_url)) + filename_list = [file.filename for file in ZipFile(output_url).filelist] + for filename in filename_list: + if filename.endswith("impr.html"): + break + else: + self.fail("Not exists one file with 'impr.html' format") def testRunGenerateMethodConvertOdpToHTML(self): """Test run_generate method. This test is to validate a bug convertions to -- 2.30.9