]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/paper-def.cc
patch::: 1.3.59.uu2.jcn1
[lilypond.git] / lily / paper-def.cc
index 2f60f9e14ce2f65295ed3210c2eedc141a736e2b..c32c88f41565526b8e6d0933edd6360f56f6abc9 100644 (file)
@@ -7,6 +7,7 @@
 */
 
 #include <math.h>
+
 #include "all-font-metrics.hh"
 #include "string.hh"
 #include "misc.hh"
@@ -18,7 +19,6 @@
 #include "identifier.hh"
 #include "main.hh"
 #include "scope.hh"
-#include "dictionary-iter.hh"
 #include "file-results.hh" // urg? header_global_p
 #include "paper-outputter.hh"
 #include "paper-stream.hh"
 
 Paper_def::Paper_def ()
 {
-  lookup_p_tab_p_ = new Hash_table<int, Lookup*>;
-  lookup_p_tab_p_->hash_func_ = int_hash;
+  lookup_p_tab_p_ = new map<int, Lookup*>;
 }
 
 
 Paper_def::~Paper_def ()
 {
-  for (Hash_table_iter<int, Lookup*> ai(*lookup_p_tab_p_); ai.ok (); ai++)
+  for (map<int,Lookup*>::const_iterator ai = lookup_p_tab_p_->begin();
+       ai != lookup_p_tab_p_->end (); ai++)
     {
-      delete ai.val ();
+      delete (*ai).second;
     }
   
   delete lookup_p_tab_p_;
@@ -45,13 +45,13 @@ Paper_def::Paper_def (Paper_def const&s)
   : Music_output_def (s)
 {
   shape_int_a_ = s.shape_int_a_;
-  lookup_p_tab_p_ = new Hash_table<int, Lookup*>;
-  lookup_p_tab_p_->hash_func_ = int_hash;
+  lookup_p_tab_p_ = new map<int, Lookup*>;
   
-  for (Hash_table_iter<int, Lookup*> ai(*s.lookup_p_tab_p_); ai.ok (); ai++)
+  for (map<int,Lookup*>::const_iterator ai = s.lookup_p_tab_p_->begin();
+       ai != s.lookup_p_tab_p_->end (); ai++)
     {
-      Lookup * l = new Lookup (*ai.val ());
-      set_lookup (ai.key(), l);
+      Lookup * l = new Lookup (* (*ai).second);
+      set_lookup ((*ai).first, l);      
     }
 }
 
@@ -77,44 +77,26 @@ Paper_def::get_realvar (SCM s) const
   return *p;
 }
 
-
+/*
+  FIXME. This is broken until we have a generic way of
+  putting lists inside the \paper block.
+ */
 Interval
 Paper_def::line_dimensions_int (int n) const
 {
-  SCM s = default_properties_.get (ly_symbol2scm ("margin-shape"));
-  if (!gh_pair_p (s))
-    {
-      Real lw =  get_var ("linewidth");
-      Real ind = n? 0.0:get_var ("indent");
-
-      return Interval (ind, lw);
-    }
+  Real lw =  get_var ("linewidth");
+  Real ind = n? 0.0:get_var ("indent");
 
-  SCM last = SCM_EOL;
-  while (gh_pair_p (s) && n --)
-    {
-      last = s;
-      s = gh_cdr (s);
-    }
-
-  if (s == SCM_EOL)
-    {
-      s = last;
-    }
-
-  SCM pair = gh_car (s);
-  
-  return Interval (gh_scm2double (gh_car (pair)),
-                  gh_scm2double (gh_cdr (pair)));
+  return Interval (ind, lw);
 }
 
 void
 Paper_def::set_lookup (int i, Lookup*l)
 {
-  if (lookup_p_tab_p_->elem_b (i))
+  map<int,Lookup*> :: const_iterator it (lookup_p_tab_p_->find (i));
+  if (it != lookup_p_tab_p_->end ())
     {
-      delete lookup_p_tab_p_->elem (i);
+      delete (*it).second;
     }
   (*lookup_p_tab_p_)[i] = l;
 }
@@ -139,9 +121,11 @@ Paper_def::print () const
 #ifndef NPRINT
   Music_output_def::print ();
   DEBUG_OUT << "Paper {";
-  for (Hash_table_iter<int, Lookup*> ai(*lookup_p_tab_p_); ai.ok (); ai++)
+  for (map<int,Lookup*>::const_iterator ai = lookup_p_tab_p_->begin();
+       ai != lookup_p_tab_p_->end (); ai++)
     {
-      DEBUG_OUT << "Lookup: " << ai.key () << " = " << ai.val ()->font_name_ << '\n';
+      DEBUG_OUT << "Lookup: " << (*ai).first
+               << " = " << (*ai).second->font_name_ << '\n';
     }
   DEBUG_OUT << "}\n";
 #endif