+void
+Book::process_bookparts (Paper_book *output_paper_book, Output_def *paper, Output_def *layout)
+{
+ add_scores_to_bookpart ();
+ for (SCM p = scm_reverse (bookparts_); scm_is_pair (p); p = scm_cdr (p))
+ {
+ if (Book *book = unsmob<Book> (scm_car (p)))
+ {
+ Paper_book *paper_book_part = book->process (paper, layout, output_paper_book);
+ if (paper_book_part)
+ {
+ output_paper_book->add_bookpart (paper_book_part->self_scm ());
+ paper_book_part->unprotect ();
+ }
+ }
+ }
+ /* In a Paper_book, bookparts are stored in straight order */
+ output_paper_book->bookparts_ = scm_reverse_x (output_paper_book->bookparts_, SCM_EOL);
+}
+
+void
+Book::process_score (SCM s, Paper_book *output_paper_book, Output_def *layout)
+{
+ if (Score *score = unsmob<Score> (scm_car (s)))
+ {
+ SCM outputs = score
+ ->book_rendering (output_paper_book->paper_, layout);
+
+ while (scm_is_pair (outputs))
+ {
+ Music_output *output = unsmob<Music_output> (scm_car (outputs));
+
+ if (Performance *perf = dynamic_cast<Performance *> (output))
+ {
+ output_paper_book->add_performance (perf->self_scm ());
+ // Associate the performance with a \header block (if there is
+ // one in effect in the scope of the current score), to make the
+ // header metadata accessible when outputting the performance.
+ if (ly_is_module (score->get_header ()))
+ perf->set_header (score->get_header ());
+ else if (ly_is_module (output_paper_book->header_))
+ perf->set_header (output_paper_book->header_);
+ else if (ly_is_module (output_paper_book->header_0_))
+ perf->set_header (output_paper_book->header_0_);
+ }
+ else if (Paper_score *pscore = dynamic_cast<Paper_score *> (output))
+ {
+ if (ly_is_module (score->get_header ()))
+ output_paper_book->add_score (score->get_header ());
+ output_paper_book->add_score (pscore->self_scm ());
+ }
+
+ outputs = scm_cdr (outputs);
+ }
+ }
+ else if (Text_interface::is_markup_list (scm_car (s))
+ || unsmob<Page_marker> (scm_car (s)))
+ output_paper_book->add_score (scm_car (s));
+ else
+ assert (0);
+
+}
+