[pod] Bugfix in function 'pod'; added new method 'pageBreak' allowing to insert a page break via a note 'do xxx from pageBreak()'

This commit is contained in:
Gaetan Delannay 2013-05-31 15:23:28 +02:00
parent 7049e4780e
commit 1b3af98305
3 changed files with 10 additions and 5 deletions

View file

@ -1151,7 +1151,7 @@ class ToolMixin(BaseMixin):
textMessage = format_exception(tb[0], tb[1], tb[2], as_html=0)
textMessage = ''.join(textMessage).strip()
self.log(textMessage, type='error')
return '<div class="error" align="center">%s</div>' % htmlMessage
return '<div class="error">%s</div>' % htmlMessage
def getMainPages(self):
'''Returns the main pages.'''

View file

@ -165,9 +165,7 @@ class PodImporter(DocImporter):
r = self.renderer
# Define where to store the ODT result.
op = os.path
resFolder = op.dirname(self.importPath)
resName = '%s.res.odt' % op.splitext(op.basename(self.importPath))[0]
resOdt = op.join(resFolder, resName)
resOdt = op.join(self.getImportFolder(), '%s.odt' % self.getUuid())
# The POD template is in self.importPath
renderer = r.__class__(self.importPath, self.context, resOdt,
pythonWithUnoPath=r.pyPath,

View file

@ -233,7 +233,8 @@ class Renderer:
'text': self.renderText,
'test': self.evalIfExpression,
'document': self.importDocument,
'pod': self.importPod } # Default context
'pod': self.importPod,
'pageBreak': self.insertPageBreak} # Default context
if hasattr(context, '__dict__'):
evalContext.update(context.__dict__)
elif isinstance(context, dict) or isinstance(context, UserDict):
@ -367,6 +368,12 @@ class Renderer:
imp.init(ctx, pageBreakBefore, pageBreakAfter)
return imp.run()
def insertPageBreak(self):
'''Inserts a page break into the result.'''
textNs = self.currentParser.env.namespaces[PodEnvironment.NS_TEXT]
return '<%s:p %s:style-name="podPageBreak"></%s:p>' % \
(textNs, textNs, textNs)
def prepareFolders(self):
# Check if I can write the result
if not self.overwriteExisting and os.path.exists(self.result):