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