Re: cmd-line conversion of gnumeric and ods files.

2011-07-30 Thread Pavel Sanda
Tommaso Cucinotta wrote:
 for the particular case of dia the distinction makes no big sense indeed,
 its more of letting user to know that we do support dia at all...

 I see - this would be addressable via a selection combo-box in the
 GuiGraphics dialog which could be very similar to the one you have
 in the GuiExternal dialog.

note that i'm not proposing that this 'letting know' must stay there.
(better to kill it completely than add just next hardcoded set of
extensions to edialog etc.) the only 'must' is that older documents
still work.

 (another point was to distinguish drawing formats we support out of the 
 box
 with imagemagick and which require external tools, like dia. we have
 already broken this with eg .svg though.)

 Isn't ImageMagick an external tool as well ?

well, even python is :) so the distinction is more about which tools
are installed by default with lyx. imagemagick is.

pavel


Re: cmd-line conversion of gnumeric and ods files.

2011-07-30 Thread Pavel Sanda
Tommaso Cucinotta wrote:
>> for the particular case of dia the distinction makes no big sense indeed,
>> its more of letting user to know that we do support dia at all...
>
> I see - this would be addressable via a selection combo-box in the
> GuiGraphics dialog which could be very similar to the one you have
> in the GuiExternal dialog.

note that i'm not proposing that this 'letting know' must stay there.
(better to kill it completely than add just next hardcoded set of
extensions to edialog etc.) the only 'must' is that older documents
still work.

>> (another point was to distinguish drawing formats we support out of the 
>> box
>> with imagemagick and which require external tools, like dia. we have
>> already broken this with eg .svg though.)
>
> Isn't ImageMagick an external tool as well ?

well, even python is :) so the distinction is more about which tools
are installed by default with lyx. imagemagick is.

pavel


Re: cmd-line conversion of gnumeric and ods files.

2011-07-29 Thread Pavel Sanda
Tommaso Cucinotta wrote:
 1) AFAICS, there's really no reason for keeping .dia drawings as templates.

for the particular case of dia the distinction makes no big sense indeed,
its more of letting user to know that we do support dia at all...
(another point was to distinguish drawing formats we support out of the box
with imagemagick and which require external tools, like dia. we have
already broken this with eg .svg though.)

pavel


Re: cmd-line conversion of gnumeric and ods files.

2011-07-29 Thread Tommaso Cucinotta

Il 29/07/2011 10:55, Pavel Sanda ha scritto:

Tommaso Cucinotta wrote:

1) AFAICS, there's really no reason for keeping .dia drawings as templates.

for the particular case of dia the distinction makes no big sense indeed,
its more of letting user to know that we do support dia at all...


I see - this would be addressable via a selection combo-box in the
GuiGraphics dialog which could be very similar to the one you have
in the GuiExternal dialog.
So, the unexperienced user would simply type a tentative name for
the new graphics, choose from the combo the type (and he/she would
see we have .dia, and choosing it we'd have a short description saying
its a vectorial graphics editor [or it could come through a tooltip]),
then go for Create/Edit and proceed.

(another point was to distinguish drawing formats we support out of the box
with imagemagick and which require external tools, like dia. we have
already broken this with eg .svg though.)


Isn't ImageMagick an external tool as well ?

Btw, the key point is making the user aware of (at least) the open-source
tools that can be used along with LyX, for a better document writing
experience. This could be documented in the user guide, plus in Debian-
based packages of LyX we could have the suggested dependencies
enumerating the supported editors/viewers/converters (as I'm seeing
we already have).

T.


Re: cmd-line conversion of gnumeric and ods files.

2011-07-29 Thread Pavel Sanda
Tommaso Cucinotta wrote:
> 1) AFAICS, there's really no reason for keeping .dia drawings as templates.

for the particular case of dia the distinction makes no big sense indeed,
its more of letting user to know that we do support dia at all...
(another point was to distinguish drawing formats we support out of the box
with imagemagick and which require external tools, like dia. we have
already broken this with eg .svg though.)

pavel


Re: cmd-line conversion of gnumeric and ods files.

2011-07-29 Thread Tommaso Cucinotta

Il 29/07/2011 10:55, Pavel Sanda ha scritto:

Tommaso Cucinotta wrote:

