]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/paper-book.cc
remove PDF related files
[lilypond.git] / lily / paper-book.cc
index d2227ed86c17ef0de6418c8360132a06c1ca8d0f..c2b4b34fdc661e25274e33a8fb84f8dae2fb1d54 100644 (file)
@@ -3,15 +3,13 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 2004 Jan Nieuwenhuizen <janneke@gnu.org>
+  (c) 2004--2005 Jan Nieuwenhuizen <janneke@gnu.org>
 */
 
 #include "paper-book.hh"
 
-#include "ly-module.hh"
 #include "main.hh"
 #include "output-def.hh"
-#include "paper-outputter.hh"
 #include "paper-score.hh"
 #include "paper-system.hh"
 #include "warn.hh"
@@ -58,35 +56,10 @@ Paper_book::print_smob (SCM smob, SCM port, scm_print_state*)
   scm_puts ("#<", port);
   scm_puts (classname (b), port);
   scm_puts (" ", port);
-  //scm_puts (b->, port);
   scm_puts (">", port);
   return 1;
 }
 
-Array<String>
-split_string (String s, char c)
-{
-  Array<String> rv; 
-  while (s.length ())
-    {
-      int i = s.index (c);
-      
-      if (i == 0)
-       {
-         s = s.nomid_string (0, 1);
-         continue;
-       }
-      
-      if (i < 0)
-       i = s.length () ;
-
-      rv.push (s.cut_string (0, i));
-      s = s.nomid_string (0, i);
-    }
-
-  return rv;
-}
-
 SCM
 dump_fields ()
 {
@@ -98,53 +71,6 @@ dump_fields ()
   return fields;
 }
 
-LY_DEFINE (ly_output_formats, "ly:output-formats",
-          0, 0, 0, (),
-          "Formats passed to --format as a list of strings, "
-          "used for the output.")
-{
-  Array<String> output_formats = split_string (output_format_global, ',');
-
-  SCM lst = SCM_EOL;
-  int output_formats_count = output_formats.size ();
-  for (int i = 0; i < output_formats_count; i ++)
-    lst = scm_cons (scm_makfrom0str (output_formats[i].to_str0 ()), lst);
-  
-  return lst; 
-}
-
-void
-Paper_book::post_processing (SCM module,
-                            SCM file_name)
-{
-  struct
-  {
-    bool do_it_;
-    char const *func_name_;
-  } settings[] = {
-    {make_tex, "convert-to-tex"},
-    {make_dvi, "convert-to-dvi"},
-    {make_ps, "convert-to-ps"},
-    {make_pdf, "convert-to-pdf"},
-    {make_png, "convert-to-png"},
-    {0, 0},
-  };
-
-  for (int i = 0; settings[i].func_name_; i++)
-    {
-      if (settings[i].do_it_)
-       {
-         SCM func = scm_c_module_lookup (module, settings[i].func_name_);
-         if (scm_variable_p (func) == SCM_BOOL_T)
-           {
-             func = scm_variable_ref (func);
-             if (ly_c_procedure_p (func))
-               scm_call_2 (func, self_scm (), file_name);
-           }
-       }
-    }
-}
-
 void
 Paper_book::output (String outname)
 {
@@ -154,59 +80,34 @@ Paper_book::output (String outname)
   /* Generate all stencils to trigger font loads.  */
   pages ();
   
-  SCM formats = ly_output_formats ();
-  for (SCM s = formats; scm_is_pair (s); s = scm_cdr (s)) 
-    {
-      String format = ly_scm2string (scm_car (s));
-      String file_name = outname;
-      
-      if (file_name != "-")
-       file_name += "." + format;
-      
-      Paper_outputter *out = get_paper_outputter (file_name, format);
-  
-      SCM scopes = SCM_EOL;
-      if (ly_c_module_p (header_))
-       scopes = scm_cons (header_, scopes);
+  SCM scopes = SCM_EOL;
+  if (ly_c_module_p (header_))
+    scopes = scm_cons (header_, scopes);
   
-      String mod_nm = "scm framework-" + format;
+  String mod_nm = "scm framework-" + output_backend_global;
 
-      SCM mod = scm_c_resolve_module (mod_nm.to_str0 ());
-      if (make_pages)
-       {
-         SCM func = scm_c_module_lookup (mod, "output-framework");
-
-         func = scm_variable_ref (func);
-         scm_apply_0 (func, scm_list_n (out->self_scm (),
-                                        self_scm (),
-                                        scopes,
-                                        dump_fields (),
-                                        scm_makfrom0str (outname.to_str0 ()),
-                                        SCM_UNDEFINED));
-         out->close ();
-         scm_gc_unprotect_object (out->self_scm ());
-         post_processing (mod, scm_makfrom0str (file_name.to_str0 ()));
-       }
+  SCM mod = scm_c_resolve_module (mod_nm.to_str0 ());
+  if (make_pages)
+    {
+      SCM func = scm_c_module_lookup (mod, "output-framework");
+
+      func = scm_variable_ref (func);
+      scm_apply_0 (func, scm_list_n (scm_makfrom0str (outname.to_str0 ()),
+                                    self_scm (),
+                                    scopes,
+                                    dump_fields (),
+                                    SCM_UNDEFINED));
+    }
       
-      if (make_preview)
-       {
-         String file_name = outname + ".preview." + format;
-         Paper_outputter *out = get_paper_outputter (file_name, format);
-  
-         SCM func = scm_c_module_lookup (mod, "output-preview-framework");
-         func = scm_variable_ref (func);
-         scm_apply_0 (func, scm_list_n (out->self_scm (),
-                                        self_scm (),
-                                        scopes,
-                                        dump_fields (),
-                                        scm_makfrom0str (outname.to_str0 ()),
-                                        SCM_UNDEFINED));
-
-         out->close ();
-         scm_gc_unprotect_object (out->self_scm ());
-
-         post_processing (mod, scm_makfrom0str (file_name.to_str0 ()));
-       }
+  if (make_preview)
+    {
+      SCM func = scm_c_module_lookup (mod, "output-preview-framework");
+      func = scm_variable_ref (func);
+      scm_apply_0 (func, scm_list_n (scm_makfrom0str (outname.to_str0 ()),
+                                    self_scm (),
+                                    scopes,
+                                    dump_fields (),
+                                    SCM_UNDEFINED));
     }
   progress_indication ("\n");
 }
@@ -226,65 +127,23 @@ Paper_book::classic_output (String outname)
     scopes = scm_cons (score_systems_[0].header_, scopes);
   //end ugh
 
-  Array<String> output_formats = split_string (output_format_global, ',');
-
-  for (int i = 0; i < output_formats.size (); i++)
-    {
-      String format = output_formats[i];
-      String mod_nm = "scm framework-" + format;
-      
-      SCM mod = scm_c_resolve_module (mod_nm.to_str0 ());
-      SCM func = scm_c_module_lookup (mod, "output-classic-framework");
-
-      func = scm_variable_ref (func);
+  String format = output_backend_global;
+  String mod_nm = "scm framework-" + format;
       
-      Paper_outputter *out = get_paper_outputter (outname + "." + format,
-                                                 format);
-
-      scm_apply_0 (func, scm_list_n (out->self_scm (), self_scm (), scopes,
-                                    dump_fields (),
-                                    scm_makfrom0str (outname.to_str0 ()),
-                                    SCM_UNDEFINED));
-
-      scm_gc_unprotect_object (out->self_scm ());
-      progress_indication ("\n");
-    }
-}
-
-LY_DEFINE (ly_paper_book_pages, "ly:paper-book-pages",
-         1, 0, 0, (SCM pb),
-         "Return pages in book PB.")
-{
-  return unsmob_paper_book(pb)->pages ();
-}
+  SCM mod = scm_c_resolve_module (mod_nm.to_str0 ());
+  SCM func = scm_c_module_lookup (mod, "output-classic-framework");
 
