X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fgraphics%2FGraphicsCache.cpp;h=bf1b3fceff8476590772c89246ec0d1625576b4f;hb=f9c60d477d18a73c85fd277d75aeafb8edc1fbec;hp=89c5053cb6617e51511aa674524a9844fb6aa234;hpb=9439b6e6e0cf950aafe8ce8d76d380c543110db7;p=lyx.git diff --git a/src/graphics/GraphicsCache.cpp b/src/graphics/GraphicsCache.cpp index 89c5053cb6..bf1b3fceff 100644 --- a/src/graphics/GraphicsCache.cpp +++ b/src/graphics/GraphicsCache.cpp @@ -13,11 +13,13 @@ #include "GraphicsCache.h" #include "GraphicsCacheItem.h" -#include "GraphicsImage.h" + +#include "Format.h" + +#include "frontends/Application.h" #include "support/debug.h" #include "support/FileName.h" -#include "support/filetools.h" #include @@ -59,13 +61,34 @@ Cache::~Cache() } -vector Cache::loadableFormats() const +vector const & Cache::loadableFormats() const { - return Image::loadableFormats(); + static vector fmts; + + if (!fmts.empty()) + return fmts; + + for (string const & native_extension : frontend::loadableImageFormats()) { + for (Format const & format : theFormats()) { + if (format.extension() == native_extension) { + fmts.push_back(format.name()); + break; + } + } + } + + if (lyxerr.debugging()) { + LYXERR(Debug::GRAPHICS, "LyX recognises the following image formats:"); + for (string const & format : fmts) { + LYXERR(Debug::GRAPHICS, format << ','); + } + } + + 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 +97,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)); }