Commit 7ed69104 authored by Gabriel Monnerat's avatar Gabriel Monnerat

fix compatibility between cloudooo and ERP5. When a presentation document is...

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
parent 2edd78be
...@@ -93,6 +93,10 @@ class UnoConverter(object): ...@@ -93,6 +93,10 @@ class UnoConverter(object):
property_list.append(property) property_list.append(property)
property = ooolib.createProperty("FilterName", filter_name) property = ooolib.createProperty("FilterName", filter_name)
property_list.append(property) 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 return property_list
else: else:
return () return ()
...@@ -109,11 +113,13 @@ class UnoConverter(object): ...@@ -109,11 +113,13 @@ class UnoConverter(object):
self.document_type = module_manager.identify(uno_document) self.document_type = module_manager.identify(uno_document)
self.document_loaded = 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, output_url = mktemp(suffix='.%s' % destination_format,
dir=self.document_dir_path) dir=self.document_dir_path)
property_list = self._getPropertyToExport(destination_format)
property_list = self._getPropertyToExport(output_format)
try: try:
self.document_loaded.storeToURL(ooolib.systemPathToFileUrl(output_url), self.document_loaded.storeToURL(ooolib.systemPathToFileUrl(output_url),
tuple(property_list)) tuple(property_list))
......
...@@ -60,6 +60,19 @@ def createProperty(name, value): ...@@ -60,6 +60,19 @@ def createProperty(name, value):
property.Value = value property.Value = value
return property 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): def getServiceManager(host, port):
"""Get the ServiceManager from the running OpenOffice.org.""" """Get the ServiceManager from the running OpenOffice.org."""
setUpUnoEnvironment() setUpUnoEnvironment()
......
...@@ -32,6 +32,7 @@ from subprocess import Popen, PIPE ...@@ -32,6 +32,7 @@ from subprocess import Popen, PIPE
from xmlrpclib import ServerProxy, Fault from xmlrpclib import ServerProxy, Fault
from base64 import encodestring, decodestring from base64 import encodestring, decodestring
from cloudoooTestCase import cloudoooTestCase, make_suite from cloudoooTestCase import cloudoooTestCase, make_suite
from zipfile import ZipFile, is_zipfile
from types import DictType from types import DictType
class TestServer(cloudoooTestCase): class TestServer(cloudoooTestCase):
...@@ -421,6 +422,15 @@ at least v2.0 to extract\n' ...@@ -421,6 +422,15 @@ at least v2.0 to extract\n'
self.assertEquals(type(response_dict), DictType) self.assertEquals(type(response_dict), DictType)
self.assertNotEquals(response_dict['data'], '') self.assertNotEquals(response_dict['data'], '')
self.assertEquals(response_dict['mime'], 'text/html') 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): def testRunGenerateMethodConvertOdpToHTML(self):
"""Test run_generate method. This test is to validate a bug convertions to """Test run_generate method. This test is to validate a bug convertions to
......
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