9 class null_cmd : public cmd_exec {
10 vector<page *> process(vector<page *> &pages) { return pages; }
13 static const arg_def null_args[] = {
17 static cmd_exec *null_ctor(cmd *c UNUSED)
24 class move_cmd : public cmd_exec {
27 vector<page *> process(vector<page *> &pages);
30 class xform_page : public page {
34 void render(page_out *out, pdf_matrix xform);
35 xform_page(page *_orig, double _w, double _h) : page(_w, _h), orig_page(_orig) { }
38 void xform_page::render(page_out *out, pdf_matrix parent_xform)
40 orig_page->render(out, xform * parent_xform);
43 vector<page *> move_cmd::process(vector<page *> &pages)
48 xform_page *q = new xform_page(p, p->width, p->height);
55 static const arg_def move_args[] = {
56 { "x", AT_DIMEN | AT_MANDATORY | AT_POSITIONAL },
57 { "y", AT_DIMEN | AT_MANDATORY | AT_POSITIONAL },
61 static cmd_exec *move_ctor(cmd *c)
63 move_cmd *m = new move_cmd;
64 m->x = c->args.at(0)->as_double(0);
65 m->y = c->args.at(1)->as_double(0);
71 class scale_cmd : public cmd_exec {
73 double x_factor, y_factor;
74 vector<page *> process(vector<page *> &pages);
77 vector<page *> scale_cmd::process(vector<page *> &pages)
82 xform_page *q = new xform_page(p, x_factor*p->width, y_factor*p->height);
83 q->xform.scale(x_factor, y_factor);
89 static const arg_def scale_args[] = {
90 { "x", AT_DOUBLE | AT_MANDATORY | AT_POSITIONAL },
91 { "y", AT_DOUBLE | AT_POSITIONAL },
95 static cmd_exec *scale_ctor(cmd *c)
97 scale_cmd *s = new scale_cmd;
98 s->x_factor = c->args.at(0)->as_double(1);
99 s->y_factor = c->args.at(1)->as_double(s->x_factor);
105 class rotate_cmd : public cmd_exec {
108 vector<page *> process(vector<page *> &pages);
111 vector<page *> rotate_cmd::process(vector<page *> &pages)
116 xform_page *q = new xform_page(p, p->width, p->height);
117 // FIXME: This does not work yet
118 q->xform.rotate_deg(90);
124 static const arg_def rotate_args[] = {
125 { "angle", AT_INT | AT_MANDATORY | AT_POSITIONAL },
129 static cmd_exec *rotate_ctor(cmd *c)
131 rotate_cmd *r = new rotate_cmd;
132 r->deg = c->args.at(0)->as_int(0);
136 /*** Command table ***/
138 const cmd_def cmd_table[] = {
139 { "move", move_args, 0, move_ctor },
140 { "scale", scale_args, 0, scale_ctor },
141 { "rotate", rotate_args, 0, rotate_ctor },
142 { "null", null_args, 0, null_ctor },
143 { NULL, NULL, 0, NULL }