* src/Report.py: Fix adding styles and calling doc.init().

* src/BaseDoc.py: Restructure header; Replace tabs with spaces.
* src/plugins/AncestorChart.py (calc): Remove doc.init() call.
* src/plugins/AncestorChart2.py (calc): Remove doc.init() call.
* src/plugins/Ancestors.py (define_table_styles): Add method.
* src/plugins/FamilyGroup.py (define_table_styles): Add method.
* src/plugins/FanChart.py (define_graphics_styles): Add method.
* src/plugins/FtmStyleDescendants.py (define_table_styles):
Add method.
* src/plugins/FtmStyleAncestors.py: Minor cleanups
* src/plugins/IndivComplete.py (define_table_styles): Add method.
* src/plugins/IndivSummary.py (define_table_styles): Add method.
* src/plugins/Partition.py: Remove from CVS.
* src/plugins/StatisticsChart.py (define_graphics_styles):
Add method.
* src/plugins/TimeLine.py (define_graphics_styles): Add method.


svn: r3948
This commit is contained in:
Alex Roitman 2005-01-24 16:33:47 +00:00
parent b5ba21b5e4
commit 159c0eb08f
15 changed files with 99 additions and 347 deletions

View File

@ -1,3 +1,21 @@
2005-01-24 Alex Roitman <shura@alex.neuro.umn.edu>
* src/Report.py: Fix adding styles and calling doc.init().
* src/BaseDoc.py: Restructure header; Replace tabs with spaces.
* src/plugins/AncestorChart.py (calc): Remove doc.init() call.
* src/plugins/AncestorChart2.py (calc): Remove doc.init() call.
* src/plugins/Ancestors.py (define_table_styles): Add method.
* src/plugins/FamilyGroup.py (define_table_styles): Add method.
* src/plugins/FanChart.py (define_graphics_styles): Add method.
* src/plugins/FtmStyleDescendants.py (define_table_styles):
Add method.
* src/plugins/FtmStyleAncestors.py: Minor cleanups
* src/plugins/IndivComplete.py (define_table_styles): Add method.
* src/plugins/IndivSummary.py (define_table_styles): Add method.
* src/plugins/Partition.py: Remove from CVS.
* src/plugins/StatisticsChart.py (define_graphics_styles):
Add method.
* src/plugins/TimeLine.py (define_graphics_styles): Add method.
2005-01-23 Don Allingham <dallingham@users.sourceforge.net> 2005-01-23 Don Allingham <dallingham@users.sourceforge.net>
* src/BaseDoc.py: don't check for init on table or cell addition * src/BaseDoc.py: don't check for init on table or cell addition
* src/Report.py: Call doc.init() before write_report * src/Report.py: Call doc.init() before write_report

View File

@ -1,8 +1,23 @@
# #
# Gramps - a GTK+/GNOME based genealogy program # Gramps - a GTK+/GNOME based genealogy program
# #
# Copyright (C) 2000-2004 Donald N. Allingham # Copyright (C) 2000-2005 Donald N. Allingham
# #
# 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
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# Modified September 2002 by Gary Shao # Modified September 2002 by Gary Shao
# #
# Added line_break() method to BaseDoc class to allow breaking a line # Added line_break() method to BaseDoc class to allow breaking a line
@ -34,20 +49,6 @@
# modules the PDF generator is based on does not support them at this # modules the PDF generator is based on does not support them at this
# time) # time)
# #
# 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
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# $Id$ # $Id$
@ -120,7 +121,6 @@ GRAPHICS_MODE = 1
SOLID = 0 SOLID = 0
DASHED = 1 DASHED = 1
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
# cnv2color # cnv2color

View File

