Il 27/09/2011 23:49, Richard Heck ha scritto:
On 09/27/2011 05:27 PM, Tommaso Cucinotta wrote:
AFAICS, it doesn't find a direct converter from ODG to PNG, so it
gives up. So, my big question:
*) Does LyX embed any (even naive) algorithm for automatically finding
a "conversion path" from a format to another,
Yes. The "primitive" converters are used to define a graph. The nodes
are formats; the edges are converters between formats. Then LyX does a
breadth first search to find a path through this graph. That all happens
in Graph.cpp.
The mystery is why the fall-back to convert isn't employed here.
From my little investigation:
1) there's no path in the graph from ODG to EPS (pls, find attached the
dumped list of registered edges in the graph)
2) when no path is found, there's a fallback trying to use convert
directly from the source to the destination,
no intermediate solutions can be found this way -- see code [1]
from Converter::convert()
3) unfortunately, convert has no clue of how to handle ODG, and the
whole thing fails.
Now, AFAICS, there are 2 possibilities:
a) flood the graph with "low-priority" (or, if you prefer, high-cost)
fake edges, basically from
each node (handled by convert) to any other node (handled by
convert) so that, if no path
exists using the "real" converters path, then the algorithm will
find a path using
*as few fake edges as possible* (if it's true that the algo finds
the shortest path -- but
short here should be counted including this "priority" or "cost" or
"weight" of the edges).
b) simply add to the self-detected converters line a bunch of converters
that fix the graph view
of the reachable formats
c) try heuristically to use an intermediate format recognized by
convert, for example EPS
would seem to me a reasonable choice, so, change the code in [1] in
such a way that,
if the direct conversion from "from" to "to" fails, and from <>
"eps" and to <> "eps", then:
-) try a conversion from "from" to "eps"
-) if it suceeds, try a conversion from "eps" to "to"
-) otherwise fail (or fall back to use another out of a few
intermediate formats, besides eps)
My 2 cents,
T.
[1]
Graph::EdgePath edgepath = getPath(from_format, to_format);
if (edgepath.empty()) {
if (conversionflags & try_default) {
// if no special converter defined, then we take the
// default one from ImageMagic.
string const from_ext = from_format.empty() ?
getExtension(from_file.absFileName()) :
formats.extension(from_format);
string const to_ext = formats.extension(to_format);
string const command =
os::python() + ' ' +
quoteName(libFileSearch("scripts",
"convertDefault.py").toFilesystemEncoding()) +
' ' +
quoteName(from_ext + ':' +
from_file.toFilesystemEncoding()) +
' ' +
quoteName(to_ext + ':' + to_file.toFilesystemEncoding());
LYXERR(Debug::FILES, "No converter defined! "
"I use convertDefault.py:\n\t" << command);
Systemcall one;
one.startscript(Systemcall::Wait, command, buffer ?
buffer->filePath() : string());
Converter.cpp(647): Adding edge converter from latex to dvi
Converter.cpp(647): Adding edge converter from pdflatex to pdf2
Converter.cpp(647): Adding edge converter from xetex to pdf4
Converter.cpp(647): Adding edge converter from latex to lyx
Converter.cpp(647): Adding edge converter from literate to lyx
Converter.cpp(647): Adding edge converter from sweave to latex
Converter.cpp(647): Adding edge converter from sweave to pdflatex
Converter.cpp(647): Adding edge converter from sweave to xetex
Converter.cpp(647): Adding edge converter from sweave to luatex
Converter.cpp(647): Adding edge converter from sweave to r
Converter.cpp(647): Adding edge converter from lyx to html
Converter.cpp(647): Adding edge converter from lyx to wordhtml
Converter.cpp(647): Adding edge converter from sxw to latex
Converter.cpp(647): Adding edge converter from odt to latex
Converter.cpp(647): Adding edge converter from ps to pdf
Converter.cpp(647): Adding edge converter from ps to text3
Converter.cpp(647): Adding edge converter from ps to eps
Converter.cpp(647): Adding edge converter from pdf to ps
Converter.cpp(647): Adding edge converter from pdf to eps
Converter.cpp(647): Adding edge converter from dvi to ps
Converter.cpp(647): Adding edge converter from dvi to pdf3
Converter.cpp(647): Adding edge converter from fig to eps
Converter.cpp(647): Adding edge converter from fig to ppm
Converter.cpp(647): Adding edge converter from fig to png
Converter.cpp(647): Adding edge converter from fig to pdftex
Converter.cpp(647): Adding edge converter from fig to pstex
Converter.cpp(647): Adding edge converter from wmf to eps
Converter.cpp(647): Adding edge converter from emf to eps
Converter.cpp(647): Adding edge converter from eps to pdf
Converter.cpp(647): Adding edge converter from dot to eps
Converter.cpp(647): Adding edge converter from dot to png
Converter.cpp(647): Adding edge converter from dia to png
Converter.cpp(647): Adding edge converter from dia to eps
Converter.cpp(647): Adding edge converter from odg to eps
Converter.cpp(647): Adding edge converter from svg to pdf
Converter.cpp(647): Adding edge converter from svg to eps
Converter.cpp(647): Adding edge converter from svg to png
Converter.cpp(647): Adding edge converter from gnumeric to latex
Converter.cpp(647): Adding edge converter from oocalc to latex
Converter.cpp(647): Adding edge converter from excel to latex
Converter.cpp(647): Adding edge converter from lilypond to eps
Converter.cpp(647): Adding edge converter from lilypond to png
Converter.cpp(647): Adding edge converter from lilypond to pdf
Converter.cpp(647): Adding edge converter from lyx to lyxgz
Converter.cpp(647): Adding edge converter from csv to lyx
Converter.cpp(647): Adding edge converter from date to dateout
Converter.cpp(647): Adding edge converter from docbook to docbook-xml
Converter.cpp(647): Adding edge converter from fen to asciichess
Converter.cpp(647): Adding edge converter from lyx to lyx13x
Converter.cpp(647): Adding edge converter from lyx to lyx14x
Converter.cpp(647): Adding edge converter from lyx to lyx15x
Converter.cpp(647): Adding edge converter from lyx to lyx16x
Converter.cpp(647): Adding edge converter from lyx to lyx20x
Converter.cpp(647): Adding edge converter from lyx to clyx
Converter.cpp(647): Adding edge converter from lyx to jlyx
Converter.cpp(647): Adding edge converter from lyx to klyx
Converter.cpp(647): Adding edge converter from clyx to lyx
Converter.cpp(647): Adding edge converter from jlyx to lyx
Converter.cpp(647): Adding edge converter from klyx to lyx
Converter.cpp(647): Adding edge converter from lyxpreview to png
Converter.cpp(647): Adding edge converter from lyxpreview to ppm
Converter.cpp(647): Adding edge converter from docbook to dvi
Converter.cpp(647): Adding edge converter from docbook to html