1) AFAICS, there's really no reason for keeping .dia drawings as templates.

for the particular case of dia the distinction makes no big sense indeed,
its more of letting user to know that we do support dia at all...


I see - this would be addressable via a selection combo-box in the
GuiGraphics dialog which could be very similar to the one you have
in the GuiExternal dialog.
So, the unexperienced user would simply type a tentative name for
the new graphics, choose from the combo the type (and he/she would
see we have .dia, and choosing it we'd have a short description saying
its a vectorial graphics editor [or it could come through a tooltip]),
then go for Create/Edit and proceed.

(another point was to distinguish drawing formats we support out of the box
with imagemagick and which require external tools, like dia. we have
already broken this with eg .svg though.)


Isn't ImageMagick an external tool as well ?

Btw, the key point is making the user aware of (at least) the open-source
tools that can be used along with LyX, for a better document writing
experience. This could be documented in the user guide, plus in Debian-
based packages of LyX we could have the "suggested" dependencies
enumerating the supported editors/viewers/converters (as I'm seeing
we already have).

T.


Re: cmd-line conversion of gnumeric and ods files.

2011-07-27 Thread Tommaso Cucinotta

Il 26/07/2011 15:59, Richard Heck ha scritto:

On 07/26/2011 06:14 AM, Tommaso Cucinotta wrote:

For OpenOffice drawings (.odg), I found this:
   unoconv --stdout -f eps sample.odg | ps2eps  a.eps

(ps2eps is needed to fix the bounding box otherwise I get a whole page
in the .eps)

What is the proper way to customise LyX so as to do that automatically
for me ?

I believe this is what external templates are for, but I do not know how
to use them.


Probably after some roaming in the dark, I eventually got the difference 
between external templates and images: an external template is supposed 
to be converted to LaTeX code, then included someway into the document 
and compiled together with it, whilst an image is converted by LyX 
itself to an image format before actually compiling the document.


A couple of thoughts I'd like to share:

1) AFAICS, there's really no reason for keeping .dia drawings as templates.
2) From a usability perspective, wouldn't it be nice to have a unified 
interface ? After all, inserting an image is a particular type of 
Insert-File operation.
3) In those few cases in which both things are possible (AFAICS, XFig 
figures can either be converted to an image format if inserted as image, 
or converted to latex if inserted as external template), it would be 
sufficient a disambiguation checkbox insert as image (or similar) in 
the properties pane.


Bye,

T.



Re: cmd-line conversion of gnumeric and ods files.

2011-07-27 Thread Tommaso Cucinotta

Il 26/07/2011 15:59, Richard Heck ha scritto:

On 07/26/2011 06:14 AM, Tommaso Cucinotta wrote:

For OpenOffice drawings (.odg), I found this:
   unoconv --stdout -f eps sample.odg | ps2eps>  a.eps

(ps2eps is needed to fix the bounding box otherwise I get a whole page
in the .eps)

What is the proper way to customise LyX so as to do that automatically
for me ?

I believe this is what external templates are for, but I do not know how
to use them.


Probably after some roaming in the dark, I eventually got the difference 
between external templates and images: an external template is supposed 
to be converted to LaTeX code, then included someway into the document 
and compiled together with it, whilst an image is converted by LyX 
itself to an image format before actually compiling the document.


A couple of thoughts I'd like to share:

1) AFAICS, there's really no reason for keeping .dia drawings as templates.
2) From a usability perspective, wouldn't it be nice to have a unified 
interface ? After all, inserting an image is a particular type of 
Insert->File operation.
3) In those few cases in which both things are possible (AFAICS, XFig 
figures can either be converted to an image format if inserted as image, 
or converted to latex if inserted as external template), it would be 
sufficient a disambiguation checkbox "insert as image" (or similar) in 
the properties pane.


Bye,

T.



cmd-line conversion of gnumeric and ods files.

2011-07-26 Thread Tommaso Cucinotta

Hi all,

is there a way to get from the command-line a gnumeric spreadsheet and 
an OpenOffice drawing (.odg) or spreadsheet (.ods) converted to a format 
suitable for LaTeX/LyX ? For example, something that gets an .eps or 
.pdf out of those formats ?


Thanks,

Tommaso



