- for (int i=1; i < break_points.size(); i++)
- {
- Breaking_information info;
- info.bounds_[LEFT] = break_points[i-1];
- info.bounds_[RIGHT] = break_points[i];
- Direction d = LEFT;
- do
- {
- Item *&pc_l = info.bounds_[d] ;
- if (!pc_l->line_l())
- pc_l = pc_l->find_prebroken_piece(- d);
-
- assert (pc_l);
- if (!info.line_l_)
- info.line_l_ = pc_l-> line_l ();
- else
- assert( info.line_l_ = pc_l->line_l ());
-
- }
- while ((flip(&d))!= LEFT);
- info.broken_spanner_l_ = 0;
- broken_info_.push (info);
+ Slice parent_rank_slice;
+ parent_rank_slice.set_full ();
+
+ /*
+ Check if our parent in X-direction spans equally wide
+ or wider than we do.
+ */
+ for (int a = X_AXIS; a < NO_AXES; a++)
+ {
+ if (Spanner *parent = dynamic_cast<Spanner *> (get_parent ((Axis)a)))
+ parent_rank_slice.intersect (parent->spanned_rank_interval ());
+ }
+
+ for (vsize i = 1; i < break_points.size (); i++)
+ {
+ Drul_array<Item *> bounds;
+ bounds[LEFT] = break_points[i - 1];
+ bounds[RIGHT] = break_points[i];
+ for (LEFT_and_RIGHT (d))
+ {
+ if (!bounds[d]->get_system ())
+ bounds[d] = bounds[d]->find_prebroken_piece (- d);
+ }
+
+ if (!bounds[LEFT] || ! bounds[RIGHT])
+ {
+ programming_error ("bounds of this piece aren't breakable.");
+ continue;
+ }
+
+ bool ok = parent_rank_slice.contains (bounds[LEFT]->get_column ()->get_rank ());
+ ok = ok && parent_rank_slice.contains (bounds[RIGHT]->get_column ()->get_rank ());
+
+ if (!ok)
+ {
+ programming_error (to_string ("Spanner `%s' is not fully contained in parent spanner."
+ " Ignoring orphaned part",
+ name ().c_str ()));
+ continue;
+ }
+
+ Spanner *span = dynamic_cast<Spanner *> (clone ());
+ span->set_bound (LEFT, bounds[LEFT]);
+ span->set_bound (RIGHT, bounds[RIGHT]);
+
+ if (!bounds[LEFT]->get_system ()
+ || !bounds[RIGHT]->get_system ()
+ || bounds[LEFT]->get_system () != bounds[RIGHT]->get_system ())
+ {
+ programming_error ("bounds of spanner are invalid");
+ span->suicide ();
+ }
+ else
+ {
+ bounds[LEFT]->get_system ()->typeset_grob (span);
+ broken_intos_.push_back (span);
+ }
+ }