Difference between revisions of "Danny.OOo.ConfigLib.py"
From Apache OpenOffice Wiki
(Added code from oooforum.) |
(Adding categories) |
||
Line 72: | Line 72: | ||
# tNames = oElement.getElementNames() | # tNames = oElement.getElementNames() | ||
</source> | </source> | ||
+ | [[Category:Extensions]] | ||
+ | [[Category:Python]] | ||
+ | [[Category:Uno]] |
Latest revision as of 19:59, 17 February 2015
Routines for working with the Configuration Manager.
#********************************************************************** # # Danny.OOo.ConfigLib.py # # A module to easily work with OpenOffice.org. # #********************************************************************** # Copyright (c) 2003-2004 Danny Brewer # d29583@groovegarden.com # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # See: http://www.gnu.org/licenses/lgpl.html # #********************************************************************** # If you make changes, please append to the change log below. # # Change Log # Danny Brewer Revised 2004-06-20-01 # #********************************************************************** # OOo's libraries import uno import unohelper # Danny's libraries from Danny.OOo.OOoLib import createUnoService, createUnoStruct from Danny.OOo.OOoLib import makePropertyValue from Danny.OOo.OOoLib import getServiceManager def getConfigAccess( cNodePath, bWriteAccess=False, bEnableSync=True, bLazyWrite=False ): """An easy way to obtain a configuration node from the configuration manager.""" oConfigProvider = getServiceManager().createInstanceWithArguments( "com.sun.star.configuration.ConfigurationProvider", ( makePropertyValue( "enablesync", bEnableSync ), ) ) if bWriteAccess: cServiceName = "com.sun.star.configuration.ConfigurationUpdateAccess" else: cServiceName = "com.sun.star.configuration.ConfigurationAccess" oConfigAccess = oConfigProvider.createInstanceWithArguments( cServiceName, ( makePropertyValue( "nodepath", cNodePath ), makePropertyValue( "lazywrite", bLazyWrite ), ) ) return oConfigAccess # oConfigAccess = getConfigAccess( "/org.openoffice.Office.Addons/AddonUI" ) # oElement = oConfigAccess.getByName( "AddonMenu" ) # tNames = oElement.getElementNames()