Commit 4ba48a45 authored by Jérome Perrin's avatar Jérome Perrin

support import of cell with styles, by using simpler xpath.

Thx nicolas for his xpath skills


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@24598 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 0a844b37
......@@ -446,13 +446,9 @@ class OOoParser(Implicit):
# Get the cell content
cell_text = None
text_tags = cell.xpath('.//*[name() = "text:p"]')
for text in text_tags:
for k in range(len(text.childNodes)):
child = text.childNodes[k]
if child.nodeType == Node.TEXT_NODE:
if cell_text == None:
cell_text = ''
cell_text += child.nodeValue
if len(text_tags):
cell_text = ''.join([text.xpath('string(.)')
for text in text_tags])
# Add the cell to the line
table_line.append(cell_text)
......
......@@ -325,6 +325,20 @@ class TestOOoImport(ERP5TypeTestCase):
mapping = parser.getSpreadsheetsMapping()
self.assertEquals(['Person'], mapping.keys())
def test_getSpreadSheetMappingStyle(self):
parser = OOoParser()
parser.openFile(open(makeFilePath('import_data_list_with_style.ods'), 'rb'))
mapping = parser.getSpreadsheetsMapping()
self.assertEquals(['Feuille1'], mapping.keys())
self.assertEquals(mapping['Feuille1'][1],
['a line with style'])
self.assertEquals(mapping['Feuille1'][2],
['a line with multiple styles'])
self.assertEquals(mapping['Feuille1'][3],
['http://www.erp5.org'])
self.assertEquals(mapping['Feuille1'][4],
['john.doe@example.com'])
def test_suite():
suite = unittest.TestSuite()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment