]> git.lyx.org Git - lyx.git/blob - src/graphics/ImageLoader.C
Files I removed to remove and add from the former update.
[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 ImageLoader::ImageLoader()
22                 : image_(0)
23 {
24 }
25
26 ImageLoader::~ImageLoader()
27 {
28         freeImage();
29 }
30
31 bool ImageLoader::isImageFormatOK(string const & /*filename*/) const
32 {
33         return false;
34 }
35
36 void ImageLoader::setImage(LyXImage * image)
37 {
38         freeImage();
39
40         image_ = image;
41 }
42
43 void ImageLoader::freeImage()
44 {
45         delete image_;
46         image_ = 0;
47 }
48
49 ImageLoader::FormatList const
50 ImageLoader::loadableFormats() const
51 {
52         return FormatList();
53 }
54
55 ImageLoader::Result
56 ImageLoader::loadImage(string const & filename)
57 {
58         // Make sure file exists and is readable.
59         if (! IsFileReadable(filename)) {
60                 lyxerr << "No XPM file found." << endl;
61                 return NoFile;
62         }
63
64         // Verify that the file format is correct.
65         if (! isImageFormatOK(filename)) {
66                 lyxerr << "File format incorrect." << endl;
67                 return ImageFormatUnknown;
68         }
69
70         freeImage();
71
72         return runImageLoader(filename);
73 }
74