]> git.donarmstrong.com Git - lilypond.git/blob - lily/minimal-page-breaking.cc
1f4cb4d686cbb92d9d8142aba3a588dea7791d90
[lilypond.git] / lily / minimal-page-breaking.cc
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 2007--2010 Nicolas Sceaux <nicolas.sceaux@free.fr>
5
6   LilyPond is free software: you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation, either version 3 of the License, or
9   (at your option) any later version.
10
11   LilyPond is distributed in the hope that it will be useful,
12   but WITHOUT ANY WARRANTY; without even the implied warranty of
13   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   GNU General Public License for more details.
15
16   You should have received a copy of the GNU General Public License
17   along with LilyPond.  If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #include "international.hh"
21 #include "minimal-page-breaking.hh"
22 #include "output-def.hh"
23 #include "page-spacing.hh"
24 #include "paper-book.hh"
25
26 static bool
27 is_break (Grob *)
28 {
29   return false;
30 }
31
32 Minimal_page_breaking::Minimal_page_breaking (Paper_book *pb)
33   : Page_breaking (pb, is_break)
34 {
35 }
36
37 Minimal_page_breaking::~Minimal_page_breaking ()
38 {
39 }
40
41 SCM
42 Minimal_page_breaking::solve ()
43 {
44   vsize end = last_break_position ();
45
46   message (_ ("Calculating line breaks..."));
47   set_to_ideal_line_configuration (0, end);
48   break_into_pieces (0, end, current_configuration (0));
49
50   message (_ ("Calculating page breaks..."));
51   vsize first_page_num = robust_scm2int (book_->paper_->c_variable ("first-page-number"), 1);
52   Page_spacing_result res = pack_systems_on_least_pages (0, first_page_num);
53   SCM lines = systems ();
54   return make_pages (res.systems_per_page_, lines);
55 }