[Libreoffice-commits] core.git: wizards/com

Xisco Fauli anistenis at gmail.com
Fri Feb 8 10:11:48 PST 2013


 wizards/com/sun/star/wizards/agenda/AgendaWizardDialogImpl.py |   13 +--
 wizards/com/sun/star/wizards/agenda/TopicsControl.py          |   24 +++--
 wizards/com/sun/star/wizards/common/ConfigSet.py              |   42 ++++------
 3 files changed, 38 insertions(+), 41 deletions(-)

New commits:
commit 195007a80725d14c5dac64e2c9d1ed21e58da380
Author: Xisco Fauli <anistenis at gmail.com>
Date:   Fri Feb 8 19:04:00 2013 +0100

    pyagenda: Save configuration after finishing the wizard
    
    Change-Id: Ia0d80ac089608178e714735d6bfc4516030ee5b9

diff --git a/wizards/com/sun/star/wizards/agenda/AgendaWizardDialogImpl.py b/wizards/com/sun/star/wizards/agenda/AgendaWizardDialogImpl.py
index 1cf8489..2c3e288 100644
--- a/wizards/com/sun/star/wizards/agenda/AgendaWizardDialogImpl.py
+++ b/wizards/com/sun/star/wizards/agenda/AgendaWizardDialogImpl.py
@@ -208,12 +208,6 @@ class AgendaWizardDialogImpl(AgendaWizardDialog):
             self.agenda, "cp_ProceedMethod",
                 (self.optCreateAgenda, self.optMakeChanges), True).updateUI()
 
-    def saveConfiguration(self):
-        root = Configuration.getConfigurationRoot(
-            self.xMSF, "/org.openoffice.Office.Writer/Wizards/Agenda", True)
-        self.agenda.writeConfiguration(root, "cp_")
-        root.commitChanges()
-
     def insertRoadmap(self):
         self.addRoadmap()
 
@@ -360,7 +354,12 @@ class AgendaWizardDialogImpl(AgendaWizardDialog):
                 "writer8_template")
 
             if bSaveSuccess:
-                self.saveConfiguration()
+                self.topicsControl.saveTopics(self.agenda)
+                root = Configuration.getConfigurationRoot(
+                    self.xMSF, "/org.openoffice.Office.Writer/Wizards/Agenda",
+                    True)
+                self.agenda.writeConfiguration(root, "cp_")
+                root.commitChanges()
 
                 self.agendaTemplate.finish(self.topicsControl.scrollfields)
 
diff --git a/wizards/com/sun/star/wizards/agenda/TopicsControl.py b/wizards/com/sun/star/wizards/agenda/TopicsControl.py
index f579838..2fc619a 100644
--- a/wizards/com/sun/star/wizards/agenda/TopicsControl.py
+++ b/wizards/com/sun/star/wizards/agenda/TopicsControl.py
@@ -131,12 +131,12 @@ class TopicsControl(ControlScroller):
 
     def initializeScrollFields(self, agenda):
         # create a row for each topic with the given values....
-        for i  in range(len(agenda.cp_Topics.childrenList)):
-            row = self.newRow(i)
-            agenda.cp_Topics.childrenList[i].setDataToRow(row)
+        for index,item  in enumerate(agenda.cp_Topics.childrenList):
+            row = self.newRow(index)
+            item.setDataToRow(row)
             # a parent class method
-            self.registerControlGroup(row, i)
-            self.updateDocumentRow(i)
+            self.registerControlGroup(row, index)
+            self.updateDocumentRow(index)
         # inserts a blank row at the end...
         self.insertRowAtEnd()
 
@@ -157,6 +157,10 @@ class TopicsControl(ControlScroller):
             self.ControlGroupVector[l - self.nscrollvalue].\
                 setEnabled(True)
 
+    def saveTopics(self, agenda):
+        #last row is always empty
+        agenda.cp_Topics.childrenList = self.scrollfields[:-1]
+
     '''
     remove the last row
     '''
