diff options
-rw-r--r-- | src/render.c | 30 | ||||
-rw-r--r-- | src/stylesheet.c | 19 |
2 files changed, 29 insertions, 20 deletions
diff --git a/src/render.c b/src/render.c index 4199863..03125a1 100644 --- a/src/render.c +++ b/src/render.c @@ -332,20 +332,22 @@ static int render_frame(cairo_t *cr, struct frame *fr, ImageStore *is, struct frame *ch = fr->children[i]; double mtot; - if ( (ch->style != NULL) && ch->lop_from_style ) { - memcpy(&ch->lop, &ch->style->lop, - sizeof(struct layout_parameters)); - } else { - double x, y, w, h; - LengthUnits wu, hu; - x = ch->lop.x; y = ch->lop.y; - w = ch->lop.w; h = ch->lop.h; - wu = ch->lop.w_units; hu = ch->lop.h_units; - memcpy(&ch->lop, &ch->style->lop, - sizeof(struct layout_parameters)); - ch->lop.x = x; ch->lop.y = y; - ch->lop.w = w; ch->lop.h = h; - ch->lop.w_units = wu; ch->lop.h_units = hu; + if ( ch->style != NULL ) { + if ( ch->lop_from_style ) { + memcpy(&ch->lop, &ch->style->lop, + sizeof(struct layout_parameters)); + } else { + double x, y, w, h; + LengthUnits wu, hu; + x = ch->lop.x; y = ch->lop.y; + w = ch->lop.w; h = ch->lop.h; + wu = ch->lop.w_units; hu = ch->lop.h_units; + memcpy(&ch->lop, &ch->style->lop, + sizeof(struct layout_parameters)); + ch->lop.x = x; ch->lop.y = y; + ch->lop.w = w; ch->lop.h = h; + ch->lop.w_units = wu; ch->lop.h_units = hu; + } } mtot = ch->lop.margin_l + ch->lop.margin_r; diff --git a/src/stylesheet.c b/src/stylesheet.c index e2e335e..857f0f2 100644 --- a/src/stylesheet.c +++ b/src/stylesheet.c @@ -179,11 +179,13 @@ static int read_template(struct slide_template *t, StyleSheet *ss, struct ds_node *node) { int i; - int top_style, r; + char *top_style; - r = get_field_i(node, "top_style", &top_style); - if ( !r ) { - t->top_style = ss->styles[top_style]; + if ( !get_field_s(node, "top_style", &top_style) ) { + t->top_style = lookup_style(ss, top_style); + free(top_style); + } else { + t->top_style = NULL; } for ( i=0; i<node->n_children; i++ ) { @@ -282,6 +284,12 @@ StyleSheet *tree_to_stylesheet(struct ds_node *root) if ( get_field_s(root, "default_style", &ds) == 0 ) { ss->default_style = lookup_style(ss, ds); + if ( ss->default_style == NULL ) { + fprintf(stderr, "Failed to find default style '%s'\n", + ds); + } + } else { + ss->default_style = NULL; } node = find_node(root, "templates", 0); @@ -414,8 +422,7 @@ int replace_stylesheet(struct presentation *p, const char *filename) free_ds_tree(root); for ( i=0; i<p->num_slides; i++ ) { - int n; - n = fixup_styles(p->slides[i]->top, ss); + fixup_styles(p->slides[i]->top, ss); fixup_templates(p->slides[i], ss); } |