6229: bug when creating a book reports

svn: r21090
This commit is contained in:
Paul Franklin 2013-01-13 01:07:19 +00:00
parent ce373e3036
commit 6cfffee22d
3 changed files with 22 additions and 3 deletions

View File

@ -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()
#------------------------------------------------------------------------

View File

@ -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

View File

@ -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():