diff --git a/product/ERP5OOo/FormPrintout.py b/product/ERP5OOo/FormPrintout.py index 63de05cdb286b8b10cafe8e09afef9cc1fdf2dbb..0693511dc4c0c19899e3f4fe0a1992f98f55983c 100644 --- a/product/ERP5OOo/FormPrintout.py +++ b/product/ERP5OOo/FormPrintout.py @@ -777,11 +777,6 @@ class ODFStrategy(Implicit): column.remove(child) if first_child is not None: column.append(first_child) - # explicit table contents style setting - if isinstance(value, PrintoutStyleCell) and value.getStyleName() is not None: - style_attribute, original_style = self._getStyleAttributeTuple(first_child) - if style_attribute is not None: - first_child.set(style_attribute, value.getStyleName()) if column_value != '': value_attribute = self._getColumnValueAttribute(column) if value_attribute is not None: @@ -810,17 +805,17 @@ class ODFStrategy(Implicit): column_children = column.getchildren() for child in column_children: # clear data except style - style_attribute, style_value = self._getStyleAttributeTuple(child) + style_attribute_tuple = self._getStyleAttributeTuple(child) child.clear() - if style_attribute is not None: - child.set(style_attribute, style_value) + if style_attribute_tuple is not None: + child.set(style_attribute_tuple[0], style_attribute_tuple[1]) def _getStyleAttributeTuple(self, element): attrib = element.attrib for key in attrib.keys(): if key.endswith('style-name'): return (key, attrib[key]) - return (None, '') + return None def _getColumnValueAttribute(self, column): attrib = column.attrib @@ -866,28 +861,3 @@ class ODFStrategy(Implicit): class ODTStrategy(ODFStrategy): """ODTStrategy create a ODT Document from a form and a ODT template""" pass - -class PrintoutStyleCell: - """setting a style name of a table-content explicitly - - Note: experimentally implementation - """ - value = None - style_name = None - - def __init__(self, value=None, style_name=None): - self.value = value - self.style_name = style_name - - def __call__(self): - return self - - def __str__(self): - if self.value is None: return '' - elif isinstance(self.value, unicode) or isinstance(self.value, str): - return self.value - return str(self.value) - - def getStyleName(self): - return self.style_name - diff --git a/product/ERP5OOo/__init__.py b/product/ERP5OOo/__init__.py index 17b03a247c945046bea82961a50f3c17ebfc506c..bbe4e01090b7a1a65273684513510f1c194c6950 100644 --- a/product/ERP5OOo/__init__.py +++ b/product/ERP5OOo/__init__.py @@ -43,8 +43,6 @@ from AccessControl import ModuleSecurityInfo ModuleSecurityInfo('Products.ERP5OOo.OOoUtils').declarePublic('OOoParser',) ModuleSecurityInfo('Products.ERP5OOo.OOoUtils').declarePublic('newOOoParser',) -ModuleSecurityInfo('Products.ERP5OOo.FormPrintout').declarePublic('PrintoutStyleCell',) - # Define object classes and tools from OOoTemplate import OOoTemplate from FormPrintout import FormPrintout diff --git a/product/ERP5OOo/tests/testFormPrintout.py b/product/ERP5OOo/tests/testFormPrintout.py index 8a8b3ee68a05c377bb3be61b4670cbb4f317ea64..6a4728cde074ecd487ac15e71ec2c3cc0e45b7e1 100644 --- a/product/ERP5OOo/tests/testFormPrintout.py +++ b/product/ERP5OOo/tests/testFormPrintout.py @@ -578,76 +578,6 @@ class TestFormPrintout(ERP5TypeTestCase): # no rows self.assertEqual(len(odf_table_rows), 0) self._validate(odf_document) - - def test_02_Table_09_Explicit_Table_Content_Style(self, run=run_all_test): - if not run: return - # test target - test1 = self.portal.foo_module.test1 - foo_printout = test1.Foo_viewAsPrintout - foo_form = test1.Foo_view - listbox = foo_form.listbox - request = self.app.REQUEST - request['here'] = test1 - - foo_form.manage_renameObject('listbox', 'listbox2', REQUEST=request) - listbox2 = foo_form.listbox2 - test1.foo_1.setTitle('foo_title_9') - createZODBPythonScript( - self.portal.portal_skins.custom, - 'TestFoo_getFooWithStyleList', - '*args,**kw', -r""" -from Products.ERP5OOo.FormPrintout import PrintoutStyleCell -from Products.PythonScripts.standard import Object -foo_list = context.objectValues(portal_type='Foo Line') -foo_with_style_list = [] -for foo in foo_list: - o = Object(uid='new_', - id=foo.getId(), - title=foo.getTitle(), - quantity=PrintoutStyleCell(foo.getQuantity(), 'table-content-big') # explicit style - ) - foo_with_style_list.append(o) -return foo_with_style_list -""" - ) - message = listbox2.ListBox_setPropertyList( - field_list_method = 'TestFoo_getFooWithStyleList', - field_stat_method = 'portal_catalog', - field_stat_columns = 'quantity | Foo_statQuantity', - field_columns = 'id|ID\ntitle|Title\nquantity|Quantity',) - self.failUnless('Set Successfully' in message) - listboxline_list = listbox2.get_value('default', render_format = 'list', - REQUEST = request) - self.assertEqual(len(listboxline_list), 4) - self.assertTrue(listboxline_list[1].getColumnProperty('title') == "foo_title_9") - - odf_document = foo_printout.index_html(REQUEST=request) - - self.assertTrue(odf_document is not None) - test_output = open("/tmp/test_02_09_Table.odf", "w") - test_output.write(odf_document) - builder = OOoBuilder(odf_document) - content_xml = builder.extract("content.xml") - - self.assertTrue(content_xml.find("foo_title_9") > 0) - - content = etree.XML(content_xml) - table_row_xpath = '//table:table[@table:name="listbox2"]/table:table-row' - odf_table_rows = content.xpath(table_row_xpath, namespaces=content.nsmap) - self.assertEqual(len(odf_table_rows), 3) - # to test explicit style name - first_row = odf_table_rows[0] - first_row_columns = first_row.getchildren() - quantity_column = first_row_columns[2] - quantity_paragraph = quantity_column.getchildren()[0] - style_name_attrib = "{%s}style-name" % content.nsmap['text'] - self.assertTrue(quantity_paragraph.attrib.has_key(style_name_attrib)) - self.assertEqual(quantity_paragraph.attrib[style_name_attrib], 'table-content-big') - self._validate(odf_document) - - # put back the field name - foo_form.manage_renameObject('listbox2', 'listbox', REQUEST=request) def _test_03_Frame(self, run=run_all_test): """