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 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():
288 method = self.ruleconversions.get(rule,
None )
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) )
312 item = self.stack.pop()
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):
541 self.htmlstack.append((tag,attrs,block))
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]
581 self.tagstack.push( tag, attrs )
584 stag, attrs = self.tagstack.pop()
586 method = self.elements.get(tag, (
None,
None) )[1]
626 c = attrs.get((TEXTNS,
'style-name'),
'')
627 c = c.replace(
".",
"_")
635 return self.anchors.get(name)
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")]
793 for c
in self.document.childnodes:
794 if c.folder == objhref:
801 class_id = attrs[(DRAWNS,
"class-id")]
802 if class_id
and class_id.lower() ==
"00020803-0000-0000-c000-000000000046":
803 tagattrs = {
'name':
'object_ole_graph',
'class':
'ole-graph' }
813 name = attrs.get( (DRAWNS,
'name'),
"NoName")
814 stylename = attrs.get( (DRAWNS,
'style-name'),
"")
815 stylename = stylename.replace(
".",
"_")
816 masterpage = attrs.get( (DRAWNS,
'master-page-name'),
"")
817 masterpage = masterpage.replace(
".",
"_")
819 self.
opentag(
'fieldset', {
'class':
"DP-%s MP-%s" % (stylename, masterpage) })
831 if (FONS,
"min-height")
in attrs:
832 style = style +
"min-height:" + attrs[(FONS,
"min-height")] +
";"
845 self.
opentag(
'style', {
'type':
"text/css"},
True)
852 self.
opentag(
'body', block=
True)
855 img { width: 100%; height: 100%; }
856 * { padding: 0; margin: 0; background-color:white; }
857 body { margin: 0 1em; }
858 ol, ul { padding-left: 2em; }
863 styles = self.styledict.get(name)
865 if '__style-family'in styles
and styles[
'__style-family']
in self.
styledict:
866 familystyle = self.
styledict[styles[
'__style-family']].copy()
867 del styles[
'__style-family']
868 for style, val
in styles.items():
869 familystyle[style] = val
872 while '__parent-style-name' in styles
and styles[
'__parent-style-name']
in self.
styledict:
873 parentstyle = self.
styledict[styles[
'__parent-style-name']].copy()
874 del styles[
'__parent-style-name']
875 for style, val
in styles.items():
876 parentstyle[style] = val
882 styles = self.styledict.get(name)
883 css2 = self.cs.convert_styles(styles)
885 for style, val
in css2.items():
886 self.
writeout(
"\t%s: %s;\n" % (style, val) )
893 self.
opentag(
'ol', {
'style':
'border-top: 1px solid black'},
True)
899 self.
opentag(
'li', {
'id':
"footnote-%d" % key })
908 if self.
xmlfile ==
'styles.xml':
916 self.
writeout(
'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" ')
917 self.
writeout(
'"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">\n')
918 self.
opentag(
'html', {
'xmlns':
"http://www.w3.org/1999/xhtml"},
True)
919 self.
opentag(
'head', block=
True)
920 self.
emptytag(
'meta', {
'http-equiv':
"Content-Type",
'content':
"text/html;charset=UTF-8"})
940 self.
styledict[
'p'] = {(FONS,
u'font-size'):
u"24pt" }
941 self.
styledict[
'presentation'] = {(FONS,
u'font-size'):
u"24pt" }
961 self.
styledict[
'frame'] = { (STYLENS,
'wrap'):
u'parallel'}
973 for key,attr
in attrs.items():
977 familymap = {
'frame':
'frame',
'paragraph':
'p',
'presentation':
'presentation',
978 'text':
'span',
'section':
'div',
979 'table':
'table',
'table-cell':
'td',
'table-column':
'col',
980 'table-row':
'tr',
'graphic':
'graphic' }
986 family = attrs[(STYLENS,
'family')]
987 htmlfamily = self.familymap.get(family,
'unknown')
1003 name = attrs[(STYLENS,
"name")]
1004 family = attrs[(SVGNS,
"font-family")]
1005 generic = attrs.get( (STYLENS,
'font-family-generic'),
"" )
1006 self.cs.save_font(name, family, generic)
1009 self.
opentag(
'div', {
'id':
"footer" })
1023 self.
opentag(
'div', {
'id':
"header" })
1050 name = attrs[(STYLENS,
'name')]
1051 name = name.replace(
".",
"_")
1066 name = attrs[(STYLENS,
'name')]
1067 name = name.replace(
".",
"_")
1073 pagelayout = attrs.get( (STYLENS,
'page-layout-name'),
None)
1075 pagelayout =
".PL-" + pagelayout
1078 for style, val
in styles.items():
1085 _familyshort = {
'drawing-page':
'DP',
'paragraph':
'P',
'presentation':
'PR',
1086 'text':
'S',
'section':
'D',
1087 'table':
'T',
'table-cell':
'TD',
'table-column':
'TC',
1088 'table-row':
'TR',
'graphic':
'G' }
1098 name = attrs[(STYLENS,
'name')]
1099 name = name.replace(
".",
"_")
1100 family = attrs[(STYLENS,
'family')]
1101 htmlfamily = self.familymap.get(family,
'unknown')
1102 sfamily = self._familyshort.get(family,
'X')
1103 name =
"%s%s-%s" % (self.
autoprefix, sfamily, name)
1104 parent = attrs.get( (STYLENS,
'parent-style-name') )
1114 parent =
"%s-%s" % (sfamily, parent)
1115 parent = special_styles.get(parent,
"."+parent)
1118 for style, val
in styles.items():
1133 c = attrs.get( (TABLENS,
'style-name'),
None)
1135 c = c.replace(
".",
"_")
1136 self.
opentag(
'table',{
'class':
"T-%s" % c })
1155 rowspan = attrs.get( (TABLENS,
'number-rows-spanned') )
1157 htmlattrs[
'rowspan'] = rowspan
1158 colspan = attrs.get( (TABLENS,
'number-columns-spanned') )
1160 htmlattrs[
'colspan'] = colspan
1162 c = attrs.get( (TABLENS,
'style-name') )
1164 htmlattrs[
'class'] =
'TD-%s' % c.replace(
".",
"_")
1178 c = attrs.get( (TABLENS,
'style-name'),
None)
1179 repeated = int(attrs.get( (TABLENS,
'number-columns-repeated'), 1))
1182 htmlattrs[
'class'] =
"TC-%s" % c.replace(
".",
"_")
1183 for x
in range(repeated):
1191 c = attrs.get( (TABLENS,
'style-name'),
None)
1194 htmlattrs[
'class'] =
"TR-%s" % c.replace(
".",
"_")
1209 href = attrs[(XLINKNS,
"href")].split(
"|")[0]
1212 self.
opentag(
'a', {
'href':href})
1225 name = attrs[(TEXTNS,
'name')]
1228 self.
opentag(
'span', {
'id':html_id})
1235 name = attrs[(TEXTNS,
'ref-name')]
1238 self.
opentag(
'a', {
'href':html_id})
1244 level = int(attrs[(TEXTNS,
'outline-level')])
1245 if level > 6: level = 6
1246 if level < 1: level = 1
1249 for x
in range(level + 1,10):
1251 special = special_styles.get(
"P-"+name)
1255 self.
opentag(
'h%s' % level, {
'class':
"P-%s" % name })
1265 level = int(attrs[(TEXTNS,
'outline-level')])
1266 if level > 6: level = 6
1267 if level < 1: level = 1
1269 outline =
'.'.join(map(str,lev) )
1270 heading =
''.join(self.
data)
1272 anchor = self.
get_anchor(
"%s.%s" % ( outline, heading))
1273 self.
opentag(
'a', {
'id': anchor} )
1291 name = attrs.get( (TEXTNS,
'style-name') )
1292 level = self.tagstack.count_tags(tag) + 1
1294 name = name.replace(
".",
"_")
1299 name = self.tagstack.rfindattr( (TEXTNS,
'style-name') )
1300 list_class =
"%s_%d" % (name, level)
1302 self.
opentag(
'%s' % self.listtypes.get(list_class,
'ul'), {
'class': list_class })
1304 self.
opentag(
'%s' % self.listtypes.get(list_class,
'ul'))
1311 name = attrs.get( (TEXTNS,
'style-name') )
1312 level = self.tagstack.count_tags(tag) + 1
1314 name = name.replace(
".",
"_")
1319 name = self.tagstack.rfindattr( (TEXTNS,
'style-name') )
1320 list_class =
"%s_%d" % (name, level)
1321 self.
closetag(self.listtypes.get(list_class,
'ul'))
1343 name = self.tagstack.rfindattr( (STYLENS,
'name') )
1344 level = attrs[(TEXTNS,
'level')]
1346 list_class =
"%s_%s" % (name, level)
1348 self.
currentstyle =
".%s_%s" % ( name.replace(
".",
"_"), level)
1353 listtype = (
"square",
"disc",
"circle")[level % 3]
1361 name = self.tagstack.stackparent()[(STYLENS,
'name')]
1362 level = attrs[(TEXTNS,
'level')]
1363 num_format = attrs.get( (STYLENS,
'name'),
"1")
1364 list_class =
"%s_%s" % (name, level)
1366 self.
currentstyle =
".%s_%s" % ( name.replace(
".",
"_"), level)
1370 if num_format ==
"1": listtype =
"decimal"
1371 elif num_format ==
"I": listtype =
"upper-roman"
1372 elif num_format ==
"i": listtype =
"lower-roman"
1373 elif num_format ==
"A": listtype =
"upper-alpha"
1374 elif num_format ==
"a": listtype =
"lower-alpha"
1375 else: listtype =
"decimal"
1394 self.notebody.append(s)
1407 mark =
''.join(self.
data)
1414 if sys.version_info[0]==3:
1427 c = attrs.get( (TEXTNS,
'style-name'),
None)
1429 c = c.replace(
".",
"_")
1430 specialtag = special_styles.get(
"P-"+c)
1431 if specialtag
is None:
1434 htmlattrs[
'class'] =
"P-%s" % c
1435 self.
opentag(specialtag, htmlattrs)
1443 c = attrs.get( (TEXTNS,
'style-name'),
None)
1445 c = c.replace(
".",
"_")
1446 specialtag = special_styles.get(
"P-"+c)
1447 if specialtag
is None:
1458 c = attrs.get( (TEXTNS,
'c'),
"1")
1459 for x
in range(int(c)):
1468 c = attrs.get( (TEXTNS,
'style-name'),
None)
1471 c = c.replace(
".",
"_")
1472 special = special_styles.get(
"S-"+c)
1474 htmlattrs[
'class'] =
"S-%s" % c
1475 self.
opentag(
'span', htmlattrs)
1523 assert(type(odffile)==type(
u"")
or 'rb' in repr(odffile)
or 'BufferedReader' in repr(odffile)
or 'BytesIO' in repr(odffile))
1527 if type(odffile)==type(
u""):
1533 def _walknode(self, node):
1534 if node.nodeType == Node.ELEMENT_NODE:
1536 for c
in node.childNodes:
1539 if node.nodeType == Node.TEXT_NODE
or node.nodeType == Node.CDATA_SECTION_NODE:
1540 if sys.version_info[0]==3:
1554 assert(type(odffile)==type(
u"")
or 'rb' in repr(odffile)
or 'BufferedReader' in repr(odffile)
or 'BytesIO' in repr(odffile))
1560 assert(type(result)==type(
u""))
1563 def _wlines(self,s):
1564 if s !=
'': self.lines.append(s)
1570 return ''.join(self.
lines)
1572 def _writecss(self, s):
1573 if s !=
'': self._csslines.append(s)
1575 def _writenothing(self, s):
1594 def save(self, outputfile, addsuffix=False):
1595 if outputfile ==
'-':
1596 outputfp = sys.stdout
1599 outputfile = outputfile +
".html"
1600 outputfp = file(outputfile,
"w")
1601 outputfp.write(self.
xhtml().encode(
'us-ascii',
'xmlcharrefreplace'))
1609 def __init__(self, lines, generate_css=True, embedable=False):
1633 (NUMBERNS,
"boolean-style"):(self.
s_ignorexml,
None),
1634 (NUMBERNS,
"currency-style"):(self.
s_ignorexml,
None),
1635 (NUMBERNS,
"date-style"):(self.
s_ignorexml,
None),
1636 (NUMBERNS,
"number-style"):(self.
s_ignorexml,
None),
1637 (NUMBERNS,
"text-style"):(self.
s_ignorexml,
None),
1648 (PRESENTATIONNS,
"notes"):(self.
s_ignorexml,
None),
1672 (TABLENS,
'covered-table-cell'): (self.
s_ignorexml,
None),
1679 (TEXTNS,
"bibliography-configuration"):(self.
s_ignorexml,
None),
1684 (TEXTNS,
"linenumbering-configuration"):(self.
s_ignorexml,
None),
1689 (TEXTNS,
"list-style"):(
None,
None),
1693 (TEXTNS,
"notes-configuration"):(self.
s_ignorexml,
None),
1696 (TEXTNS,
's'): (self.
s_text_s,
None),
1702 (TEXTNS,
"page-number"):(
None,
None),
def generate_stylesheet(self)
def opentag
Create an open HTML tag.
def s_style_default_page_layout(self, tag, attrs)
Collect the formatting for the default page layout style.
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 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 element.
def c_hp(self, ruleset, sdict, rule, hpos)
def unknown_endtag(self, tag, attrs)
def s_draw_image(self, tag, attrs)
A becomes an element.
def s_style_header(self, tag, attrs)
def html_body(self, tag, attrs)
def e_custom_shape(self, tag, attrs)
End the
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 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
def s_draw_object_ole(self, tag, attrs)
A 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
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 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 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
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
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 save
Save the HTML under the filename.
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 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
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 endElementNS(self, tag, qname)
The ODF2XHTML parses an ODF file and produces XHTML.
def s_custom_shape(self, tag, attrs)
A 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 closetag
Close an open HTML tag.
def generate_footnotes(self)
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 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 add_style_file
Add a link to an external style file.
def e_style_header(self, tag, attrs)