diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index 1d9989f0a..6207d6862 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,6 +1,13 @@ +2005-09-28 Don Allingham + * src/NameDisplay.py: Add display_formal + * src/Report.py: remove generation strings + * src/docgen/OpenOfficeDoc.py: Fix leading space after tab. + * src/plugins/AncestorReport.py: Use ReportUtils strings + instead of local strings + 2005-09-28 Eero Tamminen * src/po/fi.po: Translation update for 2.0.9. - +p 2005-09-28 Martin Hawlisch * src/plugins/TestcaseGenerator.py: Use new tool/option api diff --git a/gramps2/src/NameDisplay.py b/gramps2/src/NameDisplay.py index 4ff080fe6..751c02b77 100644 --- a/gramps2/src/NameDisplay.py +++ b/gramps2/src/NameDisplay.py @@ -137,6 +137,24 @@ class NameDisplay: else: return self._fnln(name,person.get_nick_name()) + def display_formal(self,person): + """ + Returns a text string representing the L{RelLib.Person} instance's + L{RelLib.Name} in a manner that should be used for normal displaying. + + @param person: L{RelLib.Person} instance that contains the + L{RelLib.Name} that is to be displayed. The primary name is used for + the display. + @type person: L{RelLib.Person} + @returns: Returns the L{RelLib.Person} instance's name + @rtype: str + """ + name = person.get_primary_name() + if name.display_as == RelLib.Name.LNFN: + return self._lnfn(name,'') + else: + return self._fnln(name,'') + def display_name(self,name): """ Returns a text string representing the L{RelLib.Name} instance diff --git a/gramps2/src/Report.py b/gramps2/src/Report.py index f0ea825ed..753b218a2 100644 --- a/gramps2/src/Report.py +++ b/gramps2/src/Report.py @@ -207,25 +207,6 @@ class Report: sub-classed to create a functional report generator. """ - # Ordinal generation names. Used by multiple reports. - gen = { - 1 : _("First Generation"), 2 : _("Second Generation"), - 3 : _("Third Generation"), 4 : _("Fourth Generation"), - 5 : _("Fifth Generation"), 6 : _("Sixth Generation"), - 7 : _("Seventh Generation"), 8 : _("Eighth Generation"), - 9 : _("Ninth Generation"), 10: _("Tenth Generation"), - 11: _("Eleventh Generation"), 12: _("Twelfth Generation"), - 13: _("Thirteenth Generation"), 14: _("Fourteenth Generation"), - 15: _("Fifteenth Generation"), 16: _("Sixteenth Generation"), - 17: _("Seventeenth Generation"), 18: _("Eighteenth Generation"), - 19: _("Nineteenth Generation"), 20: _("Twentieth Generation"), - 21: _("Twenty-first Generation"), 22: _("Twenty-second Generation"), - 23: _("Twenty-third Generation"), 24: _("Twenty-fourth Generation"), - 25: _("Twenty-fifth Generation"), 26: _("Twenty-sixth Generation"), - 27: _("Twenty-seventh Generation"), 28: _("Twenty-eighth Generation"), - 29: _("Twenty-ninth Generation") - } - def __init__(self, database, person, options_class): self.database = database self.start_person = person @@ -911,7 +892,8 @@ class BareReportDialog: style sheet editor object and let them play. When they are done, the previous routine will be called to update the dialog menu for selecting a style.""" - StyleEditor.StyleListDisplay(self.style_sheet_list,self.build_style_menu,self.window) + StyleEditor.StyleListDisplay(self.style_sheet_list,self.build_style_menu, + self.window) def on_center_person_change_clicked(self,*obj): import SelectPerson diff --git a/gramps2/src/docgen/OpenOfficeDoc.py b/gramps2/src/docgen/OpenOfficeDoc.py index e73362060..19f33620a 100644 --- a/gramps2/src/docgen/OpenOfficeDoc.py +++ b/gramps2/src/docgen/OpenOfficeDoc.py @@ -679,10 +679,10 @@ class OpenOfficeDoc(BaseDoc.BaseDoc): else: self.cntnt.write('\n') + self.cntnt.write('" text:level="%d">' % self.level) if leader != None: self.cntnt.write(leader) - self.cntnt.write('\n') + self.cntnt.write('') self.new_cell = 0 def end_paragraph(self): diff --git a/gramps2/src/plugins/AncestorReport.py b/gramps2/src/plugins/AncestorReport.py index 2191bc9fe..8b57a65c5 100644 --- a/gramps2/src/plugins/AncestorReport.py +++ b/gramps2/src/plugins/AncestorReport.py @@ -27,7 +27,7 @@ # python modules # #------------------------------------------------------------------------ -import os +import math from gettext import gettext as _ #------------------------------------------------------------------------ @@ -36,13 +36,20 @@ from gettext import gettext as _ # #------------------------------------------------------------------------ import Report +import ReportUtils import BaseDoc -import RelLib import Errors -from DateHandler import displayer as _dd -from QuestionDialog import ErrorDialog +import NameDisplay import ReportOptions +#------------------------------------------------------------------------ +# +# log2val +# +#------------------------------------------------------------------------ +def log2(val): + return int(math.log10(val)/math.log10(2)) + #------------------------------------------------------------------------ # # AncestorReport @@ -90,10 +97,9 @@ class AncestorReport(Report.Report): self.apply_filter(self.start_person.get_handle(),1) - name = self.start_person.get_primary_name().get_regular_name() + name = NameDisplay.displayer.display_formal(self.start_person) self.doc.start_paragraph("AHN-Title") - title = _("Ahnentafel Report for %s") % name - self.doc.write_text(title) + self.doc.write_text(_("Ahnentafel Report for %s") % name) self.doc.end_paragraph() keys = self.map.keys() @@ -101,22 +107,21 @@ class AncestorReport(Report.Report): generation = 0 for key in keys : - if generation == 0 or key >= ( 1 << 30): + if generation == log2(key): if self.pgbrk and generation > 0: self.doc.page_break() + generation += 1 self.doc.start_paragraph("AHN-Generation") - t = _("%s Generation") % AncestorReport.gen[generation+1] - self.doc.write_text(t) + self.doc.write_text(_("Generation %d") % generation) self.doc.end_paragraph() - generation = generation + 1 - self.doc.start_paragraph("AHN-Entry","%s." % str(key)) + self.doc.start_paragraph("AHN-Entry","%d." % key) person_handle = self.map[key] person = self.database.get_person_from_handle(person_handle) - name = person.get_primary_name().get_regular_name() + name = NameDisplay.displayer.display_formal(person) self.doc.start_bold() - self.doc.write_text(name) + self.doc.write_text(name.strip()) self.doc.end_bold() if name[-1:] == '.': self.doc.write_text(" ") @@ -124,121 +129,10 @@ class AncestorReport(Report.Report): self.doc.write_text(". ") # Check birth record - - birth_handle = person.get_birth_handle() - if birth_handle: - birth = self.database.get_event_from_handle(birth_handle) - date = birth.get_date_object() - date_text = _dd.display(date) - place_handle = birth.get_place_handle() - if place_handle: - place = self.database.get_place_from_handle(place_handle).get_title() - else: - place = u'' - if place[-1:] == '.': - place = place[:-1] - if date_text != "" or place_handle: - if date_text != "": - if date.get_day_valid() and date.get_month_valid(): - if place != "": - t = _("%s was born on %s in %s. ") % \ - (name,date_text,place) - else: - t = _("%s was born on %s. ") % \ - (name,date_text) - else: - if place != "": - t = _("%s was born in the year %s in %s. ") % \ - (name,date_text,place) - else: - t = _("%s was born in the year %s. ") % \ - (name,date_text) - self.doc.write_text(t) - buried = None - for event_handle in person.get_event_list(): - event = self.database.get_event_from_handle(event_handle) - if event.get_name().lower() == "burial": - buried = event - - death_handle = person.get_death_handle() - if death_handle: - death = self.database.get_event_from_handle(death_handle) - date = death.get_date_object() - date_text = _dd.display(date) - place_handle = death.get_place_handle() - if place_handle: - place = self.database.get_place_from_handle(place_handle).get_title() - else: - place = u'' - if place[-1:] == '.': - place = place[:-1] - if date_text != "" or place_handle: - if person.get_gender() == RelLib.Person.MALE: - male = 1 - else: - male = 0 - - if date_text != "": - if date.get_day_valid() and date.get_month_valid(): - if male: - if place != "": - t = _("He died on %s in %s") % \ - (date_text,place) - else: - t = _("He died on %s") % date_text - else: - if place != "": - t = _("She died on %s in %s") % \ - (date_text,place) - else: - t = _("She died on %s") % date_text - else: - if male: - if place != "": - t = _("He died in the year %s in %s") % \ - (date_text,place) - else: - t = _("He died in the year %s") % date_text - else: - if place != "": - t = _("She died in the year %s in %s") % \ - (date_text,place) - else: - t = _("She died in the year %s") % date_text - - self.doc.write_text(t) - - if buried: - date = buried.get_date_object() - date_text = _dd.display(date) - place_handle = buried.get_place_handle() - if place_handle: - place = self.database.get_place_from_handle(place_handle).get_title() - else: - place = u'' - if place[-1:] == '.': - place = place[:-1] - if date_text != "" or place_handle: - if date_text != "": - if date.get_day_valid() and date.get_month_valid(): - if place != "": - t = _(", and was buried on %s in %s.") % \ - (date_text,place) - else: - t = _(", and was buried on %s.") % date_text - else: - if place != "": - t = _(", and was buried in the year %s in %s.") % \ - (date_text,place) - else: - t = _(", and was buried in the year %s.") % \ - date_text - else: - t = _(" and was buried in %s.") % place - self.doc.write_text(t) - else: - self.doc.write_text(".") + self.doc.write_text(ReportUtils.born_str(self.database,person)) + self.doc.write_text(ReportUtils.died_str(self.database,person,0)) + self.doc.write_text(ReportUtils.buried_str(self.database,person,0)) self.doc.end_paragraph() @@ -290,7 +184,7 @@ class AncestorOptions(ReportOptions.ReportOptions): #------------------------------------------------------------------------ # -# +# Register the plugin # #------------------------------------------------------------------------ from PluginMgr import register_report @@ -301,8 +195,8 @@ register_report( options_class = AncestorOptions, modes = Report.MODE_GUI | Report.MODE_BKI | Report.MODE_CLI, translated_name = _("Ahnentafel Report"), - status=(_("Beta")), + status=(_("Stable")), description= _("Produces a textual ancestral report"), author_name="Donald N. Allingham", - author_email="dallingham@users.sourceforge.net" + author_email="don@gramps-project.org" )