Modif for frames

bzr revid: pinky-9476736c7420bedb7327b52cdb1a7e56aee417be
This commit is contained in:
pinky 2006-12-08 09:07:43 +00:00
parent 2f9a0fcc2b
commit a871399d2f
1 changed files with 34 additions and 2 deletions

View File

@ -559,6 +559,13 @@ class _rml_flowable(object):
return platypus.NextPageTemplate(str(node.getAttribute('name'))) return platypus.NextPageTemplate(str(node.getAttribute('name')))
elif node.localName=='nextFrame': elif node.localName=='nextFrame':
return platypus.CondPageBreak(1000) # TODO: change the 1000 ! return platypus.CondPageBreak(1000) # TODO: change the 1000 !
elif node.localName == 'currentFrame':
#return platypus.CondPageBreak(1000) # TODO: change the 1000 !
from reportlab.platypus.doctemplate import CurrentFrameFlowable
return CurrentFrameFlowable(str(node.getAttribute('name')))
elif node.localName == 'frameEnd':
return False
return EndFrameFlowable()
else: else:
sys.stderr.write('Warning: flowable not yet implemented: %s !\n' % (node.localName,)) sys.stderr.write('Warning: flowable not yet implemented: %s !\n' % (node.localName,))
return None return None
@ -577,6 +584,31 @@ class _rml_flowable(object):
node = node.nextSibling node = node.nextSibling
return story return story
from reportlab.platypus.doctemplate import ActionFlowable
class EndFrameFlowable(ActionFlowable):
def __init__(self,resume=0):
ActionFlowable.__init__(self,('frameEnd',resume))
class TinyDocTemplate(platypus.BaseDocTemplate):
def handle_pageBegin(self):
self.page = self.page + 1
self.pageTemplate.beforeDrawPage(self.canv,self)
self.pageTemplate.checkPageSize(self.canv,self)
self.pageTemplate.onPage(self.canv,self)
for f in self.pageTemplate.frames: f._reset()
self.beforePage()
#keep a count of flowables added to this page. zero indicates bad stuff
self._curPageFlowableCount = 0
if hasattr(self,'_nextFrameIndex'):
del self._nextFrameIndex
for f in self.pageTemplate.frames:
if f.id == 'first':
self.frame = f
break
self.handle_frameBegin()
class _rml_template(object): class _rml_template(object):
def __init__(self, out, node, doc, images={}, path='.'): def __init__(self, out, node, doc, images={}, path='.'):
self.images= images self.images= images
@ -587,7 +619,7 @@ class _rml_template(object):
ps = map(lambda x:x.strip(), node.getAttribute('pageSize').replace(')', '').replace('(', '').split(',')) ps = map(lambda x:x.strip(), node.getAttribute('pageSize').replace(')', '').replace('(', '').split(','))
pageSize = ( utils.unit_get(ps[0]),utils.unit_get(ps[1]) ) pageSize = ( utils.unit_get(ps[0]),utils.unit_get(ps[1]) )
cm = reportlab.lib.units.cm cm = reportlab.lib.units.cm
self.doc_tmpl = platypus.BaseDocTemplate(out, pagesize=pageSize, **utils.attr_get(node, ['leftMargin','rightMargin','topMargin','bottomMargin'], {'allowSplitting':'int','showBoundary':'bool','title':'str','author':'str'})) self.doc_tmpl = TinyDocTemplate(out, pagesize=pageSize, **utils.attr_get(node, ['leftMargin','rightMargin','topMargin','bottomMargin'], {'allowSplitting':'int','showBoundary':'bool','title':'str','author':'str'}))
self.page_templates = [] self.page_templates = []
self.styles = doc.styles self.styles = doc.styles
self.doc = doc self.doc = doc
@ -595,7 +627,7 @@ class _rml_template(object):
for pt in pts: for pt in pts:
frames = [] frames = []
for frame_el in pt.getElementsByTagName('frame'): for frame_el in pt.getElementsByTagName('frame'):
frame = platypus.Frame( **(utils.attr_get(frame_el, ['x1','y1', 'width','height', 'leftPadding', 'rightPadding', 'bottomPadding', 'topPadding'], {'id':'text', 'showBoundary':'bool'})) ) frame = platypus.Frame( **(utils.attr_get(frame_el, ['x1','y1', 'width','height', 'leftPadding', 'rightPadding', 'bottomPadding', 'topPadding'], {'id':'str', 'showBoundary':'bool'})) )
frames.append( frame ) frames.append( frame )
gr = pt.getElementsByTagName('pageGraphics') gr = pt.getElementsByTagName('pageGraphics')
if len(gr): if len(gr):