From 97a8f194628e74e6fa8f872c766c4b05a3245a56 Mon Sep 17 00:00:00 2001 From: Brian Matherly Date: Sun, 4 Jun 2006 04:26:28 +0000 Subject: [PATCH] add Table of Contents marks svn: r6855 --- gramps2/ChangeLog | 11 +++++++++++ gramps2/src/BaseDoc.py | 5 +++-- gramps2/src/docgen/ODFDoc.py | 4 +++- gramps2/src/docgen/OpenOfficeDoc.py | 4 +++- gramps2/src/plugins/AncestorReport.py | 10 +++++++--- gramps2/src/plugins/DescendReport.py | 4 +++- gramps2/src/plugins/DetAncestralReport.py | 7 +++++-- gramps2/src/plugins/DetDescendantReport.py | 7 +++++-- gramps2/src/plugins/FamilyGroup.py | 7 +++++-- gramps2/src/plugins/IndivComplete.py | 5 +++-- 10 files changed, 48 insertions(+), 16 deletions(-) diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index dd410eb1b..7f12b5c98 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,3 +1,14 @@ +2006-06-03 Brian Matherly + * src/docgen/ODFDoc.py: add Table of Contents mark + * src/docgen/OpenOfficeDoc.py: add Table of Contents mark + * src/plugins/DetDecendantReport: add Table of Contents marks + * src/plugins/AncestorReport.py: add Table of Contents marks + * src/plugins/DetAncestralReport.py: add Table of Contents marks + * src/plugins/DecendReport.py: add Table of Contents marks + * src/plugins/IndivComplete.py: add Table of Contents marks + * src/plugins/FamilyGroup.py: add Table of Contents marks + * src/BaseDoc.py: add TOC levels + 2006-06-03 Don Allingham * src/DisplayTabs/_BackRefList.py (BackRefList.right_click): override right click, because Remove and Add have no relevence diff --git a/gramps2/src/BaseDoc.py b/gramps2/src/BaseDoc.py index 537524932..dec3141bd 100644 --- a/gramps2/src/BaseDoc.py +++ b/gramps2/src/BaseDoc.py @@ -1161,12 +1161,13 @@ class IndexMark: """ Defines a mark to be associated with text for indexing. """ - def __init__(self, key="", type=INDEX_TYPE_ALP): + def __init__(self, key="", type=INDEX_TYPE_ALP, level=1): """ Initialize the object with default values, unless values are specified. """ - self.type = type self.key = key + self.type = type + self.level = level #------------------------------------------------------------------------ # diff --git a/gramps2/src/docgen/ODFDoc.py b/gramps2/src/docgen/ODFDoc.py index 66ddbe285..57c3d9d7f 100644 --- a/gramps2/src/docgen/ODFDoc.py +++ b/gramps2/src/docgen/ODFDoc.py @@ -835,9 +835,11 @@ class ODFDoc(BaseDoc.BaseDoc): key = key.replace('"','"') if mark.type == BaseDoc.INDEX_TYPE_ALP: self.cntnt.write('' % key) elif mark.type == BaseDoc.INDEX_TYPE_TOC: self.cntnt.write('' % key) + self.cntnt.write('text:string-value="%s" ' % key) + self.cntnt.write('text:outline-level="%d" />' % mark.level) self.cntnt.write(escape(text,_esc_map)) def _write_manifest(self): diff --git a/gramps2/src/docgen/OpenOfficeDoc.py b/gramps2/src/docgen/OpenOfficeDoc.py index 6f5ce7f60..06237c996 100644 --- a/gramps2/src/docgen/OpenOfficeDoc.py +++ b/gramps2/src/docgen/OpenOfficeDoc.py @@ -738,9 +738,11 @@ class OpenOfficeDoc(BaseDoc.BaseDoc): key = key.replace('"','"') if mark.type == BaseDoc.INDEX_TYPE_ALP: self.cntnt.write('' % key) elif mark.type == BaseDoc.INDEX_TYPE_TOC: self.cntnt.write('' % key) + self.cntnt.write('text:string-value="%s" ' % key) + self.cntnt.write('text:outline-level="%d" />' % mark.level) self.cntnt.write(escape(text,_esc_map)) def _write_manifest(self): diff --git a/gramps2/src/plugins/AncestorReport.py b/gramps2/src/plugins/AncestorReport.py index 9601f857e..7f0e37bd4 100644 --- a/gramps2/src/plugins/AncestorReport.py +++ b/gramps2/src/plugins/AncestorReport.py @@ -98,8 +98,10 @@ class AncestorReport(Report): self.apply_filter(self.start_person.get_handle(),1) name = NameDisplay.displayer.display_formal(self.start_person) + title = _("Ahnentafel Report for %s") % name + mark = BaseDoc.IndexMark(title,BaseDoc.INDEX_TYPE_TOC,1) self.doc.start_paragraph("AHN-Title") - self.doc.write_text(_("Ahnentafel Report for %s") % name) + self.doc.write_text(title,mark) self.doc.end_paragraph() keys = self.map.keys() @@ -111,8 +113,9 @@ class AncestorReport(Report): if self.pgbrk and generation > 0: self.doc.page_break() generation += 1 + mark = BaseDoc.IndexMark(title,BaseDoc.INDEX_TYPE_TOC,2) self.doc.start_paragraph("AHN-Generation") - self.doc.write_text(_("Generation %d") % generation) + self.doc.write_text(_("Generation %d") % generation,mark) self.doc.end_paragraph() self.doc.start_paragraph("AHN-Entry","%d." % key) @@ -166,7 +169,8 @@ class AncestorOptions(ReportOptions): para.set_font(font) para.set_header_level(1) para.set_top_margin(0.25) - para.set_bottom_margin(0.25) + para.set_bottom_margin(0.25) + para.set_alignment(BaseDoc.PARA_ALIGN_CENTER) #para.set(pad=0.5) para.set_description(_('The style used for the title of the page.')) default_style.add_style("AHN-Title",para) diff --git a/gramps2/src/plugins/DescendReport.py b/gramps2/src/plugins/DescendReport.py index 82068fac5..cca2f591a 100644 --- a/gramps2/src/plugins/DescendReport.py +++ b/gramps2/src/plugins/DescendReport.py @@ -150,7 +150,9 @@ class DescendantReport(Report): def write_report(self): self.doc.start_paragraph("DR-Title") name = NameDisplay.displayer.display(self.start_person) - self.doc.write_text(_("Descendants of %s") % name) + title = _("Descendants of %s") % name + mark = BaseDoc.IndexMark(title,BaseDoc.INDEX_TYPE_TOC,1) + self.doc.write_text(title,mark) self.doc.end_paragraph() self.dump(1,self.start_person) diff --git a/gramps2/src/plugins/DetAncestralReport.py b/gramps2/src/plugins/DetAncestralReport.py index 6e8756f30..2b53f1e4c 100644 --- a/gramps2/src/plugins/DetAncestralReport.py +++ b/gramps2/src/plugins/DetAncestralReport.py @@ -149,7 +149,8 @@ class DetAncestorReport(Report): name = _nd.display_name(self.start_person.get_primary_name()) self.doc.start_paragraph("DAR-Title") title = _("Ancestral Report for %s") % name - self.doc.write_text(title) + mark = BaseDoc.IndexMark(title,BaseDoc.INDEX_TYPE_TOC,1) + self.doc.write_text(title,mark) self.doc.end_paragraph() keys = self.map.keys() @@ -163,7 +164,8 @@ class DetAncestorReport(Report): self.doc.page_break() self.doc.start_paragraph("DAR-Generation") text = _("Generation %d") % (generation+1) - self.doc.write_text(text) + mark = BaseDoc.IndexMark(text,BaseDoc.INDEX_TYPE_TOC,2) + self.doc.write_text(text,mark) self.doc.end_paragraph() generation = generation + 1 if self.childRef: @@ -666,6 +668,7 @@ class DetAncestorOptions(ReportOptions): para.set_header_level(1) para.set_top_margin(0.25) para.set_bottom_margin(0.25) + para.set_alignment(BaseDoc.PARA_ALIGN_CENTER) para.set_description(_('The style used for the title of the page.')) default_style.add_style("DAR-Title",para) diff --git a/gramps2/src/plugins/DetDescendantReport.py b/gramps2/src/plugins/DetDescendantReport.py index 9dc8cd941..2620b1513 100644 --- a/gramps2/src/plugins/DetDescendantReport.py +++ b/gramps2/src/plugins/DetDescendantReport.py @@ -181,7 +181,8 @@ class DetDescendantReport(Report): title = _("Descendant Report for %(person_name)s") % { 'person_name' : name } - self.doc.write_text(title) + mark = BaseDoc.IndexMark(title,BaseDoc.INDEX_TYPE_TOC,1) + self.doc.write_text(title,mark) self.doc.end_paragraph() keys = self.map.keys() @@ -194,7 +195,8 @@ class DetDescendantReport(Report): self.doc.page_break() self.doc.start_paragraph("DDR-Generation") text = _("Generation %d") % (generation+1) - self.doc.write_text(text) + mark = BaseDoc.IndexMark(text,BaseDoc.INDEX_TYPE_TOC,2) + self.doc.write_text(text,mark) self.doc.end_paragraph() if self.childRef: self.prev_gen_handles = self.gen_handles.copy() @@ -701,6 +703,7 @@ class DetDescendantOptions(ReportOptions): para.set_header_level(1) para.set_top_margin(0.25) para.set_bottom_margin(0.25) + para.set_alignment(BaseDoc.PARA_ALIGN_CENTER) para.set_description(_('The style used for the title of the page.')) default_style.add_style("DDR-Title",para) diff --git a/gramps2/src/plugins/FamilyGroup.py b/gramps2/src/plugins/FamilyGroup.py index c89de5873..8fd6fa6ae 100644 --- a/gramps2/src/plugins/FamilyGroup.py +++ b/gramps2/src/plugins/FamilyGroup.py @@ -607,9 +607,11 @@ class FamilyGroup(Report): def dump_family(self,family_handle,generation): self.doc.start_paragraph('FGR-Title') if self.recursive and self.generations: - self.doc.write_text(_("Family Group Report - Generation %d") % generation) + title=_("Family Group Report - Generation %d") % generation else: - self.doc.write_text(_("Family Group Report") ) + title=_("Family Group Report") + mark = BaseDoc.IndexMark(title,BaseDoc.INDEX_TYPE_TOC,1) + self.doc.write_text( title, mark ) self.doc.end_paragraph() family = self.database.get_family_from_handle(family_handle) @@ -866,6 +868,7 @@ class FamilyGroupOptions(ReportOptions): font.set_bold(1) para = BaseDoc.ParagraphStyle() para.set_font(font) + para.set_alignment(BaseDoc.PARA_ALIGN_CENTER) para.set_description(_("The style used for the title of the page.")) default_style.add_style('FGR-Title',para) diff --git a/gramps2/src/plugins/IndivComplete.py b/gramps2/src/plugins/IndivComplete.py index 4e7c5359c..33a472442 100644 --- a/gramps2/src/plugins/IndivComplete.py +++ b/gramps2/src/plugins/IndivComplete.py @@ -416,9 +416,10 @@ class IndivCompleteReport(Report): media_list = self.start_person.get_media_list() name = self.start_person.get_primary_name().get_regular_name() - mark = ReportUtils.get_person_mark(self.database,self.start_person) + title = _("Summary of %s") % name + mark = BaseDoc.IndexMark(title,BaseDoc.INDEX_TYPE_TOC,1) self.doc.start_paragraph("IDS-Title") - self.doc.write_text(_("Summary of %s") % name,mark) + self.doc.write_text(title,mark) self.doc.end_paragraph() self.doc.start_paragraph("IDS-Normal")