Commit 34f6c0b8 authored by Tatuya Kamada's avatar Tatuya Kamada

Append a new feature to the ERP5OOoTemplate, to set a stylesheet

dinamically.
The feature can set a stylesheet by a script with a parameter.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@25718 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent cfefd8bf
...@@ -147,6 +147,7 @@ class OOoTemplate(ZopePageTemplate): ...@@ -147,6 +147,7 @@ class OOoTemplate(ZopePageTemplate):
# Default Attributes # Default Attributes
ooo_stylesheet = 'Base_getODTStyleSheet' ooo_stylesheet = 'Base_getODTStyleSheet'
ooo_script_name = None
ooo_xml_file_id = 'content.xml' ooo_xml_file_id = 'content.xml'
# Default content type # Default content type
...@@ -225,13 +226,14 @@ class OOoTemplate(ZopePageTemplate): ...@@ -225,13 +226,14 @@ class OOoTemplate(ZopePageTemplate):
self.write(text) self.write(text)
security.declareProtected('Change Page Templates', 'doSettings') security.declareProtected('Change Page Templates', 'doSettings')
def doSettings(self, REQUEST, title, xml_file_id, ooo_stylesheet): def doSettings(self, REQUEST, title, xml_file_id, ooo_stylesheet, script_name=None):
""" """
Change title, xml_file_id and ooo_stylesheet. Change title, xml_file_id and ooo_stylesheet.
""" """
if SUPPORTS_WEBDAV_LOCKS and self.wl_isLocked(): if SUPPORTS_WEBDAV_LOCKS and self.wl_isLocked():
raise ResourceLockedError, "File is locked via WebDAV" raise ResourceLockedError, "File is locked via WebDAV"
self.ooo_stylesheet = ooo_stylesheet self.ooo_stylesheet = ooo_stylesheet
self.ooo_script_name = script_name
self.ooo_xml_file_id = xml_file_id self.ooo_xml_file_id = xml_file_id
self.pt_setTitle(title) self.pt_setTitle(title)
#REQUEST.set('text', self.read()) # May not equal 'text'! #REQUEST.set('text', self.read()) # May not equal 'text'!
...@@ -426,6 +428,12 @@ class OOoTemplate(ZopePageTemplate): ...@@ -426,6 +428,12 @@ class OOoTemplate(ZopePageTemplate):
# This is a system error # This is a system error
raise ValueError, 'Can not render a template without a parent acquisition context' raise ValueError, 'Can not render a template without a parent acquisition context'
# Retrieve master document # Retrieve master document
ooo_document = None
# If script is setting, call it
if (self.ooo_script_name is not None) and (self.ooo_script_name != ''):
ooo_script = getattr(here, self.ooo_script_name)
ooo_document = ooo_script(self.ooo_stylesheet)
else:
ooo_document = getattr(here, self.ooo_stylesheet) ooo_document = getattr(here, self.ooo_stylesheet)
format = request.get('format') format = request.get('format')
try: try:
......
This diff is collapsed.
...@@ -21,6 +21,12 @@ ...@@ -21,6 +21,12 @@
<td><input name="ooo_stylesheet" value="default_ooo_template" type="text" size="20" <td><input name="ooo_stylesheet" value="default_ooo_template" type="text" size="20"
tal:attributes="value request/ooo_stylesheet | here/ooo_stylesheet | nothing"/></td> tal:attributes="value request/ooo_stylesheet | here/ooo_stylesheet | nothing"/></td>
</tr> </tr>
<tr>
<td class="form-label">OOo Stylesheet Script</td>
<td><input name="script_name" value="default_ooo_script" type="text" size="20"
tal:attributes="value request/ooo_script_name | here/ooo_script_name | nothing"/></td>
</tr>
<tr> <tr>
<td align="left" valign="top"> <td align="left" valign="top">
<div class="form-element"> <div class="form-element">
......
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