Commit 8bbc5642 authored by Jody Goldberg's avatar Jody Goldberg Committed by Jody Goldberg

handle empty cells at the end when characterizing.


2003-08-17  Jody Goldberg <jody@gnome.org>

	* src/selection.c (characterize_vec) : handle empty cells at the end
	  when characterizing.

2003-08-16  Jody Goldberg <jody@gnome.org>

	http://bugzilla.gnome.org/show_bug.cgi?id=117711
	* src/sheet-view.c (sv_panes_insdel_colrow) : be smarter during
	  deletetion.
	* src/sheet-control-gui.c (scg_resize) : stave off some warnings while
	  unfreezing by not resizing the panes that we're about to delete.
parent 150071e5
......@@ -23,6 +23,8 @@
#include <goffice/graph/gog-axis.h>
#include <goffice/graph/gog-object.h>
#include <goffice/graph/gog-data-set.h>
#include <goffice/graph/gog-view.h>
#include <goffice/graph/gog-renderer.h>
#include <goffice/graph/go-data.h>
#include <gsf/gsf-impl-utils.h>
......@@ -50,6 +52,8 @@ struct _GogAxis {
typedef GogObjectClass GogAxisClass;
static GType gog_axis_view_get_type (void);
static GObjectClass *parent_klass;
enum {
......@@ -135,7 +139,8 @@ gog_axis_class_init (GObjectClass *gobject_klass)
GOG_AXIS_X, GOG_AXIS_TYPES, GOG_AXIS_TYPES, G_PARAM_READWRITE));
gog_object_register_roles (gog_klass, roles, G_N_ELEMENTS (roles));
gog_klass->update = gog_axis_update;
gog_klass->update = gog_axis_update;
gog_klass->view_type = gog_axis_view_get_type ();
}
static void
......@@ -182,6 +187,13 @@ gog_axis_type (GogAxis const *axis)
return axis->type;
}
/**
* gog_axis_add_contributor :
* @axis : #GogAxis
* @contrib : #GogObject (can we relax this to use an interface ?)
*
* Register @contrib as taking part in the negotiation of @axis's bounds.
**/
void
gog_axis_add_contributor (GogAxis *axis, GogObject *contrib)
{
......@@ -191,7 +203,13 @@ gog_axis_add_contributor (GogAxis *axis, GogObject *contrib)
axis->contributors = g_slist_prepend (axis->contributors, contrib);
}
/**
* gog_axis_del_contributor :
* @axis : #GogAxis
* @contrib : #GogObject (can we relax this to use an interface ?)
*
* @contrib no longer takes part in the negotiation of @axis's bounds.
**/
void
gog_axis_del_contributor (GogAxis *axis, GogObject *contrib)
{
......@@ -200,3 +218,57 @@ gog_axis_del_contributor (GogAxis *axis, GogObject *contrib)
axis->contributors = g_slist_remove (axis->contributors, contrib);
}
/**
*
gog_axis_bound_changed (GogAxis *axis, GogObject *contrib,
double low, double high);
**/
void
gog_axis_bound_changed (GogAxis *axis, GogObject *contrib,
double low, double high)
{
g_return_if_fail (GOG_AXIS (axis) != NULL);
g_warning ("%p : bound changed to %g -> %g", axis, low, high);
gog_object_request_update (GOG_OBJECT (axis));
}
/****************************************************************************/
typedef GogView GogAxisView;
typedef GogViewClass GogAxisViewClass;
#define GOG_AXIS_VIEW_TYPE (gog_axis_view_get_type ())
#define GOG_AXIS_VIEW(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GOG_AXIS_VIEW_TYPE, GogAxisView))
#define IS_GOG_AXIS_VIEW(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GOG_AXIS_VIEW_TYPE))
static GogViewClass *aview_parent_klass;
static void
gog_axis_view_size_request (GogView *view, GogViewRequisition *req)
{
GogAxis *axis = GOG_AXIS (view->model);
}
static void
gog_axis_view_render (GogView *view, GogViewAllocation const *bbox)
{
GogAxis *axis = GOG_AXIS (view->model);
(aview_parent_klass->render) (view, bbox);
}
static void
gog_axis_view_class_init (GogAxisViewClass *gview_klass)
{
GogViewClass *view_klass = (GogViewClass *) gview_klass;
aview_parent_klass = g_type_class_peek_parent (gview_klass);
view_klass->size_request = gog_axis_view_size_request;
view_klass->render = gog_axis_view_render;
}
static GSF_CLASS (GogAxisView, gog_axis_view,
gog_axis_view_class_init, NULL,
GOG_VIEW_TYPE)
......@@ -47,6 +47,8 @@ GogAxisType gog_axis_type (GogAxis const *axis);
void gog_axis_add_contributor (GogAxis *axis, GogObject *contrib);
void gog_axis_del_contributor (GogAxis *axis, GogObject *contrib);
void gog_axis_bound_changed (GogAxis *axis, GogObject *contrib,
double low, double high);
G_END_DECLS
......
......@@ -84,7 +84,7 @@ static void
role_plot_post_add (GogObject *parent, GogObject *plot)
{
GogChart *chart = GOG_CHART (parent);
gboolean ok;
gboolean ok = TRUE;
/* APPEND to keep order, there won't be that many */
chart->plots = g_slist_append (chart->plots, plot);
......@@ -93,9 +93,8 @@ role_plot_post_add (GogObject *parent, GogObject *plot)
if (chart->plots->next == NULL)
ok = gog_chart_axis_set_assign (chart,
gog_plot_axis_set_pref (GOG_PLOT (plot)));
else
ok = gog_plot_axis_set_assign (GOG_PLOT (plot),
chart->axis_set);
ok |= gog_plot_axis_set_assign (GOG_PLOT (plot),
chart->axis_set);
/* a quick post condition to keep us on our toes */
g_return_if_fail (ok);
......@@ -433,10 +432,20 @@ gog_chart_view_size_allocate (GogView *view, GogViewAllocation const *allocation
res.h -= outline * 2.;
(cview_parent_klass->size_allocate) (view, &res);
/* position the axis */
for (ptr = view->children; ptr != NULL ; ptr = ptr->next) {
child = ptr->data;
if (child->model->position == GOG_POSITION_SPECIAL &&
IS_GOG_AXIS (child->model)) {
gog_view_size_allocate (child, &view->residual);
}
}
/* overlay all the plots in the residual */
for (ptr = view->children; ptr != NULL ; ptr = ptr->next) {
child = ptr->data;
if (child->model->position == GOG_POSITION_SPECIAL)
if (child->model->position == GOG_POSITION_SPECIAL &&
IS_GOG_PLOT (child->model))
gog_view_size_allocate (child, &view->residual);
}
}
......
......@@ -32,8 +32,6 @@
#include <gsf/gsf-impl-utils.h>
#include <src/gnumeric-i18n.h>
static GType gog_legend_view_get_type (void);
struct _GogLegend {
GogStyledObject base;
......@@ -55,6 +53,8 @@ enum {
LEGEND_SWATCH_PADDING_PTS
};
static GType gog_legend_view_get_type (void);
static GObjectClass *parent_klass;
static void
......
......@@ -381,7 +381,7 @@ gog_plot_axis_set_assign (GogPlot *plot, GogAxisSet axis_set)
GSList *axes = gog_chart_get_axis (chart, type);
if (axes != NULL) {
gog_axis_add_contributor (axes->data, GOG_OBJECT (plot));
plot->axis[GOG_AXIS_TYPES] = axes->data;
plot->axis[type] = axes->data;
g_slist_free (axes);
}
}
......
......@@ -27,6 +27,7 @@
#include "gog-barcol.h"
#include <goffice/graph/gog-view.h>
#include <goffice/graph/gog-renderer.h>
#include <goffice/graph/gog-axis.h>
#include <goffice/graph/gog-theme.h>
#include <goffice/graph/gog-style.h>
#include <goffice/graph/go-data.h>
......@@ -100,6 +101,24 @@ gog_plot1_5d_get_property (GObject *obj, guint param_id,
}
}
static GogAxis *
gog_plot1_5d_get_value_axis (GogPlot1_5d *model)
{
GogPlot1_5dClass *klass = GOG_PLOT1_5D_GET_CLASS (model);
if (klass->swap_x_and_y && (*klass->swap_x_and_y ) (model))
return model->base.axis [GOG_AXIS_X];
return model->base.axis [GOG_AXIS_Y];
}
static GogAxis *
gog_plot1_5d_get_index_axis (GogPlot1_5d *model)
{
GogPlot1_5dClass *klass = GOG_PLOT1_5D_GET_CLASS (model);
if (klass->swap_x_and_y && (*klass->swap_x_and_y ) (model))
return model->base.axis [GOG_AXIS_Y];
return model->base.axis [GOG_AXIS_X];
}
static void
gog_plot1_5d_update (GogObject *obj)
{
......@@ -108,10 +127,14 @@ gog_plot1_5d_update (GogObject *obj)
GogSeries1_5d const *series;
unsigned i, num_elements, num_series;
double **vals, minimum, maximum;
double old_minimum, old_maximum;
unsigned *lengths;
GSList *ptr;
model->minimum = model->maximum = 0.;
minimum = DBL_MAX; /* yes I mean max */
maximum = DBL_MIN;
old_minimum = model->minimum;
old_maximum = model->maximum;
num_elements = num_series = 0;
for (ptr = model->base.series ; ptr != NULL ; ptr = ptr->next) {
series = ptr->data;
......@@ -130,26 +153,37 @@ gog_plot1_5d_update (GogObject *obj)
model->maximum = maximum;
}
}
model->num_elements = num_elements;
if (model->num_elements != num_elements) {
model->num_elements = num_elements;
gog_axis_bound_changed (
gog_plot1_5d_get_index_axis (model), GOG_OBJECT (model),
1, num_elements);
}
model->num_series = num_series;
if (num_elements <= 0 || num_series <= 0)
return;
if (num_elements > 0 && num_series > 0) {
vals = g_alloca (num_series * sizeof (double *));
lengths = g_alloca (num_series * sizeof (unsigned));
i = 0;
for (ptr = model->base.series ; ptr != NULL ; ptr = ptr->next, i++) {
series = ptr->data;
/* we are guaranteed that at least 1 series is valid above */
if (!gog_series_is_valid (GOG_SERIES (series)))
continue;
vals[i] = go_data_vector_get_values (
GO_DATA_VECTOR (series->base.values[1].data));
lengths[i] = go_data_vector_get_len (
GO_DATA_VECTOR (series->base.values[1].data));
}
vals = g_alloca (num_series * sizeof (double *));
lengths = g_alloca (num_series * sizeof (unsigned));
i = 0;
for (ptr = model->base.series ; ptr != NULL ; ptr = ptr->next, i++) {
series = ptr->data;
if (!gog_series_is_valid (GOG_SERIES (series)))
continue;
vals[i] = go_data_vector_get_values (
GO_DATA_VECTOR (series->base.values[1].data));
lengths[i] = go_data_vector_get_len (
GO_DATA_VECTOR (series->base.values[1].data));
}
klass->update_stacked_and_percentage (model, vals, lengths);
} else
model->minimum = model->maximum = 0.;
klass->update_stacked_and_percentage (model, vals, lengths);
if (old_minimum != model->minimum || old_maximum != model->maximum)
gog_axis_bound_changed (
gog_plot1_5d_get_value_axis (model), GOG_OBJECT (model),
model->minimum, model->maximum);
gog_object_emit_changed (GOG_OBJECT (obj), FALSE);
if (plot1_5d_parent_klass->update)
......
......@@ -44,9 +44,10 @@ typedef struct {
typedef struct {
GogPlotClass base;
void (*update_stacked_and_percentage) (GogPlot1_5d *model,
double **vals,
unsigned const *lengths);
gboolean (*swap_x_and_y) (GogPlot1_5d *model);
void (*update_stacked_and_percentage) (GogPlot1_5d *model,
double **vals,
unsigned const *lengths);
} GogPlot1_5dClass;
#define GOG_PLOT1_5D_TYPE (gog_plot1_5d_get_type ())
......
......@@ -105,6 +105,12 @@ gog_barcol_plot_editor (GogObject *item,
return gog_barcol_plot_pref (GOG_BARCOL_PLOT (item), cc);
}
static gboolean
gog_barcol_swap_x_and_y (GogPlot1_5d *model)
{
return GOG_BARCOL_PLOT (model)->horizontal;
}
static void
gog_barcol_update_stacked_and_percentage (GogPlot1_5d *model,
double **vals, unsigned const *lengths)
......@@ -177,6 +183,7 @@ gog_barcol_plot_class_init (GogPlot1_5dClass *gog_plot_1_5d_klass)
plot_klass->desc.series.style_fields = GOG_STYLE_OUTLINE | GOG_STYLE_FILL;
gog_plot_1_5d_klass->swap_x_and_y = gog_barcol_swap_x_and_y;
gog_plot_1_5d_klass->update_stacked_and_percentage =
gog_barcol_update_stacked_and_percentage;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment