5326: Add table of contents and index support for ODF documents
svn: r18887
This commit is contained in:
parent
3a6f1e69f5
commit
fc3d17f1df
@ -772,10 +772,12 @@ class ReportOptions(_options.Options):
|
|||||||
FTA- FTM Style Ancestral report
|
FTA- FTM Style Ancestral report
|
||||||
FTD- FTM Style Descendant report
|
FTD- FTM Style Descendant report
|
||||||
IDS- Individual Complete Report
|
IDS- Individual Complete Report
|
||||||
|
IDX- Alphabetical Index
|
||||||
IVS- Individual Summary Report
|
IVS- Individual Summary Report
|
||||||
PLC- Place Report
|
PLC- Place Report
|
||||||
SBT- Simple Boot Title
|
SBT- Simple Book Title
|
||||||
TLG- Timeline Graph
|
TLG- Timeline Graph
|
||||||
|
TOC- Table Of Contents
|
||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -1609,6 +1609,81 @@ class ODFDoc(BaseDoc, TextDoc, DrawDoc):
|
|||||||
|
|
||||||
self.cntnt.write(text)
|
self.cntnt.write(text)
|
||||||
|
|
||||||
|
def insert_toc(self):
|
||||||
|
"""
|
||||||
|
Insert a Table of Contents at this point in the document.
|
||||||
|
"""
|
||||||
|
title = _('Contents')
|
||||||
|
self.cntnt.write('<text:table-of-content>')
|
||||||
|
|
||||||
|
self.cntnt.write('<text:table-of-content-source ' +
|
||||||
|
'text:outline-level="3" ' +
|
||||||
|
'text:use-outline-level="false">')
|
||||||
|
|
||||||
|
self.cntnt.write('<text:index-title-template ' +
|
||||||
|
'text:style-name="TOC-Title">' + title)
|
||||||
|
self.cntnt.write('</text:index-title-template>')
|
||||||
|
|
||||||
|
for level in range(1, 4):
|
||||||
|
self.cntnt.write('<text:table-of-content-entry-template ' +
|
||||||
|
'text:outline-level="%d" ' % level +
|
||||||
|
'text:style-name="TOC-Heading%d">' % level)
|
||||||
|
|
||||||
|
self.cntnt.write('<text:index-entry-chapter/>')
|
||||||
|
self.cntnt.write('<text:index-entry-text/>')
|
||||||
|
self.cntnt.write('<text:index-entry-tab-stop ' +
|
||||||
|
'style:type="right" ' +
|
||||||
|
'style:leader-char="."/>')
|
||||||
|
self.cntnt.write('<text:index-entry-page-number/>')
|
||||||
|
self.cntnt.write('</text:table-of-content-entry-template>')
|
||||||
|
|
||||||
|
self.cntnt.write('</text:table-of-content-source>')
|
||||||
|
|
||||||
|
self.cntnt.write('<text:index-body>')
|
||||||
|
self.cntnt.write('<text:index-title>')
|
||||||
|
self.cntnt.write('<text:p text:style-name="NLTOC-Title">%s</text:p>' %
|
||||||
|
title)
|
||||||
|
self.cntnt.write('</text:index-title>')
|
||||||
|
self.cntnt.write('</text:index-body>')
|
||||||
|
|
||||||
|
self.cntnt.write('</text:table-of-content>')
|
||||||
|
|
||||||
|
def insert_index(self):
|
||||||
|
"""
|
||||||
|
Insert an Alphabetical Index at this point in the document.
|
||||||
|
"""
|
||||||
|
title = _('Index')
|
||||||
|
self.cntnt.write('<text:alphabetical-index>')
|
||||||
|
self.cntnt.write('<text:alphabetical-index-source ' +
|
||||||
|
'text:ignore-case="true" ' +
|
||||||
|
'text:combine-entries="false" ' +
|
||||||
|
'text:combineentries-with-pp="false">')
|
||||||
|
|
||||||
|
self.cntnt.write('<text:index-title-template ' +
|
||||||
|
'text:style-name="IDX-Title">' + title)
|
||||||
|
self.cntnt.write('</text:index-title-template>')
|
||||||
|
|
||||||
|
self.cntnt.write('<text:alphabetical-index-entry-template ' +
|
||||||
|
'text:outline-level="1" ' +
|
||||||
|
'text:style-name="IDX-Entry">')
|
||||||
|
self.cntnt.write('<text:index-entry-text/>')
|
||||||
|
self.cntnt.write('<text:index-entry-tab-stop ' +
|
||||||
|
'style:type="right" ' +
|
||||||
|
'style:leader-char="."/>')
|
||||||
|
self.cntnt.write('<text:index-entry-page-number/>')
|
||||||
|
self.cntnt.write('</text:alphabetical-index-entry-template>')
|
||||||
|
|
||||||
|
self.cntnt.write('</text:alphabetical-index-source>')
|
||||||
|
|
||||||
|
self.cntnt.write('<text:index-body>')
|
||||||
|
self.cntnt.write('<text:index-title>')
|
||||||
|
self.cntnt.write('<text:p text:style-name="NLIDX-Title">%s</text:p>' %
|
||||||
|
title)
|
||||||
|
self.cntnt.write('</text:index-title>')
|
||||||
|
self.cntnt.write('</text:index-body>')
|
||||||
|
|
||||||
|
self.cntnt.write('</text:alphabetical-index>')
|
||||||
|
|
||||||
def _write_manifest(self):
|
def _write_manifest(self):
|
||||||
"""
|
"""
|
||||||
create the manifest.xml file
|
create the manifest.xml file
|
||||||
|
@ -248,7 +248,7 @@ def write_toc(toc, doc):
|
|||||||
doc.end_paragraph()
|
doc.end_paragraph()
|
||||||
doc.end_cell()
|
doc.end_cell()
|
||||||
doc.start_cell('TOC-Cell')
|
doc.start_cell('TOC-Cell')
|
||||||
doc.start_paragraph('TOC-Number')
|
doc.start_paragraph(style_name)
|
||||||
doc.write_text(str(page_nr))
|
doc.write_text(str(page_nr))
|
||||||
doc.end_paragraph()
|
doc.end_paragraph()
|
||||||
doc.end_cell()
|
doc.end_cell()
|
||||||
@ -262,20 +262,20 @@ def write_index(index, doc):
|
|||||||
if not index:
|
if not index:
|
||||||
return
|
return
|
||||||
|
|
||||||
doc.start_paragraph('Index-Title')
|
doc.start_paragraph('IDX-Title')
|
||||||
doc.write_text(_('Index'))
|
doc.write_text(_('Index'))
|
||||||
doc.end_paragraph()
|
doc.end_paragraph()
|
||||||
|
|
||||||
doc.start_table('index', 'Index-Table')
|
doc.start_table('index', 'IDX-Table')
|
||||||
for key in sorted(index.iterkeys()):
|
for key in sorted(index.iterkeys()):
|
||||||
doc.start_row()
|
doc.start_row()
|
||||||
doc.start_cell('Index-Cell')
|
doc.start_cell('IDX-Cell')
|
||||||
doc.start_paragraph('Index-Number')
|
doc.start_paragraph('IDX-Entry')
|
||||||
doc.write_text(key)
|
doc.write_text(key)
|
||||||
doc.end_paragraph()
|
doc.end_paragraph()
|
||||||
doc.end_cell()
|
doc.end_cell()
|
||||||
doc.start_cell('Index-Cell')
|
doc.start_cell('IDX-Cell')
|
||||||
doc.start_paragraph('Index-Number')
|
doc.start_paragraph('IDX-Entry')
|
||||||
pages = [str(page_nr) for page_nr in index[key]]
|
pages = [str(page_nr) for page_nr in index[key]]
|
||||||
doc.write_text(', '.join(pages))
|
doc.write_text(', '.join(pages))
|
||||||
doc.end_paragraph()
|
doc.end_paragraph()
|
||||||
|
@ -87,22 +87,22 @@ class AlphabeticalIndexOptions(MenuReportOptions):
|
|||||||
para = ParagraphStyle()
|
para = ParagraphStyle()
|
||||||
para.set_font(font)
|
para.set_font(font)
|
||||||
para.set_bottom_margin(0.25)
|
para.set_bottom_margin(0.25)
|
||||||
para.set_description(_('The style used for the Index title.'))
|
para.set_description(_('The style used for the title.'))
|
||||||
default_style.add_paragraph_style("Index-Title", para)
|
default_style.add_paragraph_style("IDX-Title", para)
|
||||||
|
|
||||||
table = TableStyle()
|
table = TableStyle()
|
||||||
table.set_width(100)
|
table.set_width(100)
|
||||||
table.set_columns(2)
|
table.set_columns(2)
|
||||||
table.set_column_width(0, 80)
|
table.set_column_width(0, 80)
|
||||||
table.set_column_width(1, 20)
|
table.set_column_width(1, 20)
|
||||||
default_style.add_table_style("Index-Table", table)
|
default_style.add_table_style("IDX-Table", table)
|
||||||
|
|
||||||
cell = TableCellStyle()
|
cell = TableCellStyle()
|
||||||
default_style.add_cell_style("Index-Cell", cell)
|
default_style.add_cell_style("IDX-Cell", cell)
|
||||||
|
|
||||||
font = FontStyle()
|
font = FontStyle()
|
||||||
font.set(face=FONT_SANS_SERIF, size=10)
|
font.set(face=FONT_SANS_SERIF, size=10)
|
||||||
para = ParagraphStyle()
|
para = ParagraphStyle()
|
||||||
para.set_font(font)
|
para.set_font(font)
|
||||||
para.set_description(_('The style used for the Index page numbers.'))
|
para.set_description(_('The style used for index entries.'))
|
||||||
default_style.add_paragraph_style("Index-Number", para)
|
default_style.add_paragraph_style("IDX-Entry", para)
|
||||||
|
@ -87,7 +87,7 @@ class TableOfContentsOptions(MenuReportOptions):
|
|||||||
para = ParagraphStyle()
|
para = ParagraphStyle()
|
||||||
para.set_font(font)
|
para.set_font(font)
|
||||||
para.set_bottom_margin(0.25)
|
para.set_bottom_margin(0.25)
|
||||||
para.set_description(_('The style used for the TOC title.'))
|
para.set_description(_('The style used for the title.'))
|
||||||
default_style.add_paragraph_style("TOC-Title", para)
|
default_style.add_paragraph_style("TOC-Title", para)
|
||||||
|
|
||||||
table = TableStyle()
|
table = TableStyle()
|
||||||
@ -100,26 +100,19 @@ class TableOfContentsOptions(MenuReportOptions):
|
|||||||
cell = TableCellStyle()
|
cell = TableCellStyle()
|
||||||
default_style.add_cell_style("TOC-Cell", cell)
|
default_style.add_cell_style("TOC-Cell", cell)
|
||||||
|
|
||||||
font = FontStyle()
|
|
||||||
font.set(face=FONT_SANS_SERIF, size=10)
|
|
||||||
para = ParagraphStyle()
|
para = ParagraphStyle()
|
||||||
para.set_font(font)
|
para.set_font(font)
|
||||||
para.set_description(_('The style used for the TOC page numbers.'))
|
para.set_description(_('The style used for first level headings.'))
|
||||||
default_style.add_paragraph_style("TOC-Number", para)
|
|
||||||
|
|
||||||
para = ParagraphStyle()
|
|
||||||
para.set_font(font)
|
|
||||||
para.set_description(_('The style used for the TOC first level heading.'))
|
|
||||||
default_style.add_paragraph_style("TOC-Heading1", para)
|
default_style.add_paragraph_style("TOC-Heading1", para)
|
||||||
|
|
||||||
para = ParagraphStyle()
|
para = ParagraphStyle()
|
||||||
para.set_font(font)
|
para.set_font(font)
|
||||||
para.set_first_indent(0.5)
|
para.set_first_indent(0.5)
|
||||||
para.set_description(_('The style used for the TOC second level heading.'))
|
para.set_description(_('The style used for second level headings.'))
|
||||||
default_style.add_paragraph_style("TOC-Heading2", para)
|
default_style.add_paragraph_style("TOC-Heading2", para)
|
||||||
|
|
||||||
para = ParagraphStyle()
|
para = ParagraphStyle()
|
||||||
para.set_font(font)
|
para.set_font(font)
|
||||||
para.set_first_indent(1)
|
para.set_first_indent(1)
|
||||||
para.set_description(_('The style used for the TOC third level heading.'))
|
para.set_description(_('The style used for third level headings.'))
|
||||||
default_style.add_paragraph_style("TOC-Heading3", para)
|
default_style.add_paragraph_style("TOC-Heading3", para)
|
||||||
|
@ -369,8 +369,8 @@ plg.gramps_target_version = '3.4'
|
|||||||
plg.status = STABLE
|
plg.status = STABLE
|
||||||
plg.fname = 'TableOfContents.py'
|
plg.fname = 'TableOfContents.py'
|
||||||
plg.ptype = REPORT
|
plg.ptype = REPORT
|
||||||
plg.authors = ["Brian G. Matherly"]
|
plg.authors = ["Nick Hall"]
|
||||||
plg.authors_email = ["brian@gramps-project.org"]
|
plg.authors_email = ["nick__hall@hotmail.com"]
|
||||||
plg.category = CATEGORY_TEXT
|
plg.category = CATEGORY_TEXT
|
||||||
plg.reportclass = 'TableOfContents'
|
plg.reportclass = 'TableOfContents'
|
||||||
plg.optionclass = 'TableOfContentsOptions'
|
plg.optionclass = 'TableOfContentsOptions'
|
||||||
@ -391,8 +391,8 @@ plg.gramps_target_version = '3.4'
|
|||||||
plg.status = STABLE
|
plg.status = STABLE
|
||||||
plg.fname = 'AlphabeticalIndex.py'
|
plg.fname = 'AlphabeticalIndex.py'
|
||||||
plg.ptype = REPORT
|
plg.ptype = REPORT
|
||||||
plg.authors = ["Brian G. Matherly"]
|
plg.authors = ["Nick Hall"]
|
||||||
plg.authors_email = ["brian@gramps-project.org"]
|
plg.authors_email = ["nick__hall@hotmail.com"]
|
||||||
plg.category = CATEGORY_TEXT
|
plg.category = CATEGORY_TEXT
|
||||||
plg.reportclass = 'AlphabeticalIndex'
|
plg.reportclass = 'AlphabeticalIndex'
|
||||||
plg.optionclass = 'AlphabeticalIndexOptions'
|
plg.optionclass = 'AlphabeticalIndexOptions'
|
||||||
|
Loading…
Reference in New Issue
Block a user