Re: cmd-line conversion of gnumeric and ods files.

2011-07-26 Thread Tommaso Cucinotta

Il 26/07/2011 11:54, Tommaso Cucinotta ha scritto:

Hi all,

is there a way to get from the command-line a gnumeric spreadsheet and 
an OpenOffice drawing (.odg) or spreadsheet (.ods) converted to a 
format suitable for LaTeX/LyX ? For example, something that gets an 
.eps or .pdf out of those formats ?


For OpenOffice drawings (.odg), I found this:

  unoconv --stdout -f eps sample.odg | ps2eps  a.eps

(ps2eps is needed to fix the bounding box otherwise I get a whole page 
in the .eps)


What is the proper way to customise LyX so as to do that automatically 
for me ?
(is unoconv supported among the automatically detected converters with 
reconfigure ?)


Thanks,

T.



Re: cmd-line conversion of gnumeric and ods files.

2011-07-26 Thread Richard Heck
On 07/26/2011 06:14 AM, Tommaso Cucinotta wrote:
 Il 26/07/2011 11:54, Tommaso Cucinotta ha scritto:
 Hi all,

 is there a way to get from the command-line a gnumeric spreadsheet
 and an OpenOffice drawing (.odg) or spreadsheet (.ods) converted to a
 format suitable for LaTeX/LyX ? For example, something that gets an
 .eps or .pdf out of those formats ?

 For OpenOffice drawings (.odg), I found this:

   unoconv --stdout -f eps sample.odg | ps2eps  a.eps

 (ps2eps is needed to fix the bounding box otherwise I get a whole page
 in the .eps)

 What is the proper way to customise LyX so as to do that automatically
 for me ?
 (is unoconv supported among the automatically detected converters with
 reconfigure ?)

I believe this is what external templates are for, but I do not know how
to use them.

Richard



Re: cmd-line conversion of gnumeric and ods files.

2011-07-26 Thread Julien Rioux

On 26/07/2011 6:14 AM, Tommaso Cucinotta wrote:

Il 26/07/2011 11:54, Tommaso Cucinotta ha scritto:

Hi all,

is there a way to get from the command-line a gnumeric spreadsheet and
an OpenOffice drawing (.odg) or spreadsheet (.ods) converted to a
format suitable for LaTeX/LyX ? For example, something that gets an
.eps or .pdf out of those formats ?


For OpenOffice drawings (.odg), I found this:

unoconv --stdout -f eps sample.odg | ps2eps  a.eps

(ps2eps is needed to fix the bounding box otherwise I get a whole page
in the .eps)

What is the proper way to customise LyX so as to do that automatically
for me ?
(is unoconv supported among the automatically detected converters with
reconfigure ?)

Thanks,

T.




You can define a converter from odg to eps in Preferences  File 
Handling  Converters. You might first have to define the odg format. 
Then you can insert odg files as graphics.


Cheers,
Julien



Image Lifecycle Patch (was: Re: cmd-line conversion of gnumeric and ods files.)

2011-07-26 Thread Tommaso Cucinotta

Il 26/07/2011 17:33, Julien Rioux ha scritto:
You can define a converter from odg to eps in Preferences  File 
Handling  Converters. You might first have to define the odg format. 
Then you can insert odg files as graphics.


In the attached patch, I just realised what is my ideal lifecycle for 
working with images.


This is how it works:
a) I'm writing a LyX document
b) I realise I need an image, so: Insert-Image... dialog,
c) I enter a file-name for a vectorial format, like architecture.odg
d) I push the Create/Edit button, and I confirm I want a new file created
from an empty sample
e) I edit my diagram with LibreOffice, then save it (and/or exit 
LibreOffice)
f) Whenever I need to edit it back, I use the [Right Click]-[Edit 
Externally] feature,
   or I pop-up the properties pane and I press the Create/Edit button 
again


The key point is that, for creating the new drawing, I don't have to 
launch my image editor independently, then pointing it to the same 
folder where I have my .lyx file for saving a new file, then back to LyX 
and have the file finally inserted as Image in LyX. That's a burden. 
With the steps above, it all gets simpler and just gives you the feeling 
that the whole image creation/insertion/editing lifecycle is well 
integrated with LyX.
Note that I don't have to manually save from OpenOffice to .eps, then 
insert in LyX the .eps. I just save the .odg, and LyX converts it for me 
(but I didn't try the pdflatex way of generating the output yet -- my 
guess is that, once LyX knows how to convert that .odg thing, it will 
get the right toolchain automagically).


