[Libreoffice-commits] .: 5 commits - wizards/com
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Wed Nov 7 22:43:32 PST 2012
wizards/com/sun/star/wizards/agenda/AgendaTemplate.py | 481 ++++++++--
wizards/com/sun/star/wizards/agenda/AgendaWizardDialogImpl.py | 27
wizards/com/sun/star/wizards/agenda/AgendaWizardDialogResources.py | 54 -
wizards/com/sun/star/wizards/agenda/TemplateConsts.py | 92 +
wizards/com/sun/star/wizards/common/TextElement.py | 41
wizards/com/sun/star/wizards/fax/FaxWizardDialog.py | 2
wizards/com/sun/star/wizards/fax/FaxWizardDialogImpl.py | 13
wizards/com/sun/star/wizards/letter/LetterWizardDialogImpl.py | 10
wizards/com/sun/star/wizards/text/TextDocument.py | 7
wizards/com/sun/star/wizards/text/TextElement.py | 28
10 files changed, 550 insertions(+), 205 deletions(-)
New commits:
commit 0ff42915684fe773e58f5c77ce3c78470123412b
Author: Xisco Fauli <anistenis at gmail.com>
Date: Thu Nov 8 01:01:31 2012 +0100
pyagenda: remove duplicate code
Change-Id: I673818e6ab3ed5c430b9891af5c4bd5fe7ab146f
diff --git a/wizards/com/sun/star/wizards/agenda/AgendaTemplate.py b/wizards/com/sun/star/wizards/agenda/AgendaTemplate.py
index 0ecf8c3..4f99bfd 100644
--- a/wizards/com/sun/star/wizards/agenda/AgendaTemplate.py
+++ b/wizards/com/sun/star/wizards/agenda/AgendaTemplate.py
@@ -173,7 +173,6 @@ class AgendaTemplate(TextDocument):
def redraw(self, itemName):
AgendaTemplate.xTextDocument.lockControllers()
try:
- print "kinki"
# get the table in which the item is...
itemsTable = AgendaTemplate.itemsMap[itemName]
# rewrite the table.
@@ -450,9 +449,9 @@ class AgendaTemplate(TextDocument):
@classmethod
def writeTitle(self, te, tr, text):
if text is None:
- te.text = ""
+ te.placeHolderText = ""
else:
- te.text = text
+ te.placeHolderText = text
te.write(tr)
@classmethod
@@ -1141,18 +1140,18 @@ inserts a placeholder instead.
class PlaceholderTextElement(TextElement):
def __init__(self, textRange, placeHolderText_, hint_, xmsf_):
- super(PlaceholderTextElement,self).__init__(textRange, placeHolderText_)
+ super(PlaceholderTextElement,self).__init__(textRange, "")
- self.placeHolderText = placeHolderText_
+ self.text = placeHolderText_
self.hint = hint_
self.xmsf = xmsf_
def write(self, textRange):
- textRange.String = self.text
- if self.text is None or self.text == "":
+ textRange.String = self.placeHolderText
+ if self.placeHolderText is None or self.placeHolderText == "":
try:
xTextContent = AgendaTemplate.createPlaceHolder(
- self.xmsf, self.placeHolderText, self.hint)
+ self.xmsf, self.text, self.hint)
textRange.Text.insertTextContent(
textRange.Start, xTextContent, True)
except Exception, ex:
commit 531b7136b389ca0600865bd3a1b255bc71e67275
Author: Xisco Fauli <anistenis at gmail.com>
Date: Thu Nov 8 00:30:21 2012 +0100
pyagenda: remove duplicate code
Change-Id: Id0842c128038bc4ec2f0c3b0145c8bb9fac5142b
diff --git a/wizards/com/sun/star/wizards/agenda/AgendaTemplate.py b/wizards/com/sun/star/wizards/agenda/AgendaTemplate.py
index 95ca3da..0ecf8c3 100644
--- a/wizards/com/sun/star/wizards/agenda/AgendaTemplate.py
+++ b/wizards/com/sun/star/wizards/agenda/AgendaTemplate.py
@@ -18,7 +18,7 @@
import uno
import traceback
from threading import RLock
-from .TemplateConsts import TemplateConsts
+from ..text.TextElement import TextElement
from ..text.TextDocument import TextDocument
from ..common.FileAccess import FileAccess
from ..text.TextSectionHandler import TextSectionHandler
@@ -105,12 +105,12 @@ 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, templateConsts, listener):
+ super(AgendaTemplate,self).__init__(xmsf,listener, None,
"WIZARD_LIVE_PREVIEW")
- AgendaTemplate.agenda = agenda_
- AgendaTemplate.templateConsts = TemplateConsts
- self.resources = resources_
+ AgendaTemplate.agenda = agenda
+ AgendaTemplate.templateConsts = templateConsts
+ self.resources = resources
if AgendaTemplate.itemsCache is None:
self.initItemsCache()
@@ -173,6 +173,7 @@ class AgendaTemplate(TextDocument):
def redraw(self, itemName):
AgendaTemplate.xTextDocument.lockControllers()
try:
+ print "kinki"
# get the table in which the item is...
itemsTable = AgendaTemplate.itemsMap[itemName]
# rewrite the table.
@@ -234,28 +235,28 @@ class AgendaTemplate(TextDocument):
AgendaTemplate.itemsCache[
AgendaTemplate.templateConsts.FILLIN_MEETING_TYPE] = \
AgendaItem(AgendaTemplate.templateConsts.FILLIN_MEETING_TYPE,
- TextElement (self.resources.itemMeetingType),
+ self.resources.itemMeetingType,
PlaceholderElement(
self.resources.reschkMeetingTitle_value,
self.resources.resPlaceHolderHint, self.xMSF))
AgendaTemplate.itemsCache[
AgendaTemplate.templateConsts.FILLIN_BRING] = \
AgendaItem(AgendaTemplate.templateConsts.FILLIN_BRING,
- TextElement (self.resources.itemBring),
+ self.resources.itemBring,
PlaceholderElement (
self.resources.reschkBring_value,
self.resources.resPlaceHolderHint, self.xMSF))
AgendaTemplate.itemsCache[
AgendaTemplate.templateConsts.FILLIN_READ] = \
AgendaItem (AgendaTemplate.templateConsts.FILLIN_READ,
- TextElement (self.resources.itemRead),
+ self.resources.itemRead,
PlaceholderElement (
self.resources.reschkRead_value,
self.resources.resPlaceHolderHint, self.xMSF))
AgendaTemplate.itemsCache[
AgendaTemplate.templateConsts.FILLIN_NOTES] = \
AgendaItem (AgendaTemplate.templateConsts.FILLIN_NOTES,
- TextElement (self.resources.itemNote),
+ self.resources.itemNote,
PlaceholderElement (
self.resources.reschkNotes_value,
self.resources.resPlaceHolderHint, self.xMSF))
@@ -264,52 +265,52 @@ class AgendaTemplate(TextDocument):
AgendaTemplate.itemsCache[
AgendaTemplate.templateConsts.FILLIN_CALLED_BY] = \
AgendaItem(AgendaTemplate.templateConsts.FILLIN_CALLED_BY,
- TextElement (self.resources.itemCalledBy),
+ self.resources.itemCalledBy,
PlaceholderElement (
self.resources.reschkConvenedBy_value,
self.resources.resPlaceHolderHint, self.xMSF))
AgendaTemplate.itemsCache[
AgendaTemplate.templateConsts.FILLIN_FACILITATOR] = \
AgendaItem(AgendaTemplate.templateConsts.FILLIN_FACILITATOR,
- TextElement (self.resources.itemFacilitator),
+ self.resources.itemFacilitator,
PlaceholderElement (
self.resources.reschkPresiding_value,
self.resources.resPlaceHolderHint, self.xMSF))
AgendaTemplate.itemsCache[
AgendaTemplate.templateConsts.FILLIN_PARTICIPANTS] = \
AgendaItem(AgendaTemplate.templateConsts.FILLIN_PARTICIPANTS,
- TextElement (self.resources.itemAttendees),
+ self.resources.itemAttendees,
PlaceholderElement(
self.resources.reschkAttendees_value,
self.resources.resPlaceHolderHint, self.xMSF))
AgendaTemplate.itemsCache[
AgendaTemplate.templateConsts.FILLIN_NOTETAKER] = \
AgendaItem(AgendaTemplate.templateConsts.FILLIN_NOTETAKER,
- TextElement(self.resources.itemNotetaker),
+ self.resources.itemNotetaker,
PlaceholderElement(
self.resources.reschkNoteTaker_value,
self.resources.resPlaceHolderHint, self.xMSF))
AgendaTemplate.itemsCache[
AgendaTemplate.templateConsts.FILLIN_TIMEKEEPER] = \
AgendaItem(AgendaTemplate.templateConsts.FILLIN_TIMEKEEPER,
- TextElement (self.resources.itemTimekeeper),
+ self.resources.itemTimekeeper,
PlaceholderElement(
self.resources.reschkTimekeeper_value,
self.resources.resPlaceHolderHint, self.xMSF))
AgendaTemplate.itemsCache[
AgendaTemplate.templateConsts.FILLIN_OBSERVERS] = \
AgendaItem(AgendaTemplate.templateConsts.FILLIN_OBSERVERS,
- TextElement(self.resources.itemObservers),
+ self.resources.itemObservers,
PlaceholderElement(
self.resources.reschkObservers_value,
self.resources.resPlaceHolderHint, self.xMSF))
AgendaTemplate.itemsCache[
AgendaTemplate.templateConsts.FILLIN_RESOURCE_PERSONS] = \
AgendaItem(AgendaTemplate.templateConsts.FILLIN_RESOURCE_PERSONS,
- TextElement(self.resources.itemResource),
+ self.resources.itemResource,
PlaceholderElement(
self.resources.reschkResourcePersons_value,
- AgendaTemplate.templateConsts.resPlaceHolderHint, self.xMSF))
+ self.resources.resPlaceHolderHint, self.xMSF))
'''Initializes a template.<br/>
This method does the following tasks:<br/>
@@ -902,18 +903,16 @@ 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()] = ae
+ self.topicItems[cell.String.lower().lstrip()] = cell
except KeyError:
pass
- Topics.topicCells.append(ae)
+ Topics.topicCells.append(cell)
# goto next cell.
cursor.goRight(1, False)
'''
@@ -1134,20 +1133,6 @@ 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).
- at 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
@@ -1156,7 +1141,7 @@ inserts a placeholder instead.
class PlaceholderTextElement(TextElement):
def __init__(self, textRange, placeHolderText_, hint_, xmsf_):
- super(PlaceholderTextElement,self).__init__(textRange)
+ super(PlaceholderTextElement,self).__init__(textRange, placeHolderText_)
self.placeHolderText = placeHolderText_
self.hint = hint_
@@ -1213,7 +1198,7 @@ class AgendaItem(object):
def write(self, tableCursor):
cellname = tableCursor.RangeName
cell = ItemsTable.table.getCellByName(cellname)
- self.textElement.write(cell)
+ cell.String = self.textElement
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 d729f07..dd09c33 100644
--- a/wizards/com/sun/star/wizards/agenda/AgendaWizardDialogImpl.py
+++ b/wizards/com/sun/star/wizards/agenda/AgendaWizardDialogImpl.py
@@ -19,6 +19,7 @@ import traceback
from .AgendaWizardDialog import AgendaWizardDialog
from .AgendaWizardDialogConst import HID
from .AgendaTemplate import AgendaTemplate, FileAccess
+from .TemplateConsts import TemplateConsts
from .TopicsControl import TopicsControl
from .CGAgenda import CGAgenda
from ..ui.PathSelection import PathSelection
@@ -71,8 +72,10 @@ class AgendaWizardDialogImpl(AgendaWizardDialog):
# initialize the agenda template
self.agenda = CGAgenda()
+ self.templateConsts = TemplateConsts
self.agendaTemplate = AgendaTemplate(
- self.xMSF, self.agenda, self.resources, self)
+ self.xMSF, self.agenda, self.resources,
+ self.templateConsts, self)
# build the dialog.
self.drawNaviBar()
@@ -296,37 +299,37 @@ class AgendaWizardDialogImpl(AgendaWizardDialog):
AgendaTemplate.agenda.cp_IncludeMinutes = bool(self.chkMinutes.State)
def chkUseMeetingTypeItemChanged(self):
- AgendaTemplate.redraw(FILLIN_MEETING_TYPE)
+ AgendaTemplate.redraw(self.templateConsts.FILLIN_MEETING_TYPE)
def chkUseReadItemChanged(self):
- AgendaTemplate.redraw(FILLIN_READ)
+ AgendaTemplate.redraw(self.templateConsts.FILLIN_READ)
def chkUseBringItemChanged(self):
- AgendaTemplate.redraw(FILLIN_BRING)
+ AgendaTemplate.redraw(self.templateConsts.FILLIN_BRING)
def chkUseNotesItemChanged(self):
- AgendaTemplate.redraw(FILLIN_NOTES)
+ AgendaTemplate.redraw(self.templateConsts.FILLIN_NOTES)
def chkUseCalledByItemChanged(self):
- AgendaTemplate.redraw(FILLIN_CALLED_BY)
+ AgendaTemplate.redraw(self.templateConsts.FILLIN_CALLED_BY)
def chkUseFacilitatorItemChanged(self):
- AgendaTemplate.redraw(FILLIN_FACILITATOR)
+ AgendaTemplate.redraw(self.templateConsts.FILLIN_FACILITATOR)
def chkUseNoteTakerItemChanged(self):
- AgendaTemplate.redraw(FILLIN_NOTETAKER)
+ AgendaTemplate.redraw(self.templateConsts.FILLIN_NOTETAKER)
def chkUseTimeKeeperItemChanged(self):
- AgendaTemplate.redraw(FILLIN_TIMEKEEPER)
+ AgendaTemplate.redraw(self.templateConsts.FILLIN_TIMEKEEPER)
def chkUseAttendeesItemChanged(self):
- AgendaTemplate.redraw(FILLIN_PARTICIPANTS)
+ AgendaTemplate.redraw(self.templateConsts.FILLIN_PARTICIPANTS)
def chkUseObserversItemChanged(self):
- AgendaTemplate.redraw(FILLIN_OBSERVERS)
+ AgendaTemplate.redraw(self.templateConsts.FILLIN_OBSERVERS)
def chkUseResourcePersonsItemChanged(self):
- AgendaTemplate.redraw(FILLIN_RESOURCE_PERSONS)
+ AgendaTemplate.redraw(self.templateConsts.FILLIN_RESOURCE_PERSONS)
'''
convenience method.
commit d6ee3e33c9bbd485d7685a790ec0ad97f8c5c05f
Author: Xisco Fauli <anistenis at gmail.com>
Date: Wed Nov 7 22:41:15 2012 +0100
pywizards: Simplify textElement and move it to text folder
Change-Id: I1f9cde45c693de5bad091272f015e5cd7fb6beeb
diff --git a/wizards/com/sun/star/wizards/common/TextElement.py b/wizards/com/sun/star/wizards/common/TextElement.py
deleted file mode 100644
index f035808..0000000
--- a/wizards/com/sun/star/wizards/common/TextElement.py
+++ /dev/null
@@ -1,41 +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 traceback
-from .Helper import Helper
-from com.sun.star.text.PlaceholderType import TEXT
-
-class TextElement(object):
-
- def __init__(self, item, placeHolderText, hint, xmsf):
- self.item = item
- self.placeHolderText = placeHolderText
- self.xmsf = xmsf
- self.paraStyle = Helper.getUnoPropertyValue(
- item.Start, "ParaStyleName")
-
- def write(self):
- try:
- if self.item is not None:
- self.item.String = ""
- cursor = self.item.Text.createTextCursorByRange(
- self.item.Start)
- cursor.String = self.placeHolderText
- Helper.setUnoPropertyValue(
- cursor, "ParaStyleName", self.paraStyle)
- except Exception, e:
- traceback.print_exc()
diff --git a/wizards/com/sun/star/wizards/fax/FaxWizardDialogImpl.py b/wizards/com/sun/star/wizards/fax/FaxWizardDialogImpl.py
index 0bae71a..51d6894 100644
--- a/wizards/com/sun/star/wizards/fax/FaxWizardDialogImpl.py
+++ b/wizards/com/sun/star/wizards/fax/FaxWizardDialogImpl.py
@@ -25,13 +25,13 @@ from ..ui.event.RadioDataAware import RadioDataAware
from ..text.TextFieldHandler import TextFieldHandler
from ..text.TextDocument import TextDocument
from ..text.ViewHandler import ViewHandler
+from ..text.TextElement import TextElement
from ..common.Configuration import Configuration
from ..common.SystemDialog import SystemDialog
from ..common.NoValidPathException import NoValidPathException
from ..common.HelpIds import HelpIds
from ..common.FileAccess import FileAccess
from ..common.Desktop import Desktop
-from ..common.TextElement import TextElement
from ..document.OfficeDocument import OfficeDocument
from com.sun.star.awt.VclWindowPeerAttribute import YES_NO, DEF_NO
@@ -235,8 +235,7 @@ class FaxWizardDialogImpl(FaxWizardDialog):
for i in constRangeList:
text = i.String.lower()
- aux = TextElement(i, self.resources.dictConstants[text],
- "hint", self.xMSF)
+ aux = TextElement(i, self.resources.dictConstants[text])
aux.write()
def insertRoadmap(self):
diff --git a/wizards/com/sun/star/wizards/letter/LetterWizardDialogImpl.py b/wizards/com/sun/star/wizards/letter/LetterWizardDialogImpl.py
index 18fefbe..8f29477 100644
--- a/wizards/com/sun/star/wizards/letter/LetterWizardDialogImpl.py
+++ b/wizards/com/sun/star/wizards/letter/LetterWizardDialogImpl.py
@@ -25,10 +25,10 @@ from ..common.FileAccess import FileAccess
from ..common.Configuration import Configuration
from ..common.SystemDialog import SystemDialog
from ..common.Desktop import Desktop
-from ..common.TextElement import TextElement
from ..ui.PathSelection import PathSelection
from ..ui.event.UnoDataAware import UnoDataAware
from ..ui.event.RadioDataAware import RadioDataAware
+from ..text.TextElement import TextElement
from ..text.TextDocument import TextDocument
from ..text.ViewHandler import ViewHandler
from ..text.TextFieldHandler import TextFieldHandler
@@ -991,8 +991,7 @@ class LetterWizardDialogImpl(LetterWizardDialog):
for i in constRangeList:
text = i.String.lower()
- aux = TextElement(i, self.resources.dictConstants[text],
- "hint", self.xMSF)
+ aux = TextElement(i, self.resources.dictConstants[text])
aux.write()
def insertRoadmap(self):
diff --git a/wizards/com/sun/star/wizards/text/TextElement.py b/wizards/com/sun/star/wizards/text/TextElement.py
new file mode 100644
index 0000000..840c70e
--- /dev/null
+++ b/wizards/com/sun/star/wizards/text/TextElement.py
@@ -0,0 +1,28 @@
+#
+# 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 traceback
+
+class TextElement(object):
+
+ def __init__(self, item, placeHolderText):
+ self.item = item
+ self.placeHolderText = placeHolderText
+
+ def write(self):
+ if self.item is not None:
+ self.item.String = self.placeHolderText
commit a434b93b25c6aa652b925a8aaba1e3e0ec6986a9
Author: Xisco Fauli <anistenis at gmail.com>
Date: Wed Nov 7 22:30:33 2012 +0100
pyagenda: better refactor it little by little
Change-Id: I002a8e27139243172deb2868fdf2fca32944be03
diff --git a/wizards/com/sun/star/wizards/agenda/AgendaTemplate.py b/wizards/com/sun/star/wizards/agenda/AgendaTemplate.py
index bb85bcc..95ca3da 100644
--- a/wizards/com/sun/star/wizards/agenda/AgendaTemplate.py
+++ b/wizards/com/sun/star/wizards/agenda/AgendaTemplate.py
@@ -16,11 +16,13 @@
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
#
import uno
-from .TemplateConsts import *
+import traceback
from threading import RLock
-from ..text.TextDocument import *
+from .TemplateConsts import TemplateConsts
+from ..text.TextDocument import TextDocument
from ..common.FileAccess import FileAccess
from ..text.TextSectionHandler import TextSectionHandler
+from ..common.Helper import Helper
from datetime import date as dateTimeObject
@@ -76,7 +78,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.document
+table.AgendaTemplate.xTextDocument
<br/><br/>
A note about threads:<br/>
Many methods here are synchronized, in order to avoid colission made by
@@ -90,7 +92,7 @@ class AgendaTemplate(TextDocument):
_allItems = []
items = []
itemsMap = {}
- document = None
+ templateConsts = None
textSectionHandler = None
template = None
agenda = None
@@ -98,7 +100,7 @@ class AgendaTemplate(TextDocument):
'''constructor. The document is *not* loaded here.
only some formal members are set.
- @param AgendaTemplate.document_ service factory.
+ @param AgendaTemplate.xTextDocument_ service factory.
@param agenda_ the data model (CGAgenda)
@param resources_ resources.
'''
@@ -107,6 +109,7 @@ class AgendaTemplate(TextDocument):
super(AgendaTemplate,self).__init__(xmsf_,listener, None,
"WIZARD_LIVE_PREVIEW")
AgendaTemplate.agenda = agenda_
+ AgendaTemplate.templateConsts = TemplateConsts
self.resources = resources_
if AgendaTemplate.itemsCache is None:
@@ -117,7 +120,7 @@ class AgendaTemplate(TextDocument):
@synchronized(lock)
def load(self, templateURL, topics):
AgendaTemplate.template = self.calcTemplateName(templateURL)
- AgendaTemplate.document = self.loadAsPreview(templateURL, False)
+ AgendaTemplate.xTextDocument = self.loadAsPreview(templateURL, False)
self.xFrame.ComponentWindow.Enable = False
self.xTextDocument.lockControllers()
self.initialize()
@@ -194,27 +197,27 @@ class AgendaTemplate(TextDocument):
@classmethod
def isShowItem(self, itemName):
- if itemName == FILLIN_MEETING_TYPE:
+ if itemName == AgendaTemplate.templateConsts.FILLIN_MEETING_TYPE:
return AgendaTemplate.agenda.cp_ShowMeetingType
- elif itemName == FILLIN_READ:
+ elif itemName == AgendaTemplate.templateConsts.FILLIN_READ:
return AgendaTemplate.agenda.cp_ShowRead
- elif itemName == FILLIN_BRING:
+ elif itemName == AgendaTemplate.templateConsts.FILLIN_BRING:
return AgendaTemplate.agenda.cp_ShowBring
- elif itemName == FILLIN_NOTES:
+ elif itemName == AgendaTemplate.templateConsts.FILLIN_NOTES:
return AgendaTemplate.agenda.cp_ShowNotes
- elif itemName == FILLIN_FACILITATOR:
+ elif itemName == AgendaTemplate.templateConsts.FILLIN_FACILITATOR:
return AgendaTemplate.agenda.cp_ShowFacilitator
- elif itemName == FILLIN_TIMEKEEPER:
+ elif itemName == AgendaTemplate.templateConsts.FILLIN_TIMEKEEPER:
return AgendaTemplate.agenda.cp_ShowTimekeeper
- elif itemName == FILLIN_NOTETAKER:
+ elif itemName == AgendaTemplate.templateConsts.FILLIN_NOTETAKER:
return AgendaTemplate.agenda.cp_ShowNotetaker
- elif itemName == FILLIN_PARTICIPANTS:
+ elif itemName == AgendaTemplate.templateConsts.FILLIN_PARTICIPANTS:
return AgendaTemplate.agenda.cp_ShowAttendees
- elif itemName == FILLIN_CALLED_BY:
+ elif itemName == AgendaTemplate.templateConsts.FILLIN_CALLED_BY:
return AgendaTemplate.agenda.cp_ShowCalledBy
- elif itemName == FILLIN_OBSERVERS:
+ elif itemName == AgendaTemplate.templateConsts.FILLIN_OBSERVERS:
return AgendaTemplate.agenda.cp_ShowObservers
- elif itemName == FILLIN_RESOURCE_PERSONS:
+ elif itemName == AgendaTemplate.templateConsts.FILLIN_RESOURCE_PERSONS:
return AgendaTemplate.agenda.cp_ShowResourcePersons
else:
raise ValueError("No such item")
@@ -228,71 +231,85 @@ class AgendaTemplate(TextDocument):
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))
+ AgendaTemplate.itemsCache[
+ AgendaTemplate.templateConsts.FILLIN_MEETING_TYPE] = \
+ AgendaItem(AgendaTemplate.templateConsts.FILLIN_MEETING_TYPE,
+ TextElement (self.resources.itemMeetingType),
+ PlaceholderElement(
+ self.resources.reschkMeetingTitle_value,
+ self.resources.resPlaceHolderHint, self.xMSF))
+ AgendaTemplate.itemsCache[
+ AgendaTemplate.templateConsts.FILLIN_BRING] = \
+ AgendaItem(AgendaTemplate.templateConsts.FILLIN_BRING,
+ TextElement (self.resources.itemBring),
+ PlaceholderElement (
+ self.resources.reschkBring_value,
+ self.resources.resPlaceHolderHint, self.xMSF))
+ AgendaTemplate.itemsCache[
+ AgendaTemplate.templateConsts.FILLIN_READ] = \
+ AgendaItem (AgendaTemplate.templateConsts.FILLIN_READ,
+ TextElement (self.resources.itemRead),
+ PlaceholderElement (
+ self.resources.reschkRead_value,
+ self.resources.resPlaceHolderHint, self.xMSF))
+ AgendaTemplate.itemsCache[
+ AgendaTemplate.templateConsts.FILLIN_NOTES] = \
+ AgendaItem (AgendaTemplate.templateConsts.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,
+ AgendaTemplate.itemsCache[
+ AgendaTemplate.templateConsts.FILLIN_CALLED_BY] = \
+ AgendaItem(AgendaTemplate.templateConsts.FILLIN_CALLED_BY,
+ TextElement (self.resources.itemCalledBy),
+ PlaceholderElement (
+ self.resources.reschkConvenedBy_value,
+ self.resources.resPlaceHolderHint, self.xMSF))
+ AgendaTemplate.itemsCache[
+ AgendaTemplate.templateConsts.FILLIN_FACILITATOR] = \
+ AgendaItem(AgendaTemplate.templateConsts.FILLIN_FACILITATOR,
+ TextElement (self.resources.itemFacilitator),
+ PlaceholderElement (
+ self.resources.reschkPresiding_value,
+ self.resources.resPlaceHolderHint, self.xMSF))
+ AgendaTemplate.itemsCache[
+ AgendaTemplate.templateConsts.FILLIN_PARTICIPANTS] = \
+ AgendaItem(AgendaTemplate.templateConsts.FILLIN_PARTICIPANTS,
+ TextElement (self.resources.itemAttendees),
+ PlaceholderElement(
+ self.resources.reschkAttendees_value,
+ self.resources.resPlaceHolderHint, self.xMSF))
+ AgendaTemplate.itemsCache[
+ AgendaTemplate.templateConsts.FILLIN_NOTETAKER] = \
+ AgendaItem(AgendaTemplate.templateConsts.FILLIN_NOTETAKER,
+ TextElement(self.resources.itemNotetaker),
+ PlaceholderElement(
+ self.resources.reschkNoteTaker_value,
+ self.resources.resPlaceHolderHint, self.xMSF))
+ AgendaTemplate.itemsCache[
+ AgendaTemplate.templateConsts.FILLIN_TIMEKEEPER] = \
+ AgendaItem(AgendaTemplate.templateConsts.FILLIN_TIMEKEEPER,
+ TextElement (self.resources.itemTimekeeper),
+ PlaceholderElement(
+ self.resources.reschkTimekeeper_value,
+ self.resources.resPlaceHolderHint, self.xMSF))
+ AgendaTemplate.itemsCache[
+ AgendaTemplate.templateConsts.FILLIN_OBSERVERS] = \
+ AgendaItem(AgendaTemplate.templateConsts.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))
+ PlaceholderElement(
+ self.resources.reschkObservers_value,
+ self.resources.resPlaceHolderHint, self.xMSF))
+ AgendaTemplate.itemsCache[
+ AgendaTemplate.templateConsts.FILLIN_RESOURCE_PERSONS] = \
+ AgendaItem(AgendaTemplate.templateConsts.FILLIN_RESOURCE_PERSONS,
+ TextElement(self.resources.itemResource),
+ PlaceholderElement(
+ self.resources.reschkResourcePersons_value,
+ AgendaTemplate.templateConsts.resPlaceHolderHint, self.xMSF))
'''Initializes a template.<br/>
This method does the following tasks:<br/>
@@ -312,22 +329,24 @@ class AgendaTemplate(TextDocument):
and create the date and time formatters.
'''
AgendaTemplate.dateUtils = Helper.DateUtils(
- self.xMSF, AgendaTemplate.document)
+ self.xMSF, AgendaTemplate.xTextDocument)
AgendaTemplate.formatter = AgendaTemplate.dateUtils.formatter
- AgendaTemplate.dateFormat = AgendaTemplate.dateUtils.getFormat(DATE_SYSTEM_LONG)
- AgendaTemplate.timeFormat = AgendaTemplate.dateUtils.getFormat(TIME_HHMM)
+ AgendaTemplate.dateFormat = \
+ AgendaTemplate.dateUtils.getFormat(DATE_SYSTEM_LONG)
+ AgendaTemplate.timeFormat = \
+ AgendaTemplate.dateUtils.getFormat(TIME_HHMM)
'''
get the document properties object.
'''
- self.m_xDocProps = AgendaTemplate.document.DocumentProperties
+ self.m_xDocProps = AgendaTemplate.xTextDocument.DocumentProperties
self.initItemsCache()
- AgendaTemplate._allItems = self.searchFillInItems()
+ AgendaTemplate._allItems = self.searchFillInItems(0)
self.initializeTitles()
self.initializeItemsSections()
AgendaTemplate.textSectionHandler = TextSectionHandler(
- AgendaTemplate.document, AgendaTemplate.document)
+ AgendaTemplate.xTextDocument, AgendaTemplate.xTextDocument)
self.topics = Topics()
del AgendaTemplate._allItems[:]
AgendaTemplate._allItems = None
@@ -338,43 +357,36 @@ class AgendaTemplate(TextDocument):
'''
def initializeTitles(self):
- i = 0
- while i < len(AgendaTemplate._allItems):
- workwith = AgendaTemplate._allItems[i]
- text = workwith.String.lstrip().lower()
- if text == FILLIN_TITLE:
+ auxList = []
+ for i in AgendaTemplate._allItems:
+ text = i.String.lstrip().lower()
+ if text == AgendaTemplate.templateConsts.FILLIN_TITLE:
AgendaTemplate.teTitle = PlaceholderTextElement(
- workwith, self.resources.resPlaceHolderTitle,
+ i, self.resources.resPlaceHolderTitle,
self.resources.resPlaceHolderHint,
- AgendaTemplate.document)
- AgendaTemplate.trTitle = workwith
- del AgendaTemplate._allItems[i]
- i -= 1
- elif text == FILLIN_DATE:
+ AgendaTemplate.xTextDocument)
+ AgendaTemplate.trTitle = i
+ elif text == AgendaTemplate.templateConsts.FILLIN_DATE:
AgendaTemplate.teDate = PlaceholderTextElement(
- workwith, self.resources.resPlaceHolderDate,
+ i, self.resources.resPlaceHolderDate,
self.resources.resPlaceHolderHint,
- AgendaTemplate.document)
- AgendaTemplate.trDate = workwith
- del AgendaTemplate._allItems[i]
- i -= 1
- elif text == FILLIN_TIME:
+ AgendaTemplate.xTextDocument)
+ AgendaTemplate.trDate = i
+ elif text == AgendaTemplate.templateConsts.FILLIN_TIME:
AgendaTemplate.teTime = PlaceholderTextElement(
- workwith, self.resources.resPlaceHolderTime,
+ i, self.resources.resPlaceHolderTime,
self.resources.resPlaceHolderHint,
- AgendaTemplate.document)
- AgendaTemplate.trTime = workwith
- del AgendaTemplate._allItems[i]
- i -= 1
- elif text == FILLIN_LOCATION:
+ AgendaTemplate.xTextDocument)
+ AgendaTemplate.trTime = i
+ elif text == AgendaTemplate.templateConsts.FILLIN_LOCATION:
AgendaTemplate.teLocation = PlaceholderTextElement(
- workwith, self.resources.resPlaceHolderLocation,
+ i, self.resources.resPlaceHolderLocation,
self.resources.resPlaceHolderHint,
- AgendaTemplate.document)
- AgendaTemplate.trLocation = workwith
- del AgendaTemplate._allItems[i]
- i -= 1
- i += 1
+ AgendaTemplate.xTextDocument)
+ AgendaTemplate.trLocation = i
+ else:
+ auxList.append(i)
+ AgendaTemplate._allItems = auxList
'''
analyze the item sections in the template.
@@ -382,7 +394,8 @@ class AgendaTemplate(TextDocument):
'''
def initializeItemsSections(self):
- sections = self.getSections(AgendaTemplate.document, SECTION_ITEMS)
+ sections = self.getSections(
+ AgendaTemplate.xTextDocument, AgendaTemplate.templateConsts.SECTION_ITEMS)
# for each section - there is a table...
self.itemsTables = []
for i in sections:
@@ -402,11 +415,11 @@ class AgendaTemplate(TextDocument):
@classmethod
def getSection(self, name):
- return getattr(AgendaTemplate.document.TextSections, name)
+ return getattr(AgendaTemplate.xTextDocument.TextSections, name)
@classmethod
def getTable(self, name):
- return getattr(AgendaTemplate.document.TextTables, name)
+ return getattr(AgendaTemplate.xTextDocument.TextTables, name)
@classmethod
@synchronized(lock)
@@ -460,7 +473,8 @@ class AgendaTemplate(TextDocument):
time = int(s)
t = ((time / float(1000000)) / float(24)) \
+ ((time % 1000000) / float(1000000)) / float(35)
- return self.formatter.convertNumberToString(AgendaTemplate.timeFormat, t)
+ return self.formatter.convertNumberToString(
+ AgendaTemplate.timeFormat, t)
@synchronized(lock)
def finish(self, topics):
@@ -471,11 +485,12 @@ class AgendaTemplate(TextDocument):
'''
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 entireley from the document.
+ When finishing the wizard removes this sections
+ entirely from the document.
'''
def deleteHiddenSections(self):
- allSections = AgendaTemplate.document.TextSections.ElementNames
+ allSections = AgendaTemplate.xTextDocument.TextSections.ElementNames
try:
for i in allSections:
self.section = self.getSection(i)
@@ -503,7 +518,8 @@ class AgendaTemplate(TextDocument):
if not AgendaTemplate.agenda.cp_IncludeMinutes \
or len(topicsData) <= 1:
try:
- minutesAllSection = self.getSection(SECTION_MINUTES_ALL)
+ minutesAllSection = self.getSection(
+ AgendaTemplate.templateConsts.SECTION_MINUTES_ALL)
minutesAllSection.Anchor.String = ""
except Exception, ex:
traceback.print_exc()
@@ -517,19 +533,23 @@ class AgendaTemplate(TextDocument):
itemIndex = 0
for item in self.items:
itemText = item.String.lstrip().lower()
- if itemText == FILLIN_MINUTES_TITLE:
+ if itemText == \
+ AgendaTemplate.templateConsts.FILLIN_MINUTES_TITLE:
self.fillMinutesItem(
item, AgendaTemplate.agenda.cp_Title,
self.resources.resPlaceHolderTitle)
- elif itemText == FILLIN_MINUTES_LOCATION:
+ elif itemText == \
+ AgendaTemplate.templateConsts.FILLIN_MINUTES_LOCATION:
self.fillMinutesItem(
item, AgendaTemplate.agenda.cp_Location,
self.resources.resPlaceHolderLocation)
- elif itemText == FILLIN_MINUTES_DATE:
+ elif itemText == \
+ AgendaTemplate.templateConsts.FILLIN_MINUTES_DATE:
self.fillMinutesItem(
item, getDateString(AgendaTemplate.agenda.cp_Date),
self.resources.resPlaceHolderDate)
- elif itemText == FILLIN_MINUTES_TIME:
+ elif itemText == \
+ AgendaTemplate.templateConsts.FILLIN_MINUTES_TIME:
self.fillMinutesItem(
item, getTimeString(AgendaTemplate.agenda.cp_Time),
self.resources.resPlaceHolderTime)
@@ -548,13 +568,17 @@ class AgendaTemplate(TextDocument):
itemIndex = 0
for item in self.items:
itemText = item.String.lstrip().lower()
- if itemText == FILLIN_MINUTE_NUM:
+ if itemText == \
+ AgendaTemplate.templateConsts.FILLIN_MINUTE_NUM:
fillMinutesItem(item, topic[0].Value, "")
- elif itemText == FILLIN_MINUTE_TOPIC:
+ elif itemText == \
+ AgendaTemplate.templateConsts.FILLIN_MINUTE_TOPIC:
fillMinutesItem(item, topic[1].Value, "")
- elif itemText == FILLIN_MINUTE_RESPONSIBLE:
+ elif itemText == \
+ AgendaTemplate.templateConsts.FILLIN_MINUTE_RESPONSIBLE:
fillMinutesItem(item, topic[2].Value, "")
- elif itemText == FILLIN_MINUTE_TIME:
+ elif itemText == \
+ AgendaTemplate.templateConsts.FILLIN_MINUTE_TIME:
topicTime = 0
try:
topicTime = topic[3].Value
@@ -575,11 +599,12 @@ class AgendaTemplate(TextDocument):
fillMinutesItem(item, time, "")
AgendaTemplate.textSectionHandler.removeTextSectionbyName(
- SECTION_MINUTES)
+ AgendaTemplate.templateConsts.SECTION_MINUTES)
# after the last section we do not insert a one.
if i < len(topicsData) - 2:
AgendaTemplate.textSectionHandler.insertTextSection(
- SECTION_MINUTES, AgendaTemplate.template, False)
+ AgendaTemplate.templateConsts.SECTION_MINUTES,
+ AgendaTemplate.template, False)
except Exception, ex:
traceback.print_exc()
@@ -601,7 +626,7 @@ class AgendaTemplate(TextDocument):
if text == None or text == "":
if placeholder != None and not placeholder == "":
placeHolder = createPlaceHolder(
- AgendaTemplate.document, placeholder,
+ AgendaTemplate.xTextDocument, placeholder,
self.resources.resPlaceHolderHint)
try:
Range.Start.Text.insertTextContent(
@@ -610,7 +635,7 @@ class AgendaTemplate(TextDocument):
traceback.print_exc()
'''creates a placeholder field with the given text and given hint.
- @param AgendaTemplate.document service factory
+ @param AgendaTemplate.xTextDocument service factory
@param ph place holder text
@param hint hint text
@return the place holder field.
@@ -838,12 +863,13 @@ class Topics(object):
self.firstRowFormat = []
# This is the topics table. say hallo :-)
try:
- Topics.table = AgendaTemplate.getTable(SECTION_TOPICS)
+ Topics.table = AgendaTemplate.getTable(
+ AgendaTemplate.templateConsts.SECTION_TOPICS)
except Exception, ex:
traceback.print_exc()
raise AttributeError (
"Fatal error while loading template: table " + \
- SECTION_TOPICS + " could not load.")
+ AgendaTemplate.templateConsts.SECTION_TOPICS + " could not load.")
'''
first I store all <*> ranges
@@ -895,13 +921,17 @@ class Topics(object):
'''
Topics.numCell = Topics.topicCells.index(
- self.topicItems[FILLIN_TOPIC_NUMBER])
+ self.topicItems[
+ AgendaTemplate.templateConsts.FILLIN_TOPIC_NUMBER])
Topics.topicCell = Topics.topicCells.index(
- self.topicItems[FILLIN_TOPIC_TOPIC])
+ self.topicItems[
+ AgendaTemplate.templateConsts.FILLIN_TOPIC_TOPIC])
Topics.responsibleCell = Topics.topicCells.index(
- self.topicItems[FILLIN_TOPIC_RESPONSIBLE])
+ self.topicItems[
+ AgendaTemplate.templateConsts.FILLIN_TOPIC_RESPONSIBLE])
Topics.timeCell = Topics.topicCells.index(
- self.topicItems[FILLIN_TOPIC_TIME])
+ self.topicItems[
+ AgendaTemplate.templateConsts.FILLIN_TOPIC_TIME])
'''@param topic the topic number to write
@param data the data of the topic.
@@ -1159,7 +1189,7 @@ class PlaceholderElement(object):
def write(self, textRange):
try:
xTextContent = AgendaTemplate.createPlaceHolder(
- AgendaTemplate.document, self.placeHolderText, self.hint)
+ AgendaTemplate.xTextDocument, self.placeHolderText, self.hint)
textRange.Text.insertTextContent(
textRange.Start, xTextContent, True)
except Exception, ex:
diff --git a/wizards/com/sun/star/wizards/agenda/AgendaWizardDialogImpl.py b/wizards/com/sun/star/wizards/agenda/AgendaWizardDialogImpl.py
index e1e0765..d729f07 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()
+ lw.startWizard(xLocMSF)
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 8ddc3ab..67056fb 100644
--- a/wizards/com/sun/star/wizards/agenda/AgendaWizardDialogResources.py
+++ b/wizards/com/sun/star/wizards/agenda/AgendaWizardDialogResources.py
@@ -18,9 +18,14 @@
from wizards.common.Resource import Resource
class AgendaWizardDialogResources(Resource):
+
MODULE_NAME = "dbw"
RID_AGENDAWIZARDDIALOG_START = 5000
RID_COMMON_START = 500
+ SECTION_ITEMS = "AGENDA_ITEMS"
+ SECTION_TOPICS = "AGENDA_TOPICS"
+ SECTION_MINUTES_ALL = "MINUTES_ALL"
+ SECTION_MINUTES = "MINUTES"
def __init__(self, xmsf):
super(AgendaWizardDialogResources,self).__init__(xmsf,
@@ -164,7 +169,8 @@ class AgendaWizardDialogResources(Resource):
self.resButtonUp = self.getResText(
AgendaWizardDialogResources.RID_AGENDAWIZARDDIALOG_START + 70)
self.resButtonDown = self.getResText(
- AgendaWizardDialogResources.RID_AGENDAWIZARDDIALOG_START + 71)
+ AgendaWizardDialogResources.RID_AGENDAWIZARDDIALOG_START + 71)
+ #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
index 1736fce..8d9f669 100644
--- a/wizards/com/sun/star/wizards/agenda/TemplateConsts.py
+++ b/wizards/com/sun/star/wizards/agenda/TemplateConsts.py
@@ -15,76 +15,78 @@
# 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>"
+class TemplateConsts:
+ 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.
-'''
-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>"
+ 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/fax/FaxWizardDialog.py b/wizards/com/sun/star/wizards/fax/FaxWizardDialog.py
index 729d33c..9f033d7 100644
--- a/wizards/com/sun/star/wizards/fax/FaxWizardDialog.py
+++ b/wizards/com/sun/star/wizards/fax/FaxWizardDialog.py
@@ -16,7 +16,7 @@
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
#
from .FaxWizardDialogResources import FaxWizardDialogResources
-from .FaxWizardDialogConst import FaxWizardDialogConst, HIDMAIN
+from .FaxWizardDialogConst import FaxWizardDialogConst, HIDMAIN, HID
from ..ui.WizardDialog import WizardDialog, uno, Helper, UIConsts, \
PropertyNames
diff --git a/wizards/com/sun/star/wizards/fax/FaxWizardDialogImpl.py b/wizards/com/sun/star/wizards/fax/FaxWizardDialogImpl.py
index 70993e1..0bae71a 100644
--- a/wizards/com/sun/star/wizards/fax/FaxWizardDialogImpl.py
+++ b/wizards/com/sun/star/wizards/fax/FaxWizardDialogImpl.py
@@ -16,10 +16,9 @@
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
#
import traceback
-from .FaxWizardDialog import FaxWizardDialog, Helper, PropertyNames, uno
+from .FaxWizardDialog import FaxWizardDialog, Helper, PropertyNames, uno, HID
from .CGFaxWizard import CGFaxWizard
from .FaxDocument import FaxDocument
-from .FaxWizardDialogConst import HID
from ..ui.PathSelection import PathSelection
from ..ui.event.UnoDataAware import UnoDataAware
from ..ui.event.RadioDataAware import RadioDataAware
@@ -234,10 +233,9 @@ class FaxWizardDialogImpl(FaxWizardDialog):
'''Localise the template'''
constRangeList = TextDocument.searchFillInItems(1)
- for i in xrange(constRangeList.Count):
- item = constRangeList.getByIndex(i)
- text = item.String.lower()
- aux = TextElement(item, self.resources.dictConstants[text],
+ for i in constRangeList:
+ text = i.String.lower()
+ aux = TextElement(i, self.resources.dictConstants[text],
"hint", self.xMSF)
aux.write()
diff --git a/wizards/com/sun/star/wizards/letter/LetterWizardDialogImpl.py b/wizards/com/sun/star/wizards/letter/LetterWizardDialogImpl.py
index bfdd667..18fefbe 100644
--- a/wizards/com/sun/star/wizards/letter/LetterWizardDialogImpl.py
+++ b/wizards/com/sun/star/wizards/letter/LetterWizardDialogImpl.py
@@ -989,10 +989,9 @@ class LetterWizardDialogImpl(LetterWizardDialog):
'''Localise the template'''
constRangeList = TextDocument.searchFillInItems(1)
- for i in xrange(constRangeList.Count):
- item = constRangeList.getByIndex(i)
- text = item.String.lower()
- aux = TextElement(item, self.resources.dictConstants[text],
+ for i in constRangeList:
+ text = i.String.lower()
+ aux = TextElement(i, self.resources.dictConstants[text],
"hint", self.xMSF)
aux.write()
diff --git a/wizards/com/sun/star/wizards/text/TextDocument.py b/wizards/com/sun/star/wizards/text/TextDocument.py
index 0198d6d..5889f2c 100644
--- a/wizards/com/sun/star/wizards/text/TextDocument.py
+++ b/wizards/com/sun/star/wizards/text/TextDocument.py
@@ -250,4 +250,9 @@ class TextDocument(object):
sd.setPropertyValue("SearchRegularExpression", True)
sd.setPropertyValue("SearchWords", True)
- return self.xTextDocument.findAll(sd)
+ auxList = []
+ allItems = self.xTextDocument.findAll(sd)
+ for i in xrange(allItems.Count):
+ auxList.append(allItems.getByIndex(i))
+
+ return auxList
commit 1d615feed25842544a5ab3ae4265dc9c2de6f107
Author: Xisco Fauli <anistenis at gmail.com>
Date: Wed Nov 7 20:33:23 2012 +0100
Revert "pyagenda: rework AgendaTemplate.py. Still some work to do"
This reverts commit 9545c85db39144705fb50409b7f4b7a3cf472150.
diff --git a/wizards/com/sun/star/wizards/agenda/AgendaTemplate.py b/wizards/com/sun/star/wizards/agenda/AgendaTemplate.py
index 3e928a8..bb85bcc 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).
+ at 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.
+ at 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.
+ at 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 d729f07..e1e0765 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 92b8276..8ddc3ab 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 0000000..1736fce
--- /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 5d819b2..f035808 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)
More information about the Libreoffice-commits
mailing list