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 73b26752b0
commit 47b1b251bc
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)) clr.marginr, clr.margint, clr.marginb))
user = User() user = User()
rptlist = [] rptlist = []
global_style = None
for item in book.get_item_list(): for item in book.get_item_list():
# The option values were loaded magically by the book parser. # 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) report_class, item.option_class, user)
style_sheet = create_style_sheet(item) style_sheet = create_style_sheet(item)
rptlist.append((obj, style_sheet)) 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.open(clr.option_class.get_output())
doc.init() doc.init()
@ -754,6 +761,8 @@ def cl_book(database, name, book, options_str_dict):
newpage = 1 newpage = 1
rpt.begin_report() rpt.begin_report()
rpt.write_report() rpt.write_report()
if global_style:
doc.set_style_sheet(global_style)
doc.close() doc.close()
#------------------------------------------------------------------------ #------------------------------------------------------------------------

View File

@ -448,11 +448,11 @@ class BookParser(handler.ContentHandler):
# Functions # 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 handler = item.option_class.handler

View File

@ -892,6 +892,7 @@ class BookDialog(DocReportDialog):
self.doc = self.format(None, pstyle) self.doc = self.format(None, pstyle)
user = User() user = User()
self.rptlist = [] self.rptlist = []
self.global_style = None
for item in self.book.get_item_list(): for item in self.book.get_item_list():
item.option_class.set_document(self.doc) item.option_class.set_document(self.doc)
report_class = item.get_write_item() report_class = item.get_write_item()
@ -899,6 +900,13 @@ class BookDialog(DocReportDialog):
item.option_class, user) item.option_class, user)
style_sheet = create_style_sheet(item) style_sheet = create_style_sheet(item)
self.rptlist.append((obj, style_sheet)) 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) self.doc.open(self.target_path)
def make_book(self): def make_book(self):
@ -915,6 +923,8 @@ class BookDialog(DocReportDialog):
if rpt: if rpt:
rpt.begin_report() rpt.begin_report()
rpt.write_report() rpt.write_report()
if self.global_style:
self.doc.set_style_sheet(self.global_style)
self.doc.close() self.doc.close()
if self.open_with_app.get_active(): if self.open_with_app.get_active():