]> git.lyx.org Git - lyx.git/blob - src/graphics/ImageLoader.C
small fix with footnote, use stringstream some more
[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 void
34 ImageLoader::freeImage()
35 {
36         delete image_;
37         image_ = 0;
38 }
39
40 bool ImageLoader::isImageFormatOK(string const & /*filename*/) const
41 {
42         return false;
43 }
44
45 void ImageLoader::setImage(LyXImage * image)
46 {
47         image_ = image;
48 }
49
50 LyXImage * ImageLoader::getImage()
51 {
52         LyXImage * tmp = image_;
53         image_ = 0;
54         return tmp;
55 }
56
57 ImageLoader::FormatList const
58 ImageLoader::loadableFormats() const
59 {
60         return FormatList();
61 }
62
63 ImageLoader::Result
64 ImageLoader::loadImage(string const & filename)
65 {
66         // Make sure file exists and is readable.
67         if (! IsFileReadable(filename)) {
68                 lyxerr << "No XPM file found." << endl;
69                 return NoFile;
70         }
71
72         // Verify that the file format is correct.
73         if (! isImageFormatOK(filename)) {
74                 lyxerr << "File format incorrect." << endl;
75                 return ImageFormatUnknown;
76         }
77
78         freeImage();
79
80         return runImageLoader(filename);
81 }
82