Date: prev next · Thread: first prev next last
2012 Archives by date, by thread · List index


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()

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.