static DiaObject * flow_load(ObjectNode obj_node, int version, DiaContext *ctx) { Flow *flow; AttributeNode attr; Connection *conn; DiaObject *obj; LineBBExtras *extra; flow = g_malloc0(sizeof(Flow)); conn = &flow->connection; obj = &conn->object; extra = &conn->extra_spacing; obj->type = &flow_type; obj->ops = &flow_ops; connection_load(conn, obj_node, ctx); connection_init(conn, 3, 0); flow->text = NULL; attr = object_find_attribute(obj_node, "text"); if (attr != NULL) flow->text = data_text(attribute_first_data(attr), ctx); else { /* pathologic */ DiaFont *font = dia_font_new_from_style(DIA_FONT_SANS, FLOW_FONTHEIGHT); flow->text = new_text("", font, FLOW_FONTHEIGHT, &obj->position, &color_black, ALIGN_CENTER); dia_font_unref(font); } attr = object_find_attribute(obj_node, "type"); if (attr != NULL) flow->type = (FlowType)data_int(attribute_first_data(attr), ctx); flow->text_handle.id = HANDLE_MOVE_TEXT; flow->text_handle.type = HANDLE_MINOR_CONTROL; flow->text_handle.connect_type = HANDLE_NONCONNECTABLE; flow->text_handle.connected_to = NULL; flow->text_handle.pos = flow->text->position; obj->handles[2] = &flow->text_handle; extra->start_long = extra->end_long = extra->start_trans = FLOW_WIDTH/2.0; extra->end_trans = MAX(FLOW_WIDTH, FLOW_ARROWLEN) / 2.0; flow->textpos = flow->text->position; flow_update_data(flow); return &flow->connection.object; }
static void intarrayprop_load(IntarrayProperty *prop, AttributeNode attr, DataNode data) { guint nvals = attribute_num_data(attr); guint i; g_array_set_size(prop->intarray_data,nvals); for (i=0; (i < nvals) && data; i++, data = data_next(data)) g_array_index(prop->intarray_data,gint,i) = data_int(data); if (i != nvals) g_warning("attribute_num_data() and actual data count mismatch " "(shouldn't happen)"); }
static Object * message_load(ObjectNode obj_node, int version, const char *filename) { Message *message; AttributeNode attr; Connection *conn; Object *obj; if (message_font == NULL) message_font = font_getfont("Helvetica"); message = g_malloc(sizeof(Message)); conn = &message->connection; obj = (Object *) message; obj->type = &message_type; obj->ops = &message_ops; connection_load(conn, obj_node); connection_init(conn, 3, 0); message->text = NULL; attr = object_find_attribute(obj_node, "text"); if (attr != NULL) message->text = data_string(attribute_first_data(attr)); attr = object_find_attribute(obj_node, "text_pos"); if (attr != NULL) data_point(attribute_first_data(attr), &message->text_pos); attr = object_find_attribute(obj_node, "type"); if (attr != NULL) message->type = (MessageType)data_int(attribute_first_data(attr)); if (message->text) message->text_width = font_string_width(message->text, message_font, MESSAGE_FONTHEIGHT); else message->text_width = 0; message->text_handle.id = HANDLE_MOVE_TEXT; message->text_handle.type = HANDLE_MINOR_CONTROL; message->text_handle.connect_type = HANDLE_NONCONNECTABLE; message->text_handle.connected_to = NULL; obj->handles[2] = &message->text_handle; message_update_data(message); return (Object *)message; }
ConnPointLine * connpointline_load(DiaObject *obj,ObjectNode obj_node, const gchar *name, int default_nc,int *realconncount) { ConnPointLine *cpl; int nc = default_nc; AttributeNode attr; attr = object_find_attribute(obj_node, name); if (attr != NULL) nc = data_int(attribute_first_data(attr)); cpl = connpointline_create(obj,nc); if (realconncount) (*realconncount) += cpl->num_connections; return cpl; /* NOT this ! return cpl_inplacecreate(obj, load_int(obj_node,name,default_nc), realconncount); */ }
static Object * state_load(ObjectNode obj_node, int version, const char *filename) { State *state; Element *elem; Object *obj; int i; AttributeNode attr; state = g_malloc(sizeof(State)); elem = &state->element; obj = (Object *) state; obj->type = &state_type; obj->ops = &state_ops; element_load(elem, obj_node); attr = object_find_attribute(obj_node, "text"); if (attr != NULL) state->text = data_text(attribute_first_data(attr)); attr = object_find_attribute(obj_node, "type"); if (attr != NULL) state->state_type = data_int(attribute_first_data(attr)); element_init(elem, 8, 8); for (i=0;i<8;i++) { obj->connections[i] = &state->connections[i]; state->connections[i].object = obj; state->connections[i].connected = NULL; } state_update_data(state); for (i=0;i<8;i++) { obj->handles[i]->type = HANDLE_NON_MOVABLE; } return (Object *)state; }
static void enumprop_load(EnumProperty *prop, AttributeNode attr, DataNode data) { DataType dt = data_type (data); if (DATATYPE_ENUM == dt) prop->enum_data = data_enum(data); else if (DATATYPE_INT == dt) { gboolean cast_ok = FALSE; PropEnumData *enumdata = prop->common.extra_data; guint i, v = data_int(data); for (i = 0; enumdata[i].name != NULL; ++i) { if (v == enumdata[i].enumv) { prop->enum_data = v; cast_ok = TRUE; break; } } if (!cast_ok) { prop->enum_data = enumdata[0].enumv; message_warning (_("Property cast from int to enum out of range")); } } }
static void connpoint_lineprop_load(Connpoint_LineProperty *prop, AttributeNode attr, DataNode data, DiaContext *ctx) { prop->connpoint_line_data = data_int(data,ctx); }
static void intprop_load(IntProperty *prop, AttributeNode attr, DataNode data) { prop->int_data = data_int(data); }
static void intprop_load(IntProperty *prop, AttributeNode attr, DataNode data, DiaContext *ctx) { prop->int_data = data_int(data,ctx); }