[Libreoffice-commits] .: 7 commits - wizards/com

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Sun Jan 20 12:08:37 PST 2013


 wizards/com/sun/star/wizards/agenda/AgendaDocument.py         | 1154 ++++++++++
 wizards/com/sun/star/wizards/agenda/AgendaTemplate.py         | 1149 ---------
 wizards/com/sun/star/wizards/agenda/AgendaWizardDialogImpl.py |   10 
 wizards/com/sun/star/wizards/agenda/TopicsControl.py          |    7 
 wizards/com/sun/star/wizards/text/TextSectionHandler.py       |   11 
 wizards/com/sun/star/wizards/ui/ControlScroller.py            |   35 
 wizards/com/sun/star/wizards/ui/UIConsts.py                   |   25 
 wizards/com/sun/star/wizards/ui/UnoDialog.py                  |   69 
 8 files changed, 1193 insertions(+), 1267 deletions(-)

New commits:
commit 5bbc006823a8eba8dbcf06943f76c8fcb30ec7ba
Author: Xisco Fauli <anistenis at gmail.com>
Date:   Sun Jan 20 21:05:57 2013 +0100

    pyagenda: table's cells are TextElement
    
    Change-Id: Ica2289b710369b8d319991fde311d10f64acd295

diff --git a/wizards/com/sun/star/wizards/agenda/AgendaDocument.py b/wizards/com/sun/star/wizards/agenda/AgendaDocument.py
index 001d5c2..8600778 100644
--- a/wizards/com/sun/star/wizards/agenda/AgendaDocument.py
+++ b/wizards/com/sun/star/wizards/agenda/AgendaDocument.py
@@ -844,16 +844,18 @@ class Topics(object):
             # analyze the structure of the topic rows.
             while not cursor.RangeName == afterLastCell:
                 cell = Topics.table.getCellByName(cursor.RangeName)
+                # first I store the content and para style of the cell
+                ae = TextElement(cell, cell.String)
                 # if the cell contains a relevant <...>
                 # i add the text element to the hash,
                 # so it's text can be updated later.
                 try:
                     if items[cell.CellName] is not None:
-                        self.topicItems[cell.String.lower().lstrip()] = cell
+                        self.topicItems[cell.String.lower().lstrip()] = ae
                 except KeyError:
                     pass
 
-                Topics.topicCells.append(cell)
+                Topics.topicCells.append(ae)
                 # goto next cell.
                 cursor.goRight(1, False)
             '''
@@ -886,22 +888,25 @@ class Topics(object):
             size = topic - len(self.writtenTopics)
             self.writtenTopics += [None] * size
         self.writtenTopics.insert(topic, "")
-        # make sure threr are enough rows for me...
+        # make sure three are enough rows for me...
         rows = self.agenda.getRowCount(Topics.table)
         reqRows = 1 + (topic + 1) * Topics.rowsPerTopic
         firstRow = reqRows - Topics.rowsPerTopic + 1
         diff = reqRows - rows
         if diff > 0:
-            self.agenda.insertTableRows(Topics.table, rows, diff)
             # set the item's text...
-        '''self.setItemText(Topics.numCell, data[0].Value)
+            self.agenda.insertTableRows(Topics.table, rows, diff)
+
+        self.setItemText(Topics.numCell, data[0].Value)
         self.setItemText(Topics.topicCell, data[1].Value)
         self.setItemText(Topics.responsibleCell, data[2].Value)
-        self.setItemText(Topics.timeCell, data[3].Value)'''
+        self.setItemText(Topics.timeCell, data[3].Value)
         # now write !
         cursor = Topics.table.createCursorByCellName("A" + str(firstRow))
         for i in Topics.topicCells:
-            self.write(Topics.table.getCellByName(cursor.RangeName))
+            i.placeHolderText = \
+                Topics.table.getCellByName(cursor.RangeName).String
+            i.write()
             cursor.goRight(1, False)
         # now format !
         cursor.gotoCellByName("A" + str(firstRow), False)
@@ -961,7 +966,8 @@ class Topics(object):
             cursor.goRight(cursorMoves, False)
             xc = Topics.table.getCellByName(cursor.RangeName)
             # and write it !
-            te.write(xc)
+            te.placeHolderText = xc.String
+            te.write()
 
     '''writes the given topic.
     if the first topic was involved, reformat the
diff --git a/wizards/com/sun/star/wizards/agenda/TopicsControl.py b/wizards/com/sun/star/wizards/agenda/TopicsControl.py
index 4a72317..809e468 100644
--- a/wizards/com/sun/star/wizards/agenda/TopicsControl.py
+++ b/wizards/com/sun/star/wizards/agenda/TopicsControl.py
@@ -392,12 +392,12 @@ class TopicsControl(ControlScroller):
                     '''
                     while len(ControlScroller.scrollfields) > 1 \
                             and self.isRowEmpty(len(ControlScroller.scrollfields) - 2):
-                        removeLastRow()
+                        self.removeLastRow()
                     cr = self.ControlGroupVector[
-                        ControlScroller.scrollfields.size - ControlScroller.nscrollvalue - 1]
+                        len(ControlScroller.scrollfields) - ControlScroller.nscrollvalue - 1]
                     # if a remove was performed, set focus
                     #to the last row with some data in it...
-                    self.focus(getControl(cr, column))
+                    self.focus(self.getControl(cr, column))
                     # update the preview document.
                     self.reduceDocumentToTopics()
 
diff --git a/wizards/com/sun/star/wizards/ui/ControlScroller.py b/wizards/com/sun/star/wizards/ui/ControlScroller.py
index 219ffaa..35b0bac 100644
--- a/wizards/com/sun/star/wizards/ui/ControlScroller.py
+++ b/wizards/com/sun/star/wizards/ui/ControlScroller.py
@@ -99,7 +99,7 @@ class ControlScroller(object):
         if _ntotfieldcount is not None:
             self.setTotalFieldCount(_ntotfieldcount)
         if _nscrollvalue >= 0:
-            ControlScroller.xScrollBar.xDialogModel.ScrollValue = _nscrollvalue
+            ControlScroller.xScrollBar.Model.ScrollValue = _nscrollvalue
             self.scrollControls()
 
     @classmethod
commit 7f038472fb4640f01f028185dc5e19781e8a8459
Author: Xisco Fauli <anistenis at gmail.com>
Date:   Sun Jan 20 18:49:33 2013 +0100

    pyagenda: Fix fdo#42543 in python
    
    Change-Id: I8dacaa369c62a3d4d183737f024edfe42b903d8c

diff --git a/wizards/com/sun/star/wizards/agenda/AgendaDocument.py b/wizards/com/sun/star/wizards/agenda/AgendaDocument.py
index 4a7e097..001d5c2 100644
--- a/wizards/com/sun/star/wizards/agenda/AgendaDocument.py
+++ b/wizards/com/sun/star/wizards/agenda/AgendaDocument.py
@@ -894,15 +894,14 @@ class Topics(object):
         if diff > 0:
             self.agenda.insertTableRows(Topics.table, rows, diff)
             # set the item's text...
-
-        self.setItemText(Topics.numCell, data[0].Value)
+        '''self.setItemText(Topics.numCell, data[0].Value)
         self.setItemText(Topics.topicCell, data[1].Value)
         self.setItemText(Topics.responsibleCell, data[2].Value)
-        self.setItemText(Topics.timeCell, data[3].Value)
+        self.setItemText(Topics.timeCell, data[3].Value)'''
         # now write !
         cursor = Topics.table.createCursorByCellName("A" + str(firstRow))
         for i in Topics.topicCells:
-            i.write(Topics.table.getCellByName(cursor.RangeName))
+            self.write(Topics.table.getCellByName(cursor.RangeName))
             cursor.goRight(1, False)
         # now format !
         cursor.gotoCellByName("A" + str(firstRow), False)
diff --git a/wizards/com/sun/star/wizards/ui/ControlScroller.py b/wizards/com/sun/star/wizards/ui/ControlScroller.py
index 44c1957..219ffaa 100644
--- a/wizards/com/sun/star/wizards/ui/ControlScroller.py
+++ b/wizards/com/sun/star/wizards/ui/ControlScroller.py
@@ -52,19 +52,7 @@ class ControlScroller(object):
         self.nlineincrement = 1
         self.sincSuffix = Desktop.getIncrementSuffix(
             ControlScroller.CurUnoDialog.xDialogModel, "imgBackground")
-        self.oImgControl = ControlScroller.CurUnoDialog.insertControlModel(
-            "com.sun.star.awt.UnoControlImageControlModel",
-            "imgBackground" + self.sincSuffix,
-            ("Border", PropertyNames.PROPERTY_HEIGHT,
-                PropertyNames.PROPERTY_POSITION_X,
-                PropertyNames.PROPERTY_POSITION_Y,
-                PropertyNames.PROPERTY_STEP,
-                PropertyNames.PROPERTY_WIDTH),
-            (1, self.iCompHeight, self.iCompPosX,
-                self.iCompPosY, ControlScroller.iStep, self.iCompWidth))
-        self.oImgControl = ControlScroller.CurUnoDialog.xUnoDialog.getControl(
-            "imgBackground" + self.sincSuffix)
-        self.setComponentMouseTransparent()
+
         ControlScroller.xScrollBar = ControlScroller.CurUnoDialog.insertScrollBar(
             "TitleScrollBar" + self.sincSuffix,
             ("Border", PropertyNames.PROPERTY_ENABLED,
@@ -87,10 +75,6 @@ class ControlScroller(object):
             self.insertControlGroup(i, ypos)
             ypos += self.linedistance
 
-    def setComponentMouseTransparent(self):
-        ControlScroller.CurUnoDialog.getPeerConfiguration().\
-            setPeerProperties(self.oImgControl, "MouseTransparent", True)
-
     @classmethod
     def fillupControls(self, binitialize):
         for i in range(ControlScroller.nblockincrement):
@@ -115,7 +99,7 @@ class ControlScroller(object):
         if _ntotfieldcount is not None:
             self.setTotalFieldCount(_ntotfieldcount)
         if _nscrollvalue >= 0:
-            ControlScroller.xScrollBar.Model.ScrollValue = _nscrollvalue
+            ControlScroller.xScrollBar.xDialogModel.ScrollValue = _nscrollvalue
             self.scrollControls()
 
     @classmethod
@@ -209,8 +193,7 @@ class ControlScroller(object):
             controlname).Model
         propertyname = UnoDialog.getDisplayProperty(oControlModel)
         if propertyname:
-            print(type(controlname))
-            setattr(controlname, propertyname, newvalue)
+            setattr(oControlModel, propertyname, newvalue)
 
     @classmethod
     def getControlData(self, controlname):
@@ -218,7 +201,7 @@ class ControlScroller(object):
             controlname).Model
         propertyname = UnoDialog.getDisplayProperty(oControlModel)
         if propertyname:
-            return getattr(controlname, propertyname)
+            return getattr(oControlModel, propertyname)
         else:
             return None
 
commit be0dad06ddf15dc56163a07fa6b3f6a4fa44b6e4
Author: Xisco Fauli <anistenis at gmail.com>
Date:   Sun Jan 20 16:37:18 2013 +0100

    pyagenda: simplify UIDialog code
    
    Change-Id: I869d13c8b40f4c52e30a0a40c148fd2a5ef9d31c

diff --git a/wizards/com/sun/star/wizards/agenda/TopicsControl.py b/wizards/com/sun/star/wizards/agenda/TopicsControl.py
index b934a6a..4a72317 100644
--- a/wizards/com/sun/star/wizards/agenda/TopicsControl.py
+++ b/wizards/com/sun/star/wizards/agenda/TopicsControl.py
@@ -123,7 +123,6 @@ class TopicsControl(ControlScroller):
 
     '''
     initializes the data of the control.
