12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- import uno
- import traceback
- class Configuration(object):
- '''This class gives access to the OO configuration api.'''
- @classmethod
- def getConfigurationRoot(self, xmsf, sPath, updateable):
- oConfigProvider = xmsf.createInstance(
- "com.sun.star.configuration.ConfigurationProvider")
- args = []
- aPathArgument = uno.createUnoStruct(
- 'com.sun.star.beans.PropertyValue')
- aPathArgument.Name = "nodepath"
- aPathArgument.Value = sPath
- args.append(aPathArgument)
- if updateable:
- sView = "com.sun.star.configuration.ConfigurationUpdateAccess"
- else:
- sView = "com.sun.star.configuration.ConfigurationAccess"
- return oConfigProvider.createInstanceWithArguments(sView, tuple(args))
- @classmethod
- def getProductName(self, xMSF):
- try:
- oProdNameAccess = self.getConfigurationRoot(xMSF, "org.openoffice.Setup/Product", False);
- return oProdNameAccess.getByName("ooName")
- except Exception:
- traceback.print_exc()
- return "Unknown"
- @classmethod
- def getNode(self, name, parent):
- return parent.getByName(name)
- @classmethod
- def commit(self, configView):
- configView.commitChanges()
- @classmethod
- def getInt(self, name, parent):
- o = getNode(name, parent)
- if (com.sun.star.uno.AnyConverter.isVoid(o)):
- return 0
- return com.sun.star.uno.AnyConverter.toInt(o)
- @classmethod
- def set(self, value, name, parent):
- parent.setHierarchicalPropertyValue(name, value)
|