5326: Add Alphabetical Index and Table of Contents generation for pdf reports

svn: r18842
This commit is contained in:
Nick Hall
2012-02-10 14:53:58 +00:00
parent 249c5dc46b
commit 3767c1d1e4
25 changed files with 598 additions and 41 deletions

View File

@@ -48,8 +48,9 @@ log = logging.getLogger(".")
#-------------------------------------------------------------------------
import Utils
from gen.plug import BasePluginManager
from gen.plug.docgen import (StyleSheet, StyleSheetList, PaperStyle,
PAPER_PORTRAIT, PAPER_LANDSCAPE, graphdoc)
from gen.plug.docgen import (StyleSheet, StyleSheetList, PaperStyle,
PAPER_PORTRAIT, PAPER_LANDSCAPE, graphdoc,
IndexOptions)
from gen.plug.menu import (FamilyOption, PersonOption, NoteOption,
MediaOption, PersonListOption, NumberOption,
BooleanOption, DestinationOption, StringOption,
@@ -59,6 +60,7 @@ from Errors import ReportError
from gen.plug.report import (CATEGORY_TEXT, CATEGORY_DRAW, CATEGORY_BOOK,
CATEGORY_GRAPHVIZ, CATEGORY_CODE)
from gen.plug.report._paper import paper_sizes
from gen.plug.report.toc_index import add_toc_index_styles
import const
import DbState
from cli.grampscli import CLIManager
@@ -256,6 +258,8 @@ class CommandLineReport(object):
'papermt' : self.option_class.handler.get_margins()[2],
'papermb' : self.option_class.handler.get_margins()[3],
'css' : self.option_class.handler.get_css_filename(),
'toc' : self.option_class.handler.get_toc(),
'index' : self.option_class.handler.get_index(),
}
self.options_help = {
@@ -270,6 +274,10 @@ class CommandLineReport(object):
'papermb' : ["=num", "Bottom paper margin", "Size in cm"],
'css' : ["=css filename", "CSS filename to use, html format"
" only", ""],
'toc' : ["=bool", "Include table of contents.",
["False", "True"]],
'index' : ["=bool", "Include alphabetical index.",
["False", "True"]],
}
if noopt:
@@ -311,6 +319,7 @@ class CommandLineReport(object):
if self.category in (CATEGORY_TEXT, CATEGORY_DRAW):
default_style = StyleSheet()
self.option_class.make_default_style(default_style)
add_toc_index_styles(default_style)
# Read all style sheets available for this item
style_file = self.option_class.handler.get_stylesheet_savefile()
@@ -498,9 +507,13 @@ class CommandLineReport(object):
self.margint = self.options_dict['papermt']
self.marginb = self.options_dict['papermb']
self.toc = self.options_dict['toc']
self.index = self.options_dict['index']
if self.category in (CATEGORY_TEXT, CATEGORY_DRAW):
default_style = StyleSheet()
self.option_class.make_default_style(default_style)
add_toc_index_styles(default_style)
# Read all style sheets available for this item
style_file = self.option_class.handler.get_stylesheet_savefile()
@@ -573,12 +586,14 @@ def cl_report(database, name, category, report_class, options_class,
clr.option_class.handler.doc = clr.format(
clr.selected_style,
PaperStyle(clr.paper,clr.orien,clr.marginl,
clr.marginr,clr.margint,clr.marginb))
clr.marginr,clr.margint,clr.marginb),
IndexOptions(clr.toc, clr.index))
elif category == CATEGORY_GRAPHVIZ:
clr.option_class.handler.doc = clr.format(
clr.option_class,
PaperStyle(clr.paper,clr.orien,clr.marginl,
clr.marginr,clr.margint,clr.marginb))
clr.marginr,clr.margint,clr.marginb),
IndexOptions(clr.toc, clr.index))
if clr.css_filename is not None and \
hasattr(clr.option_class.handler.doc, 'set_css_filename'):
clr.option_class.handler.doc.set_css_filename(clr.css_filename)