From: <dku...@us...> - 2006-08-30 22:32:52
|
Author: dkuhlman Date: 2006-08-31 00:32:45 +0200 (Thu, 31 Aug 2006) New Revision: 4708 Modified: trunk/sandbox/dkuhlman/OpenDocument/odtwriter/__init__.py Log: Added separte section for footer (view source, ...). Added visit_field, visit_field_name, visit_field_body, etc. Modified: trunk/sandbox/dkuhlman/OpenDocument/odtwriter/__init__.py =================================================================== --- trunk/sandbox/dkuhlman/OpenDocument/odtwriter/__init__.py 2006-08-30 22:30:51 UTC (rev 4707) +++ trunk/sandbox/dkuhlman/OpenDocument/odtwriter/__init__.py 2006-08-30 22:32:45 UTC (rev 4708) @@ -398,6 +398,8 @@ self.trace_level = -1 self.optiontablestyles_generated = False self.footer_element = None + self.field_name = None + self.field_element = None def astext(self): root = self.content_tree.getroot() @@ -568,7 +570,7 @@ attrib={'text:style-name': 'rststyle-textbody'}) el1 = etree.SubElement(el, 'office:annotation', attrib={}) el2 = etree.SubElement(el1, 'text:p', attrib={}) - el2.text = self.encode(node.astext()) + el2.text = node.astext() def depart_comment(self, node): pass @@ -580,11 +582,23 @@ def depart_copyright(self, node): self.set_to_parent() + def visit_date(self, node): + el = self.append_child('text:p', attrib={ + 'text:style-name': 'rststyle-textbody'}) + el1 = etree.SubElement(el, 'text:span', + attrib={'text:style-name': 'rststyle-strong'}) + el1.text = 'Date: ' + el1.tail = node.astext() + + def depart_date(self, node): + pass + def visit_decoration(self, node): - global DEBUG + #global DEBUG #ipshell('At visit_decoration') #DEBUG = 1 #self.trace_visit_node(node) + pass def depart_decoration(self, node): #global DEBUG @@ -593,19 +607,12 @@ #ipshell('At depart_decoration') el = self.current_element.getchildren()[-1] self.current_element.remove(el) - self.footer_element = el + el1 = etree.Element('text:section', attrib={ + 'text:name': '_rstFooterSection', + }) + el1.append(el) + self.footer_element = el1 - def visit_date(self, node): - el = self.append_child('text:p', attrib={ - 'text:style-name': 'rststyle-textbody'}) - el1 = etree.SubElement(el, 'text:span', - attrib={'text:style-name': 'rststyle-strong'}) - el1.text = 'Date: ' - el1.tail = node.astext() - - def depart_date(self, node): - pass - def visit_definition(self, node): el = self.append_child('text:p', attrib={'text:style-name': 'rststyle-blockindent'}) @@ -691,6 +698,16 @@ self.set_to_parent() self.paragraph_style_stack.pop() + def visit_list_item(self, node): + #import pdb; pdb.set_trace() + #ipshell('At visit_document') + #print '(visit_list_item) node: %s' % node.astext() + el = etree.SubElement(self.current_element, 'text:list-item') + self.set_current_element(el) + + def depart_list_item(self, node): + self.set_to_parent() + def visit_footer(self, node): #ipshell('At visit_footer') #self.trace_visit_node(node) @@ -700,16 +717,41 @@ #self.trace_depart_node(node) pass - def visit_list_item(self, node): - #import pdb; pdb.set_trace() - #ipshell('At visit_document') - #print '(visit_list_item) node: %s' % node.astext() - el = etree.SubElement(self.current_element, 'text:list-item') - self.set_current_element(el) + def visit_field(self, node): + #ipshell('At visit_field') + #self.trace_visit_node(node) + pass - def depart_list_item(self, node): - self.set_to_parent() + def depart_field(self, node): + #self.trace_depart_node(node) + #self.current_element.append(self.field_element) + pass + def visit_field_name(self, node): + #ipshell('At visit_field_name') + #self.trace_visit_node(node) + el = self.append_child('text:p', attrib={ + 'text:style-name': 'rststyle-textbody'}) + el1 = etree.SubElement(el, 'text:span', + attrib={'text:style-name': 'rststyle-strong'}) + el1.text = node.astext() + + def depart_field_name(self, node): + #self.trace_depart_node(node) + pass + + def visit_field_body(self, node): + #ipshell('At visit_field_body') + #self.trace_visit_node(node) + el = self.append_child('text:p', attrib={ + 'text:style-name': 'rststyle-blockindent'}) + el.text = node.astext() + raise nodes.SkipChildren() + + def depart_field_body(self, node): + #self.trace_depart_node(node) + pass + def visit_generated(self, node): pass @@ -876,7 +918,7 @@ def visit_option(self, node): el = self.append_child('text:p', attrib={ 'text:style-name': 'Table_20_Contents'}) - el.text = self.encode(node.astext()) + el.text = node.astext() def depart_option(self, node): pass @@ -901,7 +943,7 @@ }) el1 = etree.SubElement(el, 'text:p', attrib={ 'text:style-name': 'Table_20_Contents'}) - el1.text = self.encode(node.astext()) + el1.text = node.astext() raise nodes.SkipChildren() def depart_description(self, node): |