The only feature I'm missing is that the (non-expert) user doesn't get a 
list of possible image formats, something that would be very useful 
indeed (a'la Insert-ExternalMaterial dialog combo-box...), with a short 
description (mainly the user would need to know/choose whether he/she 
needs a raster/bitmap or vectorial image format).


The weird check on the file extensions that you can see in the patch is 
needed to avoid that LyX thinks that .odg is a compressed archive and 
tries wastefully to uncompress its contents for being able to do nothing 
with that later. In such cases, I just need LyX to think that .odg is 
.odg and look for converters to other formats for rendering purposes.


Any comments welcome.

Bye,

T.
Index: src/frontends/qt4/GuiGraphics.cpp
===
--- src/frontends/qt4/GuiGraphics.cpp	(revisione 39369)
+++ src/frontends/qt4/GuiGraphics.cpp	(copia locale)
@@ -24,6 +24,7 @@
 #include LengthCombo.h
 #include Length.h
 #include LyXRC.h
+#include Format.h
 
 #include graphics/GraphicsCache.h
 #include graphics/GraphicsCacheItem.h
@@ -358,6 +359,43 @@
 }
 
 
+void GuiGraphics::on_createOrEditPB_clicked()
+{
+	printf(Hello world!\n);
+	string const fname = fromqstr(filename-text());
+	FileName dest_fname(FileName(fromqstr(bufferFilePath())), fname);
+	string fmt_name = lyx::formats.getFormatFromFile(FileName(fname));
+	if (fmt_name.empty()) {
+		Alert::warning(_(Format not found), _(It was not possible to infer the format from the file contents or its name.));
+		return;
+	}
+	if (!dest_fname.exists()) {
+		int create = frontend::Alert::prompt(
+			_(Create ?), _(File does not exist. Create from empty sample ?),
+			0, 1, _(Yes), _(No));
+		if (create != 0)
+			return;
+
+		Format const *fmt = formats.getFormat(fmt_name);
+		string sample_name = string(sample.) + fmt-extension();
+		if (sample_name.empty()) {
+			Alert::warning(_(Format sample not found), _(Cannot find a format sample to use as empty file));
+			return;
+		}
+		FileName sample_fname = libFileSearch(toqstr(samples), toqstr(sample_name));
+		if (!sample_fname.exists()) {
+			Alert::warning(_(Format sample not found), _(Cannot find a format sample to use as empty file));
+			return;
+		}
+		sample_fname.copyTo(dest_fname);
+		frontend::Alert::information(_(Information), bformat(_(Empty file created from sample: %1$s), from_utf8(dest_fname.realPath(;
+		dest_fname.refresh();
+	}
+
+	formats.edit(buffer(), dest_fname, fmt_name);
+}
+
+
 void GuiGraphics::on_getPB_clicked()
 {
 	getBB();
Index: src/frontends/qt4/GuiGraphics.h
===
--- src/frontends/qt4/GuiGraphics.h	(revisione 39369)
+++ src/frontends/qt4/GuiGraphics.h	(copia locale)
@@ -45,6 +45,7 @@
 	void on_newGroupPB_clicked();
 	void on_browsePB_clicked();
 	void on_getPB_clicked();
+	void on_createOrEditPB_clicked();
 	void on_scaleCB_toggled(bool);
 	void on_WidthCB_toggled(bool);
 	void on_HeightCB_toggled(bool);
Index: src/frontends/qt4/ui/GraphicsUi.ui
===
--- src/frontends/qt4/ui/GraphicsUi.ui	(revisione 39369)
+++ src/frontends/qt4/ui/GraphicsUi.ui	(copia locale)
@@ -277,6 +277,13 @@
  /property
 /widget
/item
+   item row=0 column=4
+widget 

cmd-line conversion of gnumeric and ods files.

2011-07-26 Thread Tommaso Cucinotta

Hi all,

is there a way to get from the command-line a gnumeric spreadsheet and 
an OpenOffice drawing (.odg) or spreadsheet (.ods) converted to a format 
suitable for LaTeX/LyX ? For example, something that gets an .eps or 
.pdf out of those formats ?


Thanks,

Tommaso



Re: cmd-line conversion of gnumeric and ods files.

2011-07-26 Thread Tommaso Cucinotta

Il 26/07/2011 11:54, Tommaso Cucinotta ha scritto:

Hi all,

is there a way to get from the command-line a gnumeric spreadsheet and 
an OpenOffice drawing (.odg) or spreadsheet (.ods) converted to a 
format suitable for LaTeX/LyX ? For example, something that gets an 
.eps or .pdf out of those formats ?


For OpenOffice drawings (.odg), I found this:

  unoconv --stdout -f eps sample.odg | ps2eps > a.eps

(ps2eps is needed to fix the bounding box otherwise I get a whole page 
in the .eps)


What is the proper way to customise LyX so as to do that automatically 
for me ?
(is unoconv supported among the automatically detected converters with 
reconfigure ?)


Thanks,

T.



Re: cmd-line conversion of gnumeric and ods files.

2011-07-26 Thread Richard Heck
On 07/26/2011 06:14 AM, Tommaso Cucinotta wrote:
> Il 26/07/2011 11:54, Tommaso Cucinotta ha scritto:
>> Hi all,
>>
>> is there a way to get from the command-line a gnumeric spreadsheet
>> and an OpenOffice drawing (.odg) or spreadsheet (.ods) converted to a
>> format suitable for LaTeX/LyX ? For example, something that gets an
>> .eps or .pdf out of those formats ?
>
> For OpenOffice drawings (.odg), I found this:
>
>   unoconv --stdout -f eps sample.odg | ps2eps > a.eps
>
> (ps2eps is needed to fix the bounding box otherwise I get a whole page
> in the .eps)
>
> What is the proper way to customise LyX so as to do that automatically
> for me ?
> (is unoconv supported among the automatically detected converters with
> reconfigure ?)
>
I believe this is what external templates are for, but I do not know how
to use them.

Richard



Re: cmd-line conversion of gnumeric and ods files.

2011-07-26 Thread Julien Rioux

On 26/07/2011 6:14 AM, Tommaso Cucinotta wrote:

Il 26/07/2011 11:54, Tommaso Cucinotta ha scritto:

Hi all,

is there a way to get from the command-line a gnumeric spreadsheet and
an OpenOffice drawing (.odg) or spreadsheet (.ods) converted to a
format suitable for LaTeX/LyX ? For example, something that gets an
.eps or .pdf out of those formats ?


For OpenOffice drawings (.odg), I found this:

unoconv --stdout -f eps sample.odg | ps2eps > a.eps

(ps2eps is needed to fix the bounding box otherwise I get a whole page
in the .eps)

What is the proper way to customise LyX so as to do that automatically
for me ?
(is unoconv supported among the automatically detected converters with
reconfigure ?)

Thanks,

T.




You can define a converter from odg to eps in Preferences > File 
Handling > Converters. You might first have to define the odg format. 
Then you can insert odg files as graphics.


Cheers,
Julien



Image Lifecycle Patch (was: Re: cmd-line conversion of gnumeric and ods files.)

2011-07-26 Thread Tommaso Cucinotta

Il 26/07/2011 17:33, Julien Rioux ha scritto:
You can define a converter from odg to eps in Preferences > File 
Handling > Converters. You might first have to define the odg format. 
Then you can insert odg files as graphics.


In the attached patch, I just realised what is my "ideal" lifecycle for 
working with images.


This is how it works:
a) I'm writing a LyX document
b) I realise I need an image, so: Insert->Image... dialog,
c) I enter a file-name for a vectorial format, like "architecture.odg"
d) I push the "Create/Edit" button, and I confirm I want a new file created
from an empty sample
e) I edit my diagram with LibreOffice, then save it (and/or exit 
LibreOffice)
f) Whenever I need to edit it back, I use the [Right Click]->[Edit 
Externally] feature,
   or I pop-up the properties pane and I press the "Create/Edit" button 
