X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fgraphics%2FGraphicsCache.cpp;h=dbf9cafa5e93d0e14ccbefce7ab646280947cbfa;hb=c8230ab0d0a919530c43c29395f4d9961498bf15;hp=f38188a566a3c649a1981d200ef7f98d22fcdd9c;hpb=9abb7db46800e554f57e865a3e768602ffd9d6f1;p=lyx.git diff --git a/src/graphics/GraphicsCache.cpp b/src/graphics/GraphicsCache.cpp index f38188a566..dbf9cafa5e 100644 --- a/src/graphics/GraphicsCache.cpp +++ b/src/graphics/GraphicsCache.cpp @@ -15,8 +15,12 @@ #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 @@ -59,13 +63,45 @@ Cache::~Cache() } -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 = theFormats().begin(); + Formats::const_iterator end = theFormats().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) { + LYXERR(Debug::GRAPHICS, *fit << ','); + } + } + + return fmts; } -void Cache::add(FileName const & file) const +void Cache::add(FileName const & file, FileName const & doc_file) const { // Is the file in the cache already? if (inCache(file)) { @@ -74,7 +110,7 @@ void Cache::add(FileName const & file) const return; } - pimpl_->cache[file] = ItemPtr(new CacheItem(file)); + pimpl_->cache[file] = ItemPtr(new CacheItem(file, doc_file)); }