Commit 78ec7e2c authored by Jody Goldberg's avatar Jody Goldberg Committed by Jody Goldberg

Add OPER_UNARY_PLUS.

Support hidden rows cols in print preview.

2000-01-18  Jody Goldberg <jgoldberg@home.com>

	* src/expr.c (eval_expr_real) : Add OPER_UNARY_PLUS.
	(do_expr_decode_tree) : Ditto.
	(expr_dump_tree) : Ditto.

	* src/auto-format.c (do_af_suggest) : Add OPER_UNARY_PLUS.

	* src/parser.y (exp -> + exp): treat as OPER_UNARY_PLUS.

	* src/print-cell.c (print_cell_range) : Ignore hidden rows/cols.
parent 67cc9216
2000-01-18 Jody Goldberg <jgoldberg@home.com>
* src/expr.c (eval_expr_real) : Add OPER_UNARY_PLUS.
(do_expr_decode_tree) : Ditto.
(expr_dump_tree) : Ditto.
* src/auto-format.c (do_af_suggest) : Add OPER_UNARY_PLUS.
* src/parser.y (exp -> + exp): treat as OPER_UNARY_PLUS.
* src/print-cell.c (print_cell_range) : Ignore hidden rows/cols.
2000-01-18 Morten Welinder <terra@diku.dk>
* src/expr.c (eval_expr_empty): New function.
......
......@@ -7,8 +7,9 @@ Jody:
* Parse errors in formulas.
* Improve xml export of borders to include cleared borders.
* Improve inter{sheet,book} references.
* Cut/paste bug.
* Clipboard fixes.
* Undo.
* Row/Col hiding.
Morten:
* Revamp the memory handling of the parser.
......
2000-01-18 Jody Goldberg <jgoldberg@home.com>
* src/expr.c (eval_expr_real) : Add OPER_UNARY_PLUS.
(do_expr_decode_tree) : Ditto.
(expr_dump_tree) : Ditto.
* src/auto-format.c (do_af_suggest) : Add OPER_UNARY_PLUS.
* src/parser.y (exp -> + exp): treat as OPER_UNARY_PLUS.
* src/print-cell.c (print_cell_range) : Ignore hidden rows/cols.
2000-01-18 Morten Welinder <terra@diku.dk>
* src/expr.c (eval_expr_empty): New function.
......
2000-01-18 Jody Goldberg <jgoldberg@home.com>
* ms-formula-read.c (ms_excel_parse_formula) : Add OPER_UNARY_PLUS.
* ms-formula-write.c (write_node) : Ditto.
* ms-excel-read.c (get_units_net_of_margins) : Return 1 when faced
with < 0 sized things.
(ms_excel_read_row) : Support hidden rows.
......
......@@ -1120,12 +1120,15 @@ ms_excel_parse_formula (ExcelWorkbook *wb, ExcelSheet *sheet, guint8 const *mem,
break ;
}
case FORMULA_PTG_U_PLUS: /* Discard */
case FORMULA_PTG_U_PLUS:
parse_list_push (&stack,
expr_tree_new_unary (OPER_UNARY_PLUS,
parse_list_pop (&stack)));
break;
case FORMULA_PTG_U_MINUS:
parse_list_push (&stack,
expr_tree_new_unary (OPER_NEG,
expr_tree_new_unary (OPER_UNARY_NEG,
parse_list_pop (&stack)));
break;
......
......@@ -689,7 +689,12 @@ write_node (PolishData *pd, ExprTree *tree)
}
break;
}
case OPER_NEG:
case OPER_UNARY_PLUS:
write_node (pd, tree->u.value);
push_guint8 (pd, FORMULA_PTG_U_PLUS);
break;
case OPER_UNARY_NEG:
write_node (pd, tree->u.value);
push_guint8 (pd, FORMULA_PTG_U_MINUS);
break;
......
2000-01-18 Jody Goldberg <jgoldberg@home.com>
* plugin.c (expr_to_scm) : Add OPER_UNARY_PLUS.
2000-01-14 Jon K Hellan <hellan@acm.org>
* plugin.c (func_scm_apply): Fix typo
......
......@@ -203,7 +203,11 @@ expr_to_scm (ExprTree *expr, CellRef cell_ref)
expr_to_scm(expr->u.binary.value_a, cell_ref),
expr_to_scm(expr->u.binary.value_b, cell_ref));
case OPER_NEG :
case OPER_UNARY_PLUS :
return SCM_LIST2(scm_symbolfrom0str("+"),
expr_to_scm(expr->u.value, cell_ref));
case OPER_UNARY_NEG :
return SCM_LIST2(scm_symbolfrom0str("neg"),
expr_to_scm(expr->u.value, cell_ref));
......
2000-01-18 Jody Goldberg <jgoldberg@home.com>
* lotus-formula.c (functions) : Enable OPER_UNARY_PLUS.
1999-12-23 Michael Meeks <mmeeks@gnu.org>
* lotus.c (read_workbook): comment out format_prefix.
......
......@@ -37,7 +37,7 @@ typedef struct {
} func_struct_t;
func_struct_t functions[] = {
{ 1, 0x08, "-", UNARY, OPER_NEG },
{ 1, 0x08, "-", UNARY, OPER_UNARY_NEG },
{ 2, 0x09, "+", BINOP, OPER_ADD },
{ 2, 0x0A, "-", BINOP, OPER_SUB },
{ 2, 0x0B, "*", BINOP, OPER_MULT },
......@@ -52,7 +52,7 @@ func_struct_t functions[] = {
/* { 2, 0x14, "bit-and", BINOP, OPER_AND },
{ 2, 0x15, "bit-or", BINOP, OPER_OR }, FIXME */
{ 1, 0x16, "NOT", NORMAL, 0 },
/* { 1, 0x17, "+", UNARY, 0 }, */
{ 1, 0x17, "+", UNARY, OPER_UNARY_PLUS },
{ 1, 0x1F, "NA", NORMAL, 0 },
{ 1, 0x20, "ERR", NORMAL, 0 },
{ 1, 0x21, "abs", NORMAL, 0 },
......
2000-01-18 Jody Goldberg <jgoldberg@home.com>
* POTFILES.in : remove the stat plugin.
2000-01-17 Kjartan Maraas <kmaraas@online.no>
* no.po: Updated Norwegian translation.
......
......@@ -7,7 +7,6 @@ plugins/lotus-123/boot.c
plugins/oleo/boot.c
plugins/python/python.c
plugins/sample/plugin-sample.c
plugins/stat/stat.c
plugins/sylk/sylk.c
plugins/text/text-io.c
plugins/xbase/boot.c
......
......@@ -240,7 +240,8 @@ do_af_suggest (const ExprTree *expr, EvalPosition *ppos, char **explicit)
return explicit ? AF_EXPLICIT : AF_UNKNOWN;
}
case OPER_NEG:
case OPER_UNARY_NEG:
case OPER_UNARY_PLUS:
return do_af_suggest (expr->u.value, ppos, explicit);
case OPER_PERCENT:
......
......@@ -864,7 +864,8 @@ eval_expr_real (EvalPosition const * const pos, ExprTree const * const tree)
return value_new_error (pos, _("Unknown operator"));
case OPER_PERCENT:
case OPER_NEG:
case OPER_UNARY_NEG:
case OPER_UNARY_PLUS:
/* Garantees that a != NULL */
a = eval_expr (pos, tree->u.value);
......@@ -878,11 +879,14 @@ eval_expr_real (EvalPosition const * const pos, ExprTree const * const tree)
if (a->type == VALUE_ERROR)
return a;
if (tree->oper == OPER_UNARY_PLUS)
return a;
if (!VALUE_IS_NUMBER (a)){
value_release (a);
return value_new_error (pos, gnumeric_err_VALUE);
}
if (tree->oper == OPER_NEG) {
if (tree->oper == OPER_UNARY_NEG) {
if (a->type == VALUE_INTEGER)
res = value_new_int (-a->v.v_int);
else if (a->type == VALUE_FLOAT)
......@@ -1168,7 +1172,8 @@ do_expr_decode_tree (ExprTree *tree, ParsePosition const *pp,
{ NULL, 0, 0, 0 }, /* Name */
{ NULL, 0, 0, 0 }, /* Constant */
{ NULL, 0, 0, 0 }, /* Var */
{ "-", 5, 0, 0 },
{ "-", 5, 0, 0 }, /* Unary - */
{ "+", 5, 0, 0 }, /* Unary + */
{ "%", 5, 0, 0 },
{ NULL, 0, 0, 0 } /* Array */
};
......@@ -1207,7 +1212,7 @@ do_expr_decode_tree (ExprTree *tree, ParsePosition const *pp,
a = do_expr_decode_tree (tree->u.value, pp, operations[op].prec);
opname = operations[op].name;
if (tree->oper == OPER_NEG) {
if (tree->oper != OPER_PERCENT) {
if (prec <= paren_level)
res = g_strconcat ("(", opname, a, ")", NULL);
else
......@@ -1316,11 +1321,11 @@ do_expr_decode_tree (ExprTree *tree, ParsePosition const *pp,
vstr = value_get_as_string (v);
/* If the number has a sign, pretend that it is the
result of OPER_NEG. It is not clear how we would
result of OPER_UNARY_{NEG,PLUS}. It is not clear how we would
currently get negative numbers here, but some
loader might do it. */
if ((vstr[0] == '-' || vstr[0] == '+') &&
operations[OPER_NEG].prec <= paren_level) {
operations[OPER_UNARY_NEG].prec <= paren_level) {
res = g_strconcat ("(", vstr, ")", NULL);
g_free (vstr);
} else
......@@ -1693,12 +1698,15 @@ expr_dump_tree (const ExprTree *tree)
return;
case OPER_PERCENT:
case OPER_NEG:
case OPER_UNARY_NEG:
case OPER_UNARY_PLUS:
expr_dump_tree (tree->u.value);
if (tree->oper == OPER_PERCENT)
printf ("PERCENT\n");
else
else if (tree->oper == OPER_UNARY_NEG)
printf ("NEGATIVE\n");
else
printf ("POSITIVE\n");
return;
case OPER_ARRAY:
......
......@@ -31,7 +31,8 @@ typedef enum {
OPER_CONSTANT, /* Constant value */
OPER_VAR, /* Cell content lookup (variable) */
OPER_NEG, /* Sign inversion */
OPER_UNARY_NEG, /* Sign inversion */
OPER_UNARY_PLUS, /* Mark as positive */
OPER_PERCENT, /* Percentage (value/100) */
OPER_ARRAY /* Array access */
} Operation;
......@@ -41,7 +42,7 @@ typedef enum {
case OPER_LTE: case OPER_NOT_EQUAL: \
case OPER_ADD: case OPER_SUB: case OPER_MULT: case OPER_DIV: \
case OPER_EXP: case OPER_CONCAT
#define OPER_ANY_UNARY OPER_NEG: case OPER_PERCENT
#define OPER_ANY_UNARY OPER_UNARY_NEG: case OPER_UNARY_PLUS : case OPER_PERCENT
struct _ArrayRef {
int x, y;
......
......@@ -343,15 +343,8 @@ exp: NUMBER { $$ = $1; }
| '(' exp ')' { $$ = $2; }
| exp '%' { $$ = build_unary_op (OPER_PERCENT, $1); }
| '-' exp %prec NEG { $$ = build_unary_op (OPER_NEG, $2); }
| '+' exp %prec PLUS {
/* count(+a1) is 1, if a1 is blank. Treat +a1 as 0+a1. */
unregister_allocation ($2);
$$ = register_expr_allocation (
expr_tree_new_binary (expr_tree_new_constant (value_new_int (0)),
OPER_ADD,
$2));
}
| '-' exp %prec NEG { $$ = build_unary_op (OPER_UNARY_NEG, $2); }
| '+' exp %prec PLUS { $$ = build_unary_op (OPER_UNARY_PLUS, $2); }
| '{' array_cols '}' {
unregister_allocation ($2);
......
......@@ -447,6 +447,10 @@ print_cell_range (GnomePrintContext *context,
for (row = start_row; row <= end_row; row++){
ri = sheet_row_get_info (sheet, row);
/* Ignore hidden rows */
if (ri->pixels < 0)
continue;
x = 0;
for (col = start_col; col <= end_col; col++){
double x1 = base_x + x;
......@@ -455,15 +459,25 @@ print_cell_range (GnomePrintContext *context,
cell = sheet_cell_get (sheet, col, row);
if (cell){
double x2 = x1 + CELL_WIDTH (cell);
double y2 = y1 - CELL_HEIGHT (cell);
double x2;
double y2;
ci = cell->col;
/* Ignore hidden columns */
if (ci->pixels < 0)
continue;
x2 = x1 + CELL_WIDTH (cell);
y2 = y1 - CELL_HEIGHT (cell);
print_cell (context, cell, x1, y1, x2, y2);
} else {
double x2, y2;
ci = sheet_col_get_info (sheet, col);
/* Ignore hidden columns */
if (ci->pixels < 0)
continue;
x2 = x1 + DIM (ci);
y2 = y1 - DIM (ri);
......
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