* src/plugins/IndivComplete.py: fix source citations (0000867)

* src/ReportBase.py: fix source citations (0000867)

svn: r8020
This commit is contained in:
Brian Matherly 2007-01-31 03:16:11 +00:00
parent 8a1ccd0768
commit 167b009dcd
3 changed files with 69 additions and 37 deletions

View File

@ -5,6 +5,8 @@
* src/docgen/HtmlDoc.py: add start_superscript and stop_superscript * src/docgen/HtmlDoc.py: add start_superscript and stop_superscript
* src/docgen/OpenOfficeDoc.py: add start_superscript and stop_superscript * src/docgen/OpenOfficeDoc.py: add start_superscript and stop_superscript
* src/docgen/LaTeXDoc.py: add start_superscript and stop_superscript * src/docgen/LaTeXDoc.py: add start_superscript and stop_superscript
* src/plugins/IndivComplete.py: fix source citations (0000867)
* src/ReportBase.py: fix source citations (0000867)
2007-01-30 Don Allingham <don@gramps-project.org> 2007-01-30 Don Allingham <don@gramps-project.org>
* src/plugins/EventCmp.py: (#886) properly handle CANCEL on save dialog * src/plugins/EventCmp.py: (#886) properly handle CANCEL on save dialog

View File

@ -33,6 +33,7 @@ A collection of utilities to aid in the generation of reports.
import time import time
import os import os
from gettext import gettext as _ from gettext import gettext as _
import cStringIO
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
@ -2314,3 +2315,31 @@ def get_address_str(addr):
str = "%s, %s" % (str,info) str = "%s, %s" % (str,info)
return str return str
def get_endnotes(sref_map,obj):
if not obj:
return ""
slist = obj.get_source_references()
if not slist:
return ""
msg = cStringIO.StringIO()
first = 1
for ref in slist:
if not first:
msg.write(',')
first = 0
ref_base = ref.get_reference_handle()
the_key = 0
for key in sref_map.keys():
if ref_base == sref_map[key].get_reference_handle():
the_key = key
break
if not the_key:
the_key = len(sref_map) + 1
sref_map[the_key] = ref
msg.write("%d" % the_key)
str = msg.getvalue()
msg.close()
return str

View File

@ -85,6 +85,7 @@ class IndivCompleteReport(Report):
filter_num = options_class.get_filter_number() filter_num = options_class.get_filter_number()
filters = options_class.get_report_filters(person) filters = options_class.get_report_filters(person)
self.filter = filters[filter_num] self.filter = filters[filter_num]
self.sref_map = {}
def define_table_styles(self): def define_table_styles(self):
tbl = BaseDoc.TableStyle() tbl = BaseDoc.TableStyle()
@ -137,19 +138,19 @@ class IndivCompleteReport(Report):
description = event.get_description() description = event.get_description()
text = '%s%s. ' % (text,description) text = '%s%s. ' % (text,description)
endnotes = ""
if self.use_srcs: if self.use_srcs:
for s in event.get_source_references(): endnotes = ReportUtils.get_endnotes(self.sref_map,event)
src_handle = s.get_reference_handle()
src = self.database.get_source_from_handle(src_handle)
text = "%s [%s]" % (text,src.get_gramps_id())
self.slist.append(s)
self.doc.start_row() self.doc.start_row()
self.normal_cell(name) self.normal_cell(name)
self.doc.start_cell('IDS-NormalCell') self.doc.start_cell('IDS-NormalCell')
self.doc.start_paragraph('IDS-Normal') self.doc.start_paragraph('IDS-Normal')
self.doc.write_text(text) self.doc.write_text(text)
if endnotes:
self.doc.start_superscript()
self.doc.write_text(endnotes)
self.doc.end_superscript()
self.doc.end_paragraph() self.doc.end_paragraph()
note = event.get_note() note = event.get_note()
@ -268,13 +269,10 @@ class IndivCompleteReport(Report):
self.doc.start_row() self.doc.start_row()
self.normal_cell(name_type) self.normal_cell(name_type)
text = _nd.display_name(name) text = _nd.display_name(name)
endnotes = ""
if self.use_srcs: if self.use_srcs:
for s in name.get_source_references(): endnotes = ReportUtils.get_endnotes(self.sref_map,name)
src_handle = s.get_reference_handle() self.normal_cell(text,endnotes)
src = self.database.get_source_from_handle(src_handle)
text = "%s [%s]" % (text,src.get_gramps_id())
self.slist.append(s)
self.normal_cell(text)
self.doc.end_row() self.doc.end_row()
self.doc.end_table() self.doc.end_table()
self.doc.start_paragraph('IDS-Normal') self.doc.start_paragraph('IDS-Normal')
@ -299,16 +297,12 @@ class IndivCompleteReport(Report):
for addr in alist: for addr in alist:
text = ReportUtils.get_address_str(addr) text = ReportUtils.get_address_str(addr)
date = DateHandler.get_date(addr) date = DateHandler.get_date(addr)
endnotes = ""
if self.use_srcs:
endnotes = ReportUtils.get_endnotes(self.sref_map,addr)
self.doc.start_row() self.doc.start_row()
self.normal_cell(date) self.normal_cell(date)
if self.use_srcs: self.normal_cell(text,endnotes)
for s in addr.get_source_references():
src_handle = s.get_reference_handle()
src = self.database.get_source_from_handle(src_handle)
text = "%s [%s]" % (text,src.get_gramps_id())
self.slist.append(s)
self.normal_cell(text)
self.doc.end_row() self.doc.end_row()
self.doc.end_table() self.doc.end_table()
self.doc.start_paragraph('IDS-Normal') self.doc.start_paragraph('IDS-Normal')
@ -375,8 +369,8 @@ class IndivCompleteReport(Report):
self.doc.end_paragraph() self.doc.end_paragraph()
def write_sources(self): def write_sources(self):
keys = self.sref_map.keys()
if len(self.slist) == 0: if not keys:
return return
self.doc.start_table("three","IDS-IndTable") self.doc.start_table("three","IDS-IndTable")
@ -388,13 +382,19 @@ class IndivCompleteReport(Report):
self.doc.end_cell() self.doc.end_cell()
self.doc.end_row() self.doc.end_row()
for source in self.slist: keys.sort()
for key in keys:
srcref = self.sref_map[key]
base = self.database.get_source_from_handle(
srcref.get_reference_handle())
self.doc.start_row() self.doc.start_row()
s_handle = source.get_reference_handle() self.doc.start_cell('IDS-NormalCell',2)
src = self.database.get_source_from_handle(s_handle) self.doc.start_paragraph("IDS-Normal","%d." % key)
self.normal_cell(src.get_gramps_id()) self.doc.write_text(base.get_title())
self.normal_cell(src.get_title()) self.doc.end_paragraph()
self.doc.end_cell()
self.doc.end_row() self.doc.end_row()
self.doc.end_table() self.doc.end_table()
def write_facts(self): def write_facts(self):
@ -416,10 +416,14 @@ class IndivCompleteReport(Report):
self.doc.start_paragraph("IDS-Normal") self.doc.start_paragraph("IDS-Normal")
self.doc.end_paragraph() self.doc.end_paragraph()
def normal_cell(self,text,mark=None): def normal_cell(self,text,endnotes=None,mark=None):
self.doc.start_cell('IDS-NormalCell') self.doc.start_cell('IDS-NormalCell')
self.doc.start_paragraph('IDS-Normal') self.doc.start_paragraph('IDS-Normal')
self.doc.write_text(text,mark) self.doc.write_text(text,mark)
if endnotes:
self.doc.start_superscript()
self.doc.write_text(endnotes)
self.doc.end_superscript()
self.doc.end_paragraph() self.doc.end_paragraph()
self.doc.end_cell() self.doc.end_cell()
@ -474,13 +478,10 @@ class IndivCompleteReport(Report):
name = self.start_person.get_primary_name() name = self.start_person.get_primary_name()
text = _nd.display_name(name) text = _nd.display_name(name)
mark = ReportUtils.get_person_mark(self.database, self.start_person) mark = ReportUtils.get_person_mark(self.database, self.start_person)
endnotes = ""
if self.use_srcs: if self.use_srcs:
for s in name.get_source_references(): endnotes = ReportUtils.get_endnotes(self.sref_map,name)
self.slist.append(s) self.normal_cell(text,endnotes,mark)
src_handle = s.get_reference_handle()
src = self.database.get_source_from_handle(src_handle)
text = "%s [%s]" % (text,src.get_gramps_id())
self.normal_cell(text,mark)
self.doc.end_row() self.doc.end_row()
self.doc.start_row() self.doc.start_row()
@ -520,12 +521,12 @@ class IndivCompleteReport(Report):
self.doc.start_row() self.doc.start_row()
self.normal_cell("%s:" % _("Father")) self.normal_cell("%s:" % _("Father"))
self.normal_cell(father,fmark) self.normal_cell(father,mark=fmark)
self.doc.end_row() self.doc.end_row()
self.doc.start_row() self.doc.start_row()
self.normal_cell("%s:" % _("Mother")) self.normal_cell("%s:" % _("Mother"))
self.normal_cell(mother,mmark) self.normal_cell(mother,mark=mmark)
self.doc.end_row() self.doc.end_row()
self.doc.end_table() self.doc.end_table()