Commit 131aee7a authored by Jody Goldberg's avatar Jody Goldberg Committed by Jody Goldberg

add validation-combo.h

2006-11-24  Jody Goldberg <jody@gnome.org>

	* src/Makefile.am : add validation-combo.h

	* src/mstyle.c (gnm_style_get_validation) : constify the result.  We
	  should not modify it while it's part of a style.

	* src/sheet-control-gui.c (cb_collect_objects_to_commit) : handle
	  no-view case.
	* src/gnumeric-pane.c (gnm_pane_display_obj_size_tip) : ditto.

	* src/sheet-object.c (sheet_object_clear_sheet) : Handle
	  so::sheet == NULL (eg when data validation combo is cleared from
	  wbv::finalize after content_destroy clears the sheet list)
	  Drop the return flag, nothing was using.

	* src/validation.c (gnm_validation_combo_new) : new.
	(gnm_validation_combo_class_init) : new.
	(gnm_validation_combo_finalize) : new.
	(gnm_validation_combo_init) : new.
	(validation_ref) : allow the reffing of const objects.
	(validation_unref) : ditto, this should really be split into a const
	  and non-const version.  We can do that for all unref routines.

	* src/value.h : create new struct GnmValueIter.
	* src/value.c (gnm_value_get_type) : Make GnmValue a glib boxed type.
	* src/value-sheet.c (value_area_foreach) : rework to use GnmValueIter.
	  All callers changed.

	* src/workbook-view.h : s/::current_format/::current_style/
	  and make it const.  We have a ref to it, so it's not going away
	  _but_ we should never change it.
	  Add validation_combo.  For the sheet object corresponding to an
	  in cell data validation combo.

	* src/workbook-view.c (wb_view_style_feedback) : renamed from
	  wb_view_format_feedback all callers changed.  Add a creation
	  and removal of data validation in cell combo.
	(wb_view_finalize) : clear the validation combo if it exists.
	(workbook_view_new) : init the combo.

2006-11-24  Jody Goldberg <jody@gnome.org>

	* tools/xmlunzip : Add the 'macro enabled' formats from office12
