Kaydet (Commit) c71a811b authored tarafından Xisco Fauli's avatar Xisco Fauli

pyagenda: Change to new model and remove unused code

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