25 sys.path.append(os.path.dirname(__file__))
26 from xml.sax
import handler
27 from xml.sax.saxutils
import escape, quoteattr
28 from xml.dom
import Node
30 from opendocument
import load
32 from 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
73 (FONS,
u"background-color"): self.
c_fo,
74 (FONS,
u"border"): self.
c_fo,
75 (FONS,
u"border-bottom"): self.
c_fo,
76 (FONS,
u"border-left"): self.
c_fo,
77 (FONS,
u"border-right"): self.
c_fo,
78 (FONS,
u"border-top"): self.
c_fo,
79 (FONS,
u"color"): self.
c_fo,
80 (FONS,
u"font-family"): self.
c_fo,
81 (FONS,
u"font-size"): self.
c_fo,
82 (FONS,
u"font-style"): self.
c_fo,
83 (FONS,
u"font-variant"): self.
c_fo,
84 (FONS,
u"font-weight"): self.
c_fo,
85 (FONS,
u"line-height"): self.
c_fo,
86 (FONS,
u"margin"): self.
c_fo,
87 (FONS,
u"margin-bottom"): self.
c_fo,
88 (FONS,
u"margin-left"): self.
c_fo,
89 (FONS,
u"margin-right"): self.
c_fo,
90 (FONS,
u"margin-top"): self.
c_fo,
91 (FONS,
u"min-height"): self.
c_fo,
92 (FONS,
u"padding"): self.
c_fo,
93 (FONS,
u"padding-bottom"): self.
c_fo,
94 (FONS,
u"padding-left"): self.
c_fo,
95 (FONS,
u"padding-right"): self.
c_fo,
96 (FONS,
u"padding-top"): self.
c_fo,
100 (FONS,
u"text-indent") :self.
c_fo,
102 (STYLENS,
u'column-width') : self.
c_width,
103 (STYLENS,
u"font-name"): self.
c_fn,
104 (STYLENS,
u'horizontal-pos'): self.
c_hp,
108 (STYLENS,
u'width') : self.
c_width,
121 htmlgeneric =
"sans-serif" 122 if generic ==
"roman": htmlgeneric =
"serif" 123 elif generic ==
"swiss": htmlgeneric =
"sans-serif" 124 elif generic ==
"modern": htmlgeneric =
"monospace" 125 elif generic ==
"decorative": htmlgeneric =
"sans-serif" 126 elif generic ==
"script": htmlgeneric =
"monospace" 127 elif generic ==
"system": htmlgeneric =
"serif" 128 self.
fontdict[name] = (family, htmlgeneric)
136 sdict[
'background-image'] =
"url('%s')" % self.
fillimages[val]
140 def c_fo(self, ruleset, sdict, rule, val):
142 sdict[selector] = val
147 if val ==
'collapsing':
148 sdict[
'border-collapse'] =
'collapse' 150 sdict[
'border-collapse'] =
'separate' 160 if align ==
"start": align =
"left" 161 if align ==
"end": align =
"right" 162 sdict[
'text-align'] = align
169 def c_fn(self, ruleset, sdict, rule, fontstyle):
170 generic = ruleset.get((STYLENS,
'font-family-generic') )
171 if generic
is not None:
172 self.
save_font(fontstyle, fontstyle, generic)
173 family, htmlgeneric = self.
fontdict.get(fontstyle, (fontstyle,
'serif'))
174 sdict[
'font-family'] =
'%s, %s' % (family, htmlgeneric)
196 textpos = tp.split(
' ')
197 if len(textpos) == 2
and textpos[0] !=
"0%":
199 sdict[
'font-size'] = textpos[1]
200 if textpos[0] ==
"super":
201 sdict[
'vertical-align'] =
"33%" 202 elif textpos[0] ==
"sub":
203 sdict[
'vertical-align'] =
"-33%" 205 sdict[
'vertical-align'] = textpos[0]
207 def c_hp(self, ruleset, sdict, rule, hpos):
211 wrap = ruleset.get((STYLENS,
'wrap'),
'parallel')
214 sdict[
'margin-left'] =
"auto" 215 sdict[
'margin-right'] =
"auto" 221 if hpos
in (
"right",
"outside"):
222 if wrap
in (
"left",
"parallel",
"dynamic"):
223 sdict[
'float'] =
"right" 224 elif wrap ==
"run-through":
225 sdict[
'position'] =
"absolute" 227 sdict[
'right'] =
"0";
229 sdict[
'margin-left'] =
"auto" 230 sdict[
'margin-right'] =
"0cm" 231 elif hpos
in (
"left",
"inside"):
232 if wrap
in (
"right",
"parallel",
"dynamic"):
233 sdict[
'float'] =
"left" 234 elif wrap ==
"run-through":
235 sdict[
'position'] =
"absolute" 239 sdict[
'margin-left'] =
"0cm" 240 sdict[
'margin-right'] =
"auto" 241 elif hpos
in (
"from-left",
"from-inside"):
242 if wrap
in (
"right",
"parallel"):
243 sdict[
'float'] =
"left" 245 sdict[
'position'] =
"relative" 246 if (SVGNS,
'x')
in ruleset:
247 sdict[
'left'] = ruleset[(SVGNS,
'x')]
261 if val
and val !=
"none":
262 sdict[
'text-decoration'] =
"underline" 269 if val
and val !=
"none":
270 sdict[
'text-decoration'] =
"line-through" 275 sdict[
'height'] = val
284 for rule,val
in ruleset.items():
290 procedures.append([method, ruleset, sdict, rule, val])
294 for p
in filter(
lambda x: x[0] != self.
c_hp, procedures):
295 method, ruleset, sdict, rule, val = p
296 method(ruleset, sdict, rule, val)
297 for p
in filter(
lambda x: x[0] == self.
c_hp, procedures):
298 method, ruleset, sdict, rule, val = p
299 method(ruleset, sdict, rule, val)
309 self.
stack.append( (tag, attrs) )
316 item = self.
stack[-1]
322 for tag, attrs
in self.
stack:
328 for ttag, tattrs
in self.
stack:
329 if ttag == tag: c = c + 1
335 'S-Strong_20_Emphasis':
'strong',
337 'S-Definition':
'dfn',
339 'P-Heading_20_1':
'h1',
340 'P-Heading_20_2':
'h2',
341 'P-Heading_20_3':
'h3',
342 'P-Heading_20_4':
'h4',
343 'P-Heading_20_5':
'h5',
344 'P-Heading_20_6':
'h6',
346 'P-Addressee':
'address',
349 'P-Preformatted_20_Text':
'pre',
364 def __init__(self, generate_css=True, embedable=False):
386 (NUMBERNS,
"boolean-style"):(self.
s_ignorexml,
None),
387 (NUMBERNS,
"currency-style"):(self.
s_ignorexml,
None),
389 (NUMBERNS,
"number-style"):(self.
s_ignorexml,
None),
404 (PRESENTATIONNS,
"notes"):(self.
s_ignorexml,
None),
406 (STYLENS,
"default-page-layout"):(self.
s_ignorexml,
None),
413 (STYLENS,
"handout-master"):(self.
s_ignorexml,
None),
428 (TABLENS,
'covered-table-cell'): (self.
s_ignorexml,
None),
435 (TEXTNS,
"bibliography-configuration"):(self.
s_ignorexml,
None),
444 (TEXTNS,
"linenumbering-configuration"):(self.
s_ignorexml,
None),
449 (TEXTNS,
"list-style"):(
None,
None),
453 (TEXTNS,
"notes-configuration"):(self.
s_ignorexml,
None),
456 (TEXTNS,
's'): (self.
s_text_s,
None),
475 self.
elements[(OFFICENS,
u"text")] = (
None,
None)
476 self.
elements[(OFFICENS,
u"spreadsheet")] = (
None,
None)
477 self.
elements[(OFFICENS,
u"presentation")] = (
None,
None)
478 self.
elements[(OFFICENS,
u"document-content")] = (
None,
None)
489 self.
metatags.append(
'<link rel="stylesheet" type="text/css" href="%s" media="%s"/>\n' % (stylefilename,media))
491 self.
metatags.append(
'<link rel="stylesheet" type="text/css" href="%s"/>\n' % (stylefilename))
493 def _resetfootnotes(self):
499 def _resetobject(self):
513 self.
headinglevels = [0, 0,0,0,0,0, 0,0,0,0,0]
534 d =
''.join(self.
data)
540 def opentag(self, tag, attrs={}, block=False):
543 for key,val
in attrs.items():
544 a.append(
'''%s=%s''' % (key, quoteattr(val)))
548 self.
writeout(
"<%s %s>" % (tag,
" ".join(a)))
562 for key,val
in attrs.items():
563 a.append(
'''%s=%s''' % (key, quoteattr(val)))
564 self.
writeout(
"<%s %s/>\n" % (tag,
" ".join(a)))
571 self.
data.append(data)
576 method = self.
elements.get(tag, (
None,
None) )[0]
586 method = self.
elements.get(tag, (
None,
None) )[1]
626 c = attrs.get((TEXTNS,
'style-name'),
'')
627 c = c.replace(
".",
"_")
660 self.
metatags.append(
'<meta name="%s" content=%s/>\n' % (tag[1], quoteattr(
''.join(self.
data))))
668 self.
metatags.append(
'<meta http-equiv="content-language" content="%s"/>\n' % escape(self.
language))
676 self.
metatags.append(
'<meta http-equiv="creator" content="%s"/>\n' % escape(self.
creator))
683 anchor_type = attrs.get((TEXTNS,
'anchor-type'),
'notfound')
685 name =
"G-" + attrs.get( (DRAWNS,
'style-name'),
"")
687 name =
"PR-" + attrs.get( (PRESENTATIONNS,
'style-name'),
"")
688 name = name.replace(
".",
"_")
689 if anchor_type ==
"paragraph":
690 style =
'position:absolute;' 691 elif anchor_type ==
'char':
692 style =
"position:absolute;" 693 elif anchor_type ==
'as-char':
697 style =
"position: absolute;" 698 if (SVGNS,
"width")
in attrs:
699 style = style +
"width:" + attrs[(SVGNS,
"width")] +
";" 700 if (SVGNS,
"height")
in attrs:
701 style = style +
"height:" + attrs[(SVGNS,
"height")] +
";" 702 if (SVGNS,
"x")
in attrs:
703 style = style +
"left:" + attrs[(SVGNS,
"x")] +
";" 704 if (SVGNS,
"y")
in attrs:
705 style = style +
"top:" + attrs[(SVGNS,
"y")] +
";" 707 self.
opentag(htmltag, {
'class': name,
'style': style})
721 anchor_type = attrs.get((TEXTNS,
'anchor-type'),
'notfound')
723 name =
"G-" + attrs.get( (DRAWNS,
'style-name'),
"")
725 name =
"PR-" + attrs.get( (PRESENTATIONNS,
'style-name'),
"")
726 name = name.replace(
".",
"_")
727 if anchor_type ==
"paragraph":
728 style =
'position:relative;' 729 elif anchor_type ==
'char':
730 style =
"position:relative;" 731 elif anchor_type ==
'as-char':
735 style =
"position:absolute;" 736 if (SVGNS,
"width")
in attrs:
737 style = style +
"width:" + attrs[(SVGNS,
"width")] +
";" 738 if (SVGNS,
"height")
in attrs:
739 style = style +
"height:" + attrs[(SVGNS,
"height")] +
";" 740 if (SVGNS,
"x")
in attrs:
741 style = style +
"left:" + attrs[(SVGNS,
"x")] +
";" 742 if (SVGNS,
"y")
in attrs:
743 style = style +
"top:" + attrs[(SVGNS,
"y")] +
";" 745 self.
opentag(htmltag, {
'class': name,
'style': style})
756 name = attrs.get( (DRAWNS,
'name'),
"NoName")
757 imghref = attrs[(XLINKNS,
"href")]
759 self.
cs.fillimages[name] = imghref
772 parent = self.
tagstack.stackparent()
773 anchor_type = parent.get((TEXTNS,
'anchor-type'))
774 imghref = attrs[(XLINKNS,
"href")]
776 htmlattrs = {
'alt':
"",
'src':imghref }
778 if anchor_type !=
"char":
779 htmlattrs[
'style'] =
"display: block;" 786 objhref = attrs[(XLINKNS,
"href")]
796 for c
in self.
document.childobjects:
797 if c.folder == objhref:
804 class_id = attrs[(DRAWNS,
"class-id")]
805 if class_id
and class_id.lower() ==
"00020803-0000-0000-c000-000000000046":
806 tagattrs = {
'name':
'object_ole_graph',
'class':
'ole-graph' }
816 name = attrs.get( (DRAWNS,
'name'),
"NoName")
817 stylename = attrs.get( (DRAWNS,
'style-name'),
"")
818 stylename = stylename.replace(
".",
"_")
819 masterpage = attrs.get( (DRAWNS,
'master-page-name'),
"")
820 masterpage = masterpage.replace(
".",
"_")
822 self.
opentag(
'fieldset', {
'class':
"DP-%s MP-%s" % (stylename, masterpage) })
834 if (FONS,
"min-height")
in attrs:
835 style = style +
"min-height:" + attrs[(FONS,
"min-height")] +
";" 848 self.
opentag(
'style', {
'type':
"text/css"},
True)
855 self.
opentag(
'body', block=
True)
858 img { width: 100%; height: 100%; } 859 * { padding: 0; margin: 0; background-color:white; } 860 body { margin: 0 1em; } 861 ol, ul { padding-left: 2em; } 868 if '__style-family'in styles
and styles[
'__style-family']
in self.
styledict:
869 familystyle = self.
styledict[styles[
'__style-family']].copy()
870 del styles[
'__style-family']
871 for style, val
in styles.items():
872 familystyle[style] = val
875 while '__parent-style-name' in styles
and styles[
'__parent-style-name']
in self.
styledict:
876 parentstyle = self.
styledict[styles[
'__parent-style-name']].copy()
877 del styles[
'__parent-style-name']
878 for style, val
in styles.items():
879 parentstyle[style] = val
886 css2 = self.
cs.convert_styles(styles)
888 for style, val
in css2.items():
889 self.
writeout(
"\t%s: %s;\n" % (style, val) )
896 self.
opentag(
'ol', {
'style':
'border-top: 1px solid black'},
True)
902 self.
opentag(
'li', {
'id':
"footnote-%d" % key })
911 if self.
xmlfile ==
'styles.xml':
919 self.
writeout(
'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" ')
920 self.
writeout(
'"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">\n')
921 self.
opentag(
'html', {
'xmlns':
"http://www.w3.org/1999/xhtml"},
True)
922 self.
opentag(
'head', block=
True)
923 self.
emptytag(
'meta', {
'http-equiv':
"Content-Type",
'content':
"text/html;charset=UTF-8"})
943 self.
styledict[
'p'] = {(FONS,
u'font-size'):
u"24pt" }
944 self.
styledict[
'presentation'] = {(FONS,
u'font-size'):
u"24pt" }
964 self.
styledict[
'frame'] = { (STYLENS,
'wrap'):
u'parallel'}
976 for key,attr
in attrs.items():
980 familymap = {
'frame':
'frame',
'paragraph':
'p',
'presentation':
'presentation',
981 'text':
'span',
'section':
'div',
982 'table':
'table',
'table-cell':
'td',
'table-column':
'col',
983 'table-row':
'tr',
'graphic':
'graphic' }
989 family = attrs[(STYLENS,
'family')]
990 htmlfamily = self.
familymap.get(family,
'unknown')
1006 name = attrs[(STYLENS,
"name")]
1007 family = attrs[(SVGNS,
"font-family")]
1008 generic = attrs.get( (STYLENS,
'font-family-generic'),
"" )
1009 self.
cs.save_font(name, family, generic)
1012 self.
opentag(
'div', {
'id':
"footer" })
1026 self.
opentag(
'div', {
'id':
"header" })
1053 name = attrs[(STYLENS,
'name')]
1054 name = name.replace(
".",
"_")
1069 name = attrs[(STYLENS,
'name')]
1070 name = name.replace(
".",
"_")
1076 pagelayout = attrs.get( (STYLENS,
'page-layout-name'),
None)
1078 pagelayout =
".PL-" + pagelayout
1081 for style, val
in styles.items():
1088 _familyshort = {
'drawing-page':
'DP',
'paragraph':
'P',
'presentation':
'PR',
1089 'text':
'S',
'section':
'D',
1090 'table':
'T',
'table-cell':
'TD',
'table-column':
'TC',
1091 'table-row':
'TR',
'graphic':
'G' }
1101 name = attrs[(STYLENS,
'name')]
1102 name = name.replace(
".",
"_")
1103 family = attrs[(STYLENS,
'family')]
1104 htmlfamily = self.
familymap.get(family,
'unknown')
1106 name =
"%s%s-%s" % (self.
autoprefix, sfamily, name)
1107 parent = attrs.get( (STYLENS,
'parent-style-name') )
1117 parent =
"%s-%s" % (sfamily, parent)
1118 parent = special_styles.get(parent,
"."+parent)
1121 for style, val
in styles.items():
1136 c = attrs.get( (TABLENS,
'style-name'),
None)
1138 c = c.replace(
".",
"_")
1139 self.
opentag(
'table',{
'class':
"T-%s" % c })
1158 rowspan = attrs.get( (TABLENS,
'number-rows-spanned') )
1160 htmlattrs[
'rowspan'] = rowspan
1161 colspan = attrs.get( (TABLENS,
'number-columns-spanned') )
1163 htmlattrs[
'colspan'] = colspan
1165 c = attrs.get( (TABLENS,
'style-name') )
1167 htmlattrs[
'class'] =
'TD-%s' % c.replace(
".",
"_")
1181 c = attrs.get( (TABLENS,
'style-name'),
None)
1182 repeated = int(attrs.get( (TABLENS,
'number-columns-repeated'), 1))
1185 htmlattrs[
'class'] =
"TC-%s" % c.replace(
".",
"_")
1186 for x
in range(repeated):
1194 c = attrs.get( (TABLENS,
'style-name'),
None)
1197 htmlattrs[
'class'] =
"TR-%s" % c.replace(
".",
"_")
1212 href = attrs[(XLINKNS,
"href")].split(
"|")[0]
1215 self.
opentag(
'a', {
'href':href})
1228 name = attrs[(TEXTNS,
'name')]
1231 self.
opentag(
'span', {
'id':html_id})
1238 name = attrs[(TEXTNS,
'ref-name')]
1241 self.
opentag(
'a', {
'href':html_id})
1247 level = int(attrs[(TEXTNS,
'outline-level')])
1248 if level > 6: level = 6
1249 if level < 1: level = 1
1252 for x
in range(level + 1,10):
1254 special = special_styles.get(
"P-"+name)
1258 self.
opentag(
'h%s' % level, {
'class':
"P-%s" % name })
1268 level = int(attrs[(TEXTNS,
'outline-level')])
1269 if level > 6: level = 6
1270 if level < 1: level = 1
1272 outline =
'.'.join(map(str,lev) )
1273 heading =
''.join(self.
data)
1275 anchor = self.
get_anchor(
"%s.%s" % ( outline, heading))
1276 self.
opentag(
'a', {
'id': anchor} )
1294 name = attrs.get( (TEXTNS,
'style-name') )
1295 level = self.
tagstack.count_tags(tag) + 1
1297 name = name.replace(
".",
"_")
1302 name = self.
tagstack.rfindattr( (TEXTNS,
'style-name') )
1303 list_class =
"%s_%d" % (name, level)
1305 self.
opentag(
'%s' % self.
listtypes.get(list_class,
'ul'), {
'class': list_class })
1314 name = attrs.get( (TEXTNS,
'style-name') )
1315 level = self.
tagstack.count_tags(tag) + 1
1317 name = name.replace(
".",
"_")
1322 name = self.
tagstack.rfindattr( (TEXTNS,
'style-name') )
1323 list_class =
"%s_%d" % (name, level)
1346 name = self.
tagstack.rfindattr( (STYLENS,
'name') )
1347 level = attrs[(TEXTNS,
'level')]
1349 list_class =
"%s_%s" % (name, level)
1351 self.
currentstyle =
".%s_%s" % ( name.replace(
".",
"_"), level)
1356 listtype = (
"square",
"disc",
"circle")[level % 3]
1364 name = self.
tagstack.stackparent()[(STYLENS,
'name')]
1365 level = attrs[(TEXTNS,
'level')]
1366 num_format = attrs.get( (STYLENS,
'name'),
"1")
1367 list_class =
"%s_%s" % (name, level)
1369 self.
currentstyle =
".%s_%s" % ( name.replace(
".",
"_"), level)
1373 if num_format ==
"1": listtype =
"decimal" 1374 elif num_format ==
"I": listtype =
"upper-roman" 1375 elif num_format ==
"i": listtype =
"lower-roman" 1376 elif num_format ==
"A": listtype =
"upper-alpha" 1377 elif num_format ==
"a": listtype =
"lower-alpha" 1378 else: listtype =
"decimal" 1397 self.notebody.append(s)
1410 mark =
''.join(self.
data)
1417 if sys.version_info[0]==3:
1430 c = attrs.get( (TEXTNS,
'style-name'),
None)
1432 c = c.replace(
".",
"_")
1433 specialtag = special_styles.get(
"P-"+c)
1434 if specialtag
is None:
1437 htmlattrs[
'class'] =
"P-%s" % c
1438 self.
opentag(specialtag, htmlattrs)
1446 c = attrs.get( (TEXTNS,
'style-name'),
None)
1448 c = c.replace(
".",
"_")
1449 specialtag = special_styles.get(
"P-"+c)
1450 if specialtag
is None:
1461 c = attrs.get( (TEXTNS,
'c'),
"1")
1462 for x
in range(int(c)):
1471 c = attrs.get( (TEXTNS,
'style-name'),
None)
1474 c = c.replace(
".",
"_")
1475 special = special_styles.get(
"S-"+c)
1477 htmlattrs[
'class'] =
"S-%s" % c
1478 self.
opentag(
'span', htmlattrs)
1526 assert(type(odffile)==type(
u"")
or 'rb' in repr(odffile)
or 'BufferedReader' in repr(odffile)
or 'BytesIO' in repr(odffile))
1530 if type(odffile)==type(
u""):
1536 def _walknode(self, node):
1537 if node.nodeType == Node.ELEMENT_NODE:
1539 for c
in node.childNodes:
1542 if node.nodeType == Node.TEXT_NODE
or node.nodeType == Node.CDATA_SECTION_NODE:
1543 if sys.version_info[0]==3:
1557 assert(type(odffile)==type(
u"")
or 'rb' in repr(odffile)
or 'BufferedReader' in repr(odffile)
or 'BytesIO' in repr(odffile))
1563 assert(type(result)==type(
u""))
1566 def _wlines(self,s):
1567 if s !=
'': self.
lines.append(s)
1573 return ''.join(self.
lines)
1575 def _writecss(self, s):
1578 def _writenothing(self, s):
1597 def save(self, outputfile, addsuffix=False):
1598 if outputfile ==
'-':
1599 outputfp = sys.stdout
1602 outputfile = outputfile +
".html" 1603 outputfp = file(outputfile,
"w")
1604 outputfp.write(self.
xhtml().encode(
'us-ascii',
'xmlcharrefreplace'))
1612 def __init__(self, lines, generate_css=True, embedable=False):
1636 (NUMBERNS,
"boolean-style"):(self.
s_ignorexml,
None),
1637 (NUMBERNS,
"currency-style"):(self.
s_ignorexml,
None),
1638 (NUMBERNS,
"date-style"):(self.
s_ignorexml,
None),
1639 (NUMBERNS,
"number-style"):(self.
s_ignorexml,
None),
1640 (NUMBERNS,
"text-style"):(self.
s_ignorexml,
None),
1651 (PRESENTATIONNS,
"notes"):(self.
s_ignorexml,
None),
1675 (TABLENS,
'covered-table-cell'): (self.
s_ignorexml,
None),
1682 (TEXTNS,
"bibliography-configuration"):(self.
s_ignorexml,
None),
1687 (TEXTNS,
"linenumbering-configuration"):(self.
s_ignorexml,
None),
1692 (TEXTNS,
"list-style"):(
None,
None),
1696 (TEXTNS,
"notes-configuration"):(self.
s_ignorexml,
None),
1699 (TEXTNS,
's'): (self.
s_text_s,
None),
1705 (TEXTNS,
"page-number"):(
None,
None),
def generate_stylesheet(self)
def s_style_default_page_layout(self, tag, attrs)
Collect the formatting for the default page layout style.
def opentag(self, tag, attrs={}, block=False)
Create an open HTML tag.
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...
def s_draw_page(self, tag, attrs)
A <draw:page> is a slide in a presentation.
def e_dc_contentlanguage(self, tag, attrs)
Set the content language.
def e_dc_metatag(self, tag, attrs)
Any other meta data is added as a <meta> element.
def c_hp(self, ruleset, sdict, rule, hpos)
def unknown_endtag(self, tag, attrs)
def s_draw_image(self, tag, attrs)
A <draw:image> becomes an element.
def emptytag(self, tag, attrs={})
def s_style_header(self, tag, attrs)
def html_body(self, tag, attrs)
def closetag(self, tag, block=True)
Close an open HTML tag.
def e_custom_shape(self, tag, attrs)
End the <draw:frame>
def classname(self, attrs)
Generate a class name from a style name.
def _walknode(self, node)
def e_style_style(self, tag, attrs)
End this style.
def s_style_handle_properties(self, tag, attrs)
Copy all attributes to a struct.
def s_table_table_cell(self, tag, attrs)
Start a table cell.
def e_text_note(self, tag, attrs)
def e_draw_page(self, tag, attrs)
def e_text_note_body(self, tag, attrs)
def unknown_starttag(self, tag, attrs)
def e_text_list_item(self, tag, attrs)
End list item.
def s_style_master_page(self, tag, attrs)
Collect the formatting for the page layout style.
def __init__(self, lines, generate_css=True, embedable=False)
def e_office_spreadsheet(self, tag, attrs)
def s_style_page_layout(self, tag, attrs)
Collect the formatting for the page layout style.
def set_embedable(self)
Tells the converter to only output the parts inside the <body>
def s_draw_object_ole(self, tag, attrs)
A <draw:object-ole> is embedded OLE object in the document (e.g.
def s_office_spreadsheet(self, tag, attrs)
def s_office_automatic_styles(self, tag, attrs)
def s_style_header_style(self, tag, attrs)
def e_draw_frame(self, tag, attrs)
End the <draw:frame>
def s_draw_fill_image(self, tag, attrs)
def s_ignorexml(self, tag, attrs)
Ignore this xml element and all children of it It will automatically stop ignoring.
def s_ignorecont(self, tag, attrs)
Stop processing the text nodes.
def s_draw_object(self, tag, attrs)
A <draw:object> is embedded object in the document (e.g.
def e_text_list(self, tag, attrs)
End a list.
def s_office_text(self, tag, attrs)
OpenDocument text.
def handle_endtag(self, tag, attrs, method)
def e_style_default_style(self, tag, attrs)
def s_processcont(self, tag, attrs)
Start processing the text nodes.
def s_office_master_styles(self, tag, attrs)
def e_text_p(self, tag, attrs)
End Paragraph.
def s_text_span(self, tag, attrs)
The <text:span> element matches the element in HTML.
def e_table_table_cell(self, tag, attrs)
End a table cell.
def startElementNS(self, tag, qname, attrs)
def s_text_list_level_style_number(self, tag, attrs)
def e_text_span(self, tag, attrs)
End the <text:span>
def characters(self, data)
def s_draw_textbox(self, tag, attrs)
def s_text_s(self, tag, attrs)
Generate a number of spaces.
def s_style_footer(self, tag, attrs)
def e_text_x_source(self, tag, attrs)
Various indexes and tables of contents.
def c_text_align(self, ruleset, sdict, rule, align)
Text align.
def s_office_styles(self, tag, attrs)
def e_style_page_layout(self, tag, attrs)
End this style.
def e_draw_textbox(self, tag, attrs)
End the <draw:text-box>
def s_text_p(self, tag, attrs)
Paragraph.
def get_anchor(self, name)
Create a unique anchor id for a href name.
def s_text_h(self, tag, attrs)
Headings start.
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...
def s_text_bookmark(self, tag, attrs)
Bookmark definition.
def save_font(self, name, family, generic)
It is possible that the HTML browser doesn't know how to show a particular font.
def s_table_table_column(self, tag, attrs)
Start a table column.
def c_text_underline_style(self, ruleset, sdict, rule, val)
Set underline decoration HTML doesn't really have a page-width.
def s_text_x_source(self, tag, attrs)
Various indexes and tables of contents.
def s_text_bookmark_ref(self, tag, attrs)
Bookmark reference.
def s_style_style(self, tag, attrs)
Collect the formatting for the style.
def _resetfootnotes(self)
def odf2xhtml(self, odffile)
Load a file and return the XHTML.
def c_fn(self, ruleset, sdict, rule, fontstyle)
Generate the CSS font family A generic font can be found in two ways.
def s_text_tab(self, tag, attrs)
Move to the next tabstop.
def s_text_line_break(self, tag, attrs)
Force a line break ( )
def s_table_table_row(self, tag, attrs)
Start a table row.
def c_border_model(self, ruleset, sdict, rule, val)
Convert to CSS2 border model.
def s_style_default_style(self, tag, attrs)
A default style is like a style on an HTML tag.
def set_plain(self)
Tell the parser to not generate CSS.
def e_text_note_citation(self, tag, attrs)
def s_table_table(self, tag, attrs)
Start a table.
def css(self)
Returns the CSS content.
def rewritelink(self, imghref)
Intended to be overloaded if you don't store your pictures in a Pictures subfolder.
def e_text_list_level_style_bullet(self, tag, attrs)
def c_width(self, ruleset, sdict, rule, val)
Set width of box.
def e_office_text(self, tag, attrs)
def handle_starttag(self, tag, method, attrs)
def __init__(self, generate_css=True, embedable=False)
def e_text_list_level_style_number(self, tag, attrs)
def s_text_list_item(self, tag, attrs)
Start list item.
def s_office_presentation(self, tag, attrs)
For some odd reason, OpenOffice Impress doesn't define a default-style for the 'paragraph'.
The ODF2XHTML parses an ODF file and produces XHTML.
def e_dc_title(self, tag, attrs)
Get the title from the meta data and create a HTML <title>
def s_text_note(self, tag, attrs)
def e_office_document_content(self, tag, attrs)
Last tag.
def e_text_a(self, tag, attrs)
End an anchor or bookmark reference.
def load(self, odffile)
Loads a document into the parser and parses it.
def c_fo(self, ruleset, sdict, rule, val)
XSL formatting attributes.
def save(self, outputfile, addsuffix=False)
Save the HTML under the filename.
def endElementNS(self, tag, qname)
The ODF2XHTML parses an ODF file and produces XHTML.
def s_custom_shape(self, tag, attrs)
A <draw:custom-shape> is made into a in HTML which is then styled.
def xhtml(self)
Returns the xhtml.
def s_text_list(self, tag, attrs)
Start a list (.
def s_text_note_body(self, tag, attrs)
The purpose of the StyleToCSS class is to contain the rules to convert ODF styles to CSS2...
def convert_styles(self, ruleset)
Rule is a tuple of (namespace, name).
def generate_footnotes(self)
def add_style_file(self, stylefilename, media=None)
Add a link to an external style file.
def c_drawfillimage(self, ruleset, sdict, rule, val)
Fill a figure with an image.
def s_text_a(self, tag, attrs)
Anchors start.
def e_office_presentation(self, tag, attrs)
def e_style_footer(self, tag, attrs)
def e_dc_creator(self, tag, attrs)
Set the content creator.
def s_style_font_face(self, tag, attrs)
It is possible that the HTML browser doesn't know how to show a particular font.
def e_table_table_row(self, tag, attrs)
End a table row.
def e_table_table(self, tag, attrs)
End a table.
def c_text_line_through_style(self, ruleset, sdict, rule, val)
Set underline decoration HTML doesn't really have a page-width.
def s_style_footer_style(self, tag, attrs)
def c_page_width(self, ruleset, sdict, rule, val)
Set width of box HTML doesn't really have a page-width.
def c_page_height(self, ruleset, sdict, rule, val)
Set height of box.
def s_draw_frame(self, tag, attrs)
A <draw:frame> is made into a in HTML which is then styled.
def s_office_document_content(self, tag, attrs)
First tag in the content.xml file.
def c_text_position(self, ruleset, sdict, rule, tp)
Text position.
def e_style_header(self, tag, attrs)