]> git.lyx.org Git - lyx.git/blobdiff - src/graphics/GraphicsCache.cpp
Simplify b3fe9cb7049da
[lyx.git] / src / graphics / GraphicsCache.cpp
index f38188a566a3c649a1981d200ef7f98d22fcdd9c..bf1b3fceff8476590772c89246ec0d1625576b4f 100644 (file)
 
 #include "GraphicsCache.h"
 #include "GraphicsCacheItem.h"
-#include "GraphicsImage.h"
 
-#include "support/debug.h"
+#include "Format.h"
+
+#include "frontends/Application.h"
 
-#include "support/filetools.h"
+#include "support/debug.h"
+#include "support/FileName.h"
 
 #include <map>
 
@@ -59,13 +61,34 @@ Cache::~Cache()
 }
 
 
-vector<string> Cache::loadableFormats() const
+vector<string> const & Cache::loadableFormats() const
 {
-       return Image::loadableFormats();
+       static vector<string> 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));
 }