diff options
author | Javier Fernandez <jfernandez@igalia.com> | 2013-05-03 13:39:24 +0000 |
---|---|---|
committer | Javier Fernandez <jfernandez@igalia.com> | 2013-05-08 09:36:38 +0000 |
commit | 99a41e7862c68759f3d3dd5e4bf096848c4859b2 (patch) | |
tree | 2e1f8925e43219740935caa3dc5c7cc202906d34 /wizards/com | |
parent | 8a9e404be28d10a2f7e4e40abb5a0f79066b767d (diff) |
PyWebWizard: Fixing bugs and implementation of mising features.
New utility Configuration methods for manipulating nodes.
Change-Id: I966767fb773c0d710561bea191e901f233b1164e
Diffstat (limited to 'wizards/com')
-rw-r--r-- | wizards/com/sun/star/wizards/common/Configuration.py | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/wizards/com/sun/star/wizards/common/Configuration.py b/wizards/com/sun/star/wizards/common/Configuration.py index 5e42356efede..dbaf6ddc1766 100644 --- a/wizards/com/sun/star/wizards/common/Configuration.py +++ b/wizards/com/sun/star/wizards/common/Configuration.py @@ -44,3 +44,67 @@ class Configuration(object): 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) + + # This method creates a new configuration node and adds it + # to the given view. Note that if a node with the given name + # already exists it will be completely removed from + # the configuration. + # @param configView + # @param name + # @return the new created configuration node. + # @throws com.sun.star.lang.WrappedTargetException + # @throws ElementExistException + # @throws NoSuchElementException + # @throws com.sun.star.uno.Exception + @classmethod + def addConfigNode(self, configView, name): + try: + node = configView.getByName(name) + except Exception: + node = None + if (node is not None): + return node + else: + # create a new detached set element (instance of DataSourceDescription) + # the new element is the result ! + node = configView.createInstance() + # insert it - this also names the element + configView.insertByName(name, node) + return node + + @classmethod + def removeNode(self, configView, name): + if (configView.hasByName(name)): + configView.removeByName(name) + + @classmethod + def commit(self, configView): + configView.commitChanges() + + @classmethod + def getChildrenNames(self, configView): + return configView.getElementNames() + + @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) |