def set_properties(self, properties={}, style=None, area=None, **kw): """Set the properties of the "area" type of this style. Properties are given either as a dict or as named arguments (or both). The area is identical to the style family by default. If the properties element is missing, it is created. Instead of properties, you can pass a style with properties of the same area. These will be copied. Arguments: properties -- dict style -- odf_style area -- 'paragraph', 'text'... """ if area is None: area = self.get_family() element = self.get_element('style:%s-properties' % area) if element is None: element = odf_create_element('style:%s-properties' % area) self.append(element) if properties or kw: properties = _expand_properties(_merge_dicts(properties, kw)) elif style is not None: properties = style.get_properties(area=area) if properties is None: return for key, value in properties.iteritems(): if value is None: element.del_attribute(key) else: element.set_attribute(key, value)
def del_properties(self, properties=[], area=None, *args): """Delete the given properties, either by list argument or positional argument (or both). Remove only from the given area, identical to the style family by default. Arguments: properties -- list area -- str """ if area is None: area = self.get_family() element = self.get_element('style:%s-properties' % area) if element is None: raise ValueError, "properties element is inexistent" for key in _expand_properties(properties): element.del_attribute(key)