]> git.lyx.org Git - lyx.git/blob - src/graphics/ImageLoader.C
compilation fixes in the new InsetGraphics stuff
[lyx.git] / src / graphics / ImageLoader.C
1 // -*- C++ -*-
2 /* This file is part of
3  * =================================================
4  * 
5  *          LyX, The Document Processor
6  *          Copyright 1995 Matthias Ettrich.
7  *          Copyright 1995-2000 The LyX Team.
8  *
9  * ================================================= */
10
11 #ifdef __GNUG__
12 #pragma implementation
13 #endif
14
15 #include <config.h>
16 #include "ImageLoader.h"
17 #include "frontends/support/LyXImage.h"
18
19 #include "support/filetools.h"
20
21 using std::endl;
22
23 ImageLoader::ImageLoader()
24                 : image_(0)
25 {
26 }
27
28 ImageLoader::~ImageLoader()
29 {
30         freeImage();
31 }
32
33 bool ImageLoader::isImageFormatOK(string const & /*filename*/) const
34 {
35         return false;
36 }
37
38 void ImageLoader::setImage(LyXImage * image)
39 {
40         freeImage();
41
42         image_ = image;
43 }
44
45 void ImageLoader::freeImage()
46 {
47         delete image_;
48         image_ = 0;
49 }
50
51 ImageLoader::FormatList const
52 ImageLoader::loadableFormats() const
53 {
54         return FormatList();
55 }
56
57 ImageLoader::Result
58 ImageLoader::loadImage(string const & filename)
59 {
60         // Make sure file exists and is readable.
61         if (! IsFileReadable(filename)) {
62                 lyxerr << "No XPM file found." << endl;
63                 return NoFile;
64         }
65
66         // Verify that the file format is correct.
67         if (! isImageFormatOK(filename)) {
68                 lyxerr << "File format incorrect." << endl;
69                 return ImageFormatUnknown;
70         }
71
72         freeImage();
73
74         return runImageLoader(filename);
75 }
76