static void _rsvg_node_ellipse_set_atts (RsvgNode * self, RsvgHandle * ctx, RsvgPropertyBag * atts) { const char *klazz = NULL, *id = NULL, *value; RsvgNodeEllipse *ellipse = (RsvgNodeEllipse *) self; if (rsvg_property_bag_size (atts)) { if ((value = rsvg_property_bag_lookup (atts, "cx"))) ellipse->cx = _rsvg_css_parse_length (value); if ((value = rsvg_property_bag_lookup (atts, "cy"))) ellipse->cy = _rsvg_css_parse_length (value); if ((value = rsvg_property_bag_lookup (atts, "rx"))) ellipse->rx = _rsvg_css_parse_length (value); if ((value = rsvg_property_bag_lookup (atts, "ry"))) ellipse->ry = _rsvg_css_parse_length (value); if ((value = rsvg_property_bag_lookup (atts, "class"))) klazz = value; if ((value = rsvg_property_bag_lookup (atts, "id"))) { id = value; rsvg_defs_register_name (ctx->priv->defs, value, self); } rsvg_parse_style_attrs (ctx, self->state, "ellipse", klazz, id, atts); } }
static void rsvg_node_use_set_atts (RsvgNode * self, RsvgHandle * ctx, RsvgPropertyBag * atts) { const char *value = NULL, *klazz = NULL, *id = NULL; RsvgNodeUse *use; use = (RsvgNodeUse *) self; if (rsvg_property_bag_size (atts)) { if ((value = rsvg_property_bag_lookup (atts, "x"))) use->x = _rsvg_css_parse_length (value); if ((value = rsvg_property_bag_lookup (atts, "y"))) use->y = _rsvg_css_parse_length (value); if ((value = rsvg_property_bag_lookup (atts, "width"))) use->w = _rsvg_css_parse_length (value); if ((value = rsvg_property_bag_lookup (atts, "height"))) use->h = _rsvg_css_parse_length (value); if ((value = rsvg_property_bag_lookup (atts, "class"))) klazz = value; if ((value = rsvg_property_bag_lookup (atts, "id"))) { id = value; rsvg_defs_register_name (ctx->priv->defs, value, &use->super); } if ((value = rsvg_property_bag_lookup (atts, "xlink:href"))) rsvg_defs_add_resolver (ctx->priv->defs, &use->link, value); rsvg_parse_style_attrs (ctx, self->state, "use", klazz, id, atts); } }
static void _rsvg_node_tspan_set_atts (RsvgNode * self, RsvgHandle * ctx, RsvgPropertyBag * atts) { const char *klazz = NULL, *id = NULL, *value; RsvgNodeText *text = (RsvgNodeText *) self; if (rsvg_property_bag_size (atts)) { if ((value = rsvg_property_bag_lookup (atts, "x"))) text->x = _rsvg_css_parse_length (value); if ((value = rsvg_property_bag_lookup (atts, "y"))) text->y = _rsvg_css_parse_length (value); if ((value = rsvg_property_bag_lookup (atts, "dx"))) text->dx = _rsvg_css_parse_length (value); if ((value = rsvg_property_bag_lookup (atts, "dy"))) text->dy = _rsvg_css_parse_length (value); if ((value = rsvg_property_bag_lookup (atts, "class"))) klazz = value; if ((value = rsvg_property_bag_lookup (atts, "id"))) { id = value; rsvg_defs_register_name (ctx->priv->defs, value, self); } rsvg_parse_style_attrs (ctx, self->state, "tspan", klazz, id, atts); } }
static void rsvg_node_svg_set_atts (RsvgNode * self, RsvgHandle * ctx, RsvgPropertyBag * atts) { const char *value; RsvgNodeSvg *svg = (RsvgNodeSvg *) self; if (rsvg_property_bag_size (atts)) { if ((value = rsvg_property_bag_lookup (atts, "viewBox"))) svg->vbox = rsvg_css_parse_vbox (value); if ((value = rsvg_property_bag_lookup (atts, "preserveAspectRatio"))) svg->preserve_aspect_ratio = rsvg_css_parse_aspect_ratio (value); if ((value = rsvg_property_bag_lookup (atts, "width"))) svg->w = _rsvg_css_parse_length (value); if ((value = rsvg_property_bag_lookup (atts, "height"))) svg->h = _rsvg_css_parse_length (value); /* * x & y attributes have no effect on outermost svg * http://www.w3.org/TR/SVG/struct.html#SVGElement */ if (self->parent && (value = rsvg_property_bag_lookup (atts, "x"))) svg->x = _rsvg_css_parse_length (value); if (self->parent && (value = rsvg_property_bag_lookup (atts, "y"))) svg->y = _rsvg_css_parse_length (value); if ((value = rsvg_property_bag_lookup (atts, "id"))) { rsvg_defs_register_name (ctx->priv->defs, value, &svg->super); } /* * style element is not loaded yet here, so we need to store those attribues * to be applied later. */ svg->atts = rsvg_property_bag_ref(atts); } }
static void _rsvg_node_line_set_atts (RsvgNode * self, RsvgHandle * ctx, RsvgPropertyBag * atts) { const char *klazz = NULL, *id = NULL, *value; RsvgNodeLine *line = (RsvgNodeLine *) self; if (rsvg_property_bag_size (atts)) { if ((value = rsvg_property_bag_lookup (atts, "x1"))) line->x1 = _rsvg_css_parse_length (value); if ((value = rsvg_property_bag_lookup (atts, "y1"))) line->y1 = _rsvg_css_parse_length (value); if ((value = rsvg_property_bag_lookup (atts, "x2"))) line->x2 = _rsvg_css_parse_length (value); if ((value = rsvg_property_bag_lookup (atts, "y2"))) line->y2 = _rsvg_css_parse_length (value); if ((value = rsvg_property_bag_lookup (atts, "class"))) klazz = value; if ((value = rsvg_property_bag_lookup (atts, "id"))) { id = value; rsvg_defs_register_name (ctx->priv->defs, value, self); } rsvg_parse_style_attrs (ctx, self->state, "line", klazz, id, atts); } }
RsvgNode * rsvg_new_use (void) { RsvgNodeUse *use; use = g_new (RsvgNodeUse, 1); _rsvg_node_init (&use->super); use->super.draw = rsvg_node_use_draw; use->super.set_atts = rsvg_node_use_set_atts; use->x = _rsvg_css_parse_length ("0"); use->y = _rsvg_css_parse_length ("0"); use->w = _rsvg_css_parse_length ("0"); use->h = _rsvg_css_parse_length ("0"); use->link = NULL; return (RsvgNode *) use; }
RsvgNode * rsvg_new_mask (void) { RsvgMask *mask; mask = g_new (RsvgMask, 1); _rsvg_node_init (&mask->super); mask->maskunits = objectBoundingBox; mask->contentunits = userSpaceOnUse; mask->x = _rsvg_css_parse_length ("0"); mask->y = _rsvg_css_parse_length ("0"); mask->width = _rsvg_css_parse_length ("1"); mask->height = _rsvg_css_parse_length ("1"); mask->super.set_atts = rsvg_mask_set_atts; return &mask->super; }
RsvgNode * rsvg_new_marker (void) { RsvgMarker *marker; marker = g_new (RsvgMarker, 1); _rsvg_node_init (&marker->super, RSVG_NODE_TYPE_MARKER); marker->orient = 0; marker->orientAuto = FALSE; marker->preserve_aspect_ratio = RSVG_ASPECT_RATIO_XMID_YMID; marker->refX = marker->refY = _rsvg_css_parse_length ("0"); marker->width = marker->height = _rsvg_css_parse_length ("1"); marker->bbox = TRUE; marker->vbox.active = FALSE; marker->super.set_atts = rsvg_node_marker_set_atts; return &marker->super; }
RsvgNode * rsvg_new_svg (void) { RsvgNodeSvg *svg; svg = g_new (RsvgNodeSvg, 1); _rsvg_node_init (&svg->super); svg->vbox.active = FALSE; svg->preserve_aspect_ratio = RSVG_ASPECT_RATIO_XMID_YMID; svg->x = _rsvg_css_parse_length ("0"); svg->y = _rsvg_css_parse_length ("0"); svg->w = _rsvg_css_parse_length ("100%"); svg->h = _rsvg_css_parse_length ("100%"); svg->super.draw = rsvg_node_svg_draw; svg->super.free = _rsvg_svg_free; svg->super.set_atts = rsvg_node_svg_set_atts; return &svg->super; }
RsvgNode * rsvg_new_tspan (void) { RsvgNodeText *text; text = g_new (RsvgNodeText, 1); _rsvg_node_init (&text->super); text->super.set_atts = _rsvg_node_tspan_set_atts; text->x.factor = text->y.factor = 'n'; text->dx = text->dy = _rsvg_css_parse_length ("0"); return &text->super; }
RsvgNode * rsvg_new_text (void) { RsvgNodeText *text; text = g_new (RsvgNodeText, 1); _rsvg_node_init (&text->super); text->super.draw = _rsvg_node_text_draw; text->super.set_atts = _rsvg_node_text_set_atts; text->x = text->y = text->dx = text->dy = _rsvg_css_parse_length ("0"); return &text->super; }
RsvgNode * rsvg_new_circle (void) { RsvgNodeCircle *circle; circle = g_new (RsvgNodeCircle, 1); _rsvg_node_init (&circle->super, RSVG_NODE_TYPE_CIRCLE); circle->super.draw = _rsvg_node_circle_draw; circle->super.set_atts = _rsvg_node_circle_set_atts; circle->cx = circle->cy = circle->r = _rsvg_css_parse_length ("0"); return &circle->super; }
RsvgNode * rsvg_new_ellipse (void) { RsvgNodeEllipse *ellipse; ellipse = g_new (RsvgNodeEllipse, 1); _rsvg_node_init (&ellipse->super, RSVG_NODE_TYPE_ELLIPSE); ellipse->super.draw = _rsvg_node_ellipse_draw; ellipse->super.set_atts = _rsvg_node_ellipse_set_atts; ellipse->cx = ellipse->cy = ellipse->rx = ellipse->ry = _rsvg_css_parse_length ("0"); return &ellipse->super; }
RsvgNode * rsvg_new_line (void) { RsvgNodeLine *line; line = g_new (RsvgNodeLine, 1); _rsvg_node_init (&line->super, RSVG_NODE_TYPE_LINE); line->super.draw = _rsvg_node_line_draw; line->super.set_atts = _rsvg_node_line_set_atts; line->x1 = line->x2 = line->y1 = line->y2 = _rsvg_css_parse_length ("0"); return &line->super; }
static void rsvg_node_marker_set_atts (RsvgNode * self, RsvgHandle * ctx, RsvgPropertyBag * atts) { const char *klazz = NULL, *id = NULL, *value; RsvgMarker *marker; marker = (RsvgMarker *) self; if (rsvg_property_bag_size (atts)) { if ((value = rsvg_property_bag_lookup (atts, "id"))) { id = value; rsvg_defs_register_name (ctx->priv->defs, id, &marker->super); } if ((value = rsvg_property_bag_lookup (atts, "class"))) klazz = value; if ((value = rsvg_property_bag_lookup (atts, "viewBox"))) marker->vbox = rsvg_css_parse_vbox (value); if ((value = rsvg_property_bag_lookup (atts, "refX"))) marker->refX = _rsvg_css_parse_length (value); if ((value = rsvg_property_bag_lookup (atts, "refY"))) marker->refY = _rsvg_css_parse_length (value); if ((value = rsvg_property_bag_lookup (atts, "markerWidth"))) marker->width = _rsvg_css_parse_length (value); if ((value = rsvg_property_bag_lookup (atts, "markerHeight"))) marker->height = _rsvg_css_parse_length (value); if ((value = rsvg_property_bag_lookup (atts, "orient"))) { if (!strcmp (value, "auto")) marker->orientAuto = TRUE; else marker->orient = rsvg_css_parse_angle (value); } if ((value = rsvg_property_bag_lookup (atts, "markerUnits"))) { if (!strcmp (value, "userSpaceOnUse")) marker->bbox = FALSE; if (!strcmp (value, "strokeWidth")) marker->bbox = TRUE; } if ((value = rsvg_property_bag_lookup (atts, "preserveAspectRatio"))) marker->preserve_aspect_ratio = rsvg_css_parse_aspect_ratio (value); rsvg_parse_style_attrs (ctx, self->state, "marker", klazz, id, atts); } }
RsvgNode * rsvg_new_rect (void) { RsvgNodeRect *rect; rect = g_new (RsvgNodeRect, 1); _rsvg_node_init (&rect->super, RSVG_NODE_TYPE_RECT); rect->super.draw = _rsvg_node_rect_draw; rect->super.set_atts = _rsvg_node_rect_set_atts; rect->x = rect->y = rect->w = rect->h = rect->rx = rect->ry = _rsvg_css_parse_length ("0"); rect->got_rx = rect->got_ry = FALSE; return &rect->super; }
static void _rsvg_node_rect_set_atts (RsvgNode * self, RsvgHandle * ctx, RsvgPropertyBag * atts) { const char *klazz = NULL, *id = NULL, *value; RsvgNodeRect *rect = (RsvgNodeRect *) self; /* FIXME: negative w/h/rx/ry is an error, per http://www.w3.org/TR/SVG11/shapes.html#RectElement */ if (rsvg_property_bag_size (atts)) { if ((value = rsvg_property_bag_lookup (atts, "x"))) rect->x = _rsvg_css_parse_length (value); if ((value = rsvg_property_bag_lookup (atts, "y"))) rect->y = _rsvg_css_parse_length (value); if ((value = rsvg_property_bag_lookup (atts, "width"))) rect->w = _rsvg_css_parse_length (value); if ((value = rsvg_property_bag_lookup (atts, "height"))) rect->h = _rsvg_css_parse_length (value); if ((value = rsvg_property_bag_lookup (atts, "rx"))) { rect->rx = _rsvg_css_parse_length (value); rect->got_rx = TRUE; } if ((value = rsvg_property_bag_lookup (atts, "ry"))) { rect->ry = _rsvg_css_parse_length (value); rect->got_ry = TRUE; } if ((value = rsvg_property_bag_lookup (atts, "class"))) klazz = value; if ((value = rsvg_property_bag_lookup (atts, "id"))) { id = value; rsvg_defs_register_name (ctx->priv->defs, value, self); } rsvg_parse_style_attrs (ctx, self->state, "rect", klazz, id, atts); } }
static void rsvg_node_image_set_atts (RsvgNode * self, RsvgHandle * ctx, RsvgPropertyBag * atts) { const char *klazz = NULL, *id = NULL, *value; RsvgNodeImage *image = (RsvgNodeImage *) self; if (rsvg_property_bag_size (atts)) { if ((value = rsvg_property_bag_lookup (atts, "x"))) image->x = _rsvg_css_parse_length (value); if ((value = rsvg_property_bag_lookup (atts, "y"))) image->y = _rsvg_css_parse_length (value); if ((value = rsvg_property_bag_lookup (atts, "width"))) image->w = _rsvg_css_parse_length (value); if ((value = rsvg_property_bag_lookup (atts, "height"))) image->h = _rsvg_css_parse_length (value); /* path is used by some older adobe illustrator versions */ if ((value = rsvg_property_bag_lookup (atts, "path")) || (value = rsvg_property_bag_lookup (atts, "xlink:href"))) { image->surface = rsvg_cairo_surface_new_from_href (ctx, value, NULL); if (!image->surface) { #ifdef G_ENABLE_DEBUG g_warning ("Couldn't load image: %s\n", value); #endif } } if ((value = rsvg_property_bag_lookup (atts, "class"))) klazz = value; if ((value = rsvg_property_bag_lookup (atts, "id"))) { id = value; rsvg_defs_register_name (ctx->priv->defs, id, &image->super); } if ((value = rsvg_property_bag_lookup (atts, "preserveAspectRatio"))) image->preserve_aspect_ratio = rsvg_css_parse_aspect_ratio (value); rsvg_parse_style_attrs (ctx, image->super.state, "image", klazz, id, atts); } }
static void rsvg_mask_set_atts (RsvgNode * self, RsvgHandle * ctx, RsvgPropertyBag * atts) { const char *id = NULL, *klazz = NULL, *value; RsvgMask *mask; mask = (RsvgMask *) self; if (rsvg_property_bag_size (atts)) { if ((value = rsvg_property_bag_lookup (atts, "maskUnits"))) { if (!strcmp (value, "userSpaceOnUse")) mask->maskunits = userSpaceOnUse; else mask->maskunits = objectBoundingBox; } if ((value = rsvg_property_bag_lookup (atts, "maskContentUnits"))) { if (!strcmp (value, "objectBoundingBox")) mask->contentunits = objectBoundingBox; else mask->contentunits = userSpaceOnUse; } if ((value = rsvg_property_bag_lookup (atts, "x"))) mask->x = _rsvg_css_parse_length (value); if ((value = rsvg_property_bag_lookup (atts, "y"))) mask->y = _rsvg_css_parse_length (value); if ((value = rsvg_property_bag_lookup (atts, "width"))) mask->width = _rsvg_css_parse_length (value); if ((value = rsvg_property_bag_lookup (atts, "height"))) mask->height = _rsvg_css_parse_length (value); if ((value = rsvg_property_bag_lookup (atts, "id"))) { id = value; rsvg_defs_register_name (ctx->priv->defs, id, &mask->super); } if ((value = rsvg_property_bag_lookup (atts, "class"))) klazz = value; } rsvg_parse_style_attrs (ctx, mask->super.state, "mask", klazz, id, atts); }
RsvgNode * rsvg_new_image (void) { RsvgNodeImage *image; image = g_new (RsvgNodeImage, 1); _rsvg_node_init (&image->super, RSVG_NODE_TYPE_IMAGE); g_assert (image->super.state); image->surface = NULL; image->preserve_aspect_ratio = RSVG_ASPECT_RATIO_XMID_YMID; image->x = image->y = image->w = image->h = _rsvg_css_parse_length ("0"); image->super.free = rsvg_node_image_free; image->super.draw = rsvg_node_image_draw; image->super.set_atts = rsvg_node_image_set_atts; return &image->super; }
static void _rsvg_node_text_path_set_atts (RsvgNode * self, RsvgHandle * ctx, RsvgPropertyBag * atts) { const char *klazz = NULL, *id = NULL, *value; RsvgNodeTextPath *text = (RsvgNodeTextPath *) self; if (rsvg_property_bag_size (atts)) { // TODO add support for method, spacing? if ((value = rsvg_property_bag_lookup (atts, "xlink:href"))) rsvg_defs_add_resolver (ctx->priv->defs, &text->link, value); if ((value = rsvg_property_bag_lookup (atts, "startOffset"))) text->startOffset = _rsvg_css_parse_length (value); if ((value = rsvg_property_bag_lookup (atts, "class"))) klazz = value; if ((value = rsvg_property_bag_lookup (atts, "id"))) rsvg_defs_register_name (ctx->priv->defs, value, self); rsvg_parse_style_attrs (ctx, self->state, "textPath", klazz, id, atts); } }