Code

Cleaned up virtual destructor problem and compile warnings.
[inkscape.git] / src / extension / internal / libwpg / WPGraphics.cpp
1 /* libwpg\r
2  * Copyright (C) 2006 Ariya Hidayat (ariya@kde.org)\r
3  *\r
4  * This library is free software; you can redistribute it and/or\r
5  * modify it under the terms of the GNU Library General Public\r
6  * License as published by the Free Software Foundation; either\r
7  * version 2 of the License, or (at your option) any later version.\r
8  *\r
9  * This library is distributed in the hope that it will be useful,\r
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\r
12  * Library General Public License for more details.\r
13  *\r
14  * You should have received a copy of the GNU Library General Public\r
15  * License along with this library; if not, write to the \r
16  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, \r
17  * Boston, MA  02111-1301 USA\r
18  *\r
19  * For further information visit http://libwpg.sourceforge.net\r
20  */\r
21 \r
22 /* "This product is not manufactured, approved, or supported by\r
23  * Corel Corporation or Corel Corporation Limited."\r
24  */\r
25 \r
26 #include "WPGraphics.h"\r
27 #include "WPGHeader.h"\r
28 #include "WPGStream.h"\r
29 #include "WPGXParser.h"\r
30 #include "WPG1Parser.h"\r
31 #include "WPG2Parser.h"\r
32 #include "libwpg_utils.h"\r
33 \r
34 using namespace libwpg;\r
35 \r
36 bool WPGraphics::isSupported(WPGInputStream* input)\r
37 {\r
38         WPGHeader header;\r
39         if(!header.load(input))\r
40                 return false;\r
41         \r
42         return header.isSupported();\r
43 }\r
44 \r
45 bool WPGraphics::parse(WPGInputStream* input, WPGPaintInterface* painter)\r
46 {\r
47         WPGXParser *parser = 0;\r
48         \r
49         WPG_DEBUG_MSG(("Loading header...\n"));\r
50         WPGHeader header;\r
51         if(!header.load(input))\r
52                 return false;\r
53         \r
54         if(!header.isSupported())\r
55         {\r
56                 WPG_DEBUG_MSG(("Unsupported file format!\n"));\r
57                 return false;  \r
58         }\r
59         \r
60         // seek to the start of document\r
61         input->seek(header.startOfDocument());\r
62         \r
63         switch (header.majorVersion()) {\r
64                 case 0x01: // WPG1\r
65                         WPG_DEBUG_MSG(("Parsing WPG1\n"));\r
66                         parser = new WPG1Parser(input, painter);\r
67                         parser->parse();\r
68                         break;\r
69                 case 0x02: // WPG2\r
70                         WPG_DEBUG_MSG(("Parsing WPG2\n"));\r
71                         parser = new WPG2Parser(input, painter);\r
72                         parser->parse();\r
73                         break;\r
74                 default: // other :-)\r
75                         WPG_DEBUG_MSG(("Unknown format\n"));\r
76                         break;\r
77         }\r
78         \r
79         delete parser;\r
80         \r
81         return false;\r
82 }\r
83  \r