[Libreoffice-commits] .: Branch 'feature/gsoc2011_wizards' - wizards/com

Xisco Fauli xfauli at kemper.freedesktop.org
Tue Jun 28 12:27:44 PDT 2011


 wizards/com/sun/star/wizards/common/ConfigGroup.py       |   73 +++------------
 wizards/com/sun/star/wizards/common/Configuration.py     |   13 +-
 wizards/com/sun/star/wizards/document/OfficeDocument.py  |    9 +
 wizards/com/sun/star/wizards/ui/event/DataAwareFields.py |    5 -
 wizards/com/sun/star/wizards/ui/event/UnoDataAware.py    |    1 
 5 files changed, 37 insertions(+), 64 deletions(-)

New commits:
commit 6747e454f04db5ee60475d2d1b101094b5a089c0
Author: Xisco Fauli <anistenis at gmail.com>
Date:   Tue Jun 28 21:23:50 2011 +0200

    Load preview configuration

diff --git a/wizards/com/sun/star/wizards/common/ConfigGroup.py b/wizards/com/sun/star/wizards/common/ConfigGroup.py
index a5824e8..b7715ac 100644
--- a/wizards/com/sun/star/wizards/common/ConfigGroup.py
+++ b/wizards/com/sun/star/wizards/common/ConfigGroup.py
@@ -1,74 +1,39 @@
 from ConfigNode import *
 from Configuration import Configuration
 import traceback
+import inspect
 
 class ConfigGroup(ConfigNode):
 
+    root = None
+
     def writeConfiguration(self, configurationView, param):
-        for i in dir(self):
-            if i.startswith(param):
-                try:
-                    self.writeField(i, configurationView, param)
-                except Exception, ex:
-                    print "Error writing field:" + i
-                    traceback.print_exc()
+        for name,data in inspect.getmembers(self):
+            if name.startswith(param):
+                self.writeField( name, configurationView, param)
 
     def writeField(self, field, configView, prefix):
         propertyName = field[len(prefix):]
-        field = getattr(self,field)
-
-        if isinstance(field, ConfigNode):
-            pass
-            #print configView
-            #childView = Configuration.addConfigNode(configView, propertyName)
-            #self.writeConfiguration(childView, prefix)
+        child = getattr(self, field)
+        if isinstance(child, ConfigNode):
+            child.setRoot(self.root)
+            child.writeConfiguration(configView.getByName(propertyName),
+                prefix)
         else:
-            #print type(field)
-            Configuration.Set(self.convertValue(field), propertyName,
-                configView)
+            configView.setHierarchicalPropertyValue(propertyName,getattr(self,field))
 
-    '''
-    convert the primitive type value of the
-    given Field object to the corresponding
-    Java Object value.
-    @param field
-    @return the value of the field as a Object.
-    @throws IllegalAccessException
-    '''
-
-    def convertValue(self, field):
-        if isinstance(field,bool):
-            return bool(field)
-        elif isinstance(field,int):
-            return int(field)
-
-    def readConfiguration(self, configurationView, param):
-        for i in dir(self):
-            if i.startswith(param):
-                try:
-                    self.readField( i, configurationView, param)
-                except Exception, ex:
-                    print "Error reading field: " + i
-                    traceback.print_exc()
 
     def readConfiguration(self, configurationView, param):
-        for i in dir(self):
-            if i.startswith(param):
-                try:
-                    self.readField( i, configurationView, param)
-                except Exception, ex:
-                    print "Error reading field: " + i
-                    traceback.print_exc()
+        for name,data in inspect.getmembers(self):
+            if name.startswith(param):
+                self.readField( name, configurationView, param)
 
     def readField(self, field, configView, prefix):
         propertyName = field[len(prefix):]
         child = getattr(self, field)
-        fieldType = type(child)
-        if type(ConfigNode) == fieldType:
+        if isinstance(child, ConfigNode):
             child.setRoot(self.root)
