svg_status_t _svg_group_apply_use_attributes (svg_element_t *group, const char **attributes) { const char *href; svg_element_t *ref; svg_element_t *clone; svgint_status_t status = SVG_STATUS_SUCCESS; _svg_attribute_get_string (attributes, "xlink:href", &href, ""); _svg_fetch_element_by_id (group->doc, href + 1, &ref); if (!ref) { /* XXX: Should we report an error here? */ return SVG_STATUS_SUCCESS; } _svg_attribute_get_length (attributes, "width", &group->e.group.width, "100%"); _svg_attribute_get_length (attributes, "height", &group->e.group.height, "100%"); clone = ref; _svg_element_reference(ref); if (status) return status; if (clone) { _svg_group_add_element (&group->e.group, clone); } return SVG_STATUS_SUCCESS; }
svg_status_t _svg_paint_init (svg_paint_t *paint, svg_t *svg, const char *str) { svg_status_t status; if (strcmp (str, "none") == 0) { paint->type = SVG_PAINT_TYPE_NONE; return SVG_STATUS_SUCCESS; } /* Paint parser courtesy of Steven Kramer */ if (strncmp (str, "url(#", 5) == 0 && strchr (str, ')')) { svg_element_t *element = NULL; const char *end = strchr (str, ')'); int length = end - (str + 5); char *id = malloc (length+1); if (!id) return SVG_STATUS_NO_MEMORY; strncpy (id, str + 5, length); id[length] = '\0'; _svg_fetch_element_by_id (svg, id, &element); free (id); if (element == NULL) return SVG_STATUS_PARSE_ERROR; switch (element->type) { case SVG_ELEMENT_TYPE_GRADIENT: paint->type = SVG_PAINT_TYPE_GRADIENT; paint->p.gradient = &element->e.gradient; break; case SVG_ELEMENT_TYPE_PATTERN: paint->type = SVG_PAINT_TYPE_PATTERN; paint->p.pattern_element = element; break; default: return SVG_STATUS_PARSE_ERROR; } return SVG_STATUS_SUCCESS; } status = _svg_color_init_from_str (&paint->p.color, str); if (status) return status; paint->type = SVG_PAINT_TYPE_COLOR; return SVG_STATUS_SUCCESS; }