-LY_DEFINE (ly_paper_book_scopes, "ly:paper-book-scopes",
-         1, 0, 0, (SCM book),
-         "Return pages in layout book @var{book}.")
-{
-  Paper_book *pb = unsmob_paper_book(book);
-  SCM_ASSERT_TYPE(pb, book, SCM_ARG1, __FUNCTION__, "Paper_book");
-  
-  SCM scopes = SCM_EOL;
-  if (ly_c_module_p (pb->header_))
-    scopes = scm_cons (pb->header_, scopes);
-  
-  return scopes;
-}
+  func = scm_variable_ref (func);
+  scm_apply_0 (func, scm_list_n (scm_makfrom0str (outname.to_str0 ()),
+                                self_scm (),
+                                scopes,
+                                dump_fields (),
+                                SCM_UNDEFINED));
 
-LY_DEFINE (ly_paper_book_systems, "ly:paper-book-systems",
-          1, 0, 0, (SCM pb),
-          "Return systems in book PB.")
-{
-  return unsmob_paper_book (pb)->systems ();
+  progress_indication ("\n");
 }
 
-LY_DEFINE (ly_paper_book_paper, "ly:paper-book-paper",
-         1, 0, 0, (SCM pb),
-         "Return pages in book PB.")
-{
-  return unsmob_paper_book (pb)->paper_->self_scm ();
-}
 
 /* TODO: resurrect more complex user-tweaks for titling?  */
 Stencil
@@ -343,7 +202,23 @@ Paper_book::score_title (int i)
   
   return title;
 }
-  
+
+void
+set_system_penalty (Paper_system * ps, SCM header)
+{
+  if (ly_c_module_p (header))
+    {
+      SCM force = ly_module_lookup (header, ly_symbol2scm ("breakbefore"));
+      if (SCM_VARIABLEP(force)
+         && scm_is_bool (SCM_VARIABLE_REF(force)))
+       {
+         ps->break_before_penalty_ = to_boolean (SCM_VARIABLE_REF(force))
+           ? -10000
+           : 10000;
+       }
+    }
+}
+           
 SCM
 Paper_book::systems ()
 {
@@ -356,6 +231,8 @@ Paper_book::systems ()
   if (!title.is_empty ())
     {
       Paper_system *ps = new Paper_system (title, true);
+      set_system_penalty (ps, header_);
+      
       systems_ = scm_cons (ps->self_scm (), systems_);
       scm_gc_unprotect_object (ps->self_scm ());
     }
@@ -369,6 +246,9 @@ Paper_book::systems ()
          Paper_system *ps = new Paper_system (title, true);
          systems_ = scm_cons (ps->self_scm (), systems_);
          scm_gc_unprotect_object (ps->self_scm ());
+
+         set_system_penalty (ps, score_systems_[i].header_);
+         
        }
       
       if (scm_vector_p (score_systems_[i].systems_) == SCM_BOOL_T)
@@ -390,9 +270,10 @@ Paper_book::systems ()
       Paper_system *ps = unsmob_paper_system (scm_car (s));
       ps->number_ = ++i;
 
-      if (last && last->is_title ())
-       // ugh, hardcoded.      
-       ps->penalty_ = 10000;
+      if (last
+         && last->is_title ()
+         && !ps->break_before_penalty_)
+       ps->break_before_penalty_ = 10000;
       last = ps;
     }