summaryrefslogtreecommitdiff
path: root/wizards
diff options
context:
space:
mode:
authorXisco Fauli <anistenis@gmail.com>2012-11-07 20:33:23 +0100
committerXisco Fauli <anistenis@gmail.com>2012-11-08 07:42:27 +0100
commit1d615feed25842544a5ab3ae4265dc9c2de6f107 (patch)
tree22d2df86d78a62bd3a37093187f02f39d0f647fa /wizards
parent88e457dc60b7a7e5f4048e00c0418bc57537c029 (diff)
Revert "pyagenda: rework AgendaTemplate.py. Still some work to do"
Diffstat (limited to 'wizards')
-rw-r--r--wizards/com/sun/star/wizards/agenda/AgendaTemplate.py457
-rw-r--r--wizards/com/sun/star/wizards/agenda/AgendaWizardDialogImpl.py2
-rw-r--r--wizards/com/sun/star/wizards/agenda/AgendaWizardDialogResources.py48
-rw-r--r--wizards/com/sun/star/wizards/agenda/TemplateConsts.py90
-rw-r--r--wizards/com/sun/star/wizards/common/TextElement.py2
5 files changed, 466 insertions, 133 deletions
diff --git a/wizards/com/sun/star/wizards/agenda/AgendaTemplate.py b/wizards/com/sun/star/wizards/agenda/AgendaTemplate.py
index 3e928a8db4a2..bb85bcc3b484 100644
--- a/wizards/com/sun/star/wizards/agenda/AgendaTemplate.py
+++ b/wizards/com/sun/star/wizards/agenda/AgendaTemplate.py
@@ -15,14 +15,11 @@
# except in compliance with the License. You may obtain a copy of
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
#
-import traceback
import uno
from .TemplateConsts import *
from threading import RLock
-from ..text.TextDocument import TextDocument
+from ..text.TextDocument import *
from ..common.FileAccess import FileAccess
-from ..common.TextElement import TextElement
-from ..common.Helper import Helper
from ..text.TextSectionHandler import TextSectionHandler
from datetime import date as dateTimeObject
@@ -79,7 +76,7 @@ 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.AgendaTemplate.xTextDocument
+table.AgendaTemplate.document
<br/><br/>
A note about threads:<br/>
Many methods here are synchronized, in order to avoid colission made by
@@ -89,6 +86,8 @@ events fired too often.
class AgendaTemplate(TextDocument):
writtenTopics = []
+ itemsCache = None
+ _allItems = []
items = []
itemsMap = {}
document = None
@@ -104,16 +103,21 @@ class AgendaTemplate(TextDocument):
@param resources_ resources.
'''
- def __init__(self, xmsf, agenda, resources, listener):
- super(AgendaTemplate,self).__init__(xmsf,listener, None,
+ def __init__(self, xmsf_, agenda_, resources_, listener):
+ super(AgendaTemplate,self).__init__(xmsf_,listener, None,
"WIZARD_LIVE_PREVIEW")
- self.agenda = agenda
- self.resources = resources
+ AgendaTemplate.agenda = agenda_
+ self.resources = resources_
+
+ if AgendaTemplate.itemsCache is None:
+ self.initItemsCache()
+
+ AgendaTemplate._allItems = None
@synchronized(lock)
def load(self, templateURL, topics):
AgendaTemplate.template = self.calcTemplateName(templateURL)
- AgendaTemplate.xTextDocument = self.loadAsPreview(templateURL, False)
+ AgendaTemplate.document = self.loadAsPreview(templateURL, False)
self.xFrame.ComponentWindow.Enable = False
self.xTextDocument.lockControllers()
self.initialize()
@@ -151,9 +155,9 @@ class AgendaTemplate(TextDocument):
self.redrawTitle("txtDate")
self.redrawTitle("txtTime")
self.redrawTitle("cbLocation")
- if self.agenda.cp_TemplateName is None:
- self.agenda.cp_TemplateName = ""
- self.setTemplateTitle(self.agenda.cp_TemplateName)
+ if AgendaTemplate.agenda.cp_TemplateName is None:
+ AgendaTemplate.agenda.cp_TemplateName = ""
+ self.setTemplateTitle(AgendaTemplate.agenda.cp_TemplateName)
'''redraws/rewrites the table which contains the given item
This method is called when the user checks/unchecks an item.
@@ -184,30 +188,111 @@ class AgendaTemplate(TextDocument):
'''checks the data model if the
item corresponding to the given string should be shown
+ @param itemName a string representing an Item (name or heading).
+ @return true if the model specifies that the item should be displayed.
'''
+
+ @classmethod
def isShowItem(self, itemName):
- if itemName is "<meeting-type>":
- return self.agenda.cp_ShowMeetingType
- elif itemName is "<read>":
- return self.agenda.cp_ShowRead
- elif itemName is "<bring>":
- return self.agenda.cp_ShowBring
- elif itemName is "<notes>":
- return self.agenda.cp_ShowNotes
- elif itemName is "<facilitator>":
- return self.agenda.cp_ShowFacilitator
- elif itemName is "<timekeeper>":
- return self.agenda.cp_ShowTimekeeper
- elif itemName is "<notetaker>":
- return self.agenda.cp_ShowNotetaker
- elif itemName is "<attendees>":
- return self.agenda.cp_ShowAttendees
- elif itemName is "<called-by>":
- return self.agenda.cp_ShowCalledBy
- elif itemName is "<observers>":
- return self.agenda.cp_ShowObservers
- elif itemName is "<resource-persons>":
- return self.agenda.cp_ShowResourcePersons
+ if itemName == FILLIN_MEETING_TYPE:
+ return AgendaTemplate.agenda.cp_ShowMeetingType
+ elif itemName == FILLIN_READ:
+ return AgendaTemplate.agenda.cp_ShowRead
+ elif itemName == FILLIN_BRING:
+ return AgendaTemplate.agenda.cp_ShowBring
+ elif itemName == FILLIN_NOTES:
+ return AgendaTemplate.agenda.cp_ShowNotes
+ elif itemName == FILLIN_FACILITATOR:
+ return AgendaTemplate.agenda.cp_ShowFacilitator
+ elif itemName == FILLIN_TIMEKEEPER:
+ return AgendaTemplate.agenda.cp_ShowTimekeeper
+ elif itemName == FILLIN_NOTETAKER:
+ return AgendaTemplate.agenda.cp_ShowNotetaker
+ elif itemName == FILLIN_PARTICIPANTS:
+ return AgendaTemplate.agenda.cp_ShowAttendees
+ elif itemName == FILLIN_CALLED_BY:
+ return AgendaTemplate.agenda.cp_ShowCalledBy
+ elif itemName == FILLIN_OBSERVERS:
+ return AgendaTemplate.agenda.cp_ShowObservers
+ elif itemName == FILLIN_RESOURCE_PERSONS:
+ return AgendaTemplate.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):
+ AgendaTemplate.itemsCache = {}
+ # Headings
+ AgendaTemplate.itemsCache[FILLIN_MEETING_TYPE] = AgendaItem(
+ FILLIN_MEETING_TYPE,
+ TextElement (self.resources.itemMeetingType),
+ PlaceholderElement(
+ self.resources.reschkMeetingTitle_value,
+ self.resources.resPlaceHolderHint, self.xMSF))
+ AgendaTemplate.itemsCache[FILLIN_BRING] = AgendaItem(
+ FILLIN_BRING, TextElement (self.resources.itemBring),
+ PlaceholderElement (
+ self.resources.reschkBring_value,
+ self.resources.resPlaceHolderHint, self.xMSF))
+ AgendaTemplate.itemsCache[FILLIN_READ] = AgendaItem (
+ FILLIN_READ, TextElement (self.resources.itemRead),
+ PlaceholderElement (
+ self.resources.reschkRead_value,
+ self.resources.resPlaceHolderHint, self.xMSF))
+ AgendaTemplate.itemsCache[FILLIN_NOTES] = AgendaItem (
+ FILLIN_NOTES, TextElement (self.resources.itemNote),
+ PlaceholderElement (
+ self.resources.reschkNotes_value,
+ self.resources.resPlaceHolderHint, self.xMSF))
+
+ # Names
+ AgendaTemplate.itemsCache[FILLIN_CALLED_BY] = AgendaItem(
+ FILLIN_CALLED_BY,
+ TextElement (self.resources.itemCalledBy),
+ PlaceholderElement (
+ self.resources.reschkConvenedBy_value,
+ self.resources.resPlaceHolderHint, self.xMSF))
+ AgendaTemplate.itemsCache[FILLIN_FACILITATOR] = AgendaItem(
+ FILLIN_FACILITATOR,
+ TextElement (self.resources.itemFacilitator),
+ PlaceholderElement (
+ self.resources.reschkPresiding_value,
+ self.resources.resPlaceHolderHint, self.xMSF))
+ AgendaTemplate.itemsCache[FILLIN_PARTICIPANTS] = AgendaItem(
+ FILLIN_PARTICIPANTS,
+ TextElement (self.resources.itemAttendees),
+ PlaceholderElement(
+ self.resources.reschkAttendees_value,
+ self.resources.resPlaceHolderHint, self.xMSF))
+ AgendaTemplate.itemsCache[FILLIN_NOTETAKER] = AgendaItem(
+ FILLIN_NOTETAKER,
+ TextElement(self.resources.itemNotetaker),
+ PlaceholderElement(
+ self.resources.reschkNoteTaker_value,
+ self.resources.resPlaceHolderHint, self.xMSF))
+ AgendaTemplate.itemsCache[FILLIN_TIMEKEEPER] = AgendaItem(
+ FILLIN_TIMEKEEPER,
+ TextElement (self.resources.itemTimekeeper),
+ PlaceholderElement(
+ self.resources.reschkTimekeeper_value,
+ self.resources.resPlaceHolderHint, self.xMSF))
+ AgendaTemplate.itemsCache[FILLIN_OBSERVERS] = AgendaItem(
+ FILLIN_OBSERVERS,
+ TextElement(self.resources.itemObservers),
+ PlaceholderElement(
+ self.resources.reschkObservers_value,
+ self.resources.resPlaceHolderHint, self.xMSF))
+ AgendaTemplate.itemsCache[FILLIN_RESOURCE_PERSONS] = AgendaItem(
+ FILLIN_RESOURCE_PERSONS,
+ TextElement(self.resources.itemResource),
+ PlaceholderElement(
+ self.resources.reschkResourcePersons_value,
+ self.resources.resPlaceHolderHint, self.xMSF))
'''Initializes a template.<br/>
This method does the following tasks:<br/>
@@ -227,7 +312,7 @@ class AgendaTemplate(TextDocument):
and create the date and time formatters.
'''
AgendaTemplate.dateUtils = Helper.DateUtils(
- self.xMSF, AgendaTemplate.xTextDocument)
+ self.xMSF, AgendaTemplate.document)
AgendaTemplate.formatter = AgendaTemplate.dateUtils.formatter
AgendaTemplate.dateFormat = AgendaTemplate.dateUtils.getFormat(DATE_SYSTEM_LONG)
AgendaTemplate.timeFormat = AgendaTemplate.dateUtils.getFormat(TIME_HHMM)
@@ -236,39 +321,60 @@ class AgendaTemplate(TextDocument):
get the document properties object.
'''
- self.m_xDocProps = AgendaTemplate.xTextDocument.DocumentProperties
- self.addTitlesToPlaceHoldersDict()
- self.initializePlaceHolders()
- #self.initializeItemsSections()
+ self.m_xDocProps = AgendaTemplate.document.DocumentProperties
+ self.initItemsCache()
+ AgendaTemplate._allItems = self.searchFillInItems()
+ self.initializeTitles()
+ self.initializeItemsSections()
AgendaTemplate.textSectionHandler = TextSectionHandler(
- AgendaTemplate.xTextDocument, AgendaTemplate.xTextDocument)
+ AgendaTemplate.document, AgendaTemplate.document)
self.topics = Topics()
+ del AgendaTemplate._allItems[:]
+ AgendaTemplate._allItems = None
+ '''
+ locates the titles (name, location, date, time)
+ and saves a reference to thier Text ranges.
+ '''
- def addTitlesToPlaceHoldersDict(self):
- #We add them here because we can't in AgendaWizardDialogResources.py
- self.resources.dictTemplatePlaceHolders["<minutes-title>"] = \
- self.agenda.cp_Title
- self.resources.dictTemplatePlaceHolders["<minutes-location>"] = \
- self.agenda.cp_Location
- self.resources.dictTemplatePlaceHolders["<minutes-date>"] = \
- self.agenda.cp_Date
- self.resources.dictTemplatePlaceHolders["<minutes-time>"] = \
- self.agenda.cp_Time
-
- def initializePlaceHolders(self):
- # Looks for all the placeholders in the template with the following
- # pattern: "<[^>]+>" and create a TextElement for each one of them
- allItems = self.searchFillInItems(0)
- for i in xrange(allItems.Count):
- item = allItems.getByIndex(i)
- text = item.String.lower()
- aux = TextElement(
- item, self.resources.dictTemplatePlaceHolders[text],
- self.resources.resPlaceHolderHint, self.xMSF)
- if self.isShowItem(text):
- aux.write()
-
+ def initializeTitles(self):
+ i = 0
+ while i < len(AgendaTemplate._allItems):
+ workwith = AgendaTemplate._allItems[i]
+ text = workwith.String.lstrip().lower()
+ if text == FILLIN_TITLE:
+ AgendaTemplate.teTitle = PlaceholderTextElement(
+ workwith, self.resources.resPlaceHolderTitle,
+ self.resources.resPlaceHolderHint,
+ AgendaTemplate.document)
+ AgendaTemplate.trTitle = workwith
+ del AgendaTemplate._allItems[i]
+ i -= 1
+ elif text == FILLIN_DATE:
+ AgendaTemplate.teDate = PlaceholderTextElement(
+ workwith, self.resources.resPlaceHolderDate,
+ self.resources.resPlaceHolderHint,
+ AgendaTemplate.document)
+ AgendaTemplate.trDate = workwith
+ del AgendaTemplate._allItems[i]
+ i -= 1
+ elif text == FILLIN_TIME:
+ AgendaTemplate.teTime = PlaceholderTextElement(
+ workwith, self.resources.resPlaceHolderTime,
+ self.resources.resPlaceHolderHint,
+ AgendaTemplate.document)
+ AgendaTemplate.trTime = workwith
+ del AgendaTemplate._allItems[i]
+ i -= 1
+ elif text == FILLIN_LOCATION:
+ AgendaTemplate.teLocation = PlaceholderTextElement(
+ workwith, self.resources.resPlaceHolderLocation,
+ self.resources.resPlaceHolderHint,
+ AgendaTemplate.document)
+ AgendaTemplate.trLocation = workwith
+ del AgendaTemplate._allItems[i]
+ i -= 1
+ i += 1
'''
analyze the item sections in the template.
@@ -276,7 +382,7 @@ class AgendaTemplate(TextDocument):
'''
def initializeItemsSections(self):
- sections = self.getSections(AgendaTemplate.xTextDocument, SECTION_ITEMS)
+ sections = self.getSections(AgendaTemplate.document, SECTION_ITEMS)
# for each section - there is a table...
self.itemsTables = []
for i in sections:
@@ -286,8 +392,8 @@ class AgendaTemplate(TextDocument):
except Exception, ex:
traceback.print_exc()
raise AttributeError (
- "Fatal Error while initialilzing" +
- "Template: items table in section " + i)
+ "Fatal Error while initialilzing \
+ Template: items table in section " + i)
def getSections(self, document, s):
@@ -296,11 +402,11 @@ class AgendaTemplate(TextDocument):
@classmethod
def getSection(self, name):
- return getattr(AgendaTemplate.xTextDocument.TextSections, name)
+ return getattr(AgendaTemplate.document.TextSections, name)
@classmethod
def getTable(self, name):
- return getattr(AgendaTemplate.xTextDocument.TextTables, name)
+ return getattr(AgendaTemplate.document.TextTables, name)
@classmethod
@synchronized(lock)
@@ -309,19 +415,19 @@ class AgendaTemplate(TextDocument):
if controlName == "txtTitle":
self.writeTitle(
AgendaTemplate.teTitle, AgendaTemplate.trTitle,
- self.agenda.cp_Title)
+ AgendaTemplate.agenda.cp_Title)
elif controlName == "txtDate":
self.writeTitle(
AgendaTemplate.teDate, AgendaTemplate.trDate,
- self.getDateString(self.agenda.cp_Date))
+ self.getDateString(AgendaTemplate.agenda.cp_Date))
elif controlName == "txtTime":
self.writeTitle(
AgendaTemplate.teTime, AgendaTemplate.trTime,
- self.getTimeString(self.agenda.cp_Time))
+ self.getTimeString(AgendaTemplate.agenda.cp_Time))
elif controlName == "cbLocation":
self.writeTitle(
AgendaTemplate.teLocation, AgendaTemplate.trLocation,
- self.agenda.cp_Location)
+ AgendaTemplate.agenda.cp_Location)
else:
raise IllegalArgumentException ("No such title control...")
except Exception:
@@ -369,7 +475,7 @@ class AgendaTemplate(TextDocument):
'''
def deleteHiddenSections(self):
- allSections = AgendaTemplate.xTextDocument.TextSections.ElementNames
+ allSections = AgendaTemplate.document.TextSections.ElementNames
try:
for i in allSections:
self.section = self.getSection(i)
@@ -394,7 +500,7 @@ class AgendaTemplate(TextDocument):
def createMinutes(self, topicsData):
# if the minutes section should be removed (the
# user did not check "create minutes")
- if not self.agenda.cp_IncludeMinutes \
+ if not AgendaTemplate.agenda.cp_IncludeMinutes \
or len(topicsData) <= 1:
try:
minutesAllSection = self.getSection(SECTION_MINUTES_ALL)
@@ -405,6 +511,30 @@ class AgendaTemplate(TextDocument):
# the user checked "create minutes"
else:
try:
+ topicStartTime = int(AgendaTemplate.agenda.cp_Time)
+ #first I replace the minutes titles...
+ AgendaTemplate.items = TextDocument.searchFillInItems()
+ itemIndex = 0
+ for item in self.items:
+ itemText = item.String.lstrip().lower()
+ if itemText == FILLIN_MINUTES_TITLE:
+ self.fillMinutesItem(
+ item, AgendaTemplate.agenda.cp_Title,
+ self.resources.resPlaceHolderTitle)
+ elif itemText == FILLIN_MINUTES_LOCATION:
+ self.fillMinutesItem(
+ item, AgendaTemplate.agenda.cp_Location,
+ self.resources.resPlaceHolderLocation)
+ elif itemText == FILLIN_MINUTES_DATE:
+ self.fillMinutesItem(
+ item, getDateString(AgendaTemplate.agenda.cp_Date),
+ self.resources.resPlaceHolderDate)
+ elif itemText == FILLIN_MINUTES_TIME:
+ self.fillMinutesItem(
+ item, getTimeString(AgendaTemplate.agenda.cp_Time),
+ self.resources.resPlaceHolderTime)
+
+ self.items.clear()
'''
now add minutes for each topic.
The template contains *one* minutes section, so
@@ -417,6 +547,20 @@ class AgendaTemplate(TextDocument):
AgendaTemplate.items = TextDocument.searchFillInItems()
itemIndex = 0
for item in self.items:
+ itemText = item.String.lstrip().lower()
+ if itemText == FILLIN_MINUTE_NUM:
+ fillMinutesItem(item, topic[0].Value, "")
+ elif itemText == FILLIN_MINUTE_TOPIC:
+ fillMinutesItem(item, topic[1].Value, "")
+ elif itemText == FILLIN_MINUTE_RESPONSIBLE:
+ fillMinutesItem(item, topic[2].Value, "")
+ elif itemText == FILLIN_MINUTE_TIME:
+ topicTime = 0
+ try:
+ topicTime = topic[3].Value
+ except Exception, ex:
+ pass
+
'''
if the topic has no time, we do not
display any time here.
@@ -440,6 +584,53 @@ class AgendaTemplate(TextDocument):
except Exception, ex:
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 = Helper.getUnoPropertyValue(Range, "ParaStyleName")
+ Range.setString(text)
+ Helper.setUnoPropertyValue(Range, "ParaStyleName", paraStyle)
+ if text == None or text == "":
+ if placeholder != None and not placeholder == "":
+ placeHolder = createPlaceHolder(
+ AgendaTemplate.document, placeholder,
+ self.resources.resPlaceHolderHint)
+ try:
+ Range.Start.Text.insertTextContent(
+ Range.Start, placeHolder, True)
+ except Exception, ex:
+ traceback.print_exc()
+
+ '''creates a placeholder field with the given text and given hint.
+ @param AgendaTemplate.document service factory
+ @param ph place holder text
+ @param hint hint text
+ @return the place holder field.
+ '''
+
+ @classmethod
+ def createPlaceHolder(self, xmsf, ph, hint):
+ try:
+ placeHolder = xmsf.createInstance(
+ "com.sun.star.text.TextField.JumpEdit")
+ except Exception, ex:
+ traceback.print_exc()
+ return None
+
+ Helper.setUnoPropertyValue(placeHolder, "PlaceHolder", ph)
+ Helper.setUnoPropertyValue(placeHolder, "Hint", hint)
+ Helper.setUnoPropertyValue(
+ placeHolder, "PlaceHolderType", uno.Any("short",TEXT))
+ return placeHolder
+
def getNamesWhichStartWith(self, allNames, prefix):
v = []
for i in allNames:
@@ -489,6 +680,26 @@ class ItemsTable(object):
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(AgendaTemplate._allItems):
+ workwith = AgendaTemplate._allItems[i]
+ t = Helper.getUnoPropertyValue(workwith, "TextTable")
+ if t == ItemsTable.table:
+ iText = workwith.String.lower().lstrip()
+ ai = AgendaTemplate.itemsCache[iText]
+ if ai is not None:
+ self.items.append(ai)
+ del AgendaTemplate._allItems[i]
+ AgendaTemplate.itemsMap[iText] = self
+ i -= 1
+ i += 1
'''
link the section to the template. this will restore the original table
@@ -635,6 +846,22 @@ class Topics(object):
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.
+ '''
+ items = {}
+ for i in AgendaTemplate._allItems:
+ t = Helper.getUnoPropertyValue(i, "TextTable")
+ if t == Topics.table:
+ cell = Helper.getUnoPropertyValue(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
@@ -649,16 +876,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)
# 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)
'''
@@ -875,6 +1104,68 @@ class Topics(object):
cursor.goRight(1, False)
'''
+A basic implementation of AgendaElement:
+writes a String to the given XText/XTextRange, and applies
+a ParaStyle to it (using the parent class).
+@author rp143992
+'''
+class TextElement(object):
+
+ def __init__(self, text_):
+ self.text = text_
+
+ def write(self, textRange):
+ textRange.String = self.text
+
+'''
+A Text element which, if the text to write is empty (null or "")
+inserts a placeholder instead.
+@author rp143992
+'''
+
+class PlaceholderTextElement(TextElement):
+
+ def __init__(self, textRange, placeHolderText_, hint_, xmsf_):
+ super(PlaceholderTextElement,self).__init__(textRange)
+
+ self.placeHolderText = placeHolderText_
+ self.hint = hint_
+ self.xmsf = xmsf_
+
+ def write(self, textRange):
+ textRange.String = self.text
+ if self.text is None or self.text == "":
+ try:
+ xTextContent = AgendaTemplate.createPlaceHolder(
+ self.xmsf, self.placeHolderText, self.hint)
+ textRange.Text.insertTextContent(
+ textRange.Start, xTextContent, True)
+ except Exception, ex:
+ traceback.print_exc()
+
+'''
+An Agenda element which writes no text, but inserts a placeholder, and formats
+it using a ParaStyleName.
+@author rp143992
+'''
+
+class PlaceholderElement(object):
+
+ def __init__(self, placeHolderText_, hint_, xmsf_):
+ self.placeHolderText = placeHolderText_
+ self.hint = hint_
+ self.xmsf = xmsf_
+
+ def write(self, textRange):
+ try:
+ xTextContent = AgendaTemplate.createPlaceHolder(
+ AgendaTemplate.document, self.placeHolderText, self.hint)
+ textRange.Text.insertTextContent(
+ textRange.Start, xTextContent, True)
+ except Exception, ex:
+ 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
@@ -884,15 +1175,15 @@ a place holder to the next cell.
class AgendaItem(object):
- def __init__(self, name, textRange, field):
- self.name = name
- self.field = field
- self.textRange = textRange
+ 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)
- self.textElement.String = cell
+ self.textElement.write(cell)
tableCursor.goRight(1, False)
#second field is actually always null...
# this is a preparation for adding placeholders.
diff --git a/wizards/com/sun/star/wizards/agenda/AgendaWizardDialogImpl.py b/wizards/com/sun/star/wizards/agenda/AgendaWizardDialogImpl.py
index d729f07e79c8..e1e07655e7f5 100644
--- a/wizards/com/sun/star/wizards/agenda/AgendaWizardDialogImpl.py
+++ b/wizards/com/sun/star/wizards/agenda/AgendaWizardDialogImpl.py
@@ -57,7 +57,7 @@ class AgendaWizardDialogImpl(AgendaWizardDialog):
"uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext"
xLocMSF = Desktop.connect(ConnectStr)
lw = AgendaWizardDialogImpl(xLocMSF)
- lw.startWizard(xLocMSF)
+ lw.startWizard()
except Exception as e:
print ("Wizard failure exception " + str(type(e)) +
" message " + str(e) + " args " + str(e.args) +
diff --git a/wizards/com/sun/star/wizards/agenda/AgendaWizardDialogResources.py b/wizards/com/sun/star/wizards/agenda/AgendaWizardDialogResources.py
index 92b827691052..8ddc3abb2bd3 100644
--- a/wizards/com/sun/star/wizards/agenda/AgendaWizardDialogResources.py
+++ b/wizards/com/sun/star/wizards/agenda/AgendaWizardDialogResources.py
@@ -166,53 +166,5 @@ class AgendaWizardDialogResources(Resource):
self.resButtonDown = self.getResText(
AgendaWizardDialogResources.RID_AGENDAWIZARDDIALOG_START + 71)
- #Create a dictionary for localising the template placeholders
- self.dictTemplatePlaceHolders = {
- "<title>" : self.resPlaceHolderTitle,
- "<date>" : self.resPlaceHolderDate,
- "<time>" : self.resPlaceHolderTime,
- "<location>" : self.resPlaceHolderLocation,
- "<meeting-type>" : self.reschkMeetingTitle_value,
- "<bring>" : self.reschkBring_value,
- "<read>" : self.reschkRead_value,
- "<notes>" : self.reschkNotes_value,
- "<called-by>" : self.itemCalledBy,
- "<facilitator>" : self.itemFacilitator,
- "<attendees>" : self.itemAttendees,
- "<notetaker>" : self.itemNotetaker,
- "<timekeeper>" : self.itemTimekeeper,
- "<observers>" : self.itemObservers,
- "<resource-persons>" : self.itemResource,
- "<num>" : "",
- "<topic>" : "",
- "<responsible>" : "",
- "<topic-time>" : "",
- "<mnum>" : "",
- "<mtopic>" : "",
- "<mresponsible>" : "",
- "<mtime>" : ""}
-
- '''
- section name <b>prefix</b> for sections that contain items.
- this is also used as table name prefix, since each items section
- must contain a table whos name is identical name to the section's name.
- '''
- SECTION_ITEMS = "AGENDA_ITEMS"
- '''
- the name of the section which contains the topics.
- '''
- SECTION_TOPICS = "AGENDA_TOPICS"
- '''
- the name of the parent minutes section.
- '''
- SECTION_MINUTES_ALL = "MINUTES_ALL"
- '''
- the name of the child nimutes section.
- This section will be duplicated for each topic.
- '''
- SECTION_MINUTES = "MINUTES"
-
-
- #Common Resources
self.resOverwriteWarning = self.getResText(
AgendaWizardDialogResources.RID_COMMON_START + 19)
diff --git a/wizards/com/sun/star/wizards/agenda/TemplateConsts.py b/wizards/com/sun/star/wizards/agenda/TemplateConsts.py
new file mode 100644
index 000000000000..1736fce642d7
--- /dev/null
+++ b/wizards/com/sun/star/wizards/agenda/TemplateConsts.py
@@ -0,0 +1,90 @@
+#
+# 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 .
+#
+FILLIN_TITLE = "<title>"
+FILLIN_TITLE = "<title>"
+FILLIN_DATE = "<date>"
+FILLIN_TIME = "<time>"
+FILLIN_LOCATION = "<location>"
+'''
+section name <b>prefix</b> for sections that contain items.
+this is also used as table name prefix, since each items section
+must contain a table whos name is identical name to the section's name.
+'''
+SECTION_ITEMS = "AGENDA_ITEMS"
+'''
+the name of the section which contains the topics.
+'''
+SECTION_TOPICS = "AGENDA_TOPICS"
+'''
+the name of the parent minutes section.
+'''
+SECTION_MINUTES_ALL = "MINUTES_ALL"
+'''
+the name of the child nimutes section.
+This section will be duplicated for each topic.
+'''
+SECTION_MINUTES = "MINUTES"
+'''
+taged headings and names.
+These will be searched in item tables (in the template) and will be
+replaced with resource strings.
+
+headings...
+'''
+FILLIN_MEETING_TYPE = "<meeting-type>"
+FILLIN_BRING = "<bring>"
+FILLIN_READ = "<read>"
+FILLIN_NOTES = "<notes>"
+'''
+names...
+'''
+FILLIN_CALLED_BY = "<called-by>"
+FILLIN_FACILITATOR = "<facilitator>"
+FILLIN_PARTICIPANTS = "<attendees>"
+FILLIN_NOTETAKER = "<notetaker>"
+FILLIN_TIMEKEEPER = "<timekeeper>"
+FILLIN_OBSERVERS = "<observers>"
+FILLIN_RESOURCE_PERSONS = "<resource-persons>"
+
+'''
+Fillins for the topic table.
+These strings will be searched inside the topic table as
+part of detecting its structure.
+'''
+FILLIN_TOPIC_NUMBER = "<num>"
+FILLIN_TOPIC_TOPIC = "<topic>"
+FILLIN_TOPIC_RESPONSIBLE = "<responsible>"
+FILLIN_TOPIC_TIME = "<topic-time>"
+'''
+fillins for minutes.
+These will be searched in the minutes section and will be replaced
+with the appropriate data.
+'''
+FILLIN_MINUTES_TITLE = "<minutes-title>"
+FILLIN_MINUTES_LOCATION = "<minutes-location>"
+FILLIN_MINUTES_DATE = "<minutes-date>"
+FILLIN_MINUTES_TIME = "<minutes-time>"
+'''
+Minutes-topic fillins
+These will be searched in the minutes-child-section, and
+will be replaced with topic data.
+'''
+FILLIN_MINUTE_NUM = "<mnum>"
+FILLIN_MINUTE_TOPIC = "<mtopic>"
+FILLIN_MINUTE_RESPONSIBLE = "<mresponsible>"
+FILLIN_MINUTE_TIME = "<mtime>"
diff --git a/wizards/com/sun/star/wizards/common/TextElement.py b/wizards/com/sun/star/wizards/common/TextElement.py
index 5d819b2d1102..f035808c4892 100644
--- a/wizards/com/sun/star/wizards/common/TextElement.py
+++ b/wizards/com/sun/star/wizards/common/TextElement.py
@@ -30,7 +30,7 @@ class TextElement(object):
def write(self):
try:
- if self.item is not None and not self.placeHolderText:
+ if self.item is not None:
self.item.String = ""
cursor = self.item.Text.createTextCursorByRange(
self.item.Start)