summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXisco Fauli <anistenis@gmail.com>2013-02-02 22:36:03 +0100
committerXisco Fauli <anistenis@gmail.com>2013-02-03 00:43:36 +0100
commit98185094cf975dcc3fe4e6c234bea9b46b4e9482 (patch)
treef0ba029a69c9eba872efe7a02e7e390f18f6cafa
parent270a8259bf86ea5a338f57abd02d747756c0c43a (diff)
pyagenda: load previous topics configuration when launching the wizard
Change-Id: I771c3a86d00c55e82a96286fec0484283d28ff4c
-rw-r--r--wizards/com/sun/star/wizards/agenda/AgendaDocument.py26
-rw-r--r--wizards/com/sun/star/wizards/agenda/AgendaWizardDialogImpl.py24
-rw-r--r--wizards/com/sun/star/wizards/agenda/CGAgenda.py44
-rw-r--r--wizards/com/sun/star/wizards/agenda/CGTopic.py29
-rw-r--r--wizards/com/sun/star/wizards/agenda/TopicsControl.py14
-rw-r--r--wizards/com/sun/star/wizards/common/ConfigGroup.py1
-rw-r--r--wizards/com/sun/star/wizards/common/ConfigNode.py3
-rw-r--r--wizards/com/sun/star/wizards/common/ConfigSet.py129
8 files changed, 79 insertions, 191 deletions
diff --git a/wizards/com/sun/star/wizards/agenda/AgendaDocument.py b/wizards/com/sun/star/wizards/agenda/AgendaDocument.py
index b3d88065024b..25ecf04d42a8 100644
--- a/wizards/com/sun/star/wizards/agenda/AgendaDocument.py
+++ b/wizards/com/sun/star/wizards/agenda/AgendaDocument.py
@@ -836,13 +836,14 @@ class Topics(object):
except Exception:
traceback.print_exc()
- '''@param topic the topic number to write
- @param data the data of the topic.
- @return the number of rows that have been added
- to the table. 0 or a negative number: no rows added.
+ '''rewrites a single cell containing.
+ This is used in order to refresh the topic/responsible/duration data
+ in the preview document, in response to a change in the gui (by the user)
+ Since the structure of the topics table is flexible,
+ The Topics object, which analyzed the structure of the topics table appon
+ initialization, refreshes the approperiate cell.
'''
-
- def write(self, row, column, data):
+ def writeCell(self, row, column, data):
# if the whole row should be written...
if self.writtenTopics < row:
self.writtenTopics += 1
@@ -863,21 +864,10 @@ class Topics(object):
# move the cursor to the needed cell...
cursor.goRight(column, False)
- self.writeCell(cursor, column, data)
-
- '''rewrites a single cell containing.
- This is used in order to refresh the topic/responsible/duration data
- in the preview document, in response to a change in the gui (by the user)
- Since the structure of the topics table is flexible,
- The Topics object, which analyzed the structure of the topics table appon
- initialization, refreshes the approperiate cell.
- '''
-
- def writeCell(self, cursor, column, data):
xc = Topics.table.getCellByName(cursor.RangeName)
# and write it !
te = TextElement(xc, data[column].Value)
- te.write()
+ te.write()
'''removes obsolete rows, reducing the
topics table to the given number of topics.
diff --git a/wizards/com/sun/star/wizards/agenda/AgendaWizardDialogImpl.py b/wizards/com/sun/star/wizards/agenda/AgendaWizardDialogImpl.py
index e40442beca38..1cf8489af0e4 100644
--- a/wizards/com/sun/star/wizards/agenda/AgendaWizardDialogImpl.py
+++ b/wizards/com/sun/star/wizards/agenda/AgendaWizardDialogImpl.py
@@ -72,13 +72,24 @@ class AgendaWizardDialogImpl(AgendaWizardDialog):
#Number of steps on WizardDialog
self.nMaxStep = 6
- # initialize the agenda template
self.agenda = CGAgenda()
-
+
+ # read configuration data before we initialize the topics
+ root = Configuration.getConfigurationRoot(
+ self.xMSF, "/org.openoffice.Office.Writer/Wizards/Agenda",
+ False)
+ self.agenda.readConfiguration(root, "cp_")
+
self.templateConsts = TemplateConsts
+
+ # initialize the agenda template
self.agendaTemplate = AgendaDocument(
self.xMSF, self.agenda, self.resources,
self.templateConsts, self)
+ self.initializeTemplates()
+
+ self.agendaTemplate.load(
+ self.agendaTemplates[1][self.agenda.cp_AgendaType], [])
# build the dialog.
self.drawNaviBar()
@@ -96,8 +107,6 @@ class AgendaWizardDialogImpl(AgendaWizardDialog):
#special Control for setting the save Path:
self.insertPathSelectionControl()
- self.initializeTemplates()
-
# synchronize GUI and CGAgenda object.
self.initConfiguration()
@@ -111,8 +120,6 @@ class AgendaWizardDialogImpl(AgendaWizardDialog):
# initialize roadmap
self.insertRoadmap()
- self.pageDesignChanged()
-
self.executeDialogFromComponent(self.agendaTemplate.xFrame)
self.removeTerminateListener()
self.closeDocument()
@@ -150,11 +157,6 @@ class AgendaWizardDialogImpl(AgendaWizardDialog):
'''
def initConfiguration(self):
- # read configuration data.
- root = Configuration.getConfigurationRoot(
- self.xMSF, "/org.openoffice.Office.Writer/Wizards/Agenda", False)
- self.agenda.readConfiguration(root, "cp_")
-
self.xDialogModel.listPageDesign.StringItemList = \
tuple(self.agendaTemplates[0])
UnoDataAware.attachListBox(
diff --git a/wizards/com/sun/star/wizards/agenda/CGAgenda.py b/wizards/com/sun/star/wizards/agenda/CGAgenda.py
index 32d033ed3803..a50dbd9b4770 100644
--- a/wizards/com/sun/star/wizards/agenda/CGAgenda.py
+++ b/wizards/com/sun/star/wizards/agenda/CGAgenda.py
@@ -20,25 +20,27 @@ from ..common.ConfigSet import ConfigSet
from .CGTopic import CGTopic
class CGAgenda(ConfigGroup):
- cp_AgendaType = int()
- cp_IncludeMinutes = bool()
- cp_Title = ""
- cp_Date = str()
- cp_Time = str()
- cp_Location = ""
- cp_ShowMeetingType = bool()
- cp_ShowRead = bool()
- cp_ShowBring = bool()
- cp_ShowNotes = bool()
- cp_ShowCalledBy = bool()
- cp_ShowFacilitator = bool()
- cp_ShowNotetaker = bool()
- cp_ShowTimekeeper = bool()
- cp_ShowAttendees = bool()
- cp_ShowObservers = bool()
- cp_ShowResourcePersons = bool()
- cp_TemplateName = str()
- cp_TemplatePath = str()
- cp_ProceedMethod = int()
- cp_Topics = ConfigSet(CGTopic())
+ def __init__(self):
+ self.cp_AgendaType = int()
+ self.cp_IncludeMinutes = bool()
+ self.cp_Title = ""
+ self.cp_Date = str()
+ self.cp_Time = str()
+ self.cp_Location = ""
+ self.cp_ShowMeetingType = bool()
+ self.cp_ShowRead = bool()
+ self.cp_ShowBring = bool()
+ self.cp_ShowNotes = bool()
+ self.cp_ShowCalledBy = bool()
+ self.cp_ShowFacilitator = bool()
+ self.cp_ShowNotetaker = bool()
+ self.cp_ShowTimekeeper = bool()
+ self.cp_ShowAttendees = bool()
+ self.cp_ShowObservers = bool()
+ self.cp_ShowResourcePersons = bool()
+ self.cp_TemplateName = str()
+ self.cp_TemplatePath = str()
+ self.cp_ProceedMethod = int()
+
+ self.cp_Topics = ConfigSet(CGTopic())
diff --git a/wizards/com/sun/star/wizards/agenda/CGTopic.py b/wizards/com/sun/star/wizards/agenda/CGTopic.py
index 50ebc4d1d03a..240ad0ed4b5b 100644
--- a/wizards/com/sun/star/wizards/agenda/CGTopic.py
+++ b/wizards/com/sun/star/wizards/agenda/CGTopic.py
@@ -27,11 +27,6 @@ and vice versa (setDataToRow method - used when loading the last session...)
class CGTopic(ConfigGroup):
- cp_Index = int()
- cp_Topic = str()
- cp_Responsible = str()
- cp_Time = str()
-
'''
create a new CGTopic object with data from the given row.
the row object is a PropertyValue array, as used
@@ -41,12 +36,16 @@ class CGTopic(ConfigGroup):
def __init__(self, row=None):
if row is None:
- return
- num = row[0].Value
- CGTopic.cp_Index = int(row[0].Value[:-1])
- CGTopic.cp_Topic = row[1].Value
- CGTopic.cp_Responsible = row[2].Value
- CGTopic.cp_Time = row[3].Value
+ self.cp_Index = int()
+ self.cp_Topic = str()
+ self.cp_Responsible = str()
+ self.cp_Time = str()
+ else:
+ num = row[0].Value
+ self.cp_Index = int(row[0].Value[:-1])
+ self.cp_Topic = row[1].Value
+ self.cp_Responsible = row[2].Value
+ self.cp_Time = row[3].Value
'''
copies the data in this CGTopic object
@@ -56,7 +55,7 @@ class CGTopic(ConfigGroup):
'''
def setDataToRow(self, row):
- row[0].Value = "" + str(CGTopic.cp_Index) + "."
- row[1].Value = CGTopic.cp_Topic
- row[2].Value = CGTopic.cp_Responsible
- row[3].Value = CGTopic.cp_Time
+ row[0].Value = "" + str(self.cp_Index) + "."
+ row[1].Value = self.cp_Topic
+ row[2].Value = self.cp_Responsible
+ row[3].Value = self.cp_Time
diff --git a/wizards/com/sun/star/wizards/agenda/TopicsControl.py b/wizards/com/sun/star/wizards/agenda/TopicsControl.py
index af962b8c81f2..8116b43a1762 100644
--- a/wizards/com/sun/star/wizards/agenda/TopicsControl.py
+++ b/wizards/com/sun/star/wizards/agenda/TopicsControl.py
@@ -105,6 +105,7 @@ class TopicsControl(ControlScroller):
try:
super(TopicsControl, self).__init__(
dialog, xmsf, 5, 92, 38, 212, 5, 18, HID + 32)
+ self.dialog = dialog
self.initializeScrollFields(agenda)
# set some focus listeners for TAB scroll down and up...
# prepare scroll down on tab press...
@@ -127,9 +128,9 @@ class TopicsControl(ControlScroller):
def initializeScrollFields(self, agenda):
# create a row for each topic with the given values....
- for i in range(agenda.cp_Topics.getSize()):
+ for i in range(len(agenda.cp_Topics.childrenList)):
row = self.newRow(i)
- agenda.cp_Topics.getElementAt(i).setDataToRow(row)
+ agenda.cp_Topics.childrenList[i].setDataToRow(row)
# a parent class method
self.registerControlGroup(row, i)
self.updateDocumentRow(i)
@@ -313,7 +314,7 @@ class TopicsControl(ControlScroller):
@classmethod
def newRow(self, i):
- pv = [None] * 4
+ pv = list(range(4))
pv[0] = Properties.createProperty(
TopicsControl.LABEL + str(i), "" + str(i + 1) + ".")
pv[1] = Properties.createProperty(TopicsControl.TOPIC + str(i), "")
@@ -699,8 +700,9 @@ class TopicsControl(ControlScroller):
if data is None:
data = ControlScroller.scrollfields[row]
try:
- ControlScroller.CurUnoDialog.agendaTemplate.topics.write(
- row, data)
+ for i in range(len(data)):
+ ControlScroller.CurUnoDialog.agendaTemplate.topics.writeCell(
+ row, i, data)
except Exception:
traceback.print_exc()
@@ -716,7 +718,7 @@ class TopicsControl(ControlScroller):
@classmethod
def updateDocumentCell(self, row, column, data):
try:
- ControlScroller.CurUnoDialog.agendaTemplate.topics.write(
+ ControlScroller.CurUnoDialog.agendaTemplate.topics.writeCell(
row, column, data)
except Exception:
traceback.print_exc()
diff --git a/wizards/com/sun/star/wizards/common/ConfigGroup.py b/wizards/com/sun/star/wizards/common/ConfigGroup.py
index ae15e85a766e..225b2fcb7bb7 100644
--- a/wizards/com/sun/star/wizards/common/ConfigGroup.py
+++ b/wizards/com/sun/star/wizards/common/ConfigGroup.py
@@ -44,7 +44,6 @@ class ConfigGroup(ConfigNode):
propertyName = field[len(prefix):]
child = getattr(self, field)
if isinstance(child, ConfigNode):
- child.root = self.root
child.readConfiguration(configView.getByName(propertyName),
prefix)
else:
diff --git a/wizards/com/sun/star/wizards/common/ConfigNode.py b/wizards/com/sun/star/wizards/common/ConfigNode.py
index c2cd23163978..efaeedbacf76 100644
--- a/wizards/com/sun/star/wizards/common/ConfigNode.py
+++ b/wizards/com/sun/star/wizards/common/ConfigNode.py
@@ -18,9 +18,6 @@
from abc import ABCMeta, abstractmethod
class ConfigNode(object):
-
- root = None
-
@abstractmethod
def readConfiguration(self, configurationView, param):
pass
diff --git a/wizards/com/sun/star/wizards/common/ConfigSet.py b/wizards/com/sun/star/wizards/common/ConfigSet.py
index f9b38562ac78..0675e8dca21a 100644
--- a/wizards/com/sun/star/wizards/common/ConfigSet.py
+++ b/wizards/com/sun/star/wizards/common/ConfigSet.py
@@ -16,6 +16,7 @@
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
#
import traceback
+import inspect
from .ConfigNode import ConfigNode
from .Configuration import Configuration
@@ -29,13 +30,13 @@ class ConfigSet(ConfigNode):
to avoid this "deletion" of nulls.
'''
- def __init__(self, childType):
- self.childClass = childType
+ def __init__(self, topic):
+ self.topic = topic
self.childrenMap = {}
self.childrenList = []
self.noNulls = False
- def add(self, name, o):
+ def add2(self, name, o):
self.childrenMap[name] = o
if isinstance(name, int):
i = name
@@ -56,6 +57,9 @@ class ConfigSet(ConfigNode):
except Exception:
self.childrenList.append(o)
+ def add(self, name, o):
+ self.childrenList.append(o)
+
def writeConfiguration(self, configView, param):
names = self.childrenMap.keys()
if isinstance(self.childClass, ConfigNode):
@@ -80,122 +84,15 @@ class ConfigSet(ConfigNode):
raise AttributeError (
"Unable to write primitive sets to configuration (not implemented)")
+
def readConfiguration(self, configurationView, param):
+ #each iteration represents a Topic row
names = configurationView.ElementNames
- if isinstance(self.childClass, ConfigNode):
- if names:
- for i in names:
- try:
- child = type(self.childClass)()
- child.root = self.root
- child.readConfiguration(
- configurationView.getByName(i), param)
- self.add(i, child)
- except Exception:
- traceback.print_exc()
- #remove any nulls from the list
- if self.noNulls:
- i = 0
- while i < len(self.childrenList):
- if self.childrenList[i] is None:
- del self.childrenList[i]
- i -= 1
- i += 1
-
- else:
+ if names:
for i in names:
try:
- child = configurationView.getByName(i)
- self.add(i, child)
+ self.topic.readConfiguration(
+ configurationView.getByName(i), param)
+ self.add(i, self.topic)
except Exception:
traceback.print_exc()
-
- def remove(self, obj):
- key = getKey(obj)
- self.childrenMap.remove(key)
- i = self.childrenList.indexOf(obj)
- self.childrenList.remove(obj)
- fireListDataListenerIntervalRemoved(i, i)
-
- def remove(self, i):
- o = getElementAt(i)
- remove(o)
-
- def clear(self):
- self.childrenMap.clear()
- del self.childrenList[:]
-
- def createDOM(self, parent):
- items = items()
- i = 0
- while i < items.length:
- item = items[i]
- if item.instanceof.XMLProvider:
- item.createDOM(parent)
-
- i += 1
- return parent
-
- def getKey(self, _object):
- for k,v in self.childrenMap.items():
- if v == _object:
- return k
-
- return None
-
- def getElementAt(self, i):
- return self.childrenList[i]
-
- def getElement(self, o):
- return self.childrenMap[o]
-
- def getSize(self):
- return len(self.childrenList)
-
- def getIndexOf(self, item):
- return self.childrenList.index(item)
-
- '''
- Set members might include a property
- which orders them.
- This method reindexes the given member to be
- the index number 0
- Do not forget to call commit() after calling this method.
- @param confView
- @param memebrName
- '''
-
- def reindexSet(self, confView, memberName, indexPropertyName):
- '''
- First I read all memebrs of the set,
- except the one that should be number 0
- to a vector, ordered by there index property
- '''
- names = Configuration.getChildrenNames(confView)
- v = Vector.Vector_unknown(names.length)
- member = None
- index = 0
- i = 0
- while i < names.length:
- if not names[i].equals(memberName):
- member = Configuration.getConfigurationNode(names[i], confView)
- index = Configuration.getInt(indexPropertyName, member)
- while index >= v.size():
- v.add(None)
- v.setElementAt(member, index)
- '''
- Now I reindex them
- '''
-
- i += 1
- index = 1
- i = 0
- while i < v.size():
- member = v.get(i)
- if member is not None:
- Configuration.set((index + 1), indexPropertyName, member)
-
- i += 1
-
- def sort(self, comparator):
- self.childrenList.sort(comparator)