[Erp5-report] r24598 - in /erp5/trunk/products/ERP5OOo: ./ tests/ tests/test_document/

nobody at svn.erp5.org nobody at svn.erp5.org
Fri Nov 14 15:40:45 CET 2008


Author: jerome
Date: Fri Nov 14 15:40:34 2008
New Revision: 24598

URL: http://svn.erp5.org?rev=24598&view=rev
Log:
support import of cell with styles, by using simpler xpath.
Thx nicolas for his xpath skills

Added:
    erp5/trunk/products/ERP5OOo/tests/test_document/import_data_list_with_style.ods   (with props)
Modified:
    erp5/trunk/products/ERP5OOo/OOoUtils.py
    erp5/trunk/products/ERP5OOo/tests/testOOoImport.py

Modified: erp5/trunk/products/ERP5OOo/OOoUtils.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5OOo/OOoUtils.py?rev=24598&r1=24597&r2=24598&view=diff
==============================================================================
--- erp5/trunk/products/ERP5OOo/OOoUtils.py [utf8] (original)
+++ erp5/trunk/products/ERP5OOo/OOoUtils.py [utf8] Fri Nov 14 15:40:34 2008
@@ -446,13 +446,9 @@
             # 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)

Modified: erp5/trunk/products/ERP5OOo/tests/testOOoImport.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5OOo/tests/testOOoImport.py?rev=24598&r1=24597&r2=24598&view=diff
==============================================================================
--- erp5/trunk/products/ERP5OOo/tests/testOOoImport.py [utf8] (original)
+++ erp5/trunk/products/ERP5OOo/tests/testOOoImport.py [utf8] Fri Nov 14 15:40:34 2008
@@ -325,6 +325,20 @@
     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 at example.com'])
+
 
 def test_suite():
   suite = unittest.TestSuite()

Added: erp5/trunk/products/ERP5OOo/tests/test_document/import_data_list_with_style.ods
URL: http://svn.erp5.org/erp5/trunk/products/ERP5OOo/tests/test_document/import_data_list_with_style.ods?rev=24598&view=auto
==============================================================================
Binary file - no diff available.

Propchange: erp5/trunk/products/ERP5OOo/tests/test_document/import_data_list_with_style.ods
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream




More information about the Erp5-report mailing list