-    @param agenda
     '''
 
     def initializeScrollFields(self, agenda):
diff --git a/wizards/com/sun/star/wizards/ui/ControlScroller.py b/wizards/com/sun/star/wizards/ui/ControlScroller.py
index 85325cd..44c1957 100644
--- a/wizards/com/sun/star/wizards/ui/ControlScroller.py
+++ b/wizards/com/sun/star/wizards/ui/ControlScroller.py
@@ -209,6 +209,7 @@ class ControlScroller(object):
             controlname).Model
         propertyname = UnoDialog.getDisplayProperty(oControlModel)
         if propertyname:
+            print(type(controlname))
             setattr(controlname, propertyname, newvalue)
 
     @classmethod
diff --git a/wizards/com/sun/star/wizards/ui/UIConsts.py b/wizards/com/sun/star/wizards/ui/UIConsts.py
index 64c4dee..edffd16 100644
--- a/wizards/com/sun/star/wizards/ui/UIConsts.py
+++ b/wizards/com/sun/star/wizards/ui/UIConsts.py
@@ -45,28 +45,3 @@ class UIConsts():
     SOGROUPFILTERPAGE = 6
     SOTITLESPAGE = 7
     SOSUMMARYPAGE = 8
-
-    class CONTROLTYPE():
-
-        BUTTON = 1
-        IMAGECONTROL = 2
-        LISTBOX = 3
-        COMBOBOX = 4
-        CHECKBOX = 5
-        RADIOBUTTON = 6
-        DATEFIELD = 7
-        EDITCONTROL = 8
-        FILECONTROL = 9
-        FIXEDLINE = 10
-        FIXEDTEXT = 11
-        FORMATTEDFIELD = 12
-        GROUPBOX = 13
-        HYPERTEXT = 14
-        NUMERICFIELD = 15
-        PATTERNFIELD = 16
-        PROGRESSBAR = 17
-        ROADMAP = 18
-        SCROLLBAR = 19
-        TIMEFIELD = 20
-        CURRENCYFIELD = 21
-        UNKNOWN = -1
diff --git a/wizards/com/sun/star/wizards/ui/UnoDialog.py b/wizards/com/sun/star/wizards/ui/UnoDialog.py
index a5b1d18..ca93e72 100644
--- a/wizards/com/sun/star/wizards/ui/UnoDialog.py
+++ b/wizards/com/sun/star/wizards/ui/UnoDialog.py
@@ -262,91 +262,56 @@ class UnoDialog(object):
         control.Model.Enabled = enabled
 
     @classmethod
-    def getControlModelType(self, xServiceInfo):
+    def getDisplayProperty(self, xServiceInfo):
         if xServiceInfo.supportsService(
                 "com.sun.star.awt.UnoControlFixedTextModel"):
-            return UIConsts.CONTROLTYPE.FIXEDTEXT
+            return PropertyNames.PROPERTY_LABEL
         elif xServiceInfo.supportsService(
                 "com.sun.star.awt.UnoControlButtonModel"):
-            return UIConsts.CONTROLTYPE.BUTTON
+            return PropertyNames.PROPERTY_LABEL
         elif xServiceInfo.supportsService(
                 "com.sun.star.awt.UnoControlCurrencyFieldModel"):
-            return UIConsts.CONTROLTYPE.CURRENCYFIELD
+            return "Value"
         elif xServiceInfo.supportsService(
                 "com.sun.star.awt.UnoControlDateFieldModel"):
-            return UIConsts.CONTROLTYPE.DATEFIELD
+            return "Date"
         elif xServiceInfo.supportsService(
                 "com.sun.star.awt.UnoControlFixedLineModel"):
-            return UIConsts.CONTROLTYPE.FIXEDLINE
+            return PropertyNames.PROPERTY_LABEL
         elif xServiceInfo.supportsService(
                 "com.sun.star.awt.UnoControlFormattedFieldModel"):
-            return UIConsts.CONTROLTYPE.FORMATTEDFIELD
-        elif xServiceInfo.supportsService(
-                "com.sun.star.awt.UnoControlRoadmapModel"):
-            return UIConsts.CONTROLTYPE.ROADMAP
+            return "EffectiveValue"
         elif xServiceInfo.supportsService(
                 "com.sun.star.awt.UnoControlNumericFieldModel"):
-            return UIConsts.CONTROLTYPE.NUMERICFIELD
+            return "Value"
         elif xServiceInfo.supportsService(
                 "com.sun.star.awt.UnoControlPatternFieldModel"):
-            return UIConsts.CONTROLTYPE.PATTERNFIELD
-        elif xServiceInfo.supportsService(
-                "com.sun.star.awt.UnoControlHyperTextModel"):
-            return UIConsts.CONTROLTYPE.HYPERTEXT
+            return "Text"
         elif xServiceInfo.supportsService(
                 "com.sun.star.awt.UnoControlProgressBarModel"):
-            return UIConsts.CONTROLTYPE.PROGRESSBAR
+            return "ProgressValue"
         elif xServiceInfo.supportsService(
                 "com.sun.star.awt.UnoControlTimeFieldModel"):
-            return UIConsts.CONTROLTYPE.TIMEFIELD
+            return "Time"
         elif xServiceInfo.supportsService(
                 "com.sun.star.awt.UnoControlImageControlModel"):
-            return UIConsts.CONTROLTYPE.IMAGECONTROL
+            return PropertyNames.PROPERTY_IMAGEURL
         elif xServiceInfo.supportsService(
                 "com.sun.star.awt.UnoControlRadioButtonModel"):
-            return UIConsts.CONTROLTYPE.RADIOBUTTON
+            return PropertyNames.PROPERTY_STATE
         elif xServiceInfo.supportsService(
                 "com.sun.star.awt.UnoControlCheckBoxModel"):
-            return UIConsts.CONTROLTYPE.CHECKBOX
+            return PropertyNames.PROPERTY_STATE
         elif xServiceInfo.supportsService(
                 "com.sun.star.awt.UnoControlEditModel"):
-            return UIConsts.CONTROLTYPE.EDITCONTROL
+            return "Text"
         elif xServiceInfo.supportsService(
                 "com.sun.star.awt.UnoControlComboBoxModel"):
-            return UIConsts.CONTROLTYPE.COMBOBOX
+            return "Text"
         elif xServiceInfo.supportsService(
                 "com.sun.star.awt.UnoControlListBoxModel"):
-            return UIConsts.CONTROLTYPE.LISTBOX
+            return "SelectedItems"
         else:
-            return UIConsts.CONTROLTYPE.UNKNOWN
-
-    @classmethod
-    def getDisplayProperty(self, oControlModel):
-        itype = self.getControlModelType(oControlModel)
-        if not UnoDialog.createDict:
-            UnoDialog.createDict = True
-            UnoDialog.dictProperties = {
-                UIConsts.CONTROLTYPE.FIXEDTEXT:PropertyNames.PROPERTY_LABEL,
-                UIConsts.CONTROLTYPE.BUTTON:PropertyNames.PROPERTY_LABEL,
-                UIConsts.CONTROLTYPE.FIXEDLINE:PropertyNames.PROPERTY_LABEL,
-                UIConsts.CONTROLTYPE.NUMERICFIELD:"Value",
-                UIConsts.CONTROLTYPE.CURRENCYFIELD:"Value",
-                UIConsts.CONTROLTYPE.FORMATTEDFIELD:"EffectiveValue",
-                UIConsts.CONTROLTYPE.DATEFIELD:"Date",
-                UIConsts.CONTROLTYPE.TIMEFIELD:"Time",
-                UIConsts.CONTROLTYPE.SCROLLBAR:"ScrollValue",
-                UIConsts.CONTROLTYPE.PROGRESSBAR:"ProgressValue",
-                UIConsts.CONTROLTYPE.IMAGECONTROL:PropertyNames.PROPERTY_IMAGEURL,
-                UIConsts.CONTROLTYPE.RADIOBUTTON:PropertyNames.PROPERTY_STATE,
-                UIConsts.CONTROLTYPE.CHECKBOX:PropertyNames.PROPERTY_STATE,
-                UIConsts.CONTROLTYPE.EDITCONTROL:"Text",
-                UIConsts.CONTROLTYPE.COMBOBOX:"Text",
-                UIConsts.CONTROLTYPE.PATTERNFIELD:"Text",
-                UIConsts.CONTROLTYPE.LISTBOX:"SelectedItems"
-            }
-        try:
-            return UnoDialog.dictProperties[itype]
-        except KeyError:
             return ""
 
     def addResourceHandler(self, _Unit, _Module):
commit 93bed66a1de719a7b2fb59445ff6847aaae6f1a9
Author: Xisco Fauli <anistenis at gmail.com>
Date:   Sat Jan 19 22:12:42 2013 +0100

    pyagenda: Fix a problem with template's sections
    
    Change-Id: Ifbd5ba9800c1b52b2f0ed929b8919ff60fc48120

diff --git a/wizards/com/sun/star/wizards/agenda/AgendaDocument.py b/wizards/com/sun/star/wizards/agenda/AgendaDocument.py
index 65ba21b..4a7e097 100644
--- a/wizards/com/sun/star/wizards/agenda/AgendaDocument.py
+++ b/wizards/com/sun/star/wizards/agenda/AgendaDocument.py
@@ -20,6 +20,7 @@ import traceback
 from ..text.TextElement import TextElement
 from ..text.TextDocument import TextDocument
 from ..text.TextSectionHandler import TextSectionHandler
+from ..common.FileAccess import FileAccess
 
 from datetime import date as dateTimeObject
 
@@ -87,6 +88,9 @@ class AgendaDocument(TextDocument):
         self.allItems = []
 
     def load(self, templateURL, topics):
+        #Each template is duplicated. aw-XXX.ott is the template itself
+        #and XXX.ott is a section link.
+        self.template = self.calcTemplateName(templateURL)
         self.loadAsPreview(templateURL, False)
         self.xFrame.ComponentWindow.Enable = False
         self.xTextDocument.lockControllers()
@@ -94,6 +98,16 @@ class AgendaDocument(TextDocument):
         self.initializeData(topics)
         self.xTextDocument.unlockControllers()
 
+    '''
+    The agenda templates are in format of aw-XXX.ott
+    the templates name is then XXX.ott.
+    This method calculates it.
+    '''
+
+    def calcTemplateName(self, url):
+        return FileAccess.connectURLs(
+            FileAccess.getParentDir(url), FileAccess.getFilename(url)[3:])
+        
     '''synchronize the document to the model.<br/>
     this method rewrites all titles, item tables , and the topics table-
     thus synchronizing the document to the data model (CGAgenda).
@@ -104,7 +118,7 @@ class AgendaDocument(TextDocument):
     def initializeData(self, topicsData):
         for i in self.itemsTables:
             try:
-                i.write("")
+                i.write()
             except Exception:
                 traceback.print_exc()
 
@@ -125,7 +139,7 @@ class AgendaDocument(TextDocument):
             # get the table in which the item is...
             itemsTable = self.itemsMap[itemName]
             # rewrite the table.
-            itemsTable.write(None)
+            itemsTable.write()
         except Exception:
             traceback.print_exc()
         self.xTextDocument.unlockControllers()
@@ -346,10 +360,10 @@ class AgendaDocument(TextDocument):
         return self.getNamesWhichStartWith(allSections, s)
 
     def getSection(self, name):
-        return getattr(self.xTextDocument.TextSections, name)
+        return self.xTextDocument.TextSections.getByName(name)
 
     def getTable(self, name):
-        return getattr(self.xTextDocument.TextTables, name)
+        return self.xTextDocument.TextTables.getByName(name)
 
     def redrawTitle(self, controlName):
         try:
@@ -652,19 +666,17 @@ class ItemsTable(object):
     then, starting at cell one, write all items that should be visible.
     then clear the rest and remove obsolete rows.
     If no items are visible, hide the section.
-    @param dummy we need a param to make this an Implementation
-    of AgendaElement.
-    @throws Exception
     '''
 
-    def write(self, dummy):
+    def write(self):
         name = self.section.Name
         # link and unlink the section to the template.
         self.agenda.textSectionHandler.linkSectiontoTemplate(
             self.agenda.template, name, self.section)
         self.agenda.textSectionHandler.breakLinkOfTextSection(
             self.section)
-        # we need to get a instance after linking.
+        # we need to get a instance after linking
+        
         ItemsTable.table = self.agenda.getTable(name)
         self.section = self.agenda.getSection(name)
         cursor = ItemsTable.table.createCursorByCellName("A1")
diff --git a/wizards/com/sun/star/wizards/common/FileAccess.py b/wizards/com/sun/star/wizards/common/FileAccess.py
index e78310c..fd7a97c 100644
--- a/wizards/com/sun/star/wizards/common/FileAccess.py
+++ b/wizards/com/sun/star/wizards/common/FileAccess.py
@@ -251,3 +251,13 @@ class FileAccess(object):
         while url[-1] == "/":
             url = hello[:-1]
         return url[:url.rfind("/")]
+
+    @classmethod
+    def connectURLs(self, urlFolder, urlFilename):
+        stringFolder = ""
+        stringFileName = urlFilename
+        if not urlFolder.endswith("/"):
+            stringFolder = "/"
+        if urlFilename.startswith("/"):
+            stringFileName = urlFilename[1:]
+        return urlFolder + stringFolder + stringFileName
diff --git a/wizards/com/sun/star/wizards/text/TextSectionHandler.py b/wizards/com/sun/star/wizards/text/TextSectionHandler.py
index 4a35fb4..8896539 100644
--- a/wizards/com/sun/star/wizards/text/TextSectionHandler.py
+++ b/wizards/com/sun/star/wizards/text/TextSectionHandler.py
@@ -85,22 +85,23 @@ class TextSectionHandler(object):
             oSectionLink = \
                 uno.createUnoStruct('com.sun.star.text.SectionFileLink')
             oSectionLink.FileURL = ""
-            oTextSection.FileLink = oSectionLink
-            oTextSection.LinkRegion =  ""
+            uno.invoke(oTextSection, "setPropertyValues",
+                (("FileLink", "LinkRegion"), (oSectionLink, "")))
         except Exception:
             traceback.print_exc()
 
     def linkSectiontoTemplate(
             self, TemplateName, SectionName, oTextSection=None):
         try:
-            if oTextSection is not None:
+            if not oTextSection:
                 oTextSection = self.xTextDocument.TextSections.getByName(
                     SectionName)
             oSectionLink = \
                 uno.createUnoStruct('com.sun.star.text.SectionFileLink')
             oSectionLink.FileURL = TemplateName
-            oTextSection.FileLink = oSectionLink
-            oTextSection.LinkRegion = SectionName
+            uno.invoke(oTextSection, "setPropertyValues",
+                (("FileLink", "LinkRegion"), (oSectionLink, SectionName)))
+
             NewSectionName = oTextSection.Name
             if NewSectionName is not SectionName:
                 oTextSection.Name = SectionName
diff --git a/wizards/com/sun/star/wizards/ui/ControlScroller.py b/wizards/com/sun/star/wizards/ui/ControlScroller.py
index e411503..85325cd 100644
--- a/wizards/com/sun/star/wizards/ui/ControlScroller.py
+++ b/wizards/com/sun/star/wizards/ui/ControlScroller.py
@@ -139,8 +139,7 @@ class ControlScroller(object):
     def toggleComponent(self, _bdoenable):
         bdoenable = _bdoenable and \
             (self.ntotfieldcount > ControlScroller.nblockincrement)
-        ControlScroller.CurUnoDialog.setControlProperty(
-                "TitleScrollBar" + self.sincSuffix,
+        setattr("TitleScrollBar" + self.sincSuffix,
                 PropertyNames.PROPERTY_ENABLED, bdoenable)
 
     def toggleControls(self, _bdoenable):
@@ -150,8 +149,8 @@ class ControlScroller(object):
             m = 0
             while m < curproperties.length:
                 curproperty = curproperties[m]
-                ControlScroller.CurUnoDialog.setControlProperty(
-                curproperty.Name, PropertyNames.PROPERTY_ENABLED, _bdoenable)
+                setattr(curproperty.Name, PropertyNames.PROPERTY_ENABLED,
+                    _bdoenable)
                 m += 1
             n += 1
 
@@ -209,18 +208,16 @@ class ControlScroller(object):
         oControlModel = ControlScroller.CurUnoDialog.xUnoDialog.getControl(
             controlname).Model
         propertyname = UnoDialog.getDisplayProperty(oControlModel)
-        if propertyname != "":
-            ControlScroller.CurUnoDialog.setControlProperty(
-                controlname, propertyname, newvalue)
+        if propertyname:
+            setattr(controlname, propertyname, newvalue)
 
     @classmethod
     def getControlData(self, controlname):
         oControlModel = ControlScroller.CurUnoDialog.xUnoDialog.getControl(
             controlname).Model
         propertyname = UnoDialog.getDisplayProperty(oControlModel)
-        if propertyname != "":
-            return ControlScroller.CurUnoDialog.getControlProperty(
-                controlname, propertyname)
+        if propertyname:
+            return getattr(controlname, propertyname)
         else:
             return None
 
commit c71a811bbddcb33f5296a2b21598cee2ea36e6f5
Author: Xisco Fauli <anistenis at gmail.com>
Date:   Fri Jan 18 21:45:04 2013 +0100

    pyagenda: Change to new model and remove unused code
    
    Change-Id: Ibdc1fb2fb09e5b209c761b7f9898ad019620b01d

diff --git a/wizards/com/sun/star/wizards/agenda/AgendaDocument.py b/wizards/com/sun/star/wizards/agenda/AgendaDocument.py
index 54be369..65ba21b 100644
--- a/wizards/com/sun/star/wizards/agenda/AgendaDocument.py
+++ b/wizards/com/sun/star/wizards/agenda/AgendaDocument.py
@@ -19,7 +19,6 @@ import uno
 import traceback
 from ..text.TextElement import TextElement
 from ..text.TextDocument import TextDocument
-from ..common.FileAccess import FileAccess
 from ..text.TextSectionHandler import TextSectionHandler
 
 from datetime import date as dateTimeObject
@@ -71,7 +70,7 @@ Many methods here are synchronized, in order to avoid colission made by
 events fired too often.
 @author rpiterman
 '''
-class AgendaTemplate(TextDocument):
+class AgendaDocument(TextDocument):
 
     '''
     constructor. The document is *not* loaded here.
@@ -79,7 +78,7 @@ class AgendaTemplate(TextDocument):
     '''
 
     def __init__(self,  xmsf, agenda, resources, templateConsts, listener):
