[Python-modules-commits] [python-odf] 74/118: Fixed a problem with lists that are mixed ordered and unordered
Wolfgang Borgert
debacle at moszumanska.debian.org
Fri Oct 3 21:27:24 UTC 2014
This is an automated email from the git hooks/post-receive script.
debacle pushed a commit to reference refs/remotes/upstream/master
in repository python-odf.
commit b27deca23b6832eb29a3219adf0745cbeb0f8865
Author: Søren Roug <soren.roug at eea.europa.eu>
Date: Mon Mar 1 21:42:54 2010 +0000
Fixed a problem with lists that are mixed ordered and unordered
---
odf/odf2xhtml.py | 20 +++++++++++---------
tests/examples/ol.odp | Bin 0 -> 14940 bytes
tests/testxhtml.py | 15 +++++++++++++++
3 files changed, 26 insertions(+), 9 deletions(-)
diff --git a/odf/odf2xhtml.py b/odf/odf2xhtml.py
index 7ebd354..6aaf165 100644
--- a/odf/odf2xhtml.py
+++ b/odf/odf2xhtml.py
@@ -1030,34 +1030,34 @@ class ODF2XHTML(handler.ContentHandler):
of <text:list> elements on the tagstack.
"""
name = attrs.get( (TEXTNS,'style-name') )
+ level = self.tagstack.count_tags(tag) + 1
if name:
name = name.replace(".","_")
- level = 1
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.
- level = self.tagstack.count_tags(tag) + 1
name = self.tagstack.rfindattr( (TEXTNS,'style-name') )
+ list_class = "%s_%d" % (name, level)
if self.generate_css:
- self.opentag('%s' % self.listtypes.get(name), {'class':"%s_%d" % (name, level) })
+ self.opentag('%s' % self.listtypes.get(list_class,'UL'), {'class': list_class })
else:
- self.opentag('%s' % self.listtypes.get(name))
+ self.opentag('%s' % self.listtypes.get(list_class,'UL'))
self.purgedata()
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(".","_")
- level = 1
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.
- level = self.tagstack.count_tags(tag) + 1
name = self.tagstack.rfindattr( (TEXTNS,'style-name') )
- self.closetag(self.listtypes.get(name))
+ list_class = "%s_%d" % (name, level)
+ self.closetag(self.listtypes.get(list_class,'UL'))
self.purgedata()
def s_text_list_item(self, tag, attrs):
@@ -1075,9 +1075,10 @@ class ODF2XHTML(handler.ContentHandler):
the available glyphs
"""
name = self.tagstack.rfindattr( (STYLENS,'name') )
- self.listtypes[name] = 'ul'
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] = {}
@@ -1092,11 +1093,12 @@ class ODF2XHTML(handler.ContentHandler):
def s_text_list_level_style_number(self, tag, attrs):
name = self.tagstack.stackparent()[(STYLENS,'name')]
- self.listtypes[name] = 'ol'
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"
diff --git a/tests/examples/ol.odp b/tests/examples/ol.odp
new file mode 100644
index 0000000..3ed5fea
Binary files /dev/null and b/tests/examples/ol.odp differ
diff --git a/tests/testxhtml.py b/tests/testxhtml.py
index 3ab126c..a48b192 100644
--- a/tests/testxhtml.py
+++ b/tests/testxhtml.py
@@ -153,6 +153,21 @@ class TestExampleDocs(unittest.TestCase):
assert has_rules(result,".L1_3","list-style-type: square;")
self.assertNotEqual(-1, result.find(u"""<p class="P-Standard">Line 1</p>\n<ul class="L1_1"><li><p class="P-P1">Item A</p>"""))
+ def test_mixedlist(self):
+ """ Check CSS has list styles """
+ simplelist_odt = os.path.join(
+ os.path.dirname(__file__), "examples", "ol.odp")
+ odhandler = ODF2XHTML()
+ result = odhandler.odf2xhtml(simplelist_odt)
+ assert has_rules(result,".L2_1","list-style-type: decimal;")
+ assert has_rules(result,".L2_2","list-style-type: circle;")
+ assert has_rules(result,".L2_3","list-style-type: square;")
+ assert has_rules(result,".L3_1","list-style-type: disc;")
+ assert has_rules(result,".L3_2","list-style-type: decimal;")
+ assert has_rules(result,".L3_3","list-style-type: square;")
+ self.assertNotEqual(-1, result.find(u"""<ol class="L2_1">"""))
+ self.assertNotEqual(-1, result.find(u"""<ol class="L3_2">"""))
+
def test_simpletable(self):
""" Check CSS has table styles """
simpletable_odt = os.path.join(
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-odf.git
More information about the Python-modules-commits
mailing list