Commit a42c9d20 authored by Tatuya Kamada's avatar Tatuya Kamada

Append a feature to enable setting a style name in a Table,

according as a listbox row CSS class name

TODO: write a test


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@26744 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 4b71b774
...@@ -686,7 +686,8 @@ class ODFStrategy(Implicit): ...@@ -686,7 +686,8 @@ class ODFStrategy(Implicit):
has_header_rows = len(table_header_rows_list) > 0 has_header_rows = len(table_header_rows_list) > 0
(row_top, row_middle, row_bottom) = self._copyRowStyle(table_row_list, (row_top, row_middle, row_bottom) = self._copyRowStyle(table_row_list,
has_header_rows=has_header_rows) has_header_rows=has_header_rows)
# create style-name and table-row dictionary if a reference name is set
style_name_row_dictionary = self._createStyleNameRowDictionary(table_row_list)
# clear original table # clear original table
parent_paragraph = target_table.getparent() parent_paragraph = target_table.getparent()
target_index = parent_paragraph.index(target_table) target_index = parent_paragraph.index(target_table)
...@@ -706,12 +707,16 @@ class ODFStrategy(Implicit): ...@@ -706,12 +707,16 @@ class ODFStrategy(Implicit):
last_index = len(listboxline_list) - 1 last_index = len(listboxline_list) - 1
for (index, listboxline) in enumerate(listboxline_list): for (index, listboxline) in enumerate(listboxline_list):
listbox_column_list = listboxline.getColumnItemList() listbox_column_list = listboxline.getColumnItemList()
row_style_name = listboxline.getRowCSSClassName()
if listboxline.isTitleLine() and not has_header_rows: if listboxline.isTitleLine() and not has_header_rows:
row = deepcopy(row_top) row = deepcopy(row_top)
row = self._updateColumnValue(row, listbox_column_list) row = self._updateColumnValue(row, listbox_column_list)
newtable.append(row) newtable.append(row)
is_top = False is_top = False
elif listboxline.isDataLine() and is_top: elif listboxline.isDataLine() and is_top:
if style_name_row_dictionary.has_key(row_style_name):
row = deepcopy(style_name_row_dictionary[row_style_name])
else:
row = deepcopy(row_top) row = deepcopy(row_top)
row = self._updateColumnValue(row, listbox_column_list) row = self._updateColumnValue(row, listbox_column_list)
newtable.append(row) newtable.append(row)
...@@ -721,6 +726,9 @@ class ODFStrategy(Implicit): ...@@ -721,6 +726,9 @@ class ODFStrategy(Implicit):
row = self._updateColumnStatValue(row, listbox_column_list, row_middle) row = self._updateColumnStatValue(row, listbox_column_list, row_middle)
newtable.append(row) newtable.append(row)
elif index > 0 and listboxline.isDataLine(): elif index > 0 and listboxline.isDataLine():
if style_name_row_dictionary.has_key(row_style_name):
row = deepcopy(style_name_row_dictionary[row_style_name])
else:
row = deepcopy(row_middle) row = deepcopy(row_middle)
row = self._updateColumnValue(row, listbox_column_list) row = self._updateColumnValue(row, listbox_column_list)
newtable.append(row) newtable.append(row)
...@@ -765,6 +773,17 @@ class ODFStrategy(Implicit): ...@@ -765,6 +773,17 @@ class ODFStrategy(Implicit):
removeOfficeAttribute(row_top) removeOfficeAttribute(row_top)
return (row_top, row_middle, row_bottom) return (row_top, row_middle, row_bottom)
def _createStyleNameRowDictionary(self, table_row_list=[]):
"""create stylename and table row dictionary if a style name reference is set"""
style_name_row_dictionary = {}
for table_row in table_row_list:
reference_element = table_row.find('.//*[@{%s}name]' % table_row.nsmap['text'])
if reference_element is not None:
name = reference_element.attrib['{%s}name' % table_row.nsmap['text']]
style_name_row_dictionary[name] = deepcopy(table_row)
return style_name_row_dictionary
def _updateColumnValue(self, row=None, listbox_column_list=[]): def _updateColumnValue(self, row=None, listbox_column_list=[]):
odf_cell_list = row.findall("{%s}table-cell" % row.nsmap['table']) odf_cell_list = row.findall("{%s}table-cell" % row.nsmap['table'])
odf_cell_list_size = len(odf_cell_list) odf_cell_list_size = len(odf_cell_list)
......
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