From 0a7ebf229c60143eddd9cbe5f9b87acea1a94e0e Mon Sep 17 00:00:00 2001 From: Georg Baum Date: Thu, 19 Jan 2006 21:18:25 +0000 Subject: [PATCH] fix bug 2192 git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10758 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/ChangeLog | 6 +++++- src/converter.C | 4 +++- src/graphics/ChangeLog | 6 ++++++ src/graphics/GraphicsCacheItem.C | 7 ++++--- src/graphics/GraphicsConverter.C | 7 +++++-- src/insets/ChangeLog | 5 +++++ src/insets/insetgraphics.C | 3 ++- 7 files changed, 30 insertions(+), 8 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index cd425edf93..df4234e1bb 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2006-01-11 Georg Baum + + * converter.C (convert): handle unknown formats + 2006-01-19 Jean-Marc Lasgouttes * cursor.C (goUpDown): comment out some debug messages. @@ -38,7 +42,7 @@ * rowpainter.C (paintPar): always repaint the row with the cursor in it -2006-01-01 Lars Gullik Bjønnes +2006-01-01 Lars Gullik Bjønnes * MenuBackend.h: * bufferlist.h: diff --git a/src/converter.C b/src/converter.C index 4dec5fa2b3..1d5b67c197 100644 --- a/src/converter.C +++ b/src/converter.C @@ -294,7 +294,9 @@ bool Converters::convert(Buffer const * buffer, 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")) + diff --git a/src/graphics/ChangeLog b/src/graphics/ChangeLog index c732bd3502..00ec15395c 100644 --- a/src/graphics/ChangeLog +++ b/src/graphics/ChangeLog @@ -1,3 +1,9 @@ +2006-01-11 Georg Baum + + * GraphicsCacheItem.C (convertToDisplayFormat): handle unknown + formats + * GraphicsConverter.C (Impl, build_script): ditto + 2005-11-02 Angus Leeming * GraphicsCacheItem.C: trivial fix to a MSVS warning. diff --git a/src/graphics/GraphicsCacheItem.C b/src/graphics/GraphicsCacheItem.C index 1d031d8a71..4c11ed6b98 100644 --- a/src/graphics/GraphicsCacheItem.C +++ b/src/graphics/GraphicsCacheItem.C @@ -335,8 +335,10 @@ string const findTargetFormat(string const & from) 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::convertToDisplayFormat() setStatus(ErrorConverting); lyxerr[Debug::GRAPHICS] << "\tCould not determine file format." << endl; - return; } lyxerr[Debug::GRAPHICS] << "\n\tThe file contains " << from << " format data." << endl; diff --git a/src/graphics/GraphicsConverter.C b/src/graphics/GraphicsConverter.C index 8508b2e082..65c517db46 100644 --- a/src/graphics/GraphicsConverter.C +++ b/src/graphics/GraphicsConverter.C @@ -169,8 +169,8 @@ Converter::Impl::Impl(string const & from_file, string const & to_file_base, 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_); @@ -283,6 +283,9 @@ bool build_script(string const & from_file, 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 '.' string const to_file = to_file_base + '.' diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index 6190daeea7..67523c4447 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,8 @@ +2006-01-11 Georg Baum + + * insetgraphics.C (findTargetFormat): document + * insetgraphics.C (prepareFile): handle unknown formats + 2006-01-10 Jean-Marc Lasgouttes * insettext.C (getLabelList): diff --git a/src/insets/insetgraphics.C b/src/insets/insetgraphics.C index 60d3302c4e..e0ce2256ec 100644 --- a/src/insets/insetgraphics.C +++ b/src/insets/insetgraphics.C @@ -128,6 +128,8 @@ string const RemoveExtension(string const & filename) } +/// 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(Buffer const & buf, 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); -- 2.39.5