@@ -338,7 +342,7 @@ class TopicsControl(ControlScroller):
     def isRowEmpty(self, row):
         data = self.getTopicData(row)
         # now - is this row empty?
-        return data[1].Value or data[2].Value or data[3].Value
+        return not data[1].Value and not data[2].Value and not data[3].Value
 
     '''
     update the preview document and
@@ -355,7 +359,7 @@ class TopicsControl(ControlScroller):
                 return
             self.updateDocumentCell(
                 guiRow + self.nscrollvalue, column, data)
-            if not self.isRowEmpty(guiRow + self.nscrollvalue):
+            if self.isRowEmpty(guiRow + self.nscrollvalue):
                 '''
                 if this is the row before the last one
                 (the last row is always empty)
@@ -370,7 +374,7 @@ class TopicsControl(ControlScroller):
                     because the last one is always empty...
                     '''
                     while len(self.scrollfields) > 1 \
-                            and not self.isRowEmpty(
+                            and self.isRowEmpty(
                                 len(self.scrollfields) - 2):
                         self.removeLastRow()
                     cr = self.ControlGroupVector[
@@ -593,8 +597,8 @@ class TopicsControl(ControlScroller):
         elif (row1 + self.nscrollvalue) + \
                 (row2 + self.nscrollvalue) \
                 == (len(self.scrollfields) * 2 - 5):
-            if not self.isRowEmpty(len(self.scrollfields) - 2) \
-                    and not self.isRowEmpty(
+            if self.isRowEmpty(len(self.scrollfields) - 2) \
+                    and self.isRowEmpty(
                         len(self.scrollfields) - 1):
                 self.removeLastRow()
                 self.reduceDocumentToTopics()
diff --git a/wizards/com/sun/star/wizards/common/ConfigSet.py b/wizards/com/sun/star/wizards/common/ConfigSet.py
index e69ed13..ee041de 100644
--- a/wizards/com/sun/star/wizards/common/ConfigSet.py
+++ b/wizards/com/sun/star/wizards/common/ConfigSet.py
@@ -32,31 +32,24 @@ class ConfigSet(ConfigGroup):
 
     def __init__(self):
         self.childrenList = []
+        self.childrenListLen = 0
 
-    def writeConfiguration(self, configView, param):
-        names = self.childrenMap.keys()
-        if isinstance(self.childClass, ConfigNode):
-            #first I remove all the children from the configuration.
-            children = configView.ElementNames
-            if children:
-                for i in children:
-                    try:
-                        Configuration.removeNode(configView, i)
-                    except Exception:
-                        traceback.print_exc()
-
-                # and add them new.
-            for i in names:
-                try:
-                    child = self.getElement(i)
-                    childView = configView.getByName(i)
-                    child.writeConfiguration(childView, param)
-                except Exception:
-                    traceback.print_exc()
-        else:
-            raise AttributeError (
-            "Unable to write primitive sets to configuration (not implemented)")
-
+    def writeConfiguration(self, configurationView, param):
+        for i in range(self.childrenListLen):
+            #remove previous configuration
+            configurationView.removeByName(i)
+        for index,item in enumerate(self.childrenList):
+            try:
+                childView = configurationView.createInstance()
+                configurationView.insertByName(index, childView)
+                topic = CGTopic()
+                topic.cp_Index = item[0].Value
+                topic.cp_Topic = item[1].Value
+                topic.cp_Responsible = item[2].Value
+                topic.cp_Time = item[3].Value
+                topic.writeConfiguration(childView, param)
+            except Exception:
+                traceback.print_exc()
 
     def readConfiguration(self, configurationView, param):
         #each iteration represents a Topic row
@@ -70,3 +63,4 @@ class ConfigSet(ConfigGroup):
                     self.childrenList.append(topic)
                 except Exception:
                     traceback.print_exc()
+        self.childrenListLen = len(self.childrenList)


More information about the Libreoffice-commits mailing list