int first_page_number
= robust_scm2int (book_->paper_->c_variable ("first-page-number"), 1);
SCM ret = SCM_EOL;
+ SCM label_page_table = SCM_EOL;
for (vsize i = 0; i < lines_per_page.size (); i++)
{
scm_list_n (book, lines, page_num,
rag, last, SCM_UNDEFINED));
+ /* collect labels */
+ for (SCM l = lines ; scm_is_pair (l) ; l = scm_cdr (l))
+ {
+ SCM labels = SCM_EOL;
+ if (Grob * line = unsmob_grob (scm_car (l)))
+ {
+ System *system = dynamic_cast<System*> (line);
+ labels = system->get_property ("labels");
+ }
+ else if (Prob *prob = unsmob_prob (scm_car (l)))
+ labels = prob->get_property ("labels");
+
+ for (SCM lbls = labels ; scm_is_pair (lbls) ; lbls = scm_cdr (lbls))
+ label_page_table = scm_cons (scm_cons (scm_car (lbls), page_num),
+ label_page_table);
+ }
+
scm_apply_1 (page_stencil, page, SCM_EOL);
ret = scm_cons (page, ret);
systems = scm_list_tail (systems, line_count);
}
+ book_->paper_->set_variable (ly_symbol2scm ("label-page-table"), label_page_table);
ret = scm_reverse (ret);
return ret;
}
Page_spacing_result n_res;
Page_spacing_result m_res;
- if (n <= 2)
+ cache_line_details (configuration);
+ vsize min_p_count = min_page_count (configuration, first_page_num);
+
+ if (n == 1)
{
- n_res = space_systems_on_n_pages (configuration, n, first_page_num);
- m_res = space_systems_on_n_pages (configuration, n+1, first_page_num);
+ bool rag = ragged () || (is_last () && ragged_last ());
+ Real height = page_height (first_page_num, is_last ());
+
+ if (1 >= min_p_count)
+ n_res = space_systems_on_1_page (cached_line_details_, height, rag);
+ if (1 < cached_line_details_.size ())
+ m_res = space_systems_on_2_pages (configuration, first_page_num);
}
else
{
- cache_line_details (configuration);
-
- vsize min_p_count = min_page_count (configuration, first_page_num);
Page_spacer ps (cached_line_details_, first_page_num, this);
+
if (n >= min_p_count)
n_res = ps.solve (n);
if (n < cached_line_details_.size ())
m_res = ps.solve (n+1);
}
+ m_res = finalize_spacing_result (configuration, m_res);
+ n_res = finalize_spacing_result (configuration, n_res);
+
Real penalty = blank_page_penalty ();
n_res.demerits_ += penalty;
n_res.force_.back () += penalty;
- if (m_res.demerits_ < n_res.demerits_)
- return m_res;
- return n_res;
+ return (m_res.demerits_ < n_res.demerits_) ? m_res : n_res;
}
Page_spacing_result