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

handle outline width for text boxes. ditto.


2004-03-06  Jody Goldberg <jody@gnome.org>

	* ms-obj.c (ms_obj_read_pre_biff8_obj) : handle outline width for text
	  boxes.
	* ms-excel-read.c (ms_sheet_create_obj) : ditto.
parent 09ad1ad2
......@@ -10,7 +10,6 @@ Release Critical
http://bugzilla.gnome.org/show_bug.cgi?id=127203 [x axis child pos]
: X axis label seperation
: box colors and warnings in christ95.xls
The Insert menu has an "Insert" entry. (Which is named thusly because it
is also edit->sheet->insert.)
......
2004-03-06 Jody Goldberg <jody@gnome.org>
* ms-obj.c (ms_obj_read_pre_biff8_obj) : handle outline width for text
boxes.
* ms-excel-read.c (ms_sheet_create_obj) : ditto.
2004-03-06 Jody Goldberg <jody@gnome.org>
* ms-obj.c (ms_obj_attr_new_markup) : new.
......
......@@ -470,9 +470,12 @@ ms_sheet_create_obj (MSContainer *container, MSObj *obj)
/* default is None */
gnm_so_graphic_set_fill_color (so, NULL);
/* default is none */
gnm_so_filled_set_outline_style (so,
ms_obj_attr_get_int (obj, MS_OBJ_ATTR_OUTLINE_STYLE, 0));
gnm_so_filled_set_outline_color (so,
ms_sheet_map_color (esheet, obj, MS_OBJ_ATTR_OUTLINE_COLOR));
gnm_so_graphic_set_width (so,
ms_obj_attr_get_int (obj, MS_OBJ_ATTR_OUTLINE_WIDTH, 0));
gnm_so_text_set_markup (so,
ms_obj_attr_get_markup (obj, MS_OBJ_ATTR_MARKUP, NULL));
......
......@@ -496,24 +496,32 @@ ms_obj_read_pre_biff8_obj (BiffQuery *q, MSContainer *container, MSObj *obj)
ms_obj_attr_new_uint (MS_OBJ_ATTR_FILL_COLOR,
0x80000000 | GSF_LE_GET_GUINT8 (q->data+35)));
}
tmp = GSF_LE_GET_GUINT8 (q->data+39);
ms_obj_attr_bag_insert (obj->attrs,
ms_obj_attr_new_uint (MS_OBJ_ATTR_OUTLINE_STYLE,
((tmp == 0xff) ? 0 : tmp+1)));
ms_obj_attr_bag_insert (obj->attrs,
ms_obj_attr_new_uint (MS_OBJ_ATTR_OUTLINE_COLOR,
0x80000000 | GSF_LE_GET_GUINT8 (q->data+38)));
ms_obj_attr_bag_insert (obj->attrs,
ms_obj_attr_new_uint (MS_OBJ_ATTR_OUTLINE_WIDTH,
GSF_LE_GET_GUINT8 (q->data+40)));
/* only pull in the text if it exists */
len = GSF_LE_GET_GUINT16 (q->data + 44);
txo_len = GSF_LE_GET_GUINT16 (q->data + 48);
tmp = GSF_LE_GET_GUINT16 (q->data + 50);
data = q->data + 70;
g_return_val_if_fail ((unsigned)(data - q->data) < q->length, TRUE);
g_return_val_if_fail (!has_fmla, TRUE); /* how would this happen */
data = q->data + 70;
g_return_val_if_fail ((unsigned)(data - q->data) < q->length, TRUE);
g_return_val_if_fail (!has_fmla, TRUE); /* how would this happen */
/* skip the obj name if defined */
if (has_name) {
data += *data + ((*data & 0x1) ? 1 : 2); /* padding byte */
/* skip the obj name if defined */
if (has_name) {
data += *data + ((*data & 0x1) ? 1 : 2); /* padding byte */
g_return_val_if_fail ((unsigned)(data - q->data) <= q->length, TRUE);
}
}
if (len > 0)
ms_obj_attr_bag_insert (obj->attrs,
......
......@@ -36,6 +36,8 @@ typedef enum {
MS_OBJ_ATTR_FILL_BACKGROUND,
MS_OBJ_ATTR_FILL_BACKGROUND_ALPHA,
MS_OBJ_ATTR_OUTLINE_COLOR,
MS_OBJ_ATTR_OUTLINE_WIDTH,
MS_OBJ_ATTR_OUTLINE_STYLE,
MS_OBJ_ATTR_SCROLLBAR_VALUE,
MS_OBJ_ATTR_SCROLLBAR_MIN,
MS_OBJ_ATTR_SCROLLBAR_MAX,
......
......@@ -167,7 +167,7 @@ static guint go_color_palette_signals [LAST_SIGNAL] = { 0, };
static GObjectClass *go_color_palette_parent_class;
static GtkWidget *
create_color_sel (GObject *action_proxy, GOColor c, GCallback handler)
create_color_sel (GObject *action_proxy, GOColor c, GCallback handler, gboolean allow_alpha)
{
char *title = g_object_get_data (G_OBJECT (action_proxy), "title");
GtkWidget *w = gtk_color_selection_dialog_new (title);
......@@ -178,6 +178,7 @@ create_color_sel (GObject *action_proxy, GOColor c, GCallback handler)
gtk_widget_hide (dialog->help_button);
gtk_color_selection_set_current_color (colorsel,
go_color_to_gdk (c, &gdk));
gtk_color_selection_set_has_opacity_control (colorsel, allow_alpha);
g_signal_connect_object (dialog,
"response", handler, action_proxy, 0);
......@@ -391,7 +392,7 @@ static void
cb_combo_custom_clicked (GtkWidget *button, GOColorPalette *pal)
{
GtkWidget *dialog = create_color_sel (G_OBJECT (pal), pal->selection,
G_CALLBACK (cb_combo_custom_response));
G_CALLBACK (cb_combo_custom_response), pal->allow_alpha);
g_signal_emit (pal, go_color_palette_signals [DISPLAY_CUSTOM_DIALOG], 0,
dialog);
gtk_widget_show (dialog);
......@@ -549,7 +550,8 @@ go_color_palette_new (char const *no_color_label,
typedef struct {
GtkMenu base;
GOColor selection, default_color;
gboolean allow_alpha;
GOColor selection, default_color;
} GOMenuColor;
typedef struct {
......@@ -638,7 +640,7 @@ static void
cb_menu_custom_activate (GtkWidget *button, GOMenuColor *menu)
{
GtkWidget *dialog = create_color_sel (G_OBJECT (menu), menu->selection,
G_CALLBACK (cb_menu_custom_response));
G_CALLBACK (cb_menu_custom_response), menu->allow_alpha);
g_signal_emit (menu, go_menu_color_signals [DISPLAY_CUSTOM_DIALOG], 0,
dialog);
gtk_widget_show (dialog);
......
......@@ -262,8 +262,11 @@ go_combo_color_set_color (GOComboColor *cc, GdkColor *color)
{
#warning convert to GOColor
g_return_if_fail (IS_GO_COMBO_COLOR (cc));
go_color_palette_set_current_color (cc->palette, GDK_TO_UINT (*color));
if (color != NULL)
go_color_palette_set_current_color (cc->palette, GDK_TO_UINT (*color));
else
go_color_palette_set_color_to_default (cc->palette);
}
void
......
......@@ -225,7 +225,7 @@ go_pattern_selector (GOColor fore, GOColor back,
path[1].y = path[2].y = H;
svp = art_svp_from_vpath (path);
w = go_combo_pixmaps_new (4);
w = go_combo_pixmaps_new (5);
for (i = 0; i < G_N_ELEMENTS (elements); i++) {
pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, W, H);
is_auto = elements[i] == GO_PATTERN_MAX;
......
......@@ -165,7 +165,7 @@
<property name="update_policy">GTK_UPDATE_ALWAYS</property>
<property name="snap_to_ticks">False</property>
<property name="wrap">False</property>
<property name="adjustment">0 0 3001 1 10 1</property>
<property name="adjustment">0 -1 3001 1 10 1</property>
<accessibility>
<atkrelation target="label3" type="labelled-by"/>
</accessibility>
......
......@@ -3,8 +3,9 @@
/*
* sheet-object-graphic.c: Implements the drawing object manipulation for Gnumeric
*
* Author:
* Authors:
* Miguel de Icaza (miguel@kernel.org)
* Jody Goldberg (jody@gnome.org)
*/
#include <gnumeric-config.h>
#include <glib/gi18n.h>
......@@ -98,10 +99,10 @@ gnm_so_graphic_set_fill_color (SheetObject *so, GnmColor *color)
NULL);
}
static void
sheet_object_graphic_width_set (SheetObjectGraphic *sog, double width)
void
gnm_so_graphic_set_width (SheetObject *so, double width)
{
SheetObject *so = SHEET_OBJECT (sog);
SheetObjectGraphic *sog = SHEET_OBJECT_GRAPHIC (so);
GList *l;
sog->width = width;
......@@ -235,7 +236,7 @@ sheet_object_graphic_read_xml_dom (SheetObject *so, char const *typename,
sog->type = tmp;
xml_node_get_double (tree, "Width", &width);
sheet_object_graphic_width_set (sog, width);
gnm_so_graphic_set_width (so, width);
if (xml_node_get_double (tree, "ArrowShapeA", &a) &&
xml_node_get_double (tree, "ArrowShapeB", &b) &&
......@@ -409,7 +410,7 @@ cb_dialog_graphic_config_cancel_clicked (GtkWidget *button, DialogGraphicData *s
{
SheetObject *so = SHEET_OBJECT (state->sog);
sheet_object_graphic_width_set (state->sog, state->width);
gnm_so_graphic_set_width (so, state->width);
gnm_so_graphic_set_fill_color (so,
state->fill_color);
state->fill_color = NULL;
......@@ -423,9 +424,9 @@ cb_dialog_graphic_config_cancel_clicked (GtkWidget *button, DialogGraphicData *s
static void
cb_adjustment_value_changed (GtkAdjustment *adj, DialogGraphicData *state)
{
sheet_object_graphic_width_set (state->sog,
gtk_spin_button_get_adjustment (
state->spin_line_width)->value);
SheetObject *so = SHEET_OBJECT (state->sog);
gnm_so_graphic_set_width (so,
gtk_spin_button_get_adjustment (state->spin_line_width)->value);
foo_canvas_item_set (state->arrow,
"width_units", (double) gtk_spin_button_get_adjustment (
state->spin_line_width)->value,
......@@ -663,19 +664,27 @@ typedef struct {
SheetObjectGraphic sheet_object_graphic;
GnmColor *outline_color;
int outline_style;
} SheetObjectFilled;
typedef struct {
SheetObjectGraphicClass parent_class;
} SheetObjectFilledClass;
typedef SheetObjectGraphicClass SheetObjectFilledClass;
static SheetObjectGraphicClass *sheet_object_filled_parent_class;
void
gnm_so_filled_set_outline_style (SheetObject *so, int style)
{
SheetObjectFilled *sof = SHEET_OBJECT_FILLED (so);
sof->outline_style = style;
style_color_ref (sof->outline_color);
gnm_so_filled_set_outline_color (so, sof->outline_color);
}
void
gnm_so_filled_set_outline_color (SheetObject *so, GnmColor *color)
{
SheetObjectFilled *sof = SHEET_OBJECT_FILLED (so);
GdkColor *gdk = (color != NULL) ? &color->color : NULL;
GdkColor *gdk = (color != NULL && sof->outline_style != 0) ? &color->color : NULL;
GList *l;
g_return_if_fail (sof != NULL);
......@@ -753,7 +762,8 @@ sheet_object_filled_new_view_internal (SheetObject *so, SheetControl *sc, GnmCan
sog = SHEET_OBJECT_GRAPHIC (so);
fill_color = (sog->fill_color != NULL) ? &sog->fill_color->color : NULL;
outline_color = (sof->outline_color != NULL) ? &sof->outline_color->color : NULL;
outline_color = (sof->outline_color != NULL && sof->outline_style != 0)
? &sof->outline_color->color : NULL;
item = foo_canvas_item_new (group,
(sog->type == SHEET_OBJECT_OVAL) ?
......@@ -825,6 +835,7 @@ sheet_object_filled_clone (SheetObject const *so, Sheet *sheet)
new_sof = SHEET_OBJECT_FILLED (new_so);
new_sof->outline_color = style_color_ref (sof->outline_color);
new_sof->outline_style = sof->outline_style;
return SHEET_OBJECT (new_sof);
}
......@@ -866,11 +877,8 @@ cb_dialog_filled_config_destroy (DialogFilledData *state)
static void
cb_dialog_filled_adjustment_value_changed (GtkAdjustment *adj, DialogFilledData *state)
{
SheetObjectGraphic *sog = SHEET_OBJECT_GRAPHIC (state->sof);
sheet_object_graphic_width_set (sog,
gtk_spin_button_get_adjustment (
state->spin_border_width)->value);
gnm_so_graphic_set_width (SHEET_OBJECT (state->sof),
gtk_spin_button_get_adjustment (state->spin_border_width)->value);
}
static void
......@@ -900,10 +908,9 @@ cb_dialog_filled_config_ok_clicked (GtkWidget *button, DialogFilledData *state)
static void
cb_dialog_filled_config_cancel_clicked (GtkWidget *button, DialogFilledData *state)
{
SheetObjectGraphic *sog = SHEET_OBJECT_GRAPHIC (state->sof);
SheetObject *so = SHEET_OBJECT (state->sof);
sheet_object_graphic_width_set (sog, state->width);
gnm_so_graphic_set_width (so, state->width);
gnm_so_graphic_set_fill_color (so,
state->fill_color);
state->fill_color = NULL;
......@@ -1105,7 +1112,7 @@ sheet_object_filled_print (SheetObject const *so, GnomePrintContext *ctx,
gnome_print_fill (ctx);
gnome_print_grestore (ctx);
}
if (sof->outline_color) {
if (sof->outline_color && sof->outline_style > 0) {
gnome_print_setlinewidth (ctx, sog->width);
gnome_print_setrgbcolor (ctx,
sof->outline_color->color.red / (double) 0xffff,
......@@ -1565,6 +1572,14 @@ sheet_object_text_get_graphic (FooCanvasItem *item)
return FOO_CANVAS_ITEM (group->item_list->data);
}
static void
sheet_object_text_print (SheetObject const *so, GnomePrintContext *ctx,
double width, double height)
{
SHEET_OBJECT_CLASS (sheet_object_text_parent_class)->
print (so, ctx, width, height);
}
static void
sheet_object_text_class_init (GObjectClass *object_class)
{
......@@ -1584,7 +1599,7 @@ sheet_object_text_class_init (GObjectClass *object_class)
so_class->write_xml_dom = sheet_object_text_write_xml_dom;
so_class->clone = sheet_object_text_clone;
/* so_class->user_config = NULL; inherit from parent */
/* so_class->print = NULL; inherit from parent */
so_class->print = sheet_object_text_print;
so_class->rubber_band_directly = FALSE;
sog_class->get_graphic = sheet_object_text_get_graphic;
......
......@@ -8,13 +8,15 @@
GType sheet_object_graphic_get_type (void);
SheetObject *sheet_object_line_new (gboolean with_arrow);
void gnm_so_graphic_set_fill_color (SheetObject *so, GnmColor *color);
void gnm_so_graphic_set_width (SheetObject *so, double width);
#define SHEET_OBJECT_FILLED_TYPE (sheet_object_filled_get_type ())
#define IS_SHEET_OBJECT_FILLED(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), SHEET_OBJECT_FILLED_TYPE))
GType sheet_object_filled_get_type (void);
SheetObject *sheet_object_box_new (gboolean is_oval);
void gnm_so_filled_set_outline_color (SheetObject *so, GnmColor *color);
void gnm_so_filled_set_outline_color (SheetObject *so, GnmColor *color);
void gnm_so_filled_set_outline_style (SheetObject *so, int style);
#define SHEET_OBJECT_POLYGON_TYPE (sheet_object_polygon_get_type ())
#define IS_SHEET_OBJECT_POLYGON(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), SHEET_OBJECT_POLYGON_TYPE))
......
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