예제 #1
0
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;
}
예제 #2
0
/* Apply attributes unique to `svg' elements */
svg_status_t
_svg_group_apply_svg_attributes (svg_group_t	*group,
				 const char	**attributes)
{
    const char *view_box_str, *aspect_ratio_str;

    _svg_attribute_get_length (attributes, "width", &group->width, "100%");
    _svg_attribute_get_length (attributes, "height", &group->height, "100%");

    /* XXX: What else? */
    _svg_attribute_get_length (attributes, "x", &group->x, "0");
    _svg_attribute_get_length (attributes, "y", &group->y, "0");

    _svg_attribute_get_string (attributes, "viewBox", &view_box_str, NULL);

    if (view_box_str)
    {
	    (void) _svg_element_parse_view_box (view_box_str,
		    			      &group->view_box.box.x,
		    			      &group->view_box.box.y,
		    			      &group->view_box.box.width,
		    			      &group->view_box.box.height);

	group->view_box.aspect_ratio = SVG_PRESERVE_ASPECT_RATIO_NONE;
	_svg_attribute_get_string (attributes, "preserveAspectRatio", &aspect_ratio_str, NULL);
	if (aspect_ratio_str)
		(void) _svg_element_parse_aspect_ratio (aspect_ratio_str, &group->view_box);
    }

    return SVG_STATUS_SUCCESS;
}
svg_status_t
_svg_text_apply_attributes (svg_text_t		*text,
			    const char		**attributes)
{
    _svg_attribute_get_length (attributes, "x", &text->x, "0");
    _svg_attribute_get_length (attributes, "y", &text->y, "0");

    /* XXX: What else goes here? */

    return SVG_STATUS_SUCCESS;
}
예제 #4
0
static svg_status_t
_svg_parser_parse_line (svg_parser_t	*parser,
			const char	**attributes,
			svg_element_t	**path_element)
{
    svg_status_t status;

    status = _svg_parser_new_leaf_element (parser, path_element, SVG_ELEMENT_TYPE_LINE);
    if (status)
	return status;

    _svg_attribute_get_length (attributes, "x1", &((*path_element)->e.line.x1), "0");
    _svg_attribute_get_length (attributes, "y1", &((*path_element)->e.line.y1), "0");
    _svg_attribute_get_length (attributes, "x2", &((*path_element)->e.line.x2), "0");
    _svg_attribute_get_length (attributes, "y2", &((*path_element)->e.line.y2), "0");

    return SVG_STATUS_SUCCESS;
}
예제 #5
0
static svg_status_t
_svg_parser_parse_ellipse (svg_parser_t		*parser,
			   const char	**attributes,
			   svg_element_t	**path_element)
{
    svg_status_t status;

    status = _svg_parser_new_leaf_element (parser, path_element, SVG_ELEMENT_TYPE_ELLIPSE);
    if (status)
		return status;

    _svg_attribute_get_length (attributes, "cx", &((*path_element)->e.ellipse.cx), "0");
    _svg_attribute_get_length (attributes, "cy", &((*path_element)->e.ellipse.cy), "0");
    _svg_attribute_get_length (attributes, "rx", &((*path_element)->e.ellipse.rx), "100%");
    _svg_attribute_get_length (attributes, "ry", &((*path_element)->e.ellipse.ry), "100%");
    if ((*path_element)->e.ellipse.rx.value < 0 || (*path_element)->e.ellipse.ry.value < 0)
		return SVG_STATUS_PARSE_ERROR;

    return SVG_STATUS_SUCCESS;
}
예제 #6
0
static svg_status_t
_svg_parser_parse_rect (svg_parser_t	*parser,
			const char	**attributes,
			svg_element_t	**path_element)
{
    svg_status_t status;
    int has_rx = 0, has_ry = 0;

    status = _svg_parser_new_leaf_element (parser, path_element, SVG_ELEMENT_TYPE_RECT);
    if (status)
		return SVG_STATUS_PARSE_ERROR;
	
    _svg_attribute_get_length (attributes, "x", &((*path_element)->e.rect.x), "0");
    _svg_attribute_get_length (attributes, "y", &((*path_element)->e.rect.y), "0");
    _svg_attribute_get_length (attributes, "width", &((*path_element)->e.rect.width), "0");
    _svg_attribute_get_length (attributes, "height", &((*path_element)->e.rect.height), "0");
    status = _svg_attribute_get_length (attributes, "rx", &((*path_element)->e.rect.rx), "0");
    if (status == SVG_STATUS_SUCCESS)
		has_rx = 1;
    status = _svg_attribute_get_length (attributes, "ry", &((*path_element)->e.rect.ry), "0");
    if (status == SVG_STATUS_SUCCESS)
		has_ry = 1;

    if (has_rx || has_ry) {
		if (! has_rx)
			(*path_element)->e.rect.rx = (*path_element)->e.rect.ry;
		if (! has_ry)
			(*path_element)->e.rect.ry = (*path_element)->e.rect.rx;
	}
    return SVG_STATUS_SUCCESS;
}