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