62 pm.set_page_dims( self.page_width*cm, self.page_height*cm ) |
62 pm.set_page_dims( self.page_width*cm, self.page_height*cm ) |
63 pm.set_page_margins({u'top' : self.page_tmargin*cm, |
63 pm.set_page_margins({u'top' : self.page_tmargin*cm, |
64 u'bottom': self.page_bmargin*cm, |
64 u'bottom': self.page_bmargin*cm, |
65 u'left' : self.page_lmargin*cm, |
65 u'left' : self.page_lmargin*cm, |
66 u'right' : self.page_rmargin*cm }) |
66 u'right' : self.page_rmargin*cm }) |
67 pm.add_peripheral_region(u"end",self.hf_height) |
67 pm.add_peripheral_region(u"end", self.hf_height) |
68 dims = {} |
68 dims = {} |
69 dims[u"bottom"] = self.hf_height + 0.25 |
69 dims[u"bottom"] = self.hf_height + 0.25 |
70 pm.set_main_region_margins(dims) |
70 pm.set_main_region_margins(dims) |
71 return [pm] |
71 return [pm] |
72 |
72 |
80 |
80 |
81 ps = self.create_pagesequence(u"page-report") |
81 ps = self.create_pagesequence(u"page-report") |
82 props = { u"force-page-count": u"no-force", |
82 props = { u"force-page-count": u"no-force", |
83 u"initial-page-number": u"1", |
83 u"initial-page-number": u"1", |
84 u"format": u"1", } |
84 u"format": u"1", } |
85 self._output_properties(ps,props) |
85 self._output_properties(ps, props) |
86 |
86 |
87 sc = self.create_staticcontent(ps, u"end") |
87 sc = self.create_staticcontent(ps, u"end") |
88 sc_bl = self.create_block(sc) |
88 sc_bl = self.create_block(sc) |
89 attrs = { u"hyphenate": u"false", } |
89 attrs = { u"hyphenate": u"false", } |
90 attrs[u"font-size"] = u"%.1fpt" %(self.font_size*0.7) |
90 attrs[u"font-size"] = u"%.1fpt" % (self.font_size * 0.7) |
91 attrs[u"language"] = self.lang |
91 attrs[u"language"] = self.lang |
92 attrs[u"text-align"] = u"center" |
92 attrs[u"text-align"] = u"center" |
93 self._output_properties(sc_bl,attrs) |
93 self._output_properties(sc_bl, attrs) |
94 sc_bl.text = u"Page" + u" " # ### Should be localised! |
94 sc_bl.text = u"Page" + u" " # ### Should be localised! |
95 pn = self.create_pagenumber(sc_bl) |
95 pn = self.create_pagenumber(sc_bl) |
96 pn.tail = u"/" |
96 pn.tail = u"/" |
97 lpn = self.create_pagenumbercitation( sc_bl, |
97 self.create_pagenumbercitation( |
98 u"last-block-of-report-%d" % params[u"context_pos"] |
98 sc_bl, u"last-block-of-report-%d" % params[u"context_pos"]) |
99 ) |
|
100 |
99 |
101 |
100 fl = self.create_flow(ps, u"body") |
102 fl = self.create_flow(ps,u"body") |
|
103 bl = self.create_block(fl) |
101 bl = self.create_block(fl) |
104 |
102 |
105 # Sets on the highest block element the properties of the XHTML body |
103 # Sets on the highest block element the properties of the XHTML body |
106 # element. These properties (at the least the inheritable ones) will |
104 # element. These properties (at the least the inheritable ones) will |
107 # be inherited by all the future FO elements. |
105 # be inherited by all the future FO elements. |
108 bodies = list(self.in_tree.getiterator(QName(XHTML_NS,u"body"))) |
106 bodies = list(self.in_tree.getiterator(QName(XHTML_NS, u"body"))) |
109 if len(bodies) > 0: |
107 if len(bodies) > 0: |
110 attrs = self._extract_properties([bodies[0]]) |
108 attrs = self._extract_properties([bodies[0]]) |
111 else: |
109 else: |
112 attrs = default_styles[u"body"].copy() |
110 attrs = default_styles[u"body"].copy() |
113 attrs[u"font-size"] = u"%.1fpt" %self.font_size |
111 attrs[u"font-size"] = u"%.1fpt" % self.font_size |
114 attrs[u"language"] = self.lang |
112 attrs[u"language"] = self.lang |
115 self._output_properties(bl,attrs) |
113 self._output_properties(bl,attrs) |
116 |
114 |
117 # Processes the report content |
115 # Processes the report content |
118 self._copy_text(in_elt,bl) |
116 self._copy_text(in_elt, bl) |
119 self._process_nodes(in_elt.getchildren(),bl) |
117 self._process_nodes(in_elt.getchildren(), bl) |
120 |
118 |
121 # Inserts an empty block at the end of the report in order to be able |
119 # Inserts an empty block at the end of the report in order to be able |
122 # to compute the last page number of this report. |
120 # to compute the last page number of this report. |
123 last_bl = self.create_block(bl) |
121 last_bl = self.create_block(bl) |
124 props = { u"keep-with-previous": u"always", } |
122 props = { u"keep-with-previous": u"always", } |
128 |
126 |
129 def _root_visit(self): |
127 def _root_visit(self): |
130 """ |
128 """ |
131 Visit function called when starting the process of the input tree. |
129 Visit function called when starting the process of the input tree. |
132 """ |
130 """ |
133 content = [ d for d in self.in_tree.getiterator(QName(XHTML_NS,u"div")) |
131 content = [ d for d in self.in_tree.getiterator(QName(XHTML_NS, u"div")) |
134 if d.get(u"id") == self.section ] |
132 if d.get(u"id") == self.section ] |
135 # Asks the process of the report elements with a specific visit |
133 # Asks the process of the report elements with a specific visit |
136 # function |
134 # function |
137 self._process_nodes(content, self.fo_root, |
135 self._process_nodes(content, self.fo_root, |
138 with_function=self._visit_report) |
136 with_function=self._visit_report) |