-            child.readConfiguration(Configuration.getNode(propertyName, configView),
+            child.readConfiguration(configView.getByName(propertyName),
                 prefix)
-            field.set(this, Configuration.getString(propertyName, configView))
-
-    def setRoot(self, newRoot):
-        self.root = newRoot
+        else:
+            setattr(self,field,configView.getByName(propertyName))
diff --git a/wizards/com/sun/star/wizards/common/Configuration.py b/wizards/com/sun/star/wizards/common/Configuration.py
index 96385bf..d11f1c5 100644
--- a/wizards/com/sun/star/wizards/common/Configuration.py
+++ b/wizards/com/sun/star/wizards/common/Configuration.py
@@ -24,7 +24,7 @@ class Configuration(object):
 
     @classmethod
     def Set(self, value, name, parent):
-        parent.setHierarchicalPropertyValue(name, value)
+        setattr(parent, name, value)
 
     '''
     @param name
@@ -131,13 +131,12 @@ class Configuration(object):
         if configView is None:
             return configView.getByName(name)
         else:
-            print configView
+            # the new element is the result !
+            print type(configView)
+            newNode = configView.createInstance()
             # insert it - this also names the element
-            try:
-                configView.insertByName(name, configView.createInstance())
-            except Exception,e:
-                traceback.print_exc()
-            #return newNode
+            configView.insertByName(name, newNode)
+            return newNode
 
     @classmethod
     def removeNode(self, configView, name):
diff --git a/wizards/com/sun/star/wizards/document/OfficeDocument.py b/wizards/com/sun/star/wizards/document/OfficeDocument.py
index e2636d0..f053bae 100644
--- a/wizards/com/sun/star/wizards/document/OfficeDocument.py
+++ b/wizards/com/sun/star/wizards/document/OfficeDocument.py
@@ -7,6 +7,8 @@ from com.sun.star.awt import WindowDescriptor
 from com.sun.star.awt import Rectangle
 import unohelper
 
+from com.sun.star.task import ErrorCodeIOException
+
 #Window Constants
 com_sun_star_awt_WindowAttribute_BORDER \
     = uno.getConstantByName( "com.sun.star.awt.WindowAttribute.BORDER" )
@@ -199,9 +201,12 @@ class OfficeDocument(object):
                 unohelper.absolutize(
                     unohelper.systemPathToFileUrl(sPath),
                     unohelper.systemPathToFileUrl(sFile)),
-                tuple(oStoreProperties))
-
+                    tuple(oStoreProperties))
+            return True
+        except ErrorCodeIOException:
             return True
+            #There's a bug here, fix later
+            pass
         except Exception, exception:
             traceback.print_exc()
             return False
diff --git a/wizards/com/sun/star/wizards/ui/event/DataAwareFields.py b/wizards/com/sun/star/wizards/ui/event/DataAwareFields.py
index 80f400d..4a8e04b 100644
--- a/wizards/com/sun/star/wizards/ui/event/DataAwareFields.py
+++ b/wizards/com/sun/star/wizards/ui/event/DataAwareFields.py
@@ -34,8 +34,11 @@ class DataAwareFields(object):
                 return self.__ConvertedStringValue(fieldname, value)
             elif isinstance(f,int):
                 return self.__IntFieldValue(fieldname, value)
+            elif isinstance(f,float):
+                pass
+                #return self.__IntFieldValue(fieldname, value)
             else:
-                return SimpleFieldValue(f)
+                return self.__IntFieldValue(fieldname, value)
 
         except AttributeError, ex:
             traceback.print_exc()
diff --git a/wizards/com/sun/star/wizards/ui/event/UnoDataAware.py b/wizards/com/sun/star/wizards/ui/event/UnoDataAware.py
index cca27ae..9e4a456 100644
--- a/wizards/com/sun/star/wizards/ui/event/UnoDataAware.py
+++ b/wizards/com/sun/star/wizards/ui/event/UnoDataAware.py
@@ -134,6 +134,7 @@ class UnoDataAware(DataAware):
         return self.__attachTextControl(
             data, prop, unoControl, listener, "Time", field, 0)
 
+    @classmethod
     def attachNumericControl(self, data, prop, unoControl, listener, field):
         return self.__attachTextControl(
             data, prop, unoControl, listener, "Value", field, float(0))


More information about the Libreoffice-commits mailing list