parent 92c6a8c8
......@@ -670,6 +670,12 @@ Short Term Goals
21.27) combo contains start to end of continuous region
not just the end of the selected region
21.28) filter changes should dirty things
21.29) Enter in combo selects the current val (see 22.3)
22) Validate from List
22.1) Implement (DONE)
22.2) Pre-select current value in combo (DONE)
22.3) Enter in combo selects the current val (see 21.29)
29) gconf.
29.1) Check for errors (DONE)
......
2006-11-24 Jody Goldberg <jody@gnome.org>
* src/Makefile.am : add validation-combo.h
2006-11-24 Jody Goldberg <jody@gnome.org>
* src/mstyle.c (gnm_style_get_validation) : constify the result. We
should not modify it while it's part of a style.
* src/sheet-control-gui.c (cb_collect_objects_to_commit) : handle
no-view case.
* src/gnumeric-pane.c (gnm_pane_display_obj_size_tip) : ditto.
* src/sheet-object.c (sheet_object_clear_sheet) : Handle
so::sheet == NULL (eg when data validation combo is cleared from
wbv::finalize after content_destroy clears the sheet list)
Drop the return flag, nothing was using.
* src/validation.c (gnm_validation_combo_new) : new.
(gnm_validation_combo_class_init) : new.
(gnm_validation_combo_finalize) : new.
(gnm_validation_combo_init) : new.
(validation_ref) : allow the reffing of const objects.
(validation_unref) : ditto, this should really be split into a const
and non-const version. We can do that for all unref routines.
* src/value.h : create new struct GnmValueIter.
* src/value.c (gnm_value_get_type) : Make GnmValue a glib boxed type.
* src/value-sheet.c (value_area_foreach) : rework to use GnmValueIter.
All callers changed.
* src/workbook-view.h : s/::current_format/::current_style/
and make it const. We have a ref to it, so it's not going away
_but_ we should never change it.
Add validation_combo. For the sheet object corresponding to an
in cell data validation combo.
* src/workbook-view.c (wb_view_style_feedback) : renamed from
wb_view_format_feedback all callers changed. Add a creation
and removal of data validation in cell combo.
(wb_view_finalize) : clear the validation combo if it exists.
(workbook_view_new) : init the combo.
2006-11-24 Jody Goldberg <jody@gnome.org>
* tools/xmlunzip : Add the 'macro enabled' formats from office12
2006-11-23 Morten Welinder <terra@gnome.org>
* src/xml-sax-write.c (xml_write_styles): Sort style regions so
......
......@@ -5,6 +5,10 @@ Jon Kåre:
Jody:
* Improve xls import/export of bestfit column widths. [#378560]
* Implement Validate from List cell combo. [#375620]
* Fix xls import of checkboxes with empty labels. [#375620]
* Put the style feedback onto an idle handle to improve cursor
responsiveness.
Morten:
* Fix sc import of functions with no args.
......
2006-11-24 Jody Goldberg <jody@gnome.org>
* ms-obj.c (ms_obj_attr_get_ptr) : change signature to better
distiguish between NULL and not-specified.
* ms-excel-read.c (ms_sheet_realize_obj) : Using NULL as the default
was a bad idea. We could not differentiate between empty text which
got stored as NULL, and not specified which should use the default.
Use the new signature to ms_obj_attr_get_ptr to handle this
correctly. (test case : checkboxes in 375620 with no labels)
2006-11-24 Jody Goldberg <jody@gnome.org>
* xlsx-write.c (xlsx_write_col) : set 'bestFit' if the column has a
......
......@@ -373,14 +373,8 @@ ms_sheet_obj_anchor_to_pos (Sheet const * sheet, MsBiffVersion const ver,
static gboolean
ms_sheet_realize_obj (MSContainer *container, MSObj *obj)
{
static SheetObjectAnchorType const anchor_types[4] = {
SO_ANCHOR_PERCENTAGE_FROM_COLROW_START,
SO_ANCHOR_PERCENTAGE_FROM_COLROW_START,
SO_ANCHOR_PERCENTAGE_FROM_COLROW_START,
SO_ANCHOR_PERCENTAGE_FROM_COLROW_START
};
float offsets[4];
char const *label;
gpointer label;
PangoAttrList *markup;
GnmRange range;
ExcelReadSheet *esheet;
......@@ -416,12 +410,11 @@ ms_sheet_realize_obj (MSContainer *container, MSObj *obj)
((flip_v == NULL) ? GOD_ANCHOR_DIR_DOWN : 0);
sheet_object_anchor_init (&anchor, &range,
offsets, anchor_types, direction);
offsets, NULL, direction);
sheet_object_set_anchor (so, &anchor);
sheet_object_set_sheet (so, esheet->sheet);
label = ms_obj_attr_get_ptr (obj->attrs, MS_OBJ_ATTR_TEXT, NULL, FALSE);
if (label != NULL)
if (ms_obj_attr_get_ptr (obj->attrs, MS_OBJ_ATTR_TEXT, &label, FALSE))
g_object_set (G_OBJECT (so), "text", label, NULL);
markup = ms_obj_attr_get_markup (obj->attrs, MS_OBJ_ATTR_MARKUP, NULL, FALSE);
......@@ -581,6 +574,7 @@ ms_sheet_create_obj (MSContainer *container, MSObj *obj)
SheetObject *so = NULL;
Workbook *wb;
ExcelReadSheet *esheet;
gpointer label;
if (obj == NULL)
return NULL;
......@@ -604,9 +598,10 @@ ms_sheet_create_obj (MSContainer *container, MSObj *obj)
case 0x06: /* TextBox */
case 0x0E: /* Label */
so = g_object_new (GNM_SO_FILLED_TYPE,
"text", ms_obj_attr_get_ptr (obj->attrs, MS_OBJ_ATTR_TEXT, NULL, FALSE),
"is-oval", obj->excel_type == 3,
NULL);
if (ms_obj_attr_get_ptr (obj->attrs, MS_OBJ_ATTR_TEXT, &label, FALSE))
g_object_set (G_OBJECT (so), "text", label, NULL);
break;
case 0x05: /* Chart */
......
......@@ -1105,7 +1105,7 @@ excel_write_conditions (BiffPut *bp, ExcelWriteSheet *esheet)
/****************************************************************************/
typedef struct {
GnmValidation *v;
GnmValidation const *v;
GnmInputMsg *msg;
GSList *ranges;
} ValInputPair;
......
......@@ -181,23 +181,23 @@ ms_obj_attr_get_int (MSObjAttrBag *attrs, MSObjAttrID id, gint32 default_value)
return attr->v.v_int;
}
gpointer
gboolean
ms_obj_attr_get_ptr (MSObjAttrBag *attrs, MSObjAttrID id,
gpointer default_value, gboolean steal)
gpointer *res, gboolean steal)
{
MSObjAttr *attr;
gpointer res;
g_return_val_if_fail (attrs != NULL, default_value);
g_return_val_if_fail (id & MS_OBJ_ATTR_IS_PTR_MASK, default_value);
g_return_val_if_fail (attrs != NULL, FALSE);
g_return_val_if_fail (id & MS_OBJ_ATTR_IS_PTR_MASK, FALSE);
attr = ms_obj_attr_bag_lookup (attrs, id);
if (attr == NULL)
return default_value;
res = attr->v.v_ptr;
if (NULL == (attr = ms_obj_attr_bag_lookup (attrs, id)))
return FALSE;
*res = attr->v.v_ptr;
if (steal)
attr->v.v_ptr = NULL;
return res;
return TRUE;
}
GArray *
......
......@@ -111,8 +111,8 @@ guint32 ms_obj_attr_get_uint (MSObjAttrBag *ab, MSObjAttrID id,
guint32 default_value);
gint32 ms_obj_attr_get_int (MSObjAttrBag *ab, MSObjAttrID id,
gint32 default_value);
gpointer ms_obj_attr_get_ptr (MSObjAttrBag *ab, MSObjAttrID id,
gpointer default_value, gboolean steal);
gboolean ms_obj_attr_get_ptr (MSObjAttrBag *ab, MSObjAttrID id,
gpointer *res, gboolean steal);
GArray *ms_obj_attr_get_array (MSObjAttrBag *ab, MSObjAttrID id,
GArray *default_value, gboolean steal);
GnmExprTop const *ms_obj_attr_get_expr (MSObjAttrBag *ab, MSObjAttrID id,
......
......@@ -47,7 +47,7 @@
GNM_PLUGIN_MODULE_HEADER;
#define DAY_SECONDS (3600*24)
#define DATE_CONV(ep) workbook_date_conv (ep->sheet->workbook)
#define DATE_CONV(ep) workbook_date_conv ((ep)->sheet->workbook)
static GnmValue *
make_date (GnmValue *res)
......@@ -1196,34 +1196,31 @@ get_serial_weekday (int serial, int *offset, GODateConventions const *conv)
return serial;
}
typedef struct
{
typedef struct {
int start_serial, end_serial;
int res;
} networkdays_holiday_closure;
static GnmValue *
networkdays_holiday_callback (GnmValue const *v, GnmEvalPos const *ep,
int x, int y, void *user_data)
cb_networkdays_holiday (GnmValueIter const *v_iter,
networkdays_holiday_closure *close)
{
networkdays_holiday_closure * close =
(networkdays_holiday_closure *)user_data;
int serial;
GDate date;
GODateConventions const *conv = DATE_CONV (ep);
GODateConventions const *conv = DATE_CONV (v_iter->ep);
if (VALUE_IS_ERROR (v))
return value_dup (v);
serial = datetime_value_to_serial (v, conv);
if (VALUE_IS_ERROR (v_iter->v))
return value_dup (v_iter->v);
serial = datetime_value_to_serial (v_iter->v, conv);
if (serial <= 0)
return value_new_error_NUM (ep);
return value_new_error_NUM (v_iter->ep);
if (serial < close->start_serial || close->end_serial < serial)
return NULL;
datetime_serial_to_g (&date, serial, conv);
if (!g_date_valid (&date))
return value_new_error_NUM (ep);
return value_new_error_NUM (v_iter->ep);
if (g_date_get_weekday (&date) < G_DATE_SATURDAY)
++close->res;
return NULL;
......@@ -1264,10 +1261,8 @@ gnumeric_networkdays (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
res -= ((res/7)*2); /* Remove weekends */
if (argv[2] != NULL)
value_area_foreach (argv[2], ei->pos,
CELL_ITER_IGNORE_BLANK,
&networkdays_holiday_callback,
&close);
value_area_foreach (argv[2], ei->pos, CELL_ITER_IGNORE_BLANK,
(GnmValueIterFunc) &cb_networkdays_holiday, &close);
res = res - start_offset + end_offset - close.res;
......
......@@ -273,6 +273,7 @@ libspreadsheet_include_HEADERS = \
style-font.h \
symbol.h \
validation.h \
validation-combo.h \
value.h \
workbook.h \
workbook-priv.h \
......
......@@ -476,7 +476,7 @@ clipboard_paste_region (GnmCellRegion const *cr,
sheet_region_queue_recalc (pt->sheet, r);
sheet_flag_status_update_range (pt->sheet, r);
} else
sheet_flag_format_update_range (pt->sheet, r);
sheet_flag_style_update_range (pt->sheet, r);
sheet_range_calc_spans (pt->sheet, r,
(pt->paste_flags & PASTE_FORMATS) ? GNM_SPANCALC_RE_RENDER : GNM_SPANCALC_RENDER);
......
......@@ -1823,7 +1823,7 @@ cmd_format_undo (GnmCommand *cmd,
}
sheet_range_calc_spans (me->cmd.sheet, r, flags);
sheet_flag_format_update_range (me->cmd.sheet, r);
sheet_flag_style_update_range (me->cmd.sheet, r);
}
sheet_redraw_all (me->cmd.sheet, FALSE);
......@@ -1868,7 +1868,7 @@ cmd_format_redo (GnmCommand *cmd, WorkbookControl *wbc)
&os->rows, &os->old_heights);
}
sheet_flag_format_update_range (me->cmd.sheet, r);
sheet_flag_style_update_range (me->cmd.sheet, r);
}
sheet_redraw_all (me->cmd.sheet, FALSE);
sheet_mark_dirty (me->cmd.sheet);
......
2006-11-24 Jody Goldberg <jody@gnome.org>
* cell-format.glade : make 'in cell dropdown' visible now that we
support the feature.
2006-11-20 Jody Goldberg <jody@gnome.org>
* Release 1.7.4
......
......@@ -3519,6 +3519,7 @@
<child>
<widget class="GtkCheckButton" id="validation_in_dropdown">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">I_n-cell dropdown</property>
<property name="use_underline">True</property>
......
......@@ -846,6 +846,7 @@ typedef GnmValue *(*BinOpImplicitIteratorFunc) (GnmEvalPos const *ep,
GnmValue const *b,
gpointer user_data);
typedef struct {
GnmEvalPos const *ep;
GnmValue *res;
GnmValue const *a, *b;
BinOpImplicitIteratorFunc func;
......@@ -861,21 +862,27 @@ typedef struct {
} BinOpImplicitIteratorState;
static GnmValue *
cb_implicit_iter_a_and_b (GnmValue const *v, GnmEvalPos const *ep,
int x, int y, BinOpImplicitIteratorState const *state)
{
state->res->v_array.vals [x][y] = (*state->func) (ep,
value_area_get_x_y (state->a, state->x.a * x, state->y.a * y, ep),
value_area_get_x_y (state->b, state->x.b * x, state->y.b * y, ep),
state->user_data);
cb_implicit_iter_a_and_b (GnmValueIter const *v_iter,
BinOpImplicitIteratorState const *state)
{
state->res->v_array.vals [v_iter->x][v_iter->y] =
(*state->func) (v_iter->ep,
value_area_get_x_y (state->a,
state->x.a * v_iter->x,
state->y.a * v_iter->y, v_iter->ep),
value_area_get_x_y (state->b,
state->x.b * v_iter->x,
state->y.b * v_iter->y, v_iter->ep),
state->user_data);
return NULL;
}
static GnmValue *
cb_implicit_iter_a_to_scalar_b (GnmValue const *v, GnmEvalPos const *ep,
int x, int y, BinOpImplicitIteratorState const *state)
cb_implicit_iter_a_to_scalar_b (GnmValueIter const *v_iter,
BinOpImplicitIteratorState const *state)
{
state->res->v_array.vals [x][y] = (*state->func) (ep,
v, state->b, state->user_data);
state->res->v_array.vals [v_iter->x][v_iter->y] =
(*state->func) (v_iter->ep,
v_iter->v, state->b, state->user_data);
return NULL;
}
......@@ -890,6 +897,7 @@ bin_array_iter_a (GnmEvalPos const *ep,
BinOpImplicitIteratorState iter_info;
/* a must be a cellrange or array, it can not be NULL */
iter_info.ep = ep;
iter_info.func = func;
iter_info.user_data = (gpointer) expr;
iter_info.a = a;
......@@ -922,13 +930,13 @@ bin_array_iter_a (GnmEvalPos const *ep,
iter_info.res = value_new_array_empty (w, h);
value_area_foreach (iter_info.res, ep, CELL_ITER_ALL,
(ValueAreaFunc) cb_implicit_iter_a_and_b, &iter_info);
(GnmValueIterFunc) cb_implicit_iter_a_and_b, &iter_info);
} else {
iter_info.res = value_new_array_empty (
value_area_get_width (a, ep),
value_area_get_height (a, ep));
value_area_foreach (a, ep, CELL_ITER_ALL,
(ValueAreaFunc) cb_implicit_iter_a_to_scalar_b, &iter_info);
(GnmValueIterFunc) cb_implicit_iter_a_to_scalar_b, &iter_info);
}
value_release (a);
......@@ -938,11 +946,12 @@ bin_array_iter_a (GnmEvalPos const *ep,
}
static GnmValue *
cb_implicit_iter_b_to_scalar_a (GnmValue const *v, GnmEvalPos const *ep,
int x, int y, BinOpImplicitIteratorState const *state)
cb_implicit_iter_b_to_scalar_a (GnmValueIter const *v_iter,
BinOpImplicitIteratorState const *state)
{
state->res->v_array.vals [x][y] = (*state->func) (ep,
state->a, v, state->user_data);
state->res->v_array.vals [v_iter->x][v_iter->y] =
(*state->func) (v_iter->ep,
state->a, v_iter->v, state->user_data);
return NULL;
}
static GnmValue *
......@@ -963,7 +972,7 @@ bin_array_iter_b (GnmEvalPos const *ep,
value_area_get_width (b, ep),
value_area_get_height (b, ep));
value_area_foreach (b, ep, CELL_ITER_ALL,
(ValueAreaFunc) cb_implicit_iter_b_to_scalar_a, &iter_info);
(GnmValueIterFunc) cb_implicit_iter_b_to_scalar_a, &iter_info);
if (a != NULL)
value_release (a);
value_release (b);
......@@ -983,9 +992,9 @@ negate_value (GnmValue const *v)
}
static GnmValue *
cb_iter_unary_neg (GnmValue const *v, GnmEvalPos const *ep,
int x, int y, GnmValue *res)
cb_iter_unary_neg (GnmValueIter const *v_iter, GnmValue *res)
{
GnmValue const *v = v_iter->v;
GnmValue *tmp = NULL;
if (VALUE_IS_EMPTY (v))
......@@ -993,9 +1002,9 @@ cb_iter_unary_neg (GnmValue const *v, GnmEvalPos const *ep,
else if (VALUE_IS_ERROR (v))
tmp = value_dup (v);
else if (VALUE_IS_STRING (v)) {
GnmValue *conv = format_match_number
(value_peek_string (v), NULL,
workbook_date_conv (ep->sheet->workbook));
GnmValue *conv = format_match_number (
value_peek_string (v), NULL,
workbook_date_conv (v_iter->ep->sheet->workbook));
if (conv != NULL) {
tmp = negate_value (conv);
value_release (conv);
......@@ -1005,17 +1014,16 @@ cb_iter_unary_neg (GnmValue const *v, GnmEvalPos const *ep,
tmp = negate_value (v);
}
if (!tmp)
tmp = value_new_error_VALUE (ep);
res->v_array.vals[x][y] = tmp;
if (NULL == tmp)
tmp = value_new_error_VALUE (v_iter->ep);
res->v_array.vals[v_iter->x][v_iter->y] = tmp;
return NULL;
}
static GnmValue *
cb_iter_percentage (GnmValue const *v, GnmEvalPos const *ep,
int x, int y, GnmValue *res)
cb_iter_percentage (GnmValueIter const *v_iter, GnmValue *res)
{
GnmValue const *v = v_iter->v;
GnmValue *tmp;
if (VALUE_IS_EMPTY (v))
......@@ -1025,8 +1033,9 @@ cb_iter_percentage (GnmValue const *v, GnmEvalPos const *ep,
else {
GnmValue *conv = NULL;
if (VALUE_IS_STRING (v)) {
conv = format_match_number (value_peek_string (v), NULL,
workbook_date_conv (ep->sheet->workbook));
conv = format_match_number (
value_peek_string (v), NULL,
workbook_date_conv (v_iter->ep->sheet->workbook));
if (conv != NULL)
v = conv;
}
......@@ -1035,13 +1044,13 @@ cb_iter_percentage (GnmValue const *v, GnmEvalPos const *ep,
tmp = value_new_float (value_get_as_float (v) / 100);
value_set_fmt (tmp, go_format_default_percentage ());
} else
tmp = value_new_error_VALUE (ep);
tmp = value_new_error_VALUE (v_iter->ep);
if (conv != NULL)
value_release (conv);
}
res->v_array.vals[x][y] = tmp;
res->v_array.vals[v_iter->x][v_iter->y] = tmp;
return NULL;
}
......@@ -1241,7 +1250,7 @@ gnm_expr_eval (GnmExpr const *expr, GnmEvalPos const *pos,
value_area_get_width (a, pos),
value_area_get_height (a, pos));
value_area_foreach (a, pos, CELL_ITER_ALL,
(ValueAreaFunc) ((GNM_EXPR_GET_OPER (expr) == GNM_EXPR_OP_UNARY_NEG)
(GnmValueIterFunc) ((GNM_EXPR_GET_OPER (expr) == GNM_EXPR_OP_UNARY_NEG)
? cb_iter_unary_neg : cb_iter_percentage),
res);
value_release (a);
......
......@@ -1260,7 +1260,8 @@ set_acetate_coords (GnmPane *pane, SheetObject *so, FooCanvasItem **ctrl_pts,
sov = sheet_object_new_view (so, (SheetObjectViewContainer *)pane);
coords [0] = l; coords [2] = r; coords [1] = t; coords [3] = b;
sheet_object_view_set_bounds (sov, coords, TRUE);
if (NULL != sov)
sheet_object_view_set_bounds (sov, coords, TRUE);
normalize_high_low (r, l);
normalize_high_low (b, t);
}
......
......@@ -1369,7 +1369,7 @@ gnm_style_set_validation (GnmStyle *style, GnmValidation *v)
style->validation = v;
}
GnmValidation *
GnmValidation const *
gnm_style_get_validation (GnmStyle const *style)
{
g_return_val_if_fail (elem_is_set (style, MSTYLE_VALIDATION), NULL);
......
......@@ -141,7 +141,8 @@ void gnm_style_set_contents_hidden (GnmStyle *style, gboolean f);
gboolean gnm_style_get_contents_hidden (GnmStyle const *style);
void gnm_style_set_validation (GnmStyle *style, GnmValidation *v);
GnmValidation *gnm_style_get_validation (GnmStyle const *style);
GnmValidation const *
gnm_style_get_validation (GnmStyle const *style);
void gnm_style_set_hlink (GnmStyle *style, GnmHLink *link);
GnmHLink *gnm_style_get_hlink (GnmStyle const *style);
......
......@@ -2308,7 +2308,8 @@ cb_collect_objects_to_commit (SheetObject *so, double *coords, CollectObjectsDat
if (NULL == sov)
sov = sheet_object_new_view (so, (SheetObjectViewContainer *)pane);
sheet_object_view_set_bounds (sov, pts, TRUE);
if (NULL != sov)
sheet_object_view_set_bounds (sov, pts, TRUE);
}
});
}
......
......@@ -35,7 +35,7 @@
#include "number-match.h"
#include "gutils.h"
#include "sheet-object.h"
#include "gnm-filter-combo.h"
#include "gnm-filter-combo-foo-view.h"
#include <gsf/gsf-impl-utils.h>
#include <glib/gi18n-lib.h>
......@@ -415,14 +415,10 @@ gnm_filter_combo_finalize (GObject *object)
{
GnmFilterCombo *fcombo = GNM_FILTER_COMBO (object);
GObjectClass *parent;
g_return_if_fail (fcombo != NULL);
if (fcombo->cond != NULL) {
gnm_filter_condition_unref (fcombo->cond);
fcombo->cond = NULL;
}
parent = g_type_class_peek (SHEET_OBJECT_TYPE);
parent->finalize (object);
}
......
......@@ -367,24 +367,26 @@ sheet_object_set_sheet (SheetObject *so, Sheet *sheet)
/**
* sheet_object_clear_sheet :
* @so :
* @so : #SheetObject
*
* Removes @so from it's container, unrealizes all views, disconects the
* associated data and unrefs the object
*
* Returns TRUE if there was a problem
**/
gboolean
void
sheet_object_clear_sheet (SheetObject *so)
{
GSList *ptr;
gpointer view_handler;
g_return_val_if_fail (IS_SHEET_OBJECT (so), TRUE);
g_return_val_if_fail (IS_SHEET (so->sheet), TRUE);
g_return_if_fail (IS_SHEET_OBJECT (so));
if (so->sheet == NULL) /* already removed */
return;
g_return_if_fail (IS_SHEET (so->sheet));
ptr = g_slist_find (so->sheet->sheet_objects, so);
g_return_val_if_fail (ptr != NULL, TRUE);
g_return_if_fail (ptr != NULL);
/* clear any pending attempts to create views */
view_handler = g_object_get_data (G_OBJECT (so), "create_view_handler");
......@@ -400,7 +402,7 @@ sheet_object_clear_sheet (SheetObject *so)
if (SO_CLASS (so)->remove_from_sheet &&
SO_CLASS (so)->remove_from_sheet (so))
return TRUE;
return;
so->sheet->sheet_objects = g_slist_remove_link (so->sheet->sheet_objects, ptr);
g_slist_free (ptr);
......@@ -411,8 +413,6 @@ sheet_object_clear_sheet (SheetObject *so)
so->sheet = NULL;
g_object_unref (G_OBJECT (so));
return FALSE;
}
void
......@@ -450,6 +450,9 @@ sheet_object_new_view (SheetObject *so, SheetObjectViewContainer *container)
view = SO_CLASS (so)->new_view (so, container);
if (NULL == view)
return NULL;
g_return_val_if_fail (IS_SHEET_OBJECT_VIEW (view), NULL);
/* Store some useful information */
......
......@@ -71,7 +71,7 @@ GType sheet_object_exportable_get_type (void);
gboolean sheet_object_set_sheet (SheetObject *so, Sheet *sheet);
Sheet *sheet_object_get_sheet (SheetObject const *so);
gboolean sheet_object_clear_sheet (SheetObject *so);
void sheet_object_clear_sheet (SheetObject *so);
SheetObject *sheet_object_dup (SheetObject const *so);
gboolean sheet_object_can_print (SheetObject const *so);
......
......@@ -240,7 +240,7 @@ sheet_view_init (GObject *object)
sv->edit_pos_changed.location = TRUE;
sv->edit_pos_changed.content = TRUE;
sv->edit_pos_changed.format = TRUE;
sv->edit_pos_changed.style = TRUE;
sv->selection_content_changed = TRUE;
sv->reposition_selection = TRUE;
sv->auto_expr_timer = 0;
......@@ -479,7 +479,7 @@ sv_set_edit_pos (SheetView *sv, GnmCellPos const *pos)
sv->edit_pos_changed.location =
sv->edit_pos_changed.content =
sv->edit_pos_changed.format = TRUE;
sv->edit_pos_changed.style = TRUE;
/* Redraw before change */
if (merged == NULL) {
......@@ -531,7 +531,7 @@ sv_flag_status_update_pos (SheetView *sv, GnmCellPos const *pos)
*/
if (pos->col == sv->edit_pos.col && pos->row == sv->edit_pos.row)
sv->edit_pos_changed.content =
sv->edit_pos_changed.format = TRUE;
sv->edit_pos_changed.style = TRUE;
}
/**
......@@ -556,7 +556,7 @@ sv_flag_status_update_range (SheetView *sv, GnmRange const *range)
sv->selection_content_changed = TRUE;
sv->edit_pos_changed.location =
sv->edit_pos_changed.content =
sv->edit_pos_changed.format = TRUE;
sv->edit_pos_changed.style = TRUE;
return;
}
......@@ -570,23 +570,23 @@ sv_flag_status_update_range (SheetView *sv, GnmRange const *range)
* and the format toolbar
*/
if (range_contains (range, sv->edit_pos.col, sv->edit_pos.row))
sv->edit_pos_changed.content = sv->edit_pos_changed.format = TRUE;
sv->edit_pos_changed.content = sv->edit_pos_changed.style = TRUE;
}
/**
* sv_flag_format_update_range :
* sv_flag_style_update_range :
* @sheet : The sheet being changed
* @range : the range that is changing.
*
* Flag format changes that will require updating the format indicators.
* Flag style changes that will require updating the style indicators.
*/
void
sv_flag_format_update_range (SheetView *sv, GnmRange const *range)
sv_flag_style_update_range (SheetView *sv, GnmRange const *range)
{
g_return_if_fail (IS_SHEET_VIEW (sv));
g_return_if_fail (range != NULL);
if (range_contains (range, sv->edit_pos.col, sv->edit_pos.row))
sv->edit_pos_changed.format = TRUE;
sv->edit_pos_changed.style = TRUE;
}
/**
......@@ -615,10 +615,10 @@ sv_update (SheetView *sv)
wb_view_edit_line_set (sv->sv_wbv, NULL);
}
if (sv->edit_pos_changed.format) {
sv->edit_pos_changed.format = FALSE;
if (sv->edit_pos_changed.style ) {
sv->edit_pos_changed.style = FALSE;
if (wb_view_cur_sheet_view (sv->sv_wbv) == sv)
wb_view_format_feedback (sv->sv_wbv);
wb_view_style_feedback (sv->sv_wbv);
}
if (sv->edit_pos_changed.location) {
......
......@@ -54,7 +54,7 @@ struct _SheetView {
struct {
unsigned char location;
unsigned char content; /* entered content NOT value */
unsigned char format;
unsigned char style;
} edit_pos_changed;
guint auto_expr_timer;
};
......@@ -87,7 +87,7 @@ gboolean sv_is_region_empty_or_selected (SheetView const *sv,
/* Manipulation */
void sv_flag_status_update_pos (SheetView *sv, GnmCellPos const *pos);
void sv_flag_status_update_range (SheetView *sv, GnmRange const *r);
void sv_flag_format_update_range (SheetView *sv, GnmRange const *r);
void sv_flag_style_update_range (SheetView *sv, GnmRange const *r);