X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fgraphics%2FGraphicsCache.cpp;h=5f89c56fd43ce7c147241ad36802e22a03df9040;hb=e97daf9e13f450fd1828b944c0db94d0efff52c9;hp=43743535f2504ed8b01e19db2043d01b2245eaf1;hpb=e1ce2f92db49d50c688414a32944be8e718faa2e;p=lyx.git diff --git a/src/graphics/GraphicsCache.cpp b/src/graphics/GraphicsCache.cpp index 43743535f2..5f89c56fd4 100644 --- a/src/graphics/GraphicsCache.cpp +++ b/src/graphics/GraphicsCache.cpp @@ -15,25 +15,27 @@ #include "GraphicsCacheItem.h" #include "GraphicsImage.h" -#include "debug.h" +#include "Format.h" +#include "frontends/Application.h" + +#include "support/debug.h" +#include "support/FileName.h" #include "support/filetools.h" #include -using std::string; - +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: @@ -56,16 +58,39 @@ Cache::Cache() Cache::~Cache() -{} +{ + delete pimpl_; +} -std::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 +99,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)); }