openoffice.org - Python storeAsUrl fails to save document -


this code should open template , save using storeasurl. opens template fails saving it. have no idea why.

import pyuno  os.path import realpath, join com.sun.star.beans import propertyvalue   save_path = '/home/user/bureau/' filename = 'p{0:04d}.doc' template_path = '/home/user/bureau/' template_name = 'bal.ott'   def convert_path_to_url(path):     return pyuno.systempathtofileurl(realpath(path))   def python_bal(*args):     bal_doc = baldocument(1)     bal_doc.save()   class baldocument():      def __init__(self, id):         self.id = id         self.desktop = xscriptcontext.getdesktop()         template_url = convert_path_to_url(join(template_path, template_name))         args = (propertyvalue('hidden', 0, false, 0),)         self.model = self.desktop.loadcomponentfromurl(template_url, "_default", 0, args)         self.filename = filename.format(id)         self.save_path = join(save_path, self.filename)      def save(self):         url = convert_path_to_url(self.save_path)         args = (propertyvalue('filtername', 0, 'ms word 97', 0),)         self.model.storeasurl(url, args)         self.model.dispose()  g_exportedscripts = python_bal, 

this simple script placed in ~/.config/libreoffice/4/user/scripts/python/. launch button in toolbar of empty doc. can't through error:

com.sun.star.uno.runtimeexceptionerror during invoking function python_bal in module file:///home/bastien/.config/libreoffice/4/user/scripts/python/bbal.py (: storeasurl...)

i wonder if doesn't come way create self.desktop.

there typo in method name : storeasurl url solved trick.

developing uno component , python full of pitfall because there no simple ide autocompleting or inspecting code while developping. yes, there xraytools...


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -