1
/* imposter (OO.org Impress viewer)
2
** Copyright (C) 2003-2005 Gurer Ozen
3
** This code is free software; you can redistribute it and/or
4
** modify it under the terms of GNU General Public License.
11
// { "draw:text-box", r_text },
12
// { "draw:connector", r_line },
13
// { "draw:polyline", r_polyline },
14
// { "draw:polygon", r_polygon },
15
// { "draw:path", r_path },
18
render_object(ImpRenderCtx *ctx, void *drw_data, iks *node)
24
if (strcmp(tag, "draw:g") == 0) {
26
for (x = iks_first_tag(node); x; x = iks_next_tag(x)) {
27
render_object(ctx, drw_data, x);
29
} else if (strcmp(tag, "draw:line") == 0) {
31
r_get_color(ctx, node, "svg:stroke-color", &fg);
32
ctx->drw->set_fg_color(drw_data, &fg);
33
x1 = r_get_x(ctx, node, "svg:x1");
34
y1 = r_get_y(ctx, node, "svg:y1");
35
x2 = r_get_x(ctx, node, "svg:x2");
36
y2 = r_get_y(ctx, node, "svg:y2");
37
ctx->drw->draw_line(drw_data, x1, y1, x2, y2);
38
if (r_get_style(ctx, node, "draw:marker-start")) {
39
_imp_draw_line_end(ctx, drw_data, 0, 0, x2, y2, x1, y1);
41
if (r_get_style(ctx, node, "draw:marker-end")) {
42
_imp_draw_line_end(ctx, drw_data, 0, 0, x1, y1, x2, y2);
44
} else if (strcmp(tag, "draw:rect") == 0) {
45
int x, y, w, h, r = 0;
47
x = r_get_x(ctx, node, "svg:x");
48
y = r_get_y(ctx, node, "svg:y");
49
w = r_get_x(ctx, node, "svg:width");
50
h = r_get_y(ctx, node, "svg:height");
51
t = r_get_style(ctx, node, "draw:corner-radius");
52
if (t) r = atof(t) * ctx->fact_x;
53
t = r_get_style(ctx, node, "draw:fill");
54
if (t && strcmp(t, "none") != 0) {
55
r_get_color(ctx, node, "draw:fill-color", &fg);
56
ctx->drw->set_fg_color(drw_data, &fg);
57
_imp_draw_rect(ctx, drw_data, 1, x, y, w, h, r);
59
r_get_color(ctx, node, "svg:stroke-color", &fg);
60
ctx->drw->set_fg_color(drw_data, &fg);
61
_imp_draw_rect(ctx, drw_data, 0, x, y, w, h, r);
62
r_text(ctx, drw_data, node);
63
} else if (strcmp(tag, "draw:ellipse") == 0 || strcmp(tag, "draw:circle") == 0) {
65
r_get_color(ctx, node, "svg:stroke-color", &fg);
66
sa = r_get_angle(node, "draw:start-angle", 0);
67
ea = r_get_angle(node, "draw:end-angle", 360);
68
if (ea > sa) ea = ea - sa; else ea = 360 + ea - sa;
69
t = r_get_style(ctx, node, "draw:fill");
71
ctx->drw->set_fg_color(drw_data, &fg);
72
ctx->drw->draw_arc(drw_data,
74
r_get_x(ctx, node, "svg:x"), r_get_y(ctx, node, "svg:y"),
75
r_get_x(ctx, node, "svg:width"), r_get_y(ctx, node, "svg:height"),
78
} else if (strcmp(tag, "draw:polygon") == 0) {
80
r_polygon(ctx, drw_data, node);
81
} else if (strcmp(tag, "draw:text-box") == 0) {
83
r_text(ctx, drw_data, node);
84
} else if (strcmp(tag, "draw:image") == 0) {
87
name = iks_find_attrib(node, "xlink:href");
89
if (name[0] == '#') ++name;
91
_imp_draw_image(ctx, drw_data,
93
r_get_x(ctx, node, "svg:x"),
94
r_get_y(ctx, node, "svg:y"),
95
r_get_x(ctx, node, "svg:width"),
96
r_get_y(ctx, node, "svg:height")
99
printf("Unknown element: %s\n", tag);
104
render_page(ImpRenderCtx *ctx, void *drw_data)
110
i = _imp_fill_back(ctx, drw_data, ctx->page->page);
111
element = iks_find_attrib(ctx->page->page, "draw:master-page-name");
113
x = iks_find_with_attrib(
114
iks_find(ctx->page->doc->styles, "office:master-styles"),
115
"style:master-page", "style:name", element
118
if (i == 0) _imp_fill_back(ctx, drw_data, x);
119
for (x = iks_first_tag(x); x; x = iks_next_tag(x)) {
120
if (iks_find_attrib(x, "presentation:class"))
122
render_object(ctx, drw_data, x);
126
for (x = iks_first_tag(ctx->page->page); x; x = iks_next_tag(x)) {
127
render_object(ctx, drw_data, x);
132
get_geometry(ImpRenderCtx *ctx)
137
tmp = iks_find_attrib(ctx->page->page, "draw:master-page-name");
138
x = iks_find(ctx->page->doc->styles, "office:master-styles");
139
y = iks_find_with_attrib(x, "style:master-page", "style:name", tmp);
140
x = iks_find(ctx->page->doc->styles, "office:automatic-styles");
141
y = iks_find_with_attrib(x, "style:page-master", "style:name",
142
iks_find_attrib(y, "style:page-master-name"));
143
ctx->cm_w = atof(iks_find_attrib(iks_find(y, "style:properties"), "fo:page-width"));
144
ctx->cm_h = atof(iks_find_attrib(iks_find(y, "style:properties"), "fo:page-height"));
148
_imp_oo13_load(ImpDoc *doc)
155
class = iks_find_attrib(doc->content, "office:class");
156
if (iks_strcmp(class, "presentation") != 0) return IMP_NOTIMP;
158
x = iks_find(iks_find(doc->content, "office:body"), "draw:page");
159
if (!x) return IMP_NOTIMP;
161
for (; x; x = iks_next_tag(x)) {
162
if (strcmp(iks_name(x), "draw:page") == 0) {
163
page = iks_stack_alloc(doc->stack, sizeof(ImpPage));
164
if (!page) return IMP_NOMEM;
165
memset(page, 0, sizeof(ImpPage));
168
page->name = iks_find_attrib(x, "draw:name");
170
if (!doc->pages) doc->pages = page;
171
page->prev = doc->last_page;
172
if (doc->last_page) doc->last_page->next = page;
173
doc->last_page = page;
177
doc->get_geometry = get_geometry;
178
doc->render_page = render_page;