Enhance source endnotes in some text reports.
svn: r8541
This commit is contained in:
parent
150a0fc05d
commit
dae8c99230
11
ChangeLog
11
ChangeLog
@ -1,3 +1,14 @@
|
||||
2007-06-01 Brian Matherly <brian@gramps-project.org>
|
||||
* src/ReportBase/_ReportUtils.py:
|
||||
* src/ReportBase/__init__.py:
|
||||
* src/ReportBase/_Bibliography.py:
|
||||
* src/ReportBase/_Endnotes.py:
|
||||
* src/plugins/DetDescendantReport.py:
|
||||
* src/plugins/IndivComplete.py:
|
||||
* src/plugins/BookReport.py:
|
||||
* src/plugins/DetAncestralReport.py:
|
||||
Enhance the source endnotes in some text reports.
|
||||
|
||||
2007-06-12 Don Allingham <don@gramps-project.org>
|
||||
* src/ViewManager.py: detection and recovery from db errors
|
||||
* src/GrampsDb/_GrampsDBDir.py: detection and recovery from db errors
|
||||
|
157
src/ReportBase/_Bibliography.py
Normal file
157
src/ReportBase/_Bibliography.py
Normal file
@ -0,0 +1,157 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# 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
|
||||
# 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: $
|
||||
|
||||
"""
|
||||
Contain and organize bibliographic information.
|
||||
"""
|
||||
|
||||
class Citation:
|
||||
"""
|
||||
Store information about a citation and all of its references.
|
||||
"""
|
||||
def __init__(self):
|
||||
"""
|
||||
Initialize members.
|
||||
"""
|
||||
self.__src_handle = None
|
||||
self.__ref_list = []
|
||||
|
||||
def get_source_handle(self):
|
||||
"""
|
||||
Provide the handle to the source that this citation is for.
|
||||
|
||||
@return: Source Handle
|
||||
@rtype: handle
|
||||
"""
|
||||
return self.__src_handle
|
||||
|
||||
def set_source_handle(self,handle):
|
||||
"""
|
||||
Set the handle for the source that this citation is for.
|
||||
|
||||
@param handle: Source Handle
|
||||
@type handle: handle
|
||||
"""
|
||||
self.__src_handle = handle
|
||||
|
||||
def get_ref_list(self):
|
||||
"""
|
||||
List all the references to this citation.
|
||||
|
||||
@return: a list of references
|
||||
@rtype: list of L{Relib.SourceRef} objects
|
||||
"""
|
||||
return self.__ref_list
|
||||
|
||||
def add_reference(self, source_ref):
|
||||
"""
|
||||
Add a reference to this citation. If a similar reference exists, don't
|
||||
add another one.
|
||||
|
||||
@param source_ref: Source Reference
|
||||
@type source_ref: L{Relib.SourceRef}
|
||||
@return: The index of the added reference among all the references.
|
||||
@rtype: int
|
||||
"""
|
||||
index = 0
|
||||
for ref in self.__ref_list:
|
||||
if _srefs_are_equal(ref,source_ref):
|
||||
# if a reference like this already exists, don't add another one
|
||||
return index
|
||||
index += 1
|
||||
|
||||
self.__ref_list.append(source_ref)
|
||||
return index
|
||||
|
||||
class Bibliography:
|
||||
"""
|
||||
Store and organize multiple citations into a bibliography.
|
||||
"""
|
||||
def __init__(self):
|
||||
"""
|
||||
Initialize members.
|
||||
"""
|
||||
self.__citation_list = []
|
||||
|
||||
def add_reference(self, source_ref):
|
||||
"""
|
||||
Add a reference to a source to this bibliography. If the source already
|
||||
exists, don't add it again. If a similar reference exists, don't
|
||||
add another one.
|
||||
|
||||
@param source_ref: Source Reference
|
||||
@type source_ref: L{Relib.SourceRef}
|
||||
@return: A tuple containing the index of the source among all the
|
||||
sources and the index of the reference among all the references. If
|
||||
there is no reference information, the second element will be None.
|
||||
@rtype: (int,int) or (int,None)
|
||||
"""
|
||||
source_handle = source_ref.get_reference_handle()
|
||||
cindex = 0
|
||||
rindex = None
|
||||
citation = None
|
||||
citation_found = False
|
||||
for citation in self.__citation_list:
|
||||
if citation.get_source_handle() == source_handle:
|
||||
citation_found = True
|
||||
break
|
||||
cindex += 1
|
||||
|
||||
if not citation_found:
|
||||
citation = Citation()
|
||||
citation.set_source_handle(source_handle)
|
||||
cindex = len(self.__citation_list)
|
||||
self.__citation_list.append(citation)
|
||||
|
||||
if _sref_has_info(source_ref):
|
||||
rindex = citation.add_reference(source_ref)
|
||||
|
||||
return (cindex,rindex)
|
||||
|
||||
def get_citation_count(self):
|
||||
"""
|
||||
Report the number of citations in this bibliography.
|
||||
|
||||
@return: number of citations
|
||||
@rtype: int
|
||||
"""
|
||||
return len(self.__citation_list)
|
||||
|
||||
def get_citation_list(self):
|
||||
"""
|
||||
Return a list containing all the citations in this bibliography.
|
||||
|
||||
@return: citation list
|
||||
@rtype: list of L{Citation} objects
|
||||
"""
|
||||
return self.__citation_list
|
||||
|
||||
def _sref_has_info(source_ref):
|
||||
if source_ref.get_page() == "":
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
def _srefs_are_equal(source_ref1,source_ref2):
|
||||
if source_ref1.get_page() == source_ref2.get_page():
|
||||
return True
|
||||
else:
|
||||
return False
|
155
src/ReportBase/_Endnotes.py
Normal file
155
src/ReportBase/_Endnotes.py
Normal file
@ -0,0 +1,155 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# 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
|
||||
# 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: $
|
||||
|
||||
"""
|
||||
Provide utilities for printing endnotes in text reports.
|
||||
"""
|
||||
|
||||
import string
|
||||
import BaseDoc
|
||||
|
||||
def add_endnote_styles(style_sheet):
|
||||
"""
|
||||
Add paragraph styles to a style sheet to be used for displaying endnotes.
|
||||
|
||||
@param style_sheet: Style sheet
|
||||
@type style_sheet: L{Basedoc.StyleSheet}
|
||||
"""
|
||||
font = BaseDoc.FontStyle()
|
||||
font.set(face=BaseDoc.FONT_SANS_SERIF,size=14,italic=1)
|
||||
para = BaseDoc.ParagraphStyle()
|
||||
para.set_font(font)
|
||||
para.set_header_level(2)
|
||||
para.set_top_margin(0.25)
|
||||
para.set_bottom_margin(0.25)
|
||||
para.set_description(_('The style used for the generation header.'))
|
||||
style_sheet.add_paragraph_style("Endnotes-Header",para)
|
||||
|
||||
para = BaseDoc.ParagraphStyle()
|
||||
para.set(first_indent=-0.75,lmargin=.75)
|
||||
para.set_top_margin(0.25)
|
||||
para.set_bottom_margin(0.25)
|
||||
para.set_description(_('The basic style used for the endnotes source display.'))
|
||||
style_sheet.add_paragraph_style("Endnotes-Source",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 endnotes reference display.'))
|
||||
style_sheet.add_paragraph_style("Endnotes-Ref",para)
|
||||
|
||||
def cite_source(bibliography,obj):
|
||||
"""
|
||||
Cite any sources for the object and add them to the bibliography.
|
||||
|
||||
@param bibliography: The bibliography to contain the citations.
|
||||
@type bibliography: L{Bibliography}
|
||||
@param obj: An object with source references.
|
||||
@type obj: L{Relib.SourceBase}
|
||||
"""
|
||||
txt = ""
|
||||
slist = obj.get_source_references()
|
||||
if slist:
|
||||
txt += '<super>'
|
||||
first = 1
|
||||
for ref in slist:
|
||||
if not first:
|
||||
txt += ','
|
||||
first = 0
|
||||
(cindex,rindex) = bibliography.add_reference(ref)
|
||||
txt += "%d" % (cindex + 1)
|
||||
if rindex != None:
|
||||
txt += "%s" % string.lowercase[rindex]
|
||||
txt += '</super>'
|
||||
return txt
|
||||
|
||||
def write_endnotes(bibliography,database,doc):
|
||||
"""
|
||||
Write all the entries in the bibliography as endnotes.
|
||||
|
||||
@param bibliography: The bibliography that contains the citations.
|
||||
@type bibliography: L{Bibliography}
|
||||
@param database: The database that the sources come from.
|
||||
@type database: GrampsDbBase
|
||||
@param doc: The document to write the endnotes into.
|
||||
@type doc: L{BaseDoc.TextDoc}
|
||||
"""
|
||||
if bibliography.get_citation_count() == 0:
|
||||
return
|
||||
|
||||
doc.start_paragraph('Endnotes-Header')
|
||||
doc.write_text(_('Endnotes'))
|
||||
doc.end_paragraph()
|
||||
|
||||
cindex = 0
|
||||
for citation in bibliography.get_citation_list():
|
||||
cindex += 1
|
||||
source = database.get_source_from_handle(citation.get_source_handle())
|
||||
first = True
|
||||
|
||||
doc.start_paragraph('Endnotes-Source',"%d." % cindex)
|
||||
|
||||
src_txt = _format_source_text(source)
|
||||
|
||||
doc.write_text(src_txt)
|
||||
doc.end_paragraph()
|
||||
|
||||
ref_list = citation.get_ref_list()
|
||||
|
||||
if ref_list:
|
||||
doc.start_paragraph('Endnotes-Ref')
|
||||
|
||||
first = True
|
||||
rindex = 0
|
||||
for ref in ref_list:
|
||||
txt = "%s: %s" % (string.lowercase[rindex],ref.get_page())
|
||||
if first:
|
||||
doc.write_text(txt)
|
||||
first = False
|
||||
else:
|
||||
doc.write_text('; %s' % txt)
|
||||
|
||||
rindex += 1
|
||||
doc.end_paragraph()
|
||||
|
||||
def _format_source_text(source):
|
||||
src_txt = ""
|
||||
|
||||
if source.get_author():
|
||||
src_txt += source.get_author()
|
||||
|
||||
if source.get_title():
|
||||
if src_txt:
|
||||
src_txt += ", "
|
||||
src_txt += '"%s"' % source.get_title()
|
||||
|
||||
if source.get_publication_info():
|
||||
if src_txt:
|
||||
src_txt += ", "
|
||||
src_txt += source.get_publication_info()
|
||||
|
||||
if source.get_abbreviation():
|
||||
if src_txt:
|
||||
src_txt += ", "
|
||||
src_txt += "(%s)" % source.get_abbreviation()
|
||||
|
||||
return src_txt
|
@ -34,7 +34,6 @@ A collection of utilities to aid in the generation of reports.
|
||||
import time
|
||||
import os
|
||||
from gettext import gettext as _
|
||||
import cStringIO
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
@ -2434,35 +2433,6 @@ def get_address_str(addr):
|
||||
str = "%s, %s" % (str,info)
|
||||
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
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# People Filters
|
||||
|
@ -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
|
||||
@ -38,4 +39,7 @@ from _TextReportDialog import TextReportDialog
|
||||
from _ReportOptions import ReportOptions
|
||||
import _ReportUtils as ReportUtils
|
||||
|
||||
from _Bibliography import Bibliography, Citation
|
||||
import _Endnotes as Endnotes
|
||||
|
||||
from _PrintTools import run_print_dialog, get_print_dialog_app
|
||||
|
@ -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
|
||||
@ -1010,9 +1011,9 @@ class BookReportDialog(ReportDialog):
|
||||
style_name = item.option_class.handler.get_default_stylesheet_name()
|
||||
style_sheet = style_list.get_style_sheet(style_name)
|
||||
|
||||
for this_style_name in style_sheet.get_names():
|
||||
self.selected_style.add_style(
|
||||
this_style_name,style_sheet.get_style(this_style_name))
|
||||
for this_style_name in style_sheet.get_paragraph_style_names():
|
||||
self.selected_style.add_paragraph_style(
|
||||
this_style_name,style_sheet.get_paragraph_style(this_style_name))
|
||||
|
||||
response = self.window.run()
|
||||
if response == RESPONSE_OK:
|
||||
|
@ -30,7 +30,6 @@
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
from gettext import gettext as _
|
||||
import cStringIO
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
@ -48,6 +47,7 @@ import RelLib
|
||||
from PluginUtils import register_report
|
||||
from ReportBase import Report, ReportUtils, ReportOptions, \
|
||||
CATEGORY_TEXT, MODE_GUI, MODE_BKI, MODE_CLI
|
||||
from ReportBase import Bibliography, Endnotes
|
||||
|
||||
import BaseDoc
|
||||
import Utils
|
||||
@ -129,8 +129,7 @@ class DetAncestorReport(Report):
|
||||
else:
|
||||
self.EMPTY_PLACE = ""
|
||||
|
||||
self.sref_map = {}
|
||||
self.sref_index = 0
|
||||
self.bibli = Bibliography()
|
||||
|
||||
def apply_filter(self,person_handle,index):
|
||||
if (not person_handle) or (index >= 2**self.max_generations):
|
||||
@ -189,7 +188,7 @@ class DetAncestorReport(Report):
|
||||
if self.includeEvents:
|
||||
self.write_family_events(family)
|
||||
if self.includeSources:
|
||||
self.write_endnotes()
|
||||
Endnotes.write_endnotes(self.bibli,self.database,self.doc)
|
||||
|
||||
def write_person(self, key):
|
||||
"""Output birth, death, parentage, marriage and notes information """
|
||||
@ -210,12 +209,10 @@ class DetAncestorReport(Report):
|
||||
self.doc.start_bold()
|
||||
self.doc.write_text(name,mark)
|
||||
if name[-1:] == '.':
|
||||
self.doc.write_text(" ")
|
||||
self.doc.write_text("%s " % self.endnotes(person))
|
||||
else:
|
||||
self.doc.write_text(". ")
|
||||
self.doc.write_text("%s. " % self.endnotes(person))
|
||||
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)
|
||||
@ -237,25 +234,26 @@ class DetAncestorReport(Report):
|
||||
text = ReportUtils.born_str(self.database,person,first,
|
||||
self.EMPTY_DATE,self.EMPTY_PLACE)
|
||||
if text:
|
||||
self.doc.write_text(text)
|
||||
birth_ref = person.get_birth_ref()
|
||||
if birth_ref:
|
||||
birth = self.database.get_event_from_handle(birth_ref.ref)
|
||||
self.endnotes(birth)
|
||||
text = text.rstrip(". ")
|
||||
text = text + self.endnotes(birth) + ". "
|
||||
self.doc.write_text(text)
|
||||
first = 0
|
||||
|
||||
age,units = self.calc_age(person)
|
||||
text = ReportUtils.died_str(self.database,person,first,
|
||||
self.EMPTY_DATE,self.EMPTY_PLACE,age,units)
|
||||
if text:
|
||||
self.doc.write_text(text)
|
||||
death_ref = person.get_birth_ref()
|
||||
if death_ref:
|
||||
death = self.database.get_event_from_handle(death_ref.ref)
|
||||
self.endnotes(death)
|
||||
text = text.rstrip(". ")
|
||||
text = text + self.endnotes(death) + ". "
|
||||
self.doc.write_text(text)
|
||||
first = 0
|
||||
|
||||
|
||||
text = ReportUtils.buried_str(self.database,person,first,
|
||||
self.EMPTY_DATE,self.EMPTY_PLACE)
|
||||
if text:
|
||||
@ -336,6 +334,7 @@ class DetAncestorReport(Report):
|
||||
return 0 # Not duplicate person
|
||||
|
||||
def write_event(self, event_ref):
|
||||
text = ""
|
||||
event = self.database.get_event_from_handle(event_ref.ref)
|
||||
date = DateHandler.get_date(event)
|
||||
ph = event.get_place_handle()
|
||||
@ -347,30 +346,30 @@ class DetAncestorReport(Report):
|
||||
self.doc.start_paragraph('DAR-MoreDetails')
|
||||
evtName = str( event.get_type() )
|
||||
if date and place:
|
||||
self.doc.write_text(
|
||||
_('%(event_name)s: %(date)s, %(place)s%(endnotes)s. ') % {
|
||||
text += _('%(event_name)s: %(date)s, %(place)s') % {
|
||||
'event_name' : _(evtName),
|
||||
'date' : date,
|
||||
'endnotes' : self.endnotes(event),
|
||||
'place' : place })
|
||||
'place' : place }
|
||||
elif date:
|
||||
self.doc.write_text(
|
||||
_('%(event_name)s: %(date)s%(endnotes)s. ') % {
|
||||
text += _('%(event_name)s: %(date)s') % {
|
||||
'event_name' : _(evtName),
|
||||
'endnotes' : self.endnotes(event),
|
||||
'date' : date})
|
||||
'date' : date}
|
||||
elif place:
|
||||
self.doc.write_text(
|
||||
_('%(event_name)s: %(place)s%(endnotes)s. ') % {
|
||||
text += _('%(event_name)s: %(place)s%') % {
|
||||
'event_name' : _(evtName),
|
||||
'endnotes' : self.endnotes(event),
|
||||
'place' : place })
|
||||
'place' : place }
|
||||
else:
|
||||
self.doc.write_text(_('%(event_name)s: ') % {
|
||||
'event_name' : _(evtName)})
|
||||
text += _('%(event_name)s: ') % {'event_name' : _(evtName)}
|
||||
|
||||
if event.get_description():
|
||||
self.doc.write_text(event.get_description())
|
||||
self.doc.write_text(".")
|
||||
if text:
|
||||
text += ". "
|
||||
text += event.get_description()
|
||||
|
||||
if text:
|
||||
text += _('%(endnotes)s.') % { 'endnotes' : self.endnotes(event) }
|
||||
|
||||
self.doc.write_text(text)
|
||||
self.doc.end_paragraph()
|
||||
|
||||
def write_parents(self, person, firstName):
|
||||
@ -598,79 +597,11 @@ class DetAncestorReport(Report):
|
||||
else:
|
||||
return (0,0)
|
||||
|
||||
def write_endnotes(self):
|
||||
keys = self.sref_map.keys()
|
||||
if not keys:
|
||||
return
|
||||
|
||||
self.doc.start_paragraph('DAR-Endnotes-Header')
|
||||
self.doc.write_text(_('Endnotes'))
|
||||
self.doc.end_paragraph()
|
||||
|
||||
keys.sort()
|
||||
for key in keys:
|
||||
srcref = self.sref_map[key]
|
||||
sh = srcref.get_reference_handle()
|
||||
base = self.database.get_source_from_handle(sh)
|
||||
|
||||
self.doc.start_paragraph('DAR-Endnotes',"%d." % key)
|
||||
self.doc.write_text(base.get_title())
|
||||
|
||||
# Disable writing reference details, because only the details
|
||||
# the first reference to this source will appear.
|
||||
# FIXME: need to properly change self.endnotes() to put
|
||||
# this feature back correclty.
|
||||
## for item in [ base.get_author(), base.get_publication_info(),
|
||||
## base.get_abbreviation(),
|
||||
## _dd.display(srcref.get_date_object()),]:
|
||||
## if item:
|
||||
## self.doc.write_text('; %s' % item)
|
||||
##
|
||||
## item = srcref.get_text()
|
||||
## if item:
|
||||
## self.doc.write_text('; ')
|
||||
## self.doc.write_text(_('Text:'))
|
||||
## self.doc.write_text(' ')
|
||||
## self.doc.write_text(item)
|
||||
##
|
||||
## item = srcref.get_note()
|
||||
## if item:
|
||||
## self.doc.write_text('; ')
|
||||
## self.doc.write_text(_('Comments:'))
|
||||
## self.doc.write_text(' ')
|
||||
## self.doc.write_text(item)
|
||||
|
||||
self.doc.write_text('.')
|
||||
self.doc.end_paragraph()
|
||||
|
||||
def endnotes(self,obj):
|
||||
if not obj or not self.includeSources:
|
||||
return ""
|
||||
msg = cStringIO.StringIO()
|
||||
slist = obj.get_source_references()
|
||||
if slist:
|
||||
msg.write('<super>')
|
||||
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 self.sref_map.keys():
|
||||
if ref_base == self.sref_map[key].get_reference_handle():
|
||||
the_key = key
|
||||
break
|
||||
if the_key:
|
||||
msg.write("%d" % the_key)
|
||||
else:
|
||||
self.sref_index += 1
|
||||
self.sref_map[self.sref_index] = ref
|
||||
msg.write("%d" % self.sref_index)
|
||||
msg.write('</super>')
|
||||
the_str = msg.getvalue()
|
||||
msg.close()
|
||||
return the_str
|
||||
|
||||
return Endnotes.cite_source(self.bibli,obj)
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
@ -843,22 +774,7 @@ class DetAncestorOptions(ReportOptions):
|
||||
para.set_description(_('The style used for additional detail data.'))
|
||||
default_style.add_paragraph_style("DAR-MoreDetails",para)
|
||||
|
||||
font = BaseDoc.FontStyle()
|
||||
font.set(face=BaseDoc.FONT_SANS_SERIF,size=14,italic=1)
|
||||
para = BaseDoc.ParagraphStyle()
|
||||
para.set_font(font)
|
||||
para.set_header_level(2)
|
||||
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_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_paragraph_style("DAR-Endnotes",para)
|
||||
Endnotes.add_endnote_styles(default_style)
|
||||
|
||||
def add_user_options(self,dialog):
|
||||
"""
|
||||
|
@ -30,7 +30,6 @@
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
from gettext import gettext as _
|
||||
import cStringIO
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
@ -50,6 +49,7 @@ import Errors
|
||||
from PluginUtils import register_report
|
||||
from ReportBase import Report, ReportUtils, ReportOptions, \
|
||||
CATEGORY_TEXT, MODE_GUI, MODE_BKI, MODE_CLI
|
||||
from ReportBase import Bibliography, Endnotes
|
||||
import BaseDoc
|
||||
import const
|
||||
import DateHandler
|
||||
@ -135,8 +135,7 @@ class DetDescendantReport(Report):
|
||||
else:
|
||||
self.EMPTY_PLACE = ""
|
||||
|
||||
self.sref_map = {}
|
||||
self.sref_index = 0
|
||||
self.bibli = Bibliography()
|
||||
|
||||
def apply_filter(self,person_handle,index,pid,cur_gen=1):
|
||||
if (not person_handle) or (cur_gen > self.max_generations):
|
||||
@ -217,7 +216,7 @@ class DetDescendantReport(Report):
|
||||
self.write_family_events(family)
|
||||
|
||||
if self.includeSources:
|
||||
self.write_endnotes()
|
||||
Endnotes.write_endnotes(self.bibli,self.database,self.doc)
|
||||
|
||||
def write_person(self, key):
|
||||
"""Output birth, death, parentage, marriage and notes information """
|
||||
@ -238,12 +237,10 @@ class DetDescendantReport(Report):
|
||||
self.doc.start_bold()
|
||||
self.doc.write_text(name,mark)
|
||||
if name[-1:] == '.':
|
||||
self.doc.write_text(" ")
|
||||
self.doc.write_text("%s " % self.endnotes(person))
|
||||
else:
|
||||
self.doc.write_text(". ")
|
||||
self.doc.write_text("%s. " % self.endnotes(person))
|
||||
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)
|
||||
@ -264,25 +261,26 @@ class DetDescendantReport(Report):
|
||||
text = ReportUtils.born_str(self.database,person,first,
|
||||
self.EMPTY_DATE,self.EMPTY_PLACE)
|
||||
if text:
|
||||
self.doc.write_text(text)
|
||||
birth_ref = person.get_birth_ref()
|
||||
if birth_ref:
|
||||
birth = self.database.get_event_from_handle(birth_ref.ref)
|
||||
self.endnotes(birth)
|
||||
text = text.rstrip(". ")
|
||||
text = text + self.endnotes(birth) + ". "
|
||||
self.doc.write_text(text)
|
||||
first = 0
|
||||
|
||||
age,units = self.calc_age(person)
|
||||
text = ReportUtils.died_str(self.database,person,first,
|
||||
self.EMPTY_DATE,self.EMPTY_PLACE,age,units)
|
||||
if text:
|
||||
self.doc.write_text(text)
|
||||
death_ref = person.get_birth_ref()
|
||||
if death_ref:
|
||||
death = self.database.get_event_from_handle(death_ref.ref)
|
||||
self.endnotes(death)
|
||||
text = text.rstrip(". ")
|
||||
text = text + self.endnotes(death) + ". "
|
||||
self.doc.write_text(text)
|
||||
first = 0
|
||||
|
||||
|
||||
text = ReportUtils.buried_str(self.database,person,first,
|
||||
self.EMPTY_DATE,self.EMPTY_PLACE)
|
||||
if text:
|
||||
@ -363,6 +361,7 @@ class DetDescendantReport(Report):
|
||||
return 0 # Not duplicate person
|
||||
|
||||
def write_event(self, event_ref):
|
||||
text = ""
|
||||
event = self.database.get_event_from_handle(event_ref.ref)
|
||||
date = DateHandler.get_date(event)
|
||||
ph = event.get_place_handle()
|
||||
@ -374,30 +373,30 @@ class DetDescendantReport(Report):
|
||||
self.doc.start_paragraph('DDR-MoreDetails')
|
||||
evtName = str( event.get_type() )
|
||||
if date and place:
|
||||
self.doc.write_text(
|
||||
_('%(event_name)s: %(date)s, %(place)s%(endnotes)s. ') % {
|
||||
text += _('%(event_name)s: %(date)s, %(place)s') % {
|
||||
'event_name' : _(evtName),
|
||||
'date' : date,
|
||||
'endnotes' : self.endnotes(event),
|
||||
'place' : place })
|
||||
'place' : place }
|
||||
elif date:
|
||||
self.doc.write_text(
|
||||
_('%(event_name)s: %(date)s%(endnotes)s. ') % {
|
||||
text += _('%(event_name)s: %(date)s') % {
|
||||
'event_name' : _(evtName),
|
||||
'endnotes' : self.endnotes(event),
|
||||
'date' : date})
|
||||
'date' : date}
|
||||
elif place:
|
||||
self.doc.write_text(
|
||||
_('%(event_name)s: %(place)s%(endnotes)s. ') % {
|
||||
text += _('%(event_name)s: %(place)s%') % {
|
||||
'event_name' : _(evtName),
|
||||
'endnotes' : self.endnotes(event),
|
||||
'place' : place })
|
||||
'place' : place }
|
||||
else:
|
||||
self.doc.write_text(_('%(event_name)s: ') % {
|
||||
'event_name' : _(evtName)})
|
||||
text += _('%(event_name)s: ') % {'event_name' : _(evtName)}
|
||||
|
||||
if event.get_description():
|
||||
self.doc.write_text(event.get_description())
|
||||
self.doc.write_text(".")
|
||||
if text:
|
||||
text += ". "
|
||||
text += event.get_description()
|
||||
|
||||
if text:
|
||||
text += _('%(endnotes)s.') % { 'endnotes' : self.endnotes(event) }
|
||||
|
||||
self.doc.write_text(text)
|
||||
self.doc.end_paragraph()
|
||||
|
||||
def write_parents(self, person, firstName):
|
||||
@ -624,79 +623,11 @@ class DetDescendantReport(Report):
|
||||
else:
|
||||
return (0,0)
|
||||
|
||||
def write_endnotes(self):
|
||||
keys = self.sref_map.keys()
|
||||
if not keys:
|
||||
return
|
||||
|
||||
self.doc.start_paragraph('DDR-Endnotes-Header')
|
||||
self.doc.write_text(_('Endnotes'))
|
||||
self.doc.end_paragraph()
|
||||
|
||||
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_paragraph('DDR-Endnotes',"%d." % key)
|
||||
self.doc.write_text(base.get_title())
|
||||
|
||||
# Disable writing reference details, because only the details
|
||||
# the first reference to this source will appear.
|
||||
# FIXME: need to properly change self.endnotes() to put
|
||||
# this feature back correclty.
|
||||
## for item in [ base.get_author(), base.get_publication_info(), base.get_abbreviation(),
|
||||
## _dd.display(srcref.get_date_object()),]:
|
||||
## if item:
|
||||
## self.doc.write_text('; %s' % item)
|
||||
##
|
||||
## item = srcref.get_text()
|
||||
## if item:
|
||||
## self.doc.write_text('; ')
|
||||
## self.doc.write_text(_('Text:'))
|
||||
## self.doc.write_text(' ')
|
||||
## self.doc.write_text(item)
|
||||
##
|
||||
## item = srcref.get_note()
|
||||
## if item:
|
||||
## self.doc.write_text('; ')
|
||||
## self.doc.write_text(_('Comments:'))
|
||||
## self.doc.write_text(' ')
|
||||
## self.doc.write_text(item)
|
||||
|
||||
self.doc.write_text('.')
|
||||
self.doc.end_paragraph()
|
||||
|
||||
def endnotes(self,obj):
|
||||
if not obj or not self.includeSources:
|
||||
return ""
|
||||
|
||||
msg = cStringIO.StringIO()
|
||||
slist = obj.get_source_references()
|
||||
if slist:
|
||||
msg.write('<super>')
|
||||
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 self.sref_map.keys():
|
||||
if ref_base == self.sref_map[key].get_reference_handle():
|
||||
the_key = key
|
||||
break
|
||||
if the_key:
|
||||
msg.write("%d" % the_key)
|
||||
else:
|
||||
self.sref_index += 1
|
||||
self.sref_map[self.sref_index] = ref
|
||||
msg.write("%d" % self.sref_index)
|
||||
msg.write('</super>')
|
||||
str = msg.getvalue()
|
||||
msg.close()
|
||||
return str
|
||||
return Endnotes.cite_source(self.bibli,obj)
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
@ -873,22 +804,7 @@ class DetDescendantOptions(ReportOptions):
|
||||
para.set_description(_('The style used for additional detail data.'))
|
||||
default_style.add_paragraph_style("DDR-MoreDetails",para)
|
||||
|
||||
font = BaseDoc.FontStyle()
|
||||
font.set(face=BaseDoc.FONT_SANS_SERIF,size=14,italic=1)
|
||||
para = BaseDoc.ParagraphStyle()
|
||||
para.set_font(font)
|
||||
para.set_header_level(2)
|
||||
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_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_paragraph_style("DDR-Endnotes",para)
|
||||
Endnotes.add_endnote_styles(default_style)
|
||||
|
||||
def add_user_options(self,dialog):
|
||||
"""
|
||||
|
@ -50,6 +50,7 @@ import DateHandler
|
||||
from PluginUtils import register_report
|
||||
from ReportBase import Report, ReportUtils, ReportOptions, \
|
||||
CATEGORY_TEXT, MODE_GUI, MODE_BKI, MODE_CLI
|
||||
from ReportBase import Bibliography, Endnotes
|
||||
from BasicUtils.NameDisplay import displayer as _nd
|
||||
from QuestionDialog import WarningDialog
|
||||
|
||||
@ -86,7 +87,7 @@ class IndivCompleteReport(Report):
|
||||
filter_num = options_class.handler.options_dict['filter']
|
||||
filters = ReportUtils.get_person_filters(person)
|
||||
self.filter = filters[filter_num]
|
||||
self.sref_map = {}
|
||||
self.bibli = Bibliography()
|
||||
|
||||
def write_fact(self,event):
|
||||
if event == None:
|
||||
@ -114,7 +115,7 @@ class IndivCompleteReport(Report):
|
||||
text = '%s%s. ' % (text,description)
|
||||
endnotes = ""
|
||||
if self.use_srcs:
|
||||
endnotes = ReportUtils.get_endnotes(self.sref_map,event)
|
||||
endnotes = Endnotes.cite_source(self.bibli,event)
|
||||
|
||||
self.doc.start_row()
|
||||
self.normal_cell(name)
|
||||
@ -249,7 +250,7 @@ class IndivCompleteReport(Report):
|
||||
text = _nd.display_name(name)
|
||||
endnotes = ""
|
||||
if self.use_srcs:
|
||||
endnotes = ReportUtils.get_endnotes(self.sref_map,name)
|
||||
endnotes = Endnotes.cite_source(self.bibli,name)
|
||||
self.normal_cell(text,endnotes)
|
||||
self.doc.end_row()
|
||||
self.doc.end_table()
|
||||
@ -277,7 +278,7 @@ class IndivCompleteReport(Report):
|
||||
date = DateHandler.get_date(addr)
|
||||
endnotes = ""
|
||||
if self.use_srcs:
|
||||
endnotes = ReportUtils.get_endnotes(self.sref_map,addr)
|
||||
endnotes = Endnotes.cite_source(self.bibli,addr)
|
||||
self.doc.start_row()
|
||||
self.normal_cell(date)
|
||||
self.normal_cell(text,endnotes)
|
||||
@ -399,9 +400,7 @@ class IndivCompleteReport(Report):
|
||||
self.doc.start_paragraph('IDS-Normal')
|
||||
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_cell()
|
||||
|
||||
@ -458,7 +457,7 @@ class IndivCompleteReport(Report):
|
||||
mark = ReportUtils.get_person_mark(self.database, self.start_person)
|
||||
endnotes = ""
|
||||
if self.use_srcs:
|
||||
endnotes = ReportUtils.get_endnotes(self.sref_map,name)
|
||||
endnotes = Endnotes.cite_source(self.bibli,name)
|
||||
self.normal_cell(text,endnotes,mark)
|
||||
self.doc.end_row()
|
||||
|
||||
@ -517,7 +516,8 @@ class IndivCompleteReport(Report):
|
||||
self.write_families()
|
||||
self.write_addresses()
|
||||
self.write_note()
|
||||
self.write_sources()
|
||||
if self.use_srcs:
|
||||
Endnotes.write_endnotes(self.bibli,self.database,self.doc)
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
@ -649,6 +649,8 @@ class IndivCompleteOptions(ReportOptions):
|
||||
cell.set_longlist(1)
|
||||
default_style.add_cell_style("IDS-ListCell",cell)
|
||||
|
||||
Endnotes.add_endnote_styles(default_style)
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
|
Loading…
x
Reference in New Issue
Block a user