X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fgraphics%2FGraphicsCache.cpp;h=d50856389197f057675ebc910068d81ff7c34534;hb=99c5a46c68bd605c03d4e3a86811831ed7dd3d37;hp=ed87453fa1db32f05491f07570f71469694b6ad8;hpb=9383f4c3c6f9cfab2d658701ba66e2b54cd68bea;p=lyx.git diff --git a/src/graphics/GraphicsCache.cpp b/src/graphics/GraphicsCache.cpp index ed87453fa1..d508563891 100644 --- a/src/graphics/GraphicsCache.cpp +++ b/src/graphics/GraphicsCache.cpp @@ -15,24 +15,27 @@ #include "GraphicsCacheItem.h" #include "GraphicsImage.h" -#include "support/debug.h" +#include "Format.h" + +#include "frontends/Application.h" +#include "support/debug.h" +#include "support/FileName.h" #include "support/filetools.h" #include using namespace std; +using namespace lyx::support; namespace lyx { -using support::FileName; - namespace graphics { /** The cache contains one item per file, so use a map to find the * cache item quickly by filename. */ -typedef std::map CacheType; +typedef map CacheType; class Cache::Impl { public: @@ -60,9 +63,44 @@ Cache::~Cache() } -std::vector Cache::loadableFormats() const +vector const & Cache::loadableFormats() const { - return Image::loadableFormats(); + static vector fmts; + + if (!fmts.empty()) + return fmts; + + // The formats recognised by LyX + Formats::const_iterator begin = formats.begin(); + Formats::const_iterator end = formats.end(); + + // The formats natively loadable. + vector nformat = frontend::loadableImageFormats(); + + vector::const_iterator it = nformat.begin(); + for (; it != nformat.end(); ++it) { + for (Formats::const_iterator fit = begin; fit != end; ++fit) { + if (fit->extension() == *it) { + fmts.push_back(fit->name()); + break; + } + } + } + + if (lyxerr.debugging()) { + LYXERR(Debug::GRAPHICS, "LyX recognises the following image formats:"); + + vector::const_iterator fbegin = fmts.begin(); + vector::const_iterator fend = fmts.end(); + for (vector::const_iterator fit = fbegin; fit != fend; ++fit) { + if (fit != fbegin) + LYXERR(Debug::GRAPHICS, ", "); + LYXERR(Debug::GRAPHICS, *fit); + } + LYXERR(Debug::GRAPHICS, '\n'); + } + + return fmts; }