]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/page-turn-page-breaking.cc
Merge with master
[lilypond.git] / lily / page-turn-page-breaking.cc
index c6a1381f3670280cc8349a48f1c521b53da37970..58c66ed09d69b71c1f8c26d939c1c5b87e869130 100644 (file)
@@ -3,7 +3,7 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 2006 Joe Neeman <joeneeman@gmail.com>
+  (c) 2006--2007 Joe Neeman <joeneeman@gmail.com>
 */
 
 #include "page-turn-page-breaking.hh"
@@ -53,7 +53,7 @@ Page_turn_page_breaking::put_systems_on_pages (vsize start,
   /* If [START, END] does not contain an intermediate
      breakpoint, we may need to consider solutions that result in a bad turn.
      In this case, we won't abort if the min_page_count is too big */
-  if (start < end - 1 && min_p_count > 2)
+  if (start < end - 1 && min_p_count + (page_number % 2) > 2)
     return Break_node ();
 
   /* if PAGE-NUMBER is odd, we are starting on a right hand page. That is, we
@@ -115,7 +115,7 @@ vsize
 Page_turn_page_breaking::final_page_num (Break_node const &b)
 {
   vsize end = b.first_page_number_ + b.page_count_;
-  return end + 1 - (end % 2);
+  return end - 1 + (end % 2);
 }
 
 void
@@ -171,7 +171,7 @@ Page_turn_page_breaking::calc_subproblem (vsize ending_breakpoint)
               cur = put_systems_on_pages (start, end, line, div[d], p_num);
 
               if (isinf (cur.demerits_)
-                 || (cur.page_count_ > 2
+                 || (cur.page_count_  + (p_num % 2) > 2
                      && (!isinf (this_start_best.demerits_))
                      && final_page_num (cur) > final_page_num (this_start_best)))
                 {
@@ -202,7 +202,7 @@ Page_turn_page_breaking::calc_subproblem (vsize ending_breakpoint)
       if (start == 0 && end == 1
          && this_start_best.first_page_number_ == 1
          && this_start_best.page_count_ > 1)
-       warning (_ ("couldn't fit the first page turn onto a single page. "
+       warning (_ ("cannot fit the first page turn onto a single page.  "
                    "Consider setting first-page-number to an even number."));
 
       if (this_start_best.demerits_ < best.demerits_)
@@ -217,7 +217,7 @@ Page_turn_page_breaking::solve ()
   state_.clear ();
   message (_f ("Calculating page and line breaks (%d possible page breaks)...",
                (int)breaks_.size () - 1) + " ");
-  for (vsize i = 0; i < breaks_.size () - 1; i++)
+  for (vsize i = 0; i + 1 < breaks_.size (); i++)
     {
       calc_subproblem (i);
       progress_indication (string ("[") + to_string (i + 1) + "]");
@@ -263,7 +263,7 @@ Page_turn_page_breaking::make_pages (vector<Break_node> const &soln, SCM systems
       for (vsize j = 0; j < soln[i].page_count_; j++)
        lines_per_page.push_back (soln[i].system_count_[j]);
 
-      if (i < soln.size () - 1 && (soln[i].first_page_number_ + soln[i].page_count_) % 2)
+      if (i + 1 < soln.size () && (soln[i].first_page_number_ + soln[i].page_count_) % 2)
        /* add a blank page */
        lines_per_page.push_back (0);
     }