again


The key point is that, for creating the new drawing, I don't have to 
launch my image editor independently, then pointing it to the same 
folder where I have my .lyx file for saving a new file, then back to LyX 
and have the file finally inserted as Image in LyX. That's a burden. 
With the steps above, it all gets simpler and just gives you the feeling 
that the whole image creation/insertion/editing lifecycle is well 
integrated with LyX.
Note that I don't have to manually save from OpenOffice to .eps, then 
insert in LyX the .eps. I just save the .odg, and LyX converts it for me 
(but I didn't try the pdflatex way of generating the output yet -- my 
guess is that, once LyX knows how to convert that .odg thing, it will 
get the right toolchain automagically).


The only feature I'm missing is that the (non-expert) user doesn't get a 
list of possible image formats, something that would be very useful 
indeed (a'la Insert->ExternalMaterial dialog combo-box...), with a short 
description (mainly the user would need to know/choose whether he/she 
needs a raster/bitmap or vectorial image format).


The weird check on the file extensions that you can see in the patch is 
needed to avoid that LyX thinks that .odg is a compressed archive and 
tries wastefully to uncompress its contents for being able to do nothing 
with that later. In such cases, I just need LyX to think that .odg is 
.odg and look for converters to other formats for rendering purposes.


Any comments welcome.

Bye,

T.
Index: src/frontends/qt4/GuiGraphics.cpp
===
--- src/frontends/qt4/GuiGraphics.cpp	(revisione 39369)
+++ src/frontends/qt4/GuiGraphics.cpp	(copia locale)
@@ -24,6 +24,7 @@
 #include "LengthCombo.h"
 #include "Length.h"
 #include "LyXRC.h"
+#include "Format.h"
 
 #include "graphics/GraphicsCache.h"
 #include "graphics/GraphicsCacheItem.h"
@@ -358,6 +359,43 @@
 }
 
 
