]> www.fi.muni.cz Git - evince.git/blob - backend/impress/r_style.c
39ee9c6203fdb7eed472073ea1e1b2c60107033a
[evince.git] / backend / impress / r_style.c
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 char *
12 get_style(ImpRenderCtx *ctx, iks *node, char *style, char *attr)
13 {
14         char *ret;
15         iks *x;
16
17         if (!style) return NULL;
18
19         if (iks_root (node) == ctx->content) {
20                 x = iks_find_with_attrib (iks_find (ctx->content, "office:automatic-styles"),
21                         "style:style", "style:name", style);
22         } else {
23                 x = iks_find_with_attrib (iks_find (ctx->styles, "office:automatic-styles"),
24                         "style:style", "style:name", style);
25         }
26         if (!x) return NULL;
27
28         while (x) {
29                 ret = iks_find_attrib (iks_find (x, "style:properties"), attr);
30                 if (ret) return ret;
31                 ret = iks_find_attrib (iks_find (x, "style:text-properties"), attr);
32                 if (ret) return ret;
33                 ret = iks_find_attrib (iks_find (x, "style:paragraph-properties"), attr);
34                 if (ret) return ret;
35                 ret = iks_find_attrib (iks_find (x, "style:graphic-properties"), attr);
36                 if (ret) return ret;
37                 ret = iks_find_attrib (iks_find (x, "style:drawing-page-properties"), attr);
38                 if (ret) return ret;
39
40                 style = iks_find_attrib (x, "style:parent-style-name");
41                 if (!style) return NULL;
42
43                 x = iks_find_with_attrib (iks_find (ctx->styles, "office:styles"),
44                         "style:style", "style:name", style);
45
46         }
47         return NULL;
48 }
49
50 char *
51 r_get_style (ImpRenderCtx *ctx, iks *node, char *attr)
52 {
53         char *ret, *s;
54         iks *x;
55
56         ret = iks_find_attrib (node, attr);
57         if (ret) return ret;
58
59         for (x = node; x; x = iks_parent (x)) {
60                 s = iks_find_attrib (x, "text:style-name");
61                 ret = get_style (ctx, node, s, attr);
62                 if (ret) return ret;
63                 s = iks_find_attrib (x, "presentation:style-name");
64                 ret = get_style (ctx, node, s, attr);
65                 if (ret) return ret;
66                 s = iks_find_attrib (x, "draw:style-name");
67                 ret = get_style (ctx, node, s, attr);
68                 if (ret) return ret;
69         }
70         return NULL;
71 }
72
73 #if 0
74 static iks *
75 get_style_x (ImpRenderCtx *ctx, iks *node, char *style, char *attr)
76 {
77         iks *x;
78
79         if (!style) return NULL;
80
81         if (iks_root (node) == ctx->content) {
82                 x = iks_find_with_attrib (iks_find (ctx->content, "office:automatic-styles"),
83                         "text:list-style", "style:name", style);
84         } else {
85                 x = iks_find_with_attrib (iks_find (ctx->styles, "office:automatic-styles"),
86                         "text:list-style", "style:name", style);
87         }
88         return x;
89 }
90
91 static iks *
92 r_get_bullet (ImpRenderCtx *ctx, iks *node, char *attr)
93 {
94         iks *ret;
95         char *s;
96         iks *x;
97
98         for (x = node; x; x = iks_parent (x)) {
99                 s = iks_find_attrib (x, "text:style-name");
100                 ret = get_style_x (ctx, node, s, attr);
101                 if (ret) return ret;
102                 s = iks_find_attrib (x, "presentation:style-name");
103                 ret = get_style_x (ctx, node, s, attr);
104                 if (ret) return ret;
105                 s = iks_find_attrib (x, "draw:style-name");
106                 ret = get_style_x (ctx, node, s, attr);
107                 if (ret) return ret;
108         }
109         return NULL;
110 }
111 #endif