Commit e19a6b2e authored by Nicolas Delaby's avatar Nicolas Delaby

Support replacement of fields inside ODT documents

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@31042 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 85293006
......@@ -953,6 +953,7 @@ class ODTStrategy(ODFStrategy):
"""replace nodes (e.g. paragraphs) via ODF reference"""
element_tree = self._replaceNodeViaRangeReference(element_tree=element_tree, field=field)
element_tree = self._replaceNodeViaPointReference(element_tree=element_tree, field=field)
self._replaceNodeViaFormName(element_tree, field)
return element_tree
def _renderField(self, field):
......@@ -1026,6 +1027,19 @@ class ODTStrategy(ODFStrategy):
element_tree=element_tree)
return element_tree
def _replaceNodeViaFormName(self, element_tree, field, iteration_index=0):
"""
Used to replace field in ODT document like checkboxes
"""
field_id = field.id
reference_xpath = '//*[@form:name = "%s"]' % field_id
reference_list = element_tree.xpath(reference_xpath, namespaces=element_tree.nsmap)
for target_node in reference_list:
attr_dict = {}
attr_dict.update(target_node.attrib)
new_node = field.render_odt(attr_dict=attr_dict)
target_node.getparent().replace(target_node, new_node)
class ODGStrategy(ODFStrategy):
"""ODGStrategy create a ODG Document from a form and a ODG template"""
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment