add a "description" to a report style table and a style table cell

This commit is contained in:
Paul Franklin 2017-03-19 18:29:01 -07:00
parent be6780fa7d
commit 64690ea554
5 changed files with 55 additions and 12 deletions

View File

@ -108,13 +108,13 @@ class GraphicsStyle:
def set_description(self, text):
"""
Set the desciption of the graphics object
Set the description of the graphics object
"""
self.description = text
def get_description(self):
"""
Return the desciption of the graphics object
Return the description of the graphics object
"""
return self.description

View File

@ -108,13 +108,13 @@ class ParagraphStyle:
def set_description(self, text):
"""
Set the desciption of the paragraph
Set the description of the paragraph
"""
self.description = text
def get_description(self):
"""
Return the desciption of the paragraph
Return the description of the paragraph
"""
return self.description

View File

@ -7,6 +7,7 @@
# Copyright (C) 2009 Benny Malengier
# Copyright (C) 2009 Gary Burton
# Copyright (C) 2014 Nick Hall
# Copyright (C) 2017 Paul Franklin
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -185,7 +186,8 @@ class StyleSheetList:
# Write out style definition
xml_file.write(
' <style name="%s">\n' % escxml(p_name) +
' <font face="%d" ' % font.get_type_face() +
' <font ' +
'face="%d" ' % font.get_type_face() +
'size="%d" ' % font.get_size() +
'italic="%d" ' % font.get_italic() +
'bold="%d" ' % font.get_bold() +
@ -218,13 +220,15 @@ class StyleSheetList:
# Write out style definition
xml_file.write(
' <style name="%s">\n' % escxml(t_name) +
' <table width="%d" ' % t_style.get_width() +
' <table ' +
'description="%s" ' % escxml(t_style.get_description()) +
'width="%d" ' % t_style.get_width() +
'columns="%d"' % t_style.get_columns() +
'>\n')
for col in range(t_style.get_columns()):
column_width = t_style.get_column_width(col)
xml_file.write('<column width="%d" />\n' % column_width)
xml_file.write(' <column width="%d" />\n' % column_width)
xml_file.write(' </table>\n')
xml_file.write(' </style>\n')
@ -236,7 +240,9 @@ class StyleSheetList:
# Write out style definition
xml_file.write(
' <style name="%s">\n' % escxml(c_name) +
' <cell lborder="%d" ' % cell.get_left_border() +
' <cell ' +
'description="%s" ' % escxml(cell.get_description()) +
'lborder="%d" ' % cell.get_left_border() +
'rborder="%d" ' % cell.get_right_border() +
'tborder="%d" ' % cell.get_top_border() +
'bborder="%d" ' % cell.get_bottom_border() +
@ -252,8 +258,9 @@ class StyleSheetList:
# Write out style definition
xml_file.write(
' <style name="%s">\n' % escxml(g_name) +
' <draw para="%s" ' % draw.get_paragraph_style() +
' <draw ' +
'description="%s" ' % escxml(draw.get_description()) +
'para="%s" ' % draw.get_paragraph_style() +
'width="%.3f" ' % draw.get_line_width() +
'style="%d" ' % draw.get_line_style() +
'color="#%02x%02x%02x" ' % draw.get_color() +
@ -494,6 +501,8 @@ class SheetParser(handler.ContentHandler):
self.style_name = attrs['name']
elif tag == "table":
self.t = TableStyle()
if 'description' in attrs:
self.t.set_description(attrs['description'])
self.t.set_width(int(attrs['width']))
self.t.set_columns(int(attrs['columns']))
self.column_widths = []
@ -501,6 +510,8 @@ class SheetParser(handler.ContentHandler):
self.column_widths.append(int(attrs['width']))
elif tag == "cell":
self.c = TableCellStyle()
if 'description' in attrs:
self.c.set_description(attrs['description'])
self.c.set_left_border(int(attrs['lborder']))
self.c.set_right_border(int(attrs['rborder']))
self.c.set_top_border(int(attrs['tborder']))

View File

@ -67,10 +67,24 @@ class TableStyle:
self.width = obj.width
self.columns = obj.columns
self.colwid = obj.colwid[:]
self.description = obj.description
else:
self.width = 0
self.columns = 0
self.colwid = [ 0 ] * 100
self.description = ""
def set_description(self, text):
"""
Set the description of the table object
"""
self.description = text
def get_description(self):
"""
Return the description of the table object
"""
return self.description
def set_width(self, width):
"""
@ -151,6 +165,7 @@ class TableCellStyle:
self.bborder = obj.bborder
self.padding = obj.padding
self.longlist = obj.longlist
self.description = obj.description
else:
self.rborder = 0
self.lborder = 0
@ -158,6 +173,19 @@ class TableCellStyle:
self.bborder = 0
self.padding = 0
self.longlist = 0
self.description = ""
def set_description(self, text):
"""
Set the description of the table cell object
"""
self.description = text
def get_description(self):
"""
Return the description of the table cell object
"""
return self.description
def set_padding(self, val):
"Return the cell padding in centimeters"

View File

@ -5,7 +5,7 @@
# Copyright (C) 2007-2008 Brian G. Matherly
# Copyright (C) 2008 Peter Landgren
# Copyright (C) 2010 Jakim Friant
# Copyright (C) 2012 Paul Franklin
# Copyright (C) 2012,2017 Paul Franklin
# Copyright (C) 2014 Nick Hall
#
# This program is free software; you can redistribute it and/or modify
@ -359,7 +359,9 @@ class StyleEditor(ManagedWindow):
self.pname.set_text( '<span size="larger" weight="bold">%s</span>' %
self.current_name)
self.pname.set_use_markup(True)
self.pdescription.set_text(_("No description available") )
descr = c.get_description()
self.pdescription.set_text(descr or _("No description available"))
self.top.get_object("cell_lborder").set_active(c.get_left_border())
self.top.get_object("cell_rborder").set_active(c.get_right_border())
@ -375,7 +377,9 @@ class StyleEditor(ManagedWindow):
self.pname.set_text( '<span size="larger" weight="bold">%s</span>' %
self.current_name)
self.pname.set_use_markup(True)
self.pdescription.set_text(_("No description available") )
descr = t.get_description()
self.pdescription.set_text(descr or _("No description available"))
self.top.get_object("table_width").set_value(t.get_width())