- /* add the ending breakpoint */
- if (all_.back ().pscore_)
- breaks_.push_back (Break_position (all_.size () - 1, all_.back ().score_break_count_));
- else
- breaks_.push_back (Break_position (all_.size () - 1));
+void
+Page_breaking::find_chunks_and_breaks (Break_predicate is_break)
+{
+ SCM force_sym = ly_symbol2scm ("force");
+
+ chunks_.push_back (Break_position ());
+ breaks_.push_back (Break_position ());
+
+ for (vsize i = 0; i < all_.size (); i++)
+ {
+ if (all_[i].pscore_)
+ {
+ vector<Grob*> cols = all_[i].pscore_->root_system ()->used_columns ();
+ vector<vsize> line_breaker_columns;
+ line_breaker_columns.push_back (0);
+
+ for (vsize j = 1; j < cols.size (); j++)
+ {
+ bool last = j == cols.size () - 1;
+ bool break_point = is_break (cols[j]);
+ bool chunk_end = cols[j]->get_property ("page-break-permission") == force_sym;
+ Break_position cur_pos = Break_position (i,
+ line_breaker_columns.size (),
+ cols[j],
+ last);
+
+ if (break_point || (i == all_.size () - 1 && last))
+ breaks_.push_back (cur_pos);
+ if (chunk_end || last)
+ chunks_.push_back (cur_pos);
+
+ if ((break_point || chunk_end) && !last)
+ line_breaker_columns.push_back (j);
+ }
+ line_breaking_.push_back (Constrained_breaking (all_[i].pscore_, line_breaker_columns));
+ }
+ else
+ {
+ /* TODO: we want some way of applying Break_p to a prob? */
+ if (i == all_.size () - 1)
+ breaks_.push_back (Break_position (i));
+
+ chunks_.push_back (Break_position (i));
+ line_breaking_.push_back (Constrained_breaking (NULL));
+ }
+ }