]> mj.ucw.cz Git - paperjam.git/blobdiff - jam.h
Measure bboxes by Ghostscripting
[paperjam.git] / jam.h
diff --git a/jam.h b/jam.h
index dddaa81fb3e669416b527d44a12fdc0fd73c7c9c..a966cea36d72bce230f9b775284f190ef8ef05eb 100644 (file)
--- a/jam.h
+++ b/jam.h
@@ -31,26 +31,39 @@ struct arg_def {
 class arg_val {
 public:
   virtual bool given() { return false; }
-  int as_int(int def) { return def; }
-  double as_double(double def) { return def; }
-  const string as_string(const string def) { return def; }
+  virtual int as_int(int def) { return def; }
+  virtual double as_double(double def) { return def; }
+  virtual const string as_string(const string def) { return def; }
   virtual string dump() { return "<undef>"; }
 };
 
-struct page_out {
+struct out_context {
   QPDFObjectHandle resources;
   QPDFObjectHandle xobjects;
   string contents;
   int res_cnt;
   string new_resource(const string type);
+  out_context() { res_cnt = 0; }
 };
 
 struct page {
   int index;
-  double width;
+  double width;                // Physical dimensions of media
   double height;
-  virtual void render(page_out *out UNUSED, pdf_matrix xform UNUSED) { abort(); }
+  BBox bbox;           // Bounds useful contents
+  virtual void render(out_context *out UNUSED, pdf_matrix xform UNUSED) { abort(); }
   page(double _w=0, double _h=0) : width(_w), height(_h) { }
+  page(page *p) {
+    index = p->index;
+    width = p->width;
+    height = p->height;
+    bbox = p->bbox;
+  }
+};
+
+struct empty_page : public page {
+  void render(out_context *out UNUSED, pdf_matrix xform UNUSED) { }
+  empty_page(double _w=0, double _h=0) : page(_w, _h) { };
 };
 
 struct cmd_exec {
@@ -85,10 +98,19 @@ struct pipeline {
   vector<pipeline_branch *> branches;
 };
 
+// paperjam.cc
+
+vector<page *> run_command_list(list<cmd *> &cmds, vector<page *> &pages);
+
 // parse.cc
 
 void parse(const char *in, list<cmd *> &cmds);
+void help();
 
 // cmds.cc
 
 extern const cmd_def cmd_table[];
+
+// gs.cc
+
+vector<BBox> gs_bboxes(const char *in);