From bd48c356cf0632ffa4254b3cc781a4e8144b4862 Mon Sep 17 00:00:00 2001 From: Benny Malengier Date: Fri, 14 Aug 2009 11:28:28 +0000 Subject: [PATCH] 3166: Add source notes to DDR/DAR svn: r13005 --- src/ReportBase/_Endnotes.py | 25 ++++++++++++++++++- src/plugins/textreport/DetAncestralReport.py | 11 ++++++-- src/plugins/textreport/DetDescendantReport.py | 9 ++++++- 3 files changed, 41 insertions(+), 4 deletions(-) diff --git a/src/ReportBase/_Endnotes.py b/src/ReportBase/_Endnotes.py index 7f61be804..aa31881f0 100644 --- a/src/ReportBase/_Endnotes.py +++ b/src/ReportBase/_Endnotes.py @@ -55,6 +55,13 @@ def add_endnote_styles(style_sheet): 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) + + para = 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 notes display.')) + style_sheet.add_paragraph_style("Endnotes-Notes", para) def cite_source(bibliography, obj): """ @@ -79,7 +86,7 @@ def cite_source(bibliography, obj): txt += key return txt -def write_endnotes(bibliography, database, doc): +def write_endnotes(bibliography, database, doc, printnotes=False): """ Write all the entries in the bibliography as endnotes. @@ -89,6 +96,9 @@ def write_endnotes(bibliography, database, doc): @type database: GrampsDbBase @param doc: The document to write the endnotes into. @type doc: L{docgen.TextDoc} + @param printnotes: Indicate if the notes attached to a source must be + written too. + @type printnotes: bool """ if bibliography.get_citation_count() == 0: return @@ -127,6 +137,19 @@ def write_endnotes(bibliography, database, doc): rindex += 1 doc.end_paragraph() + if printnotes: + note_list = source.get_note_list() + ind = 1 + for notehandle in note_list: + note = database.get_note_from_handle(notehandle) + doc.start_paragraph('Endnotes-Notes') + doc.write_text(_('Note %(ind)d - Type: %(type)s') % { + 'ind': ind, + 'type': str(note.get_type())}) + doc.end_paragraph() + doc.write_styled_note(note.get_styledtext(), + note.get_format(),'Endnotes-Notes') + ind += 1 def _format_source_text(source): src_txt = "" diff --git a/src/plugins/textreport/DetAncestralReport.py b/src/plugins/textreport/DetAncestralReport.py index afde04a02..30c9b6ffd 100644 --- a/src/plugins/textreport/DetAncestralReport.py +++ b/src/plugins/textreport/DetAncestralReport.py @@ -116,6 +116,7 @@ class DetAncestorReport(Report): self.inc_events = menu.get_option_by_name('incevents').get_value() self.inc_addr = menu.get_option_by_name('incaddresses').get_value() self.inc_sources = menu.get_option_by_name('incsources').get_value() + self.inc_srcnotes = menu.get_option_by_name('incsrcnotes').get_value() self.inc_attrs = menu.get_option_by_name('incattrs').get_value() pid = menu.get_option_by_name('pid').get_value() self.center_person = database.get_person_from_gramps_id(pid) @@ -196,7 +197,8 @@ class DetAncestorReport(Report): if self.inc_events: self.write_family_events(family) if self.inc_sources: - Endnotes.write_endnotes(self.bibli,self.database,self.doc) + Endnotes.write_endnotes(self.bibli, self.database, self.doc, + printnotes=self.inc_srcnotes) def write_person(self, key): """Output birth, death, parentage, marriage and notes information """ @@ -790,7 +792,12 @@ class DetAncestorOptions(MenuReportOptions): incsources = BooleanOption(_("Include sources"),False) incsources.set_help(_("Whether to include source references.")) menu.add_option(category_name,"incsources",incsources) - + + incsrcnotes = BooleanOption(_("Include sources notes"), False) + incsrcnotes.set_help(_("Whether to include source notes in the " + "Endnotes section. Only works if Include sources is selected.")) + menu.add_option(category_name, "incsrcnotes", incsrcnotes) + category_name = _("Missing information") repplace = BooleanOption(_("Replace missing places with ______"),False) diff --git a/src/plugins/textreport/DetDescendantReport.py b/src/plugins/textreport/DetDescendantReport.py index 2a64fceb1..a5651543f 100644 --- a/src/plugins/textreport/DetDescendantReport.py +++ b/src/plugins/textreport/DetDescendantReport.py @@ -121,6 +121,7 @@ class DetDescendantReport(Report): self.inc_events = menu.get_option_by_name('incevents').get_value() self.inc_addr = menu.get_option_by_name('incaddresses').get_value() self.inc_sources = menu.get_option_by_name('incsources').get_value() + self.inc_srcnotes = menu.get_option_by_name('incsrcnotes').get_value() self.inc_mates = menu.get_option_by_name('incmates').get_value() self.inc_attrs = menu.get_option_by_name('incattrs').get_value() self.inc_paths = menu.get_option_by_name('incpaths').get_value() @@ -235,7 +236,8 @@ class DetDescendantReport(Report): self.write_person(key) if self.inc_sources: - Endnotes.write_endnotes(self.bibli, self.database, self.doc) + Endnotes.write_endnotes(self.bibli, self.database, self.doc, + printnotes=self.inc_srcnotes) def write_path(self, person): path = [] @@ -819,6 +821,11 @@ class DetDescendantOptions(MenuReportOptions): incsources = BooleanOption(_("Include sources"), False) incsources.set_help(_("Whether to include source references.")) menu.add_option(category_name, "incsources", incsources) + + incsrcnotes = BooleanOption(_("Include sources notes"), False) + incsrcnotes.set_help(_("Whether to include source notes in the " + "Endnotes section. Only works if Include sources is selected.")) + menu.add_option(category_name, "incsrcnotes", incsrcnotes) incmates = BooleanOption(_("Include spouses"), False) incmates.set_help(_("Whether to include detailed spouse information."))