[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][TOP]

gnumeric patch


あかがきです。

日本語化 gnome-print-0.25 上で
gnumeric 0.64 をつかう patch です。

Akira TAGOH さんがここに gnome-print と共に post されていたものを
gnumeric-0.61 用のものをベースにしています。
diff -uNr gnumeric-0.64.orig/src/cell-draw.c gnumeric-0.64/src/cell-draw.c
--- gnumeric-0.64.orig/src/cell-draw.c	Sun Feb 25 12:38:43 2001
+++ gnumeric-0.64/src/cell-draw.c	Fri Apr 27 19:56:45 2001
@@ -21,7 +21,11 @@
 	   int x1, int text_base, char const * text, int n, int len_pixels,
 	   int const * const line_offset, int num_lines)
 {
-	gdk_draw_text (drawable, font, gc, x1, text_base, text, n);
+	size_t wclen;
+	GdkWChar* wctext=g_new0(GdkWChar,n+1);
+	wclen=gdk_mbstowcs(wctext,text,n);
+	gdk_draw_text_wc (drawable, font, gc, x1, text_base, wctext, wclen);
+	g_free(wctext);
 
 	/* FIXME how to handle small fonts ?
 	 * the text_base should be at least 2 pixels above the bottom */
diff -uNr gnumeric-0.64.orig/src/dialogs/dialog-stf-preview.c gnumeric-0.64/src/dialogs/dialog-stf-preview.c
--- gnumeric-0.64.orig/src/dialogs/dialog-stf-preview.c	Fri Dec 22 17:03:32 2000
+++ gnumeric-0.64/src/dialogs/dialog-stf-preview.c	Wed Apr 25 00:20:48 2001
@@ -711,7 +711,7 @@
 	renderdata->gridgroup    = NULL;
 	renderdata->hashtable    = g_hash_table_new (g_int_hash, g_int_equal);
 
-	renderdata->font       = gdk_font_load ("fixed");
+	renderdata->font       = gdk_fontset_load ("-alias-fixed-medium-r-normal--14-*-*-*-*-*-*-*,*-r-*");
 	renderdata->charwidth  = gdk_string_width (renderdata->font, "W");
 	renderdata->charheight = gdk_string_height (renderdata->font, "W");
 
diff -uNr gnumeric-0.64.orig/src/gnumeric-sheet.c gnumeric-0.64/src/gnumeric-sheet.c
--- gnumeric-0.64.orig/src/gnumeric-sheet.c	Sun Mar 11 13:14:44 2001
+++ gnumeric-0.64/src/gnumeric-sheet.c	Tue May  1 16:49:14 2001
@@ -912,11 +911,31 @@
 		GdkIMStyle style;
 		GdkIMStyle supported_style = GDK_IM_PREEDIT_NONE |
 			GDK_IM_PREEDIT_NOTHING |
+			GDK_IM_PREEDIT_POSITION |
 			GDK_IM_STATUS_NONE |
 			GDK_IM_STATUS_NOTHING;
 
 		attr->style = style = gdk_im_decide_style (supported_style);
 		attr->client_window = gsheet->canvas.layout.bin_window;
+
+		switch (style & GDK_IM_PREEDIT_MASK){
+		case GDK_IM_PREEDIT_POSITION:
+			if (widget->style && widget->style->font->type != GDK_FONT_FONTSET){
+				g_warning ("over-the-spot style requires fontset");
+				break;
+			}
+
+			attrmask |= GDK_IC_PREEDIT_POSITION_REQ;
+			attr->spot_location.x = 0;
+			attr->spot_location.y = 10;
+			attr->preedit_area.x = 100;
+			attr->preedit_area.y = 100;
+			attr->preedit_area.width = 100;
+			attr->preedit_area.height = 100;
+			attr->preedit_fontset = widget->style->font;
+
+			break;
+		}
 
 		gsheet->ic = gdk_ic_new (attr, attrmask);
 		if (gsheet->ic != NULL) {
diff -uNr gnumeric-0.64.orig/src/item-bar.c gnumeric-0.64/src/item-bar.c
--- gnumeric-0.64.orig/src/item-bar.c	Tue Mar 13 10:00:51 2001
+++ gnumeric-0.64/src/item-bar.c	Fri Apr 27 15:47:32 2001
@@ -6,6 +6,7 @@
  *     Miguel de Icaza (miguel@xxxxxxxxxx)
  */
 #include <config.h>
+#include <locale.h>
 
 #include "item-bar.h"
 #include "item-debug.h"
@@ -95,12 +96,19 @@
 	double const zoom_factor =
 		item_bar->scg->sheet->last_zoom_factor_used;
 	double const res  = application_dpi_to_pixels ();
-	StyleFont * const normal_font =
-		style_font_new_simple (DEFAULT_FONT, DEFAULT_SIZE,
-				       res*zoom_factor, FALSE, FALSE);
-	StyleFont * const bold_font =
-		style_font_new_simple (DEFAULT_FONT, DEFAULT_SIZE,
-				       res*zoom_factor, TRUE, FALSE);
+	StyleFont * const normal_font;
+	StyleFont * const bold_font;
+	gchar *locale = setlocale (LC_CTYPE, ""), *font_name;
+
+	/* FIXME: change default font if locale is ja* */
+	if (g_strncasecmp (locale, "ja", 2))
+		font_name = DEFAULT_FONT;
+	else
+		font_name = DEFAULT_FONT_J;
+	normal_font = style_font_new_simple (font_name, DEFAULT_SIZE,
+						res*zoom_factor, FALSE, FALSE);
+	bold_font = style_font_new_simple (font_name, DEFAULT_SIZE,
+						res*zoom_factor, TRUE, FALSE);
 
 	/* Now that we have the new fonts unref the old ones */
 	item_bar_fonts_unref (item_bar);
diff -uNr gnumeric-0.64.orig/src/mstyle.c gnumeric-0.64/src/mstyle.c
--- gnumeric-0.64.orig/src/mstyle.c	Fri Mar  2 21:44:03 2001
+++ gnumeric-0.64/src/mstyle.c	Tue Apr 24 23:58:54 2001
@@ -8,6 +8,7 @@
  *   Almer S. Tigelaar <almer1@xxxxxx>
  */
 #include <config.h>
+#include <locale.h>
 #include "str.h"
 #include "mstyle.h"
 #include "style-border.h"
@@ -565,6 +566,7 @@
 mstyle_new_default (void)
 {
 	MStyle *mstyle = mstyle_new ();
+	gchar *locale = setlocale (LC_CTYPE, "");
 
 	mstyle_set_format_text (mstyle, "General");
 	mstyle_set_align_v     (mstyle, VALIGN_BOTTOM);
@@ -572,7 +574,12 @@
 	mstyle_set_indent      (mstyle, 0);
 	mstyle_set_orientation (mstyle, ORIENT_HORIZ);
 	mstyle_set_wrap_text   (mstyle, FALSE);
-	mstyle_set_font_name   (mstyle, DEFAULT_FONT);
+	/* FIXME: change default font if locale is ja* */
+	if (g_strncasecmp (locale, "ja", 2)) {
+		mstyle_set_font_name   (mstyle, DEFAULT_FONT);
+	} else {
+		mstyle_set_font_name   (mstyle, DEFAULT_FONT_J);
+	}
 	mstyle_set_font_bold   (mstyle, FALSE);
 	mstyle_set_font_italic (mstyle, FALSE);
 	mstyle_set_font_uline  (mstyle, UNDERLINE_NONE);
@@ -919,8 +926,17 @@
 
 	if (mstyle_is_element_set (style, MSTYLE_FONT_NAME))
 		name = mstyle_get_font_name (style);
-	else
-		name = DEFAULT_FONT;
+	else {
+		gchar *locale = setlocale (LC_CTYPE, "");
+
+		/* FIXME: change default font if locale is ja* */
+		if (g_strncasecmp (locale, "ja", 2)) {
+			name = DEFAULT_FONT;
+		} else {
+			name = DEFAULT_FONT_J;
+		}
+	}
+
 
 	if (mstyle_is_element_set (style, MSTYLE_FONT_BOLD))
 		bold = mstyle_get_font_bold (style);
diff -uNr gnumeric-0.64.orig/src/print-cell.c gnumeric-0.64/src/print-cell.c
--- gnumeric-0.64.orig/src/print-cell.c	Tue Mar 13 10:00:51 2001
+++ gnumeric-0.64/src/print-cell.c	Tue Apr 24 23:58:54 2001
@@ -10,6 +10,8 @@
 #include <config.h>
 #include <gnome.h>
 #include <locale.h>
+#include <iconv.h>
+#include <langinfo.h>
 #include <libgnomeprint/gnome-print.h>
 #include "gnumeric.h"
 #include "eval.h"
@@ -259,8 +261,29 @@
 	    double x, double text_base, char const * text, double len_pts,
 	    double const * const line_offset, int num_lines)
 {
+	gchar *utext, *locale;
+	gint len;
+	iconv_t fd;
+
 	gnome_print_moveto (context, x, text_base);
-	print_show (context, text);
+	setlocale (LC_CTYPE, "");
+	locale = nl_langinfo (CODESET);
+	if (locale != NULL && strcmp (locale, "C") && (fd = iconv_open ("UTF-8", locale)) != (iconv_t)-1) {
+		gchar *pout, *pin;
+		gint ib, ob;
+
+		ib = strlen (text);
+		pin = text;
+		ob = ib * 3;
+		pout = utext = g_new0 (gchar, ob);
+		iconv (fd, &pin, &ib, &pout, &ob);
+		iconv_close (fd);
+	} else {
+		utext = g_strdup (text);
+	}
+	len = strlen (utext);
+
+	gnome_print_show_sized (context, utext, len);
 
 	/* FIXME how to handle small fonts ?
 	 * the text_base should be at least 2 pixels above the bottom */
@@ -270,6 +293,7 @@
 		gnome_print_setlinewidth (context, 0);
 		print_hline (context, x, x+len_pts, y);
 	}
+	g_free(utext);
 }
 
 static void
diff -uNr gnumeric-0.64.orig/src/print.c gnumeric-0.64/src/print.c
--- gnumeric-0.64.orig/src/print.c	Tue Mar 13 10:00:51 2001
+++ gnumeric-0.64/src/print.c	Tue Apr 24 23:58:54 2001
@@ -9,6 +9,9 @@
  */
 #include <config.h>
 #include <gnome.h>
+#include <locale.h>
+#include <iconv.h>
+#include <langinfo.h>
 #include <libgnomeprint/gnome-printer.h>
 #include <libgnomeprint/gnome-print.h>
 #include <libgnomeprint/gnome-printer-dialog.h>
@@ -254,6 +257,7 @@
 	char *text;
 	double x;
 	double len;
+	gchar* utext;
 
 	/* Be really really anal in case Bug
 	 * http://bugs.gnome.org/db/82/8200.html exists
@@ -269,9 +273,28 @@
 	if (text [0] == 0) {
 		g_free (text);
 		return;
+	} else {
+		iconv_t fd;
+		gchar *locale;
+
+		setlocale (LC_CTYPE, "");
+		locale = nl_langinfo (CODESET);
+		if (locale != NULL && strcmp (locale, "C") && (fd = iconv_open ("UTF-8", locale)) != (iconv_t)-1) {
+			gchar *pout, *pin;
+			gint ib, ob;
+
+			ib = strlen (text);
+			pin = text;
+			ob = ib * 3;
+			pout = utext = g_new0 (gchar, ob);
+			iconv (fd, &pin, &ib, &pout, &ob);
+			iconv_close (fd);
+		} else {
+			utext = g_strdup (text);
+		}
 	}
 
-	len = get_width_string (pj->decoration_font, text);
+	len = get_width_string (pj->decoration_font, utext);
 
 	pm = &pj->pi->margins;
 	switch (side){
@@ -291,8 +314,9 @@
 		x = 0;
 	}
 	gnome_print_moveto (pj->print_context, x, y);
-	print_show (pj->print_context, text);
+	gnome_print_show_sized (pj->print_context, utext, len);
 	g_free (text);
+	g_free (utext);
 }
 
 /*
diff -uNr gnumeric-0.64.orig/src/sheet-control-gui.c gnumeric-0.64/src/sheet-control-gui.c
--- gnumeric-0.64.orig/src/sheet-control-gui.c	Mon Mar 12 11:02:25 2001
+++ gnumeric-0.64/src/sheet-control-gui.c	Tue May  1 18:11:41 2001
@@ -127,6 +127,25 @@
 	fprintf (stderr, "%s%d:", col_name(min_col), first_row+1);
 	fprintf (stderr, "%s%d\n", col_name(max_col), last_row+1);
 #endif
+{
+        if (gsheet->ic && (gdk_ic_get_style (gsheet->ic) & GDK_IM_PREEDIT_POSITION)){
+		int sx1,sy1;
+		gnome_canvas_get_scroll_offsets(GNOME_CANVAS(gsheet),&sx1,&sy1);
+                gsheet->ic_attr->spot_location.x = x1-sx1;
+                gsheet->ic_attr->spot_location.y = scg_colrow_distance_get (scg, FALSE, gsheet->row.first, end_row+1)-sy1;
+                gsheet->ic_attr->preedit_area.x=x1-sx1;
+                gsheet->ic_attr->preedit_area.y=y2-sy1;
+                gsheet->ic_attr->preedit_area.width=x2-x1;
+                gsheet->ic_attr->preedit_area.height=y2-y1;
+                gsheet->ic_attr->preedit_area_needed.x=x1-sx1;
+                gsheet->ic_attr->preedit_area_needed.y=y2-sy1;
+                gsheet->ic_attr->preedit_area_needed.width=x2-x1;
+                gsheet->ic_attr->preedit_area_needed.height=y2-y1;
+
+
+                gdk_ic_set_attr (gsheet->ic,gsheet->ic_attr, GDK_IC_PREEDIT_AREA|GDK_IC_SPOT_LOCATION);
+}
+        }
 
 	gnome_canvas_request_redraw (GNOME_CANVAS (gsheet), x1-2, y1-2, x2, y2);
 }
diff -uNr gnumeric-0.64.orig/src/style.c gnumeric-0.64/src/style.c
--- gnumeric-0.64.orig/src/style.c	Mon Feb 19 21:58:14 2001
+++ gnumeric-0.64/src/style.c	Fri Apr 27 19:58:34 2001
@@ -72,7 +72,7 @@
 		/* Worst case scenario */
 		font->gdk_font = gnome_display_font_get_gdk_font (font->dfont);
 		if (font->gdk_font == NULL)
-			font->gdk_font = gdk_font_load ("fixed");
+			font->gdk_font = gdk_fontset_load ("-alias-fixed-medium-r-normal--14-*-*-*-*-*-*-*,*-r-*");
 		else
 			gdk_font_ref (font->gdk_font);
 
@@ -227,9 +227,15 @@
 static void
 font_init (void)
 {
+	gchar *locale = setlocale (LC_CTYPE, ""), *font_name;
 	double const scale  = application_dpi_to_pixels ();
-	gnumeric_default_font = style_font_new_simple (DEFAULT_FONT, DEFAULT_SIZE,
-						       scale, FALSE, FALSE);
+	/* FIXME: change default font if locale is ja* */
+	if (g_strncasecmp (locale, "ja", 2))
+		font_name = DEFAULT_FONT;
+	else
+		font_name = DEFAULT_FONT_J;
+	gnumeric_default_font = style_font_new_simple (font_name, DEFAULT_SIZE,
+                                                        scale, FALSE, FALSE);
 
 	if (!gnumeric_default_font) {
 		char *lc_all = getenv ("LC_ALL");
@@ -274,8 +280,8 @@
 	/*
 	 * Load bold font
 	 */
-	gnumeric_default_bold_font = style_font_new_simple (
-		DEFAULT_FONT, DEFAULT_SIZE, scale, TRUE, FALSE);
+	/* FIXME: change default font if locale is ja* */
+	gnumeric_default_bold_font = style_font_new_simple (font_name, DEFAULT_SIZE, scale, TRUE, FALSE);
 	if (gnumeric_default_bold_font == NULL){
 	    gnumeric_default_bold_font = gnumeric_default_font;
 	    style_font_ref (gnumeric_default_bold_font);
@@ -284,8 +290,8 @@
 	/*
 	 * Load italic font
 	 */
-	gnumeric_default_italic_font = style_font_new_simple (
-		DEFAULT_FONT, DEFAULT_SIZE, scale, FALSE, TRUE);
+	/* FIXME: change default font if locale is ja* */
+	gnumeric_default_italic_font = style_font_new_simple (font_name, DEFAULT_SIZE, scale, FALSE, TRUE);
 	if (gnumeric_default_italic_font == NULL){
 		gnumeric_default_italic_font = gnumeric_default_font;
 		style_font_ref (gnumeric_default_italic_font);
diff -uNr gnumeric-0.64.orig/src/style.h gnumeric-0.64/src/style.h
--- gnumeric-0.64.orig/src/style.h	Sun Dec 31 13:15:17 2000
+++ gnumeric-0.64/src/style.h	Tue Apr 24 23:58:54 2001
@@ -6,6 +6,7 @@
 #include "gnumeric.h"
 
 #define DEFAULT_FONT "Helvetica"
+#define DEFAULT_FONT_J "Mincho"
 #define DEFAULT_SIZE 9.0
 
 /* Alignment definitions */
diff -uNr gnumeric-0.64.orig/src/item-edit.c gnumeric-0.64/src/item-edit.c
--- gnumeric-0.64.orig/src/item-edit.c	Fri Feb 23 09:26:54 2001
+++ gnumeric-0.64/src/item-edit.c	Tue May  1 18:25:49 2001
@@ -31,6 +31,8 @@
 #include "workbook.h"
 #include "workbook-edit.h"
 #include "gnumeric-util.h"
+#include "workbook-control-gui-priv.h"
+#include "cell.h"
 
 #include <ctype.h>
 #include <string.h>
@@ -170,6 +172,30 @@
 	gdk_draw_line (drawable, style->black_gc,
 		       x, y-font->ascent,
 		       x, y+font->descent);
+
+#if 0
+//IMMMMMM
+{
+	GnumericSheet *gsheet = GNUMERIC_SHEET(GNOME_CANVAS_ITEM(item_edit)->canvas);
+        if (gsheet->ic && (gdk_ic_get_style (gsheet->ic) & GDK_IM_PREEDIT_POSITION)){
+                int sx1,sy1;
+                gnome_canvas_get_scroll_offsets(GNOME_CANVAS(gsheet),&sx1,&sy1);
+                gsheet->ic_attr->preedit_area.x=x;
+                gsheet->ic_attr->preedit_area.y=y-font->ascent;
+                gsheet->ic_attr->preedit_area.width=500;
+                gsheet->ic_attr->preedit_area.height=font->ascent+font->descent;
+                gsheet->ic_attr->preedit_area_needed.x=x;
+                gsheet->ic_attr->preedit_area_needed.y=y-font->ascent;
+                gsheet->ic_attr->preedit_area_needed.width=500;
+                gsheet->ic_attr->preedit_area_needed.height=font->ascent+font->descent;
+		gsheet->ic_attr->preedit_fontset=font;
+
+
+                gdk_ic_set_attr (gsheet->ic,gsheet->ic_attr, GDK_IC_PREEDIT_AREA|GDK_IC_PREEDIT_FONTSET);
+	}
+
+}
+#endif
 }
 
 static void
@@ -180,13 +206,20 @@
 	GdkFont *font = item_edit->font;
 
 	GdkGC *gc = style->black_gc;
+	GdkWChar *wtext ,*freeptr;
+	gint i;
 
+	wtext = freeptr = g_new0 (GdkWChar, text_length+1);
+	i = gdk_mbstowcs (wtext, text, text_length);
+	text_length = i;
 	/* If this segment contains the cursor draw it */
 	if (0 <= cursor_pos && cursor_pos <= text_length) {
+		if (wtext != NULL) {
+			gdk_draw_text_wc (drawable, font, gc, x1, y, wtext, cursor_pos);
+			x1 += gdk_text_width_wc (font, wtext, cursor_pos);
+		}
 		if (cursor_pos > 0) {
-			gdk_draw_text (drawable, font, gc, x1, y, text, cursor_pos);
-			x1 += gdk_text_width (font, text, cursor_pos);
-			text += cursor_pos;
+			wtext += cursor_pos;
 			text_length -= cursor_pos;
 			cursor_pos = 0;
 		}
@@ -198,15 +231,16 @@
 		if (text_length > cursor_pos &&
 		    workbook_auto_completing (item_edit->scg->wbcg)) {
 			if (w < 0)
-				w = gdk_text_width (font, text, text_length);
+				w = gdk_text_width_wc (font, wtext, text_length);
 			gdk_draw_rectangle (drawable, style->black_gc, TRUE,
 					    x1, y - font->ascent, w,
 					    font->ascent + font->descent);
 			gc = style->white_gc;
 		}
-
-		gdk_draw_text (drawable, font, gc, x1, y, text, text_length);
+		if(wtext!=NULL)
+			gdk_draw_text_wc (drawable, font, gc, x1, y, wtext, text_length);	
 	}
+	g_free(freeptr);
 }
 
 static void
@@ -294,8 +328,9 @@
 	ItemEdit *item_edit = ITEM_EDIT (item);
 	Sheet    *sheet     = item_edit->scg->sheet;
 	GdkFont  *font      = item_edit->font;
-	const char *start = workbook_edit_get_display_text (item_edit->scg->wbcg);
-	const char *text  = start;
+	const char *start_c = workbook_edit_get_display_text (item_edit->scg->wbcg);
+	GdkWChar* start = g_new0(GdkWChar,strlen(start_c)+1);
+	const GdkWChar* text =start;
 	int col_span, row_span, tmp;
 	GSList	*text_offsets = NULL;
 	Range const *merged;
@@ -310,9 +345,11 @@
 	int left_in_col = cri->size_pixels - cri->margin_a - 1;
 	int ignore_rows = 0;
 
+	gdk_mbstowcs (start, start_c, strlen(start_c));
+
 	/* the entire string */
 	while (*text) {
-		int pos_size = gdk_text_width (font, text++, 1);
+		int pos_size = gdk_text_width_wc (font, text++, 1);
 
 		/* Be wary of large fonts and small columns */
 		while (left_in_col < pos_size) {
@@ -349,6 +386,8 @@
 		}
 		left_in_col -= pos_size;
 	}
+	g_free(start);
+
 	item_edit->col_span = 1 + max_col - item_edit->pos.col;
 	item_edit->lines = cur_line;