Update bundled odfpy

This commit is contained in:
Kovid Goyal 2010-02-15 17:31:16 -07:00
parent c187c899ca
commit bd350e57ce
3 changed files with 43 additions and 4 deletions

View File

@ -165,6 +165,18 @@ class Node(xml.dom.Node):
oldChild.parentNode = None oldChild.parentNode = None
return oldChild return oldChild
def __str__(self):
val = []
for c in self.childNodes:
val.append(str(c))
return ''.join(val)
def __unicode__(self):
val = []
for c in self.childNodes:
val.append(unicode(c))
return u''.join(val)
defproperty(Node, "firstChild", doc="First child node, or None.") defproperty(Node, "firstChild", doc="First child node, or None.")
defproperty(Node, "lastChild", doc="Last child node, or None.") defproperty(Node, "lastChild", doc="Last child node, or None.")
@ -221,6 +233,9 @@ class Text(Childless, Node):
self.data = data self.data = data
def __str__(self): def __str__(self):
return self.data.encode()
def __unicode__(self):
return self.data return self.data
def toXml(self,level,f): def toXml(self,level,f):
@ -452,3 +467,9 @@ class Element(Node):
obj = element(check_grammar=False) obj = element(check_grammar=False)
return self._getElementsByObj(obj,[]) return self._getElementsByObj(obj,[])
def isInstanceOf(self, element):
""" This is a check to see if the object is an instance of a type """
obj = element(check_grammar=False)
return self.qname == obj.qname

View File

@ -4670,6 +4670,7 @@ allowed_attributes = {
(NUMBERNS,u'boolean-style'):( (NUMBERNS,u'boolean-style'):(
(NUMBERNS,u'transliteration-language'), (NUMBERNS,u'transliteration-language'),
(STYLENS,u'name'), (STYLENS,u'name'),
(STYLENS,u'display-name'),
(NUMBERNS,u'language'), (NUMBERNS,u'language'),
(NUMBERNS,u'title'), (NUMBERNS,u'title'),
(NUMBERNS,u'country'), (NUMBERNS,u'country'),
@ -4681,6 +4682,7 @@ allowed_attributes = {
(NUMBERNS,u'currency-style'):( (NUMBERNS,u'currency-style'):(
(NUMBERNS,u'transliteration-language'), (NUMBERNS,u'transliteration-language'),
(STYLENS,u'name'), (STYLENS,u'name'),
(STYLENS,u'display-name'),
(NUMBERNS,u'language'), (NUMBERNS,u'language'),
(NUMBERNS,u'title'), (NUMBERNS,u'title'),
(NUMBERNS,u'country'), (NUMBERNS,u'country'),
@ -4698,6 +4700,7 @@ allowed_attributes = {
(NUMBERNS,u'date-style'):( (NUMBERNS,u'date-style'):(
(NUMBERNS,u'transliteration-language'), (NUMBERNS,u'transliteration-language'),
(STYLENS,u'name'), (STYLENS,u'name'),
(STYLENS,u'display-name'),
(NUMBERNS,u'language'), (NUMBERNS,u'language'),
(NUMBERNS,u'title'), (NUMBERNS,u'title'),
(NUMBERNS,u'country'), (NUMBERNS,u'country'),
@ -4753,6 +4756,7 @@ allowed_attributes = {
(NUMBERNS,u'number-style'):( (NUMBERNS,u'number-style'):(
(NUMBERNS,u'transliteration-language'), (NUMBERNS,u'transliteration-language'),
(STYLENS,u'name'), (STYLENS,u'name'),
(STYLENS,u'display-name'),
(NUMBERNS,u'language'), (NUMBERNS,u'language'),
(NUMBERNS,u'title'), (NUMBERNS,u'title'),
(NUMBERNS,u'country'), (NUMBERNS,u'country'),
@ -4765,6 +4769,7 @@ allowed_attributes = {
(NUMBERNS,u'percentage-style'):( (NUMBERNS,u'percentage-style'):(
(NUMBERNS,u'transliteration-language'), (NUMBERNS,u'transliteration-language'),
(STYLENS,u'name'), (STYLENS,u'name'),
(STYLENS,u'display-name'),
(NUMBERNS,u'language'), (NUMBERNS,u'language'),
(NUMBERNS,u'title'), (NUMBERNS,u'title'),
(NUMBERNS,u'country'), (NUMBERNS,u'country'),
@ -4794,6 +4799,7 @@ allowed_attributes = {
(NUMBERNS,u'text-style'):( (NUMBERNS,u'text-style'):(
(NUMBERNS,u'transliteration-language'), (NUMBERNS,u'transliteration-language'),
(STYLENS,u'name'), (STYLENS,u'name'),
(STYLENS,u'display-name'),
(NUMBERNS,u'language'), (NUMBERNS,u'language'),
(NUMBERNS,u'title'), (NUMBERNS,u'title'),
(NUMBERNS,u'country'), (NUMBERNS,u'country'),
@ -4806,6 +4812,7 @@ allowed_attributes = {
(NUMBERNS,u'transliteration-language'), (NUMBERNS,u'transliteration-language'),
(NUMBERNS,u'transliteration-format'), (NUMBERNS,u'transliteration-format'),
(STYLENS,u'name'), (STYLENS,u'name'),
(STYLENS,u'display-name'),
(NUMBERNS,u'language'), (NUMBERNS,u'language'),
(NUMBERNS,u'title'), (NUMBERNS,u'title'),
(NUMBERNS,u'country'), (NUMBERNS,u'country'),

View File

@ -376,6 +376,8 @@ class ODF2XHTML(handler.ContentHandler):
(OFFICENS, "text"):(self.s_office_text, self.e_office_text), (OFFICENS, "text"):(self.s_office_text, self.e_office_text),
(OFFICENS, "scripts"):(self.s_ignorexml, None), (OFFICENS, "scripts"):(self.s_ignorexml, None),
(PRESENTATIONNS, "notes"):(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, "default-style"):(self.s_style_default_style, self.e_style_default_style),
(STYLENS, "drawing-page-properties"):(self.s_style_handle_properties, None), (STYLENS, "drawing-page-properties"):(self.s_style_handle_properties, None),
(STYLENS, "font-face"):(self.s_style_font_face, None), (STYLENS, "font-face"):(self.s_style_font_face, None),
@ -834,8 +836,17 @@ class ODF2XHTML(handler.ContentHandler):
self.stylestack.append(self.currentstyle) self.stylestack.append(self.currentstyle)
self.styledict[self.currentstyle] = {} self.styledict[self.currentstyle] = {}
def s_style_default_page_layout(self, tag, attrs):
""" Collect the formatting for the default page layout style.
"""
self.currentstyle = "@page"
self.stylestack.append(self.currentstyle)
self.styledict[self.currentstyle] = {}
def s_style_page_layout(self, tag, attrs): def s_style_page_layout(self, tag, attrs):
""" Collect the formatting for the page layout style. """ 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
""" """
name = attrs[(STYLENS,'name')] name = attrs[(STYLENS,'name')]
name = name.replace(".","_") name = name.replace(".","_")