+2005-01-14 Georg Baum <Georg.Baum@post.rwth-aachen.de>
+
+ * converter.[Ch] (convert): take a new parameter try_default. Use
+ a default converter (imagemagick) if try_default is true.
+
2005-01-13 Angus Leeming <leeming@lyx.org>
* lyxrc.C (read): use LyXRC::cygwin_path_fix to set the value of
using lyx::support::contains;
using lyx::support::DirList;
using lyx::support::GetExtension;
+using lyx::support::IsFileReadable;
+using lyx::support::LibFileSearch;
using lyx::support::LibScriptSearch;
using lyx::support::MakeRelPath;
using lyx::support::OnlyFilename;
bool Converters::convert(Buffer const * buffer,
string const & from_file, string const & to_file_base,
string const & from_format, string const & to_format,
- string & to_file)
+ string & to_file, bool try_default)
{
- to_file = ChangeExtension(to_file_base,
- formats.extension(to_format));
+ string const to_ext = formats.extension(to_format);
+ to_file = ChangeExtension(to_file_base, to_ext);
if (from_format == to_format)
return move(from_format, from_file, to_file, false);
Graph::EdgePath edgepath = getPath(from_format, to_format);
if (edgepath.empty()) {
+ if (try_default) {
+ // if no special converter defined, then we take the
+ // default one from ImageMagic.
+ string const from_ext = formats.extension(from_format);
+ string const command = "sh " +
+ LibFileSearch("scripts", "convertDefault.sh") +
+ ' ' + from_ext + ':' + from_file +
+ ' ' + to_ext + ':' + to_file;
+ lyxerr[Debug::FILES]
+ << "No converter defined! "
+ "I use convertDefault.sh:\n\t"
+ << command << endl;
+ Systemcall one;
+ one.startscript(Systemcall::Wait, command);
+ if (IsFileReadable(to_file)) {
+ return true;
+ }
+ }
+ Alert::error(_("Cannot convert file"),
+ bformat(_("No information for converting %1$s "
+ "format files to %2$s.\n"
+ "Try defining a convertor in the preferences."),
+ from_format, to_format));
return false;
}
OutputParams runparams;
bool Converters::convert(Buffer const * buffer,
string const & from_file, string const & to_file_base,
- string const & from_format, string const & to_format)
+ string const & from_format, string const & to_format,
+ bool try_default)
{
string to_file;
return convert(buffer, from_file, to_file_base, from_format, to_format,
- to_file);
+ to_file, try_default);
}
bool convert(Buffer const * buffer,
std::string const & from_file, std::string const & to_file_base,
std::string const & from_format, std::string const & to_format,
- std::string & to_file);
+ std::string & to_file, bool try_default = false);
///
bool convert(Buffer const * buffer,
std::string const & from_file, std::string const & to_file_base,
- std::string const & from_format, std::string const & to_format);
+ std::string const & from_format, std::string const & to_format,
+ bool try_default = false);
///
void update(Formats const & formats);
///
+2005-01-14 Georg Baum <Georg.Baum@post.rwth-aachen.de>
+
+ * insetgraphics.C (prepareFile): move the invocation of the default
+ converter to ../converter.C
+ * insetgraphics.C (prepareFile), ExternalSupport.C (updateExternal):
+ call convert with try_default == true
+
2005-01-11 Georg Baum <Georg.Baum@post.rwth-aachen.de>
* insetgraphics.C (prepareFile): add missing calls to addExternalFile
- * updateExternal.[Ch] (doSubstitution): take a new parameter that
+ * ExternalSupport.[Ch] (doSubstitution): take a new parameter that
determines what variables are substituted
- * updateExternal.C (updateExternal): fix substitution of
+ * ExternalSupport.C (updateExternal): fix substitution of
ReferencedFiles
2005-01-10 Angus Leeming <leeming@lyx.org>
support::ChangeExtension(to_file, string());
/* bool const success = */
converters.convert(&buffer, temp_file, to_file_base,
- from_format, to_format);
+ from_format, to_format, true);
// return success
}
using lyx::support::float_equal;
using lyx::support::GetExtension;
using lyx::support::IsFileReadable;
-using lyx::support::LibFileSearch;
using lyx::support::OnlyFilename;
using lyx::support::rtrim;
using lyx::support::strToDbl;
<< "\tfile to convert = " << temp_file << '\n'
<< "\t from " << from << " to " << to << '\n';
- // if no special converter defined, then we take the default one
- // from ImageMagic: convert from:inname.from to:outname.to
- if (converters.convert(&buf, temp_file, temp_file, from, to)) {
+ if (converters.convert(&buf, temp_file, temp_file, from, to, true)) {
runparams.exportdata->addExternalFile("latex",
to_file, output_to_file);
runparams.exportdata->addExternalFile("dvi",
to_file, output_to_file);
- } else {
- string const command =
- "sh " + LibFileSearch("scripts", "convertDefault.sh") +
- ' ' + formats.extension(from) + ':' + temp_file +
- ' ' + ext + ':' + to_file;
- lyxerr[Debug::GRAPHICS]
- << "No converter defined! I use convertDefault.sh:\n\t"
- << command << endl;
- Systemcall one;
- one.startscript(Systemcall::Wait, command);
- if (IsFileReadable(to_file)) {
- runparams.exportdata->addExternalFile("latex",
- to_file, output_to_file);
- runparams.exportdata->addExternalFile("dvi",
- to_file, output_to_file);
- } else {
- string str = bformat(_("No information for converting %1$s "
- "format files to %2$s.\n"
- "Try defining a convertor in the preferences."), from, to);
- Alert::error(_("Could not convert image"), str);
- }
}
return stripExtension(output_file);