+void GuiGraphics::on_createOrEditPB_clicked()
+{
+	printf("Hello world!\n");
+	string const fname = fromqstr(filename->text());
+	FileName dest_fname(FileName(fromqstr(bufferFilePath())), fname);
+	string fmt_name = lyx::formats.getFormatFromFile(FileName(fname));
+	if (fmt_name.empty()) {
+		Alert::warning(_("Format not found"), _("It was not possible to infer the format from the file contents or its name."));
+		return;
+	}
+	if (!dest_fname.exists()) {
+		int create = frontend::Alert::prompt(
+			_("Create ?"), _("File does not exist. Create from empty sample ?"),
+			0, 1, _(""), _(""));
+		if (create != 0)
+			return;
+
+		Format const *fmt = formats.getFormat(fmt_name);
+		string sample_name = string("sample.") + fmt->extension();
+		if (sample_name.empty()) {
+			Alert::warning(_("Format sample not found"), _("Cannot find a format sample to use as empty file"));
+			return;
+		}
+		FileName sample_fname = libFileSearch(toqstr("samples"), toqstr(sample_name));
+		if (!sample_fname.exists()) {
+			Alert::warning(_("Format sample not found"), _("Cannot find a format sample to use as empty file"));
+			return;
+		}
+		sample_fname.copyTo(dest_fname);
+		frontend::Alert::information(_("Information"), bformat(_("Empty file created from sample: %1$s"), from_utf8(dest_fname.realPath(;
+		dest_fname.refresh();
+	}
+
+	formats.edit(buffer(), dest_fname, fmt_name);
+}
+
+
 void GuiGraphics::on_getPB_clicked()
 {
 	getBB();
Index: src/frontends/qt4/GuiGraphics.h
===
--- src/frontends/qt4/GuiGraphics.h	(revisione 39369)
+++ src/frontends/qt4/GuiGraphics.h	(copia locale)
@@ -45,6 +45,7 @@
 	void on_newGroupPB_clicked();
 	void on_browsePB_clicked();
 	void on_getPB_clicked();
+	void on_createOrEditPB_clicked();
 	void on_scaleCB_toggled(bool);
 	void on_WidthCB_toggled(bool);
 	void on_HeightCB_toggled(bool);
Index: src/frontends/qt4/ui/GraphicsUi.ui
===
--- src/frontends/qt4/ui/GraphicsUi.ui	(revisione 39369)
+++ src/frontends/qt4/ui/GraphicsUi.ui	(copia locale)
@@ -277,6 +277,13 @@
  
 

+   
+
+