#include "GraphicsCache.h"
#include "GraphicsCacheItem.h"
-#include "GraphicsImage.h"
-#include "support/debug.h"
+#include "Format.h"
-#include "support/filetools.h"
+#include "frontends/Application.h"
-#include <map>
+#include "support/debug.h"
+#include "support/FileName.h"
-using std::string;
+#include <map>
+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<FileName, Cache::ItemPtr> CacheType;
+typedef map<FileName, Cache::ItemPtr> CacheType;
class Cache::Impl {
public:
}
-std::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)) {
return;
}
- pimpl_->cache[file] = ItemPtr(new CacheItem(file));
+ pimpl_->cache[file] = ItemPtr(new CacheItem(file, doc_file));
}