static DiaObject * zigzagline_load(ObjectNode obj_node, int version, DiaContext *ctx) { Zigzagline *zigzagline; OrthConn *orth; DiaObject *obj; AttributeNode attr; zigzagline = g_malloc0(sizeof(Zigzagline)); orth = &zigzagline->orth; obj = &orth->object; obj->type = &zigzagline_type; obj->ops = &zigzagline_ops; orthconn_load(orth, obj_node, ctx); zigzagline->line_color = color_black; attr = object_find_attribute(obj_node, "line_color"); if (attr != NULL) data_color(attribute_first_data(attr), &zigzagline->line_color, ctx); zigzagline->line_width = 0.1; attr = object_find_attribute(obj_node, PROP_STDNAME_LINE_WIDTH); if (attr != NULL) zigzagline->line_width = data_real(attribute_first_data(attr), ctx); zigzagline->line_style = LINESTYLE_SOLID; attr = object_find_attribute(obj_node, "line_style"); if (attr != NULL) zigzagline->line_style = data_enum(attribute_first_data(attr), ctx); zigzagline->line_join = LINEJOIN_MITER; attr = object_find_attribute(obj_node, "line_join"); if (attr != NULL) zigzagline->line_join = data_enum(attribute_first_data(attr), ctx); zigzagline->line_caps = LINECAPS_BUTT; attr = object_find_attribute(obj_node, "line_caps"); if (attr != NULL) zigzagline->line_caps = data_enum(attribute_first_data(attr), ctx); load_arrow(obj_node, &zigzagline->start_arrow, "start_arrow", "start_arrow_length", "start_arrow_width", ctx); load_arrow(obj_node, &zigzagline->end_arrow, "end_arrow", "end_arrow_length", "end_arrow_width", ctx); zigzagline->dashlength = DEFAULT_LINESTYLE_DASHLEN; attr = object_find_attribute(obj_node, "dashlength"); if (attr != NULL) zigzagline->dashlength = data_real(attribute_first_data(attr), ctx); zigzagline->corner_radius = 0.0; attr = object_find_attribute(obj_node, "corner_radius"); if (attr != NULL) zigzagline->corner_radius = data_real(attribute_first_data(attr), ctx); zigzagline_update_data(zigzagline); return &zigzagline->orth.object; }
static DiaObject * line_load(ObjectNode obj_node, int version, DiaContext *ctx) { Line *line; Connection *conn; DiaObject *obj; AttributeNode attr; line = g_malloc0(sizeof(Line)); conn = &line->connection; obj = &conn->object; obj->type = &line_type; obj->ops = &line_ops; connection_load(conn, obj_node, ctx); line->line_color = color_black; attr = object_find_attribute(obj_node, "line_color"); if (attr != NULL) data_color(attribute_first_data(attr), &line->line_color, ctx); line->line_width = 0.1; attr = object_find_attribute(obj_node, PROP_STDNAME_LINE_WIDTH); if (attr != NULL) line->line_width = data_real(attribute_first_data(attr), ctx); line->line_style = LINESTYLE_SOLID; attr = object_find_attribute(obj_node, "line_style"); if (attr != NULL) line->line_style = data_enum(attribute_first_data(attr), ctx); line->line_caps = LINECAPS_BUTT; attr = object_find_attribute(obj_node, "line_caps"); if (attr != NULL) line->line_caps = data_enum(attribute_first_data(attr), ctx); load_arrow(obj_node, &line->start_arrow, "start_arrow", "start_arrow_length", "start_arrow_width", ctx); load_arrow(obj_node, &line->end_arrow, "end_arrow", "end_arrow_length", "end_arrow_width", ctx); line->absolute_start_gap = 0.0; attr = object_find_attribute(obj_node, "absolute_start_gap"); if (attr != NULL) line->absolute_start_gap = data_real(attribute_first_data(attr), ctx); line->absolute_end_gap = 0.0; attr = object_find_attribute(obj_node, "absolute_end_gap"); if (attr != NULL) line->absolute_end_gap = data_real(attribute_first_data(attr), ctx); line->dashlength = DEFAULT_LINESTYLE_DASHLEN; attr = object_find_attribute(obj_node, "dashlength"); if (attr != NULL) line->dashlength = data_real(attribute_first_data(attr), ctx); connection_init(conn, 2, 0); line->cpl = connpointline_load(obj,obj_node,"numcp",1,NULL, ctx); line_update_data(line); return &line->connection.object; }
static DiaObject * bezierline_load(ObjectNode obj_node, int version, DiaContext *ctx) { Bezierline *bezierline; BezierConn *bez; DiaObject *obj; AttributeNode attr; bezierline = g_new0(Bezierline, 1); bezierline->bez.object.enclosing_box = g_new0 (Rectangle, 1); bez = &bezierline->bez; obj = &bez->object; obj->type = &bezierline_type; obj->ops = &bezierline_ops; bezierconn_load(bez, obj_node, ctx); bezierline->line_color = color_black; attr = object_find_attribute(obj_node, "line_color"); if (attr != NULL) data_color(attribute_first_data(attr), &bezierline->line_color, ctx); bezierline->line_width = 0.1; attr = object_find_attribute(obj_node, PROP_STDNAME_LINE_WIDTH); if (attr != NULL) bezierline->line_width = data_real(attribute_first_data(attr), ctx); bezierline->line_style = LINESTYLE_SOLID; attr = object_find_attribute(obj_node, "line_style"); if (attr != NULL) bezierline->line_style = data_enum(attribute_first_data(attr), ctx); bezierline->line_join = LINEJOIN_MITER; attr = object_find_attribute(obj_node, "line_join"); if (attr != NULL) bezierline->line_join = data_enum(attribute_first_data(attr), ctx); bezierline->line_caps = LINECAPS_BUTT; attr = object_find_attribute(obj_node, "line_caps"); if (attr != NULL) bezierline->line_caps = data_enum(attribute_first_data(attr), ctx); bezierline->dashlength = DEFAULT_LINESTYLE_DASHLEN; attr = object_find_attribute(obj_node, "dashlength"); if (attr != NULL) bezierline->dashlength = data_real(attribute_first_data(attr), ctx); load_arrow(obj_node, &bezierline->start_arrow, "start_arrow", "start_arrow_length", "start_arrow_width", ctx); load_arrow(obj_node, &bezierline->end_arrow, "end_arrow", "end_arrow_length", "end_arrow_width", ctx); bezierline->absolute_start_gap = 0.0; attr = object_find_attribute(obj_node, "absolute_start_gap"); if (attr != NULL) bezierline->absolute_start_gap = data_real(attribute_first_data(attr), ctx); bezierline->absolute_end_gap = 0.0; attr = object_find_attribute(obj_node, "absolute_end_gap"); if (attr != NULL) bezierline->absolute_end_gap = data_real(attribute_first_data(attr), ctx); /* if "screws up the bounding box if auto_gap" it must be fixed there * not by copying some meaningless bounding_box before this function call! * But the real fix is in connectionpoint.c(connpoint_is_autogap) */ bezierline_update_data(bezierline); return &bezierline->bez.object; }
static DiaObject * polyline_load(ObjectNode obj_node, int version, DiaContext *ctx) { Polyline *polyline; PolyConn *poly; DiaObject *obj; AttributeNode attr; polyline = g_malloc0(sizeof(Polyline)); poly = &polyline->poly; obj = &poly->object; obj->type = &polyline_type; obj->ops = &polyline_ops; polyconn_load(poly, obj_node, ctx); polyline->line_color = color_black; attr = object_find_attribute(obj_node, "line_color"); if (attr != NULL) data_color(attribute_first_data(attr), &polyline->line_color, ctx); polyline->line_width = 0.1; attr = object_find_attribute(obj_node, PROP_STDNAME_LINE_WIDTH); if (attr != NULL) polyline->line_width = data_real(attribute_first_data(attr), ctx); polyline->line_style = LINESTYLE_SOLID; attr = object_find_attribute(obj_node, "line_style"); if (attr != NULL) polyline->line_style = data_enum(attribute_first_data(attr), ctx); polyline->line_join = LINEJOIN_MITER; attr = object_find_attribute(obj_node, "line_join"); if (attr != NULL) polyline->line_join = data_enum(attribute_first_data(attr), ctx); polyline->line_caps = LINECAPS_BUTT; attr = object_find_attribute(obj_node, "line_caps"); if (attr != NULL) polyline->line_caps = data_enum(attribute_first_data(attr), ctx); polyline->dashlength = DEFAULT_LINESTYLE_DASHLEN; attr = object_find_attribute(obj_node, "dashlength"); if (attr != NULL) polyline->dashlength = data_real(attribute_first_data(attr), ctx); load_arrow(obj_node, &polyline->start_arrow, "start_arrow", "start_arrow_length", "start_arrow_width", ctx); load_arrow(obj_node, &polyline->end_arrow, "end_arrow", "end_arrow_length", "end_arrow_width", ctx); polyline->absolute_start_gap = 0.0; attr = object_find_attribute(obj_node, "absolute_start_gap"); if (attr != NULL) polyline->absolute_start_gap = data_real(attribute_first_data(attr), ctx); polyline->absolute_end_gap = 0.0; attr = object_find_attribute(obj_node, "absolute_end_gap"); if (attr != NULL) polyline->absolute_end_gap = data_real(attribute_first_data(attr), ctx); polyline->corner_radius = 0.0; attr = object_find_attribute(obj_node, "corner_radius"); if (attr != NULL) polyline->corner_radius = data_real(attribute_first_data(attr), ctx); polyline_update_data(polyline); return &polyline->poly.object; }
static DiaObject * arc_load(ObjectNode obj_node, int version,DiaContext *ctx) { Arc *arc; Connection *conn; DiaObject *obj; AttributeNode attr; arc = g_malloc0(sizeof(Arc)); conn = &arc->connection; obj = &conn->object; obj->type = &arc_type; obj->ops = &arc_ops; connection_load(conn, obj_node, ctx); arc->arc_color = color_black; attr = object_find_attribute(obj_node, "arc_color"); if (attr != NULL) data_color(attribute_first_data(attr), &arc->arc_color, ctx); arc->curve_distance = 0.1; attr = object_find_attribute(obj_node, "curve_distance"); if (attr != NULL) arc->curve_distance = data_real(attribute_first_data(attr), ctx); arc->line_width = 0.1; attr = object_find_attribute(obj_node, PROP_STDNAME_LINE_WIDTH); if (attr != NULL) arc->line_width = data_real(attribute_first_data(attr), ctx); arc->line_style = LINESTYLE_SOLID; attr = object_find_attribute(obj_node, "line_style"); if (attr != NULL) arc->line_style = data_enum(attribute_first_data(attr), ctx); arc->dashlength = DEFAULT_LINESTYLE_DASHLEN; attr = object_find_attribute(obj_node, "dashlength"); if (attr != NULL) arc->dashlength = data_real(attribute_first_data(attr), ctx); arc->line_caps = LINECAPS_BUTT; attr = object_find_attribute(obj_node, "line_caps"); if (attr != NULL) arc->line_caps = data_enum(attribute_first_data(attr), ctx); load_arrow(obj_node, &arc->start_arrow, "start_arrow", "start_arrow_length", "start_arrow_width", ctx); load_arrow(obj_node, &arc->end_arrow, "end_arrow", "end_arrow_length", "end_arrow_width", ctx); connection_init(conn, 4, 0); _arc_setup_handles (arc); /* older versions did not prohibit everything reduced to a single point * and afterwards failed on all the calculations producing nan. */ if (distance_point_point (&arc->connection.endpoints[0], &arc->connection.endpoints[1]) < 0.02) { arc->curve_distance = 0.0; arc->connection.endpoints[0].x -= 0.01; arc->connection.endpoints[1].x += 0.01; arc_update_handles (arc); } arc_update_data(arc); return &arc->connection.object; }