Patch for PDF/PS graph export

2005-11-29 Thread Emmanuel Pacaud
Hi,

Please find attached a patch that adds experimental PDF/PS export
support via cairo renderer (if cairo is compiled with PDF/PS backends,
of course, which should be the default for next stable release...).

In the process, I've moved some image format related code from gnumeric
to goffice.

Ok to commit ?

Emmanuel.
? po/fr.po.autosave
? src/gnm-graph-window.c
? src/gnm-graph-window.h
Index: src/sheet-object-graph.c
===
RCS file: /cvs/gnome/gnumeric/src/sheet-object-graph.c,v
retrieving revision 1.74
diff -u -p -r1.74 sheet-object-graph.c
--- src/sheet-object-graph.c	18 Nov 2005 15:54:51 -	1.74
+++ src/sheet-object-graph.c	29 Nov 2005 15:24:24 -
@@ -221,24 +221,9 @@ gnm_sog_get_object_target_list (SheetObj
 	return tl;
 }
 
-static gboolean
-sog_gsf_gdk_pixbuf_save (const gchar *buf,
-			 gsize count,
-			 GError **error,
-			 gpointer data)
-{
-	GsfOutput *output = GSF_OUTPUT (data);
-	gboolean ok = gsf_output_write (output, count, buf);
-
-	if (!ok  error)
-		*error = g_error_copy (gsf_output_error (output));
-
-	return ok;
-}
-
 static void
 gnm_sog_write_image (SheetObject const *so, const char *format,
-GsfOutput *output, GError **err)
+		 GsfOutput *output, GError **err)
 {
 	SheetObjectGraph *sog = SHEET_OBJECT_GRAPH (so);
 	gboolean res = FALSE;
@@ -258,20 +243,10 @@ gnm_sog_write_image (SheetObject const *
 
 	g_return_if_fail (w  0  h  0);
 
-	if (strcmp (format, svg) == 0) {
-		res = gog_graph_export_to_svg (sog-graph, output, w, h, 1.0);
-	} else {
-		GdkPixbuf *pixbuf = gog_renderer_get_pixbuf (sog-renderer);
-
-		if (!pixbuf) {
-			gog_renderer_update (sog-renderer, w, h, 1.);
-			pixbuf = gog_renderer_get_pixbuf (sog-renderer);
-		}
-		res = gdk_pixbuf_save_to_callback (pixbuf,
-		   sog_gsf_gdk_pixbuf_save,
-		   output, format,
-		   err, NULL);
-	}
+	/* FIXME Add a dpi editor. Default dpi to 150 for now */
+	res = gog_graph_export_image (sog-graph, go_image_get_format_from_name (format),
+  output, 150.0, 150.0);
+	
 	if (!res  err  *err == NULL)
 		*err = g_error_new (gsf_output_error_id (), 0,
 _(Unknown failure while saving image));
@@ -308,49 +283,34 @@ gnm_sog_write_object (SheetObject const 
 	g_free (old_num_locale);
 }
 
-/* 
- * The following are useful formats to save in:
- *  png
- *  svg
- *  eps
- *
- * TODO: Possibly add an eps renderer.  We may also use a new instance of
- * pixbufrenderer to save as png. This would allow the user to specify size of
- * the saved image, if that's wanted.
- */
 static void
 sog_cb_save_as (SheetObject *so, SheetControl *sc)
 {
-	static GOImageType const fmts[] = {
-		{(char *) svg,  (char *) N_(SVG (vector graphics)), (char *) svg, FALSE},
-		{(char *) png,  (char *) N_(PNG (raster graphics)), (char *) png, TRUE},
-		{(char *) jpeg, (char *) N_(JPEG (photograph)), (char *) jpg, TRUE}
-	};
-
 	WorkbookControlGUI *wbcg;
 	char *uri;
 	GError *err = NULL;
 	GsfOutput *output;
-	GSList *l = NULL;
-	GOImageType const *sel_fmt = fmts[0];
-	guint i;
+	GSList *l;
+	GOImageFormat selected_format;
+	GOImageFormatInfo const *format_info;
 	SheetObjectGraph *sog = SHEET_OBJECT_GRAPH (so);
 
 	g_return_if_fail (sog != NULL);
 
-	for (i = 0; i  G_N_ELEMENTS (fmts); i++)
-		l = g_slist_prepend (l, (gpointer) (fmts + i));
-	l = g_slist_reverse (l);
+	l = gog_graph_get_supported_image_formats ();
+	g_return_if_fail (l != NULL);
+	selected_format = GPOINTER_TO_UINT (l-data);
 
 #warning This violates model gui barrier
 	wbcg = scg_get_wbcg (SHEET_CONTROL_GUI (sc));
-	uri = gui_get_image_save_info (wbcg_toplevel (wbcg), l, sel_fmt);
+	uri = gui_get_image_save_info (wbcg_toplevel (wbcg), l, selected_format);
 	if (!uri)
 		goto out;
 	output = go_file_create (uri, err);
 	if (!output)
 		goto out;
-	sheet_object_write_image (so, sel_fmt-name, output, err);
+	format_info = go_image_get_format_info (selected_format);
+	sheet_object_write_image (so, format_info-name, output, err);
 	g_object_unref (output);
 		
 	if (err != NULL)
Index: src/sheet-object-image.c
===
RCS file: /cvs/gnome/gnumeric/src/sheet-object-image.c,v
retrieving revision 1.61
diff -u -p -r1.61 sheet-object-image.c
--- src/sheet-object-image.c	7 Nov 2005 04:44:02 -	1.61
+++ src/sheet-object-image.c	29 Nov 2005 15:24:24 -
@@ -138,9 +138,9 @@ enum {
 void
 sheet_object_image_set_image (SheetObjectImage *soi,
 			  char const   *type,
-			guint8   *data,
+			  guint8   *data,
 			  unsigned  data_len,
-			gboolean  copy_data)
+			  gboolean  copy_data)
 {
 	g_return_if_fail (IS_SHEET_OBJECT_IMAGE (soi));
 	g_return_if_fail (soi-bytes.data == NULL  soi-bytes.len == 0);
@@ -345,77 +345,14 @@ soi_gdk_pixbuf_save (const gchar *buf,
 	return ok;
 }
 
-static GOImageType const std_fmts[] = {
-	{(char *) png,  (char *) N_(PNG (raster graphics)),   
-	 (char *) png, TRUE},
-	

Re: new documentation format

2005-11-29 Thread Morten Welinder
On 11/28/05, Nicholas Lamb [EMAIL PROTECTED] wrote:

 Is there any documentation on how to write function docs with the new
 format? Compared to what I've seen so far it needs at least:

The test case for the new docs has so far been fn-R.  We haven't sorted
about the example issues yet.

Just thinking about we might want to have something like:

   { GNM_FUNC_HELP_EXAMPLE_1, GCD(10,15) }

where Gnumeric would parse the string as a (C-locale) formula, compute
the result, and display the example.  The format to use to display the result
would simply been the automatically deduced format by auto-format.c,
falling back to General.

That should be good enough for hundreds of functions.  It won't work for
INDEX and other range-type functions.  This might work:

   { GNM_FUNC_HELP_EXAMPLE_TABLE, A1:42 }
   { GNM_FUNC_HELP_EXAMPLE_TABLE, A2:-1.14 }
   { GNM_FUNC_HELP_EXAMPLE_TABLE, A3:\4\ }
   { GNM_FUNC_HELP_EXAMPLE_TABLE, A4:=SUM(A1:A3) }
   { GNM_FUNC_HELP_EXAMPLE_TEXT, N_(Since SUM ignores string...)}

The help system would have to build a little workbook internally, but I don't
see any problems with that.

Note, that formulas and values about are not translated.  We might need the
occational translated string constant, though.

Comments?

Morten
___
gnumeric-list mailing list
gnumeric-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gnumeric-list


Re: Patch for PDF/PS graph export

2005-11-29 Thread Andreas J. Guelzow
On Tue, 2005-29-11 at 16:36 +0100, Emmanuel Pacaud wrote:
 Hi,
 
 Please find attached a patch that adds experimental PDF/PS export
 support via cairo renderer (if cairo is compiled with PDF/PS backends,
 of course, which should be the default for next stable release...).

Why would one consider pdf/ps export outside of gnome-print?

Andreas
-- 
Andreas J. Guelzow
Taliesin Software, Shelties, Pyr Sheps
and Shetland Sheep


signature.asc
Description: This is a digitally signed message part
___
gnumeric-list mailing list
gnumeric-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gnumeric-list


Re: Patch for PDF/PS graph export

2005-11-29 Thread Emmanuel Pacaud
Hi,

Le mardi 29 novembre 2005 à 10:55 -0700, Andreas J. Guelzow a écrit :
 On Tue, 2005-29-11 at 16:36 +0100, Emmanuel Pacaud wrote:
  Please find attached a patch that adds experimental PDF/PS export
  support via cairo renderer (if cairo is compiled with PDF/PS backends,
  of course, which should be the default for next stable release...).
 
 Why would one consider pdf/ps export outside of gnome-print?

- It was easy to implement with cairo.
- At some point, I hope cairo will support pixbuf, SVG, PDF and PS. This
day we'll be able to only keep cairo renderer.
- IMHO, gnome-print itself should be built on top of cairo.
- I want to test the quality of cairo's PDF and PS backends.

Emmanuel.

___
gnumeric-list mailing list
gnumeric-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gnumeric-list


Re: wysiwyg should depend on font resolution?

2005-11-29 Thread Andreas J. Guelzow
On Wed, 2005-30-11 at 00:11 +0100, Pere Pujal i Carabantes wrote:
 Hello all!
 
 After some trys  I've find the origin of my gnumeric printing problems:
 
 The fact is printing in gnumeric assumes a font resolution of
 aproximately 100dpi without looking if the screen is using other
 resolution.
 
 gnome-control-center-Font-Details
 Change Resolution to 120 dots per inch
 Open gnumeric, type something and do a print preview.
 You can see the text cutted horizontally in gnumeric even if it is
 nearly right in preview.
 Close gnumeric and change resolution to 80dpi
 Open gnumeric, type something in various rows and autoadjust the rows.
 You can see the text right in gnumeric but cutted in preview.

Does it change anything if you adjust the screen resolution in
Gnumeric's preference dialog (File-Preferences, item Window/Screen)?

Andreas
-- 
Andreas J. Guelzow
Taliesin Software, Shelties, Pyr Sheps
and Shetland Sheep


signature.asc
Description: This is a digitally signed message part
___
gnumeric-list mailing list
gnumeric-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gnumeric-list


Re: a compatibility sheet and some results

2005-11-29 Thread Morten Welinder
 AND fails because Gnumeric considers strings to be TRUE

Fixed.  Gnumeric converted strings to truth values, not always
to TRUE, though.  0 would be FALSE, for example.  Also
fixed the same issue for OR and XOR.

 ATAN2 fails because Excel defines ATAN2(0,0) as #DIV/0! while Gnumeric
   returns 0.

Fixed.

 Jody, if you'd like I can file bugs for some, or all of these depending
 on your judgement of whether they're good candidates for improved
 compatibility.

Please file the rest as separate bugs.  If you find severeal
instances of what is probably the same issue, using one
bug is preferred.

Thanks,

Morten
___
gnumeric-list mailing list
gnumeric-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gnumeric-list


Re: a compatibility sheet and some results

2005-11-29 Thread Jody Goldberg
On Wed, Nov 30, 2005 at 12:51:31AM +, Nicholas Lamb wrote:
 
 ADDRESS failed because Gnumeric always quotes sheet names

Interesting.  I just did some work on ADDRESS to handle the special
case of
ADDRESS(-1,-1,,FALSE)   // R[-1]C[-1]
being ok but
ADDRESS(-1,-1,,TRUE)
not being ok.

It looks like the sheet name quoting mechanism is overzealous.
I'll have a look.
 
 AREAS fails because Gnumeric returns #VALUE! for an invalid Name, while
   Excel returns #NAME?
This will take some testing.  Should we special case invalid names
or special case referenced errors.
 
 I also loaded this sheet up in OO Calc, which fails every function, often
 on inconsistent error handling or odd behaviour differences.

Let's merge it with the existing tests and get it into CVS.
___
gnumeric-list mailing list
gnumeric-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gnumeric-list