Commit a0aaf6ad authored by Jody Goldberg's avatar Jody Goldberg Committed by Jody Goldberg

Move the #define wrapper out here.


2001-04-26  Jody Goldberg <jgoldberg@home.com>

	* src/mathfunc.h (FINITE) : Move the #define wrapper out here.

	* src/cell.c : prune some includes
	(cell_default_halign) : rename to
	* src/style.c (style_default_halign) : to simplify headers for systems
	  that do not support fwd declarations of enums. H - cough - PUX
parent fa079372
......@@ -14,6 +14,8 @@ Release Critical
merged cells.
- Get the i18n XL patches verified and in
: smarter support for unicode characters that do not convert to the
current encoding.
- Fix XL named expr import for sheet local names
......@@ -77,12 +79,7 @@ Long term breakage
flashing when entering data quickly.
- The currency list in the format dialog needs to be sorted for the locale
- When applying a currency symbol we need to store the NON-localized id.
- Increase/Decrease precision toolbar buttons should look at the displayed
precision for the edit cell and assign the changed value to the entire
selection. Not individually adjusting each non-blank cell's precision.
This would mirror the application of bold/italic/underline
- Moreover, the above buttons ought to work. Try "44", click $, then add
and remove decimals.
- Inc/Dec precision should work. Try "44", click $, then add/remove decimals.
- While we're playing with those functions, let's add simple ones like inc/dec
font size and things like that.
......
2001-04-26 Jody Goldberg <jgoldberg@home.com>
* src/mathfunc.h (FINITE) : Move the #define wrapper out here.
* src/cell.c : prune some includes
(cell_default_halign) : rename to
* src/style.c (style_default_halign) : to simplify headers for systems
that do not support fwd declarations of enums. H - cough - PUX
2001-04-26 Morten Welinder <terra@diku.dk>
* src/stf-parse.c: Put a decisive end to the signed-vs-unsigned
......@@ -14,6 +23,9 @@
* src/item-grid.c (item_grid_class_init) : Drat part of a canceled
patch slipped in.
* src/ranges.c (range_is_sane) : new function.
(sheet_merge_add) : use it here.
2001-04-26 Jon K Hellan <hellan@acm.org>
* src/item-grid.c (item_grid_draw_background): Fix typo.
......
......@@ -13,8 +13,9 @@ Jody:
* Fix array intercept checking.
* Some fine tuning to improve start and exit times.
* Merge cell & hidden column interactions
* Some XL import improvement when parsing objects.
* Improve XL95 export
* Some XL import improvement when parsing objects
* Improve XL95 export and include merged regions
* More system portability enhancements.
Jon Kåre:
* New architecture for selecting cell ranges into dialogs.
......
2001-04-26 Jody Goldberg <jgoldberg@home.com>
* src/mathfunc.h (FINITE) : Move the #define wrapper out here.
* src/cell.c : prune some includes
(cell_default_halign) : rename to
* src/style.c (style_default_halign) : to simplify headers for systems
that do not support fwd declarations of enums. H - cough - PUX
2001-04-26 Morten Welinder <terra@diku.dk>
* src/stf-parse.c: Put a decisive end to the signed-vs-unsigned
......@@ -14,6 +23,9 @@
* src/item-grid.c (item_grid_class_init) : Drat part of a canceled
patch slipped in.
* src/ranges.c (range_is_sane) : new function.
(sheet_merge_add) : use it here.
2001-04-26 Jon K Hellan <hellan@acm.org>
* src/item-grid.c (item_grid_draw_background): Fix typo.
......
2001-04-26 Jody Goldberg <jgoldberg@home.com>
* src/mathfunc.h (FINITE) : Move the #define wrapper out here.
* src/cell.c : prune some includes
(cell_default_halign) : rename to
* src/style.c (style_default_halign) : to simplify headers for systems
that do not support fwd declarations of enums. H - cough - PUX
2001-04-26 Morten Welinder <terra@diku.dk>
* src/stf-parse.c: Put a decisive end to the signed-vs-unsigned
......@@ -14,6 +23,9 @@
* src/item-grid.c (item_grid_class_init) : Drat part of a canceled
patch slipped in.
* src/ranges.c (range_is_sane) : new function.
(sheet_merge_add) : use it here.
2001-04-26 Jon K Hellan <hellan@acm.org>
* src/item-grid.c (item_grid_draw_background): Fix typo.
......
2001-04-26 Jody Goldberg <jgoldberg@home.com>
* src/mathfunc.h (FINITE) : Move the #define wrapper out here.
* src/cell.c : prune some includes
(cell_default_halign) : rename to
* src/style.c (style_default_halign) : to simplify headers for systems
that do not support fwd declarations of enums. H - cough - PUX
2001-04-26 Morten Welinder <terra@diku.dk>
* src/stf-parse.c: Put a decisive end to the signed-vs-unsigned
......@@ -14,6 +23,9 @@
* src/item-grid.c (item_grid_class_init) : Drat part of a canceled
patch slipped in.
* src/ranges.c (range_is_sane) : new function.
(sheet_merge_add) : use it here.
2001-04-26 Jon K Hellan <hellan@acm.org>
* src/item-grid.c (item_grid_draw_background): Fix typo.
......
2001-04-26 Jody Goldberg <jgoldberg@home.com>
* src/mathfunc.h (FINITE) : Move the #define wrapper out here.
* src/cell.c : prune some includes
(cell_default_halign) : rename to
* src/style.c (style_default_halign) : to simplify headers for systems
that do not support fwd declarations of enums. H - cough - PUX
2001-04-26 Morten Welinder <terra@diku.dk>
* src/stf-parse.c: Put a decisive end to the signed-vs-unsigned
......@@ -14,6 +23,9 @@
* src/item-grid.c (item_grid_class_init) : Drat part of a canceled
patch slipped in.
* src/ranges.c (range_is_sane) : new function.
(sheet_merge_add) : use it here.
2001-04-26 Jon K Hellan <hellan@acm.org>
* src/item-grid.c (item_grid_draw_background): Fix typo.
......
......@@ -267,7 +267,7 @@ cell_draw (Cell const *cell, MStyle const *mstyle,
return;
}
halign = cell_default_halign (cell, mstyle);
halign = style_default_halign (mstyle, cell);
if (halign == HALIGN_CENTER_ACROSS_SELECTION || h_center <= 0)
h_center = width / 2;
......
......@@ -8,18 +8,15 @@
#include "config.h"
#include "gnumeric.h"
#include "cell.h"
#include "cellspan.h"
#include "sheet.h"
#include "expr.h"
#include "eval.h"
#include "rendered-value.h"
#include "value.h"
#include "style.h"
#include "sheet.h"
#include "sheet-style.h"
#include "rendered-value.h"
#include "gnumeric-util.h"
#include "parse-util.h"
#include "format.h"
#include "sheet-object-cell-comment.h"
#include "eval.h"
#include "sheet-style.h"
extern int dependency_debugging;
......@@ -607,43 +604,6 @@ cell_is_partial_array (Cell const *cell)
return ref != NULL && (ref->cols > 1 || ref->rows > 1);
}
StyleHAlignFlags
cell_default_halign (Cell const *c, MStyle const *mstyle)
{
StyleHAlignFlags align = mstyle_get_align_h (mstyle);
if (align == HALIGN_GENERAL) {
Value *v;
g_return_val_if_fail (c != NULL, HALIGN_RIGHT);
if (c->base.sheet && c->base.sheet->display_formulas &&
cell_has_expr (c))
return HALIGN_LEFT;
for (v = c->value; v != NULL ; )
switch (v->type) {
case VALUE_BOOLEAN :
return HALIGN_CENTER;
case VALUE_INTEGER :
case VALUE_FLOAT :
return HALIGN_RIGHT;
case VALUE_ARRAY :
if (v->v_array.x > 0 && v->v_array.y > 0) {
v = v->v_array.vals [0][0];
break;
}
default :
return HALIGN_LEFT;
}
}
return align;
}
/***************************************************************************/
/**
......
......@@ -63,7 +63,6 @@ gboolean cell_is_number (Cell const *cell);
gboolean cell_is_zero (Cell const *cell);
gboolean cell_is_partial_array (Cell const *cell);
ExprArray const *cell_is_array (Cell const *cell);
StyleHAlignFlags cell_default_halign (Cell const *v, MStyle const *mstyle);
/**
* Utilities to assign the contents of a cell
......
......@@ -215,7 +215,7 @@ cell_calc_span (Cell const * const cell, int * const col1, int * const col2)
}
mstyle = cell_get_mstyle (cell);
align = cell_default_halign (cell, mstyle);
align = style_default_halign (mstyle, cell);
row = cell->pos.row;
indented_w = cell_width_pixel = cell_rendered_width (cell);
if (align == HALIGN_LEFT || align == HALIGN_RIGHT)
......
......@@ -2187,7 +2187,7 @@ cmd_paste_cut_redo (GnumericCommand *cmd, WorkbookControl *wbc)
g_free (r);
}
range_check_sanity (&tmp);
range_ensure_sanity (&tmp);
sheet_move_range (wbc, &me->info, &me->reloc_storage);
......
2001-04-26 Jody Goldberg <jgoldberg@home.com>
* dialog-goal-seek.c (goal_seek_eval) : Merge in some of boc's
portability patch.
2001-04-26 Morten Welinder <terra@diku.dk>
* dialog-solver.c (dialog_solver): Plug leak.
......
......@@ -21,6 +21,7 @@
#include "workbook.h"
#include "utils-dialog.h"
#include "goal-seek.h"
#include "mathfunc.h"
#ifdef HAVE_IEEEFP_H
#include <ieeefp.h>
#endif
......@@ -54,7 +55,7 @@ goal_seek_eval (gnum_float x, gnum_float *y, void *vevaldata)
if (evaldata->ycell->value) {
*y = value_get_as_float (evaldata->ycell->value) - evaldata->ytarget;
if (finite (*y))
if (FINITE (*y))
return GOAL_SEEK_OK;
}
......
......@@ -1574,7 +1574,7 @@ format_value (StyleFormat *format, const Value *value, StyleColor **color,
switch (value->type){
case VALUE_FLOAT:
if (!finite (value->v_float.val))
if (!FINITE (value->v_float.val))
return g_strdup (gnumeric_err_VALUE);
if (is_general) {
......
......@@ -61,7 +61,6 @@ typedef struct _Range Range;
typedef struct _RangeRef RangeRef;
typedef struct _MStyle MStyle;
typedef enum _MStyleElementType MStyleElementType;
typedef struct _SheetStyleData SheetStyleData;
typedef struct _StyleRegion StyleRegion;
......@@ -76,12 +75,6 @@ typedef struct _String String;
typedef struct _DependencyData DependencyData;
typedef enum _StyleHAlignFlags StyleHAlignFlags;
typedef enum _StyleVAlignFlags StyleVAlignFlags;
typedef enum _StyleOrientation StyleOrientation;
typedef enum _StyleBorderLocation StyleBorderLocation;
typedef enum _StyleUnderlineType StyleUnderlineType;
typedef struct _StyleFormat StyleFormat;
typedef struct _StyleFont StyleFont;
typedef struct _StyleColor StyleColor;
......
......@@ -42,10 +42,6 @@
#define ISNAN isnan
#endif
#ifndef FINITE
#define FINITE finite
#endif
/* Any better idea for a quick hack? */
#define ML_NAN (0.0 / 0.0)
#define ML_NEGINF (-1.0 / 0.0)
......@@ -91,7 +87,7 @@ d1mach (int i)
static double
gnumeric_add_epsilon (double x)
{
if (!finite (x) || x == 0)
if (!FINITE (x) || x == 0)
return x;
else {
int exp;
......@@ -711,7 +707,7 @@ double pnorm(double x, double mu, double sigma)
}
x = (x - mu) / sigma;
#ifdef IEEE_754
if(!finite(x)) {
if(!FINITE (x)) {
if(x < 0) return 0;
else return 1;
}
......@@ -1373,7 +1369,7 @@ double qgamma(double p, double alpha, double scale)
p1 = 0.5*ch;
p2 = p - pgamma(p1, alpha, 1);
#ifdef IEEE_754
if(!finite(p2))
if(!FINITE (p2))
#else
if(errno != 0)
#endif
......@@ -1759,7 +1755,7 @@ double lbeta(double a, double b)
return ML_POSINF;
}
#ifdef IEEE_754
else if (!FINITE(q)) {
else if (!FINITE (q)) {
return ML_NEGINF;
}
#endif
......@@ -2080,7 +2076,7 @@ double qbeta(double alpha, double p, double q)
y = pbeta_raw(xinbta, pp, qq);
/* y = pbeta_raw2(xinbta, pp, qq, logbeta) -- to SAVE CPU; */
#ifdef IEEE_754
if(!FINITE(y))
if(!FINITE (y))
#else
if (errno)
#endif
......@@ -2159,9 +2155,9 @@ double pt(double x, double n)
return ML_NAN;
}
#ifdef IEEE_754
if(!finite(x))
if(!FINITE (x))
return (x < 0) ? 0 : 1;
if(!finite(n))
if(!FINITE (n))
return pnorm(x, 0.0, 1.0);
#endif
if (n > 4e5) { /*-- Fixme(?): test should depend on `n' AND `x' ! */
......@@ -2502,7 +2498,7 @@ double dweibull(double x, double shape, double scale)
}
if (x <= 0) return 0;
#ifdef IEEE_754
if (!finite(x)) return 0;
if (!FINITE (x)) return 0;
#endif
tmp1 = pow(x / scale, shape - 1);
tmp2 = tmp1 * (x / scale);
......@@ -2555,7 +2551,7 @@ double ppois(double x, double lambda)
if (x < 0)
return 0;
#ifdef IEEE_754
if (!finite(x))
if (!FINITE (x))
return 1;
#endif
return 1 - pgamma(lambda, x + 1, 1.0);
......@@ -2607,7 +2603,7 @@ double dpois(double x, double lambda)
if (x < 0)
return 0;
#ifdef IEEE_754
if(!finite(x))
if(!FINITE (x))
return 0;
#endif
return exp(x * log(lambda) - lambda - lgammafn(x + 1));
......@@ -2650,7 +2646,7 @@ double pbinom(double x, double n, double p)
#ifdef IEEE_754
if (ISNAN(x) || ISNAN(n) || ISNAN(p))
return x + n + p;
if (!FINITE(n) || !FINITE(p)) {
if (!FINITE (n) || !FINITE (p)) {
ML_ERROR(ME_DOMAIN);
return ML_NAN;
}
......@@ -2768,7 +2764,7 @@ double qbinom(double x, double n, double p)
#ifdef IEEE_754
if (ISNAN(x) || ISNAN(n) || ISNAN(p))
return x + n + p;
if(!FINITE(x) || !FINITE(n) || !FINITE(p)) {
if(!FINITE (x) || !FINITE (n) || !FINITE (p)) {
ML_ERROR(ME_DOMAIN);
return ML_NAN;
}
......
......@@ -5,6 +5,14 @@
#include <math.h>
#include <glib.h>
#ifndef FINITE
# ifdef finite
# define FINITE finite
# elif defined(isfinite)
# define FINITE isfinite
# endif
#endif
#ifdef qgamma
/* It was reported that mips-sgi-irix6.5 has a weird and conflicting define
for qgamma. See bug 1689. */
......
......@@ -7,7 +7,7 @@
/*
* Keep element_size up to date.
*/
enum _MStyleElementType {
typedef enum _MStyleElementType {
/* Delimiter */
MSTYLE_ELEMENT_UNSET = 0,
/* When there is a conflict in a merge */
......@@ -46,7 +46,7 @@ enum _MStyleElementType {
MSTYLE_WRAP_TEXT,
/* Delimiter */
MSTYLE_ELEMENT_MAX
};
} MStyleElementType;
MStyle *mstyle_new (void);
MStyle *mstyle_new_default (void);
......
......@@ -523,7 +523,7 @@ print_cell (Cell const *cell, MStyle const *mstyle, GnomePrintContext *context,
return;
}
halign = cell_default_halign (cell, mstyle);
halign = style_default_halign (mstyle, cell);
if (halign == HALIGN_CENTER_ACROSS_SELECTION || h_center <= 0.)
h_center = width / 2.;
......
......@@ -1084,20 +1084,20 @@ range_translate (Range *range, int col_offset, int row_offset)
range->start.row >= SHEET_MAX_ROWS || range->end.row < 0)
return TRUE;
range_check_sanity (range);
range_ensure_sanity (range);
return FALSE;
}
/**
* range_check_sanity :
* range_ensure_sanity :
* @range : the range to check
*
* Silently clip a range to ensure that it does not contain areas
* outside the valid bounds
* outside the valid bounds. Does NOT fix inverted ranges.
*/
void
range_check_sanity (Range *range)
range_ensure_sanity (Range *range)
{
if (range->start.col < 0)
range->start.col = 0;
......@@ -1109,6 +1109,28 @@ range_check_sanity (Range *range)
range->end.row = SHEET_MAX_ROWS-1;
}
/**
* range_is_sane :
* @range : the range to check
*
* Generate warnings if the range is out of bounds or inverted.
*/
gboolean
range_is_sane (Range const *range)
{
g_return_val_if_fail (range != NULL, FALSE);
g_return_val_if_fail (range->start.col >= 0, FALSE);
g_return_val_if_fail (range->end.col >= range->start.col, FALSE);
g_return_val_if_fail (range->end.col <= SHEET_MAX_COLS, FALSE);
g_return_val_if_fail (range->start.row >= 0, FALSE);
g_return_val_if_fail (range->end.row >= range->start.row, FALSE);
g_return_val_if_fail (range->end.row <= SHEET_MAX_ROWS, FALSE);
return TRUE;
}
gboolean
range_is_sane (Range const *range);
/**
* range_transpose:
* @range: The range.
......
......@@ -89,7 +89,8 @@ gboolean range_intersection (Range *r,
const Range *b);
void range_normalize (Range *src);
Range range_union (const Range *a, const Range *b);
void range_check_sanity (Range *range);
void range_ensure_sanity (Range *range);
gboolean range_is_sane (Range const *range);
gboolean range_translate (Range *range, int col_offset, int row_offset);
gboolean range_transpose (Range *range, const CellPos *origin);
gboolean range_expand (Range *range,
......
......@@ -65,7 +65,7 @@ sheet_merge_add (WorkbookControl *wbc,
MStyle *style;
g_return_val_if_fail (IS_SHEET (sheet), TRUE);
g_return_val_if_fail (r != NULL, TRUE);
g_return_val_if_fail (range_is_sane (r), TRUE);
if (sheet_range_splits_array (sheet, r, wbc, _("Merge")))
return TRUE;
......
......@@ -34,7 +34,7 @@ typedef enum {
/* The order corresponds to the border_buttons name list
* in dialog_cell_format_impl */
enum _StyleBorderLocation {
typedef enum _StyleBorderLocation {
STYLE_BORDER_TOP, STYLE_BORDER_BOTTOM,
STYLE_BORDER_LEFT, STYLE_BORDER_RIGHT,
STYLE_BORDER_REV_DIAG, STYLE_BORDER_DIAG,
......@@ -46,7 +46,7 @@ enum _StyleBorderLocation {
STYLE_BORDER_HORIZ, STYLE_BORDER_VERT,
STYLE_BORDER_EDGE_MAX
};
} StyleBorderLocation;
struct _StyleBorder {
/* Key elements */
......
......@@ -15,6 +15,8 @@
#include "application.h"
#include "gnumeric-util.h"
#include "sheet.h"
#include "cell.h"
#include "value.h"
#include <gal/widgets/e-colors.h>
......@@ -381,3 +383,48 @@ required_updates_for_style (MStyle *style)
: SPANCALC_SIMPLE;
}
/**
* style_default_halign :
* @style :
* @cell :
*
* Select the appropriate horizontal alignment depending on the style and cell
* value.
*/
StyleHAlignFlags
style_default_halign (MStyle const *mstyle, Cell const *c)
{
StyleHAlignFlags align = mstyle_get_align_h (mstyle);
if (align == HALIGN_GENERAL) {
Value *v;
g_return_val_if_fail (c != NULL, HALIGN_RIGHT);
if (c->base.sheet && c->base.sheet->display_formulas &&
cell_has_expr (c))
return HALIGN_LEFT;
for (v = c->value; v != NULL ; )
switch (v->type) {
case VALUE_BOOLEAN :
return HALIGN_CENTER;
case VALUE_INTEGER :
case VALUE_FLOAT :
return HALIGN_RIGHT;
case VALUE_ARRAY :
/* Tail recurse into the array */
if (v->v_array.x > 0 && v->v_array.y > 0) {
v = v->v_array.vals [0][0];
break;
}
default :
return HALIGN_LEFT;
}
}
return align;
}
......@@ -9,7 +9,7 @@
#define DEFAULT_SIZE 9.0
/* Alignment definitions */
enum _StyleHAlignFlags {
typedef enum _StyleHAlignFlags {
HALIGN_GENERAL = 0x01,
HALIGN_LEFT = 0x02,
HALIGN_RIGHT = 0x04,
......@@ -17,27 +17,27 @@ enum _StyleHAlignFlags {
HALIGN_FILL = 0x10,
HALIGN_JUSTIFY = 0x20,
HALIGN_CENTER_ACROSS_SELECTION = 0x40
};
} StyleHAlignFlags;
enum _StyleVAlignFlags {
typedef enum _StyleVAlignFlags {
VALIGN_TOP = 1,