@ -216,12 +216,13 @@ class Report:
if output: if output:
self.standalone = True self.standalone = True
self.doc.open(options_class.get_output()) self.doc.open(options_class.get_output())
self.doc.init()
else: else:
self.standalone = False self.standalone = False
self.define_table_styles()
self.define_graphics_styles()
def begin_report(self): def begin_report(self):
self.doc.init()
if self.options_class.get_newpage(): if self.options_class.get_newpage():
self.doc.page_break() self.doc.page_break()
@ -232,6 +233,18 @@ class Report:
if self.standalone: if self.standalone:
self.doc.close() 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
def get_progressbar_data(self): def get_progressbar_data(self):
"""The window title for this dialog, and the header line to """The window title for this dialog, and the header line to
put at the top of the contents of the dialog box.""" put at the top of the contents of the dialog box."""
@ -1759,6 +1772,7 @@ def report(database,person,report_class,options_class,translated_name,name,categ
if response: if response:
try: try:
MyReport = report_class(dialog.db,dialog.person,dialog.options) MyReport = report_class(dialog.db,dialog.person,dialog.options)
MyReport.doc.init()
MyReport.begin_report() MyReport.begin_report()
MyReport.write_report() MyReport.write_report()
MyReport.end_report() MyReport.end_report()
@ -1806,6 +1820,7 @@ def cl_report(database,name,category,report_class,options_class,options_str_dict
clr.option_class.handler.doc = clr.format( clr.option_class.handler.doc = clr.format(
clr.selected_style,clr.paper,clr.template_name,clr.orien) clr.selected_style,clr.paper,clr.template_name,clr.orien)
MyReport = report_class(database, clr.person, clr.option_class) MyReport = report_class(database, clr.person, clr.option_class)
MyReport.doc.init()
MyReport.begin_report() MyReport.begin_report()
MyReport.write_report() MyReport.write_report()
MyReport.end_report() MyReport.end_report()

View File

@ -177,8 +177,6 @@ class AncestorChart(Report.Report):
g = BaseDoc.GraphicsStyle() g = BaseDoc.GraphicsStyle()
self.doc.add_draw_style("AC-line",g) self.doc.add_draw_style("AC-line",g)
if self.standalone:
self.doc.init()
def get_numbers(self,start,index,vals): def get_numbers(self,start,index,vals):
if index > 4: if index > 4:

View File

@ -344,8 +344,6 @@ class AncestorChart(Report.Report):
g = BaseDoc.GraphicsStyle() g = BaseDoc.GraphicsStyle()
self.doc.add_draw_style("AC2-line",g) self.doc.add_draw_style("AC2-line",g)
if self.standalone:
self.doc.init()
def print_page(self,startx,stopx,starty,stopy,colx,coly): def print_page(self,startx,stopx,starty,stopy,colx,coly):

View File

@ -86,6 +86,7 @@ class ComprehensiveAncestorsReport (Report.Report):
self.RelClass = PluginMgr.relationship_class self.RelClass = PluginMgr.relationship_class
self.relationship = self.RelClass(database) self.relationship = self.RelClass(database)
def define_table_styles(self):
table = BaseDoc.TableStyle () table = BaseDoc.TableStyle ()
table.set_column_widths ([15, 85]) table.set_column_widths ([15, 85])
table.set_width (100) table.set_width (100)
@ -131,7 +132,6 @@ class ComprehensiveAncestorsReport (Report.Report):
cell.set_padding (0.1) cell.set_padding (0.1)
self.doc.add_cell_style ("AR-Entry", cell) self.doc.add_cell_style ("AR-Entry", cell)
def write_report(self): def write_report(self):
self.sources = [] self.sources = []
name = self.person_name (self.start_person.get_handle()) name = self.person_name (self.start_person.get_handle())

View File

@ -89,9 +89,7 @@ class FamilyGroup(Report.Report):
self.family = family self.family = family
break break
self.setup() def define_table_styles(self):
def setup(self):
""" """
Define the table styles used by the report. Define the table styles used by the report.
""" """

View File

@ -54,7 +54,6 @@ from ReportUtils import pt2cm
class FanChart(Report.Report): class FanChart(Report.Report):
def __init__(self,database,person,options_class): def __init__(self,database,person,options_class):
#database,person,display,doc,output,newpage=0):
""" """
Creates the FanChart object that produces the report. Creates the FanChart object that produces the report.
@ -78,9 +77,7 @@ class FanChart(Report.Report):
self.text= {} self.text= {}
self.box_width = 0 self.box_width = 0
self.setup() def define_graphics_styles(self):
def setup(self):
g = BaseDoc.GraphicsStyle() g = BaseDoc.GraphicsStyle()
g.set_paragraph_style('FC-Title') g.set_paragraph_style('FC-Title')
g.set_line_width(0) g.set_line_width(0)

View File

@ -1,7 +1,7 @@
# #
# Gramps - a GTK+/GNOME based genealogy program # Gramps - a GTK+/GNOME based genealogy program
# #
# Copyright (C) 2003-2004 Donald N. Allingham # Copyright (C) 2003-2005 Donald N. Allingham
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
@ -37,19 +37,10 @@ from gettext import gettext as _
import Report import Report
import BaseDoc import BaseDoc
import RelLib import RelLib
import Errors
from QuestionDialog import ErrorDialog
import ReportOptions import ReportOptions
import DateHandler from DateHandler import displayer as dd
import const import const
#------------------------------------------------------------------------
#
#
#
#------------------------------------------------------------------------
dd = DateHandler.displayer
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
# AncestorReport # AncestorReport

View File

@ -1,7 +1,7 @@
# #
# Gramps - a GTK+/GNOME based genealogy program # Gramps - a GTK+/GNOME based genealogy program
# #
# Copyright (C) 2003-2004 Donald N. Allingham # Copyright (C) 2003-2005 Donald N. Allingham
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
@ -40,20 +40,11 @@ from gettext import gettext as _
import Report import Report
import BaseDoc import BaseDoc
import RelLib import RelLib
import Errors
import Utils import Utils
import ReportOptions import ReportOptions
from QuestionDialog import ErrorDialog from DateHandler import displayer as dd
import DateHandler
import const import const
#------------------------------------------------------------------------
#
#
#
#------------------------------------------------------------------------
dd = DateHandler.displayer
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
# DescendantReport # DescendantReport
@ -86,12 +77,10 @@ class FtmDescendantReport(Report.Report):
(self.max_generations,self.pgbrk) \ (self.max_generations,self.pgbrk) \
= options_class.get_report_generations() = options_class.get_report_generations()
self.setup()
self.sref_map = {} self.sref_map = {}
self.sref_index = 0 self.sref_index = 0
def setup(self): def define_table_styles(self):
tbl = BaseDoc.TableStyle() tbl = BaseDoc.TableStyle()
tbl.set_width(100) tbl.set_width(100)
tbl.set_columns(3) tbl.set_columns(3)

View File

@ -1,7 +1,7 @@
# #
# Gramps - a GTK+/GNOME based genealogy program # Gramps - a GTK+/GNOME based genealogy program
# #
# Copyright (C) 2000-2004 Donald N. Allingham # Copyright (C) 2000-2005 Donald N. Allingham
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
@ -43,11 +43,8 @@ import gtk
import RelLib import RelLib
import const import const
import BaseDoc import BaseDoc
import StyleEditor
import Report import Report
import GenericFilter import GenericFilter
import Errors
from QuestionDialog import ErrorDialog
import ReportOptions import ReportOptions
#------------------------------------------------------------------------ #------------------------------------------------------------------------
@ -85,12 +82,7 @@ class IndivCompleteReport(Report.Report):
filters.extend(GenericFilter.CustomFilters.get_filters()) filters.extend(GenericFilter.CustomFilters.get_filters())
self.filter = filters[filter_num] self.filter = filters[filter_num]
c = database.get_researcher().get_name() def define_table_styles(self):
self.doc.creator(c)
self.map = {}
self.setup()
def setup(self):
tbl = BaseDoc.TableStyle() tbl = BaseDoc.TableStyle()
tbl.set_width(100) tbl.set_width(100)
tbl.set_columns(2) tbl.set_columns(2)

View File

@ -1,7 +1,7 @@
# #
# Gramps - a GTK+/GNOME based genealogy program # Gramps - a GTK+/GNOME based genealogy program
# #
# Copyright (C) 2000-2004 Donald N. Allingham # Copyright (C) 2000-2005 Donald N. Allingham
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
@ -45,10 +45,7 @@ import gtk
import RelLib import RelLib
import const import const
import BaseDoc import BaseDoc
import StyleEditor
import Report import Report
import Errors
from QuestionDialog import ErrorDialog
import ReportOptions import ReportOptions
import const import const
@ -73,10 +70,7 @@ class IndivSummary(Report.Report):
Report.Report.__init__(self,database,person,options_class) Report.Report.__init__(self,database,person,options_class)
self.map = {} def define_table_styles(self):
self.setup()
def setup(self):
tbl = BaseDoc.TableStyle() tbl = BaseDoc.TableStyle()
tbl.set_width(100) tbl.set_width(100)
tbl.set_columns(2) tbl.set_columns(2)

View File

@ -1,234 +0,0 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2003 Jesper Zedlitz
# Copyright (C) 2003-2004 Donald N. Allingham
#
# 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
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# $Id$
"Export/Partition"
#------------------------------------------------------------------------
#
# standard python modules
#
#------------------------------------------------------------------------
import os
import posixpath
#------------------------------------------------------------------------
#
# GRAMPS modules
#
#------------------------------------------------------------------------
import Utils
import RelLib
import GrampsCfg
from QuestionDialog import ErrorDialog
from gettext import gettext as _
#------------------------------------------------------------------------
#
# GNOME/GTK modules
#
#------------------------------------------------------------------------
import gobject
import gtk
import gtk.glade
from gnome.ui import *
import WriteXML
personSeen = []
familySeen = []
#database_for_unlinked_persons = RelLib.GrampsDB()
prefix = "/tmp/test"
#-------------------------------------------------------------------------
#
#
#
#-------------------------------------------------------------------------
def work_on_person( db, person ):
global personSeen
if (len(person.get_family_handle_list()) + len(person.get_parent_family_handle_list())) > 0:
database = db
#else:
# database = database_for_unlinked_persons
if( database.get_person_handle_map().has_key( person.get_handle() ) ):
return
database.add_person_no_map( person, person.get_handle() )
personSeen.append(person)
for source_ref in person.get_primary_name().get_source_references():
work_on_sourceref( database, source_ref)
for name in person.get_alternate_names():
for source_ref in name.get_source_references():
work_on_sourceref( database, source_ref)
work_on_event( database, person.get_birth() )
work_on_event( database, person.get_death() )
for event in person.get_event_list():
work_on_event(database, event)
# recursion
for fam in person.get_family_handle_list():
work_on_family( database, fam )
for fam in person.get_parent_family_handle_list():
work_on_family( database, fam[0] )
#-------------------------------------------------------------------------
#
#
#
#-------------------------------------------------------------------------
def work_on_family( database, family ):
global familySeen
if database.get_family_handle_map().has_key( family.get_handle() ):
return
database.get_family_handle_map()[family.get_handle()] = family
familySeen.append(family)
work_on_event( database, family.get_marriage() )
for event in family.get_event_list():
work_on_event(database, event)
# recursion
father = family.get_father_handle()
if( father != None ):
work_on_person( database, father )
mother = family.get_mother_handle()
if( mother != None ):
work_on_person( database, mother )
for person in family.get_child_handle_list():
work_on_person( database, person )
#-------------------------------------------------------------------------
#
#
#
#-------------------------------------------------------------------------
def work_on_sourceref( database, source_ref ):
if source_ref == None:
return
source = source_ref.get_base_handle()
if source == None:
return
if database.get_source_map().has_key(source.get_handle()):
return
database.add_source_no_map( source, source.get_handle() );
#-------------------------------------------------------------------------
#
#
#
#-------------------------------------------------------------------------
def work_on_event( database, event ):
if event == None:
return
for source_ref in event.get_source_references():
work_on_sourceref( database, source_ref)
work_on_place( database, event.get_place_handle() )
#-------------------------------------------------------------------------
#
#
#
#-------------------------------------------------------------------------
def work_on_place( database, place ):
if place == None:
return
if place in database.get_place_handles():
return
database.add_place_no_map(place, place.get_handle())
#-------------------------------------------------------------------------
#
#
#
#-------------------------------------------------------------------------
def report(db, person):
global personSeen
global prefix
global database_for_unlinked_persons
text = "=== Partitions ===\n"
count = 0
for p in db.get_person_handle_map().values():
if not p in personSeen:
database = RelLib.GrampsDB()
work_on_person( database, p )
person_len = len(database.get_person_handles(sort_handles=False))
if person_len > 0:
g = WriteXML.XmlWriter(database,None,0,0)
g.write(prefix+str(count)+".xml")
text += "partition "+prefix+str(count)+".xml written ( "+str(person_len)+" persons)\n"
count += 1
g = WriteXML.XmlWriter(database_for_unlinked_persons,None,0,0)
g.write(prefix+".xml")
text += "partition "+prefix+".xml written ( "+str(len(database_for_unlinked_persons.get_person_handles(sort_handles=False)))+" persons)\n"
base = os.path.dirname(__file__)
glade_file = "%s/summary.glade" % base
topDialog = gtk.glade.XML(glade_file,"summary","gramps")
topDialog.signal_autoconnect({
"destroy_passed_object" : Utils.destroy_passed_object,
})
top = topDialog.get_widget("summary")
textwindow = topDialog.get_widget("textwindow")
textwindow.get_buffer().set_text(text)
top.show()
#-------------------------------------------------------------------------
#
#
#
#-------------------------------------------------------------------------
from PluginMgr import register_report
register_report(
report,
_("Partitions"),
status=(_("Alpha")),
category=_("Export"),
description=_("This program partitions individuals in a database into disjoint partitions.\n"+
"A partition is composed of people related by one or more multiple relations.\n"+
"There should be no known relationship between people in different partitions.")
)

View File

@ -409,8 +409,6 @@ class StatisticsChart(Report.Report):
print heading print heading
print table[1] print table[1]
self.setup()
def index_items(self, data, sort, reverse): def index_items(self, data, sort, reverse):
"""creates & stores a sorted index for the items""" """creates & stores a sorted index for the items"""
@ -434,7 +432,7 @@ class StatisticsChart(Report.Report):
return index return index
def setup(self): def define_graphics_styles(self):
""" """
Define the graphics styles used by the report. Paragraph definitions Define the graphics styles used by the report. Paragraph definitions
have already been defined in the document. The styles used are: have already been defined in the document. The styles used are:

View File

@ -95,9 +95,7 @@ class TimeLine(Report.Report):
sort_functions = options_class.get_sort_functions(Sort.Sort(database)) sort_functions = options_class.get_sort_functions(Sort.Sort(database))
self.sort_func = sort_functions[sort_func_num][1] self.sort_func = sort_functions[sort_func_num][1]
self.setup() def define_graphics_styles(self):
def setup(self):
""" """
Define the graphics styles used by the report. Paragraph definitions Define the graphics styles used by the report. Paragraph definitions
have already been defined in the document. The styles used are: have already been defined in the document. The styles used are: