From 3601fbf7a603b829e7a07c32cfbb926fb397ea49 Mon Sep 17 00:00:00 2001 From: John Darrington Date: Sat, 1 Aug 2009 12:23:26 +0200 Subject: [PATCH] Add a styles.xml file Add a basic style XML and have the table headings rendered in a different style to the table contents. --- src/output/odt.c | 93 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) diff --git a/src/output/odt.c b/src/output/odt.c index 59a628a6..31f389fd 100644 --- a/src/output/odt.c +++ b/src/output/odt.c @@ -105,6 +105,98 @@ register_file (struct odt_driver_ext *x, const char *filename) xmlTextWriterEndElement (x->manifest_wtr); } +static void +write_style_data (struct odt_driver_ext *x) +{ + xmlTextWriterPtr w = create_writer (x, "styles.xml"); + register_file (x, "styles.xml"); + + xmlTextWriterStartElement (w, _xml ("office:document-styles")); + xmlTextWriterWriteAttribute (w, _xml ("xmlns:office"), + _xml ("urn:oasis:names:tc:opendocument:xmlns:office:1.0")); + + xmlTextWriterWriteAttribute (w, _xml ("xmlns:style"), + _xml ("urn:oasis:names:tc:opendocument:xmlns:style:1.0")); + + xmlTextWriterWriteAttribute (w, _xml ("xmlns:fo"), + _xml ("urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0") ); + + xmlTextWriterWriteAttribute (w, _xml ("office:version"), _xml ("1.1")); + + + + xmlTextWriterStartElement (w, _xml ("office:styles")); + + + { + xmlTextWriterStartElement (w, _xml ("style:style")); + xmlTextWriterWriteAttribute (w, _xml ("style:name"), + _xml ("Standard")); + + xmlTextWriterWriteAttribute (w, _xml ("style:family"), + _xml ("paragraph")); + + xmlTextWriterWriteAttribute (w, _xml ("style:class"), + _xml ("text")); + + xmlTextWriterEndElement (w); /* style:style */ + } + + { + xmlTextWriterStartElement (w, _xml ("style:style")); + xmlTextWriterWriteAttribute (w, _xml ("style:name"), + _xml ("Table_20_Contents")); + + xmlTextWriterWriteAttribute (w, _xml ("style:display-name"), + _xml ("Table Contents")); + + xmlTextWriterWriteAttribute (w, _xml ("style:family"), + _xml ("paragraph")); + + xmlTextWriterWriteAttribute (w, _xml ("style:parent-style-name"), + _xml ("Standard")); + + xmlTextWriterWriteAttribute (w, _xml ("style:class"), + _xml ("extra")); + + xmlTextWriterEndElement (w); /* style:style */ + } + + { + xmlTextWriterStartElement (w, _xml ("style:style")); + xmlTextWriterWriteAttribute (w, _xml ("style:name"), + _xml ("Table_20_Heading")); + + xmlTextWriterWriteAttribute (w, _xml ("style:display-name"), + _xml ("Table Heading")); + + xmlTextWriterWriteAttribute (w, _xml ("style:family"), + _xml ("paragraph")); + + xmlTextWriterWriteAttribute (w, _xml ("style:parent-style-name"), + _xml ("Table_20_Contents")); + + xmlTextWriterWriteAttribute (w, _xml ("style:class"), + _xml ("extra")); + + + xmlTextWriterStartElement (w, _xml ("style:text-properties")); + xmlTextWriterWriteAttribute (w, _xml ("fo:font-weight"), _xml ("bold")); + xmlTextWriterWriteAttribute (w, _xml ("style:font-weight-asian"), _xml ("bold")); + xmlTextWriterWriteAttribute (w, _xml ("style:font-weight-complex"), _xml ("bold")); + xmlTextWriterEndElement (w); /* style:text-properties */ + + xmlTextWriterEndElement (w); /* style:style */ + } + + + xmlTextWriterEndElement (w); /* office:styles */ + xmlTextWriterEndElement (w); /* office:document-styles */ + + xmlTextWriterEndDocument (w); + xmlFreeTextWriter (w); +} + static void write_meta_data (struct odt_driver_ext *x) { @@ -189,6 +281,7 @@ odt_open_driver (const char *name, int types, struct substring option_string) write_meta_data (x); + write_style_data (x); x->content_wtr = create_writer (x, "content.xml"); register_file (x, "content.xml"); -- 2.30.2