Commit 95f26cb8 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

ooo: deprecate refresh parameter, as the variable replacement always happens...

ooo: deprecate refresh parameter, as the variable replacement always happens with LibreOffice >= 7.6.
parent 26a0394f
......@@ -61,7 +61,6 @@ class Handler:
self.uno_path = kw.get("uno_path", None)
self.office_binary_path = kw.get("office_binary_path", None)
self.timeout = kw.get("timeout", 600)
self.refresh = kw.get('refresh', False)
self.source_format = source_format
if not self.uno_path:
self.uno_path = environ.get("uno_path")
......@@ -183,7 +182,6 @@ class Handler:
kw['destination_format'] = destination_format
kw['mimemapper'] = self._serializeMimemapper(self.source_format,
destination_format)
kw['refresh'] = json.dumps(self.refresh)
openoffice.acquire()
try:
stdout, _ = self._callUnoConverter(*['convert'], **kw)
......
......@@ -186,10 +186,8 @@ class UnoDocument:
return args
def _load(self, infilter, refresh):
def _load(self, infilter):
"""Create one document with basic properties
refresh argument tells to uno environment to
replace dynamic properties of document before conversion
"""
createInstance = self.service_manager.createInstance
self.desktop = createInstance("com.sun.star.frame.Desktop")
......@@ -231,15 +229,6 @@ class UnoDocument:
parser = CustomHTMLParser()
with open(temp_file.name, 'r') as f:
parser.feed(f.read())
if refresh:
# Before converting to expected format, refresh dynamic
# value inside document.
dispatch = partial(
createInstance("com.sun.star.frame.DispatchHelper").executeDispatch,
uno_document.CurrentController.Frame)
for uno_command in ('UpdateFields', 'UpdateAll', 'UpdateInputFields',
'UpdateAllLinks', 'UpdateCharts',):
dispatch('.uno:%s' % uno_command, '', 0, ())
module_manager = createInstance("com.sun.star.frame.ModuleManager")
self.document_type = module_manager.identify(uno_document)
......@@ -363,7 +352,7 @@ def main():
"uno_path=", "office_binary_path=",
"hostname=", "port=", "source_format=",
"document_url=", "destination_format=",
"mimemapper=", "metadata=", "refresh=",
"mimemapper=", "metadata=",
"unomimemapper_bin=", "infilter=", "script="])
except GetoptError as msg:
msg = msg.msg + help_msg
......@@ -376,7 +365,7 @@ def main():
metadata = mimemapper = script = None
hostname = port = office_binary_path = uno_path = None
document_url = destination_format = source_format = infilter = refresh = None
document_url = destination_format = source_format = infilter = None
for opt, arg in iter(opt_list):
if opt in ('-h', '--help'):
help()
......@@ -394,8 +383,6 @@ def main():
destination_format = arg
elif opt == '--source_format':
source_format = arg
elif opt == '--refresh':
refresh = json.loads(arg)
elif opt == '--metadata':
arg = b64decode(arg).decode('utf-8')
metadata = json.loads(arg)
......@@ -409,7 +396,7 @@ def main():
service_manager = helper_util.getServiceManager(
hostname, port, uno_path, office_binary_path)
unodocument = UnoDocument(service_manager, document_url,
source_format, destination_format, infilter, refresh)
source_format, destination_format, infilter)
if script:
unodocument.runScript(script)
if '--setmetadata' in param_list:
......@@ -421,7 +408,7 @@ def main():
if output:
# Instanciate new UnoDocument instance with new url
unodocument = UnoDocument(service_manager, output,
destination_format or source_format, None, None, refresh)
destination_format or source_format, None, None)
metadata_dict = unodocument.getMetadata()
if output:
metadata_dict['document_url'] = output
......
......@@ -167,9 +167,9 @@ class TestHandler(HandlerTestCase):
def testRefreshOdt(self):
"""Test refresh argument"""
# Check when refreshing is disabled
with open("data/test_fields.odt", "rb") as f:
data = f.read()
# refresh parameter is now ignored.
handler = Handler(self.tmp_url,
data,
'odt',
......@@ -179,19 +179,6 @@ class TestHandler(HandlerTestCase):
self._save_document(document_output_url, doc_exported)
zip_handler = ZipFile(document_output_url)
content_tree = etree.fromstring(zip_handler.read('content.xml'))
self.assertFalse(content_tree.xpath('//text:variable-get[text() = "DISPLAY ME"]',
namespaces=content_tree.nsmap))
# Check when refreshing is enabled
handler = Handler(self.tmp_url,
data,
'odt',
refresh=True)
doc_exported = handler.convert("odt")
document_output_url = path.join(self.tmp_url, "testExport.odt")
self._save_document(document_output_url, doc_exported)
zip_handler = ZipFile(document_output_url)
content_tree = etree.fromstring(zip_handler.read('content.xml'))
self.assertTrue(content_tree.xpath('//text:variable-get[text() = "DISPLAY ME"]',
namespaces=content_tree.nsmap))
......
......@@ -122,11 +122,12 @@ class Manager(object):
destination_format -- Target format as string
zip -- Boolean Attribute. If true, returns the file in the form of a
zip archive
refresh -- Obsolete and ignored
"""
self._check_file_type(file)
kw = self.kw.copy()
kw.update(zip=zip, refresh=refresh)
kw.update(zip=zip)
# XXX Force the use of wkhtmltopdf handler if converting from html to pdf
# with conversion parameters.
# This is a hack that quickly enables the use of wkhtmltopdf without
......
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