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

pyagenda: Fix a problem with template's sections

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