From 537dc4485a9515498df3032ce18c380f03a8fd3e Mon Sep 17 00:00:00 2001 From: Eric Lapouyade Date: Sun, 9 May 2021 10:00:26 +0200 Subject: [PATCH] Revert "fix issue #345" --- docxtpl/__init__.py | 52 --------------------------------------------- 1 file changed, 52 deletions(-) diff --git a/docxtpl/__init__.py b/docxtpl/__init__.py index 1b528a4..734e2d5 100644 --- a/docxtpl/__init__.py +++ b/docxtpl/__init__.py @@ -318,9 +318,6 @@ class DocxTemplate(object): # fix tables if needed tree = self.fix_tables(xml_src) - # fix shapes if needed - tree = self.fix_shapes(xml_src) - self.map_tree(tree) # Headers @@ -335,55 +332,6 @@ class DocxTemplate(object): for relKey, xml in footers: self.map_headers_footers_xml(relKey, xml) - def fix_shapes(self, xml): - parser = etree.XMLParser(recover=True) - tree = etree.fromstring(xml, parser=parser) - # get namespace - ns = '{' + tree.nsmap['w'] + '}' - nsp = '{' + tree.nsmap['wp'] + '}' - mc = '{' + tree.nsmap['mc'] + '}' - - # walk trough xml and fix docPr id duplicates - ids = [] - amount = 2000 - for p in tree.iter(ns+'p'): - rows = p.findall(ns+'r') - for r in rows: - drawing = r.find(ns+'drawing') - alternative = r.find(mc+'AlternateContent') - if drawing is not None: - anchor = drawing.find(nsp+'anchor') - if anchor is not None: - docPr = anchor.find(nsp+'docPr') - id = docPr.attrib['id'] - if id not in ids: - ids.append(id) - else: - docPr.set('id', str(int(id)+amount)) - amount += 1000 - elif alternative is not None: - choice = alternative.find(mc+'Choice') - drawing = choice.find(ns+'drawing') - anchor = drawing.find(nsp+'anchor') - inline = drawing.find(nsp+'inline') - if anchor is not None: - docPr = anchor.find(nsp+'docPr') - id = docPr.attrib['id'] - if id not in ids: - ids.append(id) - else: - docPr.set('id', str(int(id)+amount)) - amount += 1000 - elif inline is not None: - docPr = inline.find(nsp+'docPr') - id = docPr.attrib['id'] - if id not in ids: - ids.append(id) - else: - docPr.set('id', str(int(id)+amount)) - amount += 1000 - return tree - # using of TC tag in for cycle can cause that count of columns does not # correspond to real count of columns in row. This function is able to fix it. def fix_tables(self, xml):