[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:
parent
7049e4780e
commit
1b3af98305
|
@ -1151,7 +1151,7 @@ class ToolMixin(BaseMixin):
|
||||||
textMessage = format_exception(tb[0], tb[1], tb[2], as_html=0)
|
textMessage = format_exception(tb[0], tb[1], tb[2], as_html=0)
|
||||||
textMessage = ''.join(textMessage).strip()
|
textMessage = ''.join(textMessage).strip()
|
||||||
self.log(textMessage, type='error')
|
self.log(textMessage, type='error')
|
||||||
return '<div class="error" align="center">%s</div>' % htmlMessage
|
return '<div class="error">%s</div>' % htmlMessage
|
||||||
|
|
||||||
def getMainPages(self):
|
def getMainPages(self):
|
||||||
'''Returns the main pages.'''
|
'''Returns the main pages.'''
|
||||||
|
|
|
@ -165,9 +165,7 @@ class PodImporter(DocImporter):
|
||||||
r = self.renderer
|
r = self.renderer
|
||||||
# Define where to store the ODT result.
|
# Define where to store the ODT result.
|
||||||
op = os.path
|
op = os.path
|
||||||
resFolder = op.dirname(self.importPath)
|
resOdt = op.join(self.getImportFolder(), '%s.odt' % self.getUuid())
|
||||||
resName = '%s.res.odt' % op.splitext(op.basename(self.importPath))[0]
|
|
||||||
resOdt = op.join(resFolder, resName)
|
|
||||||
# The POD template is in self.importPath
|
# The POD template is in self.importPath
|
||||||
renderer = r.__class__(self.importPath, self.context, resOdt,
|
renderer = r.__class__(self.importPath, self.context, resOdt,
|
||||||
pythonWithUnoPath=r.pyPath,
|
pythonWithUnoPath=r.pyPath,
|
||||||
|
|
|
@ -233,7 +233,8 @@ class Renderer:
|
||||||
'text': self.renderText,
|
'text': self.renderText,
|
||||||
'test': self.evalIfExpression,
|
'test': self.evalIfExpression,
|
||||||
'document': self.importDocument,
|
'document': self.importDocument,
|
||||||
'pod': self.importPod } # Default context
|
'pod': self.importPod,
|
||||||
|
'pageBreak': self.insertPageBreak} # Default context
|
||||||
if hasattr(context, '__dict__'):
|
if hasattr(context, '__dict__'):
|
||||||
evalContext.update(context.__dict__)
|
evalContext.update(context.__dict__)
|
||||||
elif isinstance(context, dict) or isinstance(context, UserDict):
|
elif isinstance(context, dict) or isinstance(context, UserDict):
|
||||||
|
@ -367,6 +368,12 @@ class Renderer:
|
||||||
imp.init(ctx, pageBreakBefore, pageBreakAfter)
|
imp.init(ctx, pageBreakBefore, pageBreakAfter)
|
||||||
return imp.run()
|
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):
|
def prepareFolders(self):
|
||||||
# Check if I can write the result
|
# Check if I can write the result
|
||||||
if not self.overwriteExisting and os.path.exists(self.result):
|
if not self.overwriteExisting and os.path.exists(self.result):
|
||||||
|
|
Loading…
Reference in a new issue