Move Graphic Styles, Table Styles and Cell Styles into the StyleSheet class. All report styles are now defined in the "get_default_style()" function.
svn: r8421
This commit is contained in:
parent
4708a791a4
commit
3eebd910d5
32
ChangeLog
32
ChangeLog
@ -1,3 +1,35 @@
|
||||
2007-04-23 Brian Matherly <brian@gramps-project.org>
|
||||
* src/ReportBase/_ReportUtils.py:
|
||||
* src/ReportBase/_StyleEditor.py:
|
||||
* src/ReportBase/_Report.py:
|
||||
* src/plugins/DescendReport.py:
|
||||
* src/plugins/DetDescendantReport.py:
|
||||
* src/plugins/IndivComplete.py:
|
||||
* src/plugins/TimeLine.py:
|
||||
* src/plugins/AncestorReport.py:
|
||||
* src/plugins/DescendChart.py:
|
||||
* src/plugins/DetAncestralReport.py:
|
||||
* src/plugins/AncestorChart2.py:
|
||||
* src/plugins/IndivSummary.py:
|
||||
* src/plugins/FamilyGroup.py:
|
||||
* src/plugins/StatisticsChart.py:
|
||||
* src/plugins/FanChart.py:
|
||||
* src/BaseDoc.py:
|
||||
* src/docgen/HtmlDoc.py:
|
||||
* src/docgen/ODFDoc.py:
|
||||
* src/docgen/AbiWord2Doc.py:
|
||||
* src/docgen/PdfDoc.py:
|
||||
* src/docgen/SvgDrawDoc.py:
|
||||
* src/docgen/LaTeXDoc.py:
|
||||
* src/docgen/OpenOfficeDoc.py:
|
||||
* src/docgen/KwordDoc.py:
|
||||
* src/docgen/AsciiDoc.py:
|
||||
* src/docgen/RTFDoc.py:
|
||||
* src/docgen/LPRDoc.py:
|
||||
* src/docgen/PSDrawDoc.py:
|
||||
Move Graphic Styles, Table Styles and Cell Styles into the StyleSheet class.
|
||||
All report styles are now defined in the "get_default_style()" function.
|
||||
|
||||
2007-04-22 Brian Matherly <brian@gramps-project.org>
|
||||
* src/docgen/ODFDoc.py: escape still wasn't right. ancestor and descendant
|
||||
charts were wrong.
|
||||
|
204
src/BaseDoc.py
204
src/BaseDoc.py
@ -2,6 +2,8 @@
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2005 Donald N. Allingham
|
||||
# Copyright (C) 2002 Gary Shao
|
||||
# Copyright (C) 2007 Brian G. Matherly
|
||||
#
|
||||
# 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
|
||||
@ -18,38 +20,6 @@
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
# Modified September 2002 by Gary Shao
|
||||
#
|
||||
# Added line_break() method to BaseDoc class to allow breaking a line
|
||||
# in a paragraph (in those document generators that support it).
|
||||
#
|
||||
# Added start_listing() and end_listing() methods to BaseDoc class to
|
||||
# allow displaying text blocks without automatic filling and justification.
|
||||
# Creating a new listing element seems called for because many document
|
||||
# generator implementation have to use a different mechanism for text
|
||||
# that is not going to be automatically filled and justified than that
|
||||
# used for normal paragraphs. Examples are <pre> tags in HTML, using
|
||||
# the Verbatim environment in LaTeX, and using the Preformatted class
|
||||
# in reportlab for generating PDF.
|
||||
#
|
||||
# Added another option, FONT_MONOSPACE, for use as a font face. This
|
||||
# calls for a fixed-width font (e.g. Courier). It is intended primarily
|
||||
# for supporting the display of text where alignment by character position
|
||||
# may be important, such as in code source or column-aligned data.
|
||||
# Especially useful in styles for the new listing element discussed above.
|
||||
#
|
||||
# Added start_italic() and end_italic() methods to BaseDoc class to
|
||||
# complement the emphasis of text in a paragraph by bolding with the
|
||||
# ability to italicize segments of text in a paragraph.
|
||||
#
|
||||
# Added the show_link() method to BaseDoc to enable the creation of
|
||||
# hyperlinks in HTML output. Only produces active links in HTML, while
|
||||
# link will be represented as text in other generator output. (active
|
||||
# links are technically possible in PDF documents, but the reportlab
|
||||
# modules the PDF generator is based on does not support them at this
|
||||
# time)
|
||||
#
|
||||
|
||||
# $Id$
|
||||
|
||||
"""
|
||||
@ -928,8 +898,8 @@ class StyleSheetList:
|
||||
continue
|
||||
sheet = self.map[name]
|
||||
xml_file.write('<sheet name="%s">\n' % escxml(name))
|
||||
for p_name in sheet.get_names():
|
||||
para = sheet.get_style(p_name)
|
||||
for p_name in sheet.get_paragraph_style_names():
|
||||
para = sheet.get_paragraph_style(p_name)
|
||||
xml_file.write('<style name="%s">\n' % escxml(p_name))
|
||||
font = para.get_font()
|
||||
xml_file.write('<font face="%d" ' % font.get_type_face())
|
||||
@ -994,16 +964,30 @@ class StyleSheet:
|
||||
@param obj: if not None, creates the StyleSheet from the values in
|
||||
obj, instead of creating an empty StyleSheet
|
||||
"""
|
||||
self.style_list = {}
|
||||
self._para_styles = {}
|
||||
self._draw_styles = {}
|
||||
self._table_styles = {}
|
||||
self._cell_styles = {}
|
||||
self.name = ""
|
||||
if obj != None:
|
||||
for style_name in obj.style_list.keys():
|
||||
style = obj.style_list[style_name]
|
||||
self.style_list[style_name] = ParagraphStyle(style)
|
||||
for style_name in obj._para_styles.keys():
|
||||
style = obj._para_styles[style_name]
|
||||
self._para_styles[style_name] = ParagraphStyle(style)
|
||||
for style_name in obj._draw_styles.keys():
|
||||
style = obj._draw_styles[style_name]
|
||||
self._draw_styles[style_name] = GraphicsStyle(style)
|
||||
for style_name in obj._table_styles.keys():
|
||||
style = obj._table_styles[style_name]
|
||||
self._table_styles[style_name] = TableStyle(style)
|
||||
for style_name in obj._cell_styles.keys():
|
||||
style = obj._cell_styles[style_name]
|
||||
self._cell_styles[style_name] = TableCellStyle(style)
|
||||
|
||||
def set_name(self, name):
|
||||
"""
|
||||
Sets the name of the StyleSheet
|
||||
|
||||
@param name: The name to be given to the StyleSheet
|
||||
"""
|
||||
self.name = name
|
||||
|
||||
@ -1014,33 +998,95 @@ class StyleSheet:
|
||||
return self.name
|
||||
|
||||
def clear(self):
|
||||
"Removes all paragraph styles from the StyleSheet"
|
||||
self.style_list = {}
|
||||
"Removes all styles from the StyleSheet"
|
||||
self._para_styles = {}
|
||||
self._draw_styles = {}
|
||||
self._table_styles = {}
|
||||
self._cell_styles = {}
|
||||
|
||||
def add_style(self, name, style):
|
||||
def add_paragraph_style(self, name, style):
|
||||
"""
|
||||
Adds a paragraph style to the style sheet.
|
||||
|
||||
name - name of the ParagraphStyle
|
||||
style - ParagraphStyle instance to be added.
|
||||
@param name: The name of the ParagraphStyle
|
||||
@param style: ParagraphStyle instance to be added.
|
||||
"""
|
||||
self.style_list[name] = ParagraphStyle(style)
|
||||
|
||||
def get_names(self):
|
||||
"Returns the the list of paragraph names in the StyleSheet"
|
||||
return self.style_list.keys()
|
||||
|
||||
def get_styles(self):
|
||||
"Returns the paragraph name/ParagraphStyle map"
|
||||
return self.style_list
|
||||
|
||||
def get_style(self, name):
|
||||
self._para_styles[name] = ParagraphStyle(style)
|
||||
|
||||
def get_paragraph_style(self, name):
|
||||
"""
|
||||
Returns the ParagraphStyle associated with the name
|
||||
|
||||
name - name of the ParagraphStyle that is wanted
|
||||
@param name: name of the ParagraphStyle that is wanted
|
||||
"""
|
||||
return self.style_list[name]
|
||||
return ParagraphStyle(self._para_styles[name])
|
||||
|
||||
def get_paragraph_style_names(self):
|
||||
"Returns the the list of paragraph names in the StyleSheet"
|
||||
return self._para_styles.keys()
|
||||
|
||||
def add_draw_style(self, name, style):
|
||||
"""
|
||||
Adds a draw style to the style sheet.
|
||||
|
||||
@param name: The name of the GraphicsStyle
|
||||
@param style: GraphicsStyle instance to be added.
|
||||
"""
|
||||
self._draw_styles[name] = GraphicsStyle(style)
|
||||
|
||||
def get_draw_style(self, name):
|
||||
"""
|
||||
Returns the GraphicsStyle associated with the name
|
||||
|
||||
@param name: name of the GraphicsStyle that is wanted
|
||||
"""
|
||||
return GraphicsStyle(self._draw_styles[name])
|
||||
|
||||
def get_draw_style_names(self):
|
||||
"Returns the the list of draw style names in the StyleSheet"
|
||||
return self._draw_styles.keys()
|
||||
|
||||
def add_table_style(self, name, style):
|
||||
"""
|
||||
Adds a table style to the style sheet.
|
||||
|
||||
@param name: The name of the TableStyle
|
||||
@param style: TableStyle instance to be added.
|
||||
"""
|
||||
self._table_styles[name] = TableStyle(style)
|
||||
|
||||
def get_table_style(self, name):
|
||||
"""
|
||||
Returns the TableStyle associated with the name
|
||||
|
||||
@param name: name of the TableStyle that is wanted
|
||||
"""
|
||||
return TableStyle(self._table_styles[name])
|
||||
|
||||
def get_table_style_names(self):
|
||||
"Returns the the list of table style names in the StyleSheet"
|
||||
return self._table_styles.keys()
|
||||
|
||||
def add_cell_style(self, name, style):
|
||||
"""
|
||||
Adds a cell style to the style sheet.
|
||||
|
||||
@param name: The name of the TableCellStyle
|
||||
@param style: TableCellStyle instance to be added.
|
||||
"""
|
||||
self._cell_styles[name] = TableCellStyle(style)
|
||||
|
||||
def get_cell_style(self, name):
|
||||
"""
|
||||
Returns the TableCellStyle associated with the name
|
||||
|
||||
@param name: name of the TableCellStyle that is wanted
|
||||
"""
|
||||
return TableCellStyle(self._cell_styles[name])
|
||||
|
||||
def get_cell_style_names(self):
|
||||
"Returns the the list of cell style names in the StyleSheet"
|
||||
return self._cell_styles.keys()
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -1112,7 +1158,7 @@ class SheetParser(handler.ContentHandler):
|
||||
"Overridden class that handles the start of a XML element"
|
||||
if tag == "style":
|
||||
self.p.set_font(self.f)
|
||||
self.s.add_style(self.pname, self.p)
|
||||
self.s.add_paragraph_style(self.pname, self.p)
|
||||
elif tag == "sheet":
|
||||
self.sheetlist.set_style_sheet(self.sname, self.s)
|
||||
|
||||
@ -1229,23 +1275,17 @@ class BaseDoc:
|
||||
interface. This class should never be instantiated directly, but
|
||||
only through a derived class.
|
||||
|
||||
@param styles: StyleSheet containing the paragraph styles used.
|
||||
@param paper_type: PaperSize instance containing information about
|
||||
@param styles: StyleSheet containing the styles used.
|
||||
@param paper_style: PaperStyle instance containing information about
|
||||
the paper. If set to None, then the document is not a page
|
||||
oriented document (e.g. HTML)
|
||||
@param template: Format template for document generators that are
|
||||
not page oriented.
|
||||
@param orientation: page orientation, either PAPER_PORTRAIT or
|
||||
PAPER_LANDSCAPE
|
||||
"""
|
||||
self.template = template
|
||||
self.paper = paper_style
|
||||
self.title = ""
|
||||
|
||||
self.draw_styles = {}
|
||||
self.style_list = styles.get_styles()
|
||||
self.table_styles = {}
|
||||
self.cell_styles = {}
|
||||
self._style_sheet = styles
|
||||
self.name = ""
|
||||
self.print_req = 0
|
||||
self.init_called = False
|
||||
@ -1299,33 +1339,21 @@ class BaseDoc:
|
||||
@param name: Title of the document
|
||||
"""
|
||||
self.title = name
|
||||
|
||||
def add_draw_style(self, name, style):
|
||||
self.draw_styles[name] = GraphicsStyle(style)
|
||||
|
||||
def get_draw_style(self, name):
|
||||
return self.draw_styles[name]
|
||||
|
||||
def get_style(self, name):
|
||||
return self.style_list[name]
|
||||
|
||||
def add_table_style(self, name, style):
|
||||
|
||||
def get_style_sheet(self):
|
||||
"""
|
||||
Adds the TableStyle with the specfied name.
|
||||
|
||||
@param name: name of the table style
|
||||
@param style: TableStyle instance to be added
|
||||
Returns the StyleSheet of the document.
|
||||
"""
|
||||
self.table_styles[name] = TableStyle(style)
|
||||
|
||||
def add_cell_style(self, name, style):
|
||||
return StyleSheet(self._style_sheet)
|
||||
|
||||
def set_style_sheet(self,style_sheet):
|
||||
"""
|
||||
Adds the TableCellStyle with the specfied name.
|
||||
Sets the StyleSheet of the document.
|
||||
|
||||
@param name: name of the table cell style
|
||||
@param style: TableCellStyle instance to be added
|
||||
@param style_sheet: The new style sheet for the document
|
||||
@type style_sheet: StyleSheet
|
||||
"""
|
||||
self.cell_styles[name] = TableCellStyle(style)
|
||||
self._style_sheet = StyleSheet(style_sheet)
|
||||
|
||||
def open(self, filename):
|
||||
"""
|
||||
|
@ -3,6 +3,7 @@
|
||||
#
|
||||
# Copyright (C) 2001 David R. Hampton
|
||||
# Copyright (C) 2001-2006 Donald N. Allingham
|
||||
# Copyright (C) 2007 Brian G. Matherly
|
||||
#
|
||||
# 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
|
||||
@ -64,9 +65,6 @@ class Report:
|
||||
self.doc.open(options_class.get_output())
|
||||
else:
|
||||
self.standalone = False
|
||||
|
||||
self.define_table_styles()
|
||||
self.define_graphics_styles()
|
||||
|
||||
def begin_report(self):
|
||||
pass
|
||||
@ -77,15 +75,4 @@ class Report:
|
||||
def end_report(self):
|
||||
if self.standalone:
|
||||
self.doc.close()
|
||||
|
||||
def define_table_styles(self):
|
||||
"""
|
||||
This method MUST be used for adding table and cell styles.
|
||||
"""
|
||||
pass
|
||||
|
||||
def define_graphics_styles(self):
|
||||
"""
|
||||
This method MUST be used for adding drawing styles.
|
||||
"""
|
||||
pass
|
||||
|
@ -2,6 +2,7 @@
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2006 Donald N. Allingham
|
||||
# Copyright (C) 2007 Brian G. Matherly
|
||||
#
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
@ -977,17 +978,20 @@ def draw_legend(doc, start_x, start_y, data, title, label_style):
|
||||
legend_description).
|
||||
@type data: list
|
||||
"""
|
||||
style_sheet = doc.get_style_sheet()
|
||||
if title:
|
||||
gstyle = doc.get_draw_style(label_style)
|
||||
pstyle = gstyle.get_paragraph_style()
|
||||
size = pt2cm(doc.get_style(pstyle).get_font().get_size())
|
||||
gstyle = style_sheet.get_draw_style(label_style)
|
||||
pstyle_name = gstyle.get_paragraph_style()
|
||||
pstyle = style_sheet.get_paragraph_style(pstyle_name)
|
||||
size = pt2cm(pstyle.get_font().get_size())
|
||||
doc.draw_text(label_style, title, start_x + (3*size), start_y - (size*0.25))
|
||||
start_y += size * 1.3
|
||||
|
||||
for (format, size, legend) in data:
|
||||
gstyle = doc.get_draw_style(format)
|
||||
pstyle = gstyle.get_paragraph_style()
|
||||
size = pt2cm(doc.get_style(pstyle).get_font().get_size())
|
||||
gstyle = style_sheet.get_draw_style(format)
|
||||
pstyle_name = gstyle.get_paragraph_style()
|
||||
pstyle = style_sheet.get_paragraph_style(pstyle_name)
|
||||
size = pt2cm(pstyle.get_font().get_size())
|
||||
doc.draw_box(format, "", start_x, start_y, (2*size), size)
|
||||
doc.draw_text(label_style, legend, start_x + (3*size), start_y - (size*0.25))
|
||||
start_y += size * 1.3
|
||||
|
@ -2,6 +2,7 @@
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2005 Donald N. Allingham
|
||||
# Copyright (C) 2007 Brian G. Matherly
|
||||
#
|
||||
# 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
|
||||
@ -181,8 +182,9 @@ class StyleEditor:
|
||||
style - style object that is to be edited
|
||||
parent - StyleListDisplay object that called the editor
|
||||
"""
|
||||
self.current_p = None
|
||||
self.current_name = None
|
||||
|
||||
self.original_style = style
|
||||
self.style = BaseDoc.StyleSheet(style)
|
||||
self.parent = parent
|
||||
self.top = gtk.glade.XML(const.gladeFile,"editor","gramps")
|
||||
@ -210,10 +212,10 @@ class StyleEditor:
|
||||
self.top.get_widget('bgcolor').connect('color-set',self.bg_color_set)
|
||||
self.top.get_widget("style_name").set_text(name)
|
||||
|
||||
names = self.style.get_names()
|
||||
names = self.style.get_paragraph_style_names()
|
||||
names.reverse()
|
||||
for p_name in names:
|
||||
self.plist.add([p_name],self.style.get_style(p_name))
|
||||
self.plist.add([p_name],self.style.get_paragraph_style(p_name))
|
||||
self.plist.select_row(0)
|
||||
|
||||
if self.parent:
|
||||
@ -221,12 +223,12 @@ class StyleEditor:
|
||||
self.window.run()
|
||||
self.window.destroy()
|
||||
|
||||
def draw(self,name,p):
|
||||
def draw(self):
|
||||
"""Updates the display with the selected paragraph."""
|
||||
|
||||
self.current_p = p
|
||||
|
||||
self.pname.set_text('<span size="larger" weight="bold">%s</span>' % name)
|
||||
p = self.current_p
|
||||
self.pname.set_text( '<span size="larger" weight="bold">%s</span>' %
|
||||
self.current_name )
|
||||
self.pname.set_use_markup(True)
|
||||
|
||||
descr = p.get_description()
|
||||
@ -283,9 +285,9 @@ class StyleEditor:
|
||||
self.fg_color = (c.red >> 8, c.green >> 8, c.blue >> 8)
|
||||
self.top.get_widget('color_code').set_text("#%02X%02X%02X" % self.fg_color)
|
||||
|
||||
def save_paragraph(self,p):
|
||||
def save_paragraph(self):
|
||||
"""Saves the current paragraph displayed on the dialog"""
|
||||
|
||||
p = self.current_p
|
||||
font = p.get_font()
|
||||
font.set_size(self.top.get_widget("size").get_value_as_int())
|
||||
|
||||
@ -319,16 +321,17 @@ class StyleEditor:
|
||||
|
||||
font.set_color(self.fg_color)
|
||||
p.set_background_color(self.bg_color)
|
||||
|
||||
self.style.add_paragraph_style(self.current_name,self.current_p)
|
||||
|
||||
def on_save_style_clicked(self,obj):
|
||||
"""
|
||||
Saves the current style sheet and causes the parent to be updated with
|
||||
the changes.
|
||||
"""
|
||||
p = self.current_p
|
||||
name = unicode(self.top.get_widget("style_name").get_text())
|
||||
|
||||
self.save_paragraph(p)
|
||||
self.save_paragraph()
|
||||
self.style.set_name(name)
|
||||
self.parent.sheetlist.set_style_sheet(name,self.style)
|
||||
self.parent.redraw()
|
||||
@ -340,10 +343,10 @@ class StyleEditor:
|
||||
|
||||
objs = self.plist.get_selected_objects()
|
||||
store,node = self.plist.get_selected()
|
||||
name = store.get_value(node,0)
|
||||
self.current_name = store.get_value(node,0)
|
||||
if self.first == 0:
|
||||
self.save_paragraph(self.current_p)
|
||||
self.save_paragraph()
|
||||
else:
|
||||
self.first = 0
|
||||
self.current_p = objs[0]
|
||||
self.draw(name,self.current_p)
|
||||
self.draw()
|
||||
|
@ -2,6 +2,7 @@
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2006 Donald N. Allingham
|
||||
# Copyright (C) 2007 Brian G. Matherly
|
||||
#
|
||||
# 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
|
||||
@ -121,8 +122,9 @@ class AbiWordDoc(BaseDoc.BaseDoc):
|
||||
|
||||
def write_styles(self):
|
||||
self.f.write('<styles>\n')
|
||||
for style_name in self.style_list.keys():
|
||||
style = self.style_list[style_name]
|
||||
styles = self.get_style_sheet()
|
||||
for style_name in styles.get_paragraph_style_names():
|
||||
style = styles.get_paragraph_style(style_name)
|
||||
self.current_style = style
|
||||
self.f.write('<s type="P" name="%s" basedon="" followedby="" props="' % style_name)
|
||||
self.f.write('margin-top:%.4fin; ' % (float(style.get_top_margin())/2.54))
|
||||
@ -232,7 +234,8 @@ class AbiWordDoc(BaseDoc.BaseDoc):
|
||||
|
||||
def start_paragraph(self,style_name,leader=None):
|
||||
self.in_paragraph = 1
|
||||
style = self.style_list[style_name]
|
||||
styles = self.get_style_sheet()
|
||||
style = styles.get_paragraph_style(style_name)
|
||||
self.current_style = style
|
||||
self.f.write('<p style="%s">' % style_name)
|
||||
if self.new_page == 1:
|
||||
@ -280,7 +283,8 @@ class AbiWordDoc(BaseDoc.BaseDoc):
|
||||
|
||||
def start_table(self,name,style_name):
|
||||
self.in_table = 1
|
||||
self.tblstyle = self.table_styles[style_name]
|
||||
styles = self.get_style_sheet()
|
||||
self.tblstyle = styles.get_table_style(style_name)
|
||||
self.f.write('<table props="table-column-props:')
|
||||
width = float(self.get_usable_width())
|
||||
for col in range(0,self.tblstyle.get_columns()):
|
||||
@ -301,7 +305,8 @@ class AbiWordDoc(BaseDoc.BaseDoc):
|
||||
pass
|
||||
|
||||
def start_cell(self,style_name,span=1):
|
||||
self.cstyle = self.cell_styles[style_name]
|
||||
styles = self.get_style_sheet()
|
||||
self.cstyle = styles.get_cell_style(style_name)
|
||||
self.f.write('<cell props="')
|
||||
if not self.cstyle.get_top_border():
|
||||
self.f.write('top-style:0; top-style:0;')
|
||||
|
@ -2,6 +2,7 @@
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2006 Donald N. Allingham
|
||||
# Copyright (C) 2007 Brian G. Matherly
|
||||
#
|
||||
# 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
|
||||
@ -197,7 +198,8 @@ class AsciiDoc(BaseDoc.BaseDoc):
|
||||
#
|
||||
#--------------------------------------------------------------------
|
||||
def start_paragraph(self,style_name,leader=None):
|
||||
self.p = self.style_list[style_name]
|
||||
styles = self.get_style_sheet()
|
||||
self.p = styles.get_paragraph_style(style_name)
|
||||
self.leader = leader
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
@ -267,7 +269,8 @@ class AsciiDoc(BaseDoc.BaseDoc):
|
||||
#
|
||||
#--------------------------------------------------------------------
|
||||
def start_table(self,name,style_name):
|
||||
self.tbl_style = self.table_styles[style_name]
|
||||
styles = self.get_style_sheet()
|
||||
self.tbl_style = styles.get_table_style(style_name)
|
||||
self.ncols = self.tbl_style.get_columns()
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
|
@ -2,6 +2,7 @@
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2006 Donald N. Allingham
|
||||
# Copyright (C) 2007 Brian G. Matherly
|
||||
#
|
||||
# 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
|
||||
@ -260,10 +261,12 @@ class HtmlDoc(BaseDoc.BaseDoc):
|
||||
self.file_header = self.process_line(self.file_header)
|
||||
|
||||
def build_style_declaration(self):
|
||||
styles = self.get_style_sheet()
|
||||
|
||||
text = ['<style type="text/css">\n<!--']
|
||||
for key in self.cell_styles.keys():
|
||||
style = self.cell_styles[key]
|
||||
|
||||
|
||||
for sname in styles.get_cell_style_names():
|
||||
style = styles.get_cell_style(sname)
|
||||
pad = "%.3fcm" % style.get_padding()
|
||||
top = bottom = left = right = 'none'
|
||||
if style.get_top_border():
|
||||
@ -278,10 +281,11 @@ class HtmlDoc(BaseDoc.BaseDoc):
|
||||
'\tpadding: %s %s %s %s;\n'
|
||||
'\tborder-top:%s; border-bottom:%s;\n'
|
||||
'\tborder-left:%s; border-right:%s;\n}'
|
||||
% (key, pad, pad, pad, pad, top, bottom, left, right))
|
||||
% (sname, pad, pad, pad, pad, top, bottom, left, right))
|
||||
|
||||
for key in self.style_list.keys():
|
||||
style = self.style_list[key]
|
||||
|
||||
for style_name in styles.get_paragraph_style_names():
|
||||
style = styles.get_paragraph_style(style_name)
|
||||
font = style.get_font()
|
||||
font_size = font.get_size()
|
||||
font_color = '#%02x%02x%02x' % font.get_color()
|
||||
@ -320,7 +324,7 @@ class HtmlDoc(BaseDoc.BaseDoc):
|
||||
'\tborder-top:%s; border-bottom:%s;\n'
|
||||
'\tborder-left:%s; border-right:%s;\n'
|
||||
'\t%s%sfont-family:%s;\n}'
|
||||
% (key, font_size, font_color,
|
||||
% (style_name, font_size, font_color,
|
||||
align, text_indent,
|
||||
right_margin, left_margin,
|
||||
top_margin, bottom_margin,
|
||||
@ -400,7 +404,8 @@ class HtmlDoc(BaseDoc.BaseDoc):
|
||||
% (refname,size_str,size,alt,xtra))
|
||||
|
||||
def start_table(self,name,style):
|
||||
self.tbl = self.table_styles[style]
|
||||
styles = self.get_style_sheet()
|
||||
self.tbl = styles.get_table_style(style)
|
||||
self.f.write('<table width="%d%%" ' % self.tbl.get_width())
|
||||
self.f.write('cellspacing="0">\n')
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2006 Donald N. Allingham
|
||||
# Copyright (C) 2007 Brian G. Matherly
|
||||
#
|
||||
# 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
|
||||
@ -183,11 +184,12 @@ class KwordDoc(BaseDoc.BaseDoc):
|
||||
self.f.write('</FRAMESET>\n')
|
||||
self.f.write('</FRAMESETS>\n')
|
||||
self.f.write('<STYLES>\n')
|
||||
for name in self.style_list.keys():
|
||||
style_sheet = self.get_style_sheet()
|
||||
for name in style_sheet.get_paragraph_style_names():
|
||||
self.f.write('<STYLE>\n')
|
||||
self.f.write('<NAME value="%s"/>\n' % name)
|
||||
|
||||
p = self.style_list[name]
|
||||
p = style_sheet.get_paragraph_style(name)
|
||||
|
||||
tpad = points(p.get_top_margin())
|
||||
bpad = points(p.get_bottom_margin())
|
||||
@ -299,7 +301,8 @@ class KwordDoc(BaseDoc.BaseDoc):
|
||||
self.bold_start = 0
|
||||
self.text = ""
|
||||
self.style_name = style_name
|
||||
self.p = self.style_list[self.style_name]
|
||||
style_sheet = self.get_style_sheet()
|
||||
self.p = style_sheet.get_paragraph_style(self.style_name)
|
||||
self.font = self.p.get_font()
|
||||
if self.font.get_type_face() == BaseDoc.FONT_SERIF:
|
||||
self.font_face = "Bitstream Vera Serif"
|
||||
@ -402,7 +405,8 @@ class KwordDoc(BaseDoc.BaseDoc):
|
||||
self.format_list.append(txt)
|
||||
|
||||
def start_table(self,name,style_name):
|
||||
self.tbl= self.table_styles[style_name]
|
||||
styles = self.get_style_sheet()
|
||||
self.tbl = styles.get_table_style(style_name)
|
||||
self.cell_left= (self.paper.get_left_margin() * 72)/ 2.54
|
||||
self.tbl_width= ((self.paper.get_size().get_width() - self.paper.get_left_margin() - self.paper.get_right_margin()) * 72 ) / 2.54
|
||||
if self.frameset_flg == 1:
|
||||
|
@ -2,6 +2,7 @@
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2006 Donald N. Allingham
|
||||
# Copyright (C) 2007 Brian G. Matherly
|
||||
#
|
||||
# Modifications and feature additions:
|
||||
# 2002 Donald A. Peterson
|
||||
@ -594,7 +595,9 @@ class LPRDoc(BaseDoc.BaseDoc):
|
||||
single body of text, from a single word, to several sentences.
|
||||
We assume a linebreak at the end of each paragraph."""
|
||||
# Instantiate paragraph object and initialize buffers
|
||||
self.paragraph = GnomePrintParagraph(self.style_list[style_name])
|
||||
style_sheet = self.get_style_sheet()
|
||||
style = style_sheet.get_paragraph_style(style_name)
|
||||
self.paragraph = GnomePrintParagraph(style)
|
||||
if leader:
|
||||
append_to_paragraph(self.paragraph,"",leader)
|
||||
self.paragraph_directive = _POSTLEADER
|
||||
@ -656,7 +659,8 @@ class LPRDoc(BaseDoc.BaseDoc):
|
||||
# initialize table, compute its width, find number of columns
|
||||
self.table_data = []
|
||||
self.in_table = 1
|
||||
self.tbl_style = self.table_styles[style_name]
|
||||
styles = self.get_style_sheet()
|
||||
self.tbl_style = styles.get_table_style(style_name)
|
||||
self.ncols = self.tbl_style.get_columns()
|
||||
self.rownum = -1
|
||||
self.table_width = (self.right_margin - self.left_margin) * \
|
||||
@ -701,8 +705,9 @@ class LPRDoc(BaseDoc.BaseDoc):
|
||||
self.cell_data = []
|
||||
self.cellnum = self.cellnum + self.span
|
||||
self.span = span
|
||||
self.gp_cell_styles[self.rownum][self.cellnum] = \
|
||||
self.cell_styles[style_name]
|
||||
styles = self.get_style_sheet()
|
||||
cstyle = styles.get_cell_style(style_name)
|
||||
self.gp_cell_styles[self.rownum][self.cellnum] = cstyle
|
||||
for extra_cell in range(1,span):
|
||||
self.cell_widths[self.rownum][self.cellnum] += \
|
||||
self.cell_widths[self.rownum][self.cellnum + extra_cell]
|
||||
@ -1021,7 +1026,8 @@ class LPRDoc(BaseDoc.BaseDoc):
|
||||
|
||||
def draw_path(self,style,path):
|
||||
self.brand_new_page = 0
|
||||
stype = self.draw_styles[style]
|
||||
style_sheet = self.get_style_sheet()
|
||||
stype = style_sheet.get_draw_style(style)
|
||||
self.gpc.setlinewidth(stype.get_line_width())
|
||||
fill_color = rgb_color(stype.get_fill_color())
|
||||
color = rgb_color(stype.get_color())
|
||||
@ -1058,12 +1064,13 @@ class LPRDoc(BaseDoc.BaseDoc):
|
||||
|
||||
def draw_box(self,style,text,x,y, w, h):
|
||||
#assuming that we start drawing box from current position
|
||||
style_sheet = self.get_style_sheet()
|
||||
|
||||
self.brand_new_page = 0
|
||||
x = self.left_margin + cm2u(x)
|
||||
y = self.top_margin - cm2u(y)
|
||||
|
||||
box_style = self.draw_styles[style]
|
||||
box_style = style_sheet.get_draw_style(style)
|
||||
bh = cm2u(h)
|
||||
bw = cm2u(w)
|
||||
|
||||
@ -1088,7 +1095,7 @@ class LPRDoc(BaseDoc.BaseDoc):
|
||||
|
||||
if text:
|
||||
para_name = box_style.get_paragraph_style()
|
||||
para_style = self.style_list[para_name]
|
||||
para_style = style_sheet.get_paragraph_style(para_name)
|
||||
fontstyle = para_style.get_font()
|
||||
lines = text.split('\n')
|
||||
start_x = x + 0.5 * fontstyle.get_size()
|
||||
@ -1103,9 +1110,10 @@ class LPRDoc(BaseDoc.BaseDoc):
|
||||
|
||||
def draw_text(self,style,text,x,y):
|
||||
self.brand_new_page = 0
|
||||
box_style = self.draw_styles[style]
|
||||
style_sheet = self.get_style_sheet()
|
||||
box_style = style_sheet.get_draw_style(style)
|
||||
para_name = box_style.get_paragraph_style()
|
||||
para_style = self.style_list[para_name]
|
||||
para_style = style_sheet.get_paragraph_style(para_name)
|
||||
fontstyle = para_style.get_font()
|
||||
|
||||
start_x = self.left_margin + cm2u(x)
|
||||
@ -1117,9 +1125,10 @@ class LPRDoc(BaseDoc.BaseDoc):
|
||||
|
||||
def center_text(self,style,text,x,y):
|
||||
self.brand_new_page = 0
|
||||
box_style = self.draw_styles[style]
|
||||
style_sheet = self.get_style_sheet()
|
||||
box_style = style_sheet.get_draw_style(style)
|
||||
para_name = box_style.get_paragraph_style()
|
||||
para_style = self.style_list[para_name]
|
||||
para_style = style_sheet.get_paragraph_style(para_name)
|
||||
fontstyle = para_style.get_font()
|
||||
|
||||
width = get_text_width(text,fontstyle)
|
||||
@ -1136,9 +1145,10 @@ class LPRDoc(BaseDoc.BaseDoc):
|
||||
if not support_photos:
|
||||
return
|
||||
# end FIXME
|
||||
box_style = self.draw_styles[style]
|
||||
style_sheet = self.get_style_sheet()
|
||||
box_style = style_sheet.get_draw_style(style)
|
||||
para_name = box_style.get_paragraph_style()
|
||||
para_style = self.style_list[para_name]
|
||||
para_style = style_sheet.get_paragraph_style(para_name)
|
||||
fontstyle = para_style.get_font()
|
||||
|
||||
y_start = self.top_margin - cm2u(y)
|
||||
|
@ -2,6 +2,7 @@
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2006 Donald N. Allingham
|
||||
# Copyright (C) 2007 Brian G. Matherly
|
||||
#
|
||||
# Modifications and feature additions:
|
||||
# 2002-2003 Donald A. Peterson
|
||||
@ -220,75 +221,76 @@ class LaTeXDoc(BaseDoc.BaseDoc):
|
||||
self.latexstyle = {}
|
||||
self.latex_font = {}
|
||||
|
||||
for style_name in self.style_list.keys():
|
||||
style = self.style_list[style_name]
|
||||
font = style.get_font()
|
||||
size = font.get_size()
|
||||
style_sheet = self.get_style_sheet()
|
||||
for style_name in style_sheet.get_paragraph_style_names():
|
||||
style = style_sheet.get_paragraph_style(style_name)
|
||||
font = style.get_font()
|
||||
size = font.get_size()
|
||||
|
||||
self.latex_font[style_name] = TexFont()
|
||||
thisstyle = self.latex_font[style_name]
|
||||
self.latex_font[style_name] = TexFont()
|
||||
thisstyle = self.latex_font[style_name]
|
||||
|
||||
thisstyle.font_beg = ""
|
||||
thisstyle.font_end = ""
|
||||
# Is there special alignment? (default is left)
|
||||
align = style.get_alignment_text()
|
||||
if align == "center":
|
||||
thisstyle.font_beg = thisstyle.font_beg + "\\centerline{"
|
||||
thisstyle.font_end = "}" + thisstyle.font_end
|
||||
elif align == "right":
|
||||
thisstyle.font_beg = thisstyle.font_beg + "\\hfill"
|
||||
thisstyle.font_beg = ""
|
||||
thisstyle.font_end = ""
|
||||
# Is there special alignment? (default is left)
|
||||
align = style.get_alignment_text()
|
||||
if align == "center":
|
||||
thisstyle.font_beg = thisstyle.font_beg + "\\centerline{"
|
||||
thisstyle.font_end = "}" + thisstyle.font_end
|
||||
elif align == "right":
|
||||
thisstyle.font_beg = thisstyle.font_beg + "\\hfill"
|
||||
|
||||
# Establish font face and shape
|
||||
if font.get_type_face() == BaseDoc.FONT_SANS_SERIF:
|
||||
thisstyle.font_beg = thisstyle.font_beg + "\\sffamily"
|
||||
thisstyle.font_end = "\\rmfamily" + thisstyle.font_end
|
||||
if font.get_bold():
|
||||
thisstyle.font_beg = thisstyle.font_beg + "\\bfseries"
|
||||
thisstyle.font_end = "\\mdseries" + thisstyle.font_end
|
||||
if font.get_italic() or font.get_underline():
|
||||
thisstyle.font_beg = thisstyle.font_beg + "\\itshape"
|
||||
thisstyle.font_end = "\\upshape" + thisstyle.font_end
|
||||
if font.get_type_face() == BaseDoc.FONT_SANS_SERIF:
|
||||
thisstyle.font_beg = thisstyle.font_beg + "\\sffamily"
|
||||
thisstyle.font_end = "\\rmfamily" + thisstyle.font_end
|
||||
if font.get_bold():
|
||||
thisstyle.font_beg = thisstyle.font_beg + "\\bfseries"
|
||||
thisstyle.font_end = "\\mdseries" + thisstyle.font_end
|
||||
if font.get_italic() or font.get_underline():
|
||||
thisstyle.font_beg = thisstyle.font_beg + "\\itshape"
|
||||
thisstyle.font_end = "\\upshape" + thisstyle.font_end
|
||||
|
||||
# Now determine font size
|
||||
sflag = 0
|
||||
if size >= 22:
|
||||
thisstyle.font_beg = thisstyle.font_beg + "\\Huge"
|
||||
sflag = 1
|
||||
elif size >= 20:
|
||||
thisstyle.font_beg = thisstyle.font_beg + "\\huge"
|
||||
sflag = 1
|
||||
elif size >= 18:
|
||||
thisstyle.font_beg = thisstyle.font_beg + "\\LARGE"
|
||||
sflag = 1
|
||||
elif size >= 16:
|
||||
thisstyle.font_beg = thisstyle.font_beg + "\\Large"
|
||||
sflag = 1
|
||||
elif size >= 14:
|
||||
thisstyle.font_beg = thisstyle.font_beg + "\\large"
|
||||
sflag = 1
|
||||
elif size < 8:
|
||||
thisstyle.font_beg = thisstyle.font_beg + "\\scriptsize"
|
||||
sflag = 1
|
||||
elif size < 10:
|
||||
thisstyle.font_beg = thisstyle.font_beg + "\\footnotesize"
|
||||
sflag = 1
|
||||
elif size < 12:
|
||||
thisstyle.font_beg = thisstyle.font_beg + "\\small"
|
||||
sflag = 1
|
||||
|
||||
if sflag == 1:
|
||||
thisstyle.font_end = thisstyle.font_end + "\\normalsize"
|
||||
# Now determine font size
|
||||
sflag = 0
|
||||
if size >= 22:
|
||||
thisstyle.font_beg = thisstyle.font_beg + "\\Huge"
|
||||
sflag = 1
|
||||
elif size >= 20:
|
||||
thisstyle.font_beg = thisstyle.font_beg + "\\huge"
|
||||
sflag = 1
|
||||
elif size >= 18:
|
||||
thisstyle.font_beg = thisstyle.font_beg + "\\LARGE"
|
||||
sflag = 1
|
||||
elif size >= 16:
|
||||
thisstyle.font_beg = thisstyle.font_beg + "\\Large"
|
||||
sflag = 1
|
||||
elif size >= 14:
|
||||
thisstyle.font_beg = thisstyle.font_beg + "\\large"
|
||||
sflag = 1
|
||||
elif size < 8:
|
||||
thisstyle.font_beg = thisstyle.font_beg + "\\scriptsize"
|
||||
sflag = 1
|
||||
elif size < 10:
|
||||
thisstyle.font_beg = thisstyle.font_beg + "\\footnotesize"
|
||||
sflag = 1
|
||||
elif size < 12:
|
||||
thisstyle.font_beg = thisstyle.font_beg + "\\small"
|
||||
sflag = 1
|
||||
|
||||
thisstyle.font_beg = thisstyle.font_beg + " "
|
||||
thisstyle.font_end = thisstyle.font_end + " "
|
||||
if sflag == 1:
|
||||
thisstyle.font_end = thisstyle.font_end + "\\normalsize"
|
||||
|
||||
left = style.get_left_margin()
|
||||
first = style.get_first_indent() + left
|
||||
thisstyle.font_beg = thisstyle.font_beg + " "
|
||||
thisstyle.font_end = thisstyle.font_end + " "
|
||||
|
||||
left = style.get_left_margin()
|
||||
first = style.get_first_indent() + left
|
||||
|
||||
thisstyle.leftIndent = left
|
||||
thisstyle.firstLineIndent = first
|
||||
thisstyle.leftIndent = left
|
||||
thisstyle.firstLineIndent = first
|
||||
|
||||
self.latexstyle[style_name] = thisstyle
|
||||
self.latexstyle[style_name] = thisstyle
|
||||
|
||||
def close(self):
|
||||
"""Clean up and close the document"""
|
||||
@ -305,22 +307,22 @@ class LaTeXDoc(BaseDoc.BaseDoc):
|
||||
"""Paragraphs handling - A Gramps paragraph is any
|
||||
single body of text from a single word to several sentences.
|
||||
We assume a linebreak at the end of each paragraph."""
|
||||
style_sheet = self.get_style_sheet()
|
||||
|
||||
style = self.style_list[style_name]
|
||||
ltxstyle = self.latexstyle[style_name]
|
||||
self.level = style.get_header_level()
|
||||
style = style_sheet.get_paragraph_style(style_name)
|
||||
ltxstyle = self.latexstyle[style_name]
|
||||
self.level = style.get_header_level()
|
||||
|
||||
self.fbeg = ltxstyle.font_beg
|
||||
self.fend = ltxstyle.font_end
|
||||
self.indent = ltxstyle.leftIndent
|
||||
self.FLindent = ltxstyle.firstLineIndent
|
||||
|
||||
self.fbeg = ltxstyle.font_beg
|
||||
self.fend = ltxstyle.font_end
|
||||
self.indent = ltxstyle.leftIndent
|
||||
self.FLindent = ltxstyle.firstLineIndent
|
||||
|
||||
if self.indent != None and not self.in_table:
|
||||
myspace = '%scm' % str(self.indent)
|
||||
self.f.write('\\grampsindent{%s}\n' % myspace)
|
||||
self.fix_indent = 1
|
||||
|
||||
if self.indent != None and not self.in_table:
|
||||
myspace = '%scm' % str(self.indent)
|
||||
self.f.write('\\grampsindent{%s}\n' % myspace)
|
||||
self.fix_indent = 1
|
||||
|
||||
if leader != None and not self.in_list:
|
||||
self.f.write('\\begin{enumerate}\n')
|
||||
self.in_list = 1
|
||||
@ -384,15 +386,16 @@ class LaTeXDoc(BaseDoc.BaseDoc):
|
||||
|
||||
def start_table(self,name,style_name):
|
||||
"""Begin new table"""
|
||||
self.in_table = 1
|
||||
self.currow = 0
|
||||
self.in_table = 1
|
||||
self.currow = 0
|
||||
|
||||
# We need to know a priori how many columns are in this table
|
||||
self.tblstyle = self.table_styles[style_name]
|
||||
self.numcols = self.tblstyle.get_columns()
|
||||
# We need to know a priori how many columns are in this table
|
||||
styles = self.get_style_sheet()
|
||||
self.tblstyle = styles.get_table_style(style_name)
|
||||
self.numcols = self.tblstyle.get_columns()
|
||||
|
||||
tblfmt = '*{%d}{l}' % self.numcols
|
||||
self.f.write('\n\n\\begin{longtable}[l]{%s}\n' % tblfmt)
|
||||
tblfmt = '*{%d}{l}' % self.numcols
|
||||
self.f.write('\n\n\\begin{longtable}[l]{%s}\n' % tblfmt)
|
||||
|
||||
def end_table(self):
|
||||
"""Close the table environment"""
|
||||
@ -421,38 +424,39 @@ class LaTeXDoc(BaseDoc.BaseDoc):
|
||||
|
||||
def start_cell(self,style_name,span=1):
|
||||
"""Add an entry to the table.
|
||||
We always place our data inside braces
|
||||
for safety of formatting."""
|
||||
self.colspan = span
|
||||
self.curcol = self.curcol + self.colspan
|
||||
We always place our data inside braces
|
||||
for safety of formatting."""
|
||||
self.colspan = span
|
||||
self.curcol = self.curcol + self.colspan
|
||||
|
||||
self.cstyle = self.cell_styles[style_name]
|
||||
self.lborder = self.cstyle.get_left_border()
|
||||
self.rborder = self.cstyle.get_right_border()
|
||||
self.bborder = self.cstyle.get_bottom_border()
|
||||
self.tborder = self.cstyle.get_top_border()
|
||||
self.llist = self.cstyle.get_longlist()
|
||||
|
||||
if self.llist == 1:
|
||||
cellfmt = "p{\linewidth-3cm}"
|
||||
else:
|
||||
cellfmt = "l"
|
||||
|
||||
# Account for vertical rules
|
||||
if self.lborder == 1:
|
||||
cellfmt = '|' + cellfmt
|
||||
if self.rborder == 1:
|
||||
cellfmt = cellfmt + '|'
|
||||
styles = self.get_style_sheet()
|
||||
self.cstyle = styles.get_cell_style(style_name)
|
||||
self.lborder = self.cstyle.get_left_border()
|
||||
self.rborder = self.cstyle.get_right_border()
|
||||
self.bborder = self.cstyle.get_bottom_border()
|
||||
self.tborder = self.cstyle.get_top_border()
|
||||
self.llist = self.cstyle.get_longlist()
|
||||
|
||||
# and Horizontal rules
|
||||
if self.bborder == 1:
|
||||
self.doline = 1
|
||||
elif self.curcol == 1:
|
||||
self.skipfirst = 1
|
||||
if self.llist == 1:
|
||||
cellfmt = "p{\linewidth-3cm}"
|
||||
else:
|
||||
cellfmt = "l"
|
||||
|
||||
if self.tborder != 0:
|
||||
self.f.write('\\hline\n')
|
||||
self.f.write ('\\multicolumn{%d}{%s}{' % (span,cellfmt))
|
||||
# Account for vertical rules
|
||||
if self.lborder == 1:
|
||||
cellfmt = '|' + cellfmt
|
||||
if self.rborder == 1:
|
||||
cellfmt = cellfmt + '|'
|
||||
|
||||
# and Horizontal rules
|
||||
if self.bborder == 1:
|
||||
self.doline = 1
|
||||
elif self.curcol == 1:
|
||||
elf.skipfirst = 1
|
||||
|
||||
if self.tborder != 0:
|
||||
self.f.write('\\hline\n')
|
||||
self.f.write ('\\multicolumn{%d}{%s}{' % (span,cellfmt))
|
||||
|
||||
def end_cell(self):
|
||||
"""Prepares for next cell"""
|
||||
|
@ -3,6 +3,7 @@
|
||||
#
|
||||
# Copyright (C) 2000-2006 Donald N. Allingham
|
||||
# Copyright (C) 2005-2006 Serge Noiraud
|
||||
# Copyright (C) 2007 Brian G. Matherly
|
||||
#
|
||||
# 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
|
||||
@ -157,9 +158,11 @@ class ODFDoc(BaseDoc.BaseDoc):
|
||||
self.cntnt.write('<style:style style:name="GRAMPS-preformat" style:family="text">')
|
||||
self.cntnt.write('<style:text-properties style:font-name="Courier"/>')
|
||||
self.cntnt.write('</style:style>\n')
|
||||
|
||||
styles = self.get_style_sheet()
|
||||
|
||||
for style_name in self.draw_styles.keys():
|
||||
style = self.draw_styles[style_name]
|
||||
for style_name in styles.get_draw_style_names():
|
||||
style = styles.get_draw_style(style_name)
|
||||
self.cntnt.write('<style:style style:name="%s"' % style_name)
|
||||
self.cntnt.write(' style:family="graphic"')
|
||||
self.cntnt.write(' >\n')
|
||||
@ -212,8 +215,8 @@ class ODFDoc(BaseDoc.BaseDoc):
|
||||
self.cntnt.write('/>\n')
|
||||
self.cntnt.write('</style:style>\n')
|
||||
|
||||
for style_name in self.style_list.keys():
|
||||
style = self.style_list[style_name]
|
||||
for style_name in styles.get_paragraph_style_names():
|
||||
style = styles.get_paragraph_style(style_name)
|
||||
|
||||
self.cntnt.write('<style:style style:name="NL%s" ' % style_name)
|
||||
self.cntnt.write('style:family="paragraph" ')
|
||||
@ -292,8 +295,8 @@ class ODFDoc(BaseDoc.BaseDoc):
|
||||
self.cntnt.write('style:font-size-asian="%.2fpt"/> ' % font.get_size())
|
||||
self.cntnt.write('</style:style>\n')
|
||||
|
||||
for style_name in self.table_styles.keys():
|
||||
style = self.table_styles[style_name]
|
||||
for style_name in styles.get_table_style_names():
|
||||
style = styles.get_table_style(style_name)
|
||||
self.cntnt.write('<style:style style:name="%s" ' % style_name)
|
||||
self.cntnt.write('style:family="table-properties">\n')
|
||||
table_width = float(self.get_usable_width())
|
||||
@ -311,8 +314,8 @@ class ODFDoc(BaseDoc.BaseDoc):
|
||||
self.cntnt.write('style:column-width="%scm"/>' % width_str)
|
||||
self.cntnt.write('</style:style>\n')
|
||||
|
||||
for cell in self.cell_styles.keys():
|
||||
cell_style = self.cell_styles[cell]
|
||||
for cell in styles.get_cell_style_names():
|
||||
cell_style = styles.get_cell_style(cell)
|
||||
self.cntnt.write('<style:style style:name="%s" ' % cell)
|
||||
self.cntnt.write('style:family="table-cell">\n')
|
||||
self.cntnt.write('<style:table-cell-properties')
|
||||
@ -470,7 +473,8 @@ class ODFDoc(BaseDoc.BaseDoc):
|
||||
def start_table(self,name,style_name):
|
||||
self.cntnt.write('<table:table table:name="%s" ' % name)
|
||||
self.cntnt.write('table:style-name="%s">\n' % style_name)
|
||||
table = self.table_styles[style_name]
|
||||
styles = self.get_style_sheet()
|
||||
table = styles.get_table_style(style_name)
|
||||
for col in range(0,table.get_columns()):
|
||||
self.cntnt.write('<table:table-column table:style-name="')
|
||||
self.cntnt.write(style_name + '.' + str(chr(ord('A')+col)) +'"/>\n')
|
||||
@ -649,9 +653,11 @@ class ODFDoc(BaseDoc.BaseDoc):
|
||||
self.sfile.write('style:horizontal-rel="paragraph-content"/>\n')
|
||||
self.sfile.write('</style:style>\n')
|
||||
|
||||
for key in self.style_list.keys():
|
||||
style = self.style_list[key]
|
||||
self.sfile.write('<style:style style:name="%s" ' % key)
|
||||
styles = self.get_style_sheet()
|
||||
|
||||
for style_name in styles.get_paragraph_style_names():
|
||||
style = styles.get_paragraph_style(style_name)
|
||||
self.sfile.write('<style:style style:name="%s" ' % style_name)
|
||||
self.sfile.write('style:family="paragraph" ')
|
||||
self.sfile.write('style:parent-style-name="Standard" ')
|
||||
self.sfile.write('style:class="text">\n')
|
||||
@ -813,7 +819,8 @@ class ODFDoc(BaseDoc.BaseDoc):
|
||||
self.cntnt.write('</text:p>\n')
|
||||
|
||||
def start_paragraph(self,style_name,leader=None):
|
||||
style = self.style_list[style_name]
|
||||
style_sheet = self.get_style_sheet()
|
||||
style = style_sheet.get_paragraph_style(style_name)
|
||||
self.level = style.get_header_level()
|
||||
if self.new_page == 1:
|
||||
self.new_page = 0
|
||||
@ -964,10 +971,10 @@ class ODFDoc(BaseDoc.BaseDoc):
|
||||
self.meta.write('</office:document-meta>\n')
|
||||
|
||||
def rotate_text(self,style,text,x,y,angle):
|
||||
|
||||
stype = self.draw_styles[style]
|
||||
style_sheet = self.get_style_sheet()
|
||||
stype = style_sheet.get_draw_style(style)
|
||||
pname = stype.get_paragraph_style()
|
||||
p = self.style_list[pname]
|
||||
p = style_sheet.get_paragraph_style(pname)
|
||||
font = p.get_font()
|
||||
size = font.get_size()
|
||||
|
||||
@ -992,14 +999,12 @@ class ODFDoc(BaseDoc.BaseDoc):
|
||||
self.cntnt.write('rotate (%.8f) ' % rangle)
|
||||
xloc = x-((wcm/2.0)*cos(-rangle))
|
||||
yloc = y-((hcm)*sin(-rangle))-oneline
|
||||
self.cntnt.write('translate (%.3fcm %.3fcm)"' % (xloc,yloc))
|
||||
self.cntnt.write('> ')
|
||||
self.cntnt.write('<draw:text-box>')
|
||||
self.cntnt.write('<text:p text:style-name="X%s"> ' % pname)
|
||||
|
||||
self.cntnt.write('<text:span text:style-name="F%s">\n' % pname)
|
||||
self.write_text('\n'.join(text)) # No escape(): write_text does that.
|
||||
self.cntnt.write('</text:span>\n</text:p>\n</draw:text-box>\n')
|
||||
self.cntnt.write('translate (%.3fcm %.3fcm)">\n' % (xloc,yloc))
|
||||
self.cntnt.write('<draw:text-box>\n')
|
||||
self.cntnt.write('<text:p text:style-name="X%s">' % pname)
|
||||
self.cntnt.write('<text:span text:style-name="F%s">' % pname)
|
||||
self.cntnt.write(escape('\n'.join(text),_esc_map))
|
||||
self.cntnt.write('</text:span></text:p>\n</draw:text-box>\n')
|
||||
self.cntnt.write('</draw:frame>\n')
|
||||
|
||||
def draw_path(self,style,path):
|
||||
@ -1047,10 +1052,10 @@ class ODFDoc(BaseDoc.BaseDoc):
|
||||
self.cntnt.write('</draw:line>\n')
|
||||
|
||||
def draw_text(self,style,text,x,y):
|
||||
box_style = self.draw_styles[style]
|
||||
style_sheet = self.get_style_sheet()
|
||||
box_style = style_sheet.get_draw_style(style)
|
||||
para_name = box_style.get_paragraph_style()
|
||||
|
||||
pstyle = self.style_list[para_name]
|
||||
pstyle = style_sheet.get_paragraph_style(para_name)
|
||||
font = pstyle.get_font()
|
||||
sw = ReportUtils.pt2cm(FontScale.string_width(font,text))*1.3
|
||||
|
||||
@ -1073,7 +1078,8 @@ class ODFDoc(BaseDoc.BaseDoc):
|
||||
self.cntnt.write('</draw:frame>\n')
|
||||
|
||||
def draw_box(self,style,text,x,y, w, h):
|
||||
box_style = self.draw_styles[style]
|
||||
style_sheet = self.get_style_sheet()
|
||||
box_style = style_sheet.get_draw_style(style)
|
||||
para_name = box_style.get_paragraph_style()
|
||||
shadow_width = box_style.get_shadow_space()
|
||||
|
||||
@ -1105,9 +1111,10 @@ class ODFDoc(BaseDoc.BaseDoc):
|
||||
self.cntnt.write('</draw:rect>\n')
|
||||
|
||||
def center_text(self,style,text,x,y):
|
||||
box_style = self.draw_styles[style]
|
||||
style_sheet = self.get_style_sheet()
|
||||
box_style = style_sheet.get_draw_style(style)
|
||||
para_name = box_style.get_paragraph_style()
|
||||
pstyle = self.style_list[para_name]
|
||||
pstyle = style_sheet.get_paragraph_style(para_name)
|
||||
font = pstyle.get_font()
|
||||
|
||||
size = (FontScale.string_width(font,text)/72.0) * 2.54
|
||||
|
@ -2,6 +2,7 @@
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2006 Donald N. Allingham
|
||||
# Copyright (C) 2007 Brian G. Matherly
|
||||
#
|
||||
# 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
|
||||
@ -101,6 +102,7 @@ class OpenOfficeDoc(BaseDoc.BaseDoc):
|
||||
self.init_called = True
|
||||
|
||||
self.lang = Utils.xml_lang()
|
||||
style_sheet = self.get_style_sheet()
|
||||
|
||||
self.cntnt.write('<?xml version="1.0" encoding="UTF-8"?>\n')
|
||||
self.cntnt.write('<office:document-content ')
|
||||
@ -143,8 +145,8 @@ class OpenOfficeDoc(BaseDoc.BaseDoc):
|
||||
self.cntnt.write('<style:properties style:font-name="Courier"/>')
|
||||
self.cntnt.write('</style:style>\n')
|
||||
|
||||
for style_name in self.draw_styles.keys():
|
||||
style = self.draw_styles[style_name]
|
||||
for style_name in style_sheet.get_draw_style_names():
|
||||
style = style_sheet.get_draw_style(style_name)
|
||||
self.cntnt.write('<style:style style:name="%s"' % style_name)
|
||||
self.cntnt.write(' style:family="graphics">\n')
|
||||
self.cntnt.write('<style:properties ')
|
||||
@ -175,8 +177,8 @@ class OpenOfficeDoc(BaseDoc.BaseDoc):
|
||||
self.cntnt.write('/>\n')
|
||||
self.cntnt.write('</style:style>\n')
|
||||
|
||||
for style_name in self.style_list.keys():
|
||||
style = self.style_list[style_name]
|
||||
for style_name in style_sheet.get_paragraph_style_names():
|
||||
style = style_sheet.get_paragraph_style(style_name)
|
||||
self.cntnt.write('<style:style style:name="NL%s" ' % style_name)
|
||||
self.cntnt.write('style:family="paragraph" ')
|
||||
self.cntnt.write('style:parent-style-name="%s">\n' % style_name)
|
||||
@ -260,8 +262,8 @@ class OpenOfficeDoc(BaseDoc.BaseDoc):
|
||||
self.cntnt.write('style:font-size-asian="%.3fpt"/> ' % font.get_size())
|
||||
self.cntnt.write('</style:style>\n')
|
||||
|
||||
for style_name in self.table_styles.keys():
|
||||
style = self.table_styles[style_name]
|
||||
for style_name in style_sheet.get_table_style_names():
|
||||
style = style_sheet.get_table_style(style_name)
|
||||
self.cntnt.write('<style:style style:name="%s" ' % style_name)
|
||||
self.cntnt.write('style:family="table">\n')
|
||||
table_width = float(self.get_usable_width())
|
||||
@ -279,8 +281,8 @@ class OpenOfficeDoc(BaseDoc.BaseDoc):
|
||||
self.cntnt.write('style:column-width="%scm"/>' % width_str)
|
||||
self.cntnt.write('</style:style>\n')
|
||||
|
||||
for cell in self.cell_styles.keys():
|
||||
cell_style = self.cell_styles[cell]
|
||||
for cell in style_sheet.get_cell_style_names():
|
||||
cell_style = style_sheet.get_cell_style(cell)
|
||||
self.cntnt.write('<style:style style:name="%s" ' % cell)
|
||||
self.cntnt.write('style:family="table-cell">\n')
|
||||
self.cntnt.write('<style:properties')
|
||||
@ -434,7 +436,8 @@ class OpenOfficeDoc(BaseDoc.BaseDoc):
|
||||
def start_table(self,name,style_name):
|
||||
self.cntnt.write('<table:table table:name="%s" ' % name)
|
||||
self.cntnt.write('table:style-name="%s">\n' % style_name)
|
||||
table = self.table_styles[style_name]
|
||||
styles = self.get_style_sheet()
|
||||
table = styles.get_table_style(style_name)
|
||||
for col in range(0,table.get_columns()):
|
||||
self.cntnt.write('<table:table-column table:style-name="')
|
||||
self.cntnt.write(style_name + '.' + str(chr(ord('A')+col)) +'"/>\n')
|
||||
@ -515,6 +518,7 @@ class OpenOfficeDoc(BaseDoc.BaseDoc):
|
||||
|
||||
def _write_styles_file(self):
|
||||
self.sfile = StringIO()
|
||||
style_sheet = self.get_style_sheet()
|
||||
|
||||
self.sfile.write('<?xml version="1.0" encoding="UTF-8"?>\n')
|
||||
self.sfile.write('<office:document-styles ')
|
||||
@ -561,9 +565,9 @@ class OpenOfficeDoc(BaseDoc.BaseDoc):
|
||||
self.sfile.write('style:horizontal-rel="paragraph-content"/>\n')
|
||||
self.sfile.write('</style:style>\n')
|
||||
|
||||
for key in self.style_list.keys():
|
||||
style = self.style_list[key]
|
||||
self.sfile.write('<style:style style:name="%s" ' % key)
|
||||
for name in style_sheet.get_paragraph_style_names():
|
||||
style = style_sheet.get_paragraph_style(name)
|
||||
self.sfile.write('<style:style style:name="%s" ' % name)
|
||||
self.sfile.write('style:family="paragraph" ')
|
||||
self.sfile.write('style:parent-style-name="Standard" ')
|
||||
self.sfile.write('style:class="text">\n')
|
||||
@ -684,7 +688,8 @@ class OpenOfficeDoc(BaseDoc.BaseDoc):
|
||||
self.cntnt.write('</text:p>\n')
|
||||
|
||||
def start_paragraph(self,style_name,leader=None):
|
||||
style = self.style_list[style_name]
|
||||
style_sheet = self.get_style_sheet()
|
||||
style = style_sheet.get_paragraph_style(style_name)
|
||||
self.level = style.get_header_level()
|
||||
if self.new_page == 1:
|
||||
self.new_page = 0
|
||||
@ -818,10 +823,10 @@ class OpenOfficeDoc(BaseDoc.BaseDoc):
|
||||
self.meta.write('</office:document-meta>\n')
|
||||
|
||||
def rotate_text(self,style,text,x,y,angle):
|
||||
|
||||
stype = self.draw_styles[style]
|
||||
style_sheet = self.get_style_sheet()
|
||||
stype = style_sheet.get_draw_style(style)
|
||||
pname = stype.get_paragraph_style()
|
||||
p = self.style_list[pname]
|
||||
p = style_sheet.get_paragraph_style(pname)
|
||||
font = p.get_font()
|
||||
size = font.get_size()
|
||||
|
||||
@ -892,10 +897,10 @@ class OpenOfficeDoc(BaseDoc.BaseDoc):
|
||||
self.cntnt.write('/>\n')
|
||||
|
||||
def draw_text(self,style,text,x,y):
|
||||
box_style = self.draw_styles[style]
|
||||
style_sheet = self.get_style_sheet()
|
||||
box_style = style_sheet.get_draw_style(style)
|
||||
para_name = box_style.get_paragraph_style()
|
||||
|
||||
pstyle = self.style_list[para_name]
|
||||
pstyle = style_sheet.get_paragraph_style(para_name)
|
||||
font = pstyle.get_font()
|
||||
sw = ReportUtils.pt2cm(FontScale.string_width(font,text))*1.3
|
||||
|
||||
@ -915,7 +920,8 @@ class OpenOfficeDoc(BaseDoc.BaseDoc):
|
||||
self.cntnt.write('</draw:text-box>\n')
|
||||
|
||||
def draw_box(self,style,text,x,y, w, h):
|
||||
box_style = self.draw_styles[style]
|
||||
style_sheet = self.get_style_sheet()
|
||||
box_style = style_sheet.get_draw_style(style)
|
||||
para_name = box_style.get_paragraph_style()
|
||||
shadow_width = box_style.get_shadow_space()
|
||||
|
||||
@ -949,9 +955,10 @@ class OpenOfficeDoc(BaseDoc.BaseDoc):
|
||||
self.cntnt.write('</draw:rect>\n')
|
||||
|
||||
def center_text(self,style,text,x,y):
|
||||
box_style = self.draw_styles[style]
|
||||
style_sheet = self.get_style_sheet()
|
||||
box_style = style_sheet.get_draw_style(style)
|
||||
para_name = box_style.get_paragraph_style()
|
||||
pstyle = self.style_list[para_name]
|
||||
pstyle = style_sheet.get_paragraph_style(para_name)
|
||||
font = pstyle.get_font()
|
||||
|
||||
size = (FontScale.string_width(font,text)/72.0) * 2.54
|
||||
|
@ -2,6 +2,7 @@
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2006 Donald N. Allingham
|
||||
# Copyright (C) 2007 Brian G. Matherly
|
||||
#
|
||||
# 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
|
||||
@ -191,9 +192,10 @@ class PSDrawDoc(BaseDoc.BaseDoc):
|
||||
return (new_text,fdef)
|
||||
|
||||
def center_text(self,style,text,x,y):
|
||||
stype = self.draw_styles[style]
|
||||
style_sheet = self.get_style_sheet()
|
||||
stype = style_sheet.get_draw_style(style)
|
||||
pname = stype.get_paragraph_style()
|
||||
p = self.style_list[pname]
|
||||
p = style_sheet.get_paragraph_style(pname)
|
||||
|
||||
x += self.paper.get_left_margin()
|
||||
y = y + self.paper.get_top_margin() + ReportUtils.pt2cm(p.get_font().get_size())
|
||||
@ -209,9 +211,10 @@ class PSDrawDoc(BaseDoc.BaseDoc):
|
||||
self.f.write('grestore\n')
|
||||
|
||||
def draw_text(self,style,text,x1,y1):
|
||||
stype = self.draw_styles[style]
|
||||
para_name = stype.get_paragraph_style()
|
||||
p = self.style_list[para_name]
|
||||
style_sheet = self.get_style_sheet()
|
||||
stype = style_sheet.get_draw_style(style)
|
||||
pname = stype.get_paragraph_style()
|
||||
p = style_sheet.get_paragraph_style(pname)
|
||||
|
||||
x1 = x1 + self.paper.get_left_margin()
|
||||
y1 = y1 + self.paper.get_top_margin() + ReportUtils.pt2cm(p.get_font().get_size())
|
||||
@ -228,9 +231,10 @@ class PSDrawDoc(BaseDoc.BaseDoc):
|
||||
x += self.paper.get_left_margin()
|
||||
y += self.paper.get_top_margin()
|
||||
|
||||
stype = self.draw_styles[style]
|
||||
style_sheet = self.get_style_sheet()
|
||||
stype = style_sheet.get_draw_style(style)
|
||||
pname = stype.get_paragraph_style()
|
||||
p = self.style_list[pname]
|
||||
p = style_sheet.get_paragraph_style(pname)
|
||||
font = p.get_font()
|
||||
|
||||
size = font.get_size()
|
||||
@ -258,7 +262,8 @@ class PSDrawDoc(BaseDoc.BaseDoc):
|
||||
self.f.write('grestore\n')
|
||||
|
||||
def draw_path(self,style,path):
|
||||
stype = self.draw_styles[style]
|
||||
style_sheet = self.get_style_sheet()
|
||||
stype = style_sheet.get_draw_style(style)
|
||||
self.f.write('gsave\n')
|
||||
self.f.write('newpath\n')
|
||||
self.f.write('%s setlinewidth\n' % gformat(stype.get_line_width()))
|
||||
@ -288,7 +293,8 @@ class PSDrawDoc(BaseDoc.BaseDoc):
|
||||
x2 = x2 + self.paper.get_left_margin()
|
||||
y1 = y1 + self.paper.get_top_margin()
|
||||
y2 = y2 + self.paper.get_top_margin()
|
||||
stype = self.draw_styles[style]
|
||||
style_sheet = self.get_style_sheet()
|
||||
stype = style_sheet.get_draw_style(style)
|
||||
self.f.write('gsave newpath\n')
|
||||
self.f.write('%s cm %s cm moveto\n' % coords(self.translate(x1,y1)))
|
||||
self.f.write('%s cm %s cm lineto\n' % coords(self.translate(x2,y2)))
|
||||
@ -305,8 +311,9 @@ class PSDrawDoc(BaseDoc.BaseDoc):
|
||||
def draw_box(self,style,text,x,y, w, h):
|
||||
x = x + self.paper.get_left_margin()
|
||||
y = y + self.paper.get_top_margin()
|
||||
|
||||
box_style = self.draw_styles[style]
|
||||
|
||||
style_sheet = self.get_style_sheet()
|
||||
box_style = style_sheet.get_draw_style(style)
|
||||
|
||||
self.f.write('gsave\n')
|
||||
|
||||
@ -344,7 +351,7 @@ class PSDrawDoc(BaseDoc.BaseDoc):
|
||||
if text != "":
|
||||
para_name = box_style.get_paragraph_style()
|
||||
assert( para_name != '' )
|
||||
p = self.style_list[para_name]
|
||||
p = style_sheet.get_paragraph_style(para_name)
|
||||
(text,fdef) = self.encode_text(p,text)
|
||||
self.f.write(fdef)
|
||||
lines = text.split('\n')
|
||||
|
@ -2,6 +2,7 @@
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2006 Donald N. Allingham
|
||||
# Copyright (C) 2007 Brian G. Matherly
|
||||
#
|
||||
# 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
|
||||
@ -146,9 +147,9 @@ class PdfDoc(BaseDoc.BaseDoc):
|
||||
self.doc.addPageTemplates([ptemp])
|
||||
|
||||
self.pdfstyles = {}
|
||||
|
||||
for style_name in self.style_list.keys():
|
||||
style = self.style_list[style_name]
|
||||
style_sheet = self.get_style_sheet()
|
||||
for style_name in style_sheet.get_paragraph_style_names():
|
||||
style = style_sheet.get_paragraph_style(style_name)
|
||||
font = style.get_font()
|
||||
|
||||
pdf_style = reportlab.lib.styles.ParagraphStyle(name=style_name)
|
||||
@ -211,8 +212,9 @@ class PdfDoc(BaseDoc.BaseDoc):
|
||||
self.story.append(PageBreak())
|
||||
|
||||
def start_paragraph(self,style_name,leader=None):
|
||||
style_sheet = self.get_style_sheet()
|
||||
self.current_para = self.pdfstyles[style_name]
|
||||
self.my_para = self.style_list[style_name]
|
||||
self.my_para = style_sheet.get_paragraph_style(style_name)
|
||||
self.super = "<font size=%d><super>" \
|
||||
% (self.my_para.get_font().get_size()-2)
|
||||
if leader==None:
|
||||
@ -242,7 +244,8 @@ class PdfDoc(BaseDoc.BaseDoc):
|
||||
|
||||
def start_table(self,name,style_name):
|
||||
self.in_table = 1
|
||||
self.cur_table = self.table_styles[style_name]
|
||||
styles = self.get_style_sheet()
|
||||
self.cur_table = styles.get_table_style(style_name)
|
||||
self.row = -1
|
||||
self.col = 0
|
||||
self.cur_row = []
|
||||
@ -277,7 +280,8 @@ class PdfDoc(BaseDoc.BaseDoc):
|
||||
|
||||
def start_cell(self,style_name,span=1):
|
||||
self.span = span
|
||||
self.my_table_style = self.cell_styles[style_name]
|
||||
styles = self.get_style_sheet()
|
||||
self.my_table_style = styles.get_cell_style(style_name)
|
||||
self.cur_cell = []
|
||||
|
||||
def end_cell(self):
|
||||
@ -377,7 +381,8 @@ class PdfDoc(BaseDoc.BaseDoc):
|
||||
def write_note(self,text,format,style_name):
|
||||
text = enc(text)
|
||||
current_para = self.pdfstyles[style_name]
|
||||
self.my_para = self.style_list[style_name]
|
||||
style_sheet = self.get_style_sheet()
|
||||
self.my_para = style_sheet.get_paragraph_style(style_name)
|
||||
self.super = "<font size=%d><super>" \
|
||||
% (self.my_para.get_font().get_size()-2)
|
||||
|
||||
@ -420,8 +425,8 @@ class PdfDoc(BaseDoc.BaseDoc):
|
||||
def draw_line(self,style,x1,y1,x2,y2):
|
||||
y1 = self.get_usable_height() - y1
|
||||
y2 = self.get_usable_height() - y2
|
||||
|
||||
stype = self.draw_styles[style]
|
||||
style_sheet = self.get_style_sheet()
|
||||
stype = style_sheet.get_draw_style(style)
|
||||
if stype.get_line_style() == BaseDoc.SOLID:
|
||||
line_array = None
|
||||
else:
|
||||
@ -434,7 +439,8 @@ class PdfDoc(BaseDoc.BaseDoc):
|
||||
self.drawing.add(l)
|
||||
|
||||
def draw_path(self,style,path):
|
||||
stype = self.draw_styles[style]
|
||||
style_sheet = self.get_style_sheet()
|
||||
stype = style_sheet.get_draw_style(style)
|
||||
color = make_color(stype.get_fill_color())
|
||||
y = self.get_usable_height()*cm
|
||||
|
||||
@ -458,7 +464,8 @@ class PdfDoc(BaseDoc.BaseDoc):
|
||||
|
||||
def draw_box(self,style,text,x,y, w, h):
|
||||
y = self.get_usable_height() - y
|
||||
box_style = self.draw_styles[style]
|
||||
style_sheet = self.get_style_sheet()
|
||||
box_style = style_sheet.get_draw_style(style)
|
||||
|
||||
sspace = box_style.get_shadow_space()
|
||||
if box_style.get_shadow():
|
||||
@ -481,16 +488,17 @@ class PdfDoc(BaseDoc.BaseDoc):
|
||||
|
||||
if text != "":
|
||||
para_name = box_style.get_paragraph_style()
|
||||
p = self.style_list[para_name]
|
||||
p = style_sheet.get_paragraph_style(para_name)
|
||||
size = p.get_font().get_size()
|
||||
x = x + sspace
|
||||
lines = text.split('\n')
|
||||
self.left_print(lines,p.get_font(),x*cm,y*cm - size)
|
||||
|
||||
def draw_text(self,style,text,x,y):
|
||||
stype = self.draw_styles[style]
|
||||
style_sheet = self.get_style_sheet()
|
||||
stype = style_sheet.get_draw_style(style)
|
||||
pname = stype.get_paragraph_style()
|
||||
p = self.style_list[pname]
|
||||
p = style_sheet.get_paragraph_style(pname)
|
||||
font = p.get_font()
|
||||
size = font.get_size()
|
||||
y = (self.get_usable_height()*cm)-(y*cm)
|
||||
@ -533,9 +541,10 @@ class PdfDoc(BaseDoc.BaseDoc):
|
||||
return fn
|
||||
|
||||
def rotate_text(self,style,text,x,y,angle):
|
||||
stype = self.draw_styles[style]
|
||||
style_sheet = self.get_style_sheet()
|
||||
stype = style_sheet.get_draw_style(style)
|
||||
pname = stype.get_paragraph_style()
|
||||
p = self.style_list[pname]
|
||||
p = style_sheet.get_paragraph_style(pname)
|
||||
font = p.get_font()
|
||||
size = font.get_size()
|
||||
yt = (self.get_usable_height()*cm) - (y*cm)
|
||||
@ -560,9 +569,10 @@ class PdfDoc(BaseDoc.BaseDoc):
|
||||
self.drawing.add(g)
|
||||
|
||||
def center_text(self,style,text,x,y):
|
||||
stype = self.draw_styles[style]
|
||||
style_sheet = self.get_style_sheet()
|
||||
stype = style_sheet.get_draw_style(style)
|
||||
pname = stype.get_paragraph_style()
|
||||
p = self.style_list[pname]
|
||||
p = style_sheet.get_paragraph_style(pname)
|
||||
font = p.get_font()
|
||||
yt = (self.get_usable_height()*cm) - (y*cm)
|
||||
size = font.get_size()
|
||||
|
@ -2,6 +2,7 @@
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2006 Donald N. Allingham
|
||||
# Copyright (C) 2007 Brian G. Matherly
|
||||
#
|
||||
# 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
|
||||
@ -83,6 +84,8 @@ class RTFDoc(BaseDoc.BaseDoc):
|
||||
raise Errors.ReportError(errmsg)
|
||||
except:
|
||||
raise Errors.ReportError(_("Could not create %s") % self.filename)
|
||||
|
||||
style_sheet = self.get_style_sheet()
|
||||
|
||||
self.f.write('{\\rtf1\\ansi\\ansicpg1252\\deff0\n')
|
||||
self.f.write('{\\fonttbl\n')
|
||||
@ -93,8 +96,8 @@ class RTFDoc(BaseDoc.BaseDoc):
|
||||
index = 1
|
||||
self.color_map[(0,0,0)] = 0
|
||||
self.f.write('\\red0\\green0\\blue0;')
|
||||
for style_name in self.style_list.keys():
|
||||
style = self.style_list[style_name]
|
||||
for style_name in style_sheet.get_paragraph_style_names():
|
||||
style = style_sheet.get_paragraph_style(style_name)
|
||||
fgcolor = style.get_font().get_color()
|
||||
bgcolor = style.get_background_color()
|
||||
if not self.color_map.has_key(fgcolor):
|
||||
@ -150,7 +153,8 @@ class RTFDoc(BaseDoc.BaseDoc):
|
||||
#--------------------------------------------------------------------
|
||||
def start_paragraph(self,style_name,leader=None):
|
||||
self.opened = 0
|
||||
p = self.style_list[style_name]
|
||||
style_sheet = self.get_style_sheet()
|
||||
p = style_sheet.get_paragraph_style(style_name)
|
||||
|
||||
# build font information
|
||||
|
||||
@ -272,7 +276,8 @@ class RTFDoc(BaseDoc.BaseDoc):
|
||||
#--------------------------------------------------------------------
|
||||
def start_table(self,name,style_name):
|
||||
self.in_table = 1
|
||||
self.tbl_style = self.table_styles[style_name]
|
||||
styles = self.get_style_sheet()
|
||||
self.tbl_style = styles.get_table_style(style_name)
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
#
|
||||
@ -320,7 +325,8 @@ class RTFDoc(BaseDoc.BaseDoc):
|
||||
#
|
||||
#--------------------------------------------------------------------
|
||||
def start_cell(self,style_name,span=1):
|
||||
s = self.cell_styles[style_name]
|
||||
styles = self.get_style_sheet()
|
||||
s = styles.get_cell_style(style_name)
|
||||
self.remain = span -1
|
||||
if s.get_top_border():
|
||||
self.f.write('\\clbrdrt\\brdrs\\brdrw10\n')
|
||||
|
@ -2,6 +2,7 @@
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2006 Donald N. Allingham
|
||||
# Copyright (C) 2007 Brian G. Matherly
|
||||
#
|
||||
# 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
|
||||
@ -81,11 +82,11 @@ class SvgDrawDoc(BaseDoc.BaseDoc):
|
||||
self.f.write('xmlns="http://www.w3.org/2000/svg">\n')
|
||||
|
||||
def rotate_text(self,style,text,x,y,angle):
|
||||
|
||||
stype = self.draw_styles[style]
|
||||
style_sheet = self.get_style_sheet()
|
||||
stype = style_sheet.get_draw_style(style)
|
||||
pname = stype.get_paragraph_style()
|
||||
p = self.style_list[pname]
|
||||
font = p.get_font()
|
||||
p = style_sheet.get_paragraph_style(pname)
|
||||
font = p.get_font()
|
||||
size = font.get_size()
|
||||
|
||||
width = 0
|
||||
@ -135,7 +136,8 @@ class SvgDrawDoc(BaseDoc.BaseDoc):
|
||||
y1 = y1 + self.paper.get_top_margin()
|
||||
y2 = y2 + self.paper.get_top_margin()
|
||||
|
||||
s = self.draw_styles[style]
|
||||
style_sheet = self.get_style_sheet()
|
||||
s = style_sheet.get_draw_style(style)
|
||||
|
||||
self.f.write('<line x1="%4.2fcm" y1="%4.2fcm" ' % (x1,y1))
|
||||
self.f.write('x2="%4.2fcm" y2="%4.2fcm" ' % (x2,y2))
|
||||
@ -143,7 +145,8 @@ class SvgDrawDoc(BaseDoc.BaseDoc):
|
||||
self.f.write('stroke-width:%.2fpt;"/>\n' % s.get_line_width())
|
||||
|
||||
def draw_path(self,style,path):
|
||||
stype = self.draw_styles[style]
|
||||
style_sheet = self.get_style_sheet()
|
||||
stype = style_sheet.get_draw_style(style)
|
||||
|
||||
point = path[0]
|
||||
self.f.write('<polygon fill="#%02x%02x%02x"' % stype.get_fill_color())
|
||||
@ -158,7 +161,8 @@ class SvgDrawDoc(BaseDoc.BaseDoc):
|
||||
x = x + self.paper.get_left_margin()
|
||||
y = y + self.paper.get_top_margin()
|
||||
|
||||
box_style = self.draw_styles[style]
|
||||
style_sheet = self.get_style_sheet()
|
||||
box_style = style_sheet.get_draw_style(style)
|
||||
|
||||
if box_style.get_shadow():
|
||||
self.f.write('<rect ')
|
||||
@ -178,7 +182,7 @@ class SvgDrawDoc(BaseDoc.BaseDoc):
|
||||
if text != "":
|
||||
para_name = box_style.get_paragraph_style()
|
||||
assert( para_name != '' )
|
||||
p = self.style_list[para_name]
|
||||
p = style_sheet.get_paragraph_style(para_name)
|
||||
font = p.get_font()
|
||||
font_size = font.get_size()
|
||||
lines = text.split('\n')
|
||||
@ -210,9 +214,10 @@ class SvgDrawDoc(BaseDoc.BaseDoc):
|
||||
x = x + self.paper.get_left_margin()
|
||||
y = y + self.paper.get_top_margin()
|
||||
|
||||
box_style = self.draw_styles[style]
|
||||
para_name = box_style.get_paragraph_style()
|
||||
p = self.style_list[para_name]
|
||||
style_sheet = self.get_style_sheet()
|
||||
box_style = style_sheet.get_draw_style(style)
|
||||
para_name = box_style.get_paragraph_style()
|
||||
p = style_sheet.get_paragraph_style(para_name)
|
||||
|
||||
font = p.get_font()
|
||||
font_size = font.get_size()
|
||||
@ -235,9 +240,10 @@ class SvgDrawDoc(BaseDoc.BaseDoc):
|
||||
self.f.write('</text>\n')
|
||||
|
||||
def center_text(self, style, text, x, y):
|
||||
box_style = self.draw_styles[style]
|
||||
style_sheet = self.get_style_sheet()
|
||||
box_style = style_sheet.get_draw_style(style)
|
||||
para_name = box_style.get_paragraph_style()
|
||||
p = self.style_list[para_name]
|
||||
p = style_sheet.get_paragraph_style(para_name)
|
||||
font = p.get_font()
|
||||
font_size = font.get_size()
|
||||
width = self.string_width(font,text) / 72
|
||||
|
@ -2,6 +2,7 @@
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2006 Donald N. Allingham
|
||||
# Copyright (C) 2007 Brian G. Matherly
|
||||
#
|
||||
# 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
|
||||
@ -200,9 +201,7 @@ class AncestorChart(Report):
|
||||
self.box_width = 0
|
||||
self.box_height = 0
|
||||
self.lines = 0
|
||||
|
||||
self.font = self.doc.style_list["AC2-Normal"].get_font()
|
||||
self.tfont = self.doc.style_list["AC2-Title"].get_font()
|
||||
self.scale = 1
|
||||
|
||||
self.apply_filter(self.start_person.get_handle(),1)
|
||||
|
||||
@ -214,6 +213,9 @@ class AncestorChart(Report):
|
||||
for key in self.map.keys():
|
||||
self.genchart.set(key,self.map[key])
|
||||
self.calc()
|
||||
|
||||
if self.force_fit:
|
||||
self.scale_styles()
|
||||
|
||||
def apply_filter(self,person_handle,index):
|
||||
"""traverse the ancestors recursively until either the end
|
||||
@ -225,14 +227,18 @@ class AncestorChart(Report):
|
||||
self.map[index] = person_handle
|
||||
|
||||
self.text[index] = []
|
||||
|
||||
style_sheet = self.doc.get_style_sheet()
|
||||
pstyle = style_sheet.get_paragraph_style("AC2-Normal")
|
||||
font = pstyle.get_font()
|
||||
|
||||
em = self.doc.string_width(self.font,"m")
|
||||
em = self.doc.string_width(font,"m")
|
||||
|
||||
subst = SubstKeywords(self.database,person_handle)
|
||||
self.text[index] = subst.replace_and_clean(self.display.split('\n'))
|
||||
|
||||
for line in self.text[index]:
|
||||
this_box_width = self.doc.string_width(self.font,line) + 2*em
|
||||
this_box_width = self.doc.string_width(font,line)
|
||||
self.box_width = max(self.box_width,this_box_width)
|
||||
|
||||
self.lines = max(self.lines,len(self.text[index]))
|
||||
@ -275,6 +281,7 @@ class AncestorChart(Report):
|
||||
that and the page dimensions, calculate the proper place to put
|
||||
the elements on a page.
|
||||
"""
|
||||
style_sheet = self.doc.get_style_sheet()
|
||||
|
||||
self.add_lines()
|
||||
if self.compress:
|
||||
@ -282,7 +289,9 @@ class AncestorChart(Report):
|
||||
|
||||
self.box_pad_pts = 10
|
||||
if self.title and self.force_fit:
|
||||
self.offset = pt2cm(1.25* self.tfont.get_size())
|
||||
pstyle = style_sheet.get_paragraph_style("AC2-Title")
|
||||
tfont = pstyle.get_font()
|
||||
self.offset = pt2cm(1.25* tfont.get_size())
|
||||
else:
|
||||
self.offset = 0
|
||||
self.uh = self.doc.get_usable_height() - self.offset
|
||||
@ -290,10 +299,10 @@ class AncestorChart(Report):
|
||||
|
||||
calc_width = pt2cm(self.box_width + self.box_pad_pts) + 0.2
|
||||
self.box_width = pt2cm(self.box_width)
|
||||
self.box_height = self.lines*pt2cm(1.25*self.font.get_size())
|
||||
pstyle = style_sheet.get_paragraph_style("AC2-Normal")
|
||||
font = pstyle.get_font()
|
||||
self.box_height = self.lines*pt2cm(1.25*font.get_size())
|
||||
|
||||
self.scale = 1
|
||||
|
||||
if self.force_fit:
|
||||
(maxy,maxx) = self.genchart.dimensions()
|
||||
|
||||
@ -323,24 +332,25 @@ class AncestorChart(Report):
|
||||
calc_width = self.box_width + 0.2 + pt2cm(self.box_pad_pts)
|
||||
remain = self.doc.get_usable_width() - ((self.generations_per_page)*calc_width)
|
||||
self.delta += remain/(self.generations_per_page)
|
||||
|
||||
self.font.set_size(self.font.get_size()/self.scale)
|
||||
|
||||
def scale_styles(self):
|
||||
"""
|
||||
Scale the styles for this report. This must be done in the constructor.
|
||||
"""
|
||||
style_sheet = self.doc.get_style_sheet()
|
||||
|
||||
g = BaseDoc.GraphicsStyle()
|
||||
g.set_paragraph_style("AC2-Normal")
|
||||
g.set_shadow(1,0.2/self.scale)
|
||||
g.set_fill_color((255,255,255))
|
||||
self.doc.add_draw_style("AC2-box",g)
|
||||
g = style_sheet.get_draw_style("AC2-box")
|
||||
g.set_shadow(g.get_shadow(),g.get_shadow_space()/self.scale)
|
||||
g.set_line_width(g.get_line_width()/self.scale)
|
||||
style_sheet.add_draw_style("AC2-box",g)
|
||||
|
||||
g = BaseDoc.GraphicsStyle()
|
||||
g.set_paragraph_style("AC2-Title")
|
||||
g.set_color((0,0,0))
|
||||
g.set_fill_color((255,255,255))
|
||||
g.set_line_width(0)
|
||||
self.doc.add_draw_style("AC2-title",g)
|
||||
|
||||
g = BaseDoc.GraphicsStyle()
|
||||
self.doc.add_draw_style("AC2-line",g)
|
||||
p = style_sheet.get_paragraph_style("AC2-Normal")
|
||||
font = p.get_font()
|
||||
font.set_size(font.get_size()/self.scale)
|
||||
p.set_font(font)
|
||||
style_sheet.add_paragraph_style("AC2-Normal",p)
|
||||
|
||||
self.doc.set_style_sheet(style_sheet)
|
||||
|
||||
def print_page(self,startx,stopx,starty,stopy,colx,coly):
|
||||
|
||||
@ -510,13 +520,15 @@ class AncestorChartOptions(ReportOptions):
|
||||
|
||||
def make_default_style(self,default_style):
|
||||
"""Make the default output style for the Ancestor Chart report."""
|
||||
|
||||
## Paragraph Styles:
|
||||
f = BaseDoc.FontStyle()
|
||||
f.set_size(9)
|
||||
f.set_type_face(BaseDoc.FONT_SANS_SERIF)
|
||||
p = BaseDoc.ParagraphStyle()
|
||||
p.set_font(f)
|
||||
p.set_description(_('The basic style used for the text display.'))
|
||||
default_style.add_style("AC2-Normal",p)
|
||||
default_style.add_paragraph_style("AC2-Normal",p)
|
||||
|
||||
f = BaseDoc.FontStyle()
|
||||
f.set_size(16)
|
||||
@ -525,7 +537,24 @@ class AncestorChartOptions(ReportOptions):
|
||||
p.set_font(f)
|
||||
p.set_alignment(BaseDoc.PARA_ALIGN_CENTER)
|
||||
p.set_description(_('The basic style used for the title display.'))
|
||||
default_style.add_style("AC2-Title",p)
|
||||
default_style.add_paragraph_style("AC2-Title",p)
|
||||
|
||||
## Draw styles
|
||||
g = BaseDoc.GraphicsStyle()
|
||||
g.set_paragraph_style("AC2-Normal")
|
||||
g.set_shadow(1,0.2)
|
||||
g.set_fill_color((255,255,255))
|
||||
default_style.add_draw_style("AC2-box",g)
|
||||
|
||||
g = BaseDoc.GraphicsStyle()
|
||||
g.set_paragraph_style("AC2-Title")
|
||||
g.set_color((0,0,0))
|
||||
g.set_fill_color((255,255,255))
|
||||
g.set_line_width(0)
|
||||
default_style.add_draw_style("AC2-title",g)
|
||||
|
||||
g = BaseDoc.GraphicsStyle()
|
||||
default_style.add_draw_style("AC2-line",g)
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
|
@ -2,6 +2,7 @@
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2006 Donald N. Allingham
|
||||
# Copyright (C) 2007 Brian G. Matherly
|
||||
#
|
||||
# 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
|
||||
@ -279,7 +280,7 @@ class AncestorOptions(ReportOptions):
|
||||
para.set_bottom_margin(0.25)
|
||||
para.set_alignment(BaseDoc.PARA_ALIGN_CENTER)
|
||||
para.set_description(_('The style used for the title of the page.'))
|
||||
default_style.add_style("AHN-Title",para)
|
||||
default_style.add_paragraph_style("AHN-Title",para)
|
||||
|
||||
#
|
||||
# AHN-Generation
|
||||
@ -292,7 +293,7 @@ class AncestorOptions(ReportOptions):
|
||||
para.set_top_margin(0.125)
|
||||
para.set_bottom_margin(0.125)
|
||||
para.set_description(_('The style used for the generation header.'))
|
||||
default_style.add_style("AHN-Generation",para)
|
||||
default_style.add_paragraph_style("AHN-Generation",para)
|
||||
|
||||
#
|
||||
# AHN-Entry
|
||||
@ -302,7 +303,7 @@ class AncestorOptions(ReportOptions):
|
||||
para.set_top_margin(0.125)
|
||||
para.set_bottom_margin(0.125)
|
||||
para.set_description(_('The basic style used for the text display.'))
|
||||
default_style.add_style("AHN-Entry",para)
|
||||
default_style.add_paragraph_style("AHN-Entry",para)
|
||||
|
||||
def add_user_options(self,dialog):
|
||||
"""
|
||||
|
@ -2,6 +2,7 @@
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2006 Donald N. Allingham
|
||||
# Copyright (C) 2007 Brian G. Matherly
|
||||
#
|
||||
# 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
|
||||
@ -140,9 +141,7 @@ class DescendChart(Report):
|
||||
self.box_width = 0
|
||||
self.box_height = 0
|
||||
self.lines = 0
|
||||
|
||||
self.font = self.doc.style_list["DC2-Normal"].get_font()
|
||||
self.tfont = self.doc.style_list["DC2-Title"].get_font()
|
||||
self.scale = 1
|
||||
self.box_gap = 0.2
|
||||
|
||||
self.genchart = GenChart(32)
|
||||
@ -150,6 +149,9 @@ class DescendChart(Report):
|
||||
self.apply_filter(self.start_person.get_handle(),0,0)
|
||||
|
||||
self.calc()
|
||||
|
||||
if self.force_fit:
|
||||
self.scale_styles()
|
||||
|
||||
def apply_filter(self,person_handle,x,y):
|
||||
"""traverse the ancestors recursively until either the end
|
||||
@ -164,14 +166,17 @@ class DescendChart(Report):
|
||||
person = self.database.get_person_from_handle(person_handle)
|
||||
|
||||
index = 0
|
||||
|
||||
style_sheet = self.doc.get_style_sheet()
|
||||
pstyle = style_sheet.get_paragraph_style("DC2-Normal")
|
||||
font = pstyle.get_font()
|
||||
|
||||
em = self.doc.string_width(self.font,"m")
|
||||
em = self.doc.string_width(font,"m")
|
||||
|
||||
subst = SubstKeywords(self.database,person_handle)
|
||||
self.text[(x,y)] = subst.replace_and_clean(self.display.split('\n'))
|
||||
self.font = self.doc.style_list["DC2-Normal"].get_font()
|
||||
for line in self.text[(x,y)]:
|
||||
this_box_width = self.doc.string_width(self.font,line) + 2*em
|
||||
this_box_width = self.doc.string_width(font,line) + 2*em
|
||||
self.box_width = max(self.box_width,this_box_width)
|
||||
|
||||
self.lines = max(self.lines,len(self.text[(x,y)]))
|
||||
@ -255,12 +260,15 @@ class DescendChart(Report):
|
||||
that and the page dimensions, calculate the proper place to put
|
||||
the elements on a page.
|
||||
"""
|
||||
style_sheet = self.doc.get_style_sheet()
|
||||
|
||||
self.add_lines()
|
||||
|
||||
self.box_pad_pts = 10
|
||||
if self.title and self.force_fit:
|
||||
self.offset = pt2cm(1.25* self.tfont.get_size())
|
||||
pstyle = style_sheet.get_paragraph_style("DC2-Title")
|
||||
tfont = pstyle.get_font()
|
||||
self.offset = pt2cm(1.25* tfont.get_size())
|
||||
else:
|
||||
self.offset = 0
|
||||
self.uh = self.doc.get_usable_height() - self.offset
|
||||
@ -268,7 +276,9 @@ class DescendChart(Report):
|
||||
|
||||
calc_width = pt2cm(self.box_width + self.box_pad_pts) + self.box_gap
|
||||
self.box_width = pt2cm(self.box_width)
|
||||
self.box_height = self.lines*pt2cm(1.25*self.font.get_size())
|
||||
pstyle = style_sheet.get_paragraph_style("DC2-Normal")
|
||||
font = pstyle.get_font()
|
||||
self.box_height = self.lines*pt2cm(1.25*font.get_size())
|
||||
|
||||
self.scale = 1
|
||||
|
||||
@ -299,25 +309,24 @@ class DescendChart(Report):
|
||||
remain = self.doc.get_usable_width() - ((self.generations_per_page)*calc_width)
|
||||
self.delta += remain/float(self.generations_per_page)
|
||||
|
||||
self.font.set_size(self.font.get_size()/self.scale)
|
||||
def scale_styles(self):
|
||||
"""
|
||||
Scale the styles for this report. This must be done in the constructor.
|
||||
"""
|
||||
style_sheet = self.doc.get_style_sheet()
|
||||
|
||||
g = BaseDoc.GraphicsStyle()
|
||||
g.set_paragraph_style("DC2-Normal")
|
||||
g.set_shadow(1,min(self.box_gap,0.2))
|
||||
|
||||
g = style_sheet.get_draw_style("DC2-box")
|
||||
g.set_shadow(g.get_shadow(),g.get_shadow_space()/self.scale)
|
||||
g.set_line_width(g.get_line_width()/self.scale)
|
||||
g.set_fill_color((255,255,255))
|
||||
self.doc.add_draw_style("DC2-box",g)
|
||||
|
||||
g = BaseDoc.GraphicsStyle()
|
||||
g.set_paragraph_style("DC2-Title")
|
||||
g.set_color((0,0,0))
|
||||
g.set_fill_color((255,255,255))
|
||||
g.set_line_width(0)
|
||||
self.doc.add_draw_style("DC2-title",g)
|
||||
|
||||
g = BaseDoc.GraphicsStyle()
|
||||
self.doc.add_draw_style("DC2-line",g)
|
||||
style_sheet.add_draw_style("DC2-box",g)
|
||||
|
||||
p = style_sheet.get_paragraph_style("DC2-Normal")
|
||||
font = p.get_font()
|
||||
font.set_size(font.get_size()/self.scale)
|
||||
p.set_font(font)
|
||||
style_sheet.add_paragraph_style("DC2-Normal",p)
|
||||
|
||||
self.doc.set_style_sheet(style_sheet)
|
||||
|
||||
def print_page(self,startx,stopx,starty,stopy,colx,coly):
|
||||
|
||||
@ -457,13 +466,14 @@ class DescendChartOptions(ReportOptions):
|
||||
|
||||
def make_default_style(self,default_style):
|
||||
"""Make the default output style for the Ancestor Chart report."""
|
||||
## Paragraph Styles:
|
||||
f = BaseDoc.FontStyle()
|
||||
f.set_size(9)
|
||||
f.set_type_face(BaseDoc.FONT_SANS_SERIF)
|
||||
p = BaseDoc.ParagraphStyle()
|
||||
p.set_font(f)
|
||||
p.set_description(_('The basic style used for the text display.'))
|
||||
default_style.add_style("DC2-Normal",p)
|
||||
default_style.add_paragraph_style("DC2-Normal",p)
|
||||
|
||||
f = BaseDoc.FontStyle()
|
||||
f.set_size(16)
|
||||
@ -472,7 +482,24 @@ class DescendChartOptions(ReportOptions):
|
||||
p.set_font(f)
|
||||
p.set_alignment(BaseDoc.PARA_ALIGN_CENTER)
|
||||
p.set_description(_('The basic style used for the title display.'))
|
||||
default_style.add_style("DC2-Title",p)
|
||||
default_style.add_paragraph_style("DC2-Title",p)
|
||||
|
||||
## Draw styles
|
||||
g = BaseDoc.GraphicsStyle()
|
||||
g.set_paragraph_style("DC2-Normal")
|
||||
g.set_shadow(1,0.2)
|
||||
g.set_fill_color((255,255,255))
|
||||
default_style.add_draw_style("DC2-box",g)
|
||||
|
||||
g = BaseDoc.GraphicsStyle()
|
||||
g.set_paragraph_style("DC2-Title")
|
||||
g.set_color((0,0,0))
|
||||
g.set_fill_color((255,255,255))
|
||||
g.set_line_width(0)
|
||||
default_style.add_draw_style("DC2-title",g)
|
||||
|
||||
g = BaseDoc.GraphicsStyle()
|
||||
default_style.add_draw_style("DC2-line",g)
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
|
@ -2,7 +2,7 @@
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2006 Donald N. Allingham
|
||||
# (C) 2007 Brian Matherly
|
||||
# Copyright (C) 2007 Brian G. Matherly
|
||||
#
|
||||
# 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
|
||||
@ -238,7 +238,7 @@ class DescendantOptions(ReportOptions):
|
||||
p.set_font(f)
|
||||
p.set_alignment(BaseDoc.PARA_ALIGN_CENTER)
|
||||
p.set_description(_("The style used for the title of the page."))
|
||||
default_style.add_style("DR-Title",p)
|
||||
default_style.add_paragraph_style("DR-Title",p)
|
||||
|
||||
f = BaseDoc.FontStyle()
|
||||
f.set_size(10)
|
||||
@ -251,7 +251,7 @@ class DescendantOptions(ReportOptions):
|
||||
p.set_left_margin(min(10.0,float(i-0.5)))
|
||||
p.set_description(_("The style used for the "
|
||||
"level %d display.") % i)
|
||||
default_style.add_style("DR-Level%d" % min(i,32), p)
|
||||
default_style.add_paragraph_style("DR-Level%d" % min(i,32), p)
|
||||
|
||||
p = BaseDoc.ParagraphStyle()
|
||||
p.set_font(f)
|
||||
@ -260,7 +260,7 @@ class DescendantOptions(ReportOptions):
|
||||
p.set_left_margin(min(10.0,float(i-0.5)))
|
||||
p.set_description(_("The style used for the "
|
||||
"spouse level %d display.") % i)
|
||||
default_style.add_style("DR-Spouse%d" % min(i,32), p)
|
||||
default_style.add_paragraph_style("DR-Spouse%d" % min(i,32), p)
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
|
@ -3,7 +3,7 @@
|
||||
#
|
||||
# Copyright (C) 2000-2002 Bruce J. DeGrasse
|
||||
# Copyright (C) 2000-2006 Donald N. Allingham
|
||||
# Copyright (C) 2007 Brian Matherly
|
||||
# Copyright (C) 2007 Brian G. Matherly
|
||||
#
|
||||
# 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
|
||||
@ -768,7 +768,7 @@ class DetAncestorOptions(ReportOptions):
|
||||
para.set_bottom_margin(0.25)
|
||||
para.set_alignment(BaseDoc.PARA_ALIGN_CENTER)
|
||||
para.set_description(_('The style used for the title of the page.'))
|
||||
default_style.add_style("DAR-Title",para)
|
||||
default_style.add_paragraph_style("DAR-Title",para)
|
||||
|
||||
font = BaseDoc.FontStyle()
|
||||
font.set(face=BaseDoc.FONT_SANS_SERIF,size=14,italic=1)
|
||||
@ -778,7 +778,7 @@ class DetAncestorOptions(ReportOptions):
|
||||
para.set_top_margin(0.25)
|
||||
para.set_bottom_margin(0.25)
|
||||
para.set_description(_('The style used for the generation header.'))
|
||||
default_style.add_style("DAR-Generation",para)
|
||||
default_style.add_paragraph_style("DAR-Generation",para)
|
||||
|
||||
font = BaseDoc.FontStyle()
|
||||
font.set(face=BaseDoc.FONT_SANS_SERIF,size=10,italic=0, bold=1)
|
||||
@ -788,7 +788,7 @@ class DetAncestorOptions(ReportOptions):
|
||||
para.set_top_margin(0.25)
|
||||
para.set_bottom_margin(0.25)
|
||||
para.set_description(_('The style used for the children list title.'))
|
||||
default_style.add_style("DAR-ChildTitle",para)
|
||||
default_style.add_paragraph_style("DAR-ChildTitle",para)
|
||||
|
||||
font = BaseDoc.FontStyle()
|
||||
font.set(size=10)
|
||||
@ -798,7 +798,7 @@ class DetAncestorOptions(ReportOptions):
|
||||
para.set_top_margin(0.25)
|
||||
para.set_bottom_margin(0.25)
|
||||
para.set_description(_('The style used for the children list.'))
|
||||
default_style.add_style("DAR-ChildList",para)
|
||||
default_style.add_paragraph_style("DAR-ChildList",para)
|
||||
|
||||
font = BaseDoc.FontStyle()
|
||||
font.set(face=BaseDoc.FONT_SANS_SERIF,size=10,italic=0, bold=1)
|
||||
@ -807,21 +807,21 @@ class DetAncestorOptions(ReportOptions):
|
||||
para.set(first_indent=0.0,lmargin=1.0)
|
||||
para.set_top_margin(0.25)
|
||||
para.set_bottom_margin(0.25)
|
||||
default_style.add_style("DAR-NoteHeader",para)
|
||||
default_style.add_paragraph_style("DAR-NoteHeader",para)
|
||||
|
||||
para = BaseDoc.ParagraphStyle()
|
||||
para.set(lmargin=1.0)
|
||||
para.set_top_margin(0.25)
|
||||
para.set_bottom_margin(0.25)
|
||||
para.set_description(_('The basic style used for the text display.'))
|
||||
default_style.add_style("DAR-Entry",para)
|
||||
default_style.add_paragraph_style("DAR-Entry",para)
|
||||
|
||||
para = BaseDoc.ParagraphStyle()
|
||||
para.set(first_indent=-1.0,lmargin=1.0)
|
||||
para.set_top_margin(0.25)
|
||||
para.set_bottom_margin(0.25)
|
||||
para.set_description(_('The style used for the first personal entry.'))
|
||||
default_style.add_style("DAR-First-Entry",para)
|
||||
default_style.add_paragraph_style("DAR-First-Entry",para)
|
||||
|
||||
font = BaseDoc.FontStyle()
|
||||
font.set(size=10,face=BaseDoc.FONT_SANS_SERIF,bold=1)
|
||||
@ -831,7 +831,7 @@ class DetAncestorOptions(ReportOptions):
|
||||
para.set_top_margin(0.25)
|
||||
para.set_bottom_margin(0.25)
|
||||
para.set_description(_('The style used for the More About header.'))
|
||||
default_style.add_style("DAR-MoreHeader",para)
|
||||
default_style.add_paragraph_style("DAR-MoreHeader",para)
|
||||
|
||||
font = BaseDoc.FontStyle()
|
||||
font.set(face=BaseDoc.FONT_SERIF,size=10)
|
||||
@ -841,7 +841,7 @@ class DetAncestorOptions(ReportOptions):
|
||||
para.set_top_margin(0.25)
|
||||
para.set_bottom_margin(0.25)
|
||||
para.set_description(_('The style used for additional detail data.'))
|
||||
default_style.add_style("DAR-MoreDetails",para)
|
||||
default_style.add_paragraph_style("DAR-MoreDetails",para)
|
||||
|
||||
font = BaseDoc.FontStyle()
|
||||
font.set(face=BaseDoc.FONT_SANS_SERIF,size=14,italic=1)
|
||||
@ -851,14 +851,14 @@ class DetAncestorOptions(ReportOptions):
|
||||
para.set_top_margin(0.25)
|
||||
para.set_bottom_margin(0.25)
|
||||
para.set_description(_('The style used for the generation header.'))
|
||||
default_style.add_style("DAR-Endnotes-Header",para)
|
||||
default_style.add_paragraph_style("DAR-Endnotes-Header",para)
|
||||
|
||||
para = BaseDoc.ParagraphStyle()
|
||||
para.set(first_indent=-0.8,lmargin=1.5)
|
||||
para.set_top_margin(0.25)
|
||||
para.set_bottom_margin(0.25)
|
||||
para.set_description(_('The basic style used for the endnotes text display.'))
|
||||
default_style.add_style("DAR-Endnotes",para)
|
||||
default_style.add_paragraph_style("DAR-Endnotes",para)
|
||||
|
||||
def add_user_options(self,dialog):
|
||||
"""
|
||||
|
@ -3,7 +3,7 @@
|
||||
#
|
||||
# Copyright (C) 2000-2002 Bruce J. DeGrasse
|
||||
# Copyright (C) 2000-2006 Donald N. Allingham
|
||||
# Copyright (C) 2007 Brian Matherly
|
||||
# Copyright (C) 2007 Brian G. Matherly
|
||||
#
|
||||
# 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
|
||||
@ -798,7 +798,7 @@ class DetDescendantOptions(ReportOptions):
|
||||
para.set_bottom_margin(0.25)
|
||||
para.set_alignment(BaseDoc.PARA_ALIGN_CENTER)
|
||||
para.set_description(_('The style used for the title of the page.'))
|
||||
default_style.add_style("DDR-Title",para)
|
||||
default_style.add_paragraph_style("DDR-Title",para)
|
||||
|
||||
font = BaseDoc.FontStyle()
|
||||
font.set(face=BaseDoc.FONT_SANS_SERIF,size=14,italic=1)
|
||||
@ -808,7 +808,7 @@ class DetDescendantOptions(ReportOptions):
|
||||
para.set_top_margin(0.25)
|
||||
para.set_bottom_margin(0.25)
|
||||
para.set_description(_('The style used for the generation header.'))
|
||||
default_style.add_style("DDR-Generation",para)
|
||||
default_style.add_paragraph_style("DDR-Generation",para)
|
||||
|
||||
font = BaseDoc.FontStyle()
|
||||
font.set(face=BaseDoc.FONT_SANS_SERIF,size=10,italic=0, bold=1)
|
||||
@ -818,7 +818,7 @@ class DetDescendantOptions(ReportOptions):
|
||||
para.set_top_margin(0.25)
|
||||
para.set_bottom_margin(0.25)
|
||||
para.set_description(_('The style used for the children list title.'))
|
||||
default_style.add_style("DDR-ChildTitle",para)
|
||||
default_style.add_paragraph_style("DDR-ChildTitle",para)
|
||||
|
||||
font = BaseDoc.FontStyle()
|
||||
font.set(size=10)
|
||||
@ -828,7 +828,7 @@ class DetDescendantOptions(ReportOptions):
|
||||
para.set_top_margin(0.125)
|
||||
para.set_bottom_margin(0.125)
|
||||
para.set_description(_('The style used for the children list.'))
|
||||
default_style.add_style("DDR-ChildList",para)
|
||||
default_style.add_paragraph_style("DDR-ChildList",para)
|
||||
|
||||
font = BaseDoc.FontStyle()
|
||||
font.set(face=BaseDoc.FONT_SANS_SERIF,size=10,italic=0, bold=1)
|
||||
@ -837,21 +837,21 @@ class DetDescendantOptions(ReportOptions):
|
||||
para.set(first_indent=0.0,lmargin=1.5)
|
||||
para.set_top_margin(0.25)
|
||||
para.set_bottom_margin(0.25)
|
||||
default_style.add_style("DDR-NoteHeader",para)
|
||||
default_style.add_paragraph_style("DDR-NoteHeader",para)
|
||||
|
||||
para = BaseDoc.ParagraphStyle()
|
||||
para.set(lmargin=1.5)
|
||||
para.set_top_margin(0.25)
|
||||
para.set_bottom_margin(0.25)
|
||||
para.set_description(_('The basic style used for the text display.'))
|
||||
default_style.add_style("DDR-Entry",para)
|
||||
default_style.add_paragraph_style("DDR-Entry",para)
|
||||
|
||||
para = BaseDoc.ParagraphStyle()
|
||||
para.set(first_indent=-1.5,lmargin=1.5)
|
||||
para.set_top_margin(0.25)
|
||||
para.set_bottom_margin(0.25)
|
||||
para.set_description(_('The style used for the first personal entry.'))
|
||||
default_style.add_style("DDR-First-Entry",para)
|
||||
default_style.add_paragraph_style("DDR-First-Entry",para)
|
||||
|
||||
font = BaseDoc.FontStyle()
|
||||
font.set(size=10,face=BaseDoc.FONT_SANS_SERIF,bold=1)
|
||||
@ -861,7 +861,7 @@ class DetDescendantOptions(ReportOptions):
|
||||
para.set_top_margin(0.25)
|
||||
para.set_bottom_margin(0.25)
|
||||
para.set_description(_('The style used for the More About header.'))
|
||||
default_style.add_style("DDR-MoreHeader",para)
|
||||
default_style.add_paragraph_style("DDR-MoreHeader",para)
|
||||
|
||||
font = BaseDoc.FontStyle()
|
||||
font.set(face=BaseDoc.FONT_SERIF,size=10)
|
||||
@ -871,7 +871,7 @@ class DetDescendantOptions(ReportOptions):
|
||||
para.set_top_margin(0.25)
|
||||
para.set_bottom_margin(0.25)
|
||||
para.set_description(_('The style used for additional detail data.'))
|
||||
default_style.add_style("DDR-MoreDetails",para)
|
||||
default_style.add_paragraph_style("DDR-MoreDetails",para)
|
||||
|
||||
font = BaseDoc.FontStyle()
|
||||
font.set(face=BaseDoc.FONT_SANS_SERIF,size=14,italic=1)
|
||||
@ -881,14 +881,14 @@ class DetDescendantOptions(ReportOptions):
|
||||
para.set_top_margin(0.25)
|
||||
para.set_bottom_margin(0.25)
|
||||
para.set_description(_('The style used for the generation header.'))
|
||||
default_style.add_style("DDR-Endnotes-Header",para)
|
||||
default_style.add_paragraph_style("DDR-Endnotes-Header",para)
|
||||
|
||||
para = BaseDoc.ParagraphStyle()
|
||||
para.set(first_indent=-0.8,lmargin=1.5)
|
||||
para.set_top_margin(0.25)
|
||||
para.set_bottom_margin(0.25)
|
||||
para.set_description(_('The basic style used for the endnotes text display.'))
|
||||
default_style.add_style("DDR-Endnotes",para)
|
||||
default_style.add_paragraph_style("DDR-Endnotes",para)
|
||||
|
||||
def add_user_options(self,dialog):
|
||||
"""
|
||||
|
@ -2,6 +2,7 @@
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2006 Donald N. Allingham
|
||||
# Copyright (C) 2007 Brian G. Matherly
|
||||
#
|
||||
# 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
|
||||
@ -91,69 +92,6 @@ class FamilyGroup(Report):
|
||||
self.incRelDates = options_class.handler.options_dict['incRelDates']
|
||||
self.incChiMar = options_class.handler.options_dict['incChiMar']
|
||||
|
||||
def define_table_styles(self):
|
||||
"""
|
||||
Define the table styles used by the report.
|
||||
"""
|
||||
cell = BaseDoc.TableCellStyle()
|
||||
cell.set_padding(0.2)
|
||||
cell.set_top_border(1)
|
||||
cell.set_bottom_border(1)
|
||||
cell.set_right_border(1)
|
||||
cell.set_left_border(1)
|
||||
self.doc.add_cell_style('FGR-ParentHead',cell)
|
||||
|
||||
cell = BaseDoc.TableCellStyle()
|
||||
cell.set_padding(0.1)
|
||||
cell.set_bottom_border(1)
|
||||
cell.set_left_border(1)
|
||||
self.doc.add_cell_style('FGR-TextContents',cell)
|
||||
|
||||
cell = BaseDoc.TableCellStyle()
|
||||
cell.set_padding(0.1)
|
||||
cell.set_bottom_border(0)
|
||||
cell.set_left_border(1)
|
||||
cell.set_padding(0.1)
|
||||
self.doc.add_cell_style('FGR-TextChild1',cell)
|
||||
|
||||
cell = BaseDoc.TableCellStyle()
|
||||
cell.set_padding(0.1)
|
||||
cell.set_bottom_border(1)
|
||||
cell.set_left_border(1)
|
||||
cell.set_padding(0.1)
|
||||
self.doc.add_cell_style('FGR-TextChild2',cell)
|
||||
|
||||
cell = BaseDoc.TableCellStyle()
|
||||
cell.set_padding(0.1)
|
||||
cell.set_bottom_border(1)
|
||||
cell.set_right_border(1)
|
||||
cell.set_left_border(1)
|
||||
self.doc.add_cell_style('FGR-TextContentsEnd',cell)
|
||||
|
||||
cell = BaseDoc.TableCellStyle()
|
||||
cell.set_padding(0.2)
|
||||
cell.set_bottom_border(1)
|
||||
cell.set_right_border(1)
|
||||
cell.set_left_border(1)
|
||||
self.doc.add_cell_style('FGR-ChildName',cell)
|
||||
|
||||
table = BaseDoc.TableStyle()
|
||||
table.set_width(100)
|
||||
table.set_columns(3)
|
||||
table.set_column_width(0,20)
|
||||
table.set_column_width(1,40)
|
||||
table.set_column_width(2,40)
|
||||
self.doc.add_table_style('FGR-ParentTable',table)
|
||||
|
||||
table = BaseDoc.TableStyle()
|
||||
table.set_width(100)
|
||||
table.set_columns(4)
|
||||
table.set_column_width(0,7)
|
||||
table.set_column_width(1,18)
|
||||
table.set_column_width(2,35)
|
||||
table.set_column_width(3,40)
|
||||
self.doc.add_table_style('FGR-ChildTable',table)
|
||||
|
||||
def dump_parent_event(self,name,event):
|
||||
place = ""
|
||||
date = ""
|
||||
@ -852,10 +790,11 @@ class FamilyGroupOptions(ReportOptions):
|
||||
def make_default_style(self,default_style):
|
||||
"""Make default output style for the Family Group Report."""
|
||||
para = BaseDoc.ParagraphStyle()
|
||||
#Paragraph Styles
|
||||
font = BaseDoc.FontStyle()
|
||||
font.set_size(4)
|
||||
para.set_font(font)
|
||||
default_style.add_style('FGR-blank',para)
|
||||
default_style.add_paragraph_style('FGR-blank',para)
|
||||
|
||||
font = BaseDoc.FontStyle()
|
||||
font.set_type_face(BaseDoc.FONT_SANS_SERIF)
|
||||
@ -865,7 +804,7 @@ class FamilyGroupOptions(ReportOptions):
|
||||
para.set_font(font)
|
||||
para.set_alignment(BaseDoc.PARA_ALIGN_CENTER)
|
||||
para.set_description(_("The style used for the title of the page."))
|
||||
default_style.add_style('FGR-Title',para)
|
||||
default_style.add_paragraph_style('FGR-Title',para)
|
||||
|
||||
font = BaseDoc.FontStyle()
|
||||
font.set_type_face(BaseDoc.FONT_SERIF)
|
||||
@ -874,7 +813,7 @@ class FamilyGroupOptions(ReportOptions):
|
||||
para = BaseDoc.ParagraphStyle()
|
||||
para.set_font(font)
|
||||
para.set_description(_('The basic style used for the text display.'))
|
||||
default_style.add_style('FGR-Normal',para)
|
||||
default_style.add_paragraph_style('FGR-Normal',para)
|
||||
|
||||
font = BaseDoc.FontStyle()
|
||||
font.set_type_face(BaseDoc.FONT_SANS_SERIF)
|
||||
@ -883,7 +822,7 @@ class FamilyGroupOptions(ReportOptions):
|
||||
para = BaseDoc.ParagraphStyle()
|
||||
para.set_font(font)
|
||||
para.set_description(_('The style used for the text related to the children.'))
|
||||
default_style.add_style('FGR-ChildText',para)
|
||||
default_style.add_paragraph_style('FGR-ChildText',para)
|
||||
|
||||
font = BaseDoc.FontStyle()
|
||||
font.set_type_face(BaseDoc.FONT_SANS_SERIF)
|
||||
@ -892,7 +831,67 @@ class FamilyGroupOptions(ReportOptions):
|
||||
para = BaseDoc.ParagraphStyle()
|
||||
para.set_font(font)
|
||||
para.set_description(_("The style used for the parent's name"))
|
||||
default_style.add_style('FGR-ParentName',para)
|
||||
default_style.add_paragraph_style('FGR-ParentName',para)
|
||||
|
||||
#Table Styles
|
||||
cell = BaseDoc.TableCellStyle()
|
||||
cell.set_padding(0.2)
|
||||
cell.set_top_border(1)
|
||||
cell.set_bottom_border(1)
|
||||
cell.set_right_border(1)
|
||||
cell.set_left_border(1)
|
||||
default_style.add_cell_style('FGR-ParentHead',cell)
|
||||
|
||||
cell = BaseDoc.TableCellStyle()
|
||||
cell.set_padding(0.1)
|
||||
cell.set_bottom_border(1)
|
||||
cell.set_left_border(1)
|
||||
default_style.add_cell_style('FGR-TextContents',cell)
|
||||
|
||||
cell = BaseDoc.TableCellStyle()
|
||||
cell.set_padding(0.1)
|
||||
cell.set_bottom_border(0)
|
||||
cell.set_left_border(1)
|
||||
cell.set_padding(0.1)
|
||||
default_style.add_cell_style('FGR-TextChild1',cell)
|
||||
|
||||
cell = BaseDoc.TableCellStyle()
|
||||
cell.set_padding(0.1)
|
||||
cell.set_bottom_border(1)
|
||||
cell.set_left_border(1)
|
||||
cell.set_padding(0.1)
|
||||
default_style.add_cell_style('FGR-TextChild2',cell)
|
||||
|
||||
cell = BaseDoc.TableCellStyle()
|
||||
cell.set_padding(0.1)
|
||||
cell.set_bottom_border(1)
|
||||
cell.set_right_border(1)
|
||||
cell.set_left_border(1)
|
||||
default_style.add_cell_style('FGR-TextContentsEnd',cell)
|
||||
|
||||
cell = BaseDoc.TableCellStyle()
|
||||
cell.set_padding(0.2)
|
||||
cell.set_bottom_border(1)
|
||||
cell.set_right_border(1)
|
||||
cell.set_left_border(1)
|
||||
default_style.add_cell_style('FGR-ChildName',cell)
|
||||
|
||||
table = BaseDoc.TableStyle()
|
||||
table.set_width(100)
|
||||
table.set_columns(3)
|
||||
table.set_column_width(0,20)
|
||||
table.set_column_width(1,40)
|
||||
table.set_column_width(2,40)
|
||||
default_style.add_table_style('FGR-ParentTable',table)
|
||||
|
||||
table = BaseDoc.TableStyle()
|
||||
table.set_width(100)
|
||||
table.set_columns(4)
|
||||
table.set_column_width(0,7)
|
||||
table.set_column_width(1,18)
|
||||
table.set_column_width(2,35)
|
||||
table.set_column_width(3,40)
|
||||
default_style.add_table_style('FGR-ChildTable',table)
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
|
@ -2,6 +2,7 @@
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2003-2006 Donald N. Allingham
|
||||
# Copyright (C) 2007 Brian G. Matherly
|
||||
#
|
||||
# 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
|
||||
@ -74,10 +75,6 @@ class FanChart(Report):
|
||||
radial_upright - 0: Print radial texts roundabout; 1: Print radial texts as upright as possible.
|
||||
"""
|
||||
|
||||
self.background_color_generation =\
|
||||
[(255,63,0), (255,175,15), (255,223,87), (255,255,111),
|
||||
(159,255,159), (111,215,255), (79,151,255), (231,23,255)]
|
||||
|
||||
self.max_generations = options_class.handler.options_dict['maxgen']
|
||||
self.full_circle = options_class.handler.options_dict['full_circle']
|
||||
self.half_circle = options_class.handler.options_dict['half_circle']
|
||||
@ -88,19 +85,14 @@ class FanChart(Report):
|
||||
self.background_style = []
|
||||
self.text_style = []
|
||||
for i in range (0, self.max_generations):
|
||||
background_style_name = 'background_style' + '%d' % i
|
||||
if self.backgr_white:
|
||||
background_style_name = 'background_style_white'
|
||||
else:
|
||||
background_style_name = 'background_style' + '%d' % i
|
||||
self.background_style.append(background_style_name)
|
||||
text_style_name = 'text_style' + '%d' % i
|
||||
self.text_style.append(text_style_name)
|
||||
|
||||
if self.backgr_white:
|
||||
self.background_color = []
|
||||
for i in range (0, len (self.background_color_generation)):
|
||||
self.background_color.append ((255,255,255))
|
||||
else:
|
||||
self.background_color = self.background_color_generation
|
||||
self.MAX_GENERATION = len (self.background_color)
|
||||
|
||||
Report.__init__(self,database,person,options_class)
|
||||
|
||||
self.height = 0
|
||||
@ -110,32 +102,6 @@ class FanChart(Report):
|
||||
self.text= {}
|
||||
self.box_width = 0
|
||||
|
||||
|
||||
def define_graphics_styles(self):
|
||||
g = BaseDoc.GraphicsStyle()
|
||||
g.set_paragraph_style('FC-Title')
|
||||
g.set_line_width(0)
|
||||
self.doc.add_draw_style("t",g)
|
||||
|
||||
for i in range (0, self.max_generations):
|
||||
# Continuous colors:
|
||||
color_index = i % self.MAX_GENERATION
|
||||
|
||||
g = BaseDoc.GraphicsStyle()
|
||||
g.set_fill_color(self.background_color[color_index])
|
||||
g.set_paragraph_style('FC-Normal')
|
||||
background_style_name = 'background_style' + '%d' % i
|
||||
self.doc.add_draw_style(background_style_name,g)
|
||||
|
||||
g = BaseDoc.GraphicsStyle()
|
||||
g.set_fill_color(self.background_color[color_index])
|
||||
text_style_name = 'text_style' + '%d' % (self.max_generations - 1)
|
||||
g.set_paragraph_style(text_style_name)
|
||||
g.set_line_width(0)
|
||||
text_style_name = 'text_style' + '%d' % i
|
||||
self.doc.add_draw_style(text_style_name,g)
|
||||
|
||||
|
||||
def apply_filter(self,person_handle,index):
|
||||
"""traverse the ancestors recursively until either the end
|
||||
of a line is found, or until we reach the maximum number of
|
||||
@ -152,8 +118,8 @@ class FanChart(Report):
|
||||
for line in self.display:
|
||||
self.text[index-1].append(subst.replace(line))
|
||||
|
||||
text_style_name = 'text_style' + '%d' % (self.max_generations - 1)
|
||||
self.font = self.doc.style_list[text_style_name].get_font()
|
||||
style_sheet = self.doc.get_style_sheet()
|
||||
self.font = style_sheet.get_paragraph_style('text_style').get_font()
|
||||
for line in self.text[index-1]:
|
||||
self.box_width = max(self.box_width,self.doc.string_width(self.font,line))
|
||||
|
||||
@ -348,7 +314,8 @@ class FanChartOptions(ReportOptions):
|
||||
|
||||
def __init__(self,name,person_id=None):
|
||||
ReportOptions.__init__(self,name,person_id)
|
||||
|
||||
|
||||
self.MAX_GENERATIONS = 8
|
||||
|
||||
def set_new_options(self):
|
||||
# Options specific for this report
|
||||
@ -394,7 +361,7 @@ class FanChartOptions(ReportOptions):
|
||||
Override the base class add_user_options task to add a menu that allows
|
||||
the user to select the number of generations to print, ....
|
||||
"""
|
||||
self.max_gen = gtk.SpinButton(gtk.Adjustment(5,2,8,1))
|
||||
self.max_gen = gtk.SpinButton(gtk.Adjustment(5,2,self.MAX_GENERATIONS,1))
|
||||
self.max_gen.set_value(self.options_dict['maxgen'])
|
||||
self.max_gen.set_wrap(True)
|
||||
dialog.add_option(_('Generations'),self.max_gen)
|
||||
@ -431,6 +398,18 @@ class FanChartOptions(ReportOptions):
|
||||
|
||||
def make_default_style(self,default_style):
|
||||
"""Make the default output style for the Fan Chart report."""
|
||||
BACKGROUND_COLORS = [
|
||||
(255, 63, 0),
|
||||
(255,175, 15),
|
||||
(255,223, 87),
|
||||
(255,255,111),
|
||||
(159,255,159),
|
||||
(111,215,255),
|
||||
( 79,151,255),
|
||||
(231, 23,255)
|
||||
]
|
||||
|
||||
#Paragraph Styles
|
||||
f = BaseDoc.FontStyle()
|
||||
f.set_size(20)
|
||||
f.set_bold(1)
|
||||
@ -439,19 +418,41 @@ class FanChartOptions(ReportOptions):
|
||||
p.set_font(f)
|
||||
p.set_alignment(BaseDoc.PARA_ALIGN_CENTER)
|
||||
p.set_description(_('The style used for the title.'))
|
||||
default_style.add_style("FC-Title",p)
|
||||
default_style.add_paragraph_style("FC-Title",p)
|
||||
|
||||
font_size = [48, 24, 16, 12, 9, 6, 4, 3]
|
||||
for index in range (0, len (font_size)):
|
||||
f = BaseDoc.FontStyle()
|
||||
f.set_size(font_size[index])
|
||||
f.set_type_face(BaseDoc.FONT_SANS_SERIF)
|
||||
p = BaseDoc.ParagraphStyle()
|
||||
p.set_font(f)
|
||||
p.set_alignment(BaseDoc.PARA_ALIGN_CENTER)
|
||||
p.set_description(_('The basic style used for the text display.'))
|
||||
default_style.add_style("text_style%d" % index, p)
|
||||
f = BaseDoc.FontStyle()
|
||||
f.set_size(9)
|
||||
f.set_type_face(BaseDoc.FONT_SANS_SERIF)
|
||||
p = BaseDoc.ParagraphStyle()
|
||||
p.set_font(f)
|
||||
p.set_alignment(BaseDoc.PARA_ALIGN_CENTER)
|
||||
p.set_description(_('The basic style used for the text display.'))
|
||||
default_style.add_paragraph_style("text_style", p)
|
||||
|
||||
# GraphicsStyles
|
||||
g = BaseDoc.GraphicsStyle()
|
||||
g.set_paragraph_style('FC-Title')
|
||||
g.set_line_width(0)
|
||||
default_style.add_draw_style("t",g)
|
||||
|
||||
for i in range (0, self.MAX_GENERATIONS):
|
||||
g = BaseDoc.GraphicsStyle()
|
||||
g.set_fill_color(BACKGROUND_COLORS[i])
|
||||
g.set_paragraph_style('FC-Normal')
|
||||
background_style_name = 'background_style' + '%d' % i
|
||||
default_style.add_draw_style(background_style_name,g)
|
||||
|
||||
g = BaseDoc.GraphicsStyle()
|
||||
g.set_fill_color(BACKGROUND_COLORS[i])
|
||||
g.set_paragraph_style('text_style')
|
||||
g.set_line_width(0)
|
||||
text_style_name = 'text_style' + '%d' % i
|
||||
default_style.add_draw_style(text_style_name,g)
|
||||
|
||||
g = BaseDoc.GraphicsStyle()
|
||||
g.set_fill_color((255,255,255))
|
||||
g.set_paragraph_style('FC-Normal')
|
||||
default_style.add_draw_style('background_style_white',g)
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
|
@ -2,6 +2,7 @@
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2006 Donald N. Allingham
|
||||
# Copyright (C) 2007 Brian G. Matherly
|
||||
#
|
||||
# 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
|
||||
@ -86,33 +87,6 @@ class IndivCompleteReport(Report):
|
||||
filters = ReportUtils.get_person_filters(person)
|
||||
self.filter = filters[filter_num]
|
||||
self.sref_map = {}
|
||||
|
||||
def define_table_styles(self):
|
||||
tbl = BaseDoc.TableStyle()
|
||||
tbl.set_width(100)
|
||||
tbl.set_columns(2)
|
||||
tbl.set_column_width(0,20)
|
||||
tbl.set_column_width(1,80)
|
||||
self.doc.add_table_style("IDS-IndTable",tbl)
|
||||
|
||||
tbl = BaseDoc.TableStyle()
|
||||
tbl.set_width(100)
|
||||
tbl.set_columns(2)
|
||||
tbl.set_column_width(0,50)
|
||||
tbl.set_column_width(1,50)
|
||||
self.doc.add_table_style("IDS-ParentsTable",tbl)
|
||||
|
||||
cell = BaseDoc.TableCellStyle()
|
||||
cell.set_top_border(1)
|
||||
cell.set_bottom_border(1)
|
||||
self.doc.add_cell_style("IDS-TableHead",cell)
|
||||
|
||||
cell = BaseDoc.TableCellStyle()
|
||||
self.doc.add_cell_style("IDS-NormalCell",cell)
|
||||
|
||||
cell = BaseDoc.TableCellStyle()
|
||||
cell.set_longlist(1)
|
||||
self.doc.add_cell_style("IDS-ListCell",cell)
|
||||
|
||||
def write_fact(self,event):
|
||||
if event == None:
|
||||
@ -603,6 +577,7 @@ class IndivCompleteOptions(ReportOptions):
|
||||
|
||||
def make_default_style(self,default_style):
|
||||
"""Make the default output style for the Individual Complete Report."""
|
||||
# Paragraph Styles
|
||||
font = BaseDoc.FontStyle()
|
||||
font.set_bold(1)
|
||||
font.set_type_face(BaseDoc.FONT_SANS_SERIF)
|
||||
@ -613,7 +588,7 @@ class IndivCompleteOptions(ReportOptions):
|
||||
p.set_bottom_margin(ReportUtils.pt2cm(8))
|
||||
p.set_font(font)
|
||||
p.set_description(_("The style used for the title of the page."))
|
||||
default_style.add_style("IDS-Title",p)
|
||||
default_style.add_paragraph_style("IDS-Title",p)
|
||||
|
||||
font = BaseDoc.FontStyle()
|
||||
font.set_bold(1)
|
||||
@ -625,7 +600,7 @@ class IndivCompleteOptions(ReportOptions):
|
||||
p.set_top_margin(ReportUtils.pt2cm(3))
|
||||
p.set_bottom_margin(ReportUtils.pt2cm(3))
|
||||
p.set_description(_("The style used for category labels."))
|
||||
default_style.add_style("IDS-TableTitle",p)
|
||||
default_style.add_paragraph_style("IDS-TableTitle",p)
|
||||
|
||||
font = BaseDoc.FontStyle()
|
||||
font.set_bold(1)
|
||||
@ -636,7 +611,7 @@ class IndivCompleteOptions(ReportOptions):
|
||||
p.set_top_margin(ReportUtils.pt2cm(3))
|
||||
p.set_bottom_margin(ReportUtils.pt2cm(3))
|
||||
p.set_description(_("The style used for the spouse's name."))
|
||||
default_style.add_style("IDS-Spouse",p)
|
||||
default_style.add_paragraph_style("IDS-Spouse",p)
|
||||
|
||||
font = BaseDoc.FontStyle()
|
||||
font.set_size(12)
|
||||
@ -645,7 +620,34 @@ class IndivCompleteOptions(ReportOptions):
|
||||
p.set_top_margin(ReportUtils.pt2cm(3))
|
||||
p.set_bottom_margin(ReportUtils.pt2cm(3))
|
||||
p.set_description(_('The basic style used for the text display.'))
|
||||
default_style.add_style("IDS-Normal",p)
|
||||
default_style.add_paragraph_style("IDS-Normal",p)
|
||||
|
||||
# Table Styles
|
||||
tbl = BaseDoc.TableStyle()
|
||||
tbl.set_width(100)
|
||||
tbl.set_columns(2)
|
||||
tbl.set_column_width(0,20)
|
||||
tbl.set_column_width(1,80)
|
||||
default_style.add_table_style("IDS-IndTable",tbl)
|
||||
|
||||
tbl = BaseDoc.TableStyle()
|
||||
tbl.set_width(100)
|
||||
tbl.set_columns(2)
|
||||
tbl.set_column_width(0,50)
|
||||
tbl.set_column_width(1,50)
|
||||
default_style.add_table_style("IDS-ParentsTable",tbl)
|
||||
|
||||
cell = BaseDoc.TableCellStyle()
|
||||
cell.set_top_border(1)
|
||||
cell.set_bottom_border(1)
|
||||
default_style.add_cell_style("IDS-TableHead",cell)
|
||||
|
||||
cell = BaseDoc.TableCellStyle()
|
||||
default_style.add_cell_style("IDS-NormalCell",cell)
|
||||
|
||||
cell = BaseDoc.TableCellStyle()
|
||||
cell.set_longlist(1)
|
||||
default_style.add_cell_style("IDS-ListCell",cell)
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
|
@ -2,6 +2,7 @@
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2006 Donald N. Allingham
|
||||
# Copyright (C) 2007 Brian G. Matherly
|
||||
#
|
||||
# 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
|
||||
@ -71,26 +72,6 @@ class IndivSummary(Report):
|
||||
|
||||
Report.__init__(self,database,person,options_class)
|
||||
|
||||
def define_table_styles(self):
|
||||
tbl = BaseDoc.TableStyle()
|
||||
tbl.set_width(100)
|
||||
tbl.set_columns(2)
|
||||
tbl.set_column_width(0,20)
|
||||
tbl.set_column_width(1,80)
|
||||
self.doc.add_table_style("IVS-IndTable",tbl)
|
||||
|
||||
cell = BaseDoc.TableCellStyle()
|
||||
cell.set_top_border(1)
|
||||
cell.set_bottom_border(1)
|
||||
self.doc.add_cell_style("IVS-TableHead",cell)
|
||||
|
||||
cell = BaseDoc.TableCellStyle()
|
||||
self.doc.add_cell_style("IVS-NormalCell",cell)
|
||||
|
||||
cell = BaseDoc.TableCellStyle()
|
||||
cell.set_longlist(1)
|
||||
self.doc.add_cell_style("IVS-ListCell",cell)
|
||||
|
||||
def write_fact(self,event):
|
||||
if event == None:
|
||||
return
|
||||
@ -339,6 +320,7 @@ class IndivSummaryOptions(ReportOptions):
|
||||
|
||||
def make_default_style(self,default_style):
|
||||
"""Make the default output style for the Individual Summary Report."""
|
||||
# Paragraph Styles
|
||||
font = BaseDoc.FontStyle()
|
||||
font.set_bold(1)
|
||||
font.set_type_face(BaseDoc.FONT_SANS_SERIF)
|
||||
@ -347,7 +329,7 @@ class IndivSummaryOptions(ReportOptions):
|
||||
p.set_alignment(BaseDoc.PARA_ALIGN_CENTER)
|
||||
p.set_font(font)
|
||||
p.set_description(_("The style used for the title of the page."))
|
||||
default_style.add_style("IVS-Title",p)
|
||||
default_style.add_paragraph_style("IVS-Title",p)
|
||||
|
||||
font = BaseDoc.FontStyle()
|
||||
font.set_bold(1)
|
||||
@ -357,7 +339,7 @@ class IndivSummaryOptions(ReportOptions):
|
||||
p = BaseDoc.ParagraphStyle()
|
||||
p.set_font(font)
|
||||
p.set_description(_("The style used for category labels."))
|
||||
default_style.add_style("IVS-TableTitle",p)
|
||||
default_style.add_paragraph_style("IVS-TableTitle",p)
|
||||
|
||||
font = BaseDoc.FontStyle()
|
||||
font.set_bold(1)
|
||||
@ -366,14 +348,34 @@ class IndivSummaryOptions(ReportOptions):
|
||||
p = BaseDoc.ParagraphStyle()
|
||||
p.set_font(font)
|
||||
p.set_description(_("The style used for the spouse's name."))
|
||||
default_style.add_style("IVS-Spouse",p)
|
||||
default_style.add_paragraph_style("IVS-Spouse",p)
|
||||
|
||||
font = BaseDoc.FontStyle()
|
||||
font.set_size(12)
|
||||
p = BaseDoc.ParagraphStyle()
|
||||
p.set_font(font)
|
||||
p.set_description(_('The basic style used for the text display.'))
|
||||
default_style.add_style("IVS-Normal",p)
|
||||
default_style.add_paragraph_style("IVS-Normal",p)
|
||||
|
||||
#Table Styles
|
||||
tbl = BaseDoc.TableStyle()
|
||||
tbl.set_width(100)
|
||||
tbl.set_columns(2)
|
||||
tbl.set_column_width(0,20)
|
||||
tbl.set_column_width(1,80)
|
||||
default_style.add_table_style("IVS-IndTable",tbl)
|
||||
|
||||
cell = BaseDoc.TableCellStyle()
|
||||
cell.set_top_border(1)
|
||||
cell.set_bottom_border(1)
|
||||
default_style.add_cell_style("IVS-TableHead",cell)
|
||||
|
||||
cell = BaseDoc.TableCellStyle()
|
||||
default_style.add_cell_style("IVS-NormalCell",cell)
|
||||
|
||||
cell = BaseDoc.TableCellStyle()
|
||||
cell.set_longlist(1)
|
||||
default_style.add_cell_style("IVS-ListCell",cell)
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
|
@ -2,6 +2,7 @@
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2003-2006 Donald N. Allingham
|
||||
# Copyright (C) 2007 Brian G. Matherly
|
||||
#
|
||||
# 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
|
||||
@ -554,99 +555,6 @@ class StatisticsChart(Report):
|
||||
|
||||
return index
|
||||
|
||||
|
||||
def define_graphics_styles(self):
|
||||
"""
|
||||
Define the graphics styles used by the report. Paragraph definitions
|
||||
have already been defined in the document. The styles used are:
|
||||
|
||||
SC-title - Contains the SC-Title paragraph style used for
|
||||
the title of the document
|
||||
SC-text - Contains the SC-Name paragraph style used for
|
||||
the individual's name
|
||||
SC-color-N - The colors for drawing pies.
|
||||
SC-bar - A red bar with 0.5pt black line.
|
||||
"""
|
||||
g = BaseDoc.GraphicsStyle()
|
||||
g.set_paragraph_style("SC-Title")
|
||||
g.set_color((0,0,0))
|
||||
g.set_fill_color((255,255,255))
|
||||
g.set_line_width(0)
|
||||
self.doc.add_draw_style("SC-title",g)
|
||||
|
||||
g = BaseDoc.GraphicsStyle()
|
||||
g.set_paragraph_style("SC-Text")
|
||||
g.set_color((0,0,0))
|
||||
g.set_fill_color((255,255,255))
|
||||
g.set_line_width(0)
|
||||
self.doc.add_draw_style("SC-text",g)
|
||||
|
||||
width = 0.8
|
||||
self.colors = 7
|
||||
# red
|
||||
g = BaseDoc.GraphicsStyle()
|
||||
g.set_paragraph_style('SC-Text')
|
||||
g.set_color((0,0,0))
|
||||
g.set_fill_color((255,0,0))
|
||||
g.set_line_width(width)
|
||||
self.doc.add_draw_style("SC-color-0",g)
|
||||
# orange
|
||||
g = BaseDoc.GraphicsStyle()
|
||||
g.set_paragraph_style('SC-Text')
|
||||
g.set_color((0,0,0))
|
||||
g.set_fill_color((255,158,33))
|
||||
g.set_line_width(width)
|
||||
self.doc.add_draw_style("SC-color-1",g)
|
||||
# green
|
||||
g = BaseDoc.GraphicsStyle()
|
||||
g.set_paragraph_style('SC-Text')
|
||||
g.set_color((0,0,0))
|
||||
g.set_fill_color((0,178,0))
|
||||
g.set_line_width(width)
|
||||
self.doc.add_draw_style("SC-color-2",g)
|
||||
# violet
|
||||
g = BaseDoc.GraphicsStyle()
|
||||
g.set_paragraph_style('SC-Text')
|
||||
g.set_color((0,0,0))
|
||||
g.set_fill_color((123,0,123))
|
||||
g.set_line_width(width)
|
||||
self.doc.add_draw_style("SC-color-3",g)
|
||||
# yellow
|
||||
g = BaseDoc.GraphicsStyle()
|
||||
g.set_paragraph_style('SC-Text')
|
||||
g.set_color((0,0,0))
|
||||
g.set_fill_color((255,255,0))
|
||||
g.set_line_width(width)
|
||||
self.doc.add_draw_style("SC-color-4",g)
|
||||
# blue
|
||||
g = BaseDoc.GraphicsStyle()
|
||||
g.set_paragraph_style('SC-Text')
|
||||
g.set_color((0,0,0))
|
||||
g.set_fill_color((0,105,214))
|
||||
g.set_line_width(width)
|
||||
self.doc.add_draw_style("SC-color-5",g)
|
||||
# gray
|
||||
g = BaseDoc.GraphicsStyle()
|
||||
g.set_paragraph_style('SC-Text')
|
||||
g.set_color((0,0,0))
|
||||
g.set_fill_color((210,204,210))
|
||||
g.set_line_width(width)
|
||||
self.doc.add_draw_style("SC-color-6",g)
|
||||
|
||||
g = BaseDoc.GraphicsStyle()
|
||||
g.set_color((0,0,0))
|
||||
g.set_fill_color((255,0,0))
|
||||
g.set_line_width(width)
|
||||
self.doc.add_draw_style("SC-bar",g)
|
||||
|
||||
# legend
|
||||
g = BaseDoc.GraphicsStyle()
|
||||
g.set_paragraph_style('SC-Text')
|
||||
g.set_color((0,0,0))
|
||||
g.set_fill_color((255,255,255))
|
||||
g.set_line_width(0)
|
||||
self.doc.add_draw_style("SC-legend",g)
|
||||
|
||||
def write_report(self):
|
||||
"output the selected statistics..."
|
||||
|
||||
@ -669,17 +577,19 @@ class StatisticsChart(Report):
|
||||
|
||||
# start output
|
||||
self.doc.center_text('SC-title', title, middle, 0)
|
||||
yoffset = ReportUtils.pt2cm(self.doc.style_list['SC-Title'].get_font().get_size())
|
||||
style_sheet = self.doc.get_style_sheet()
|
||||
pstyle = style_sheet.get_paragraph_style('SC-Title')
|
||||
yoffset = ReportUtils.pt2cm(pstyle.get_font().get_size())
|
||||
|
||||
# collect data for output
|
||||
color = 0
|
||||
chart_data = []
|
||||
for key in lookup:
|
||||
style = "SC-color-%d" % color
|
||||
text = "%s (%d)" % (key, data[key])
|
||||
text = "%s (%d)" % (key, data[key])
|
||||
# graphics style, value, and it's label
|
||||
chart_data.append((style, data[key], text))
|
||||
color = (color+1) % self.colors
|
||||
color = (color+1) % 7 # There are only 7 color styles defined
|
||||
|
||||
margin = 1.0
|
||||
legendx = 2.0
|
||||
@ -697,7 +607,9 @@ class StatisticsChart(Report):
|
||||
def output_barchart(self, title, typename, data, lookup):
|
||||
|
||||
pt2cm = ReportUtils.pt2cm
|
||||
font = self.doc.style_list['SC-Text'].get_font()
|
||||
style_sheet = self.doc.get_style_sheet()
|
||||
pstyle = style_sheet.get_paragraph_style('SC-Text')
|
||||
font = pstyle.get_font()
|
||||
|
||||
# set layout variables
|
||||
width = self.doc.get_usable_width()
|
||||
@ -718,7 +630,8 @@ class StatisticsChart(Report):
|
||||
|
||||
# start output
|
||||
self.doc.center_text('SC-title', title, middle, 0)
|
||||
yoffset = pt2cm(self.doc.style_list['SC-Title'].get_font().get_size())
|
||||
pstyle = style_sheet.get_paragraph_style('SC-Title')
|
||||
yoffset = pt2cm(pstyle.get_font().get_size())
|
||||
#print title
|
||||
|
||||
# header
|
||||
@ -800,6 +713,7 @@ class StatisticsChartOptions(ReportOptions):
|
||||
|
||||
def make_default_style(self, default_style):
|
||||
"""Make the default output style for the Statistics report."""
|
||||
# Paragraph Styles
|
||||
f = BaseDoc.FontStyle()
|
||||
f.set_size(10)
|
||||
f.set_type_face(BaseDoc.FONT_SERIF)
|
||||
@ -807,7 +721,7 @@ class StatisticsChartOptions(ReportOptions):
|
||||
p.set_font(f)
|
||||
p.set_alignment(BaseDoc.PARA_ALIGN_LEFT)
|
||||
p.set_description(_("The style used for the items and values."))
|
||||
default_style.add_style("SC-Text",p)
|
||||
default_style.add_paragraph_style("SC-Text",p)
|
||||
|
||||
f = BaseDoc.FontStyle()
|
||||
f.set_size(14)
|
||||
@ -816,7 +730,95 @@ class StatisticsChartOptions(ReportOptions):
|
||||
p.set_font(f)
|
||||
p.set_alignment(BaseDoc.PARA_ALIGN_CENTER)
|
||||
p.set_description(_("The style used for the title of the page."))
|
||||
default_style.add_style("SC-Title",p)
|
||||
default_style.add_paragraph_style("SC-Title",p)
|
||||
|
||||
"""
|
||||
Graphic Styles:
|
||||
SC-title - Contains the SC-Title paragraph style used for
|
||||
the title of the document
|
||||
SC-text - Contains the SC-Name paragraph style used for
|
||||
the individual's name
|
||||
SC-color-N - The colors for drawing pies.
|
||||
SC-bar - A red bar with 0.5pt black line.
|
||||
"""
|
||||
g = BaseDoc.GraphicsStyle()
|
||||
g.set_paragraph_style("SC-Title")
|
||||
g.set_color((0,0,0))
|
||||
g.set_fill_color((255,255,255))
|
||||
g.set_line_width(0)
|
||||
default_style.add_draw_style("SC-title",g)
|
||||
|
||||
g = BaseDoc.GraphicsStyle()
|
||||
g.set_paragraph_style("SC-Text")
|
||||
g.set_color((0,0,0))
|
||||
g.set_fill_color((255,255,255))
|
||||
g.set_line_width(0)
|
||||
default_style.add_draw_style("SC-text",g)
|
||||
|
||||
width = 0.8
|
||||
# red
|
||||
g = BaseDoc.GraphicsStyle()
|
||||
g.set_paragraph_style('SC-Text')
|
||||
g.set_color((0,0,0))
|
||||
g.set_fill_color((255,0,0))
|
||||
g.set_line_width(width)
|
||||
default_style.add_draw_style("SC-color-0",g)
|
||||
# orange
|
||||
g = BaseDoc.GraphicsStyle()
|
||||
g.set_paragraph_style('SC-Text')
|
||||
g.set_color((0,0,0))
|
||||
g.set_fill_color((255,158,33))
|
||||
g.set_line_width(width)
|
||||
default_style.add_draw_style("SC-color-1",g)
|
||||
# green
|
||||
g = BaseDoc.GraphicsStyle()
|
||||
g.set_paragraph_style('SC-Text')
|
||||
g.set_color((0,0,0))
|
||||
g.set_fill_color((0,178,0))
|
||||
g.set_line_width(width)
|
||||
default_style.add_draw_style("SC-color-2",g)
|
||||
# violet
|
||||
g = BaseDoc.GraphicsStyle()
|
||||
g.set_paragraph_style('SC-Text')
|
||||
g.set_color((0,0,0))
|
||||
g.set_fill_color((123,0,123))
|
||||
g.set_line_width(width)
|
||||
default_style.add_draw_style("SC-color-3",g)
|
||||
# yellow
|
||||
g = BaseDoc.GraphicsStyle()
|
||||
g.set_paragraph_style('SC-Text')
|
||||
g.set_color((0,0,0))
|
||||
g.set_fill_color((255,255,0))
|
||||
g.set_line_width(width)
|
||||
default_style.add_draw_style("SC-color-4",g)
|
||||
# blue
|
||||
g = BaseDoc.GraphicsStyle()
|
||||
g.set_paragraph_style('SC-Text')
|
||||
g.set_color((0,0,0))
|
||||
g.set_fill_color((0,105,214))
|
||||
g.set_line_width(width)
|
||||
default_style.add_draw_style("SC-color-5",g)
|
||||
# gray
|
||||
g = BaseDoc.GraphicsStyle()
|
||||
g.set_paragraph_style('SC-Text')
|
||||
g.set_color((0,0,0))
|
||||
g.set_fill_color((210,204,210))
|
||||
g.set_line_width(width)
|
||||
default_style.add_draw_style("SC-color-6",g)
|
||||
|
||||
g = BaseDoc.GraphicsStyle()
|
||||
g.set_color((0,0,0))
|
||||
g.set_fill_color((255,0,0))
|
||||
g.set_line_width(width)
|
||||
default_style.add_draw_style("SC-bar",g)
|
||||
|
||||
# legend
|
||||
g = BaseDoc.GraphicsStyle()
|
||||
g.set_paragraph_style('SC-Text')
|
||||
g.set_color((0,0,0))
|
||||
g.set_fill_color((255,255,255))
|
||||
g.set_line_width(0)
|
||||
default_style.add_draw_style("SC-legend",g)
|
||||
|
||||
def add_user_options(self, dialog):
|
||||
"""
|
||||
|
@ -2,6 +2,7 @@
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2003-2006 Donald N. Allingham
|
||||
# Copyright (C) 2007 Brian G. Matherly
|
||||
#
|
||||
# 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
|
||||
@ -95,68 +96,6 @@ class TimeLine(Report):
|
||||
sort_functions = options_class.get_sort_functions(Sort.Sort(database))
|
||||
self.sort_func = sort_functions[sort_func_num][1]
|
||||
|
||||
def define_graphics_styles(self):
|
||||
"""
|
||||
Define the graphics styles used by the report. Paragraph definitions
|
||||
have already been defined in the document. The styles used are:
|
||||
|
||||
TLG-grid - 0.5pt wide line dashed line. Used for the lines that make up
|
||||
the grid.
|
||||
TLG-line - 0.5pt wide line. Used for the line connecting two endpoints
|
||||
and for the birth marker.
|
||||
TLG-solid - 0.5pt line with a black fill color. Used for the date of
|
||||
death marker.
|
||||
TLG-text - Contains the TLG-Name paragraph style used for the individual's
|
||||
name
|
||||
TLG-title - Contains the TLG-Title paragraph style used for the title of
|
||||
the document
|
||||
TLG-label - Contains the TLG-Label paragraph style used for the year label's
|
||||
in the document.
|
||||
"""
|
||||
g = BaseDoc.GraphicsStyle()
|
||||
g.set_line_width(0.5)
|
||||
g.set_color((0,0,0))
|
||||
self.doc.add_draw_style("TLG-line",g)
|
||||
|
||||
g = BaseDoc.GraphicsStyle()
|
||||
g.set_line_width(0.5)
|
||||
g.set_color((0,0,0))
|
||||
g.set_fill_color((0,0,0))
|
||||
self.doc.add_draw_style("TLG-solid",g)
|
||||
|
||||
g = BaseDoc.GraphicsStyle()
|
||||
g.set_line_width(0.5)
|
||||
g.set_color((0,0,0))
|
||||
g.set_fill_color((255,255,255))
|
||||
self.doc.add_draw_style("open",g)
|
||||
|
||||
g = BaseDoc.GraphicsStyle()
|
||||
g.set_line_width(0.5)
|
||||
g.set_line_style(BaseDoc.DASHED)
|
||||
g.set_color((0,0,0))
|
||||
self.doc.add_draw_style("TLG-grid",g)
|
||||
|
||||
g = BaseDoc.GraphicsStyle()
|
||||
g.set_paragraph_style("TLG-Name")
|
||||
g.set_color((0,0,0))
|
||||
g.set_fill_color((255,255,255))
|
||||
g.set_line_width(0)
|
||||
self.doc.add_draw_style("TLG-text",g)
|
||||
|
||||
g = BaseDoc.GraphicsStyle()
|
||||
g.set_paragraph_style("TLG-Title")
|
||||
g.set_color((0,0,0))
|
||||
g.set_fill_color((255,255,255))
|
||||
g.set_line_width(0)
|
||||
self.doc.add_draw_style("TLG-title",g)
|
||||
|
||||
g = BaseDoc.GraphicsStyle()
|
||||
g.set_paragraph_style("TLG-Label")
|
||||
g.set_color((0,0,0))
|
||||
g.set_fill_color((255,255,255))
|
||||
g.set_line_width(0)
|
||||
self.doc.add_draw_style("TLG-label",g)
|
||||
|
||||
def write_report(self):
|
||||
|
||||
(low,high) = self.find_year_range()
|
||||
@ -170,7 +109,8 @@ class TimeLine(Report):
|
||||
|
||||
st_size = self.name_size()
|
||||
|
||||
font = self.doc.style_list['TLG-Name'].get_font()
|
||||
style_sheet = self.doc.get_style_sheet()
|
||||
font = style_sheet.get_paragraph_style('TLG-Name').get_font()
|
||||
|
||||
incr = pt2cm(font.get_size())
|
||||
pad = incr*.75
|
||||
@ -263,9 +203,10 @@ class TimeLine(Report):
|
||||
"""
|
||||
width = self.doc.get_usable_width()
|
||||
|
||||
title_font = self.doc.style_list['TLG-Title'].get_font()
|
||||
normal_font = self.doc.style_list['TLG-Name'].get_font()
|
||||
label_font = self.doc.style_list['TLG-Label'].get_font()
|
||||
style_sheet = self.doc.get_style_sheet()
|
||||
title_font = style_sheet.get_paragraph_style('TLG-Title').get_font()
|
||||
normal_font = style_sheet.get_paragraph_style('TLG-Name').get_font()
|
||||
label_font = style_sheet.get_paragraph_style('TLG-Label').get_font()
|
||||
|
||||
self.doc.center_text('TLG-title',self.title,width/2.0,0)
|
||||
|
||||
@ -333,8 +274,11 @@ class TimeLine(Report):
|
||||
self.plist = self.filter.apply(self.database,
|
||||
self.database.get_person_handles(sort_handles=False))
|
||||
|
||||
style_name = self.doc.draw_styles['TLG-text'].get_paragraph_style()
|
||||
font = self.doc.style_list[style_name].get_font()
|
||||
style_sheet = self.doc.get_style_sheet()
|
||||
gstyle = style_sheet.get_draw_style('TLG-text')
|
||||
pname = gstyle.get_paragraph_style()
|
||||
pstyle = style_sheet.get_paragraph_style(pname)
|
||||
font = pstyle.get_font()
|
||||
|
||||
size = 0
|
||||
for p_id in self.plist:
|
||||
@ -376,13 +320,14 @@ class TimeLineOptions(ReportOptions):
|
||||
|
||||
def make_default_style(self,default_style):
|
||||
"""Make the default output style for the Timeline report."""
|
||||
# Paragraph Styles
|
||||
f = BaseDoc.FontStyle()
|
||||
f.set_size(10)
|
||||
f.set_type_face(BaseDoc.FONT_SANS_SERIF)
|
||||
p = BaseDoc.ParagraphStyle()
|
||||
p.set_font(f)
|
||||
p.set_description(_("The style used for the person's name."))
|
||||
default_style.add_style("TLG-Name",p)
|
||||
default_style.add_paragraph_style("TLG-Name",p)
|
||||
|
||||
f = BaseDoc.FontStyle()
|
||||
f.set_size(8)
|
||||
@ -391,7 +336,7 @@ class TimeLineOptions(ReportOptions):
|
||||
p.set_font(f)
|
||||
p.set_alignment(BaseDoc.PARA_ALIGN_CENTER)
|
||||
p.set_description(_("The style used for the year labels."))
|
||||
default_style.add_style("TLG-Label",p)
|
||||
default_style.add_paragraph_style("TLG-Label",p)
|
||||
|
||||
f = BaseDoc.FontStyle()
|
||||
f.set_size(14)
|
||||
@ -400,7 +345,66 @@ class TimeLineOptions(ReportOptions):
|
||||
p.set_font(f)
|
||||
p.set_alignment(BaseDoc.PARA_ALIGN_CENTER)
|
||||
p.set_description(_("The style used for the title of the page."))
|
||||
default_style.add_style("TLG-Title",p)
|
||||
default_style.add_paragraph_style("TLG-Title",p)
|
||||
|
||||
"""
|
||||
Graphic Styles
|
||||
TLG-grid - 0.5pt wide line dashed line. Used for the lines that
|
||||
make up the grid.
|
||||
TLG-line - 0.5pt wide line. Used for the line connecting two
|
||||
endpoints and for the birth marker.
|
||||
TLG-solid - 0.5pt line with a black fill color. Used for the date of
|
||||
death marker.
|
||||
TLG-text - Contains the TLG-Name paragraph style used for the
|
||||
individual's name.
|
||||
TLG-title - Contains the TLG-Title paragraph style used for the
|
||||
title of the document.
|
||||
TLG-label - Contains the TLG-Label paragraph style used for the year
|
||||
label's in the document.
|
||||
"""
|
||||
g = BaseDoc.GraphicsStyle()
|
||||
g.set_line_width(0.5)
|
||||
g.set_color((0,0,0))
|
||||
default_style.add_draw_style("TLG-line",g)
|
||||
|
||||
g = BaseDoc.GraphicsStyle()
|
||||
g.set_line_width(0.5)
|
||||
g.set_color((0,0,0))
|
||||
g.set_fill_color((0,0,0))
|
||||
default_style.add_draw_style("TLG-solid",g)
|
||||
|
||||
g = BaseDoc.GraphicsStyle()
|
||||
g.set_line_width(0.5)
|
||||
g.set_color((0,0,0))
|
||||
g.set_fill_color((255,255,255))
|
||||
default_style.add_draw_style("open",g)
|
||||
|
||||
g = BaseDoc.GraphicsStyle()
|
||||
g.set_line_width(0.5)
|
||||
g.set_line_style(BaseDoc.DASHED)
|
||||
g.set_color((0,0,0))
|
||||
default_style.add_draw_style("TLG-grid",g)
|
||||
|
||||
g = BaseDoc.GraphicsStyle()
|
||||
g.set_paragraph_style("TLG-Name")
|
||||
g.set_color((0,0,0))
|
||||
g.set_fill_color((255,255,255))
|
||||
g.set_line_width(0)
|
||||
default_style.add_draw_style("TLG-text",g)
|
||||
|
||||
g = BaseDoc.GraphicsStyle()
|
||||
g.set_paragraph_style("TLG-Title")
|
||||
g.set_color((0,0,0))
|
||||
g.set_fill_color((255,255,255))
|
||||
g.set_line_width(0)
|
||||
default_style.add_draw_style("TLG-title",g)
|
||||
|
||||
g = BaseDoc.GraphicsStyle()
|
||||
g.set_paragraph_style("TLG-Label")
|
||||
g.set_color((0,0,0))
|
||||
g.set_fill_color((255,255,255))
|
||||
g.set_line_width(0)
|
||||
default_style.add_draw_style("TLG-label",g)
|
||||
|
||||
def get_sort_functions(self,sort):
|
||||
return [
|
||||
|
Loading…
Reference in New Issue
Block a user