From 47b1b251bcd3e760e1e28dd6103222d7d8c52238 Mon Sep 17 00:00:00 2001 From: Paul Franklin Date: Sun, 13 Jan 2013 01:07:19 +0000 Subject: [PATCH] 6229: bug when creating a book reports svn: r21090 --- gramps/cli/plug/__init__.py | 9 +++++++++ gramps/gen/plug/report/_book.py | 6 +++--- gramps/gui/plug/report/_bookdialog.py | 10 ++++++++++ 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/gramps/cli/plug/__init__.py b/gramps/cli/plug/__init__.py index ae5fc5cb0..663120254 100644 --- a/gramps/cli/plug/__init__.py +++ b/gramps/cli/plug/__init__.py @@ -726,6 +726,7 @@ def cl_book(database, name, book, options_str_dict): clr.marginr, clr.margint, clr.marginb)) user = User() rptlist = [] + global_style = None for item in book.get_item_list(): # The option values were loaded magically by the book parser. @@ -743,6 +744,12 @@ def cl_book(database, name, book, options_str_dict): report_class, item.option_class, user) style_sheet = create_style_sheet(item) rptlist.append((obj, style_sheet)) + if ( item.name == 'table_of_contents' or + item.name == 'alphabetical_index' ): # ugly hack: FIXME + if global_style is None: + global_style = style_sheet + else: + global_style = create_style_sheet(item, global_style) doc.open(clr.option_class.get_output()) doc.init() @@ -754,6 +761,8 @@ def cl_book(database, name, book, options_str_dict): newpage = 1 rpt.begin_report() rpt.write_report() + if global_style: + doc.set_style_sheet(global_style) doc.close() #------------------------------------------------------------------------ diff --git a/gramps/gen/plug/report/_book.py b/gramps/gen/plug/report/_book.py index 74620eca2..fa137aaa5 100644 --- a/gramps/gen/plug/report/_book.py +++ b/gramps/gen/plug/report/_book.py @@ -448,11 +448,11 @@ class BookParser(handler.ContentHandler): # Functions # #------------------------------------------------------------------------- -def create_style_sheet(item): +def create_style_sheet(item, previous_style=None): """ - Create a style sheet for a book item. + Create a style sheet for a book item, appending any previous_style. """ - selected_style = StyleSheet() + selected_style = StyleSheet(previous_style) handler = item.option_class.handler diff --git a/gramps/gui/plug/report/_bookdialog.py b/gramps/gui/plug/report/_bookdialog.py index 9fa75c8cb..a1134c709 100644 --- a/gramps/gui/plug/report/_bookdialog.py +++ b/gramps/gui/plug/report/_bookdialog.py @@ -892,6 +892,7 @@ class BookDialog(DocReportDialog): self.doc = self.format(None, pstyle) user = User() self.rptlist = [] + self.global_style = None for item in self.book.get_item_list(): item.option_class.set_document(self.doc) report_class = item.get_write_item() @@ -899,6 +900,13 @@ class BookDialog(DocReportDialog): item.option_class, user) style_sheet = create_style_sheet(item) self.rptlist.append((obj, style_sheet)) + if ( item.name == 'table_of_contents' or + item.name == 'alphabetical_index' ): # ugly hack: FIXME + if self.global_style is None: + self.global_style = style_sheet + else: + self.global_style = create_style_sheet(item, + self.global_style) self.doc.open(self.target_path) def make_book(self): @@ -915,6 +923,8 @@ class BookDialog(DocReportDialog): if rpt: rpt.begin_report() rpt.write_report() + if self.global_style: + self.doc.set_style_sheet(self.global_style) self.doc.close() if self.open_with_app.get_active():