/*! * \brief Convert _StdPath to one or more _BezierLine/BezierGon */ static ObjectChange * _convert_to_beziers_callback (DiaObject *obj, Point *clicked, gpointer data) { StdPath *stdpath = (StdPath *)obj; BezPoint *bezier = stdpath->points; GList *list = NULL; int i, n = 0; ObjectChange *change; for (i = 1; i < stdpath->num_points; ++i) { if (bezier[i].type == BEZ_MOVE_TO || i+1 == stdpath->num_points) { DiaObject *rep; int num = bezier[i].type == BEZ_MOVE_TO ? i - n : i - n + 1; if (stdpath->stroke_or_fill & PDO_FILL) rep = create_standard_beziergon (num, &bezier[n]); else rep = create_standard_bezierline (num, &bezier[n], NULL, NULL); if (!rep) /* no Standard objects? */ break; list = g_list_append (list, rep); n = i; } } if (!list) { change = change_list_create (); } else if (g_list_length (list) == 1) { change = object_substitute (obj, (DiaObject *)list->data); g_list_free (list); } else { change = object_substitute (obj, create_standard_group (list)); } return change; }
//! push the current list of objects to Dia void endPage() { DiaObject *group; g_return_if_fail (objects != NULL); int m = (int)sqrt (num_pages); if (m < 2) m = 2; gchar *name = g_strdup_printf (_("Page %d"), this->pageNum); group = create_standard_group (this->objects); this->objects = NULL; // Group eats list // page advance Point advance = { this->page_width * ((this->pageNum - 1) % m), this->page_height * ((this->pageNum - 1) / m)}; group->ops->move (group, &advance); layer_add_object (this->dia->active_layer, group); dia_object_set_meta (group, "name", name); g_free (name); }
static gboolean fig_read_object(FILE *file, DiaContext *ctx) { int objecttype; DiaObject *item = NULL; if (fscanf(file, "%d ", &objecttype) != 1) { if (!feof(file)) { dia_context_add_message_with_errno(ctx, errno, _("Couldn't identify Fig object.")); } return FALSE; } switch (objecttype) { case -6: { /* End of compound */ if (compound_stack == NULL) { dia_context_add_message(ctx, _("Compound end outside compound\n")); return FALSE; } /* Make group item with these items */ if (g_list_length((GList*)compound_stack->data) > 1) item = create_standard_group((GList*)compound_stack->data); else /* a single item needs no group */ item = (DiaObject *)((GList*)compound_stack->data)->data; compound_stack = g_slist_remove(compound_stack, compound_stack->data); if (compound_stack == NULL) { depths[compound_depth] = g_list_append(depths[compound_depth], item); } break; } case 0: { /* Color pseudo-object. */ int colornumber; int colorvalues; Color color; if (fscanf(file, " %d #%xd", &colornumber, &colorvalues) != 2) { dia_context_add_message_with_errno(ctx, errno, _("Couldn't read color\n")); return FALSE; } if (colornumber < 32 || colornumber > FIG_MAX_USER_COLORS) { dia_context_add_message(ctx, _("Color number %d out of range 0..%d. Discarding color.\n"), colornumber, FIG_MAX_USER_COLORS); return FALSE; } color.red = ((colorvalues & 0x00ff0000)>>16) / 255.0; color.green = ((colorvalues & 0x0000ff00)>>8) / 255.0; color.blue = (colorvalues & 0x000000ff) / 255.0; color.alpha = 1.0; fig_colors[colornumber-32] = color; break; } case 1: { /* Ellipse which is a generalization of circle. */ item = fig_read_ellipse(file, ctx); if (item == NULL) { return FALSE; } break; } case 2: /* Polyline which includes polygon and box. */ item = fig_read_polyline(file, ctx); if (item == NULL) { return FALSE; } break; case 3: /* Spline which includes closed/open control/interpolated spline. */ item = fig_read_spline(file, ctx); if (item == NULL) { return FALSE; } break; case 4: /* Text. */ item = fig_read_text(file, ctx); if (item == NULL) { return FALSE; } break; case 5: /* Arc. */ item = fig_read_arc(file, ctx); if (item == NULL) { return FALSE; } break; case 6: {/* Compound object which is composed of one or more objects. */ int dummy; if (fscanf(file, " %d %d %d %d\n", &dummy, &dummy, &dummy, &dummy) != 4) { dia_context_add_message_with_errno(ctx, errno, _("Couldn't read group extent.")); return FALSE; } /* Group extends don't really matter */ if (compound_stack == NULL) compound_depth = FIG_MAX_DEPTHS - 1; compound_stack = g_slist_append(compound_stack, NULL); return TRUE; break; } default: dia_context_add_message(ctx, _("Unknown object type %d\n"), objecttype); return FALSE; break; } if (compound_stack != NULL && item != NULL) { /* We're building a compound */ GList *compound = (GList *)compound_stack->data; compound = g_list_append(compound, item); compound_stack->data = compound; } return TRUE; }