Changeset 98:45f9210678c3
- Timestamp:
- 01/22/09 05:11:25 (14 months ago)
- Author:
- Ga?tan de Menten <ged@…>
- Branch:
- default
- Message:
-
- prefix make_href and guess_type methods by "relatorio" so that we don't
risk a collision with user-provided methods
- removed the second parameter to make_href which wasn't used
- added some more comments/docstrings
- Files:
-
Legend:
- Unmodified
- Added
- Removed
-
|
r97
|
r98
|
|
| 86 | 86 | self.context = context.copy() |
| 87 | 87 | |
| 88 | | def __call__(self, expr, name): |
| 89 | | #FIXME: name argument is unused |
| | 88 | def __call__(self, expr): |
| 90 | 89 | bitstream, mimetype = expr |
| 91 | 90 | if isinstance(bitstream, Report): |
| … |
… |
|
| 103 | 102 | |
| 104 | 103 | class ColumnCounter: |
| 105 | | """A class used to add the correct number of column definitions to a |
| 106 | | table containing an horizontal repetition" |
| | 104 | """A class used to count the actual maximum number of cells (and thus |
| | 105 | columns) a table contains accross its rows. |
| 107 | 106 | """ |
| 108 | 107 | def __init__(self): |
| … |
… |
|
| 122 | 121 | |
| 123 | 122 | def wrap_nodes_between(first, last, new_parent): |
| | 123 | """An helper function to move all nodes between two nodes to a new node |
| | 124 | and add that new node to their former parent. The boundary nodes are |
| | 125 | removed in the process. |
| | 126 | """ |
| 124 | 127 | old_parent = first.getparent() |
| 125 | 128 | for node in first.itersiblings(): |
| … |
… |
|
| 449 | 452 | # The grand-parent tag is a table cell we should set the |
| 450 | 453 | # correct value and type for this cell. |
| 451 | | dico = "{'%s': %s, '%s': guess_type(%s)}" |
| | 454 | dico = "{'%s': %s, '%s': __relatorio_guess_type(%s)}" |
| 452 | 455 | parent.attrib[py_attrs_attr] = dico % (office_name, expr, |
| 453 | | office_valuetype, expr) |
| | 456 | office_valuetype, expr) |
| 454 | 457 | parent.attrib.pop(office_valuetype, None) |
| 455 | 458 | parent.attrib.pop(office_name, None) |
| … |
… |
|
| 457 | 460 | def _handle_row_spanned_column_loops(self, parsed, outer_o_node, |
| 458 | 461 | opening_pos, closing_pos): |
| | 462 | """handles column repetitions which span several rows, by duplicating |
| | 463 | the py:for node for each row, and make the loops work on a copy of the |
| | 464 | original iterable as to not exhaust generators.""" |
| 459 | 465 | _, directive, attr, a_val = parsed |
| 460 | 466 | table_rowspan_attr = '{%s}number-rows-spanned' \ |
| … |
… |
|
| 516 | 522 | |
| 517 | 523 | def _handle_images(self, tree): |
| 518 | | "replaces all draw:frame named 'image: ...' by a draw:image node" |
| | 524 | "replaces all draw:frame named 'image: ...' by draw:image nodes" |
| 519 | 525 | draw_name = '{%s}name' % self.namespaces['draw'] |
| 520 | 526 | draw_image = '{%s}image' % self.namespaces['draw'] |
| … |
… |
|
| 523 | 529 | for draw in tree.xpath(xpath_expr, namespaces=self.namespaces): |
| 524 | 530 | d_name = draw.attrib[draw_name] |
| 525 | | attr_expr = "make_href(%s, %r)" % (d_name[7:], d_name[7:]) |
| | 531 | attr_expr = "__relatorio_make_href(%s)" % d_name[7:] |
| 526 | 532 | image_node = EtreeElement(draw_image, |
| 527 | 533 | attrib={py_attrs: attr_expr}, |
| … |
… |
|
| 540 | 546 | "creates the RelatorioStream." |
| 541 | 547 | serializer = OOSerializer(self.filepath) |
| 542 | | kwargs['make_href'] = ImageHref(serializer.outzip, kwargs) |
| 543 | | kwargs['guess_type'] = guess_type |
| | 548 | kwargs['__relatorio_make_href'] = ImageHref(serializer.outzip, kwargs) |
| | 549 | kwargs['__relatorio_guess_type'] = guess_type |
| 544 | 550 | |
| 545 | 551 | counter = ColumnCounter() |