odf2xhtml.py
Go to the documentation of this file.
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright (C) 2006-2010 Søren Roug, European Environment Agency
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#
# Contributor(s):
#
#import pdb
#pdb.set_trace()
import sys, os.path
sys.path.append(os.path.dirname(__file__))
from xml.sax import handler
from xml.sax.saxutils import escape, quoteattr
from xml.dom import Node
from opendocument import load
from namespaces import ANIMNS, CHARTNS, CONFIGNS, DCNS, DR3DNS, DRAWNS, FONS, \
FORMNS, MATHNS, METANS, NUMBERNS, OFFICENS, PRESENTATIONNS, SCRIPTNS, \
SMILNS, STYLENS, SVGNS, TABLENS, TEXTNS, XLINKNS
# Handling of styles
#
# First there are font face declarations. These set up a font style that will be
# referenced from a text-property. The declaration describes the font making
# it possible for the application to find a similar font should the system not
# have that particular one. The StyleToCSS stores these attributes to be used
# for the CSS2 font declaration.
#
# Then there are default-styles. These set defaults for various style types:
# "text", "paragraph", "section", "ruby", "table", "table-column", "table-row",
# "table-cell", "graphic", "presentation", "drawing-page", "chart".
# Since CSS2 can't refer to another style, ODF2XHTML add these to all
# styles unless overridden.
#
# The real styles are declared in the <style:style> element. They have a
# family referring to the default-styles, and may have a parent style.
#
# Styles have scope. The same name can be used for both paragraph and
# character etc. styles Since CSS2 has no scope we use a prefix. (Not elegant)
# In ODF a style can have a parent, these parents can be chained.
##
# The purpose of the StyleToCSS class is to contain the rules to convert
# ODF styles to CSS2. Since it needs the generic fonts, it would probably
# make sense to also contain the Styles in a dict as well..
#
class StyleToCSS:
def __init__(self):
# Font declarations
self.fontdict = {}
# Fill-images from presentations for backgrounds
self.fillimages = {}
self.ruleconversions = {
(DRAWNS,u'fill-image-name'): self.c_drawfillimage,
(FONS,u"background-color"): self.c_fo,
(FONS,u"border"): self.c_fo,
(FONS,u"border-bottom"): self.c_fo,
(FONS,u"border-left"): self.c_fo,
(FONS,u"border-right"): self.c_fo,
(FONS,u"border-top"): self.c_fo,
(FONS,u"color"): self.c_fo,
(FONS,u"font-family"): self.c_fo,
(FONS,u"font-size"): self.c_fo,
(FONS,u"font-style"): self.c_fo,
(FONS,u"font-variant"): self.c_fo,
(FONS,u"font-weight"): self.c_fo,
(FONS,u"line-height"): self.c_fo,
(FONS,u"margin"): self.c_fo,
(FONS,u"margin-bottom"): self.c_fo,
(FONS,u"margin-left"): self.c_fo,
(FONS,u"margin-right"): self.c_fo,
(FONS,u"margin-top"): self.c_fo,
(FONS,u"min-height"): self.c_fo,
(FONS,u"padding"): self.c_fo,
(FONS,u"padding-bottom"): self.c_fo,
(FONS,u"padding-left"): self.c_fo,
(FONS,u"padding-right"): self.c_fo,
(FONS,u"padding-top"): self.c_fo,
(FONS,u"page-width"): self.c_page_width,
(FONS,u"page-height"): self.c_page_height,
(FONS,u"text-align"): self.c_text_align,
(FONS,u"text-indent") :self.c_fo,
(TABLENS,u'border-model') :self.c_border_model,
(STYLENS,u'column-width') : self.c_width,
(STYLENS,u"font-name"): self.c_fn,
(STYLENS,u'horizontal-pos'): self.c_hp,
(STYLENS,u'text-position'): self.c_text_position,
(STYLENS,u'text-line-through-style'): self.c_text_line_through_style,
(STYLENS,u'text-underline-style'): self.c_text_underline_style,
(STYLENS,u'width') : self.c_width,
# FIXME Should do style:vertical-pos here
}
##
# It is possible that the HTML browser doesn't know how to
# show a particular font. Fortunately ODF provides generic fallbacks.
# Unfortunately they are not the same as CSS2.
# CSS2: serif, sans-serif, cursive, fantasy, monospace
# ODF: roman, swiss, modern, decorative, script, system
# This method put the font and fallback into a dictionary
#
def save_font(self, name, family, generic):
htmlgeneric = "sans-serif"
if generic == "roman": htmlgeneric = "serif"
elif generic == "swiss": htmlgeneric = "sans-serif"
elif generic == "modern": htmlgeneric = "monospace"
elif generic == "decorative": htmlgeneric = "sans-serif"
elif generic == "script": htmlgeneric = "monospace"
elif generic == "system": htmlgeneric = "serif"
self.fontdict[name] = (family, htmlgeneric)
##
# Fill a figure with an image. Since CSS doesn't let you resize images
# this should really be implemented as an absolutely position <img>
# with a width and a height
#
def c_drawfillimage(self, ruleset, sdict, rule, val):
sdict['background-image'] = "url('%s')" % self.fillimages[val]
##
# XSL formatting attributes
def c_fo(self, ruleset, sdict, rule, val):
selector = rule[1]
sdict[selector] = val
##
# Convert to CSS2 border model
def c_border_model(self, ruleset, sdict, rule, val):
if val == 'collapsing':
sdict['border-collapse'] ='collapse'
else:
sdict['border-collapse'] ='separate'
##
# Set width of box
def c_width(self, ruleset, sdict, rule, val):
sdict['width'] = val
##
# Text align
def c_text_align(self, ruleset, sdict, rule, align):
if align == "start": align = "left"
if align == "end": align = "right"
sdict['text-align'] = align
##
# Generate the CSS font family
# A generic font can be found in two ways. In a <style:font-face>
# element or as a font-family-generic attribute in text-properties.
#
def c_fn(self, ruleset, sdict, rule, fontstyle):
generic = ruleset.get((STYLENS,'font-family-generic') )
if generic is not None:
self.save_font(fontstyle, fontstyle, generic)
family, htmlgeneric = self.fontdict.get(fontstyle, (fontstyle, 'serif'))
sdict['font-family'] = '%s, %s' % (family, htmlgeneric)
##
# Text position. This is used e.g. to make superscript and subscript
# This attribute can have one or two values.
#
# The first value must be present and specifies the vertical
# text position as a percentage that relates to the current font
# height or it takes one of the values sub or super. Negative
# percentages or the sub value place the text below the
# baseline. Positive percentages or the super value place
# the text above the baseline. If sub or super is specified,
# the application can choose an appropriate text position.
#
# The second value is optional and specifies the font height
# as a percentage that relates to the current font-height. If
# this value is not specified, an appropriate font height is
# used. Although this value may change the font height that
# is displayed, it never changes the current font height that
# is used for additional calculations.
#
def c_text_position(self, ruleset, sdict, rule, tp):
textpos = tp.split(' ')
if len(textpos) == 2 and textpos[0] != "0%":
# Bug in OpenOffice. If vertical-align is 0% - ignore the text size.
sdict['font-size'] = textpos[1]
if textpos[0] == "super":
sdict['vertical-align'] = "33%"
elif textpos[0] == "sub":
sdict['vertical-align'] = "-33%"
else:
sdict['vertical-align'] = textpos[0]
def c_hp(self, ruleset, sdict, rule, hpos):
#FIXME: Frames wrap-style defaults to 'parallel', graphics to 'none'.
# It is properly set in the parent-styles, but the program doesn't
# collect the information.
wrap = ruleset.get((STYLENS,'wrap'),'parallel')
# Can have: from-left, left, center, right, from-inside, inside, outside
if hpos == "center":
sdict['margin-left'] = "auto"
sdict['margin-right'] = "auto"
# else:
# # force it to be *something* then delete it
# sdict['margin-left'] = sdict['margin-right'] = ''
# del sdict['margin-left'], sdict['margin-right']
if hpos in ("right","outside"):
if wrap in ( "left", "parallel","dynamic"):
sdict['float'] = "right"
elif wrap == "run-through":
sdict['position'] = "absolute" # Simulate run-through
sdict['top'] = "0"
sdict['right'] = "0";
else: # No wrapping
sdict['margin-left'] = "auto"
sdict['margin-right'] = "0cm"
elif hpos in ("left", "inside"):
if wrap in ( "right", "parallel","dynamic"):
sdict['float'] = "left"
elif wrap == "run-through":
sdict['position'] = "absolute" # Simulate run-through
sdict['top'] = "0"
sdict['left'] = "0"
else: # No wrapping
sdict['margin-left'] = "0cm"
sdict['margin-right'] = "auto"
elif hpos in ("from-left", "from-inside"):
if wrap in ( "right", "parallel"):
sdict['float'] = "left"
else:
sdict['position'] = "relative" # No wrapping
if (SVGNS,'x') in ruleset:
sdict['left'] = ruleset[(SVGNS,'x')]
##
# Set width of box
# HTML doesn't really have a page-width. It is always 100% of the browser width
#
def c_page_width(self, ruleset, sdict, rule, val):
sdict['width'] = val
##
# Set underline decoration
# HTML doesn't really have a page-width. It is always 100% of the browser width
#
def c_text_underline_style(self, ruleset, sdict, rule, val):
if val and val != "none":
sdict['text-decoration'] = "underline"
##
# Set underline decoration
# HTML doesn't really have a page-width. It is always 100% of the browser width
#
def c_text_line_through_style(self, ruleset, sdict, rule, val):
if val and val != "none":
sdict['text-decoration'] = "line-through"
##
# Set height of box
def c_page_height(self, ruleset, sdict, rule, val):
sdict['height'] = val
##
# Rule is a tuple of (namespace, name). If the namespace is '' then
# it is already CSS2
#
def convert_styles(self, ruleset):
sdict = {}
procedures=[]
for rule,val in ruleset.items():
if rule[0] == '':
sdict[rule[1]] = val
continue
method = self.ruleconversions.get(rule, None )
if method:
procedures.append([method, ruleset, sdict, rule, val])
# this ensures that the procedures for horizontal position
# are run last! It is important since Python3 makes the order
# of dictionaries unpredictable
for p in filter(lambda x: x[0] != self.c_hp, procedures):
method, ruleset, sdict, rule, val = p
method(ruleset, sdict, rule, val)
for p in filter(lambda x: x[0] == self.c_hp, procedures):
method, ruleset, sdict, rule, val = p
method(ruleset, sdict, rule, val)
return sdict
class TagStack:
def __init__(self):
self.stack = []
def push(self, tag, attrs):
self.stack.append( (tag, attrs) )
def pop(self):
item = self.stack.pop()
return item
def stackparent(self):
item = self.stack[-1]
return item[1]
##
# Find a tag with the given attribute
def rfindattr(self, attr):
for tag, attrs in self.stack:
if attr in attrs:
return attrs[attr]
return None
def count_tags(self, tag):
c = 0
for ttag, tattrs in self.stack:
if ttag == tag: c = c + 1
return c
special_styles = {
'S-Emphasis':'em',
'S-Citation':'cite',
'S-Strong_20_Emphasis':'strong',
'S-Variable':'var',
'S-Definition':'dfn',
'S-Teletype':'tt',
'P-Heading_20_1':'h1',
'P-Heading_20_2':'h2',
'P-Heading_20_3':'h3',
'P-Heading_20_4':'h4',
'P-Heading_20_5':'h5',
'P-Heading_20_6':'h6',
# 'P-Caption':'caption',
'P-Addressee':'address',
# 'P-List_20_Heading':'dt',
# 'P-List_20_Contents':'dd',
'P-Preformatted_20_Text':'pre',
# 'P-Table_20_Heading':'th',
# 'P-Table_20_Contents':'td',
# 'P-Text_20_body':'p'
}
#-----------------------------------------------------------------------------
#
# ODFCONTENTHANDLER
#
#-----------------------------------------------------------------------------
##
# The ODF2XHTML parses an ODF file and produces XHTML
class ODF2XHTML(handler.ContentHandler):
def __init__(self, generate_css=True, embedable=False):
# Tags
self.generate_css = generate_css
self.elements = {
(DCNS, 'title'): (self.s_processcont, self.e_dc_title),
(DCNS, 'language'): (self.s_processcont, self.e_dc_contentlanguage),
(DCNS, 'creator'): (self.s_processcont, self.e_dc_creator),
(DCNS, 'description'): (self.s_processcont, self.e_dc_metatag),
(DCNS, 'date'): (self.s_processcont, self.e_dc_metatag),
(DRAWNS, 'custom-shape'): (self.s_custom_shape, self.e_custom_shape),
(DRAWNS, 'frame'): (self.s_draw_frame, self.e_draw_frame),
(DRAWNS, 'image'): (self.s_draw_image, None),
(DRAWNS, 'fill-image'): (self.s_draw_fill_image, None),
(DRAWNS, "layer-set"):(self.s_ignorexml, None),
(DRAWNS, 'object'): (self.s_draw_object, None),
(DRAWNS, 'object-ole'): (self.s_draw_object_ole, None),
(DRAWNS, 'page'): (self.s_draw_page, self.e_draw_page),
(DRAWNS, 'text-box'): (self.s_draw_textbox, self.e_draw_textbox),
(METANS, 'creation-date'):(self.s_processcont, self.e_dc_metatag),
(METANS, 'generator'):(self.s_processcont, self.e_dc_metatag),
(METANS, 'initial-creator'): (self.s_processcont, self.e_dc_metatag),
(METANS, 'keyword'): (self.s_processcont, self.e_dc_metatag),
(NUMBERNS, "boolean-style"):(self.s_ignorexml, None),
(NUMBERNS, "currency-style"):(self.s_ignorexml, None),
(NUMBERNS, "date-style"):(self.s_ignorexml, None),
(NUMBERNS, "number-style"):(self.s_ignorexml, None),
(NUMBERNS, "text-style"):(self.s_ignorexml, None),
(OFFICENS, "annotation"):(self.s_ignorexml, None),
(OFFICENS, "automatic-styles"):(self.s_office_automatic_styles, None),
(OFFICENS, "document"):(self.s_office_document_content, self.e_office_document_content),
(OFFICENS, "document-content"):(self.s_office_document_content, self.e_office_document_content),
(OFFICENS, "forms"):(self.s_ignorexml, None),
(OFFICENS, "master-styles"):(self.s_office_master_styles, None),
(OFFICENS, "meta"):(self.s_ignorecont, None),
(OFFICENS, "presentation"):(self.s_office_presentation, self.e_office_presentation),
(OFFICENS, "spreadsheet"):(self.s_office_spreadsheet, self.e_office_spreadsheet),
(OFFICENS, "styles"):(self.s_office_styles, None),
(OFFICENS, "text"):(self.s_office_text, self.e_office_text),
(OFFICENS, "scripts"):(self.s_ignorexml, None),
(OFFICENS, "settings"):(self.s_ignorexml, None),
(PRESENTATIONNS, "notes"):(self.s_ignorexml, None),
# (STYLENS, "default-page-layout"):(self.s_style_default_page_layout, self.e_style_page_layout),
(STYLENS, "default-page-layout"):(self.s_ignorexml, None),
(STYLENS, "default-style"):(self.s_style_default_style, self.e_style_default_style),
(STYLENS, "drawing-page-properties"):(self.s_style_handle_properties, None),
(STYLENS, "font-face"):(self.s_style_font_face, None),
# (STYLENS, "footer"):(self.s_style_footer, self.e_style_footer),
# (STYLENS, "footer-style"):(self.s_style_footer_style, None),
(STYLENS, "graphic-properties"):(self.s_style_handle_properties, None),
(STYLENS, "handout-master"):(self.s_ignorexml, None),
# (STYLENS, "header"):(self.s_style_header, self.e_style_header),
# (STYLENS, "header-footer-properties"):(self.s_style_handle_properties, None),
# (STYLENS, "header-style"):(self.s_style_header_style, None),
(STYLENS, "master-page"):(self.s_style_master_page, None),
(STYLENS, "page-layout-properties"):(self.s_style_handle_properties, None),
(STYLENS, "page-layout"):(self.s_style_page_layout, self.e_style_page_layout),
# (STYLENS, "page-layout"):(self.s_ignorexml, None),
(STYLENS, "paragraph-properties"):(self.s_style_handle_properties, None),
(STYLENS, "style"):(self.s_style_style, self.e_style_style),
(STYLENS, "table-cell-properties"):(self.s_style_handle_properties, None),
(STYLENS, "table-column-properties"):(self.s_style_handle_properties, None),
(STYLENS, "table-properties"):(self.s_style_handle_properties, None),
(STYLENS, "text-properties"):(self.s_style_handle_properties, None),
(SVGNS, 'desc'): (self.s_ignorexml, None),
(TABLENS, 'covered-table-cell'): (self.s_ignorexml, None),
(TABLENS, 'table-cell'): (self.s_table_table_cell, self.e_table_table_cell),
(TABLENS, 'table-column'): (self.s_table_table_column, None),
(TABLENS, 'table-row'): (self.s_table_table_row, self.e_table_table_row),
(TABLENS, 'table'): (self.s_table_table, self.e_table_table),
(TEXTNS, 'a'): (self.s_text_a, self.e_text_a),
(TEXTNS, "alphabetical-index-source"):(self.s_text_x_source, self.e_text_x_source),
(TEXTNS, "bibliography-configuration"):(self.s_ignorexml, None),
(TEXTNS, "bibliography-source"):(self.s_text_x_source, self.e_text_x_source),
(TEXTNS, 'bookmark'): (self.s_text_bookmark, None),
(TEXTNS, 'bookmark-start'): (self.s_text_bookmark, None),
(TEXTNS, 'bookmark-ref'): (self.s_text_bookmark_ref, self.e_text_a),
(TEXTNS, 'bookmark-ref-start'): (self.s_text_bookmark_ref, None),
(TEXTNS, 'h'): (self.s_text_h, self.e_text_h),
(TEXTNS, "illustration-index-source"):(self.s_text_x_source, self.e_text_x_source),
(TEXTNS, 'line-break'):(self.s_text_line_break, None),
(TEXTNS, "linenumbering-configuration"):(self.s_ignorexml, None),
(TEXTNS, "list"):(self.s_text_list, self.e_text_list),
(TEXTNS, "list-item"):(self.s_text_list_item, self.e_text_list_item),
(TEXTNS, "list-level-style-bullet"):(self.s_text_list_level_style_bullet, self.e_text_list_level_style_bullet),
(TEXTNS, "list-level-style-number"):(self.s_text_list_level_style_number, self.e_text_list_level_style_number),
(TEXTNS, "list-style"):(None, None),
(TEXTNS, "note"):(self.s_text_note, None),
(TEXTNS, "note-body"):(self.s_text_note_body, self.e_text_note_body),
(TEXTNS, "note-citation"):(None, self.e_text_note_citation),
(TEXTNS, "notes-configuration"):(self.s_ignorexml, None),
(TEXTNS, "object-index-source"):(self.s_text_x_source, self.e_text_x_source),
(TEXTNS, 'p'): (self.s_text_p, self.e_text_p),
(TEXTNS, 's'): (self.s_text_s, None),
(TEXTNS, 'span'): (self.s_text_span, self.e_text_span),
(TEXTNS, 'tab'): (self.s_text_tab, None),
(TEXTNS, "table-index-source"):(self.s_text_x_source, self.e_text_x_source),
(TEXTNS, "table-of-content-source"):(self.s_text_x_source, self.e_text_x_source),
(TEXTNS, "user-index-source"):(self.s_text_x_source, self.e_text_x_source),
}
if embedable:
self.set_embedable()
self._resetobject()
##
# Tell the parser to not generate CSS
def set_plain(self):
self.generate_css = False
##
# Tells the converter to only output the parts inside the <body>
def set_embedable(self):
self.elements[(OFFICENS, u"text")] = (None,None)
self.elements[(OFFICENS, u"spreadsheet")] = (None,None)
self.elements[(OFFICENS, u"presentation")] = (None,None)
self.elements[(OFFICENS, u"document-content")] = (None,None)
##
# Add a link to an external style file.
# Also turns of the embedding of styles in the HTML
#
def add_style_file(self, stylefilename, media=None):
self.use_internal_css = False
self.stylefilename = stylefilename
if media:
self.metatags.append('<link rel="stylesheet" type="text/css" href="%s" media="%s"/>\n' % (stylefilename,media))
else:
self.metatags.append('<link rel="stylesheet" type="text/css" href="%s"/>\n' % (stylefilename))
def _resetfootnotes(self):
# Footnotes and endnotes
self.notedict = {}
self.currentnote = 0
self.notebody = ''
def _resetobject(self):
self.lines = []
self._wfunc = self._wlines
self.xmlfile = ''
self.title = ''
self.language = ''
self.creator = ''
self.data = []
self.tagstack = TagStack()
self.htmlstack = []
self.pstack = []
self.processelem = True
self.processcont = True
self.listtypes = {}
self.headinglevels = [0, 0,0,0,0,0, 0,0,0,0,0] # level 0 to 10
self.use_internal_css = True
self.cs = StyleToCSS()
self.anchors = {}
# Style declarations
self.stylestack = []
self.styledict = {}
self.currentstyle = None
self._resetfootnotes()
# Tags from meta.xml
self.metatags = []
def writeout(self, s):
if s != '':
self._wfunc(s)
def writedata(self):
d = ''.join(self.data)
if d != '':
self.writeout(escape(d))
##
# Create an open HTML tag
def opentag(self, tag, attrs={}, block=False):
self.htmlstack.append((tag,attrs,block))
a = []
for key,val in attrs.items():
a.append('''%s=%s''' % (key, quoteattr(val)))
if len(a) == 0:
self.writeout("<%s>" % tag)
else:
self.writeout("<%s %s>" % (tag, " ".join(a)))
if block == True:
self.writeout("\n")
##
# Close an open HTML tag
def closetag(self, tag, block=True):
self.htmlstack.pop()
self.writeout("</%s>" % tag)
if block == True:
self.writeout("\n")
def emptytag(self, tag, attrs={}):
a = []
for key,val in attrs.items():
a.append('''%s=%s''' % (key, quoteattr(val)))
self.writeout("<%s %s/>\n" % (tag, " ".join(a)))
#--------------------------------------------------
# Interface to parser
#--------------------------------------------------
def characters(self, data):
if self.processelem and self.processcont:
self.data.append(data)
def startElementNS(self, tag, qname, attrs):
self.pstack.append( (self.processelem, self.processcont) )
if self.processelem:
method = self.elements.get(tag, (None, None) )[0]
if method:
self.handle_starttag(tag, method, attrs)
else:
self.unknown_starttag(tag,attrs)
self.tagstack.push( tag, attrs )
def endElementNS(self, tag, qname):
stag, attrs = self.tagstack.pop()
if self.processelem:
method = self.elements.get(tag, (None, None) )[1]
if method:
self.handle_endtag(tag, attrs, method)
else:
self.unknown_endtag(tag, attrs)
self.processelem, self.processcont = self.pstack.pop()
#--------------------------------------------------
def handle_starttag(self, tag, method, attrs):
method(tag,attrs)
def handle_endtag(self, tag, attrs, method):
method(tag, attrs)
def unknown_starttag(self, tag, attrs):
pass
def unknown_endtag(self, tag, attrs):
pass
##
# Ignore this xml element and all children of it
# It will automatically stop ignoring
#
def s_ignorexml(self, tag, attrs):
self.processelem = False
##
# Stop processing the text nodes
def s_ignorecont(self, tag, attrs):
self.processcont = False
##
# Start processing the text nodes
def s_processcont(self, tag, attrs):
self.processcont = True
##
# Generate a class name from a style name
def classname(self, attrs):
c = attrs.get((TEXTNS,'style-name'),'')
c = c.replace(".","_")
return c
##
# Create a unique anchor id for a href name
def get_anchor(self, name):
if name not in self.anchors:
self.anchors[name] = "anchor%03d" % (len(self.anchors) + 1)
return self.anchors.get(name)
#--------------------------------------------------
def purgedata(self):
self.data = []
#-----------------------------------------------------------------------------
#
# Handle meta data
#
#-----------------------------------------------------------------------------
##
# Get the title from the meta data and create a HTML <title>
#
def e_dc_title(self, tag, attrs):
self.title = ''.join(self.data)
#self.metatags.append('<title>%s</title>\n' % escape(self.title))
self.data = []
##
# Any other meta data is added as a <meta> element
#
def e_dc_metatag(self, tag, attrs):
self.metatags.append('<meta name="%s" content=%s/>\n' % (tag[1], quoteattr(''.join(self.data))))
self.data = []
##
# Set the content language. Identifies the targeted audience
#
def e_dc_contentlanguage(self, tag, attrs):
self.language = ''.join(self.data)
self.metatags.append('<meta http-equiv="content-language" content="%s"/>\n' % escape(self.language))
self.data = []
##
# Set the content creator. Identifies the targeted audience
#
def e_dc_creator(self, tag, attrs):
self.creator = ''.join(self.data)
self.metatags.append('<meta http-equiv="creator" content="%s"/>\n' % escape(self.creator))
self.data = []
##
# A <draw:custom-shape> is made into a <div> in HTML which is then styled
#
def s_custom_shape(self, tag, attrs):
anchor_type = attrs.get((TEXTNS,'anchor-type'),'notfound')
htmltag = 'div'
name = "G-" + attrs.get( (DRAWNS,'style-name'), "")
if name == 'G-':
name = "PR-" + attrs.get( (PRESENTATIONNS,'style-name'), "")
name = name.replace(".","_")
if anchor_type == "paragraph":
style = 'position:absolute;'
elif anchor_type == 'char':
style = "position:absolute;"
elif anchor_type == 'as-char':
htmltag = 'div'
style = ''
else:
style = "position: absolute;"
if (SVGNS,"width")in attrs:
style = style + "width:" + attrs[(SVGNS,"width")] + ";"
if (SVGNS,"height") in attrs:
style = style + "height:" + attrs[(SVGNS,"height")] + ";"
if (SVGNS,"x") in attrs:
style = style + "left:" + attrs[(SVGNS,"x")] + ";"
if (SVGNS,"y") in attrs:
style = style + "top:" + attrs[(SVGNS,"y")] + ";"
if self.generate_css:
self.opentag(htmltag, {'class': name, 'style': style})
else:
self.opentag(htmltag)
##
# End the <draw:frame>
#
def e_custom_shape(self, tag, attrs):
self.closetag('div')
##
# A <draw:frame> is made into a <div> in HTML which is then styled
#
def s_draw_frame(self, tag, attrs):
anchor_type = attrs.get((TEXTNS,'anchor-type'),'notfound')
htmltag = 'div'
name = "G-" + attrs.get( (DRAWNS,'style-name'), "")
if name == 'G-':
name = "PR-" + attrs.get( (PRESENTATIONNS,'style-name'), "")
name = name.replace(".","_")
if anchor_type == "paragraph":
style = 'position:relative;'
elif anchor_type == 'char':
style = "position:relative;"
elif anchor_type == 'as-char':
htmltag = 'div'
style = ''
else:
style = "position:absolute;"
if (SVGNS,"width") in attrs:
style = style + "width:" + attrs[(SVGNS,"width")] + ";"
if (SVGNS,"height") in attrs:
style = style + "height:" + attrs[(SVGNS,"height")] + ";"
if (SVGNS,"x") in attrs:
style = style + "left:" + attrs[(SVGNS,"x")] + ";"
if (SVGNS,"y") in attrs:
style = style + "top:" + attrs[(SVGNS,"y")] + ";"
if self.generate_css:
self.opentag(htmltag, {'class': name, 'style': style})
else:
self.opentag(htmltag)
##
# End the <draw:frame>
#
def e_draw_frame(self, tag, attrs):
self.closetag('div')
def s_draw_fill_image(self, tag, attrs):
name = attrs.get( (DRAWNS,'name'), "NoName")
imghref = attrs[(XLINKNS,"href")]
imghref = self.rewritelink(imghref)
self.cs.fillimages[name] = imghref
##
# Intended to be overloaded if you don't store your pictures
# in a Pictures subfolder
#
def rewritelink(self, imghref):
return imghref
##
# A <draw:image> becomes an <img/> element
#
def s_draw_image(self, tag, attrs):
parent = self.tagstack.stackparent()
anchor_type = parent.get((TEXTNS,'anchor-type'))
imghref = attrs[(XLINKNS,"href")]
imghref = self.rewritelink(imghref)
htmlattrs = {'alt':"", 'src':imghref }
if self.generate_css:
if anchor_type != "char":
htmlattrs['style'] = "display: block;"
self.emptytag('img', htmlattrs)
##
# A <draw:object> is embedded object in the document (e.g. spreadsheet in presentation).
#
def s_draw_object(self, tag, attrs):
objhref = attrs[(XLINKNS,"href")]
# Remove leading "./": from "./Object 1" to "Object 1"
# objhref = objhref [2:]
# Not using os.path.join since it fails to find the file on Windows.
# objcontentpath = '/'.join([objhref, 'content.xml'])
for c in self.document.childnodes:
if c.folder == objhref:
self._walknode(c.topnode)
##
# A <draw:object-ole> is embedded OLE object in the document (e.g. MS Graph).
#
def s_draw_object_ole(self, tag, attrs):
class_id = attrs[(DRAWNS,"class-id")]
if class_id and class_id.lower() == "00020803-0000-0000-c000-000000000046": ## Microsoft Graph 97 Chart
tagattrs = { 'name':'object_ole_graph', 'class':'ole-graph' }
self.opentag('a', tagattrs)
self.closetag('a', tagattrs)
##
# A <draw:page> is a slide in a presentation. We use a <fieldset> element in HTML.
# Therefore if you convert a ODP file, you get a series of <fieldset>s.
# Override this for your own purpose.
#
def s_draw_page(self, tag, attrs):
name = attrs.get( (DRAWNS,'name'), "NoName")
stylename = attrs.get( (DRAWNS,'style-name'), "")
stylename = stylename.replace(".","_")
masterpage = attrs.get( (DRAWNS,'master-page-name'),"")
masterpage = masterpage.replace(".","_")
if self.generate_css:
self.opentag('fieldset', {'class':"DP-%s MP-%s" % (stylename, masterpage) })
else:
self.opentag('fieldset')
self.opentag('legend')
self.writeout(escape(name))
self.closetag('legend')
def e_draw_page(self, tag, attrs):
self.closetag('fieldset')
def s_draw_textbox(self, tag, attrs):
style = ''
if (FONS,"min-height") in attrs:
style = style + "min-height:" + attrs[(FONS,"min-height")] + ";"
self.opentag('div')
# self.opentag('div', {'style': style})
##
# End the <draw:text-box>
#
def e_draw_textbox(self, tag, attrs):
self.closetag('div')
def html_body(self, tag, attrs):
self.writedata()
if self.generate_css and self.use_internal_css:
self.opentag('style', {'type':"text/css"}, True)
self.writeout('/*<![CDATA[*/\n')
self.generate_stylesheet()
self.writeout('/*]]>*/\n')
self.closetag('style')
self.purgedata()
self.closetag('head')
self.opentag('body', block=True)
default_styles = """
img { width: 100%; height: 100%; }
* { padding: 0; margin: 0; background-color:white; }
body { margin: 0 1em; }
ol, ul { padding-left: 2em; }
"""
def generate_stylesheet(self):
for name in self.stylestack:
styles = self.styledict.get(name)
# Preload with the family's default style
if '__style-family'in styles and styles['__style-family'] in self.styledict:
familystyle = self.styledict[styles['__style-family']].copy()
del styles['__style-family']
for style, val in styles.items():
familystyle[style] = val
styles = familystyle
# Resolve the remaining parent styles
while '__parent-style-name' in styles and styles['__parent-style-name'] in self.styledict:
parentstyle = self.styledict[styles['__parent-style-name']].copy()
del styles['__parent-style-name']
for style, val in styles.items():
parentstyle[style] = val
styles = parentstyle
self.styledict[name] = styles
# Write the styles to HTML
self.writeout(self.default_styles)
for name in self.stylestack:
styles = self.styledict.get(name)
css2 = self.cs.convert_styles(styles)
self.writeout("%s {\n" % name)
for style, val in css2.items():
self.writeout("\t%s: %s;\n" % (style, val) )
self.writeout("}\n")
def generate_footnotes(self):
if self.currentnote == 0:
return
if self.generate_css:
self.opentag('ol', {'style':'border-top: 1px solid black'}, True)
else:
self.opentag('ol')
for key in range(1,self.currentnote+1):
note = self.notedict[key]
# for key,note in self.notedict.items():
self.opentag('li', { 'id':"footnote-%d" % key })
# self.opentag('sup')
# self.writeout(escape(note['citation']))
# self.closetag('sup', False)
self.writeout(note['body'])
self.closetag('li')
self.closetag('ol')
def s_office_automatic_styles(self, tag, attrs):
if self.xmlfile == 'styles.xml':
self.autoprefix = "A"
else:
self.autoprefix = ""
##
# First tag in the content.xml file
def s_office_document_content(self, tag, attrs):
self.writeout('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" ')
self.writeout('"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">\n')
self.opentag('html', {'xmlns':"http://www.w3.org/1999/xhtml"}, True)
self.opentag('head', block=True)
self.emptytag('meta', { 'http-equiv':"Content-Type", 'content':"text/html;charset=UTF-8"})
for metaline in self.metatags:
self.writeout(metaline)
self.writeout('<title>%s</title>\n' % escape(self.title))
##
# Last tag
def e_office_document_content(self, tag, attrs):
self.closetag('html')
##
#
def s_office_master_styles(self, tag, attrs):
##
# For some odd reason, OpenOffice Impress doesn't define a default-style
# for the 'paragraph'. We therefore force a standard when we see
# it is a presentation
#
def s_office_presentation(self, tag, attrs):
self.styledict['p'] = {(FONS,u'font-size'): u"24pt" }
self.styledict['presentation'] = {(FONS,u'font-size'): u"24pt" }
self.html_body(tag, attrs)
def e_office_presentation(self, tag, attrs):
self.generate_footnotes()
self.closetag('body')
def s_office_spreadsheet(self, tag, attrs):
self.html_body(tag, attrs)
def e_office_spreadsheet(self, tag, attrs):
self.generate_footnotes()
self.closetag('body')
def s_office_styles(self, tag, attrs):
self.autoprefix = ""
##
# OpenDocument text
def s_office_text(self, tag, attrs):
self.styledict['frame'] = { (STYLENS,'wrap'): u'parallel'}
self.html_body(tag, attrs)
def e_office_text(self, tag, attrs):
self.generate_footnotes()
self.closetag('body')
##
# Copy all attributes to a struct.
# We will later convert them to CSS2
#
def s_style_handle_properties(self, tag, attrs):
for key,attr in attrs.items():
self.styledict[self.currentstyle][key] = attr
familymap = {'frame':'frame', 'paragraph':'p', 'presentation':'presentation',
'text':'span','section':'div',
'table':'table','table-cell':'td','table-column':'col',
'table-row':'tr','graphic':'graphic' }
##
# A default style is like a style on an HTML tag
#
def s_style_default_style(self, tag, attrs):
family = attrs[(STYLENS,'family')]
htmlfamily = self.familymap.get(family,'unknown')
self.currentstyle = htmlfamily
# self.stylestack.append(self.currentstyle)
self.styledict[self.currentstyle] = {}
def e_style_default_style(self, tag, attrs):
self.currentstyle = None
##
# It is possible that the HTML browser doesn't know how to
# show a particular font. Luckily ODF provides generic fallbacks
# Unfortunately they are not the same as CSS2.
# CSS2: serif, sans-serif, cursive, fantasy, monospace
# ODF: roman, swiss, modern, decorative, script, system
#
def s_style_font_face(self, tag, attrs):
name = attrs[(STYLENS,"name")]
family = attrs[(SVGNS,"font-family")]
generic = attrs.get( (STYLENS,'font-family-generic'),"" )
self.cs.save_font(name, family, generic)
def s_style_footer(self, tag, attrs):
self.opentag('div', { 'id':"footer" })
self.purgedata()
def e_style_footer(self, tag, attrs):
self.writedata()
self.closetag('div')
self.purgedata()
def s_style_footer_style(self, tag, attrs):
self.currentstyle = "@print #footer"
self.stylestack.append(self.currentstyle)
self.styledict[self.currentstyle] = {}
def s_style_header(self, tag, attrs):
self.opentag('div', { 'id':"header" })
self.purgedata()
def e_style_header(self, tag, attrs):
self.writedata()
self.closetag('div')
self.purgedata()
def s_style_header_style(self, tag, attrs):
self.currentstyle = "@print #header"
self.stylestack.append(self.currentstyle)
self.styledict[self.currentstyle] = {}
##
# Collect the formatting for the default page layout style.
#
def s_style_default_page_layout(self, tag, attrs):
self.currentstyle = "@page"
self.stylestack.append(self.currentstyle)
self.styledict[self.currentstyle] = {}
##
# Collect the formatting for the page layout style.
# This won't work in CSS 2.1, as page identifiers are not allowed.
# It is legal in CSS3, but the rest of the application doesn't specify when to use what page layout
#
def s_style_page_layout(self, tag, attrs):
name = attrs[(STYLENS,'name')]
name = name.replace(".","_")
self.currentstyle = ".PL-" + name
self.stylestack.append(self.currentstyle)
self.styledict[self.currentstyle] = {}
##
# End this style
#
def e_style_page_layout(self, tag, attrs):
self.currentstyle = None
##
# Collect the formatting for the page layout style.
#
def s_style_master_page(self, tag, attrs):
name = attrs[(STYLENS,'name')]
name = name.replace(".","_")
self.currentstyle = ".MP-" + name
self.stylestack.append(self.currentstyle)
self.styledict[self.currentstyle] = {('','position'):'relative'}
# Then load the pagelayout style if we find it
pagelayout = attrs.get( (STYLENS,'page-layout-name'), None)
if pagelayout:
pagelayout = ".PL-" + pagelayout
if pagelayout in self.styledict:
styles = self.styledict[pagelayout]
for style, val in styles.items():
self.styledict[self.currentstyle][style] = val
else:
self.styledict[self.currentstyle]['__parent-style-name'] = pagelayout
self.s_ignorexml(tag, attrs)
# Short prefixes for class selectors
_familyshort = {'drawing-page':'DP', 'paragraph':'P', 'presentation':'PR',
'text':'S', 'section':'D',
'table':'T', 'table-cell':'TD', 'table-column':'TC',
'table-row':'TR', 'graphic':'G' }
##
# Collect the formatting for the style.
# Styles have scope. The same name can be used for both paragraph and
# character styles Since CSS has no scope we use a prefix. (Not elegant)
# In ODF a style can have a parent, these parents can be chained.
# We may not have encountered the parent yet, but if we have, we resolve it.
#
def s_style_style(self, tag, attrs):
name = attrs[(STYLENS,'name')]
name = name.replace(".","_")
family = attrs[(STYLENS,'family')]
htmlfamily = self.familymap.get(family,'unknown')
sfamily = self._familyshort.get(family,'X')
name = "%s%s-%s" % (self.autoprefix, sfamily, name)
parent = attrs.get( (STYLENS,'parent-style-name') )
self.currentstyle = special_styles.get(name,"."+name)
self.stylestack.append(self.currentstyle)
if self.currentstyle not in self.styledict:
self.styledict[self.currentstyle] = {}
self.styledict[self.currentstyle]['__style-family'] = htmlfamily
# Then load the parent style if we find it
if parent:
parent = "%s-%s" % (sfamily, parent)
parent = special_styles.get(parent, "."+parent)
if parent in self.styledict:
styles = self.styledict[parent]
for style, val in styles.items():
self.styledict[self.currentstyle][style] = val
else:
self.styledict[self.currentstyle]['__parent-style-name'] = parent
##
# End this style
#
def e_style_style(self, tag, attrs):
self.currentstyle = None
##
# Start a table
#
def s_table_table(self, tag, attrs):
c = attrs.get( (TABLENS,'style-name'), None)
if c and self.generate_css:
c = c.replace(".","_")
self.opentag('table',{ 'class': "T-%s" % c })
else:
self.opentag('table')
self.purgedata()
##
# End a table
#
def e_table_table(self, tag, attrs):
self.writedata()
self.closetag('table')
self.purgedata()
##
# Start a table cell
def s_table_table_cell(self, tag, attrs):
#FIXME: number-columns-repeated § 8.1.3
#repeated = int(attrs.get( (TABLENS,'number-columns-repeated'), 1))
htmlattrs = {}
rowspan = attrs.get( (TABLENS,'number-rows-spanned') )
if rowspan:
htmlattrs['rowspan'] = rowspan
colspan = attrs.get( (TABLENS,'number-columns-spanned') )
if colspan:
htmlattrs['colspan'] = colspan
c = attrs.get( (TABLENS,'style-name') )
if c:
htmlattrs['class'] = 'TD-%s' % c.replace(".","_")
self.opentag('td', htmlattrs)
self.purgedata()
##
# End a table cell
def e_table_table_cell(self, tag, attrs):
self.writedata()
self.closetag('td')
self.purgedata()
##
# Start a table column
def s_table_table_column(self, tag, attrs):
c = attrs.get( (TABLENS,'style-name'), None)
repeated = int(attrs.get( (TABLENS,'number-columns-repeated'), 1))
htmlattrs = {}
if c:
htmlattrs['class'] = "TC-%s" % c.replace(".","_")
for x in range(repeated):
self.emptytag('col', htmlattrs)
self.purgedata()
##
# Start a table row
def s_table_table_row(self, tag, attrs):
#FIXME: table:number-rows-repeated
c = attrs.get( (TABLENS,'style-name'), None)
htmlattrs = {}
if c:
htmlattrs['class'] = "TR-%s" % c.replace(".","_")
self.opentag('tr', htmlattrs)
self.purgedata()
##
# End a table row
def e_table_table_row(self, tag, attrs):
self.writedata()
self.closetag('tr')
self.purgedata()
##
# Anchors start
def s_text_a(self, tag, attrs):
self.writedata()
href = attrs[(XLINKNS,"href")].split("|")[0]
if href[0] == "#":
href = "#" + self.get_anchor(href[1:])
self.opentag('a', {'href':href})
self.purgedata()
##
# End an anchor or bookmark reference
def e_text_a(self, tag, attrs):
self.writedata()
self.closetag('a', False)
self.purgedata()
##
# Bookmark definition
def s_text_bookmark(self, tag, attrs):
name = attrs[(TEXTNS,'name')]
html_id = self.get_anchor(name)
self.writedata()
self.opentag('span', {'id':html_id})
self.closetag('span', False)
self.purgedata()
##
# Bookmark reference
def s_text_bookmark_ref(self, tag, attrs):
name = attrs[(TEXTNS,'ref-name')]
html_id = "#" + self.get_anchor(name)
self.writedata()
self.opentag('a', {'href':html_id})
self.purgedata()
##
# Headings start
def s_text_h(self, tag, attrs):
level = int(attrs[(TEXTNS,'outline-level')])
if level > 6: level = 6 # Heading levels go only to 6 in XHTML
if level < 1: level = 1
self.headinglevels[level] = self.headinglevels[level] + 1
name = self.classname(attrs)
for x in range(level + 1,10):
self.headinglevels[x] = 0
special = special_styles.get("P-"+name)
if special or not self.generate_css:
self.opentag('h%s' % level)
else:
self.opentag('h%s' % level, {'class':"P-%s" % name })
self.purgedata()
##
# Headings end
# Side-effect: If there is no title in the metadata, then it is taken
# from the first heading of any level.
#
def e_text_h(self, tag, attrs):
self.writedata()
level = int(attrs[(TEXTNS,'outline-level')])
if level > 6: level = 6 # Heading levels go only to 6 in XHTML
if level < 1: level = 1
lev = self.headinglevels[1:level+1]
outline = '.'.join(map(str,lev) )
heading = ''.join(self.data)
if self.title == '': self.title = heading
anchor = self.get_anchor("%s.%s" % ( outline, heading))
self.opentag('a', {'id': anchor} )
self.closetag('a', False)
self.closetag('h%s' % level)
self.purgedata()
##
# Force a line break (<br/>)
def s_text_line_break(self, tag, attrs):
self.writedata()
self.emptytag('br')
self.purgedata()
##
# Start a list (<ul> or <ol>)
# To know which level we're at, we have to count the number
# of <text:list> elements on the tagstack.
#
def s_text_list(self, tag, attrs):
name = attrs.get( (TEXTNS,'style-name') )
level = self.tagstack.count_tags(tag) + 1
if name:
name = name.replace(".","_")
else:
# FIXME: If a list is contained in a table cell or text box,
# the list level must return to 1, even though the table or
# textbox itself may be nested within another list.
name = self.tagstack.rfindattr( (TEXTNS,'style-name') )
list_class = "%s_%d" % (name, level)
if self.generate_css:
self.opentag('%s' % self.listtypes.get(list_class,'ul'), {'class': list_class })
else:
self.opentag('%s' % self.listtypes.get(list_class,'ul'))
self.purgedata()
##
# End a list
def e_text_list(self, tag, attrs):
self.writedata()
name = attrs.get( (TEXTNS,'style-name') )
level = self.tagstack.count_tags(tag) + 1
if name:
name = name.replace(".","_")
else:
# FIXME: If a list is contained in a table cell or text box,
# the list level must return to 1, even though the table or
# textbox itself may be nested within another list.
name = self.tagstack.rfindattr( (TEXTNS,'style-name') )
list_class = "%s_%d" % (name, level)
self.closetag(self.listtypes.get(list_class,'ul'))
self.purgedata()
##
# Start list item
def s_text_list_item(self, tag, attrs):
self.opentag('li')
self.purgedata()
##
# End list item
def e_text_list_item(self, tag, attrs):
self.writedata()
self.closetag('li')
self.purgedata()
##
# CSS doesn't have the ability to set the glyph
# to a particular character, so we just go through
# the available glyphs
#
def s_text_list_level_style_bullet(self, tag, attrs):
name = self.tagstack.rfindattr( (STYLENS,'name') )
level = attrs[(TEXTNS,'level')]
self.prevstyle = self.currentstyle
list_class = "%s_%s" % (name, level)
self.listtypes[list_class] = 'ul'
self.currentstyle = ".%s_%s" % ( name.replace(".","_"), level)
self.stylestack.append(self.currentstyle)
self.styledict[self.currentstyle] = {}
level = int(level)
listtype = ("square", "disc", "circle")[level % 3]
self.styledict[self.currentstyle][('','list-style-type')] = listtype
def e_text_list_level_style_bullet(self, tag, attrs):
self.currentstyle = self.prevstyle
del self.prevstyle
def s_text_list_level_style_number(self, tag, attrs):
name = self.tagstack.stackparent()[(STYLENS,'name')]
level = attrs[(TEXTNS,'level')]
num_format = attrs.get( (STYLENS,'name'),"1")
list_class = "%s_%s" % (name, level)
self.prevstyle = self.currentstyle
self.currentstyle = ".%s_%s" % ( name.replace(".","_"), level)
self.listtypes[list_class] = 'ol'
self.stylestack.append(self.currentstyle)
self.styledict[self.currentstyle] = {}
if num_format == "1": listtype = "decimal"
elif num_format == "I": listtype = "upper-roman"
elif num_format == "i": listtype = "lower-roman"
elif num_format == "A": listtype = "upper-alpha"
elif num_format == "a": listtype = "lower-alpha"
else: listtype = "decimal"
self.styledict[self.currentstyle][('','list-style-type')] = listtype
def e_text_list_level_style_number(self, tag, attrs):
self.currentstyle = self.prevstyle
del self.prevstyle
def s_text_note(self, tag, attrs):
self.writedata()
self.purgedata()
self.currentnote = self.currentnote + 1
self.notedict[self.currentnote] = {}
self.notebody = []
def e_text_note(self, tag, attrs):
pass
def collectnote(self,s):
if s != '':
self.notebody.append(s)
def s_text_note_body(self, tag, attrs):
self._orgwfunc = self._wfunc
self._wfunc = self.collectnote
def e_text_note_body(self, tag, attrs):
self._wfunc = self._orgwfunc
self.notedict[self.currentnote]['body'] = ''.join(self.notebody)
self.notebody = ''
del self._orgwfunc
def e_text_note_citation(self, tag, attrs):
mark = ''.join(self.data)
self.notedict[self.currentnote]['citation'] = mark
self.opentag('a',{ 'href': "#footnote-%s" % self.currentnote })
self.opentag('sup')
# self.writeout( escape(mark) )
# Since HTML only knows about endnotes, there is too much risk that the
# marker is reused in the source. Therefore we force numeric markers
if sys.version_info[0]==3:
self.writeout(self.currentnote)
else:
self.writeout(unicode(self.currentnote))
self.closetag('sup')
self.closetag('a')
##
# Paragraph
#
def s_text_p(self, tag, attrs):
htmlattrs = {}
specialtag = "p"
c = attrs.get( (TEXTNS,'style-name'), None)
if c:
c = c.replace(".","_")
specialtag = special_styles.get("P-"+c)
if specialtag is None:
specialtag = 'p'
if self.generate_css:
htmlattrs['class'] = "P-%s" % c
self.opentag(specialtag, htmlattrs)
self.purgedata()
##
# End Paragraph
#
def e_text_p(self, tag, attrs):
specialtag = "p"
c = attrs.get( (TEXTNS,'style-name'), None)
if c:
c = c.replace(".","_")
specialtag = special_styles.get("P-"+c)
if specialtag is None:
specialtag = 'p'
self.writedata()
self.closetag(specialtag)
self.purgedata()
##
# Generate a number of spaces. ODF has an element; HTML uses &nbsp;
# We use &#160; so we can send the output through an XML parser if we desire to
#
def s_text_s(self, tag, attrs):
c = attrs.get( (TEXTNS,'c'),"1")
for x in range(int(c)):
self.writeout('&#160;')
##
# The <text:span> element matches the <span> element in HTML. It is
# typically used to properties of the text.
#
def s_text_span(self, tag, attrs):
self.writedata()
c = attrs.get( (TEXTNS,'style-name'), None)
htmlattrs = {}
if c:
c = c.replace(".","_")
special = special_styles.get("S-"+c)
if special is None and self.generate_css:
htmlattrs['class'] = "S-%s" % c
self.opentag('span', htmlattrs)
self.purgedata()
##
# End the <text:span>
def e_text_span(self, tag, attrs):
self.writedata()
self.closetag('span', False)
self.purgedata()
##
# Move to the next tabstop. We ignore this in HTML
#
def s_text_tab(self, tag, attrs):
self.writedata()
self.writeout(' ')
self.purgedata()
##
# Various indexes and tables of contents. We ignore those.
#
def s_text_x_source(self, tag, attrs):
self.writedata()
self.purgedata()
self.s_ignorexml(tag, attrs)
##
# Various indexes and tables of contents. We ignore those.
#
def e_text_x_source(self, tag, attrs):
self.writedata()
self.purgedata()
#-----------------------------------------------------------------------------
#
# Reading the file
#
#-----------------------------------------------------------------------------
##
#
# Loads a document into the parser and parses it.
# The argument can either be a filename or a document in memory.
# @param odffile if the type is unicode string: name of a file; else
# it must be an open file type
#
def load(self, odffile):
assert(type(odffile)==type(u"") or 'rb' in repr(odffile) or 'BufferedReader' in repr(odffile) or 'BytesIO' in repr(odffile))
self.lines = []
self._wfunc = self._wlines
if type(odffile)==type(u""):
self.document = load(odffile)
else:
self.document = odffile
self._walknode(self.document.topnode)
def _walknode(self, node):
if node.nodeType == Node.ELEMENT_NODE:
self.startElementNS(node.qname, node.tagName, node.attributes)
for c in node.childNodes:
self._walknode(c)
self.endElementNS(node.qname, node.tagName)
if node.nodeType == Node.TEXT_NODE or node.nodeType == Node.CDATA_SECTION_NODE:
if sys.version_info[0]==3:
self.characters(str(node))
else:
self.characters(unicode(node))
##
#
# Load a file and return the XHTML
# @param odffile if the type is unicode string: name of a file; else
# it must be an open file type
# @return XHTML code as a a unicode string
#
def odf2xhtml(self, odffile):
assert(type(odffile)==type(u"") or 'rb' in repr(odffile) or 'BufferedReader' in repr(odffile) or 'BytesIO' in repr(odffile))
self.load(odffile)
result=self.xhtml()
assert(type(result)==type(u""))
return result
def _wlines(self,s):
if s != '': self.lines.append(s)
##
# Returns the xhtml
#
def xhtml(self):
return ''.join(self.lines)
def _writecss(self, s):
if s != '': self._csslines.append(s)
def _writenothing(self, s):
pass
##
# Returns the CSS content
def css(self):
self._csslines = []
self._wfunc = self._writecss
self.generate_stylesheet()
res = ''.join(self._csslines)
self._wfunc = self._wlines
del self._csslines
return res
##
# Save the HTML under the filename.
# If the filename is '-' then save to stdout
# We have the last style filename in self.stylefilename
#
def save(self, outputfile, addsuffix=False):
if outputfile == '-':
outputfp = sys.stdout
else:
if addsuffix:
outputfile = outputfile + ".html"
outputfp = file(outputfile, "w")
outputfp.write(self.xhtml().encode('us-ascii','xmlcharrefreplace'))
outputfp.close()
##
# The ODF2XHTML parses an ODF file and produces XHTML
class ODF2XHTMLembedded(ODF2XHTML):
def __init__(self, lines, generate_css=True, embedable=False):
self._resetobject()
self.lines = lines
# Tags
self.generate_css = generate_css
self.elements = {
# (DCNS, 'title'): (self.s_processcont, self.e_dc_title),
# (DCNS, 'language'): (self.s_processcont, self.e_dc_contentlanguage),
# (DCNS, 'creator'): (self.s_processcont, self.e_dc_metatag),
# (DCNS, 'description'): (self.s_processcont, self.e_dc_metatag),
# (DCNS, 'date'): (self.s_processcont, self.e_dc_metatag),
(DRAWNS, 'frame'): (self.s_draw_frame, self.e_draw_frame),
(DRAWNS, 'image'): (self.s_draw_image, None),
(DRAWNS, 'fill-image'): (self.s_draw_fill_image, None),
(DRAWNS, "layer-set"):(self.s_ignorexml, None),
(DRAWNS, 'page'): (self.s_draw_page, self.e_draw_page),
(DRAWNS, 'object'): (self.s_draw_object, None),
(DRAWNS, 'object-ole'): (self.s_draw_object_ole, None),
(DRAWNS, 'text-box'): (self.s_draw_textbox, self.e_draw_textbox),
# (METANS, 'creation-date'):(self.s_processcont, self.e_dc_metatag),
# (METANS, 'generator'):(self.s_processcont, self.e_dc_metatag),
# (METANS, 'initial-creator'): (self.s_processcont, self.e_dc_metatag),
# (METANS, 'keyword'): (self.s_processcont, self.e_dc_metatag),
(NUMBERNS, "boolean-style"):(self.s_ignorexml, None),
(NUMBERNS, "currency-style"):(self.s_ignorexml, None),
(NUMBERNS, "date-style"):(self.s_ignorexml, None),
(NUMBERNS, "number-style"):(self.s_ignorexml, None),
(NUMBERNS, "text-style"):(self.s_ignorexml, None),
# (OFFICENS, "automatic-styles"):(self.s_office_automatic_styles, None),
# (OFFICENS, "document-content"):(self.s_office_document_content, self.e_office_document_content),
(OFFICENS, "forms"):(self.s_ignorexml, None),
# (OFFICENS, "master-styles"):(self.s_office_master_styles, None),
(OFFICENS, "meta"):(self.s_ignorecont, None),
# (OFFICENS, "presentation"):(self.s_office_presentation, self.e_office_presentation),
# (OFFICENS, "spreadsheet"):(self.s_office_spreadsheet, self.e_office_spreadsheet),
# (OFFICENS, "styles"):(self.s_office_styles, None),
# (OFFICENS, "text"):(self.s_office_text, self.e_office_text),
(OFFICENS, "scripts"):(self.s_ignorexml, None),
(PRESENTATIONNS, "notes"):(self.s_ignorexml, None),
## (STYLENS, "default-page-layout"):(self.s_style_default_page_layout, self.e_style_page_layout),
# (STYLENS, "default-page-layout"):(self.s_ignorexml, None),
# (STYLENS, "default-style"):(self.s_style_default_style, self.e_style_default_style),
# (STYLENS, "drawing-page-properties"):(self.s_style_handle_properties, None),
# (STYLENS, "font-face"):(self.s_style_font_face, None),
## (STYLENS, "footer"):(self.s_style_footer, self.e_style_footer),
## (STYLENS, "footer-style"):(self.s_style_footer_style, None),
# (STYLENS, "graphic-properties"):(self.s_style_handle_properties, None),
# (STYLENS, "handout-master"):(self.s_ignorexml, None),
## (STYLENS, "header"):(self.s_style_header, self.e_style_header),
## (STYLENS, "header-footer-properties"):(self.s_style_handle_properties, None),
## (STYLENS, "header-style"):(self.s_style_header_style, None),
# (STYLENS, "master-page"):(self.s_style_master_page, None),
# (STYLENS, "page-layout-properties"):(self.s_style_handle_properties, None),
## (STYLENS, "page-layout"):(self.s_style_page_layout, self.e_style_page_layout),
# (STYLENS, "page-layout"):(self.s_ignorexml, None),
# (STYLENS, "paragraph-properties"):(self.s_style_handle_properties, None),
# (STYLENS, "style"):(self.s_style_style, self.e_style_style),
# (STYLENS, "table-cell-properties"):(self.s_style_handle_properties, None),
# (STYLENS, "table-column-properties"):(self.s_style_handle_properties, None),
# (STYLENS, "table-properties"):(self.s_style_handle_properties, None),
# (STYLENS, "text-properties"):(self.s_style_handle_properties, None),
(SVGNS, 'desc'): (self.s_ignorexml, None),
(TABLENS, 'covered-table-cell'): (self.s_ignorexml, None),
(TABLENS, 'table-cell'): (self.s_table_table_cell, self.e_table_table_cell),
(TABLENS, 'table-column'): (self.s_table_table_column, None),
(TABLENS, 'table-row'): (self.s_table_table_row, self.e_table_table_row),
(TABLENS, 'table'): (self.s_table_table, self.e_table_table),
(TEXTNS, 'a'): (self.s_text_a, self.e_text_a),
(TEXTNS, "alphabetical-index-source"):(self.s_text_x_source, self.e_text_x_source),
(TEXTNS, "bibliography-configuration"):(self.s_ignorexml, None),
(TEXTNS, "bibliography-source"):(self.s_text_x_source, self.e_text_x_source),
(TEXTNS, 'h'): (self.s_text_h, self.e_text_h),
(TEXTNS, "illustration-index-source"):(self.s_text_x_source, self.e_text_x_source),
(TEXTNS, 'line-break'):(self.s_text_line_break, None),
(TEXTNS, "linenumbering-configuration"):(self.s_ignorexml, None),
(TEXTNS, "list"):(self.s_text_list, self.e_text_list),
(TEXTNS, "list-item"):(self.s_text_list_item, self.e_text_list_item),
(TEXTNS, "list-level-style-bullet"):(self.s_text_list_level_style_bullet, self.e_text_list_level_style_bullet),
(TEXTNS, "list-level-style-number"):(self.s_text_list_level_style_number, self.e_text_list_level_style_number),
(TEXTNS, "list-style"):(None, None),
(TEXTNS, "note"):(self.s_text_note, None),
(TEXTNS, "note-body"):(self.s_text_note_body, self.e_text_note_body),
(TEXTNS, "note-citation"):(None, self.e_text_note_citation),
(TEXTNS, "notes-configuration"):(self.s_ignorexml, None),
(TEXTNS, "object-index-source"):(self.s_text_x_source, self.e_text_x_source),
(TEXTNS, 'p'): (self.s_text_p, self.e_text_p),
(TEXTNS, 's'): (self.s_text_s, None),
(TEXTNS, 'span'): (self.s_text_span, self.e_text_span),
(TEXTNS, 'tab'): (self.s_text_tab, None),
(TEXTNS, "table-index-source"):(self.s_text_x_source, self.e_text_x_source),
(TEXTNS, "table-of-content-source"):(self.s_text_x_source, self.e_text_x_source),
(TEXTNS, "user-index-source"):(self.s_text_x_source, self.e_text_x_source),
(TEXTNS, "page-number"):(None, None),
}
odf.odf2xhtml.ODF2XHTML.generate_stylesheet
def generate_stylesheet(self)
Definition: odf2xhtml.py:861
odf.odf2xhtml.TagStack.rfindattr
def rfindattr(self, attr)
Find a tag with the given attribute.
Definition: odf2xhtml.py:321
odf.odf2xhtml.ODF2XHTML.opentag
def opentag
Create an open HTML tag.
Definition: odf2xhtml.py:540
odf.odf2xhtml.ODF2XHTML._orgwfunc
_orgwfunc
Definition: odf2xhtml.py:1397
odf.odf2xhtml.ODF2XHTML.s_style_default_page_layout
def s_style_default_page_layout(self, tag, attrs)
Collect the formatting for the default page layout style.
Definition: odf2xhtml.py:1039
odf.odf2xhtml.ODF2XHTML.language
language
Definition: odf2xhtml.py:504
odf.odf2xhtml.ODF2XHTML.prevstyle
prevstyle
Definition: odf2xhtml.py:1345
odf.odf2xhtml.ODF2XHTML.e_text_h
def e_text_h(self, tag, attrs)
Headings end Side-effect: If there is no title in the metadata, then it is taken from the first headi...
Definition: odf2xhtml.py:1263
odf.odf2xhtml.ODF2XHTML.s_draw_page
def s_draw_page(self, tag, attrs)
A is a slide in a presentation.
Definition: odf2xhtml.py:812
odf.odf2xhtml.ODF2XHTML.e_dc_contentlanguage
def e_dc_contentlanguage(self, tag, attrs)
Set the content language.
Definition: odf2xhtml.py:666
odf.odf2xhtml.ODF2XHTML.e_dc_metatag
def e_dc_metatag(self, tag, attrs)
Any other meta data is added as a element.
Definition: odf2xhtml.py:659
odf.odf2xhtml.StyleToCSS.c_hp
def c_hp(self, ruleset, sdict, rule, hpos)
Definition: odf2xhtml.py:207
odf.odf2xhtml.ODF2XHTML.title
title
Definition: odf2xhtml.py:503
odf.odf2xhtml.ODF2XHTML.unknown_endtag
def unknown_endtag(self, tag, attrs)
Definition: odf2xhtml.py:603
odf.odf2xhtml.ODF2XHTML.s_draw_image
def s_draw_image(self, tag, attrs)
A becomes an element.
Definition: odf2xhtml.py:771
odf.odf2xhtml.StyleToCSS.ruleconversions
ruleconversions
Definition: odf2xhtml.py:71
odf.odf2xhtml.ODF2XHTML.s_style_header
def s_style_header(self, tag, attrs)
Definition: odf2xhtml.py:1022
odf.odf2xhtml.ODF2XHTML.html_body
def html_body(self, tag, attrs)
Definition: odf2xhtml.py:842
odf.odf2xhtml.ODF2XHTML.e_custom_shape
def e_custom_shape(self, tag, attrs)
End the
Definition: odf2xhtml.py:714
odf.odf2xhtml.ODF2XHTML.classname
def classname(self, attrs)
Generate a class name from a style name.
Definition: odf2xhtml.py:625
odf.odf2xhtml.ODF2XHTML._walknode
def _walknode(self, node)
Definition: odf2xhtml.py:1533
odf.odf2xhtml.ODF2XHTML.e_style_style
def e_style_style(self, tag, attrs)
End this style.
Definition: odf2xhtml.py:1126
odf.odf2xhtml.ODF2XHTML.s_style_handle_properties
def s_style_handle_properties(self, tag, attrs)
Copy all attributes to a struct.
Definition: odf2xhtml.py:972
odf.odf2xhtml.ODF2XHTML.xmlfile
xmlfile
Definition: odf2xhtml.py:502
odf.odf2xhtml.ODF2XHTML.s_table_table_cell
def s_table_table_cell(self, tag, attrs)
Start a table cell.
Definition: odf2xhtml.py:1151
odf.odf2xhtml.ODF2XHTML.creator
creator
Definition: odf2xhtml.py:505
odf.odf2xhtml.ODF2XHTML._wlines
def _wlines(self, s)
Definition: odf2xhtml.py:1563
odf.odf2xhtml.ODF2XHTML.e_text_note
def e_text_note(self, tag, attrs)
Definition: odf2xhtml.py:1389
odf.odf2xhtml.ODF2XHTML.lines
lines
Definition: odf2xhtml.py:500
odf.odf2xhtml.StyleToCSS.__init__
def __init__(self)
Definition: odf2xhtml.py:64
odf.odf2xhtml.ODF2XHTML.processcont
processcont
Definition: odf2xhtml.py:511
odf.odf2xhtml.ODF2XHTML.e_draw_page
def e_draw_page(self, tag, attrs)
Definition: odf2xhtml.py:826
odf.odf2xhtml.ODF2XHTML.e_text_note_body
def e_text_note_body(self, tag, attrs)
Definition: odf2xhtml.py:1400
odf.odf2xhtml.ODF2XHTML.unknown_starttag
def unknown_starttag(self, tag, attrs)
Definition: odf2xhtml.py:600
odf.odf2xhtml.ODF2XHTML.e_text_list_item
def e_text_list_item(self, tag, attrs)
End list item.
Definition: odf2xhtml.py:1332
odf.odf2xhtml.ODF2XHTML.s_style_master_page
def s_style_master_page(self, tag, attrs)
Collect the formatting for the page layout style.
Definition: odf2xhtml.py:1065
odf.odf2xhtml.ODF2XHTML.e_office_spreadsheet
def e_office_spreadsheet(self, tag, attrs)
Definition: odf2xhtml.py:951
odf.odf2xhtml.ODF2XHTML.collectnote
def collectnote(self, s)
Definition: odf2xhtml.py:1392
odf.odf2xhtml.ODF2XHTML.s_style_page_layout
def s_style_page_layout(self, tag, attrs)
Collect the formatting for the page layout style.
Definition: odf2xhtml.py:1049
odf.odf2xhtml.ODF2XHTML.set_embedable
def set_embedable(self)
Tells the converter to only output the parts inside the
Definition: odf2xhtml.py:474
odf.odf2xhtml.ODF2XHTML.s_draw_object_ole
def s_draw_object_ole(self, tag, attrs)
A is embedded OLE object in the document (e.g.
Definition: odf2xhtml.py:800
odf.odf2xhtml.TagStack.__init__
def __init__(self)
Definition: odf2xhtml.py:305
odf.odf2xhtml.TagStack.push
def push(self, tag, attrs)
Definition: odf2xhtml.py:308
odf.odf2xhtml.ODF2XHTML.s_office_spreadsheet
def s_office_spreadsheet(self, tag, attrs)
Definition: odf2xhtml.py:948
odf.odf2xhtml.ODF2XHTML.s_office_automatic_styles
def s_office_automatic_styles(self, tag, attrs)
Definition: odf2xhtml.py:907
odf.odf2xhtml.ODF2XHTML.s_style_header_style
def s_style_header_style(self, tag, attrs)
Definition: odf2xhtml.py:1031
odf.odf2xhtml.ODF2XHTML.e_draw_frame
def e_draw_frame(self, tag, attrs)
End the
Definition: odf2xhtml.py:752
odf.odf2xhtml.ODF2XHTML.s_draw_fill_image
def s_draw_fill_image(self, tag, attrs)
Definition: odf2xhtml.py:755
odf.odf2xhtml.ODF2XHTML.s_ignorexml
def s_ignorexml(self, tag, attrs)
Ignore this xml element and all children of it It will automatically stop ignoring.
Definition: odf2xhtml.py:610
odf.odf2xhtml.ODF2XHTML.s_ignorecont
def s_ignorecont(self, tag, attrs)
Stop processing the text nodes.
Definition: odf2xhtml.py:615
odf.odf2xhtml.ODF2XHTML.metatags
metatags
Definition: odf2xhtml.py:526
odf.odf2xhtml.ODF2XHTML.s_draw_object
def s_draw_object(self, tag, attrs)
A is embedded object in the document (e.g.
Definition: odf2xhtml.py:785
odf.odf2xhtml.ODF2XHTML.e_text_list
def e_text_list(self, tag, attrs)
End a list.
Definition: odf2xhtml.py:1309
odf.odf2xhtml.ODF2XHTML.s_office_text
def s_office_text(self, tag, attrs)
OpenDocument text.
Definition: odf2xhtml.py:960
odf.odf2xhtml.ODF2XHTML.handle_endtag
def handle_endtag(self, tag, attrs, method)
Definition: odf2xhtml.py:597
odf.odf2xhtml.ODF2XHTML.e_style_default_style
def e_style_default_style(self, tag, attrs)
Definition: odf2xhtml.py:992
odf.odf2xhtml.ODF2XHTML.s_processcont
def s_processcont(self, tag, attrs)
Start processing the text nodes.
Definition: odf2xhtml.py:620
odf.odf2xhtml.ODF2XHTML.listtypes
listtypes
Definition: odf2xhtml.py:512
odf.odf2xhtml.ODF2XHTML.s_office_master_styles
def s_office_master_styles(self, tag, attrs)
Definition: odf2xhtml.py:932
odf.odf2xhtml.ODF2XHTML.emptytag
def emptytag
Definition: odf2xhtml.py:560
odf.odf2xhtml.ODF2XHTML.e_text_p
def e_text_p(self, tag, attrs)
End Paragraph.
Definition: odf2xhtml.py:1441
odf.odf2xhtml.ODF2XHTML.s_text_span
def s_text_span(self, tag, attrs)
The element matches the element in HTML.
Definition: odf2xhtml.py:1466
odf.odf2xhtml.ODF2XHTML.e_table_table_cell
def e_table_table_cell(self, tag, attrs)
End a table cell.
Definition: odf2xhtml.py:1170
odf.odf2xhtml.ODF2XHTML.startElementNS
def startElementNS(self, tag, qname, attrs)
Definition: odf2xhtml.py:573
odf.odf2xhtml.ODF2XHTML.s_text_list_level_style_number
def s_text_list_level_style_number(self, tag, attrs)
Definition: odf2xhtml.py:1360
odf.odf2xhtml.ODF2XHTML.e_text_span
def e_text_span(self, tag, attrs)
End the
Definition: odf2xhtml.py:1480
odf.odf2xhtml.ODF2XHTML.characters
def characters(self, data)
Definition: odf2xhtml.py:569
odf.odf2xhtml.StyleToCSS.fillimages
fillimages
Definition: odf2xhtml.py:69
odf.odf2xhtml.ODF2XHTML.pstack
pstack
Definition: odf2xhtml.py:509
odf.odf2xhtml.ODF2XHTML.s_draw_textbox
def s_draw_textbox(self, tag, attrs)
Definition: odf2xhtml.py:829
odf.odf2xhtml.ODF2XHTML.s_text_s
def s_text_s(self, tag, attrs)
Generate a number of spaces.
Definition: odf2xhtml.py:1457
odf.odf2xhtml.ODF2XHTML.s_style_footer
def s_style_footer(self, tag, attrs)
Definition: odf2xhtml.py:1008
odf.odf2xhtml.ODF2XHTML.e_text_x_source
def e_text_x_source(self, tag, attrs)
Various indexes and tables of contents.
Definition: odf2xhtml.py:1504
odf.odf2xhtml.ODF2XHTML.autoprefix
autoprefix
Definition: odf2xhtml.py:909
odf.odf2xhtml.ODF2XHTML.notebody
notebody
Definition: odf2xhtml.py:497
odf.odf2xhtml.StyleToCSS.c_text_align
def c_text_align(self, ruleset, sdict, rule, align)
Text align.
Definition: odf2xhtml.py:159
odf.odf2xhtml.TagStack
Definition: odf2xhtml.py:304
odf.odf2xhtml.ODF2XHTML.s_office_styles
def s_office_styles(self, tag, attrs)
Definition: odf2xhtml.py:955
odf.odf2xhtml.ODF2XHTML.e_style_page_layout
def e_style_page_layout(self, tag, attrs)
End this style.
Definition: odf2xhtml.py:1059
odf.odf2xhtml.TagStack.stackparent
def stackparent(self)
Definition: odf2xhtml.py:315
odf.odf2xhtml.ODF2XHTML.e_draw_textbox
def e_draw_textbox(self, tag, attrs)
End the
Definition: odf2xhtml.py:839
odf.odf2xhtml.ODF2XHTML.s_text_p
def s_text_p(self, tag, attrs)
Paragraph.
Definition: odf2xhtml.py:1424
odf.odf2xhtml.ODF2XHTML.htmlstack
htmlstack
Definition: odf2xhtml.py:508
odf.odf2xhtml.ODF2XHTML.generate_css
generate_css
Definition: odf2xhtml.py:366
odf.odf2xhtml.ODF2XHTML.cs
cs
Definition: odf2xhtml.py:515
odf.odf2xhtml.ODF2XHTML.get_anchor
def get_anchor(self, name)
Create a unique anchor id for a href name.
Definition: odf2xhtml.py:632
odf.odf2xhtml.ODF2XHTML.s_text_h
def s_text_h(self, tag, attrs)
Headings start.
Definition: odf2xhtml.py:1243
odf.odf2xhtml.ODF2XHTML.s_text_list_level_style_bullet
def s_text_list_level_style_bullet(self, tag, attrs)
CSS doesn't have the ability to set the glyph to a particular character, so we just go through the av...
Definition: odf2xhtml.py:1342
odf.odf2xhtml.ODF2XHTML.s_text_bookmark
def s_text_bookmark(self, tag, attrs)
Bookmark definition.
Definition: odf2xhtml.py:1224
odf.odf2xhtml.StyleToCSS.save_font
def save_font(self, name, family, generic)
It is possible that the HTML browser doesn't know how to show a particular font.
Definition: odf2xhtml.py:120
odf.element.unicode
unicode
Definition: element.py:34
odf.odf2xhtml.ODF2XHTML.s_table_table_column
def s_table_table_column(self, tag, attrs)
Start a table column.
Definition: odf2xhtml.py:1177
odf.odf2xhtml.StyleToCSS.c_text_underline_style
def c_text_underline_style(self, ruleset, sdict, rule, val)
Set underline decoration HTML doesn't really have a page-width.
Definition: odf2xhtml.py:260
odf.odf2xhtml.ODF2XHTML.styledict
styledict
Definition: odf2xhtml.py:520
odf.odf2xhtml.ODF2XHTML.save
def save
Save the HTML under the filename.
Definition: odf2xhtml.py:1594
odf.odf2xhtml.ODF2XHTML.s_text_x_source
def s_text_x_source(self, tag, attrs)
Various indexes and tables of contents.
Definition: odf2xhtml.py:1496
odf.odf2xhtml.ODF2XHTML.writedata
def writedata(self)
Definition: odf2xhtml.py:533
odf.odf2xhtml.ODF2XHTML.s_text_bookmark_ref
def s_text_bookmark_ref(self, tag, attrs)
Bookmark reference.
Definition: odf2xhtml.py:1234
odf.odf2xhtml.ODF2XHTML.s_style_style
def s_style_style(self, tag, attrs)
Collect the formatting for the style.
Definition: odf2xhtml.py:1097
odf.odf2xhtml.ODF2XHTML._resetfootnotes
def _resetfootnotes(self)
Definition: odf2xhtml.py:493
odf.odf2xhtml.ODF2XHTML.odf2xhtml
def odf2xhtml(self, odffile)
Load a file and return the XHTML.
Definition: odf2xhtml.py:1553
odf.odf2xhtml.TagStack.stack
stack
Definition: odf2xhtml.py:306
odf.odf2xhtml.ODF2XHTML.stylefilename
stylefilename
Definition: odf2xhtml.py:487
odf.odf2xhtml.StyleToCSS.c_fn
def c_fn(self, ruleset, sdict, rule, fontstyle)
Generate the CSS font family A generic font can be found in two ways.
Definition: odf2xhtml.py:169
odf.odf2xhtml.ODF2XHTML.s_text_tab
def s_text_tab(self, tag, attrs)
Move to the next tabstop.
Definition: odf2xhtml.py:1488
odf.odf2xhtml.ODF2XHTML.s_text_line_break
def s_text_line_break(self, tag, attrs)
Force a line break ( )
Definition: odf2xhtml.py:1280
odf.odf2xhtml.ODF2XHTML.s_table_table_row
def s_table_table_row(self, tag, attrs)
Start a table row.
Definition: odf2xhtml.py:1189
odf.odf2xhtml.StyleToCSS.c_border_model
def c_border_model(self, ruleset, sdict, rule, val)
Convert to CSS2 border model.
Definition: odf2xhtml.py:146
odf.odf2xhtml.ODF2XHTML.s_style_default_style
def s_style_default_style(self, tag, attrs)
A default style is like a style on an HTML tag.
Definition: odf2xhtml.py:985
odf.odf2xhtml.StyleToCSS.fontdict
fontdict
Definition: odf2xhtml.py:66
odf.odf2xhtml.ODF2XHTML.set_plain
def set_plain(self)
Tell the parser to not generate CSS.
Definition: odf2xhtml.py:469
odf.odf2xhtml.ODF2XHTML.headinglevels
headinglevels
Definition: odf2xhtml.py:513
odf.odf2xhtml.ODF2XHTMLembedded.__init__
def __init__
Definition: odf2xhtml.py:1609
odf.odf2xhtml.ODF2XHTML.e_text_note_citation
def e_text_note_citation(self, tag, attrs)
Definition: odf2xhtml.py:1406
odf.odf2xhtml.ODF2XHTML.s_table_table
def s_table_table(self, tag, attrs)
Start a table.
Definition: odf2xhtml.py:1132
odf.odf2xhtml.ODF2XHTML.css
def css(self)
Returns the CSS content.
Definition: odf2xhtml.py:1580
odf.odf2xhtml.ODF2XHTML.rewritelink
def rewritelink(self, imghref)
Intended to be overloaded if you don't store your pictures in a Pictures subfolder.
Definition: odf2xhtml.py:765
odf.odf2xhtml.ODF2XHTML.e_text_list_level_style_bullet
def e_text_list_level_style_bullet(self, tag, attrs)
Definition: odf2xhtml.py:1356
odf.odf2xhtml.StyleToCSS.c_width
def c_width(self, ruleset, sdict, rule, val)
Set width of box.
Definition: odf2xhtml.py:154
odf.odf2xhtml.ODF2XHTML.e_office_text
def e_office_text(self, tag, attrs)
Definition: odf2xhtml.py:964
odf.odf2xhtml.ODF2XHTML.handle_starttag
def handle_starttag(self, tag, method, attrs)
Definition: odf2xhtml.py:594
odf.odf2xhtml.ODF2XHTML.currentstyle
currentstyle
Definition: odf2xhtml.py:521
odf.odf2xhtml.ODF2XHTML.e_text_list_level_style_number
def e_text_list_level_style_number(self, tag, attrs)
Definition: odf2xhtml.py:1378
odf.odf2xhtml.ODF2XHTML.s_text_list_item
def s_text_list_item(self, tag, attrs)
Start list item.
Definition: odf2xhtml.py:1326
odf.odf2xhtml.ODF2XHTML._csslines
_csslines
Definition: odf2xhtml.py:1581
odf.odf2xhtml.ODF2XHTML.document
document
Definition: odf2xhtml.py:1528
odf.odf2xhtml.ODF2XHTML.s_office_presentation
def s_office_presentation(self, tag, attrs)
For some odd reason, OpenOffice Impress doesn't define a default-style for the 'paragraph'.
Definition: odf2xhtml.py:939
odf.odf2xhtml.ODF2XHTML.purgedata
def purgedata(self)
Definition: odf2xhtml.py:640
odf.odf2xhtml.ODF2XHTML
The ODF2XHTML parses an ODF file and produces XHTML.
Definition: odf2xhtml.py:362
odf.odf2xhtml.ODF2XHTML.e_dc_title
def e_dc_title(self, tag, attrs)
Get the title from the meta data and create a HTML </div><div class="ttdef"><b>Definition:</b> <a href="odf2xhtml_8py_source.html#l00651">odf2xhtml.py:651</a></div></div> <div class="ttc" id="classodf_1_1odf2xhtml_1_1ODF2XHTML_html_a92af6b5ca7b3725cc1bfc461e500e742"><div class="ttname"><a href="classodf_1_1odf2xhtml_1_1ODF2XHTML.html#a92af6b5ca7b3725cc1bfc461e500e742">odf.odf2xhtml.ODF2XHTML.s_text_note</a></div><div class="ttdeci">def s_text_note(self, tag, attrs)</div><div class="ttdef"><b>Definition:</b> <a href="odf2xhtml_8py_source.html#l01382">odf2xhtml.py:1382</a></div></div> <div class="ttc" id="classodf_1_1odf2xhtml_1_1ODF2XHTML_html_a2c69d8e25a9d351f604594713fd89bd5"><div class="ttname"><a href="classodf_1_1odf2xhtml_1_1ODF2XHTML.html#a2c69d8e25a9d351f604594713fd89bd5">odf.odf2xhtml.ODF2XHTML.notedict</a></div><div class="ttdeci">notedict</div><div class="ttdef"><b>Definition:</b> <a href="odf2xhtml_8py_source.html#l00495">odf2xhtml.py:495</a></div></div> <div class="ttc" id="classodf_1_1odf2xhtml_1_1ODF2XHTML_html_a3cffcd2da818ce712c970f40be067a7c"><div class="ttname"><a href="classodf_1_1odf2xhtml_1_1ODF2XHTML.html#a3cffcd2da818ce712c970f40be067a7c">odf.odf2xhtml.ODF2XHTML.e_office_document_content</a></div><div class="ttdeci">def e_office_document_content(self, tag, attrs)</div><div class="ttdoc">Last tag. </div><div class="ttdef"><b>Definition:</b> <a href="odf2xhtml_8py_source.html#l00927">odf2xhtml.py:927</a></div></div> <div class="ttc" id="classodf_1_1odf2xhtml_1_1ODF2XHTML_html_a8463d7c97fd37b44742201defeee1183"><div class="ttname"><a href="classodf_1_1odf2xhtml_1_1ODF2XHTML.html#a8463d7c97fd37b44742201defeee1183">odf.odf2xhtml.ODF2XHTML.e_text_a</a></div><div class="ttdeci">def e_text_a(self, tag, attrs)</div><div class="ttdoc">End an anchor or bookmark reference. </div><div class="ttdef"><b>Definition:</b> <a href="odf2xhtml_8py_source.html#l01217">odf2xhtml.py:1217</a></div></div> <div class="ttc" id="classodf_1_1odf2xhtml_1_1ODF2XHTML_html_a3470f2f7b7c9fec62de64e7573d4e2d4"><div class="ttname"><a href="classodf_1_1odf2xhtml_1_1ODF2XHTML.html#a3470f2f7b7c9fec62de64e7573d4e2d4">odf.odf2xhtml.ODF2XHTML.__init__</a></div><div class="ttdeci">def __init__</div><div class="ttdef"><b>Definition:</b> <a href="odf2xhtml_8py_source.html#l00364">odf2xhtml.py:364</a></div></div> <div class="ttc" id="classodf_1_1odf2xhtml_1_1ODF2XHTML_html_ac56272c03476fc211636885033e08bb2"><div class="ttname"><a href="classodf_1_1odf2xhtml_1_1ODF2XHTML.html#ac56272c03476fc211636885033e08bb2">odf.odf2xhtml.ODF2XHTML.load</a></div><div class="ttdeci">def load(self, odffile)</div><div class="ttdoc">Loads a document into the parser and parses it. </div><div class="ttdef"><b>Definition:</b> <a href="odf2xhtml_8py_source.html#l01522">odf2xhtml.py:1522</a></div></div> <div class="ttc" id="classodf_1_1odf2xhtml_1_1ODF2XHTML_html_aa4517811274efe365e06423e6481f6f0"><div class="ttname"><a href="classodf_1_1odf2xhtml_1_1ODF2XHTML.html#aa4517811274efe365e06423e6481f6f0">odf.odf2xhtml.ODF2XHTML.stylestack</a></div><div class="ttdeci">stylestack</div><div class="ttdef"><b>Definition:</b> <a href="odf2xhtml_8py_source.html#l00519">odf2xhtml.py:519</a></div></div> <div class="ttc" id="classodf_1_1odf2xhtml_1_1StyleToCSS_html_a38440cbb44cb216730d54488a6e7fb11"><div class="ttname"><a href="classodf_1_1odf2xhtml_1_1StyleToCSS.html#a38440cbb44cb216730d54488a6e7fb11">odf.odf2xhtml.StyleToCSS.c_fo</a></div><div class="ttdeci">def c_fo(self, ruleset, sdict, rule, val)</div><div class="ttdoc">XSL formatting attributes. </div><div class="ttdef"><b>Definition:</b> <a href="odf2xhtml_8py_source.html#l00140">odf2xhtml.py:140</a></div></div> <div class="ttc" id="classodf_1_1odf2xhtml_1_1ODF2XHTML_html_ab9f15ff72cc5a06c605b554ea208cde0"><div class="ttname"><a href="classodf_1_1odf2xhtml_1_1ODF2XHTML.html#ab9f15ff72cc5a06c605b554ea208cde0">odf.odf2xhtml.ODF2XHTML.data</a></div><div class="ttdeci">data</div><div class="ttdef"><b>Definition:</b> <a href="odf2xhtml_8py_source.html#l00506">odf2xhtml.py:506</a></div></div> <div class="ttc" id="classodf_1_1odf2xhtml_1_1ODF2XHTML_html_aeb0c7130ee5ac5610e92dbcc49605c23"><div class="ttname"><a href="classodf_1_1odf2xhtml_1_1ODF2XHTML.html#aeb0c7130ee5ac5610e92dbcc49605c23">odf.odf2xhtml.ODF2XHTML.default_styles</a></div><div class="ttdeci">string default_styles</div><div class="ttdef"><b>Definition:</b> <a href="odf2xhtml_8py_source.html#l00854">odf2xhtml.py:854</a></div></div> <div class="ttc" id="classodf_1_1odf2xhtml_1_1ODF2XHTML_html_a63d104522ec7c527068a8f246f12e9c8"><div class="ttname"><a href="classodf_1_1odf2xhtml_1_1ODF2XHTML.html#a63d104522ec7c527068a8f246f12e9c8">odf.odf2xhtml.ODF2XHTML.endElementNS</a></div><div class="ttdeci">def endElementNS(self, tag, qname)</div><div class="ttdef"><b>Definition:</b> <a href="odf2xhtml_8py_source.html#l00583">odf2xhtml.py:583</a></div></div> <div class="ttc" id="classodf_1_1odf2xhtml_1_1ODF2XHTMLembedded_html"><div class="ttname"><a href="classodf_1_1odf2xhtml_1_1ODF2XHTMLembedded.html">odf.odf2xhtml.ODF2XHTMLembedded</a></div><div class="ttdoc">The ODF2XHTML parses an ODF file and produces XHTML. </div><div class="ttdef"><b>Definition:</b> <a href="odf2xhtml_8py_source.html#l01607">odf2xhtml.py:1607</a></div></div> <div class="ttc" id="classodf_1_1odf2xhtml_1_1ODF2XHTML_html_aff2d91335de8a18d5792fa8b5d643bb8"><div class="ttname"><a href="classodf_1_1odf2xhtml_1_1ODF2XHTML.html#aff2d91335de8a18d5792fa8b5d643bb8">odf.odf2xhtml.ODF2XHTML.s_custom_shape</a></div><div class="ttdeci">def s_custom_shape(self, tag, attrs)</div><div class="ttdoc">A <draw:custom-shape> is made into a in HTML which is then styled. </div><div class="ttdef"><b>Definition:</b> <a href="odf2xhtml_8py_source.html#l00682">odf2xhtml.py:682</a></div></div> <div class="ttc" id="classodf_1_1odf2xhtml_1_1ODF2XHTML_html_a1fee12d9aa7898773955447871d0556a"><div class="ttname"><a href="classodf_1_1odf2xhtml_1_1ODF2XHTML.html#a1fee12d9aa7898773955447871d0556a">odf.odf2xhtml.ODF2XHTML.xhtml</a></div><div class="ttdeci">def xhtml(self)</div><div class="ttdoc">Returns the xhtml. </div><div class="ttdef"><b>Definition:</b> <a href="odf2xhtml_8py_source.html#l01569">odf2xhtml.py:1569</a></div></div> <div class="ttc" id="classodf_1_1odf2xhtml_1_1ODF2XHTML_html_a8cb953dd96aed0fc42396c3492e0b879"><div class="ttname"><a href="classodf_1_1odf2xhtml_1_1ODF2XHTML.html#a8cb953dd96aed0fc42396c3492e0b879">odf.odf2xhtml.ODF2XHTML._writecss</a></div><div class="ttdeci">def _writecss(self, s)</div><div class="ttdef"><b>Definition:</b> <a href="odf2xhtml_8py_source.html#l01572">odf2xhtml.py:1572</a></div></div> <div class="ttc" id="classodf_1_1odf2xhtml_1_1ODF2XHTML_html_ab06ecdbc49f7f31d3c5274cb612af4e6"><div class="ttname"><a href="classodf_1_1odf2xhtml_1_1ODF2XHTML.html#ab06ecdbc49f7f31d3c5274cb612af4e6">odf.odf2xhtml.ODF2XHTML.elements</a></div><div class="ttdeci">elements</div><div class="ttdef"><b>Definition:</b> <a href="odf2xhtml_8py_source.html#l00367">odf2xhtml.py:367</a></div></div> <div class="ttc" id="classodf_1_1odf2xhtml_1_1ODF2XHTML_html_ae998099d573b26bb4e129bce3cde4748"><div class="ttname"><a href="classodf_1_1odf2xhtml_1_1ODF2XHTML.html#ae998099d573b26bb4e129bce3cde4748">odf.odf2xhtml.ODF2XHTML.anchors</a></div><div class="ttdeci">anchors</div><div class="ttdef"><b>Definition:</b> <a href="odf2xhtml_8py_source.html#l00516">odf2xhtml.py:516</a></div></div> <div class="ttc" id="classodf_1_1odf2xhtml_1_1ODF2XHTML_html_a38926f04d56ba25c622d0fbc821f5762"><div class="ttname"><a href="classodf_1_1odf2xhtml_1_1ODF2XHTML.html#a38926f04d56ba25c622d0fbc821f5762">odf.odf2xhtml.ODF2XHTML.s_text_list</a></div><div class="ttdeci">def s_text_list(self, tag, attrs)</div><div class="ttdoc">Start a list (. </div><div class="ttdef"><b>Definition:</b> <a href="odf2xhtml_8py_source.html#l01290">odf2xhtml.py:1290</a></div></div> <div class="ttc" id="classodf_1_1odf2xhtml_1_1ODF2XHTML_html_a9b42d7db6915a547338e4ef96b894d78"><div class="ttname"><a href="classodf_1_1odf2xhtml_1_1ODF2XHTML.html#a9b42d7db6915a547338e4ef96b894d78">odf.odf2xhtml.ODF2XHTML.s_text_note_body</a></div><div class="ttdeci">def s_text_note_body(self, tag, attrs)</div><div class="ttdef"><b>Definition:</b> <a href="odf2xhtml_8py_source.html#l01396">odf2xhtml.py:1396</a></div></div> <div class="ttc" id="classodf_1_1odf2xhtml_1_1StyleToCSS_html"><div class="ttname"><a href="classodf_1_1odf2xhtml_1_1StyleToCSS.html">odf.odf2xhtml.StyleToCSS</a></div><div class="ttdoc">The purpose of the StyleToCSS class is to contain the rules to convert ODF styles to CSS2...</div><div class="ttdef"><b>Definition:</b> <a href="odf2xhtml_8py_source.html#l00062">odf2xhtml.py:62</a></div></div> <div class="ttc" id="classodf_1_1odf2xhtml_1_1StyleToCSS_html_a4ac381627dbde14af01d753ff931a2f9"><div class="ttname"><a href="classodf_1_1odf2xhtml_1_1StyleToCSS.html#a4ac381627dbde14af01d753ff931a2f9">odf.odf2xhtml.StyleToCSS.convert_styles</a></div><div class="ttdeci">def convert_styles(self, ruleset)</div><div class="ttdoc">Rule is a tuple of (namespace, name). </div><div class="ttdef"><b>Definition:</b> <a href="odf2xhtml_8py_source.html#l00281">odf2xhtml.py:281</a></div></div> <div class="ttc" id="classodf_1_1odf2xhtml_1_1ODF2XHTML_html_af4aae69d4d252e3b2f42a6e6eb28ba69"><div class="ttname"><a href="classodf_1_1odf2xhtml_1_1ODF2XHTML.html#af4aae69d4d252e3b2f42a6e6eb28ba69">odf.odf2xhtml.ODF2XHTML.closetag</a></div><div class="ttdeci">def closetag</div><div class="ttdoc">Close an open HTML tag. </div><div class="ttdef"><b>Definition:</b> <a href="odf2xhtml_8py_source.html#l00554">odf2xhtml.py:554</a></div></div> <div class="ttc" id="classodf_1_1odf2xhtml_1_1ODF2XHTML_html_ab4e4c31b772b8e9d99e1a3119aaa3156"><div class="ttname"><a href="classodf_1_1odf2xhtml_1_1ODF2XHTML.html#ab4e4c31b772b8e9d99e1a3119aaa3156">odf.odf2xhtml.ODF2XHTML.currentnote</a></div><div class="ttdeci">currentnote</div><div class="ttdef"><b>Definition:</b> <a href="odf2xhtml_8py_source.html#l00496">odf2xhtml.py:496</a></div></div> <div class="ttc" id="classodf_1_1odf2xhtml_1_1ODF2XHTML_html_a0cae25d275a13956bbc2ad42e9ba56d3"><div class="ttname"><a href="classodf_1_1odf2xhtml_1_1ODF2XHTML.html#a0cae25d275a13956bbc2ad42e9ba56d3">odf.odf2xhtml.ODF2XHTML.generate_footnotes</a></div><div class="ttdeci">def generate_footnotes(self)</div><div class="ttdef"><b>Definition:</b> <a href="odf2xhtml_8py_source.html#l00889">odf2xhtml.py:889</a></div></div> <div class="ttc" id="classodf_1_1odf2xhtml_1_1ODF2XHTML_html_aa107d184668b5cd1173e177be166130e"><div class="ttname"><a href="classodf_1_1odf2xhtml_1_1ODF2XHTML.html#aa107d184668b5cd1173e177be166130e">odf.odf2xhtml.ODF2XHTML._wfunc</a></div><div class="ttdeci">_wfunc</div><div class="ttdef"><b>Definition:</b> <a href="odf2xhtml_8py_source.html#l00501">odf2xhtml.py:501</a></div></div> <div class="ttc" id="classodf_1_1odf2xhtml_1_1StyleToCSS_html_afb1e7cabd9d76c265e3d847887138bda"><div class="ttname"><a href="classodf_1_1odf2xhtml_1_1StyleToCSS.html#afb1e7cabd9d76c265e3d847887138bda">odf.odf2xhtml.StyleToCSS.c_drawfillimage</a></div><div class="ttdeci">def c_drawfillimage(self, ruleset, sdict, rule, val)</div><div class="ttdoc">Fill a figure with an image. </div><div class="ttdef"><b>Definition:</b> <a href="odf2xhtml_8py_source.html#l00135">odf2xhtml.py:135</a></div></div> <div class="ttc" id="classodf_1_1odf2xhtml_1_1ODF2XHTML_html_a2ef3076783a20cbed2547a0e7d988d51"><div class="ttname"><a href="classodf_1_1odf2xhtml_1_1ODF2XHTML.html#a2ef3076783a20cbed2547a0e7d988d51">odf.odf2xhtml.ODF2XHTML.s_text_a</a></div><div class="ttdeci">def s_text_a(self, tag, attrs)</div><div class="ttdoc">Anchors start. </div><div class="ttdef"><b>Definition:</b> <a href="odf2xhtml_8py_source.html#l01207">odf2xhtml.py:1207</a></div></div> <div class="ttc" id="classodf_1_1odf2xhtml_1_1ODF2XHTML_html_a3c90426fc6573629c0266fdde9c19cbf"><div class="ttname"><a href="classodf_1_1odf2xhtml_1_1ODF2XHTML.html#a3c90426fc6573629c0266fdde9c19cbf">odf.odf2xhtml.ODF2XHTML.e_office_presentation</a></div><div class="ttdeci">def e_office_presentation(self, tag, attrs)</div><div class="ttdef"><b>Definition:</b> <a href="odf2xhtml_8py_source.html#l00944">odf2xhtml.py:944</a></div></div> <div class="ttc" id="classodf_1_1odf2xhtml_1_1ODF2XHTML_html_a1abe4593b126677407c0be26ff4053fa"><div class="ttname"><a href="classodf_1_1odf2xhtml_1_1ODF2XHTML.html#a1abe4593b126677407c0be26ff4053fa">odf.odf2xhtml.ODF2XHTML.writeout</a></div><div class="ttdeci">def writeout(self, s)</div><div class="ttdef"><b>Definition:</b> <a href="odf2xhtml_8py_source.html#l00529">odf2xhtml.py:529</a></div></div> <div class="ttc" id="classodf_1_1odf2xhtml_1_1ODF2XHTML_html_a41f6359597e45b7219253a8bf3efcc75"><div class="ttname"><a href="classodf_1_1odf2xhtml_1_1ODF2XHTML.html#a41f6359597e45b7219253a8bf3efcc75">odf.odf2xhtml.ODF2XHTML.e_style_footer</a></div><div class="ttdeci">def e_style_footer(self, tag, attrs)</div><div class="ttdef"><b>Definition:</b> <a href="odf2xhtml_8py_source.html#l01012">odf2xhtml.py:1012</a></div></div> <div class="ttc" id="classodf_1_1odf2xhtml_1_1ODF2XHTML_html_aa80bac485bb33794aae78122b578589e"><div class="ttname"><a href="classodf_1_1odf2xhtml_1_1ODF2XHTML.html#aa80bac485bb33794aae78122b578589e">odf.odf2xhtml.ODF2XHTML.e_dc_creator</a></div><div class="ttdeci">def e_dc_creator(self, tag, attrs)</div><div class="ttdoc">Set the content creator. </div><div class="ttdef"><b>Definition:</b> <a href="odf2xhtml_8py_source.html#l00674">odf2xhtml.py:674</a></div></div> <div class="ttc" id="classodf_1_1odf2xhtml_1_1ODF2XHTML_html_a681650dd9dc523d264529baa9e3490b2"><div class="ttname"><a href="classodf_1_1odf2xhtml_1_1ODF2XHTML.html#a681650dd9dc523d264529baa9e3490b2">odf.odf2xhtml.ODF2XHTML.s_style_font_face</a></div><div class="ttdeci">def s_style_font_face(self, tag, attrs)</div><div class="ttdoc">It is possible that the HTML browser doesn't know how to show a particular font. </div><div class="ttdef"><b>Definition:</b> <a href="odf2xhtml_8py_source.html#l01002">odf2xhtml.py:1002</a></div></div> <div class="ttc" id="classodf_1_1odf2xhtml_1_1ODF2XHTML_html_a3cffe38f14e08fd6dd0605caee6b20a2"><div class="ttname"><a href="classodf_1_1odf2xhtml_1_1ODF2XHTML.html#a3cffe38f14e08fd6dd0605caee6b20a2">odf.odf2xhtml.ODF2XHTML.use_internal_css</a></div><div class="ttdeci">use_internal_css</div><div class="ttdef"><b>Definition:</b> <a href="odf2xhtml_8py_source.html#l00486">odf2xhtml.py:486</a></div></div> <div class="ttc" id="classodf_1_1odf2xhtml_1_1ODF2XHTML_html_a3c10cb23e159b1cbc14fb11ce3b1d51c"><div class="ttname"><a href="classodf_1_1odf2xhtml_1_1ODF2XHTML.html#a3c10cb23e159b1cbc14fb11ce3b1d51c">odf.odf2xhtml.ODF2XHTML.e_table_table_row</a></div><div class="ttdeci">def e_table_table_row(self, tag, attrs)</div><div class="ttdoc">End a table row. </div><div class="ttdef"><b>Definition:</b> <a href="odf2xhtml_8py_source.html#l01200">odf2xhtml.py:1200</a></div></div> <div class="ttc" id="classodf_1_1odf2xhtml_1_1ODF2XHTML_html_a38dee6c7819852bd6678cf0be92fa698"><div class="ttname"><a href="classodf_1_1odf2xhtml_1_1ODF2XHTML.html#a38dee6c7819852bd6678cf0be92fa698">odf.odf2xhtml.ODF2XHTML.e_table_table</a></div><div class="ttdeci">def e_table_table(self, tag, attrs)</div><div class="ttdoc">End a table. </div><div class="ttdef"><b>Definition:</b> <a href="odf2xhtml_8py_source.html#l01144">odf2xhtml.py:1144</a></div></div> <div class="ttc" id="classodf_1_1odf2xhtml_1_1TagStack_html_a1a5628b935216a5f00b52543434412ac"><div class="ttname"><a href="classodf_1_1odf2xhtml_1_1TagStack.html#a1a5628b935216a5f00b52543434412ac">odf.odf2xhtml.TagStack.count_tags</a></div><div class="ttdeci">def count_tags(self, tag)</div><div class="ttdef"><b>Definition:</b> <a href="odf2xhtml_8py_source.html#l00326">odf2xhtml.py:326</a></div></div> <div class="ttc" id="classodf_1_1odf2xhtml_1_1StyleToCSS_html_af00a8103559ec67c4bfabbb67c5458a6"><div class="ttname"><a href="classodf_1_1odf2xhtml_1_1StyleToCSS.html#af00a8103559ec67c4bfabbb67c5458a6">odf.odf2xhtml.StyleToCSS.c_text_line_through_style</a></div><div class="ttdeci">def c_text_line_through_style(self, ruleset, sdict, rule, val)</div><div class="ttdoc">Set underline decoration HTML doesn't really have a page-width. </div><div class="ttdef"><b>Definition:</b> <a href="odf2xhtml_8py_source.html#l00268">odf2xhtml.py:268</a></div></div> <div class="ttc" id="classodf_1_1odf2xhtml_1_1ODF2XHTML_html_a1a08651583c88100ecd5273381757370"><div class="ttname"><a href="classodf_1_1odf2xhtml_1_1ODF2XHTML.html#a1a08651583c88100ecd5273381757370">odf.odf2xhtml.ODF2XHTML.s_style_footer_style</a></div><div class="ttdeci">def s_style_footer_style(self, tag, attrs)</div><div class="ttdef"><b>Definition:</b> <a href="odf2xhtml_8py_source.html#l01017">odf2xhtml.py:1017</a></div></div> <div class="ttc" id="classodf_1_1odf2xhtml_1_1StyleToCSS_html_a05dbfba1c85f51b8b82c5caf87985649"><div class="ttname"><a href="classodf_1_1odf2xhtml_1_1StyleToCSS.html#a05dbfba1c85f51b8b82c5caf87985649">odf.odf2xhtml.StyleToCSS.c_page_width</a></div><div class="ttdeci">def c_page_width(self, ruleset, sdict, rule, val)</div><div class="ttdoc">Set width of box HTML doesn't really have a page-width. </div><div class="ttdef"><b>Definition:</b> <a href="odf2xhtml_8py_source.html#l00253">odf2xhtml.py:253</a></div></div> <div class="ttc" id="classodf_1_1odf2xhtml_1_1StyleToCSS_html_a71e60d11ff4d263e9de6c07da7fc32d9"><div class="ttname"><a href="classodf_1_1odf2xhtml_1_1StyleToCSS.html#a71e60d11ff4d263e9de6c07da7fc32d9">odf.odf2xhtml.StyleToCSS.c_page_height</a></div><div class="ttdeci">def c_page_height(self, ruleset, sdict, rule, val)</div><div class="ttdoc">Set height of box. </div><div class="ttdef"><b>Definition:</b> <a href="odf2xhtml_8py_source.html#l00274">odf2xhtml.py:274</a></div></div> <div class="ttc" id="classodf_1_1odf2xhtml_1_1ODF2XHTML_html_a00f38e3c4dd443e1ca3a48703230edf5"><div class="ttname"><a href="classodf_1_1odf2xhtml_1_1ODF2XHTML.html#a00f38e3c4dd443e1ca3a48703230edf5">odf.odf2xhtml.ODF2XHTML._resetobject</a></div><div class="ttdeci">def _resetobject(self)</div><div class="ttdef"><b>Definition:</b> <a href="odf2xhtml_8py_source.html#l00499">odf2xhtml.py:499</a></div></div> <div class="ttc" id="classodf_1_1odf2xhtml_1_1ODF2XHTML_html_aaf69b4d6d5bbd31b1bdf4df42f27fe51"><div class="ttname"><a href="classodf_1_1odf2xhtml_1_1ODF2XHTML.html#aaf69b4d6d5bbd31b1bdf4df42f27fe51">odf.odf2xhtml.ODF2XHTML.s_draw_frame</a></div><div class="ttdeci">def s_draw_frame(self, tag, attrs)</div><div class="ttdoc">A <draw:frame> is made into a in HTML which is then styled. </div><div class="ttdef"><b>Definition:</b> <a href="odf2xhtml_8py_source.html#l00720">odf2xhtml.py:720</a></div></div> <div class="ttc" id="classodf_1_1odf2xhtml_1_1TagStack_html_a8e173b7258ce327fad05f07863afbb50"><div class="ttname"><a href="classodf_1_1odf2xhtml_1_1TagStack.html#a8e173b7258ce327fad05f07863afbb50">odf.odf2xhtml.TagStack.pop</a></div><div class="ttdeci">def pop(self)</div><div class="ttdef"><b>Definition:</b> <a href="odf2xhtml_8py_source.html#l00311">odf2xhtml.py:311</a></div></div> <div class="ttc" id="classodf_1_1odf2xhtml_1_1ODF2XHTML_html_a85e130159e737c6701776a52a5adf17a"><div class="ttname"><a href="classodf_1_1odf2xhtml_1_1ODF2XHTML.html#a85e130159e737c6701776a52a5adf17a">odf.odf2xhtml.ODF2XHTML.s_office_document_content</a></div><div class="ttdeci">def s_office_document_content(self, tag, attrs)</div><div class="ttdoc">First tag in the content.xml file. </div><div class="ttdef"><b>Definition:</b> <a href="odf2xhtml_8py_source.html#l00915">odf2xhtml.py:915</a></div></div> <div class="ttc" id="classodf_1_1odf2xhtml_1_1StyleToCSS_html_ae9d6e5ee6f3db9405e4df6c6ed6e5d8c"><div class="ttname"><a href="classodf_1_1odf2xhtml_1_1StyleToCSS.html#ae9d6e5ee6f3db9405e4df6c6ed6e5d8c">odf.odf2xhtml.StyleToCSS.c_text_position</a></div><div class="ttdeci">def c_text_position(self, ruleset, sdict, rule, tp)</div><div class="ttdoc">Text position. </div><div class="ttdef"><b>Definition:</b> <a href="odf2xhtml_8py_source.html#l00195">odf2xhtml.py:195</a></div></div> <div class="ttc" id="classodf_1_1odf2xhtml_1_1ODF2XHTML_html_ad7c0d41a99db32946e9dc48c323ff544"><div class="ttname"><a href="classodf_1_1odf2xhtml_1_1ODF2XHTML.html#ad7c0d41a99db32946e9dc48c323ff544">odf.odf2xhtml.ODF2XHTML.add_style_file</a></div><div class="ttdeci">def add_style_file</div><div class="ttdoc">Add a link to an external style file. </div><div class="ttdef"><b>Definition:</b> <a href="odf2xhtml_8py_source.html#l00485">odf2xhtml.py:485</a></div></div> <div class="ttc" id="classodf_1_1odf2xhtml_1_1ODF2XHTML_html_a982a04827cdc62e08e0eef40b5436cc9"><div class="ttname"><a href="classodf_1_1odf2xhtml_1_1ODF2XHTML.html#a982a04827cdc62e08e0eef40b5436cc9">odf.odf2xhtml.ODF2XHTML.tagstack</a></div><div class="ttdeci">tagstack</div><div class="ttdef"><b>Definition:</b> <a href="odf2xhtml_8py_source.html#l00507">odf2xhtml.py:507</a></div></div> <div class="ttc" id="classodf_1_1odf2xhtml_1_1ODF2XHTML_html_a2c49e30dd5748171bcb695393989191f"><div class="ttname"><a href="classodf_1_1odf2xhtml_1_1ODF2XHTML.html#a2c49e30dd5748171bcb695393989191f">odf.odf2xhtml.ODF2XHTML.processelem</a></div><div class="ttdeci">processelem</div><div class="ttdef"><b>Definition:</b> <a href="odf2xhtml_8py_source.html#l00510">odf2xhtml.py:510</a></div></div> <div class="ttc" id="classodf_1_1odf2xhtml_1_1ODF2XHTML_html_a2f8c87e7db56e9dc90b02c5d36fcfd06"><div class="ttname"><a href="classodf_1_1odf2xhtml_1_1ODF2XHTML.html#a2f8c87e7db56e9dc90b02c5d36fcfd06">odf.odf2xhtml.ODF2XHTML.e_style_header</a></div><div class="ttdeci">def e_style_header(self, tag, attrs)</div><div class="ttdef"><b>Definition:</b> <a href="odf2xhtml_8py_source.html#l01026">odf2xhtml.py:1026</a></div></div> </div><!-- fragment --></div><!-- contents --> </div><!-- doc-content --> <!-- start footer part --> <div id="nav-path" class="navpath"><!-- id is needed for treeview function! --> <ul> <li class="navelem"><a class="el" href="dir_d3e4a566b869afb68c42af9b8e3a2d5a.html">odf</a></li><li class="navelem"><a class="el" href="odf2xhtml_8py.html">odf2xhtml.py</a></li> <li class="footer">Generated by <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.9.1 </li> </ul> </div> </body> </html>