~ubuntu-branches/ubuntu/oneiric/evince/oneiric-updates

« back to all changes in this revision

Viewing changes to backend/impress/f_oasis.c

  • Committer: Bazaar Package Importer
  • Author(s): Rodrigo Moya, Josselin Mouette, Rodrigo Moya
  • Date: 2011-05-19 12:12:42 UTC
  • mfrom: (1.1.65 upstream) (1.3.6 experimental)
  • Revision ID: james.westby@ubuntu.com-20110519121242-967hbn2nh2hunp4y
Tags: 3.0.0-4ubuntu1
[ Josselin Mouette ]
* bug-presubj: please document where to report rendering bugs.
* evince.mime: dropped. We have desktop files to handle MIME 
  associations, no need to maintain an alternate system by hand.
  Closes: #619564, #627027, #551734, #581441.

[ Rodrigo Moya ]
* Rebase from Debian and GNOME3 PPA (thanks to Rico Tzschichholz).
  Remaining Ubuntu changes:
* debian/apparmor-profile:
* debian/apparmor-profile.abstraction:
* debian/evince.apport:
* debian/evince-common.dirs:
* debian/evince-common.postinst:
* debian/evince-common.postrm:
  - Add apparmor profile
* debian/control:
  - Build-Depend on debhelper (>= 7.4.20ubuntu5), gnome-common,
    hardening-includes and liblaunchpad-integration-3.0-dev
  - Standards-Version is 3.9.1
  - Depend on apparmor
* debian/rules:
  - Include hardening.make
  - Add rule to install apparmor files
* debian/watch:
  - Watch unstable series
* debian/patches/01_lpi.patch:
  - Launchpad integration patch
* debian/patches/04_gold.patch:
  - Link against libz
* debian/patches/05_library-path.patch:
  - Fix library path for g-ir-scanner

Show diffs side-by-side

added added

removed removed

Lines of Context:
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.
5
 
*/
6
 
 
7
 
#include <config.h>
8
 
#include "common.h"
9
 
#include "internal.h"
10
 
 
11
 
static void
12
 
render_object(ImpRenderCtx *ctx, void *drw_data, iks *node)
13
 
{
14
 
        char *tag, *t;
15
 
        ImpColor fg;
16
 
 
17
 
        tag = iks_name(node);
18
 
        if (strcmp(tag, "draw:g") == 0) {
19
 
                iks *x;
20
 
                for (x = iks_first_tag(node); x; x = iks_next_tag(x)) {
21
 
                        render_object(ctx, drw_data, x);
22
 
                }
23
 
        } else if (strcmp(tag, "draw:frame") == 0) {
24
 
                iks *x;
25
 
                for (x = iks_first_tag(node); x; x = iks_next_tag(x)) {
26
 
                        render_object(ctx, drw_data, x);
27
 
                }
28
 
        } else if (strcmp(tag, "draw:line") == 0) {
29
 
                r_get_color(ctx, node, "svg:stroke-color", &fg);
30
 
                ctx->drw->set_fg_color(drw_data, &fg);
31
 
                ctx->drw->draw_line(drw_data,
32
 
                        r_get_x(ctx, node, "svg:x1"), r_get_y(ctx, node, "svg:y1"),
33
 
                        r_get_x(ctx, node, "svg:x2"), r_get_y(ctx, node, "svg:y2")
34
 
                );
35
 
        } else if (strcmp(tag, "draw:rect") == 0) {
36
 
                int x, y, w, h, r = 0;
37
 
                char *t;
38
 
                x = r_get_x(ctx, node, "svg:x");
39
 
                y = r_get_y(ctx, node, "svg:y");
40
 
                w = r_get_x(ctx, node, "svg:width");
41
 
                h = r_get_y(ctx, node, "svg:height");
42
 
                t = r_get_style(ctx, node, "draw:corner-radius");
43
 
                if (t) r = atof(t) * ctx->fact_x;
44
 
                if (r_get_style(ctx, node, "draw:fill")) {
45
 
                        r_get_color(ctx, node, "draw:fill-color", &fg);
46
 
                        ctx->drw->set_fg_color(drw_data, &fg);
47
 
                        _imp_draw_rect(ctx, drw_data, 1, x, y, w, h, r);
48
 
                }
49
 
                r_get_color(ctx, node, "svg:stroke-color", &fg);
50
 
                ctx->drw->set_fg_color(drw_data, &fg);
51
 
                _imp_draw_rect(ctx, drw_data, 0, x, y, w, h, r);
52
 
                r_text(ctx, drw_data, node);
53
 
        } else if (strcmp(tag, "draw:ellipse") == 0 || strcmp(tag, "draw:circle") == 0) {
54
 
                int sa, ea, fill = 0;
55
 
                r_get_color(ctx, node, "svg:stroke-color", &fg);
56
 
                sa = r_get_angle(node, "draw:start-angle", 0);
57
 
                ea = r_get_angle(node, "draw:end-angle", 360);
58
 
                if (ea > sa) ea = ea - sa; else ea = 360 + ea - sa;
59
 
                t = r_get_style(ctx, node, "draw:fill");
60
 
                if (t) fill = 1;
61
 
                ctx->drw->set_fg_color(drw_data, &fg);
62
 
                ctx->drw->draw_arc(drw_data,
63
 
                        fill,
64
 
                        r_get_x(ctx, node, "svg:x"), r_get_y(ctx, node, "svg:y"),
65
 
                        r_get_x(ctx, node, "svg:width"), r_get_y(ctx, node, "svg:height"),
66
 
                        sa, ea
67
 
                );
68
 
        } else if (strcmp(tag, "draw:polygon") == 0) {
69
 
                // FIXME:
70
 
                r_polygon(ctx, drw_data, node);
71
 
        } else if (strcmp(tag, "draw:text-box") == 0) {
72
 
                // FIXME:
73
 
                r_text(ctx, drw_data, node);
74
 
        } else if (strcmp(tag, "draw:image") == 0) {
75
 
                char *name;
76
 
 
77
 
                name = iks_find_attrib(node, "xlink:href");
78
 
                if (!name) return;
79
 
                if (name[0] == '#') ++name;
80
 
 
81
 
                _imp_draw_image(ctx, drw_data,
82
 
                        name,
83
 
                        r_get_x(ctx, node, "svg:x"),
84
 
                        r_get_y(ctx, node, "svg:y"),
85
 
                        r_get_x(ctx, node, "svg:width"),
86
 
                        r_get_y(ctx, node, "svg:height")
87
 
                );
88
 
        } else {
89
 
                printf("Unknown element: %s\n", tag);
90
 
        }
91
 
}
92
 
 
93
 
