#include <stdio.h>
-#include "ly-smobs.icc"
+#include "ly-smobs.icc"
+#include "stencil.hh"
#include "book.hh"
#include "global-context.hh"
#include "ly-module.hh"
#include "main.hh"
#include "music-iterator.hh"
-#include "music-output-def.hh"
+#include "output-def.hh"
#include "music-output.hh"
#include "music.hh"
#include "paper-book.hh"
-#include "paper-def.hh"
+#include "output-def.hh"
#include "score.hh"
#include "warn.hh"
Book::Book ()
: Input ()
{
+ bookpaper_ = 0;
header_ = SCM_EOL;
+ assert (!scores_.size ());
smobify_self ();
}
-#if 0
-Book::Book (Book const &src)
- : Input (src)
-{
- header_ = SCM_EOL;
- smobify_self ();
-
- int score_count = src.scores_.size ();
- for (int i = 0; i < score_count; i++)
- scores_.push (src.scores_[i]->clone ());
-
-#if 0
- header_ = ly_make_anonymous_module ();
- if (is_module (src.header_))
- ly_import_module (header_, src.header_);
-#endif
-}
-#endif
-
Book::~Book ()
{
}
int score_count = book->scores_.size ();
for (int i = 0; i < score_count; i++)
scm_gc_mark (book->scores_[i]->self_scm ());
+
+ if (book->bookpaper_)
+ scm_gc_mark (book->bookpaper_->self_scm ());
return book->header_;
}
return 1;
}
-void
-Book::process (String outname, Music_output_def *default_def, SCM header)
+/*
+ This function does not dump the output; outname is required eg. for
+ dumping header fields.
+ */
+Paper_book *
+Book::process (String outname, Output_def *default_def)
{
Paper_book *paper_book = new Paper_book ();
+ Real scale = ly_scm2double (bookpaper_->c_variable ("outputscale"));
+
+ Output_def * scaled_bookdef = scale_output_def (bookpaper_, scale);
+
+ paper_book->bookpaper_ = scaled_bookdef;
+ scm_gc_unprotect_object (scaled_bookdef->self_scm());
+
+ paper_book->header_ = header_;
+
int score_count = scores_.size ();
for (int i = 0; i < score_count; i++)
{
- Paper_def *paper = 0;
- SCM systems = scores_[i]->book_rendering (outname, default_def, &paper);
+ SCM systems = scores_[i]->book_rendering (outname,
+ paper_book->bookpaper_,
+ default_def);
if (systems != SCM_UNDEFINED)
{
- if (paper)
- paper_book->papers_.push (paper);
- paper_book->scores_.push (systems);
-
- // fixme.
- //paper_book->global_headers_.push (global_input_file->header_);
- //paper_book->headers_.push (scores_[i]->header_);
- paper_book->headers_.push (header);
+ Score_lines sc;
+ sc.lines_ = systems;
+ sc.header_ = header_;
+
+ paper_book->score_lines_.push (sc);
}
}
- paper_book->output (outname);
+
+ return paper_book;
+}
+
+#if 0
+/* FIXME: WIP, this is a hack. Return first page as stencil. */
+SCM
+Book::to_stencil (Output_def *default_def)
+{
+ Paper_book *paper_book = process ("<markup>", default_def);
+
+ SCM pages = paper_book->pages ();
scm_gc_unprotect_object (paper_book->self_scm ());
+
+ if (ly_c_pair_p (pages))
+ {
+ progress_indication (_f ("paper output to `%s'...", "<markup>"));
+ return ly_car (pages);
+ }
+
+ scm_gc_unprotect_object (paper_book->bookpaper_->self_scm ());
+
+ return SCM_EOL;
}
+#endif