merge changes from gramps20

svn: r5482
This commit is contained in:
Alex Roitman
2005-12-06 06:38:09 +00:00
parent e0ff843bb4
commit 2f962b5f96
202 changed files with 112821 additions and 41664 deletions

View File

@@ -29,6 +29,7 @@
#
#------------------------------------------------------------------------
from gettext import gettext as _
import cStringIO
#------------------------------------------------------------------------
#
@@ -44,15 +45,15 @@ import gtk
#------------------------------------------------------------------------
import RelLib
import Errors
from QuestionDialog import ErrorDialog
import Report
import BaseDoc
import ReportOptions
import ReportUtils
import const
from DateHandler import displayer as _dd
from NameDisplay import displayer as _nd
import cStringIO
from QuestionDialog import ErrorDialog
#------------------------------------------------------------------------
#
@@ -60,6 +61,7 @@ import cStringIO
#
#------------------------------------------------------------------------
EMPTY_ENTRY = "_____________"
HENRY = "123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#------------------------------------------------------------------------
#
@@ -101,10 +103,10 @@ class DetDescendantReport(Report.Report):
(self.max_generations,self.pgbrk) \
= options_class.get_report_generations()
self.firstName = options_class.handler.options_dict['firstnameiop']
self.fullDate = options_class.handler.options_dict['fulldates']
self.listChildren = options_class.handler.options_dict['listc']
self.includeNotes = options_class.handler.options_dict['incnotes']
self.usenick = options_class.handler.options_dict['usenick']
self.blankPlace = options_class.handler.options_dict['repplace']
self.blankDate = options_class.handler.options_dict['repdate']
self.calcAgeFlag = options_class.handler.options_dict['computeage']
@@ -118,6 +120,7 @@ class DetDescendantReport(Report.Report):
self.gen_handles = {}
self.prev_gen_handles= {}
self.gen_keys = []
self.henry = {}
if self.blankDate:
self.EMPTY_DATE = EMPTY_ENTRY
@@ -132,9 +135,10 @@ class DetDescendantReport(Report.Report):
self.sref_map = {}
self.sref_index = 0
def apply_filter(self,person_handle,index,cur_gen=1):
def apply_filter(self,person_handle,index,pid,cur_gen=1):
if (not person_handle) or (cur_gen > self.max_generations):
return
return
self.henry[person_handle] = pid
self.map[index] = person_handle
if len(self.gen_keys) < cur_gen:
@@ -143,15 +147,18 @@ class DetDescendantReport(Report.Report):
self.gen_keys[cur_gen-1].append(index)
person = self.database.get_person_from_handle(person_handle)
index = 0
for family_handle in person.get_family_handle_list():
family = self.database.get_family_from_handle(family_handle)
for child_handle in family.get_child_handle_list():
child = self.database.get_family_from_handle(child_handle)
ix = max(self.map.keys())
self.apply_filter(child_handle, ix+1, cur_gen+1)
self.apply_filter(child_handle, ix+1,
pid+HENRY[index], cur_gen+1)
index += 1
def write_report(self):
self.apply_filter(self.start_person.get_handle(),1)
self.apply_filter(self.start_person.get_handle(),1,"1")
name = _nd.display_name(self.start_person.get_primary_name())
@@ -169,11 +176,8 @@ class DetDescendantReport(Report.Report):
spouseName = _nd.display(spouse)
self.doc.start_paragraph("DDR-Title")
if nspouses == 1:
name = _("%(spouse_name)s and %(person_name)s") % {
'spouse_name' : spouseName, 'person_name' : name }
title = _("Detailed Descendant Report for %(person_name)s") % {
title = _("Descendant Report for %(person_name)s") % {
'person_name' : name }
self.doc.write_text(title)
self.doc.end_paragraph()
@@ -187,9 +191,7 @@ class DetDescendantReport(Report.Report):
if self.pgbrk and generation > 0:
self.doc.page_break()
self.doc.start_paragraph("DDR-Generation")
text = self.gen.get(generation+1,
_("Generation %(generation_number)d") % {
'generation_number' : generation+1 })
text = _("Generation %d") % (generation+1)
self.doc.write_text(text)
self.doc.end_paragraph()
if self.childRef:
@@ -215,80 +217,83 @@ class DetDescendantReport(Report.Report):
person_handle = self.map[key]
person = self.database.get_person_from_handle(person_handle)
if self.addImages:
ReportUtils.insert_images(self.database,self.doc,person)
plist = person.get_media_list()
if self.addImages and len(plist) > 0:
photo = plist[0]
ReportUtils.insert_image(self.database,self.doc,photo)
self.doc.start_paragraph("DDR-First-Entry","%s." % str(key))
val = self.henry[person_handle]
self.doc.start_paragraph("DDR-First-Entry","%s." % val)
name = _nd.display(person)
if self.firstName:
firstName = person.get_primary_name().get_first_name()
elif person.get_gender() == RelLib.Person.MALE:
firstName = _("He")
else:
firstName = _("She")
name = _nd.display_formal(person)
self.doc.start_bold()
self.doc.write_text(name)
if name[-1:] == '.':
self.doc.write_text(" ")
else:
self.doc.write_text(". ")
self.doc.end_bold()
# Output the global source references for this person
self.endnotes(person)
if self.dupPerson:
# Check for duplicate record (result of distant cousins marrying)
keys = self.map.keys()
keys.sort()
for dkey in keys:
if dkey >= key:
if dkey >= key:
break
if self.map[key] == self.map[dkey]:
self.doc.write_text(_(" is the same person as [%s].") % str(dkey))
self.doc.write_text(_("%(name)s is the same person as [%(id_str)s].") %
{ 'name' : '', 'id_str' : str(dkey) })
self.doc.end_paragraph()
return 1 # Duplicate person
# Output the global source references for this person
self.endnotes(person)
# Check birth record
birth_handle = person.get_birth_handle()
if birth_handle:
text = ReportUtils.born_str(self.database,person,"",
self.EMPTY_DATE,self.EMPTY_PLACE)
if text:
self.doc.write_text(text)
self.endnotes(self.database.get_event_from_handle(birth_handle))
else:
self.doc.write_text(". ");
else:
self.doc.write_text(". ");
death_handle = person.get_death_handle()
if death_handle:
age,units = self.calc_age(person)
text = ReportUtils.died_str(self.database,person,firstName,
self.EMPTY_DATE,self.EMPTY_PLACE,age,units)
if text:
self.doc.write_text(text)
self.endnotes(self.database.get_event_from_handle(death_handle))
text = ReportUtils.buried_str(self.database,person,firstName,
self.EMPTY_DATE,self.EMPTY_PLACE)
first = ReportUtils.common_name(person,self.usenick)
text = ReportUtils.born_str(self.database,person,first,
self.EMPTY_DATE,self.EMPTY_PLACE)
if text:
self.doc.write_text(text)
# Missing source reference for burial
birth_handle = person.get_birth_handle()
if birth_handle:
self.endnotes(self.database.get_event_from_handle(birth_handle))
first = 0
self.write_parents(person, firstName)
text = ReportUtils.died_str(self.database,person,first,
self.EMPTY_DATE,self.EMPTY_PLACE)
if text:
self.doc.write_text(text)
death_handle = person.get_birth_handle()
if death_handle:
self.endnotes(self.database.get_event_from_handle(death_handle))
first = 0
text = ReportUtils.buried_str(self.database,person,first,
self.EMPTY_DATE,self.EMPTY_PLACE)
if text:
self.doc.write_text(text)
first = ReportUtils.common_name(person,self.usenick)
self.write_parents(person, first)
self.write_marriage(person)
self.doc.end_paragraph()
self.write_mate(person)
if key == 1:
self.write_mate(person)
if person.get_note() and self.includeNotes:
if person.get_note() != "" and self.includeNotes:
self.doc.start_paragraph("DDR-NoteHeader")
self.doc.start_bold()
self.doc.write_text(_("Notes for %s") % name)
self.doc.end_bold()
self.doc.end_paragraph()
self.doc.write_note(person.get_note(),person.get_note_format(),"DDR-Entry")
self.doc.write_note(person.get_note(),person.get_note_format(),
"DDR-Entry")
first = 1
first = True
if self.includeNames:
for alt_name in person.get_alternate_names():
if first:
@@ -296,7 +301,7 @@ class DetDescendantReport(Report.Report):
self.doc.write_text(_('More about %(person_name)s:') % {
'person_name' : name })
self.doc.end_paragraph()
first = 0
first = False
self.doc.start_paragraph('DDR-MoreDetails')
self.doc.write_text(_('%(name_kind)s: %(name)s%(endnotes)s') % {
'name_kind' : const.NameTypesMap.find_value(alt_name.get_type()),
@@ -318,7 +323,7 @@ class DetDescendantReport(Report.Report):
if first:
self.doc.start_paragraph('DDR-MoreHeader')
self.doc.write_text(_('More about %(person_name)s:') % {
'person_name' : person.get_primary_name().get_regular_name() })
'person_name' : _nd.display(person) })
self.doc.end_paragraph()
first = 0
@@ -350,8 +355,6 @@ class DetDescendantReport(Report.Report):
return 0 # Not duplicate person
def write_parents(self, person, firstName):
""" Ouptut parents sentence"""
family_handle = person.get_main_parents_family_handle()
if family_handle:
family = self.database.get_family_from_handle(family_handle)
@@ -368,15 +371,16 @@ class DetDescendantReport(Report.Report):
else:
father_name = ""
text = ReportUtils.child_str(person,
father_name,mother_name,
bool(person.get_death_handle()))
text = ReportUtils.child_str(person, father_name, mother_name,
bool(person.get_death_handle()),
firstName)
if text:
self.doc.write_text(text)
def write_marriage(self, person):
""" Output marriage sentence"""
"""
Output marriage sentence.
"""
is_first = True
for family_handle in person.get_family_handle_list():
family = self.database.get_family_from_handle(family_handle)
@@ -418,69 +422,70 @@ class DetDescendantReport(Report.Report):
father_name = _("unknown")
self.doc.start_paragraph("DDR-ChildTitle")
self.doc.start_bold()
self.doc.write_text(_("Children of %s and %s are:") %
(mother_name,father_name))
self.doc.end_bold()
self.doc.write_text(_("Children of %s and %s") %
(mother_name,father_name))
self.doc.end_paragraph()
cnt = 1
for child_handle in family.get_child_handle_list():
self.doc.start_paragraph("DDR-ChildList")
child = self.database.get_person_from_handle(child_handle)
child_name = _nd.display(child)
if self.childRef and self.prev_gen_handles.get(child_handle):
child_name = "[%s] %s" % (
str(self.prev_gen_handles.get(child_handle)),
child_name)
value = str(self.prev_gen_handles.get(child_handle))
child_name += " [%s]" % value
text = ReportUtils.list_person_str(self.database,child,child_name)
self.doc.write_text(text)
self.doc.start_paragraph("DDR-ChildList",
ReportUtils.roman(cnt).lower() + ".")
cnt += 1
if self.henry.has_key(child_handle):
self.doc.write_text("%s [%s]. " % (child_name,
self.henry[child_handle]))
else:
self.doc.write_text("%s. " % child_name)
self.doc.write_text(ReportUtils.born_str(
self.database, child, 0, self.EMPTY_DATE, self.EMPTY_PLACE))
self.doc.write_text(ReportUtils.died_str(
self.database, child, 0, self.EMPTY_DATE, self.EMPTY_PLACE))
self.doc.end_paragraph()
def write_mate(self, mate):
"""Output birth, death, parentage, marriage and notes information """
for family_handle in mate.get_family_handle_list():
family = self.database.get_family_from_handle(family_handle)
person_name = ""
ind_handle = None
if mate.get_gender() == RelLib.Person.MALE:
ind_handle = family.get_mother_handle()
heshe = _("She")
else:
heshe = _("He")
ind_handle = family.get_father_handle()
if ind_handle:
ind = self.database.get_person_from_handle(ind_handle)
person_name = _nd.display(ind)
firstName = ind.get_primary_name().get_first_name()
firstName = ReportUtils.common_name(ind,self.usenick)
else:
firstName = 0
if person_name:
if self.addImages:
ReportUtils.insert_images(self.database,self.doc,ind)
self.doc.start_paragraph("DDR-Entry")
if not self.firstName:
firstName = heshe
self.doc.write_text(person_name)
text = ReportUtils.born_str(self.database,ind,"",
self.EMPTY_DATE,self.EMPTY_PLACE)
if text:
self.doc.write_text(text)
else:
self.doc.write_text(". ");
age,units = self.calc_age(ind)
text = ReportUtils.died_str(self.database,ind,heshe,
text = ReportUtils.died_str(self.database,ind,0,
self.EMPTY_DATE,self.EMPTY_PLACE,age,units)
if text:
self.doc.write_text(text)
text = ReportUtils.buried_str(self.database,ind,heshe,
text = ReportUtils.buried_str(self.database,ind,0,
self.EMPTY_DATE,self.EMPTY_PLACE)
if text:
self.doc.write_text(text)
@@ -489,9 +494,6 @@ class DetDescendantReport(Report.Report):
self.doc.end_paragraph()
# if self.listChildren \
# and mate.get_gender() == RelLib.Person.MALE:
# self.write_children(family)
def calc_age(self,ind):
"""
@@ -549,8 +551,9 @@ class DetDescendantReport(Report.Report):
self.doc.end_paragraph()
def endnotes(self,obj):
if not self.includeSources:
if not obj or not self.includeSources:
return ""
msg = cStringIO.StringIO()
slist = obj.get_source_references()
if slist:
@@ -594,10 +597,10 @@ class DetDescendantOptions(ReportOptions.ReportOptions):
def set_new_options(self):
# Options specific for this report
self.options_dict = {
'firstnameiop' : 0,
'fulldates' : 1,
'listc' : 1,
'incnotes' : 1,
'usenick' : 1,
'repplace' : 0,
'repdate' : 0,
'computeage' : 1,
@@ -609,9 +612,6 @@ class DetDescendantOptions(ReportOptions.ReportOptions):
'incsources' : 0,
}
self.options_help = {
'firstnameiop' : ("=0/1","Whether to use first names instead of pronouns",
["Do not use first names","Use first names"],
True),
'fulldates' : ("=0/1","Whether to use full dates instead of just year.",
["Do not use full dates","Use full dates"],
True),
@@ -621,6 +621,9 @@ class DetDescendantOptions(ReportOptions.ReportOptions):
'incnotes' : ("=0/1","Whether to include notes.",
["Do not include notes","Include notes"],
True),
'usenick' : ("=0/1","Whether to use the nick name as the first name.",
["Do not use nick name","Use nick name"],
True),
'repplace' : ("=0/1","Whether to replace missing Places with blanks.",
["Do not replace missing Places","Replace missing Places"],
True),
@@ -658,13 +661,14 @@ class DetDescendantOptions(ReportOptions.ReportOptions):
}
def make_default_style(self,default_style):
"""Make the default output style for the Detailed Descendant Report"""
"""Make the default output style for the Detailed Ancestral Report"""
font = BaseDoc.FontStyle()
font.set(face=BaseDoc.FONT_SANS_SERIF,size=16,bold=1)
para = BaseDoc.ParagraphStyle()
para.set_font(font)
para.set_header_level(1)
para.set(pad=0.5)
para.set_top_margin(0.25)
para.set_bottom_margin(0.25)
para.set_description(_('The style used for the title of the page.'))
default_style.add_style("DDR-Title",para)
@@ -673,55 +677,71 @@ class DetDescendantOptions(ReportOptions.ReportOptions):
para = BaseDoc.ParagraphStyle()
para.set_font(font)
para.set_header_level(2)
para.set(pad=0.5)
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)
font = BaseDoc.FontStyle()
font.set(face=BaseDoc.FONT_SANS_SERIF,size=10,italic=0, bold=0)
font.set(face=BaseDoc.FONT_SANS_SERIF,size=10,italic=0, bold=1)
para = BaseDoc.ParagraphStyle()
para.set_font(font)
#para.set_header_level(3)
para.set_left_margin(1.0) # in centimeters
para.set(pad=0.5)
para.set_left_margin(1.5) # in centimeters
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)
font = BaseDoc.FontStyle()
font.set(face=BaseDoc.FONT_SANS_SERIF,size=9)
font.set(size=10)
para = BaseDoc.ParagraphStyle()
para.set_font(font)
para.set(first_indent=0.0,lmargin=1.0,pad=0.25)
para.set(first_indent=-0.75,lmargin=2.25)
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)
font = BaseDoc.FontStyle()
font.set(face=BaseDoc.FONT_SANS_SERIF,size=10,italic=0, bold=1)
para = BaseDoc.ParagraphStyle()
para.set(first_indent=0.0,lmargin=1.0,pad=0.25)
para.set_description(_('The style used for the notes section header.'))
para.set_font(font)
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)
para = BaseDoc.ParagraphStyle()
para.set(first_indent=0.5,lmargin=0.0,pad=0.25)
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)
para = BaseDoc.ParagraphStyle()
para.set(first_indent=-1.0,lmargin=1.0,pad=0.25)
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)
font = BaseDoc.FontStyle()
font.set(bold=1)
font.set(size=10,face=BaseDoc.FONT_SANS_SERIF,bold=1)
para = BaseDoc.ParagraphStyle()
para.set_font(font)
para.set(first_indent=0.0,lmargin=0.0,pad=0.25)
para.set(first_indent=0.0,lmargin=1.5)
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)
font = BaseDoc.FontStyle()
font.set(face=BaseDoc.FONT_SANS_SERIF,size=9)
font.set(face=BaseDoc.FONT_SERIF,size=10)
para = BaseDoc.ParagraphStyle()
para.set_font(font)
para.set(first_indent=0.0,lmargin=1.0,pad=0.25)
para.set(first_indent=0.0,lmargin=1.5)
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)
@@ -730,12 +750,15 @@ class DetDescendantOptions(ReportOptions.ReportOptions):
para = BaseDoc.ParagraphStyle()
para.set_font(font)
para.set_header_level(2)
para.set(pad=0.5)
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)
para = BaseDoc.ParagraphStyle()
para.set(first_indent=0.5,lmargin=1.0,pad=0.25)
para.set(first_indent=-0.5,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)
@@ -745,10 +768,6 @@ class DetDescendantOptions(ReportOptions.ReportOptions):
the user to select the sort method.
"""
# Pronoun instead of first name
self.first_name_option = gtk.CheckButton(_("Use first names instead of pronouns"))
self.first_name_option.set_active(self.options_dict['firstnameiop'])
# Full date usage
self.full_date_option = gtk.CheckButton(_("Use full dates instead of only the year"))
self.full_date_option.set_active(self.options_dict['fulldates'])
@@ -761,6 +780,10 @@ class DetDescendantOptions(ReportOptions.ReportOptions):
self.include_notes_option = gtk.CheckButton(_("Include notes"))
self.include_notes_option.set_active(self.options_dict['incnotes'])
# Print nickname
self.usenick = gtk.CheckButton(_("Use nickname for common name"))
self.usenick.set_active(self.options_dict['usenick'])
# Replace missing Place with ___________
self.place_option = gtk.CheckButton(_("Replace missing places with ______"))
self.place_option.set_active(self.options_dict['repplace'])
@@ -801,26 +824,24 @@ class DetDescendantOptions(ReportOptions.ReportOptions):
# if you want to put everyting in the generic "Options" category, use
# self.add_option(text,widget) instead of self.add_frame_option(category,text,widget)
dialog.add_frame_option(_('Content'),'',self.first_name_option)
dialog.add_frame_option(_('Content'),'',self.full_date_option)
dialog.add_frame_option(_('Content'),'',self.list_children_option)
dialog.add_frame_option(_('Content'),'',self.include_notes_option)
dialog.add_frame_option(_('Content'),'',self.place_option)
dialog.add_frame_option(_('Content'),'',self.date_option)
dialog.add_frame_option(_('Content'),'',self.age_option)
dialog.add_frame_option(_('Content'),'',self.dupPersons_option)
dialog.add_frame_option(_('Content'),'',self.childRef_option)
dialog.add_frame_option(_('Content'),'',self.image_option)
dialog.add_frame_option(_('Content'),'',self.include_names_option)
dialog.add_frame_option(_('Content'),'',self.include_events_option)
dialog.add_frame_option(_('Content'),'',self.include_sources_option)
dialog.add_frame_option(_('Include'),'',self.image_option)
dialog.add_frame_option(_('Include'),'',self.include_names_option)
dialog.add_frame_option(_('Include'),'',self.include_events_option)
dialog.add_frame_option(_('Include'),'',self.include_sources_option)
dialog.add_frame_option(_('Missing information'),'',self.place_option)
dialog.add_frame_option(_('Missing information'),'',self.date_option)
def parse_user_options(self,dialog):
"""
Parses the custom options that we have added.
"""
self.options_dict['firstnameiop'] = int(self.first_name_option.get_active())
self.options_dict['fulldates'] = int(self.full_date_option.get_active())
self.options_dict['listc'] = int(self.list_children_option.get_active())
self.options_dict['incnotes'] = int(self.include_notes_option.get_active())
@@ -842,7 +863,7 @@ class DetDescendantOptions(ReportOptions.ReportOptions):
from PluginMgr import register_report
register_report(
name = 'det_descendant_report',
category = const.CATEGORY_TEXT,
category = Report.CATEGORY_TEXT,
report_class = DetDescendantReport,
options_class = DetDescendantOptions,
modes = Report.MODE_GUI | Report.MODE_BKI | Report.MODE_CLI,