Here is my code:
Code: Select all
import pyuno
from os.path import realpath, join
from com.sun.star.beans import PropertyValue
def bal(*args):
doc = BalDocument()
def convert_path_to_url(path):
return pyuno.systemPathToFileUrl(realpath(path))
class BalDocument():
def __init__(self):
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.save_path = join(SAVE_PATH, self.filename)
def save(self):
url = convert_path_to_url(self.save_path)
properties = []
p = PropertyValue(
Name = 'FilterName',
Value = 'MS Word 97'
)
properties.append(p)
self.model.storeAsUrl(url, properties)
Code: Select all
properties = (
PropertyValue("FilterName", 0, "MS Word 97", 0),
PropertyValue("Overwrite", 0, True, 0),
)
com.sun.star.uno.RuntimeExceptionpyuno._createUnoStructHelper: member 'Handle' of struct type 'com.sun.star.beans.PropertyValue' not given a value. (Error during invoking function bal in module file:///home/bastien/.config/libreoffice/4/user/Scripts/python/rdt_bal.py (<class 'uno.com.sun.star.uno.RuntimeException'>: pyuno._createUnoStructHelper: member 'Handle' of struct type 'com.sun.star.beans.PropertyValue' not given a value.