25sys.path.append(os.path.dirname(__file__))
26from xml.sax
import handler
27from xml.sax.saxutils
import escape, quoteattr
30from opendocument
import load
32from odf.namespaces import ANIMNS, CHARTNS, CONFIGNS, DCNS, DR3DNS, DRAWNS, FONS, \
33 FORMNS, MATHNS, METANS, NUMBERNS, OFFICENS, PRESENTATIONNS, SCRIPTNS, \
34 SMILNS, STYLENS, SVGNS, TABLENS, TEXTNS, XLINKNS
72 (FONS,
u"background-color"): self.
c_fo,
73 (FONS,
u"border"): self.
c_fo,
74 (FONS,
u"border-bottom"): self.
c_fo,
75 (FONS,
u"border-left"): self.
c_fo,
76 (FONS,
u"border-right"): self.
c_fo,
77 (FONS,
u"border-top"): self.
c_fo,
78 (FONS,
u"color"): self.
c_fo,
79 (FONS,
u"font-family"): self.
c_fo,
80 (FONS,
u"font-size"): self.
c_fo,
81 (FONS,
u"font-style"): self.
c_fo,
82 (FONS,
u"font-variant"): self.
c_fo,
83 (FONS,
u"font-weight"): self.
c_fo,
84 (FONS,
u"line-height"): self.
c_fo,
85 (FONS,
u"margin"): self.
c_fo,
86 (FONS,
u"margin-bottom"): self.
c_fo,
87 (FONS,
u"margin-left"): self.
c_fo,
88 (FONS,
u"margin-right"): self.
c_fo,
89 (FONS,
u"margin-top"): self.
c_fo,
90 (FONS,
u"min-height"): self.
c_fo,
91 (FONS,
u"padding"): self.
c_fo,
92 (FONS,
u"padding-bottom"): self.
c_fo,
93 (FONS,
u"padding-left"): self.
c_fo,
94 (FONS,
u"padding-right"): self.
c_fo,
95 (FONS,
u"padding-top"): self.
c_fo,
99 (FONS,
u"text-indent") :self.
c_fo,
101 (STYLENS,
u'column-width') : self.
c_width,
102 (STYLENS,
u"font-name"): self.
c_fn,
103 (STYLENS,
u'horizontal-pos'): self.
c_hp,
107 (STYLENS,
u'width') : self.
c_width,
119 htmlgeneric =
"sans-serif"
120 if generic ==
"roman": htmlgeneric =
"serif"
121 elif generic ==
"swiss": htmlgeneric =
"sans-serif"
122 elif generic ==
"modern": htmlgeneric =
"monospace"
123 elif generic ==
"decorative": htmlgeneric =
"sans-serif"
124 elif generic ==
"script": htmlgeneric =
"monospace"
125 elif generic ==
"system": htmlgeneric =
"serif"
126 self.
fontdict[name] = (family, htmlgeneric)
133 sdict[
'background-image'] =
"url('%s')" % self.
fillimages[val]
136 def c_fo(self, ruleset, sdict, rule, val):
138 sdict[selector] = val
142 if val ==
'collapsing':
143 sdict[
'border-collapse'] =
'collapse'
145 sdict[
'border-collapse'] =
'separate'
153 if align ==
"start": align =
"left"
154 if align ==
"end": align =
"right"
155 sdict[
'text-align'] = align
161 def c_fn(self, ruleset, sdict, rule, fontstyle):
162 generic = ruleset.get((STYLENS,
'font-family-generic') )
163 if generic
is not None:
164 self.
save_font(fontstyle, fontstyle, generic)
165 family, htmlgeneric = self.
fontdict.get(fontstyle, (fontstyle,
'serif'))
166 sdict[
'font-family'] =
'%s, %s' % (family, htmlgeneric)
187 textpos = tp.split(
' ')
188 if len(textpos) == 2
and textpos[0] !=
"0%":
190 sdict[
'font-size'] = textpos[1]
191 if textpos[0] ==
"super":
192 sdict[
'vertical-align'] =
"33%"
193 elif textpos[0] ==
"sub":
194 sdict[
'vertical-align'] =
"-33%"
196 sdict[
'vertical-align'] = textpos[0]
198 def c_hp(self, ruleset, sdict, rule, hpos):
202 wrap = ruleset.get((STYLENS,
'wrap'),
'parallel')
205 sdict[
'margin-left'] =
"auto"
206 sdict[
'margin-right'] =
"auto"
212 if hpos
in (
"right",
"outside"):
213 if wrap
in (
"left",
"parallel",
"dynamic"):
214 sdict[
'float'] =
"right"
215 elif wrap ==
"run-through":
216 sdict[
'position'] =
"absolute"
218 sdict[
'right'] =
"0";
220 sdict[
'margin-left'] =
"auto"
221 sdict[
'margin-right'] =
"0cm"
222 elif hpos
in (
"left",
"inside"):
223 if wrap
in (
"right",
"parallel",
"dynamic"):
224 sdict[
'float'] =
"left"
225 elif wrap ==
"run-through":
226 sdict[
'position'] =
"absolute"
230 sdict[
'margin-left'] =
"0cm"
231 sdict[
'margin-right'] =
"auto"
232 elif hpos
in (
"from-left",
"from-inside"):
233 if wrap
in (
"right",
"parallel"):
234 sdict[
'float'] =
"left"
236 sdict[
'position'] =
"relative"
237 if (SVGNS,
'x')
in ruleset:
238 sdict[
'left'] = ruleset[(SVGNS,
'x')]
250 if val
and val !=
"none":
251 sdict[
'text-decoration'] =
"underline"
257 if val
and val !=
"none":
258 sdict[
'text-decoration'] =
"line-through"
262 sdict[
'height'] = val
270 for rule,val
in ruleset.items():
276 procedures.append([method, ruleset, sdict, rule, val])
280 for p
in filter(
lambda x: x[0] != self.
c_hp, procedures):
281 method, ruleset, sdict, rule, val = p
282 method(ruleset, sdict, rule, val)
283 for p
in filter(
lambda x: x[0] == self.
c_hp, procedures):
284 method, ruleset, sdict, rule, val = p
285 method(ruleset, sdict, rule, val)
314 if ttag == tag: c = c + 1
320 'S-Strong_20_Emphasis':
'strong',
322 'S-Definition':
'dfn',
324 'P-Heading_20_1':
'h1',
325 'P-Heading_20_2':
'h2',
326 'P-Heading_20_3':
'h3',
327 'P-Heading_20_4':
'h4',
328 'P-Heading_20_5':
'h5',
329 'P-Heading_20_6':
'h6',
331 'P-Addressee':
'address',
334 'P-Preformatted_20_Text':
'pre',
348 def __init__(self, generate_css=True, embedable=False):
370 (NUMBERNS,
"boolean-style"):(self.
s_ignorexml,
None),
371 (NUMBERNS,
"currency-style"):(self.
s_ignorexml,
None),
373 (NUMBERNS,
"number-style"):(self.
s_ignorexml,
None),
388 (PRESENTATIONNS,
"notes"):(self.
s_ignorexml,
None),
390 (STYLENS,
"default-page-layout"):(self.
s_ignorexml,
None),
397 (STYLENS,
"handout-master"):(self.
s_ignorexml,
None),
412 (TABLENS,
'covered-table-cell'): (self.
s_ignorexml,
None),
419 (TEXTNS,
"bibliography-configuration"):(self.
s_ignorexml,
None),
428 (TEXTNS,
"linenumbering-configuration"):(self.
s_ignorexml,
None),
433 (TEXTNS,
"list-style"):(
None,
None),
437 (TEXTNS,
"notes-configuration"):(self.
s_ignorexml,
None),
440 (TEXTNS,
's'): (self.
s_text_s,
None),
457 self.
elements[(OFFICENS,
u"text")] = (
None,
None)
458 self.
elements[(OFFICENS,
u"spreadsheet")] = (
None,
None)
459 self.
elements[(OFFICENS,
u"presentation")] = (
None,
None)
460 self.
elements[(OFFICENS,
u"document-content")] = (
None,
None)
470 self.
metatags.append(
'<link rel="stylesheet" type="text/css" href="%s" media="%s"/>\n' % (stylefilename,media))
472 self.
metatags.append(
'<link rel="stylesheet" type="text/css" href="%s"/>\n' % (stylefilename))
494 self.
headinglevels = [0, 0,0,0,0,0, 0,0,0,0,0]
515 d =
''.join(self.
data)
520 def opentag(self, tag, attrs={}, block=False):
523 for key,val
in attrs.items():
524 a.append(
'''%s=%s''' % (key, quoteattr(val)))
528 self.
writeout(
"<%s %s>" % (tag,
" ".join(a)))
541 for key,val
in attrs.items():
542 a.append(
'''%s=%s''' % (key, quoteattr(val)))
543 self.
writeout(
"<%s %s/>\n" % (tag,
" ".join(a)))
550 self.
data.append(data)
555 method = self.
elements.get(tag, (
None,
None) )[0]
565 method = self.
elements.get(tag, (
None,
None) )[1]
601 c = attrs.get((TEXTNS,
'style-name'),
'')
602 c = c.replace(
".",
"_")
632 self.
metatags.append(
'<meta name="%s" content=%s/>\n' % (tag[1], quoteattr(
''.join(self.
data))))
639 self.
metatags.append(
'<meta http-equiv="content-language" content="%s"/>\n' % escape(self.
language))
646 self.
metatags.append(
'<meta http-equiv="creator" content="%s"/>\n' % escape(self.
creator))
652 anchor_type = attrs.get((TEXTNS,
'anchor-type'),
'notfound')
654 name =
"G-" + attrs.get( (DRAWNS,
'style-name'),
"")
656 name =
"PR-" + attrs.get( (PRESENTATIONNS,
'style-name'),
"")
657 name = name.replace(
".",
"_")
658 if anchor_type ==
"paragraph":
659 style =
'position:absolute;'
660 elif anchor_type ==
'char':
661 style =
"position:absolute;"
662 elif anchor_type ==
'as-char':
666 style =
"position: absolute;"
667 if (SVGNS,
"width")
in attrs:
668 style = style +
"width:" + attrs[(SVGNS,
"width")] +
";"
669 if (SVGNS,
"height")
in attrs:
670 style = style +
"height:" + attrs[(SVGNS,
"height")] +
";"
671 if (SVGNS,
"x")
in attrs:
672 style = style +
"left:" + attrs[(SVGNS,
"x")] +
";"
673 if (SVGNS,
"y")
in attrs:
674 style = style +
"top:" + attrs[(SVGNS,
"y")] +
";"
676 self.
opentag(htmltag, {
'class': name,
'style': style})
688 anchor_type = attrs.get((TEXTNS,
'anchor-type'),
'notfound')
690 name =
"G-" + attrs.get( (DRAWNS,
'style-name'),
"")
692 name =
"PR-" + attrs.get( (PRESENTATIONNS,
'style-name'),
"")
693 name = name.replace(
".",
"_")
694 if anchor_type ==
"paragraph":
695 style =
'position:relative;'
696 elif anchor_type ==
'char':
697 style =
"position:relative;"
698 elif anchor_type ==
'as-char':
702 style =
"position:absolute;"
703 if (SVGNS,
"width")
in attrs:
704 style = style +
"width:" + attrs[(SVGNS,
"width")] +
";"
705 if (SVGNS,
"height")
in attrs:
706 style = style +
"height:" + attrs[(SVGNS,
"height")] +
";"
707 if (SVGNS,
"x")
in attrs:
708 style = style +
"left:" + attrs[(SVGNS,
"x")] +
";"
709 if (SVGNS,
"y")
in attrs:
710 style = style +
"top:" + attrs[(SVGNS,
"y")] +
";"
712 self.
opentag(htmltag, {
'class': name,
'style': style})
722 name = attrs.get( (DRAWNS,
'name'),
"NoName")
723 imghref = attrs[(XLINKNS,
"href")]
725 self.
cs.fillimages[name] = imghref
736 parent = self.
tagstack.stackparent()
737 anchor_type = parent.get((TEXTNS,
'anchor-type'))
738 imghref = attrs[(XLINKNS,
"href")]
740 htmlattrs = {
'alt':
"",
'src':imghref }
742 if anchor_type !=
"char":
743 htmlattrs[
'style'] =
"display: block;"
749 objhref = attrs[(XLINKNS,
"href")]
759 for c
in self.
document.childobjects:
760 if c.folder == objhref:
766 class_id = attrs[(DRAWNS,
"class-id")]
767 if class_id
and class_id.lower() ==
"00020803-0000-0000-c000-000000000046":
768 tagattrs = {
'name':
'object_ole_graph',
'class':
'ole-graph' }
777 name = attrs.get( (DRAWNS,
'name'),
"NoName")
778 stylename = attrs.get( (DRAWNS,
'style-name'),
"")
779 stylename = stylename.replace(
".",
"_")
780 masterpage = attrs.get( (DRAWNS,
'master-page-name'),
"")
781 masterpage = masterpage.replace(
".",
"_")
783 self.
opentag(
'fieldset', {
'class':
"DP-%s MP-%s" % (stylename, masterpage) })
795 if (FONS,
"min-height")
in attrs:
796 style = style +
"min-height:" + attrs[(FONS,
"min-height")] +
";"
808 self.
opentag(
'style', {
'type':
"text/css"},
True)
815 self.
opentag(
'body', block=
True)
818img { width: 100%; height: 100%; }
819* { padding: 0; margin: 0; background-color:white; }
820body { margin: 0 1em; }
821ol, ul { padding-left: 2em; }
828 if '__style-family'in styles
and styles[
'__style-family']
in self.
styledict:
829 familystyle = self.
styledict[styles[
'__style-family']].copy()
830 del styles[
'__style-family']
831 for style, val
in styles.items():
832 familystyle[style] = val
835 while '__parent-style-name' in styles
and styles[
'__parent-style-name']
in self.
styledict:
836 parentstyle = self.
styledict[styles[
'__parent-style-name']].copy()
837 del styles[
'__parent-style-name']
838 for style, val
in styles.items():
839 parentstyle[style] = val
846 css2 = self.
cs.convert_styles(styles)
848 for style, val
in css2.items():
849 self.
writeout(
"\t%s: %s;\n" % (style, val) )
856 self.
opentag(
'ol', {
'style':
'border-top: 1px solid black'},
True)
862 self.
opentag(
'li', {
'id':
"footnote-%d" % key })
871 if self.
xmlfile ==
'styles.xml':
878 self.
writeout(
'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" ')
879 self.
writeout(
'"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">\n')
880 self.
opentag(
'html', {
'xmlns':
"http://www.w3.org/1999/xhtml"},
True)
881 self.
opentag(
'head', block=
True)
882 self.
emptytag(
'meta', {
'http-equiv':
"Content-Type",
'content':
"text/html;charset=UTF-8"})
899 self.
styledict[
'p'] = {(FONS,
u'font-size'):
u"24pt" }
900 self.
styledict[
'presentation'] = {(FONS,
u'font-size'):
u"24pt" }
919 self.
styledict[
'frame'] = { (STYLENS,
'wrap'):
u'parallel'}
930 for key,attr
in attrs.items():
934 familymap = {
'frame':
'frame',
'paragraph':
'p',
'presentation':
'presentation',
935 'text':
'span',
'section':
'div',
936 'table':
'table',
'table-cell':
'td',
'table-column':
'col',
937 'table-row':
'tr',
'graphic':
'graphic' }
942 family = attrs[(STYLENS,
'family')]
943 htmlfamily = self.
familymap.get(family,
'unknown')
958 name = attrs[(STYLENS,
"name")]
959 family = attrs[(SVGNS,
"font-family")]
960 generic = attrs.get( (STYLENS,
'font-family-generic'),
"" )
961 self.
cs.save_font(name, family, generic)
964 self.
opentag(
'div', {
'id':
"footer" })
978 self.
opentag(
'div', {
'id':
"header" })
1003 name = attrs[(STYLENS,
'name')]
1004 name = name.replace(
".",
"_")
1017 name = attrs[(STYLENS,
'name')]
1018 name = name.replace(
".",
"_")
1024 pagelayout = attrs.get( (STYLENS,
'page-layout-name'),
None)
1026 pagelayout =
".PL-" + pagelayout
1029 for style, val
in styles.items():
1039 _familyshort = {
'drawing-page':
'DP',
'paragraph':
'P',
'presentation':
'PR',
1040 'text':
'S',
'section':
'D',
1041 'table':
'T',
'table-cell':
'TD',
'table-column':
'TC',
1042 'table-row':
'TR',
'graphic':
'G' }
1051 name = attrs[(STYLENS,
'name')]
1052 name = name.replace(
".",
"_")
1053 family = attrs[(STYLENS,
'family')]
1054 htmlfamily = self.
familymap.get(family,
'unknown')
1056 name =
"%s%s-%s" % (self.
autoprefix, sfamily, name)
1057 parent = attrs.get( (STYLENS,
'parent-style-name') )
1067 parent =
"%s-%s" % (sfamily, parent)
1068 parent = special_styles.get(parent,
"."+parent)
1071 for style, val
in styles.items():
1084 c = attrs.get( (TABLENS,
'style-name'),
None)
1086 c = c.replace(
".",
"_")
1087 self.
opentag(
'table',{
'class':
"T-%s" % c })
1104 rowspan = attrs.get( (TABLENS,
'number-rows-spanned') )
1106 htmlattrs[
'rowspan'] = rowspan
1107 colspan = attrs.get( (TABLENS,
'number-columns-spanned') )
1109 htmlattrs[
'colspan'] = colspan
1111 c = attrs.get( (TABLENS,
'style-name') )
1113 htmlattrs[
'class'] =
'TD-%s' % c.replace(
".",
"_")
1125 c = attrs.get( (TABLENS,
'style-name'),
None)
1126 repeated = int(attrs.get( (TABLENS,
'number-columns-repeated'), 1))
1129 htmlattrs[
'class'] =
"TC-%s" % c.replace(
".",
"_")
1130 for x
in range(repeated):
1137 c = attrs.get( (TABLENS,
'style-name'),
None)
1140 htmlattrs[
'class'] =
"TR-%s" % c.replace(
".",
"_")
1153 href = attrs[(XLINKNS,
"href")].split(
"|")[0]
1156 self.
opentag(
'a', {
'href':href})
1167 name = attrs[(TEXTNS,
'name')]
1170 self.
opentag(
'span', {
'id':html_id})
1176 name = attrs[(TEXTNS,
'ref-name')]
1179 self.
opentag(
'a', {
'href':html_id})
1184 level = int(attrs[(TEXTNS,
'outline-level')])
1185 if level > 6: level = 6
1186 if level < 1: level = 1
1189 for x
in range(level + 1,10):
1191 special = special_styles.get(
"P-"+name)
1195 self.
opentag(
'h%s' % level, {
'class':
"P-%s" % name })
1204 level = int(attrs[(TEXTNS,
'outline-level')])
1205 if level > 6: level = 6
1206 if level < 1: level = 1
1208 outline =
'.'.join(map(str,lev) )
1209 heading =
''.join(self.
data)
1211 anchor = self.
get_anchor(
"%s.%s" % ( outline, heading))
1212 self.
opentag(
'a', {
'id': anchor} )
1228 name = attrs.get( (TEXTNS,
'style-name') )
1229 level = self.
tagstack.count_tags(tag) + 1
1231 name = name.replace(
".",
"_")
1236 name = self.
tagstack.rfindattr( (TEXTNS,
'style-name') )
1237 list_class =
"%s_%d" % (name, level)
1239 self.
opentag(
'%s' % self.
listtypes.get(list_class,
'ul'), {
'class': list_class })
1247 name = attrs.get( (TEXTNS,
'style-name') )
1248 level = self.
tagstack.count_tags(tag) + 1
1250 name = name.replace(
".",
"_")
1255 name = self.
tagstack.rfindattr( (TEXTNS,
'style-name') )
1256 list_class =
"%s_%d" % (name, level)
1276 name = self.
tagstack.rfindattr( (STYLENS,
'name') )
1277 level = attrs[(TEXTNS,
'level')]
1279 list_class =
"%s_%s" % (name, level)
1286 listtype = (
"square",
"disc",
"circle")[level % 3]
1294 name = self.
tagstack.stackparent()[(STYLENS,
'name')]
1295 level = attrs[(TEXTNS,
'level')]
1296 num_format = attrs.get( (STYLENS,
'name'),
"1")
1297 list_class =
"%s_%s" % (name, level)
1303 if num_format ==
"1": listtype =
"decimal"
1304 elif num_format ==
"I": listtype =
"upper-roman"
1305 elif num_format ==
"i": listtype =
"lower-roman"
1306 elif num_format ==
"A": listtype =
"upper-alpha"
1307 elif num_format ==
"a": listtype =
"lower-alpha"
1308 else: listtype =
"decimal"
1327 self.notebody.append(s)
1340 mark =
''.join(self.
data)
1347 if sys.version_info[0]==3:
1359 c = attrs.get( (TEXTNS,
'style-name'),
None)
1361 c = c.replace(
".",
"_")
1362 specialtag = special_styles.get(
"P-"+c)
1363 if specialtag
is None:
1366 htmlattrs[
'class'] =
"P-%s" % c
1367 self.
opentag(specialtag, htmlattrs)
1374 c = attrs.get( (TEXTNS,
'style-name'),
None)
1376 c = c.replace(
".",
"_")
1377 specialtag = special_styles.get(
"P-"+c)
1378 if specialtag
is None:
1388 c = attrs.get( (TEXTNS,
'c'),
"1")
1389 for x
in range(int(c)):
1397 c = attrs.get( (TEXTNS,
'style-name'),
None)
1400 c = c.replace(
".",
"_")
1401 special = special_styles.get(
"S-"+c)
1403 htmlattrs[
'class'] =
"S-%s" % c
1404 self.
opentag(
'span', htmlattrs)
1446 def load(self, odffile):
1447 assert(type(odffile)==type(
u"")
or 'rb' in repr(odffile)
or 'BufferedReader' in repr(odffile)
or 'BytesIO' in repr(odffile))
1455 if node.nodeType == Node.ELEMENT_NODE:
1457 for c
in node.childNodes:
1460 if node.nodeType == Node.TEXT_NODE
or node.nodeType == Node.CDATA_SECTION_NODE:
1461 if sys.version_info[0]==3:
1473 def odf2xhtml(self, odffile):
1474 assert(type(odffile)==type(
u"")
or 'rb' in repr(odffile)
or 'BufferedReader' in repr(odffile)
or 'BytesIO' in repr(odffile))
1480 assert(type(result)==type(
u""))
1484 if s !=
'': self.
lines.append(s)
1489 return ''.join(self.
lines)
1511 def save(self, outputfile, addsuffix=False):
1512 if outputfile ==
'-':
1513 outputfp = sys.stdout
1516 outputfile = outputfile +
".html"
1517 outputfp = file(outputfile,
"w")
1518 outputfp.write(self.
xhtml().encode(
'us-ascii',
'xmlcharrefreplace'))
1525 def __init__(self, lines, generate_css=True, embedable=False):
1549 (NUMBERNS,
"boolean-style"):(self.
s_ignorexml,
None),
1550 (NUMBERNS,
"currency-style"):(self.
s_ignorexml,
None),
1551 (NUMBERNS,
"date-style"):(self.
s_ignorexml,
None),
1552 (NUMBERNS,
"number-style"):(self.
s_ignorexml,
None),
1553 (NUMBERNS,
"text-style"):(self.
s_ignorexml,
None),
1564 (PRESENTATIONNS,
"notes"):(self.
s_ignorexml,
None),
1588 (TABLENS,
'covered-table-cell'): (self.
s_ignorexml,
None),
1595 (TEXTNS,
"bibliography-configuration"):(self.
s_ignorexml,
None),
1600 (TEXTNS,
"linenumbering-configuration"):(self.
s_ignorexml,
None),
1605 (TEXTNS,
"list-style"):(
None,
None),
1609 (TEXTNS,
"notes-configuration"):(self.
s_ignorexml,
None),
1612 (TEXTNS,
's'): (self.
s_text_s,
None),
1618 (TEXTNS,
"page-number"):(
None,
None),
The ODF2XHTML parses an ODF file and produces XHTML.
e_dc_metatag(self, tag, attrs)
Any other meta data is added as a <meta> element.
e_draw_page(self, tag, attrs)
s_style_header(self, tag, attrs)
rewritelink(self, imghref)
Intended to be overloaded if you don't store your pictures in a Pictures subfolder.
s_text_x_source(self, tag, attrs)
Various indexes and tables of contents.
e_text_h(self, tag, attrs)
Headings end Side If there is no title in the metadata, then it is taken from the first heading of an...
s_text_line_break(self, tag, attrs)
Force a line break ( )
s_style_header_style(self, tag, attrs)
opentag(self, tag, attrs={}, block=False)
Create an open HTML tag.
s_text_list_item(self, tag, attrs)
Start list item.
s_text_bookmark(self, tag, attrs)
Bookmark definition.
s_table_table(self, tag, attrs)
Start a table.
endElementNS(self, tag, qname)
e_text_list(self, tag, attrs)
End a list.
s_text_note(self, tag, attrs)
s_text_note_body(self, tag, attrs)
s_draw_frame(self, tag, attrs)
A <draw:frame> is made into a.
s_draw_textbox(self, tag, attrs)
startElementNS(self, tag, qname, attrs)
s_style_master_page(self, tag, attrs)
Collect the formatting for the page layout style.
s_draw_page(self, tag, attrs)
A <draw:page> is a slide in a presentation.
s_office_text(self, tag, attrs)
OpenDocument text.
s_office_spreadsheet(self, tag, attrs)
s_office_document_content(self, tag, attrs)
First tag in the content.xml file.
s_office_presentation(self, tag, attrs)
For some odd reason, OpenOffice Impress doesn't define a default-style for the 'paragraph'.
e_text_a(self, tag, attrs)
End an anchor or bookmark reference.
e_style_header(self, tag, attrs)
e_style_page_layout(self, tag, attrs)
End this style.
s_office_styles(self, tag, attrs)
xhtml(self)
Returns the xhtml.
e_office_text(self, tag, attrs)
closetag(self, tag, block=True)
Close an open HTML tag.
emptytag(self, tag, attrs={})
e_text_list_item(self, tag, attrs)
End list item.
s_style_handle_properties(self, tag, attrs)
Copy all attributes to a struct.
handle_endtag(self, tag, attrs, method)
e_style_default_style(self, tag, attrs)
e_table_table(self, tag, attrs)
End a table.
classname(self, attrs)
Generate a class name from a style name.
unknown_endtag(self, tag, attrs)
s_text_s(self, tag, attrs)
Generate a number of spaces.
save(self, outputfile, addsuffix=False)
Save the HTML under the filename.
s_processcont(self, tag, attrs)
Start processing the text nodes.
e_office_spreadsheet(self, tag, attrs)
e_text_note_body(self, tag, attrs)
e_draw_textbox(self, tag, attrs)
End the <draw:text-box>
add_style_file(self, stylefilename, media=None)
Add a link to an external style file.
s_style_footer(self, tag, attrs)
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...
__init__(self, generate_css=True, embedable=False)
s_style_font_face(self, tag, attrs)
It is possible that the HTML browser doesn't know how to show a particular font.
s_ignorecont(self, tag, attrs)
Stop processing the text nodes.
set_plain(self)
Tell the parser to not generate CSS.
e_text_p(self, tag, attrs)
End Paragraph.
e_dc_creator(self, tag, attrs)
Set the content creator.
e_text_note_citation(self, tag, attrs)
generate_stylesheet(self)
s_table_table_row(self, tag, attrs)
Start a table row.
e_text_span(self, tag, attrs)
End the <text:span>
s_style_default_style(self, tag, attrs)
A default style is like a style on an HTML tag.
get_anchor(self, name)
Create a unique anchor id for a href name.
s_text_tab(self, tag, attrs)
Move to the next tabstop.
e_style_footer(self, tag, attrs)
s_draw_object_ole(self, tag, attrs)
A <draw:object-ole> is embedded OLE object in the document (e.g.
s_draw_image(self, tag, attrs)
A <draw:image> becomes an element.
s_style_footer_style(self, tag, attrs)
s_text_list(self, tag, attrs)
Start a list (.
s_office_automatic_styles(self, tag, attrs)
e_custom_shape(self, tag, attrs)
End the <draw:frame>
handle_starttag(self, tag, method, attrs)
e_table_table_row(self, tag, attrs)
End a table row.
s_text_h(self, tag, attrs)
Headings start.
unknown_starttag(self, tag, attrs)
e_text_note(self, tag, attrs)
e_text_x_source(self, tag, attrs)
Various indexes and tables of contents.
s_draw_fill_image(self, tag, attrs)
s_style_page_layout(self, tag, attrs)
Collect the formatting for the page layout style.
e_draw_frame(self, tag, attrs)
End the <draw:frame>
s_custom_shape(self, tag, attrs)
A <draw:custom-shape> is made into a.
e_dc_contentlanguage(self, tag, attrs)
Set the content language.
e_office_presentation(self, tag, attrs)
s_table_table_cell(self, tag, attrs)
Start a table cell.
s_text_bookmark_ref(self, tag, attrs)
Bookmark reference.
e_dc_title(self, tag, attrs)
Get the title from the meta data and create a HTML <title>
css(self)
Returns the CSS content.
s_office_master_styles(self, tag, attrs)
s_table_table_column(self, tag, attrs)
Start a table column.
load(self, odffile)
Loads a document into the parser and parses it.
s_text_a(self, tag, attrs)
Anchors start.
e_text_list_level_style_bullet(self, tag, attrs)
set_embedable(self)
Tells the converter to only output the parts inside the <body>
e_table_table_cell(self, tag, attrs)
End a table cell.
s_text_list_level_style_number(self, tag, attrs)
html_body(self, tag, attrs)
e_style_style(self, tag, attrs)
End this style.
s_draw_object(self, tag, attrs)
A <draw:object> is embedded object in the document (e.g.
s_text_p(self, tag, attrs)
Paragraph.
e_text_list_level_style_number(self, tag, attrs)
e_office_document_content(self, tag, attrs)
Last tag.
s_ignorexml(self, tag, attrs)
Ignore this xml element and all children of it It will automatically stop ignoring.
s_style_style(self, tag, attrs)
Collect the formatting for the style.
s_text_span(self, tag, attrs)
The <text:span> element matches the element in HTML.
s_style_default_page_layout(self, tag, attrs)
Collect the formatting for the default page layout style.
The ODF2XHTML parses an ODF file and produces XHTML.
__init__(self, lines, generate_css=True, embedable=False)
The purpose of the StyleToCSS class is to contain the rules to convert ODF styles to CSS2.
c_text_underline_style(self, ruleset, sdict, rule, val)
Set underline decoration HTML doesn't really have a page-width.
c_fn(self, ruleset, sdict, rule, fontstyle)
Generate the CSS font family A generic font can be found in two ways.
c_text_line_through_style(self, ruleset, sdict, rule, val)
Set underline decoration HTML doesn't really have a page-width.
convert_styles(self, ruleset)
Rule is a tuple of (namespace, name).
c_page_height(self, ruleset, sdict, rule, val)
Set height of box.
c_drawfillimage(self, ruleset, sdict, rule, val)
Fill a figure with an image.
c_text_position(self, ruleset, sdict, rule, tp)
Text position.
c_hp(self, ruleset, sdict, rule, hpos)
c_text_align(self, ruleset, sdict, rule, align)
Text align.
c_fo(self, ruleset, sdict, rule, val)
XSL formatting attributes.
c_page_width(self, ruleset, sdict, rule, val)
Set width of box HTML doesn't really have a page-width.
c_border_model(self, ruleset, sdict, rule, val)
Convert to CSS2 border model.
c_width(self, ruleset, sdict, rule, val)
Set width of box.
save_font(self, name, family, generic)
It is possible that the HTML browser doesn't know how to show a particular font.