def read_page_properties(self, doc): current = [] self.page_map = OrderedDict() self.section_starts = [] for p in self.namespace.descendants(doc, 'w:p', 'w:tbl'): if p.tag.endswith('}tbl'): self.tables.register(p, self.styles) current.append(p) continue sect = tuple(self.namespace.descendants(p, 'w:sectPr')) if sect: pr = PageProperties(self.namespace, sect) paras = current + [p] for x in paras: self.page_map[x] = pr self.section_starts.append(paras[0]) current = [] else: current.append(p) if current: self.section_starts.append(current[0]) last = self.namespace.XPath('./w:body/w:sectPr')(doc) pr = PageProperties(self.namespace, last) for x in current: self.page_map[x] = pr
def read_page_properties(self, doc): current = [] self.page_map = OrderedDict() in_table = False for p in descendants(doc, 'w:p', 'w:tbl'): if p.tag.endswith('}tbl'): in_table = True self.tables.register(p) continue sect = tuple(descendants(p, 'w:sectPr')) if sect: pr = PageProperties(sect) for x in current + [p]: self.page_map[x] = pr current = [] else: current.append(p) if in_table: if ancestor(p, 'w:tbl') is not None: self.tables.add(p) else: in_table = False if current: last = XPath('./w:body/w:sectPr')(doc) pr = PageProperties(last) for x in current: self.page_map[x] = pr