Commit 7cacfff4 authored by Tatuya Kamada's avatar Tatuya Kamada

just revert r26582



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@26602 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 7df1cfc7
......@@ -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
......@@ -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
......
......@@ -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):
"""
......
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