Am Mittwoch, 11. Januar 2006 17:48 schrieb Jean-Marc Lasgouttes: > I do not like this png hardcoding thing...
Actually it is not needed at all, because findTargetFormat is not very clever (we discussed this already) > >> Wouldn't it be easier for now to just recognize XCF? > > Georg> I don't know how easy XCF files can be recognized in > Georg> getFormatFromContents(). > > /etc/magic says: > # XCF: file(1) magic for the XCF image format used in the GIMP developed > # by Spencer Kimball and Peter Mattis > # ('Bucky' LaDieu, [EMAIL PROTECTED]) > # (Recognition of versions: Simon Budig <[EMAIL PROTECTED]>) > > 0 string gimp\ xcf GIMP XCF image data, > >9 string file version 0, > >9 string v version > >>10 string >\0 %s, > >14 belong x %lu x > >18 belong x %lu, > >22 belong 0 RGB Color > >22 belong 1 Greyscale > >22 belong 2 Indexed Color > >22 belong >2 Unknown Image Type. > > So the file starts with "gimp xcf". So it should be easy to implement. > Georg> And of course the problem would only be fixed for XCF, this > Georg> patch fixes it for all unknown formats. > > Yes, but in a way I do not like much. And I don't like to touch getFormatFromContents because it should be replaced anyway. I attach an updated patch, this is the last one from me for this bug. If you or somebody else want to fix this differently - fine, but I am only going to do it my way :-) Jean-Marc or Lars, please update bugzilla accordingly if you think that this is not 1.4.0 stuff. Georg
Index: src/ChangeLog =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/ChangeLog,v retrieving revision 1.2355 diff -u -p -r1.2355 ChangeLog --- src/ChangeLog 11 Jan 2006 17:08:49 -0000 1.2355 +++ src/ChangeLog 11 Jan 2006 21:15:07 -0000 @@ -1,3 +1,7 @@ +2006-01-11 Georg Baum <[EMAIL PROTECTED]> + + * converter.C (convert): handle unknown formats + 2006-01-11 Jean-Marc Lasgouttes <[EMAIL PROTECTED]> * cursor.C (macroModeClose): returns true if an inset actually got Index: src/converter.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/converter.C,v retrieving revision 1.107 diff -u -p -r1.107 converter.C --- src/converter.C 16 Jul 2005 16:57:53 -0000 1.107 +++ src/converter.C 11 Jan 2006 21:15:07 -0000 @@ -294,7 +294,9 @@ bool Converters::convert(Buffer const * 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 from_ext = from_format.empty() ? + GetExtension(from_file) : + formats.extension(from_format); string const command = "sh " + QuoteName(LibFileSearch("scripts", "convertDefault.sh")) + Index: src/graphics/ChangeLog =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/graphics/ChangeLog,v retrieving revision 1.221 diff -u -p -r1.221 ChangeLog --- src/graphics/ChangeLog 2 Nov 2005 20:11:36 -0000 1.221 +++ src/graphics/ChangeLog 11 Jan 2006 21:15:08 -0000 @@ -1,3 +1,9 @@ +2006-01-11 Georg Baum <[EMAIL PROTECTED]> + + * GraphicsCacheItem.C (convertToDisplayFormat): handle unknown + formats + * GraphicsConverter.C (Impl, build_script): ditto + 2005-11-02 Angus Leeming <[EMAIL PROTECTED]> * GraphicsCacheItem.C: trivial fix to a MSVS warning. Index: src/graphics/GraphicsCacheItem.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/graphics/GraphicsCacheItem.C,v retrieving revision 1.66 diff -u -p -r1.66 GraphicsCacheItem.C --- src/graphics/GraphicsCacheItem.C 2 Nov 2005 20:11:36 -0000 1.66 +++ src/graphics/GraphicsCacheItem.C 11 Jan 2006 21:15:08 -0000 @@ -335,8 +335,10 @@ string const findTargetFormat(string con typedef lyx::graphics::Image::FormatList FormatList; FormatList const formats = lyx::graphics::Image::loadableFormats(); - // There must be a format to load from. - BOOST_ASSERT(!formats.empty()); + // Use the standard converter if we don't know the format to load + // from. + if (!formats.empty()) + return string("ppm"); // First ascertain if we can load directly with no conversion FormatList::const_iterator it = formats.begin(); @@ -408,7 +410,6 @@ void CacheItem::Impl::convertToDisplayFo setStatus(ErrorConverting); lyxerr[Debug::GRAPHICS] << "\tCould not determine file format." << endl; - return; } lyxerr[Debug::GRAPHICS] << "\n\tThe file contains " << from << " format data." << endl; Index: src/graphics/GraphicsConverter.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/graphics/GraphicsConverter.C,v retrieving revision 1.50 diff -u -p -r1.50 GraphicsConverter.C --- src/graphics/GraphicsConverter.C 26 Apr 2005 11:12:18 -0000 1.50 +++ src/graphics/GraphicsConverter.C 11 Jan 2006 21:15:08 -0000 @@ -169,8 +169,8 @@ Converter::Impl::Impl(string const & fro script_command_ = "sh " + QuoteName(LibFileSearch("scripts", "convertDefault.sh")) + - ' ' + - QuoteName(from_format + ':' + from_file) + + ' ' + + QuoteName((from_format.empty() ? "" : from_format + ':') + from_file) + ' ' + QuoteName(to_format + ':' + to_file_); @@ -282,6 +282,9 @@ bool build_script(string const & from_fi { lyxerr[Debug::GRAPHICS] << "build_script ... "; typedef Converters::EdgePath EdgePath; + + if (from_format.empty()) + return false; // we do not use ChangeExtension because this is a basename // which may nevertheless contain a '.' Index: src/insets/ChangeLog =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/ChangeLog,v retrieving revision 1.1212 diff -u -p -r1.1212 ChangeLog --- src/insets/ChangeLog 11 Jan 2006 14:22:09 -0000 1.1212 +++ src/insets/ChangeLog 11 Jan 2006 21:15:11 -0000 @@ -1,3 +1,8 @@ +2006-01-11 Georg Baum <[EMAIL PROTECTED]> + + * insetgraphics.C (findTargetFormat): document + * insetgraphics.C (prepareFile): handle unknown formats + 2006-01-10 Jean-Marc Lasgouttes <[EMAIL PROTECTED]> * insettext.C (getLabelList): Index: src/insets/insetgraphics.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetgraphics.C,v retrieving revision 1.283 diff -u -p -r1.283 insetgraphics.C --- src/insets/insetgraphics.C 9 Jan 2006 21:00:23 -0000 1.283 +++ src/insets/insetgraphics.C 11 Jan 2006 21:15:11 -0000 @@ -128,6 +128,8 @@ string const RemoveExtension(string cons } +/// Find the most suitable image format for images in \p format +/// Note that \p format may be unknown (i. e. an empty string) string findTargetFormat(string const & format, OutputParams const & runparams) { // Are we using latex or pdflatex? @@ -661,7 +663,6 @@ string const InsetGraphics::prepareFile( if (from.empty()) { lyxerr[Debug::GRAPHICS] << "\tCould not get file format." << endl; - return orig_file; } string const to = findTargetFormat(from, runparams); string const ext = formats.extension(to);