static void
94
 
render_page(ImpRenderCtx *ctx, void *drw_data)
95
 
{
96
 
        iks *x;
97
 
        char *element;
98
 
        int i;
99
 
 
100
 
        i = _imp_fill_back(ctx, drw_data, ctx->page->page);
101
 
        element = iks_find_attrib(ctx->page->page, "draw:master-page-name");
102
 
        if (element) {
103
 
                x = iks_find_with_attrib(
104
 
                        iks_find(ctx->page->doc->styles, "office:master-styles"),
105
 
                        "style:master-page", "style:name", element
106
 
                );
107
 
                if (x) {
108
 
                        if (i == 0) _imp_fill_back(ctx, drw_data, x);
109
 
                        for (x = iks_first_tag(x); x; x = iks_next_tag(x)) {
110
 
                                if (iks_find_attrib(x, "presentation:class"))
111
 
                                        continue;
112
 
                                render_object(ctx, drw_data, x);
113
 
                        }
114
 
                }
115
 
        }
116
 
        for (x = iks_first_tag(ctx->page->page); x; x = iks_next_tag(x)) {
117
 
                render_object(ctx, drw_data, x);
118
 
        }
119
 
}
120
 
 
121
 
static void
122
 
get_geometry(ImpRenderCtx *ctx)
123
 
{
124
 
        char *tmp;
125
 
        iks *x, *y;
126
 
 
127
 
        tmp = iks_find_attrib(ctx->page->page, "draw:master-page-name");
128
 
        x = iks_find(ctx->page->doc->styles, "office:master-styles");
129
 
        y = iks_find_with_attrib(x, "style:master-page", "style:name", tmp);
130
 
        x = iks_find(ctx->page->doc->styles, "office:automatic-styles");
131
 
        y = iks_find_with_attrib(x, "style:page-layout", "style:name",
132
 
                iks_find_attrib(y, "style:page-layout-name"));
133
 
        ctx->cm_w = atof(iks_find_attrib(iks_find(y, "style:page-layout-properties"), "fo:page-width"));
134
 
        ctx->cm_h = atof(iks_find_attrib(iks_find(y, "style:page-layout-properties"), "fo:page-height"));
135
 
}
136
 
 
137
 
int
138
 
_imp_oasis_load(ImpDoc *doc)
139
 
{
140
 
        ImpPage *page;
141
 
        iks *x, *pres;
142
 
        int i;
143
 
 
144
 
        pres = iks_find(iks_find(doc->content, "office:body"), "office:presentation");
145
 
        if (!pres) return IMP_NOTIMP;
146
 
 
147
 
        x = iks_find(pres, "draw:page");
148
 
        if (!x) return IMP_NOTIMP;
149
 
        i = 0;
150
 
        for (; x; x = iks_next_tag(x)) {
151
 
                if (strcmp(iks_name(x), "draw:page") == 0) {
152
 
                        page = iks_stack_alloc(doc->stack, sizeof(ImpPage));
153
 
                        if (!page) return IMP_NOMEM;
154
 
                        memset(page, 0, sizeof(ImpPage));
155
 
                        page->page = x;
156
 
                        page->nr = ++i;
157
 
                        page->name = iks_find_attrib(x, "draw:name");
158
 
                        page->doc = doc;
159
 
                        if (!doc->pages) doc->pages = page;
160
 
                        page->prev = doc->last_page;
161
 
                        if (doc->last_page) doc->last_page->next = page;
162
 
                        doc->last_page = page;
163
 
                }
164
 
        }
165
 
        doc->nr_pages = i;
166
 
        doc->get_geometry = get_geometry;
167
 
        doc->render_page = render_page;
168
 
 
169
 
        return 0;
170
 
}