-        super(AgendaTemplate,self).__init__(xmsf,listener, None,
+        super(AgendaDocument,self).__init__(xmsf,listener, None,
             "WIZARD_LIVE_PREVIEW")
         self.agenda = agenda
         self.templateConsts = templateConsts
@@ -88,7 +87,6 @@ class AgendaTemplate(TextDocument):
         self.allItems = []
 
     def load(self, templateURL, topics):
-        self.template = self.calcTemplateName(templateURL)
         self.loadAsPreview(templateURL, False)
         self.xFrame.ComponentWindow.Enable = False
         self.xTextDocument.lockControllers()
@@ -96,16 +94,6 @@ class AgendaTemplate(TextDocument):
         self.initializeData(topics)
         self.xTextDocument.unlockControllers()
 
-    '''
-    The agenda templates are in format of aw-XXX.ott
-    the templates name is then XXX.ott.
-    This method calculates it.
-    '''
-
-    def calcTemplateName(self, url):
-        return FileAccess.connectURLs(
-            FileAccess.getParentDir(url), FileAccess.getFilename(url)[3:])
-
     '''synchronize the document to the model.<br/>
     this method rewrites all titles, item tables , and the topics table-
     thus synchronizing the document to the data model (CGAgenda).
@@ -279,13 +267,13 @@ class AgendaTemplate(TextDocument):
         Get the default locale of the document,
         and create the date and time formatters.
         '''
-        AgendaTemplate.dateUtils = self.DateUtils(
+        AgendaDocument.dateUtils = self.DateUtils(
             self.xMSF, self.xTextDocument)
-        AgendaTemplate.formatter = AgendaTemplate.dateUtils.formatter
-        AgendaTemplate.dateFormat = \
-            AgendaTemplate.dateUtils.getFormat(DATE_SYSTEM_LONG)
-        AgendaTemplate.timeFormat = \
-            AgendaTemplate.dateUtils.getFormat(TIME_HHMM)
+        AgendaDocument.formatter = AgendaDocument.dateUtils.formatter
+        AgendaDocument.dateFormat = \
+            AgendaDocument.dateUtils.getFormat(DATE_SYSTEM_LONG)
+        AgendaDocument.timeFormat = \
+            AgendaDocument.dateUtils.getFormat(TIME_HHMM)
 
         self.initItemsCache()
         self.allItems = self.searchFillInItems(0)
@@ -305,29 +293,29 @@ class AgendaTemplate(TextDocument):
         for i in self.allItems:
             text = i.String.lstrip().lower()
             if text == self.templateConsts.FILLIN_TITLE:
-                AgendaTemplate.teTitle = PlaceholderTextElement(
+                AgendaDocument.teTitle = PlaceholderTextElement(
                     i, self.resources.resPlaceHolderTitle,
                     self.resources.resPlaceHolderHint,
                     self.xTextDocument)
-                AgendaTemplate.trTitle = i
+                AgendaDocument.trTitle = i
             elif text == self.templateConsts.FILLIN_DATE:
-                AgendaTemplate.teDate = PlaceholderTextElement(
+                AgendaDocument.teDate = PlaceholderTextElement(
                     i, self.resources.resPlaceHolderDate,
                     self.resources.resPlaceHolderHint,
                     self.xTextDocument)
-                AgendaTemplate.trDate = i
+                AgendaDocument.trDate = i
             elif text == self.templateConsts.FILLIN_TIME:
-                AgendaTemplate.teTime = PlaceholderTextElement(
+                AgendaDocument.teTime = PlaceholderTextElement(
                     i, self.resources.resPlaceHolderTime,
                     self.resources.resPlaceHolderHint,
                     self.xTextDocument)
-                AgendaTemplate.trTime = i
+                AgendaDocument.trTime = i
             elif text == self.templateConsts.FILLIN_LOCATION:
-                AgendaTemplate.teLocation = PlaceholderTextElement(
+                AgendaDocument.teLocation = PlaceholderTextElement(
                     i, self.resources.resPlaceHolderLocation,
                     self.resources.resPlaceHolderHint,
                     self.xTextDocument)
-                AgendaTemplate.trLocation = i
+                AgendaDocument.trLocation = i
             else:
                 auxList.append(i)
         self.allItems = auxList
@@ -367,19 +355,19 @@ class AgendaTemplate(TextDocument):
         try:
             if controlName == "txtTitle":
                 self.writeTitle(
-                    AgendaTemplate.teTitle, AgendaTemplate.trTitle,
+                    AgendaDocument.teTitle, AgendaDocument.trTitle,
                     self.agenda.cp_Title)
             elif controlName == "txtDate":
                 self.writeTitle(
-                    AgendaTemplate.teDate, AgendaTemplate.trDate,
+                    AgendaDocument.teDate, AgendaDocument.trDate,
                     self.getDateString(self.agenda.cp_Date))
             elif controlName == "txtTime":
                 self.writeTitle(
-                    AgendaTemplate.teTime, AgendaTemplate.trTime,
+                    AgendaDocument.teTime, AgendaDocument.trTime,
                     self.getTimeString(self.agenda.cp_Time))
             elif controlName == "cbLocation":
                 self.writeTitle(
-                    AgendaTemplate.teLocation, AgendaTemplate.trLocation,
+                    AgendaDocument.teLocation, AgendaDocument.trLocation,
                     self.agenda.cp_Location)
             else:
                 raise IllegalArgumentException ("No such title control...")
@@ -403,8 +391,8 @@ class AgendaTemplate(TextDocument):
         month = int((date % 10000) / 100)
         day = int(date % 100)
         dateObject = dateTimeObject(year, month, day)
-        return AgendaTemplate.dateUtils.format(
-            AgendaTemplate.dateFormat, dateObject)
+        return AgendaDocument.dateUtils.format(
+            AgendaDocument.dateFormat, dateObject)
 
     @classmethod
     def getTimeString(self, s):
@@ -414,7 +402,7 @@ class AgendaTemplate(TextDocument):
         t = ((time / float(1000000)) / float(24)) \
             + ((time % 1000000) / float(1000000)) / float(35)
         return self.formatter.convertNumberToString(
-            AgendaTemplate.timeFormat, t)
+            AgendaDocument.timeFormat, t)
 
     def finish(self, topics):
         self.createMinutes(topics)
@@ -739,8 +727,8 @@ class ItemsTable(object):
         if cellName == cursor.RangeName:
             return
 
-        rowIndex = AgendaTemplate.getRowIndex(cursor)
-        rowsCount = AgendaTemplate.getRowCount(ItemsTable.table)
+        rowIndex = AgendaDocument.getRowIndex(cursor)
+        rowsCount = AgendaDocument.getRowCount(ItemsTable.table)
         '''
         now before deleteing i move the cursor up so it
         does not disappear, because it will crash office.
@@ -756,7 +744,7 @@ the update is done programttically.<br/>
 The decision to make this class a class by its own
 was done out of logic reasons and not design/functionality reasons,
 since there is anyway only one instance of this class at runtime
-it could have also be implemented in the AgendaTemplate class
+it could have also be implemented in the AgendaDocument class
 but for clarity and separation I decided to make a sub class for it.
 
 @author rp143992
@@ -1093,7 +1081,7 @@ class PlaceholderTextElement(TextElement):
         textRange.String = self.placeHolderText
         if self.placeHolderText is None or self.placeHolderText == "":
             try:
-                xTextContent = AgendaTemplate.createPlaceHolder(
+                xTextContent = AgendaDocument.createPlaceHolder(
                     self.xmsf, self.text, self.hint)
                 textRange.Text.insertTextContent(
                     textRange.Start, xTextContent, True)
@@ -1115,7 +1103,7 @@ class PlaceholderElement(object):
 
     def write(self, textRange):
         try:
-            xTextContent = AgendaTemplate.createPlaceHolder(
+            xTextContent = AgendaDocument.createPlaceHolder(
                 self.textDocument, self.placeHolderText, self.hint)
             textRange.Text.insertTextContent(
                 textRange.Start, xTextContent, True)
diff --git a/wizards/com/sun/star/wizards/agenda/AgendaWizardDialogImpl.py b/wizards/com/sun/star/wizards/agenda/AgendaWizardDialogImpl.py
index dc136af..5d641c6 100644
--- a/wizards/com/sun/star/wizards/agenda/AgendaWizardDialogImpl.py
+++ b/wizards/com/sun/star/wizards/agenda/AgendaWizardDialogImpl.py
@@ -18,7 +18,7 @@
 import traceback
 from .AgendaWizardDialog import AgendaWizardDialog, uno
 from .AgendaWizardDialogConst import HID
-from .AgendaDocument import AgendaTemplate, FileAccess
+from .AgendaDocument import AgendaDocument
 from .TemplateConsts import TemplateConsts
 from .TopicsControl import TopicsControl
 from .CGAgenda import CGAgenda
@@ -30,6 +30,7 @@ from ..common.SystemDialog import SystemDialog
 from ..common.Desktop import Desktop
 from ..common.HelpIds import HelpIds
 from ..common.Configuration import Configuration
+from ..common.FileAccess import FileAccess
 from ..document.OfficeDocument import OfficeDocument
 
 from com.sun.star.view.DocumentZoomType import OPTIMAL
@@ -74,7 +75,7 @@ class AgendaWizardDialogImpl(AgendaWizardDialog):
             self.agenda = CGAgenda()
             
             self.templateConsts = TemplateConsts
-            self.agendaTemplate = AgendaTemplate(
+            self.agendaTemplate = AgendaDocument(
                 self.xMSF, self.agenda, self.resources,
                 self.templateConsts, self)
 
diff --git a/wizards/com/sun/star/wizards/common/FileAccess.py b/wizards/com/sun/star/wizards/common/FileAccess.py
index fd7a97c..e78310c 100644
--- a/wizards/com/sun/star/wizards/common/FileAccess.py
+++ b/wizards/com/sun/star/wizards/common/FileAccess.py
@@ -251,13 +251,3 @@ class FileAccess(object):
         while url[-1] == "/":
             url = hello[:-1]
         return url[:url.rfind("/")]
-
-    @classmethod
-    def connectURLs(self, urlFolder, urlFilename):
-        stringFolder = ""
-        stringFileName = urlFilename
-        if not urlFolder.endswith("/"):
-            stringFolder = "/"
-        if urlFilename.startswith("/"):
-            stringFileName = urlFilename[1:]
-        return urlFolder + stringFolder + stringFileName
commit 0d9683c756390d188b76b2803ee2621d3f4b0f0f
Author: Xisco Fauli <anistenis at gmail.com>
Date:   Fri Jan 18 19:36:44 2013 +0100

    pyagenda: follow same model as in fax and letter wizards
    
    Change-Id: I3e6265f80481995399f22d40df344cc1e55e2148

diff --git a/wizards/com/sun/star/wizards/agenda/AgendaDocument.py b/wizards/com/sun/star/wizards/agenda/AgendaDocument.py
new file mode 100644
index 0000000..54be369
--- /dev/null
+++ b/wizards/com/sun/star/wizards/agenda/AgendaDocument.py
@@ -0,0 +1,1149 @@
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+# This file incorporates work covered by the following license notice:
+#
+#   Licensed to the Apache Software Foundation (ASF) under one or more
+#   contributor license agreements. See the NOTICE file distributed
+#   with this work for additional information regarding copyright
+#   ownership. The ASF licenses this file to you under the Apache
+#   License, Version 2.0 (the "License"); you may not use this file
+#   except in compliance with the License. You may obtain a copy of
+#   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+#
+import uno
+import traceback
+from ..text.TextElement import TextElement
+from ..text.TextDocument import TextDocument
+from ..common.FileAccess import FileAccess
+from ..text.TextSectionHandler import TextSectionHandler
+
+from datetime import date as dateTimeObject
+
+from com.sun.star.text.PlaceholderType import TEXT
+from com.sun.star.i18n.NumberFormatIndex import TIME_HHMM, DATE_SYSTEM_LONG
+
+'''
+The classes here implement the whole document-functionality of the agenda wizard:
+the live-preview and the final "creation" of the document,
+when the user clicks "finish". <br/>
+<br/>
+<h2>Some terminology:<h2/>
+items are names or headings. we don't make any distinction.
+
+<br/>
+The Agenda Template is used as general "controller"
+of the whole document, whereas the two child-classes ItemsTable
+and TopicsTable control the item tables (note plural!) and the
+topics table (note singular).<br/>
+<br/>
+Other small classes are used to abstract the handling of cells and text and we
+try to use them as components.
+<br/><br/>
+We tried to keep the Agenda Template as flexible as possible, though there
+must be many limitations, because it is generated dynamically.<br/><br/>
+To keep the template flexible the following decisions were made:<br/>
+1. Item tables.<br/>
+1.a. there might be arbitrary number of Item tables.<br/>
+1.b. Item tables design (bordewr, background) is arbitrary.<br/>
+1.c. Items text styles are individual,
+and use stylelist styles with predefined names.<br/>
+As result the following limitations:<br/>
+Pairs of Name->value for each item.<br/>
+Tables contain *only* those pairs.<br/>
+2. Topics table.<br/>
+2.a. arbitrary structure.<br/>
+2.b. design is arbitrary.<br/>
+As result the following limitations:<br/>
+No column merge is allowed.<br/>
+One compolsary Heading row.<br/>
+<br/><br/>
+To let the template be flexible, we use a kind of "detection": we look where
+the items are read the design of each table, reaplying it after writing the
+table.self.xTextDocument
+<br/><br/>
+A note about threads:<br/>
+Many methods here are synchronized, in order to avoid colission made by
+events fired too often.
+ at author rpiterman
+'''
+class AgendaTemplate(TextDocument):
+
+    '''
+    constructor. The document is *not* loaded here.
+    only some formal members are set.
+    '''
+
+    def __init__(self,  xmsf, agenda, resources, templateConsts, listener):
+        super(AgendaTemplate,self).__init__(xmsf,listener, None,
+            "WIZARD_LIVE_PREVIEW")
+        self.agenda = agenda
+        self.templateConsts = templateConsts
+        self.resources = resources
+        self.itemsMap = {}
+        self.allItems = []
+
+    def load(self, templateURL, topics):
+        self.template = self.calcTemplateName(templateURL)
+        self.loadAsPreview(templateURL, False)
+        self.xFrame.ComponentWindow.Enable = False
+        self.xTextDocument.lockControllers()
+        self.initialize()
+        self.initializeData(topics)
+        self.xTextDocument.unlockControllers()
+
+    '''
+    The agenda templates are in format of aw-XXX.ott
+    the templates name is then XXX.ott.
+    This method calculates it.
+    '''
+
+    def calcTemplateName(self, url):
+        return FileAccess.connectURLs(
+            FileAccess.getParentDir(url), FileAccess.getFilename(url)[3:])
+
+    '''synchronize the document to the model.<br/>
+    this method rewrites all titles, item tables , and the topics table-
+    thus synchronizing the document to the data model (CGAgenda).
+    information (it is only actualized on save) the given list
+    supplies this information.
+    '''
+
+    def initializeData(self, topicsData):
+        for i in self.itemsTables:
+            try:
+                i.write("")
+            except Exception:
+                traceback.print_exc()
+
+        self.redrawTitle("txtTitle")
+        self.redrawTitle("txtDate")
+        self.redrawTitle("txtTime")
+        self.redrawTitle("cbLocation")
+
+    '''
+    redraws/rewrites the table which contains the given item
+    This method is called when the user checks/unchecks an item.
+    The table is being found, in which the item is, and redrawn.
+    '''
+
+    def redraw(self, itemName):
+        self.xTextDocument.lockControllers()
+        try:
+            # get the table in which the item is...
+            itemsTable = self.itemsMap[itemName]
+            # rewrite the table.
+            itemsTable.write(None)
+        except Exception:
+            traceback.print_exc()
+        self.xTextDocument.unlockControllers()
+
+    '''
+    checks the data model if the
+    item corresponding to the given string should be shown
+    '''
+
+    def isShowItem(self, itemName):
+        if itemName == self.templateConsts.FILLIN_MEETING_TYPE:
+            return self.agenda.cp_ShowMeetingType
+        elif itemName == self.templateConsts.FILLIN_READ:
+            return self.agenda.cp_ShowRead
+        elif itemName == self.templateConsts.FILLIN_BRING:
+            return self.agenda.cp_ShowBring
+        elif itemName == self.templateConsts.FILLIN_NOTES:
+            return self.agenda.cp_ShowNotes
+        elif itemName == self.templateConsts.FILLIN_FACILITATOR:
+            return self.agenda.cp_ShowFacilitator
+        elif itemName == self.templateConsts.FILLIN_TIMEKEEPER:
+            return self.agenda.cp_ShowTimekeeper
+        elif itemName == self.templateConsts.FILLIN_NOTETAKER:
+            return self.agenda.cp_ShowNotetaker
+        elif itemName == self.templateConsts.FILLIN_PARTICIPANTS:
+            return self.agenda.cp_ShowAttendees
+        elif itemName == self.templateConsts.FILLIN_CALLED_BY:
+            return self.agenda.cp_ShowCalledBy
+        elif itemName == self.templateConsts.FILLIN_OBSERVERS:
+            return self.agenda.cp_ShowObservers
+        elif itemName == self.templateConsts.FILLIN_RESOURCE_PERSONS:
+            return self.agenda.cp_ShowResourcePersons
+        else:
+            raise ValueError("No such item")
+
+    '''itemsCache is a Map containing all agenda item. These are object which
+    "write themselfs" to the table, given a table cursor.
+    A cache is used in order to reuse the objects, instead of recreate them.
+    This method fills the cache will all items objects (names and headings).
+    '''
+
+    def initItemsCache(self):
+        self.itemsCache = {}
+        # Headings
+        self.itemsCache[
+                self.templateConsts.FILLIN_MEETING_TYPE] = \
+            AgendaItem(self.templateConsts.FILLIN_MEETING_TYPE,
+                self.resources.itemMeetingType,
+                PlaceholderElement(
+                    self.resources.reschkMeetingTitle_value,
+                    self.resources.resPlaceHolderHint, self.xTextDocument))
+        self.itemsCache[
+                self.templateConsts.FILLIN_BRING] = \
+            AgendaItem(self.templateConsts.FILLIN_BRING,
+                self.resources.itemBring,
+                PlaceholderElement (
+                    self.resources.reschkBring_value,
+                    self.resources.resPlaceHolderHint, self.xTextDocument))
+        self.itemsCache[
+                self.templateConsts.FILLIN_READ] = \
+            AgendaItem (self.templateConsts.FILLIN_READ, 
+                self.resources.itemRead,
+                PlaceholderElement (
+                    self.resources.reschkRead_value,
+                    self.resources.resPlaceHolderHint, self.xTextDocument))
+        self.itemsCache[
+                self.templateConsts.FILLIN_NOTES] = \
+            AgendaItem (self.templateConsts.FILLIN_NOTES,
+                self.resources.itemNote,
+                PlaceholderElement (
+                    self.resources.reschkNotes_value,
+                    self.resources.resPlaceHolderHint, self.xTextDocument))
+
+        # Names
+        self.itemsCache[
+                self.templateConsts.FILLIN_CALLED_BY] = \
+            AgendaItem(self.templateConsts.FILLIN_CALLED_BY,
+                self.resources.itemCalledBy,
+                PlaceholderElement (
+                    self.resources.reschkConvenedBy_value,
+                    self.resources.resPlaceHolderHint, self.xTextDocument))
+        self.itemsCache[
+                self.templateConsts.FILLIN_FACILITATOR] = \
+            AgendaItem(self.templateConsts.FILLIN_FACILITATOR,
+                self.resources.itemFacilitator,
+                PlaceholderElement (
+                    self.resources.reschkPresiding_value,
+                    self.resources.resPlaceHolderHint, self.xTextDocument))
+        self.itemsCache[
+                self.templateConsts.FILLIN_PARTICIPANTS] = \
+            AgendaItem(self.templateConsts.FILLIN_PARTICIPANTS,
+                self.resources.itemAttendees,
+                PlaceholderElement(
+                    self.resources.reschkAttendees_value,
+                    self.resources.resPlaceHolderHint, self.xTextDocument))
+        self.itemsCache[
+                self.templateConsts.FILLIN_NOTETAKER] = \
+            AgendaItem(self.templateConsts.FILLIN_NOTETAKER,
+                self.resources.itemNotetaker,
+                PlaceholderElement(
+                    self.resources.reschkNoteTaker_value,
+                    self.resources.resPlaceHolderHint, self.xTextDocument))
+        self.itemsCache[
+                self.templateConsts.FILLIN_TIMEKEEPER] = \
+            AgendaItem(self.templateConsts.FILLIN_TIMEKEEPER,
+                self.resources.itemTimekeeper,
+                PlaceholderElement(
+                    self.resources.reschkTimekeeper_value,
+                    self.resources.resPlaceHolderHint, self.xTextDocument))
+        self.itemsCache[
+                self.templateConsts.FILLIN_OBSERVERS] = \
+            AgendaItem(self.templateConsts.FILLIN_OBSERVERS,
+                self.resources.itemObservers,
+                PlaceholderElement(
+                    self.resources.reschkObservers_value,
+                    self.resources.resPlaceHolderHint, self.xTextDocument))
+        self.itemsCache[
+                self.templateConsts.FILLIN_RESOURCE_PERSONS] = \
+            AgendaItem(self.templateConsts.FILLIN_RESOURCE_PERSONS,
+                self.resources.itemResource,
+                PlaceholderElement(
+                    self.resources.reschkResourcePersons_value,
+                    self.resources.resPlaceHolderHint, self.xTextDocument))
+
+    '''Initializes a template.<br/>
+    This method does the following tasks:<br/>
+    Get a Time and Date format for the document, and retrieve the null
+    date of the document (which is document-specific).<br/>
+    Initializes the Items Cache map.
+    Analyses the document:<br/>
+    -find all "fille-ins" (apear as >xxx< in the document).
+    -analyze all items sections (and the tables in them).
+    -locate the titles and actualize them
+    -analyze the topics table
+    '''
+
+    def initialize(self):
+        '''
+        Get the default locale of the document,
+        and create the date and time formatters.
+        '''
+        AgendaTemplate.dateUtils = self.DateUtils(
+            self.xMSF, self.xTextDocument)
+        AgendaTemplate.formatter = AgendaTemplate.dateUtils.formatter
+        AgendaTemplate.dateFormat = \
+            AgendaTemplate.dateUtils.getFormat(DATE_SYSTEM_LONG)
+        AgendaTemplate.timeFormat = \
+            AgendaTemplate.dateUtils.getFormat(TIME_HHMM)
+
+        self.initItemsCache()
+        self.allItems = self.searchFillInItems(0)
+        self.initializeTitles()
+        self.initializeItemsSections()
+        self.textSectionHandler = TextSectionHandler(
+            self.xTextDocument, self.xTextDocument)
+        self.topics = Topics(self)
+
+    '''
+    locates the titles (name, location, date, time)
+    and saves a reference to thier Text ranges.
+    '''
+
+    def initializeTitles(self):
+        auxList = []
+        for i in self.allItems:
+            text = i.String.lstrip().lower()
+            if text == self.templateConsts.FILLIN_TITLE:
+                AgendaTemplate.teTitle = PlaceholderTextElement(
+                    i, self.resources.resPlaceHolderTitle,
+                    self.resources.resPlaceHolderHint,
+                    self.xTextDocument)
+                AgendaTemplate.trTitle = i
+            elif text == self.templateConsts.FILLIN_DATE:
+                AgendaTemplate.teDate = PlaceholderTextElement(
+                    i, self.resources.resPlaceHolderDate,
+                    self.resources.resPlaceHolderHint,
+                    self.xTextDocument)
+                AgendaTemplate.trDate = i
+            elif text == self.templateConsts.FILLIN_TIME:
+                AgendaTemplate.teTime = PlaceholderTextElement(
+                    i, self.resources.resPlaceHolderTime,
+                    self.resources.resPlaceHolderHint,
+                    self.xTextDocument)
+                AgendaTemplate.trTime = i
+            elif text == self.templateConsts.FILLIN_LOCATION:
+                AgendaTemplate.teLocation = PlaceholderTextElement(
+                    i, self.resources.resPlaceHolderLocation,
+                    self.resources.resPlaceHolderHint,
+                    self.xTextDocument)
+                AgendaTemplate.trLocation = i
+            else:
+                auxList.append(i)
+        self.allItems = auxList
+
+    '''
+    analyze the item sections in the template.
+    delegates the analyze of each table to the ItemsTable class.
+    '''
+
+    def initializeItemsSections(self):
+        sections = self.getSections(
+        self.xTextDocument, self.templateConsts.SECTION_ITEMS)
+        # for each section - there is a table...
+        self.itemsTables = []
+        for i in sections:
+            try:
+                self.itemsTables.append(
+                    ItemsTable(self.getSection(i), self.getTable(i), self))
+            except Exception:
+                traceback.print_exc()
+                raise AttributeError (
+                    "Fatal Error while initialilzing \
+                    Template: items table in section " + i)
+
+
+    def getSections(self, document, s):
+        allSections = document.TextSections.ElementNames
+        return self.getNamesWhichStartWith(allSections, s)
+
+    def getSection(self, name):
+        return getattr(self.xTextDocument.TextSections, name)
+
+    def getTable(self, name):
+        return getattr(self.xTextDocument.TextTables, name)
+
+    def redrawTitle(self, controlName):
+        try:
+            if controlName == "txtTitle":
+                self.writeTitle(
+                    AgendaTemplate.teTitle, AgendaTemplate.trTitle,
+                    self.agenda.cp_Title)
+            elif controlName == "txtDate":
+                self.writeTitle(
+                    AgendaTemplate.teDate, AgendaTemplate.trDate,
+                    self.getDateString(self.agenda.cp_Date))
+            elif controlName == "txtTime":
+                self.writeTitle(
+                    AgendaTemplate.teTime, AgendaTemplate.trTime,
+                    self.getTimeString(self.agenda.cp_Time))
+            elif controlName == "cbLocation":
+                self.writeTitle(
+                    AgendaTemplate.teLocation, AgendaTemplate.trLocation,
+                    self.agenda.cp_Location)
+            else:
+                raise IllegalArgumentException ("No such title control...")
+        except Exception:
+            traceback.print_exc()
+
+    @classmethod
+    def writeTitle(self, te, tr, text):
+        if text is None:
+            te.placeHolderText = ""
+        else:
+            te.placeHolderText = text
+        te.write(tr)
+
+    @classmethod
+    def getDateString(self, d):
+        if d is None or d == "":
+            return ""
+        date = int(d)
+        year = int(date / 10000)
+        month = int((date % 10000) / 100)
+        day = int(date % 100)
+        dateObject = dateTimeObject(year, month, day)
+        return AgendaTemplate.dateUtils.format(
+            AgendaTemplate.dateFormat, dateObject)
+
+    @classmethod
+    def getTimeString(self, s):
+        if s is None or s == "":
+            return ""
+        time = int(s)
+        t = ((time / float(1000000)) / float(24)) \
+            + ((time % 1000000) / float(1000000)) / float(35)
+        return self.formatter.convertNumberToString(
+            AgendaTemplate.timeFormat, t)
+
+    def finish(self, topics):
+        self.createMinutes(topics)
+        self.deleteHiddenSections()
+        self.textSectionHandler.removeAllTextSections()
+
+    '''
+    hidden sections exist when an item's section is hidden because the
+    user specified not to display any items which it contains.
+    When finishing the wizard removes this sections
+    entirely from the document.
+    '''
+
+    def deleteHiddenSections(self):
+        allSections = self.xTextDocument.TextSections.ElementNames
+        try:
+            for i in allSections:
+                self.section = self.getSection(i)
+                visible = bool(self.section.IsVisible)
+                if not visible:
+                    self.section.Anchor.String = ""
+
+        except Exception:
+            traceback.print_exc()
+
+    '''
+    create the minutes for the given topics or remove the minutes
+    section from the document.
+    If no topics are supplied, or the user specified not to create minuts,
+    the minutes section will be removed,
+    @param topicsData supplies PropertyValue arrays containing
+    the values for the topics.
+    '''
+
+    def createMinutes(self, topicsData):
+        # if the minutes section should be removed (the
+        # user did not check "create minutes")
+        if not self.agenda.cp_IncludeMinutes \
+                or len(topicsData) <= 1:
+            try:
+                minutesAllSection = self.getSection(
+                    self.templateConsts.SECTION_MINUTES_ALL)
+                minutesAllSection.Anchor.String = ""
+            except Exception:
+                traceback.print_exc()
+
+        # the user checked "create minutes"
+        else:
+            try:
+                topicStartTime = int(self.agenda.cp_Time)
+                #first I replace the minutes titles...
+                self.items = self.searchFillInItems()
+                itemIndex = 0
+                for item in self.items:
+                    itemText = item.String.lstrip().lower()
+                    if itemText == \
+                            self.templateConsts.FILLIN_MINUTES_TITLE:
+                        self.fillMinutesItem(
+                            item, self.agenda.cp_Title,
+                            self.resources.resPlaceHolderTitle)
+                    elif itemText == \
+                            self.templateConsts.FILLIN_MINUTES_LOCATION:
+                        self.fillMinutesItem(
+                            item, self.agenda.cp_Location,
+                            self.resources.resPlaceHolderLocation)
+                    elif itemText == \
+                            self.templateConsts.FILLIN_MINUTES_DATE:
+                        self.fillMinutesItem(
+                            item, getDateString(self.agenda.cp_Date),
+                            self.resources.resPlaceHolderDate)
+                    elif itemText == \
+                            self.templateConsts.FILLIN_MINUTES_TIME:
+                        self.fillMinutesItem(
+                            item, getTimeString(self.agenda.cp_Time),
+                            self.resources.resPlaceHolderTime)
+
+                self.items.clear()
+                '''
+                now add minutes for each topic.
+                The template contains *one* minutes section, so
+                we first use the one available, and then add a one...
+                topics data has *always* an empty topic at the end...
+                '''
+
+                for i in xrange(len(topicsData) - 1):
+                    topic = topicsData[i]
+                    items = self.searchFillInItems()
+                    itemIndex = 0
+                    for item in items:
+                        itemText = item.String.lstrip().lower()
+                        if itemText == \
+                                self.templateConsts.FILLIN_MINUTE_NUM:
+                            fillMinutesItem(item, topic[0].Value, "")
+                        elif itemText == \
+                                self.templateConsts.FILLIN_MINUTE_TOPIC:
+                            fillMinutesItem(item, topic[1].Value, "")
+                        elif itemText == \
+                                self.templateConsts.FILLIN_MINUTE_RESPONSIBLE:
+                            fillMinutesItem(item, topic[2].Value, "")
+                        elif itemText == \
+                                self.templateConsts.FILLIN_MINUTE_TIME:
+                            topicTime = 0
+                            try:
+                                topicTime = topic[3].Value
+                            except Exception:
+                                pass
+
+                            '''
+                            if the topic has no time, we do not
+                            display any time here.
+                            '''
+                            if topicTime == 0 or topicStartTime == 0:
+                                time = topic[3].Value
+                            else:
+                                time = getTimeString(str(topicStartTime)) + " - "
+                                topicStartTime += topicTime * 1000
+                                time += getTimeString(str(topicStartTime))
+
+                            fillMinutesItem(item, time, "")
+
+                    self.textSectionHandler.removeTextSectionbyName(
+                        self.templateConsts.SECTION_MINUTES)
+                    # after the last section we do not insert a one.
+                    if i < len(topicsData) - 2:
+                        self.textSectionHandler.insertTextSection(
+                            self.templateConsts.SECTION_MINUTES,
+                            self.template, False)
+
+            except Exception:
+                traceback.print_exc()
+
+    '''given a text range and a text, fills the given
+    text range with the given text.
+    If the given text is empty, uses a placeholder with the giveb
+    placeholder text.
+    @param range text range to fill
+    @param text the text to fill to the text range object.
+    @param placeholder the placeholder text to use, if the
+    text argument is empty (null or "")
+    '''
+
+    def fillMinutesItem(self, Range, text, placeholder):
+        paraStyle = Range.ParaStyleName
+        Range.setString(text)
+        Range.ParaStyleName = paraStyle
+        if text is None or text == "":
+            if placeholder is not None and not placeholder == "":
+                placeHolder = createPlaceHolder(
+                    self.xTextDocument, placeholder,
+                    self.resources.resPlaceHolderHint)
+                try:
+                    Range.Start.Text.insertTextContent(
+                        Range.Start, placeHolder, True)
+                except Exception:
+                    traceback.print_exc()
+
+    '''
+    creates a placeholder field with the given text and given hint.
+    '''
+
+    @classmethod
+    def createPlaceHolder(self, xmsf, ph, hint):
+        try:
+            placeHolder =  xmsf.createInstance(
+                "com.sun.star.text.TextField.JumpEdit")
+        except Exception:
+            traceback.print_exc()
+            return None
+
+        placeHolder.PlaceHolder = ph
+        placeHolder.Hint = hint
+        placeHolder.PlaceHolderType = uno.Any("short",TEXT)
+        return placeHolder
+
+    def getNamesWhichStartWith(self, allNames, prefix):
+        v = []
+        for i in allNames:
+            if i.startswith(prefix):
+                v.append(i)
+        return v
+
+    '''
+    Convenience method for inserting some cells into a table.
+    '''
+
+    @classmethod
+    def insertTableRows(self, table, start, count):
+        rows = table.Rows
+        rows.insertByIndex(start, count)
+
+    '''returns the row index for this cell name.
+    @param cellName
+    @return the row index for this cell name.
+    '''
+
+    @classmethod
+    def getRowIndex(self, cellName):
+        return int(cellName.RangeName[1:])
+
+    '''
+    returns the rows count of this table, assuming
+    there is no vertical merged cells.
+    '''
+
+    @classmethod
+    def getRowCount(self, table):
+        cells = table.getCellNames()
+        return int(cells[len(cells) - 1][1:])
+
+class ItemsTable(object):
+    '''
+    the items in the table.
+    '''
+    items = []
+    table = None
+
+    def __init__(self, section, table, agenda):
+        self.agenda = agenda
+        ItemsTable.table = table
+        self.section = section
+        self.items = []
+        '''
+        go through all <*> items in the document
+        and each one if it is in this table.
+        If they are, register them to belong here, notice their order
+        and remove them from the list of all <*> items, so the next
+        search will be faster.
+        '''
+        i = 0
+        while i < len(self.agenda.allItems):
+            workwith = self.agenda.allItems[i]
+            t = workwith.TextTable
+            if t == ItemsTable.table:
+                iText = workwith.String.lower().lstrip()
+                ai = self.agenda.itemsCache[iText]
+                if ai is not None:
+                    self.items.append(ai)
+                    del self.agenda.allItems[i]
+                    self.agenda.itemsMap[iText] = self
+                    i -= 1
+            i += 1
+
+    '''
+    link the section to the template. this will restore the original table
+    with all the items.<br/>
+    then break the link, to make the section editable.<br/>
+    then, starting at cell one, write all items that should be visible.
+    then clear the rest and remove obsolete rows.
+    If no items are visible, hide the section.
+    @param dummy we need a param to make this an Implementation
+    of AgendaElement.
+    @throws Exception
+    '''
+
+    def write(self, dummy):
+        name = self.section.Name
+        # link and unlink the section to the template.
+        self.agenda.textSectionHandler.linkSectiontoTemplate(
+            self.agenda.template, name, self.section)
+        self.agenda.textSectionHandler.breakLinkOfTextSection(
+            self.section)
+        # we need to get a instance after linking.
+        ItemsTable.table = self.agenda.getTable(name)
+        self.section = self.agenda.getSection(name)
+        cursor = ItemsTable.table.createCursorByCellName("A1")
+        # should this section be visible?
+        visible = False
+        # write items
+        # ===========
+        cellName = ""
+        '''
+        now go through all items that belong to this
+        table. Check each one agains the model. If it should
+        be display, call it's write method.
+        All items are of type AgendaItem which means they write
+        two cells to the table: a title (text) and a placeholder.
+        see AgendaItem class below.
+        '''
+        for i in self.items:
+            if self.agenda.isShowItem(i.name):
+                visible = True
+                i.table = ItemsTable.table
+                i.write(cursor)
+                # I store the cell name which was last written...
+                cellName = cursor.RangeName
+                cursor.goRight(1, False)
+
+        if visible:
+            boolean = True
+        else:
+            boolean = False
+        self.section.IsVisible = boolean
+        if not visible:
+            return
+            '''
+            remove obsolete rows
+            ====================
+            if the cell that was last written is the current cell,
+            it means this is the end of the table, so we end here.
+            (because after getting the cellName above,
+            I call the goRight method.
+            If it did not go right, it means its the last cell.
+            '''
+
+        if cellName == cursor.RangeName:
+            return
+            '''
+            if not, we continue and clear all cells until
+            we are at the end of the row.
+            '''
+
+        while not cellName == cursor.RangeName and \
+                not cursor.RangeName.startswith("A"):
+            cell = ItemsTable.table.getCellByName(cursor.RangeName)
+            cell.String = ""
+            cellName = cursor.RangeName
+            cursor.goRight(1, False)
+
+        '''
+        again: if we are at the end of the table, end here.
+        '''
+        if cellName == cursor.RangeName:
+            return
+
+        rowIndex = AgendaTemplate.getRowIndex(cursor)
+        rowsCount = AgendaTemplate.getRowCount(ItemsTable.table)
+        '''
+        now before deleteing i move the cursor up so it
+        does not disappear, because it will crash office.
+        '''
+        cursor.gotoStart(False)
+
+'''
+This class handles the preview of the topics table.
+You can call it the controller of the topics table.
+It differs from ItemsTable in that it has no data model -
+the update is done programttically.<br/>
+<br/>
+The decision to make this class a class by its own
+was done out of logic reasons and not design/functionality reasons,
+since there is anyway only one instance of this class at runtime
+it could have also be implemented in the AgendaTemplate class
+but for clarity and separation I decided to make a sub class for it.
+
+ at author rp143992
+'''
+
+class Topics(object):
+    '''Analyze the structure of the Topics table.
+    The structure Must be as follows:<br>
+    -One Header Row. <br>
+    -arbitrary number of rows per topic <br>
+    -arbitrary content in the topics row <br>
+    -only soft formatting will be restored. <br>
+    -the topic rows must repeat three times. <br>
+    -in the topics rows, placeholders for number, topic, responsible,
+    and duration must be placed.<br><br>
+    A word about table format: to reconstruct the format of the table we hold
+    to the following formats: first row (header), topic, and last row.
+    We hold the format of the last row, because one might wish to give it
+    a special format, other than the one on the bottom of each topic.
+    The left and right borders of the whole table are, on the other side,
+    part of the topics rows format, and need not be preserved seperateley.
+    '''
+    table = None
+    lastRowFormat = []
+    numCell = -1
+    topicCell = -1
+    responsibleCell = -1
+    timeCell = -1
+    rowsPerTopic = None
+    topicCells = []
+
+    def __init__(self, agenda):
+        self.topicItems = {}
+        self.firstRowFormat = []
+        self.agenda = agenda
+        '''
+        this is a list which traces which topics were written to the document
+        and which not. When a cell needs to be actualized, it is checked that the
+        whole topic is already present in the document, using this vector.
+        The vector contains nulls for topics which were not written, and
+        empty strings for topics which were written (though any other
+        object would also do - i check only if it is a null or not...);
+        '''
+        self.writtenTopics = []
+        try:
+            Topics.table = self.agenda.getTable(
+                self.agenda.templateConsts.SECTION_TOPICS)
+        except Exception:
+            traceback.print_exc()
+            raise AttributeError (
+                "Fatal error while loading template: table " + \
+                self.agenda.templateConsts.SECTION_TOPICS + " could not load.")
+
+        '''
+        first I store all <*> ranges
+        which are in the topics table.
+        I store each <*> range in this - the key
+        is the cell it is in. Later when analyzing the topic,
+        cell by cell, I check in this map to know
+        if a cell contains a <*> or not.
+        '''
+        try:
+            items = {}
+            for i in self.agenda.allItems:
+                t = i.TextTable
+                if t == Topics.table:
+                    cell = i.Cell
+                    iText = cell.CellName
+                    items[iText] = i
+
+            '''
+            in the topics table, there are always one
+            title row and three topics defined.
+            So no mutter how many rows a topic takes - we
+            can restore its structure and format.
+            '''
+            rows = self.agenda.getRowCount(Topics.table)
+            Topics.rowsPerTopic = int((rows - 1) / 3)
+
+            firstCell = "A" + str(1 + Topics.rowsPerTopic + 1)
+            afterLastCell = "A" + str(1 + (Topics.rowsPerTopic * 2) + 1)
+            # go to the first row of the 2. topic
+
+            cursor = Topics.table.createCursorByCellName(firstCell)
+            # analyze the structure of the topic rows.
+            while not cursor.RangeName == afterLastCell:
+                cell = Topics.table.getCellByName(cursor.RangeName)
+                # if the cell contains a relevant <...>
+                # i add the text element to the hash,
+                # so it's text can be updated later.
+                try:
+                    if items[cell.CellName] is not None:
+                        self.topicItems[cell.String.lower().lstrip()] = cell
+                except KeyError:
+                    pass
+
+                Topics.topicCells.append(cell)
+                # goto next cell.
+                cursor.goRight(1, False)
+            '''
+            now - in which cell is every fillin?
+            '''
+
+            Topics.numCell = Topics.topicCells.index(
+                self.topicItems[
+                    self.agenda.templateConsts.FILLIN_TOPIC_NUMBER])
+            Topics.topicCell = Topics.topicCells.index(
+                self.topicItems[
+                    self.agenda.templateConsts.FILLIN_TOPIC_TOPIC])
+            Topics.responsibleCell = Topics.topicCells.index(
+                self.topicItems[
+                    self.agenda.templateConsts.FILLIN_TOPIC_RESPONSIBLE])
+            Topics.timeCell = Topics.topicCells.index(
+                self.topicItems[
+                    self.agenda.templateConsts.FILLIN_TOPIC_TIME])
+        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.
+    '''
+
+    def write2(self, topic, data):
+        if topic >= len(self.writtenTopics):
+            size = topic - len(self.writtenTopics)
+            self.writtenTopics += [None] * size
+        self.writtenTopics.insert(topic, "")
+        # make sure threr are enough rows for me...
+        rows = self.agenda.getRowCount(Topics.table)
+        reqRows = 1 + (topic + 1) * Topics.rowsPerTopic
+        firstRow = reqRows - Topics.rowsPerTopic + 1
+        diff = reqRows - rows
+        if diff > 0:
+            self.agenda.insertTableRows(Topics.table, rows, diff)
+            # set the item's text...
+
+        self.setItemText(Topics.numCell, data[0].Value)
+        self.setItemText(Topics.topicCell, data[1].Value)
+        self.setItemText(Topics.responsibleCell, data[2].Value)
+        self.setItemText(Topics.timeCell, data[3].Value)
+        # now write !
+        cursor = Topics.table.createCursorByCellName("A" + str(firstRow))
+        for i in Topics.topicCells:
+            i.write(Topics.table.getCellByName(cursor.RangeName))
+            cursor.goRight(1, False)
+        # now format !
+        cursor.gotoCellByName("A" + str(firstRow), False)
+        return diff
+
+    '''check if the topic with the given index is written to the table.
+    @param topic the topic number (0 base)
+    @return true if the topic is already written to the table. False if not.
+    (false would mean rows must be added to the table in order to
+    be able to write this topic).
+    '''
+
+    def isWritten(self, topic):
+        return (len(self.writtenTopics) > topic \
+            and self.writtenTopics[topic] is not None)
+
+    '''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,
+    we don't reference a cell number. Rather, we use "what" argument to
+    specify which cell should be redrawn.
+    The Topics object, which analyzed the structure of the topics table appon
+    initialization, refreshes the approperiate cell.
+    @param topic index of the topic (0 based).
+    @param what 0 for num, 1 for topic, 2 for responsible, 3 for duration
+    @param data the row's data.
+    @throws Exception if something goes wrong (thow nothing should)
+    '''
+
+    def writeCell(self, topic, what, data):
+        # if the whole row should be written...
+        if not self.isWritten(topic):
+            self.write(topic, data)
+            # write only the "what" cell.
+        else:
+            # calculate the table row.
+            firstRow = 1 + (topic * Topics.rowsPerTopic) + 1
+            # go to the first cell of this topic.
+            cursor = Topics.table.createCursorByCellName("A" + str(firstRow))
+            te = None
+            cursorMoves = 0
+            if what == 0:
+                te = self.setItemText(Topics.numCell, data[0].Value)
+                cursorMoves = Topics.numCell
+            elif what == 1:
+                te = self.setItemText(Topics.topicCell, data[1].Value)
+                cursorMoves = Topics.topicCell
+            elif what == 2:
+                te = self.setItemText(Topics.responsibleCell, data[2].Value)
+                cursorMoves = Topics.responsibleCell
+            elif what == 3:
+                te = self.setItemText(Topics.timeCell, data[3].Value)
+                cursorMoves = Topics.timeCell
+
+            # move the cursor to the needed cell...
+            cursor.goRight(cursorMoves, False)
+            xc = Topics.table.getCellByName(cursor.RangeName)
+            # and write it !
+            te.write(xc)
+
+    '''writes the given topic.
+    if the first topic was involved, reformat the
+    first row.
+    If any rows were added to the table, reformat
+    the last row.
+    @param topic the index of the topic to write.
+    @param data the topic's data. (see TopicsControl
+    for explanation about the topics data model)
+    @throws Exception if something goes wrong (though nothing should).
+    '''
+
+    def write(self, topic, data):
+        diff = self.write2(topic, data)
+        '''if the first topic has been written,
+        one needs to reformat the first row.
+        '''
+        if topic == 0:
+            self.formatFirstRow()
+        '''
+        if any rows were added, one needs to format
+        the whole table again.
+        '''
+
+        if diff > 0:
+            self.formatLastRow()
+
+    '''removes obsolete rows, reducing the
+    topics table to the given number of topics.
+    Note this method does only reducing - if
+    the number of topics given is greater than the
+    number of actuall topics it does *not* add
+    rows !
+    Note also that the first topic will never be removed.
+    If the table contains no topics, the whole section will
+    be removed uppon finishing.
+    The reason for that is a "table-design" one: the first topic is
+    maintained in order to be able to add rows with a design of this topic,
+    and not of the header row.
+    @param topics the number of topics the table should contain.
+    @throws Exception
+    '''
+
+    def reduceDocumentTo(self, topics):
+        # we never remove the first topic...
+        if topics <= 0:
+            topics = 1
+
+        tableRows = Topics.table.Rows
+        targetNumOfRows = topics * Topics.rowsPerTopic + 1
+        '''if tableRows.Count > targetNumOfRows:
+            tableRows.removeByIndex(
+                targetNumOfRows, tableRows.Count - targetNumOfRows)'''
+
+        self.formatLastRow()
+        while len(self.writtenTopics) > topics:
+            del self.writtenTopics[topics]
+
+    '''reapply the format of the first (header) row.
+    '''
+
+    def formatFirstRow(self):
+        cursor = Topics.table.createCursorByCellName("A1")
+        self.formatTable(cursor, self.firstRowFormat, False)
+
+    '''reaply the format of the last row.
+    '''
+    @classmethod
+    def formatLastRow(self):
+        cursor = Topics.table.createCursorByCellName("A1")
+        cursor.gotoEnd(False)
+        self.formatTable(cursor, Topics.lastRowFormat, True)
+
+    '''returns a text element for the given cell,
+    which will write the given text.
+    @param cell the topics cell number.
+    @param value the value to write.
+    @return a TextElement object which will write the given value
+    to the given cell.
+    '''
+
+    @classmethod
+    def setItemText(self, cell, value):
+        if cell >= 0:
+            te = Topics.topicCells[cell]
+            if te is not None:
+                te.Text = str(value)
+            return te
+
+        return None
+
+    '''formats a series of cells from the given one,
+    using the given List of TableCellFormatter objects,
+    in the given order.
+    This method is used to format the first (header) and the last
+    rows of the table.
+    @param cursor a table cursor, pointing to the start cell to format
+    @param formats a List containing TableCellFormatter objects.
+    Each will format one cell in the direction specified.
+    @param reverse if true the cursor will move left,
+    formatting in reverse order (used for the last row).
+    '''
+    @classmethod
+    def formatTable(self, cursor, formats, reverse):
+        for i in formats:
+            i.format(Topics.table.getCellByName(cursor.RangeName))
+            if reverse:
+                cursor.goLeft(1, False)
+            else:
+                cursor.goRight(1, False)
+
+'''
+A Text element which, if the text to write is empty (null or "")
+inserts a placeholder instead.
+ at author rp143992
+'''
+
+class PlaceholderTextElement(TextElement):
+
+    def __init__(self, textRange, placeHolderText_, hint_, xmsf_):
+        super(PlaceholderTextElement,self).__init__(textRange, "")
+
+        self.text = placeHolderText_
+        self.hint = hint_
+        self.xmsf = xmsf_
+
+    def write(self, textRange):
+        textRange.String = self.placeHolderText
+        if self.placeHolderText is None or self.placeHolderText == "":
+            try:
+                xTextContent = AgendaTemplate.createPlaceHolder(
+                    self.xmsf, self.text, self.hint)
+                textRange.Text.insertTextContent(
+                    textRange.Start, xTextContent, True)
+            except Exception:
+                traceback.print_exc()
+
+'''
+An Agenda element which writes no text, but inserts a placeholder, and formats
+it using a ParaStyleName.
+ at author rp143992
+'''
+
+class PlaceholderElement(object):
+
+    def __init__(self, placeHolderText_, hint_,  textDocument):
+        self.placeHolderText = placeHolderText_
+        self.hint = hint_
+        self.textDocument =  textDocument
+
+    def write(self, textRange):
+        try:
+            xTextContent = AgendaTemplate.createPlaceHolder(
+                self.textDocument, self.placeHolderText, self.hint)
+            textRange.Text.insertTextContent(
+                textRange.Start, xTextContent, True)
+        except Exception:
+            traceback.print_exc()
+
+'''
+An implementation of AgendaElement which
+gets as a parameter a table cursor, and writes
+a text to the cell marked by this table cursor, and
+a place holder to the next cell.
+ at author rp143992
+'''
+
+class AgendaItem(object):
+
+    def __init__(self, name_, te, f):
+        self.name = name_
+        self.field = f
+        self.textElement = te
+
+    def write(self, tableCursor):
+        cellname = tableCursor.RangeName
+        cell = ItemsTable.table.getCellByName(cellname)
+        cell.String = self.textElement
+        tableCursor.goRight(1, False)
+        #second field is actually always null...
+        # this is a preparation for adding placeholders.
+        if self.field is not None:
+            self.field.write(ItemsTable.table.getCellByName(
+                tableCursor.RangeName))
diff --git a/wizards/com/sun/star/wizards/agenda/AgendaTemplate.py b/wizards/com/sun/star/wizards/agenda/AgendaTemplate.py
deleted file mode 100644
index 54be369..0000000
--- a/wizards/com/sun/star/wizards/agenda/AgendaTemplate.py
+++ /dev/null
@@ -1,1149 +0,0 @@
-#
-# This file is part of the LibreOffice project.
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-#
-# This file incorporates work covered by the following license notice:
-#
-#   Licensed to the Apache Software Foundation (ASF) under one or more
-#   contributor license agreements. See the NOTICE file distributed
-#   with this work for additional information regarding copyright
-#   ownership. The ASF licenses this file to you under the Apache
-#   License, Version 2.0 (the "License"); you may not use this file
-#   except in compliance with the License. You may obtain a copy of
-#   the License at http://www.apache.org/licenses/LICENSE-2.0 .
-#
-import uno
-import traceback
-from ..text.TextElement import TextElement
-from ..text.TextDocument import TextDocument
-from ..common.FileAccess import FileAccess
-from ..text.TextSectionHandler import TextSectionHandler
-
-from datetime import date as dateTimeObject
-
-from com.sun.star.text.PlaceholderType import TEXT
-from com.sun.star.i18n.NumberFormatIndex import TIME_HHMM, DATE_SYSTEM_LONG
-
-'''
-The classes here implement the whole document-functionality of the agenda wizard:
-the live-preview and the final "creation" of the document,
-when the user clicks "finish". <br/>
-<br/>
-<h2>Some terminology:<h2/>
-items are names or headings. we don't make any distinction.
-
-<br/>
-The Agenda Template is used as general "controller"
-of the whole document, whereas the two child-classes ItemsTable
-and TopicsTable control the item tables (note plural!) and the
-topics table (note singular).<br/>
-<br/>
-Other small classes are used to abstract the handling of cells and text and we
-try to use them as components.
-<br/><br/>
-We tried to keep the Agenda Template as flexible as possible, though there
-must be many limitations, because it is generated dynamically.<br/><br/>
-To keep the template flexible the following decisions were made:<br/>
-1. Item tables.<br/>
-1.a. there might be arbitrary number of Item tables.<br/>
-1.b. Item tables design (bordewr, background) is arbitrary.<br/>
-1.c. Items text styles are individual,
-and use stylelist styles with predefined names.<br/>
-As result the following limitations:<br/>
-Pairs of Name->value for each item.<br/>
-Tables contain *only* those pairs.<br/>
-2. Topics table.<br/>
-2.a. arbitrary structure.<br/>
-2.b. design is arbitrary.<br/>
-As result the following limitations:<br/>
-No column merge is allowed.<br/>
-One compolsary Heading row.<br/>
-<br/><br/>
-To let the template be flexible, we use a kind of "detection": we look where
-the items are read the design of each table, reaplying it after writing the
-table.self.xTextDocument
-<br/><br/>
-A note about threads:<br/>
-Many methods here are synchronized, in order to avoid colission made by
-events fired too often.
- at author rpiterman
-'''
-class AgendaTemplate(TextDocument):
-
-    '''
-    constructor. The document is *not* loaded here.
-    only some formal members are set.
-    '''
-
-    def __init__(self,  xmsf, agenda, resources, templateConsts, listener):
-        super(AgendaTemplate,self).__init__(xmsf,listener, None,
-            "WIZARD_LIVE_PREVIEW")
-        self.agenda = agenda
-        self.templateConsts = templateConsts
-        self.resources = resources
-        self.itemsMap = {}
-        self.allItems = []
-
-    def load(self, templateURL, topics):
-        self.template = self.calcTemplateName(templateURL)
-        self.loadAsPreview(templateURL, False)
-        self.xFrame.ComponentWindow.Enable = False
-        self.xTextDocument.lockControllers()
-        self.initialize()
-        self.initializeData(topics)
-        self.xTextDocument.unlockControllers()
-
-    '''
-    The agenda templates are in format of aw-XXX.ott
-    the templates name is then XXX.ott.
-    This method calculates it.
-    '''
-
-    def calcTemplateName(self, url):
-        return FileAccess.connectURLs(
-            FileAccess.getParentDir(url), FileAccess.getFilename(url)[3:])
-
-    '''synchronize the document to the model.<br/>
-    this method rewrites all titles, item tables , and the topics table-
-    thus synchronizing the document to the data model (CGAgenda).
-    information (it is only actualized on save) the given list
-    supplies this information.
-    '''
-
-    def initializeData(self, topicsData):
-        for i in self.itemsTables:
-            try:
-                i.write("")
-            except Exception:
-                traceback.print_exc()
-
-        self.redrawTitle("txtTitle")
-        self.redrawTitle("txtDate")
-        self.redrawTitle("txtTime")
-        self.redrawTitle("cbLocation")
-
-    '''
-    redraws/rewrites the table which contains the given item
-    This method is called when the user checks/unchecks an item.
-    The table is being found, in which the item is, and redrawn.
-    '''
-
-    def redraw(self, itemName):
-        self.xTextDocument.lockControllers()
-        try:
-            # get the table in which the item is...
-            itemsTable = self.itemsMap[itemName]
-            # rewrite the table.
-            itemsTable.write(None)
-        except Exception:
-            traceback.print_exc()
-        self.xTextDocument.unlockControllers()
-
-    '''
-    checks the data model if the
-    item corresponding to the given string should be shown
-    '''
-
-    def isShowItem(self, itemName):
-        if itemName == self.templateConsts.FILLIN_MEETING_TYPE:
-            return self.agenda.cp_ShowMeetingType
-        elif itemName == self.templateConsts.FILLIN_READ:
-            return self.agenda.cp_ShowRead
-        elif itemName == self.templateConsts.FILLIN_BRING:
-            return self.agenda.cp_ShowBring
-        elif itemName == self.templateConsts.FILLIN_NOTES:
-            return self.agenda.cp_ShowNotes
-        elif itemName == self.templateConsts.FILLIN_FACILITATOR:
-            return self.agenda.cp_ShowFacilitator
-        elif itemName == self.templateConsts.FILLIN_TIMEKEEPER:
-            return self.agenda.cp_ShowTimekeeper
-        elif itemName == self.templateConsts.FILLIN_NOTETAKER:
-            return self.agenda.cp_ShowNotetaker
-        elif itemName == self.templateConsts.FILLIN_PARTICIPANTS:
-            return self.agenda.cp_ShowAttendees
-        elif itemName == self.templateConsts.FILLIN_CALLED_BY:
-            return self.agenda.cp_ShowCalledBy
-        elif itemName == self.templateConsts.FILLIN_OBSERVERS:
-            return self.agenda.cp_ShowObservers
-        elif itemName == self.templateConsts.FILLIN_RESOURCE_PERSONS:
-            return self.agenda.cp_ShowResourcePersons
-        else:
-            raise ValueError("No such item")
-
-    '''itemsCache is a Map containing all agenda item. These are object which
-    "write themselfs" to the table, given a table cursor.
-    A cache is used in order to reuse the objects, instead of recreate them.
-    This method fills the cache will all items objects (names and headings).
-    '''
-
-    def initItemsCache(self):
-        self.itemsCache = {}
-        # Headings
-        self.itemsCache[
-                self.templateConsts.FILLIN_MEETING_TYPE] = \
-            AgendaItem(self.templateConsts.FILLIN_MEETING_TYPE,
-                self.resources.itemMeetingType,
-                PlaceholderElement(
-                    self.resources.reschkMeetingTitle_value,
-                    self.resources.resPlaceHolderHint, self.xTextDocument))
-        self.itemsCache[
-                self.templateConsts.FILLIN_BRING] = \
-            AgendaItem(self.templateConsts.FILLIN_BRING,
-                self.resources.itemBring,
-                PlaceholderElement (
-                    self.resources.reschkBring_value,
-                    self.resources.resPlaceHolderHint, self.xTextDocument))
-        self.itemsCache[
-                self.templateConsts.FILLIN_READ] = \
-            AgendaItem (self.templateConsts.FILLIN_READ, 
-                self.resources.itemRead,
-                PlaceholderElement (
-                    self.resources.reschkRead_value,
-                    self.resources.resPlaceHolderHint, self.xTextDocument))
-        self.itemsCache[
-                self.templateConsts.FILLIN_NOTES] = \
-            AgendaItem (self.templateConsts.FILLIN_NOTES,
-                self.resources.itemNote,
-                PlaceholderElement (
-                    self.resources.reschkNotes_value,
-                    self.resources.resPlaceHolderHint, self.xTextDocument))
-
-        # Names
-        self.itemsCache[
-                self.templateConsts.FILLIN_CALLED_BY] = \
-            AgendaItem(self.templateConsts.FILLIN_CALLED_BY,
-                self.resources.itemCalledBy,
-                PlaceholderElement (
-                    self.resources.reschkConvenedBy_value,
-                    self.resources.resPlaceHolderHint, self.xTextDocument))
-        self.itemsCache[
-                self.templateConsts.FILLIN_FACILITATOR] = \
-            AgendaItem(self.templateConsts.FILLIN_FACILITATOR,
-                self.resources.itemFacilitator,
-                PlaceholderElement (
-                    self.resources.reschkPresiding_value,
-                    self.resources.resPlaceHolderHint, self.xTextDocument))
-        self.itemsCache[
-                self.templateConsts.FILLIN_PARTICIPANTS] = \
-            AgendaItem(self.templateConsts.FILLIN_PARTICIPANTS,
-                self.resources.itemAttendees,
-                PlaceholderElement(
-                    self.resources.reschkAttendees_value,
-                    self.resources.resPlaceHolderHint, self.xTextDocument))
-        self.itemsCache[
-                self.templateConsts.FILLIN_NOTETAKER] = \
-            AgendaItem(self.templateConsts.FILLIN_NOTETAKER,
-                self.resources.itemNotetaker,
-                PlaceholderElement(
-                    self.resources.reschkNoteTaker_value,
-                    self.resources.resPlaceHolderHint, self.xTextDocument))
-        self.itemsCache[
-                self.templateConsts.FILLIN_TIMEKEEPER] = \
-            AgendaItem(self.templateConsts.FILLIN_TIMEKEEPER,
-                self.resources.itemTimekeeper,
-                PlaceholderElement(
-                    self.resources.reschkTimekeeper_value,
-                    self.resources.resPlaceHolderHint, self.xTextDocument))
-        self.itemsCache[
-                self.templateConsts.FILLIN_OBSERVERS] = \
-            AgendaItem(self.templateConsts.FILLIN_OBSERVERS,
-                self.resources.itemObservers,
-                PlaceholderElement(
-                    self.resources.reschkObservers_value,
-                    self.resources.resPlaceHolderHint, self.xTextDocument))
-        self.itemsCache[
-                self.templateConsts.FILLIN_RESOURCE_PERSONS] = \
-            AgendaItem(self.templateConsts.FILLIN_RESOURCE_PERSONS,
-                self.resources.itemResource,
-                PlaceholderElement(
-                    self.resources.reschkResourcePersons_value,
-                    self.resources.resPlaceHolderHint, self.xTextDocument))
-
-    '''Initializes a template.<br/>
-    This method does the following tasks:<br/>
-    Get a Time and Date format for the document, and retrieve the null
-    date of the document (which is document-specific).<br/>
-    Initializes the Items Cache map.
-    Analyses the document:<br/>
-    -find all "fille-ins" (apear as >xxx< in the document).
-    -analyze all items sections (and the tables in them).
-    -locate the titles and actualize them
-    -analyze the topics table
-    '''
-
-    def initialize(self):
-        '''
-        Get the default locale of the document,
-        and create the date and time formatters.
-        '''
-        AgendaTemplate.dateUtils = self.DateUtils(
-            self.xMSF, self.xTextDocument)
-        AgendaTemplate.formatter = AgendaTemplate.dateUtils.formatter
-        AgendaTemplate.dateFormat = \
-            AgendaTemplate.dateUtils.getFormat(DATE_SYSTEM_LONG)
-        AgendaTemplate.timeFormat = \
-            AgendaTemplate.dateUtils.getFormat(TIME_HHMM)
-
-        self.initItemsCache()
-        self.allItems = self.searchFillInItems(0)
-        self.initializeTitles()
-        self.initializeItemsSections()
-        self.textSectionHandler = TextSectionHandler(
-            self.xTextDocument, self.xTextDocument)
-        self.topics = Topics(self)
-
-    '''
-    locates the titles (name, location, date, time)
-    and saves a reference to thier Text ranges.
-    '''
-
-    def initializeTitles(self):
-        auxList = []
-        for i in self.allItems:
-            text = i.String.lstrip().lower()
-            if text == self.templateConsts.FILLIN_TITLE:
-                AgendaTemplate.teTitle = PlaceholderTextElement(
-                    i, self.resources.resPlaceHolderTitle,
-                    self.resources.resPlaceHolderHint,
-                    self.xTextDocument)
-                AgendaTemplate.trTitle = i
-            elif text == self.templateConsts.FILLIN_DATE:
-                AgendaTemplate.teDate = PlaceholderTextElement(
-                    i, self.resources.resPlaceHolderDate,
-                    self.resources.resPlaceHolderHint,
-                    self.xTextDocument)
-                AgendaTemplate.trDate = i
-            elif text == self.templateConsts.FILLIN_TIME:
-                AgendaTemplate.teTime = PlaceholderTextElement(
-                    i, self.resources.resPlaceHolderTime,
-                    self.resources.resPlaceHolderHint,
-                    self.xTextDocument)
-                AgendaTemplate.trTime = i
-            elif text == self.templateConsts.FILLIN_LOCATION:
-                AgendaTemplate.teLocation = PlaceholderTextElement(
-                    i, self.resources.resPlaceHolderLocation,
-                    self.resources.resPlaceHolderHint,
-                    self.xTextDocument)
-                AgendaTemplate.trLocation = i
-            else:
-                auxList.append(i)
-        self.allItems = auxList
-
-    '''
-    analyze the item sections in the template.
-    delegates the analyze of each table to the ItemsTable class.
-    '''
-
-    def initializeItemsSections(self):
-        sections = self.getSections(
-        self.xTextDocument, self.templateConsts.SECTION_ITEMS)
-        # for each section - there is a table...
-        self.itemsTables = []
-        for i in sections:
-            try:
-                self.itemsTables.append(
-                    ItemsTable(self.getSection(i), self.getTable(i), self))
-            except Exception:
-                traceback.print_exc()
-                raise AttributeError (
-                    "Fatal Error while initialilzing \
-                    Template: items table in section " + i)
-
-
-    def getSections(self, document, s):
-        allSections = document.TextSections.ElementNames
-        return self.getNamesWhichStartWith(allSections, s)
-
-    def getSection(self, name):
-        return getattr(self.xTextDocument.TextSections, name)
-
-    def getTable(self, name):
-        return getattr(self.xTextDocument.TextTables, name)
-
-    def redrawTitle(self, controlName):
-        try:
-            if controlName == "txtTitle":
-                self.writeTitle(
-                    AgendaTemplate.teTitle, AgendaTemplate.trTitle,
-                    self.agenda.cp_Title)
-            elif controlName == "txtDate":
-                self.writeTitle(
-                    AgendaTemplate.teDate, AgendaTemplate.trDate,
-                    self.getDateString(self.agenda.cp_Date))
-            elif controlName == "txtTime":
-                self.writeTitle(
-                    AgendaTemplate.teTime, AgendaTemplate.trTime,
-                    self.getTimeString(self.agenda.cp_Time))
-            elif controlName == "cbLocation":
-                self.writeTitle(
-                    AgendaTemplate.teLocation, AgendaTemplate.trLocation,
-                    self.agenda.cp_Location)
-            else:

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list