def build_caches(self, element): """ Called from element.py """ if not self.element_dict.has_key(element.qname): self.element_dict[element.qname] = [] self.element_dict[element.qname].append(element) if element.qname == (STYLENS, u'style'): self._register_stylename(element) # Add to style dictionary styleref = element.getAttrNS(TEXTNS,u'style-name') if styleref is not None and self._styles_ooo_fix.has_key(styleref): element.setAttrNS(TEXTNS,u'style-name', self._styles_ooo_fix[styleref])
def build_caches(self, element): """ Called from element.py """ if not self.element_dict.has_key(element.qname): self.element_dict[element.qname] = [] self.element_dict[element.qname].append(element) if element.qname == (STYLENS, u'style'): self.__register_stylename(element) # Add to style dictionary styleref = element.getAttrNS(TEXTNS,u'style-name') if styleref is not None and self._styles_ooo_fix.has_key(styleref): element.setAttrNS(TEXTNS,u'style-name', self._styles_ooo_fix[styleref])
def _register_stylename(self, element): ''' Register a style. But there are three style dictionaries: office:styles, office:automatic-styles and office:master-styles Chapter 14 ''' name = element.getAttrNS(STYLENS, u'name') if name is None: return if element.parentNode.qname in ((OFFICENS,u'styles'), (OFFICENS,u'automatic-styles')): if self._styles_dict.has_key(name): newname = 'M'+name # Rename style self._styles_ooo_fix[name] = newname # From here on all references to the old name will refer to the new one name = newname element.setAttrNS(STYLENS, u'name', name) self._styles_dict[name] = element
def __register_stylename(self, element): ''' Register a style. But there are three style dictionaries: office:styles, office:automatic-styles and office:master-styles Chapter 14 ''' name = element.getAttrNS(STYLENS, u'name') if name is None: return if element.parentNode.qname in ((OFFICENS,u'styles'), (OFFICENS,u'automatic-styles')): if self._styles_dict.has_key(name): newname = 'M'+name # Rename style self._styles_ooo_fix[name] = newname # From here on all references to the old name will refer to the new one name = newname element.setAttrNS(STYLENS, u'name', name) self._styles_dict[name] = element