Commit af0271b0 authored by Jody Goldberg's avatar Jody Goldberg Committed by Jody Goldberg
Browse files

Renamed and moved from here to here. Added support for displaying


2000-11-11  Jody Goldberg <jgoldberg@home.com>

	* src/value.c (value_get_default_halign) : Renamed and moved from here
	* src/cell.c (cell_default_halign) : to here.  Added support for
	  displaying formulas.

	* src/print-cell.c (print_cell) : only draw hash marks for numbers
	  not when displaying formulas.
	* src/cell-draw.c (cell_draw) : Ditto.
	* src/cellspan.c (cell_calc_span) : Ditto.
	* src/rendered-value.c (rendered_value_calc_size_ext) : Ditto.
parent 425743e5
2000-11-11 Jody Goldberg <jgoldberg@home.com>
* src/value.c (value_get_default_halign) : Renamed and moved from here
* src/cell.c (cell_default_halign) : to here. Added support for
displaying formulas.
* src/print-cell.c (print_cell) : only draw hash marks for numbers
not when displaying formulas.
* src/cell-draw.c (cell_draw) : Ditto.
* src/cellspan.c (cell_calc_span) : Ditto.
* src/rendered-value.c (rendered_value_calc_size_ext) : Ditto.
2000-11-11 Jody Goldberg <jgoldberg@home.com>
Patch from Tyler & James Christensen
......
2000-11-11 Jody Goldberg <jgoldberg@home.com>
* src/value.c (value_get_default_halign) : Renamed and moved from here
* src/cell.c (cell_default_halign) : to here. Added support for
displaying formulas.
* src/print-cell.c (print_cell) : only draw hash marks for numbers
not when displaying formulas.
* src/cell-draw.c (cell_draw) : Ditto.
* src/cellspan.c (cell_calc_span) : Ditto.
* src/rendered-value.c (rendered_value_calc_size_ext) : Ditto.
2000-11-11 Jody Goldberg <jgoldberg@home.com>
Patch from Tyler & James Christensen
......
2000-11-11 Jody Goldberg <jgoldberg@home.com>
* src/value.c (value_get_default_halign) : Renamed and moved from here
* src/cell.c (cell_default_halign) : to here. Added support for
displaying formulas.
* src/print-cell.c (print_cell) : only draw hash marks for numbers
not when displaying formulas.
* src/cell-draw.c (cell_draw) : Ditto.
* src/cellspan.c (cell_calc_span) : Ditto.
* src/rendered-value.c (rendered_value_calc_size_ext) : Ditto.
2000-11-11 Jody Goldberg <jgoldberg@home.com>
Patch from Tyler & James Christensen
......
2000-11-11 Jody Goldberg <jgoldberg@home.com>
* src/value.c (value_get_default_halign) : Renamed and moved from here
* src/cell.c (cell_default_halign) : to here. Added support for
displaying formulas.
* src/print-cell.c (print_cell) : only draw hash marks for numbers
not when displaying formulas.
* src/cell-draw.c (cell_draw) : Ditto.
* src/cellspan.c (cell_calc_span) : Ditto.
* src/rendered-value.c (rendered_value_calc_size_ext) : Ditto.
2000-11-11 Jody Goldberg <jgoldberg@home.com>
Patch from Tyler & James Christensen
......
2000-11-11 Jody Goldberg <jgoldberg@home.com>
* src/value.c (value_get_default_halign) : Renamed and moved from here
* src/cell.c (cell_default_halign) : to here. Added support for
displaying formulas.
* src/print-cell.c (print_cell) : only draw hash marks for numbers
not when displaying formulas.
* src/cell-draw.c (cell_draw) : Ditto.
* src/cellspan.c (cell_calc_span) : Ditto.
* src/rendered-value.c (rendered_value_calc_size_ext) : Ditto.
2000-11-11 Jody Goldberg <jgoldberg@home.com>
Patch from Tyler & James Christensen
......
......@@ -113,7 +113,7 @@ html_write_cell32 (FILE *fp, Cell *cell, MStyle *style)
fprintf (fp, "\t<TD");
if (cell) {
switch (value_get_default_halign (cell->value, style)) {
switch (cell_default_halign (cell, style)) {
case HALIGN_RIGHT :
fprintf (fp, " align=right");
break;
......@@ -158,7 +158,7 @@ html_write_cell40 (FILE *fp, Cell *cell, MStyle *style)
fprintf (fp, "\t<TD");
if (cell) {
switch (value_get_default_halign (cell->value, style)) {
switch (value_get_default_halign (cell, style)) {
case HALIGN_RIGHT :
fprintf (fp, " halign=right");
break;
......
......@@ -113,7 +113,7 @@ html_write_cell32 (FILE *fp, Cell *cell, MStyle *style)
fprintf (fp, "\t<TD");
if (cell) {
switch (value_get_default_halign (cell->value, style)) {
switch (cell_default_halign (cell, style)) {
case HALIGN_RIGHT :
fprintf (fp, " align=right");
break;
......@@ -158,7 +158,7 @@ html_write_cell40 (FILE *fp, Cell *cell, MStyle *style)
fprintf (fp, "\t<TD");
if (cell) {
switch (value_get_default_halign (cell->value, style)) {
switch (value_get_default_halign (cell, style)) {
case HALIGN_RIGHT :
fprintf (fp, " halign=right");
break;
......
......@@ -226,7 +226,7 @@ cell_draw (Cell const *cell, MStyle *mstyle, CellSpanInfo const * const spaninfo
break;
}
halign = value_get_default_halign (cell->value, mstyle);
halign = cell_default_halign (cell, mstyle);
is_single_line = (halign != HALIGN_JUSTIFY &&
valign != VALIGN_JUSTIFY &&
......@@ -296,7 +296,8 @@ cell_draw (Cell const *cell, MStyle *mstyle, CellSpanInfo const * const spaninfo
cell_width_pixel = cell_rendered_width (cell);
/* if a number overflows, do special drawing */
if (width < cell_width_pixel && cell_is_number (cell)) {
if (width < cell_width_pixel && cell_is_number (cell) &&
sheet && !sheet->display_formulas) {
draw_overflow (drawable, gc, font,
x1 + ci->margin_a + 1,
text_base, width, line_offset, num_lines);
......
......@@ -12,6 +12,7 @@
#include "cell-comment.h"
#include "expr.h"
#include "eval.h"
#include "value.h"
#include "style.h"
#include "sheet.h"
#include "value.h"
......@@ -632,6 +633,23 @@ 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) {
g_return_val_if_fail (c != NULL, HALIGN_RIGHT);
if (cell_is_number (c) &&
c->base.sheet && !c->base.sheet->display_formulas)
return HALIGN_RIGHT;
return HALIGN_LEFT;
}
return align;
}
/***************************************************************************/
/**
......
......@@ -52,17 +52,18 @@ void cell_content_changed (Cell *cell);
/**
* Cell state checking
*/
gboolean cell_is_blank (Cell const * cell);
Value * cell_is_error (Cell const * cell);
gboolean cell_is_number (Cell const * cell);
gboolean cell_is_zero (Cell const * cell);
ExprArray const * cell_is_array (Cell const * cell);
gboolean cell_is_partial_array (Cell const * cell);
#define cell_needs_recalc(cell) ((cell)->base.flags & DEPENDENT_QUEUED_FOR_RECALC)
#define cell_expr_is_linked(cell) ((cell)->base.flags & DEPENDENT_IN_EXPR_LIST)
#define cell_has_expr(cell) ((cell)->base.flags & CELL_HAS_EXPRESSION)
#define cell_is_linked(cell) ((cell)->base.flags & CELL_IN_SHEET_LIST)
#define cell_has_comment(cell) ((cell)->comment != NULL)
gboolean cell_is_blank (Cell const * cell);
Value * cell_is_error (Cell const * cell);
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
......
......@@ -165,20 +165,20 @@ cell_calc_span (Cell const * const cell, int * const col1, int * const col2)
g_return_if_fail (cell != NULL);
sheet = cell->base.sheet;
/*
* If the cell is a number, or the text fits inside the column, or the
* alignment modes are set to "justify", then we report only one
* column is used.
*/
if (cell_is_number (cell)) {
if (cell_is_number (cell) &&
sheet != NULL && !sheet->display_formulas) {
*col1 = *col2 = cell->pos.col;
return;
}
sheet = cell->base.sheet;
mstyle = cell_get_mstyle (cell);
align = value_get_default_halign (cell->value, mstyle);
align = cell_default_halign (cell, mstyle);
row = cell->pos.row;
if ((cell_contents_fit_inside_column (cell) &&
......
......@@ -373,7 +373,7 @@ print_cell (Cell const *cell, MStyle *mstyle, CellSpanInfo const * const spaninf
break;
}
halign = value_get_default_halign (cell->value, mstyle);
halign = cell_default_halign (cell, mstyle);
is_single_line = (halign != HALIGN_JUSTIFY &&
valign != VALIGN_JUSTIFY &&
......@@ -446,7 +446,8 @@ print_cell (Cell const *cell, MStyle *mstyle, CellSpanInfo const * const spaninf
cell_width_pts = gnome_font_get_width_string (print_font, text);
/* if a number overflows, do special drawing */
if (width < cell_width_pts && cell_is_number (cell)) {
if (width < cell_width_pts && cell_is_number (cell) &&
sheet && !sheet->display_formulas) {
print_overflow (context, print_font,
x1 + ci->margin_a + 1,
text_base, width, line_offset, num_lines);
......
......@@ -166,8 +166,9 @@ rendered_value_calc_size (Cell const *cell)
void
rendered_value_calc_size_ext (Cell const *cell, MStyle *mstyle)
{
Sheet *sheet = cell->base.sheet;
RenderedValue *rv = cell->rendered_value;
StyleFont *style_font = sheet_view_get_style_font (cell->base.sheet, mstyle);
StyleFont *style_font = sheet_view_get_style_font (sheet, mstyle);
GdkFont *gdk_font = style_font_gdk_font (style_font);
int font_height = style_font_get_height (style_font);
int const cell_w = COL_INTERNAL_WIDTH (cell->col_info);
......@@ -180,7 +181,9 @@ rendered_value_calc_size_ext (Cell const *cell, MStyle *mstyle)
text = rv->rendered_text->str;
text_width = gdk_string_measure (gdk_font, text);
if (text_width < cell_w || cell_is_number (cell)) {
if (text_width < cell_w ||
(cell_is_number (cell) &&
sheet != NULL && !sheet->display_formulas)) {
rv->width_pixel = text_width;
rv->height_pixel = font_height;
} else if (mstyle_get_align_h (mstyle) == HALIGN_JUSTIFY ||
......
......@@ -305,7 +305,7 @@ sheet_view_scrollbar_config (SheetView const *sheet_view)
* Make the cell at the edit position visible.
*
* To be called from the "size_allocate" signal handler when the geometry of a
* new sheet view has been configured.
* new sheet view has been configured.
*/
static void
sheet_view_make_edit_pos_visible (SheetView const *sheet_view)
......@@ -934,17 +934,10 @@ sheet_view_get_style_font (const Sheet *sheet, MStyle const * const mstyle)
* display. 72dpi is base size
*/
double const res = application_dpi_to_pixels ();
double zoom;
/*
* If sheet is NULL we default to 1
*/
if (sheet)
zoom = sheet->last_zoom_factor_used;
else
zoom = 1;
/* When previewing sheet can == NULL */
double const zoom = (sheet) ? sheet->last_zoom_factor_used : 1.;
return mstyle_get_font (mstyle, zoom * res);
}
......
......@@ -305,7 +305,7 @@ sheet_view_scrollbar_config (SheetView const *sheet_view)
* Make the cell at the edit position visible.
*
* To be called from the "size_allocate" signal handler when the geometry of a
* new sheet view has been configured.
* new sheet view has been configured.
*/
static void
sheet_view_make_edit_pos_visible (SheetView const *sheet_view)
......@@ -934,17 +934,10 @@ sheet_view_get_style_font (const Sheet *sheet, MStyle const * const mstyle)
* display. 72dpi is base size
*/
double const res = application_dpi_to_pixels ();
double zoom;
/*
* If sheet is NULL we default to 1
*/
if (sheet)
zoom = sheet->last_zoom_factor_used;
else
zoom = 1;
/* When previewing sheet can == NULL */
double const zoom = (sheet) ? sheet->last_zoom_factor_used : 1.;
return mstyle_get_font (mstyle, zoom * res);
}
......
......@@ -808,18 +808,3 @@ value_compare (Value const *a, Value const *b, gboolean case_sensitive)
return TYPE_MISMATCH;
}
}
StyleHAlignFlags
value_get_default_halign (Value const *v, MStyle const *mstyle)
{
StyleHAlignFlags align = mstyle_get_align_h (mstyle);
g_return_val_if_fail (v != NULL, HALIGN_RIGHT);
if (align == HALIGN_GENERAL) {
if (v->type == VALUE_FLOAT || v->type == VALUE_INTEGER)
return HALIGN_RIGHT;
return HALIGN_LEFT;
}
return align;
}
......@@ -139,8 +139,6 @@ Value * value_area_foreach (EvalPos const *ep, Value const *v,
void value_array_set (Value *array, guint col, guint row, Value *v);
void value_array_resize (Value *v, guint width, guint height);
StyleHAlignFlags value_get_default_halign (Value const *v, MStyle const *mstyle);
/* Some utility constants to make sure we all spell correctly */
extern char const *gnumeric_err_NULL;
extern char const *gnumeric_err_DIV0;
......
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