PyUNO ConfigurationUpdateAccess does not serialize configuration

Jordi Llonch llonchj at gmail.com
Tue Apr 24 13:40:18 PDT 2012


Hello,

I am trying to add a new path into AutoText Paths configuration using PyUNO.

By executing the following code, AutoText UserPaths shows the added path
but changes
are not set to LibreOffice configuration.

What I am doing wrong?

Thanks,


#!/Applications/LibreOffice.app/Contents/MacOS/python
# -*- coding: utf-8 -*-

import uno
from com.sun.star.beans import PropertyValue

unourl =
"uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext"

def make_properties(dc):
    p = []
    for k,v in dc.iteritems():
        x = PropertyValue()
        x.Name = k
        x.Value = v
        p.append(x)
    return tuple(p)

def main():

    context = uno.getComponentContext()

    smgr = context.ServiceManager
    resolver = smgr.createInstanceWithContext(
        "com.sun.star.bridge.UnoUrlResolver", context)

    ctx = resolver.resolve(unourl)
    desktop = smgr.createInstanceWithContext(
        "com.sun.star.frame.Desktop", ctx)

    args =
make_properties({"nodepath":"/org.openoffice.Office.Paths/Paths"})

    config = smgr.createInstance(
        "com.sun.star.configuration.ConfigurationProvider")
    update_access = config.createInstanceWithArguments(
        "com.sun.star.configuration.ConfigurationUpdateAccess", args)

    path = "$(home)/autotext"

    autotext_path = update_access.getByName("AutoText")
    autotext_path.UserPaths = autotext_path.UserPaths + (path,)
    update_access.commitChanges()

    # TEST results
    access = config.createInstanceWithArguments(
        "com.sun.star.configuration.ConfigurationAccess", args)
    print access.getByName("AutoText").UserPaths

if __name__ == '__main__':
    main()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/libreoffice/attachments/20120425/f0a075ac/attachment.htm>


More information about the LibreOffice mailing list