From 99a41e7862c68759f3d3dd5e4bf096848c4859b2 Mon Sep 17 00:00:00 2001 From: Javier Fernandez Date: Fri, 3 May 2013 13:39:24 +0000 Subject: PyWebWizard: Fixing bugs and implementation of mising features. New utility Configuration methods for manipulating nodes. Change-Id: I966767fb773c0d710561bea191e901f233b1164e --- .../com/sun/star/wizards/common/Configuration.py | 64 ++++++++++++++++++++++ 1 file changed, 64 insertions(+) (limited to 'wizards') 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) -- cgit