/src/libstaroffice/src/lib/STOFFGraphicDecoder.cxx
Line | Count | Source |
1 | | /* -*- Mode: C++; c-default-style: "k&r"; indent-tabs-mode: nil; tab-width: 2; c-basic-offset: 2 -*- */ |
2 | | |
3 | | /* libstaroffice |
4 | | * Version: MPL 2.0 / LGPLv2+ |
5 | | * |
6 | | * The contents of this file are subject to the Mozilla Public License Version |
7 | | * 2.0 (the "License"); you may not use this file except in compliance with |
8 | | * the License or as specified alternatively below. You may obtain a copy of |
9 | | * the License at http://www.mozilla.org/MPL/ |
10 | | * |
11 | | * Software distributed under the License is distributed on an "AS IS" basis, |
12 | | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License |
13 | | * for the specific language governing rights and limitations under the |
14 | | * License. |
15 | | * |
16 | | * Major Contributor(s): |
17 | | * Copyright (C) 2006 Ariya Hidayat (ariya@kde.org) |
18 | | * Copyright (C) 2004 Marc Oude Kotte (marc@solcon.nl) |
19 | | * Copyright (C) 2002 William Lachance (wrlach@gmail.com) |
20 | | * Copyright (C) 2002,2004 Marc Maurer (uwog@uwog.net) |
21 | | * Copyright (C) 2004-2006 Fridrich Strba (fridrich.strba@bluewin.ch) |
22 | | * Copyright (C) 2006, 2007 Andrew Ziem |
23 | | * Copyright (C) 2011, 2012 Alonso Laurent (alonso@loria.fr) |
24 | | * |
25 | | * |
26 | | * All Rights Reserved. |
27 | | * |
28 | | * For minor contributions see the git repository. |
29 | | * |
30 | | * Alternatively, the contents of this file may be used under the terms of |
31 | | * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"), |
32 | | * in which case the provisions of the LGPLv2+ are applicable |
33 | | * instead of those above. |
34 | | */ |
35 | | |
36 | | #include <string.h> |
37 | | |
38 | | #include <librevenge/librevenge.h> |
39 | | #include <libstaroffice/libstaroffice.hxx> |
40 | | |
41 | | #include "libstaroffice_internal.hxx" |
42 | | |
43 | | #include "STOFFDebug.hxx" |
44 | | |
45 | | #include "STOFFGraphicDecoder.hxx" |
46 | | |
47 | | void STOFFGraphicDecoder::insertElement(const char *psName) |
48 | 0 | { |
49 | 0 | if (!m_output) return; |
50 | 0 | int len=psName ? int(strlen(psName)) : 0; |
51 | 0 | if (!len) { |
52 | 0 | STOFF_DEBUG_MSG(("STOFFGraphicDecoder::insertElement: called without name\n")); |
53 | 0 | return; |
54 | 0 | } |
55 | | |
56 | 0 | bool ok=true; |
57 | 0 | switch (psName[0]) { |
58 | 0 | case 'C': |
59 | 0 | if (len>=6 && strncmp(psName,"Close",5)==0) { |
60 | 0 | psName+=5; |
61 | 0 | if (strcmp(psName,"Group")==0) |
62 | 0 | m_output->closeGroup(); |
63 | 0 | else if (strcmp(psName,"Link")==0) |
64 | 0 | m_output->closeLink(); |
65 | 0 | else if (strcmp(psName,"ListElement")==0) |
66 | 0 | m_output->closeListElement(); |
67 | 0 | else if (strcmp(psName,"OrderedListLevel")==0) |
68 | 0 | m_output->closeOrderedListLevel(); |
69 | 0 | else if (strcmp(psName,"Paragraph")==0) |
70 | 0 | m_output->closeParagraph(); |
71 | 0 | else if (strcmp(psName,"Span")==0) |
72 | 0 | m_output->closeSpan(); |
73 | 0 | else if (strcmp(psName,"TableCell")==0) |
74 | 0 | m_output->closeTableCell(); |
75 | 0 | else if (strcmp(psName,"TableRow")==0) |
76 | 0 | m_output->closeTableRow(); |
77 | 0 | else if (strcmp(psName,"UnorderedListLevel")==0) |
78 | 0 | m_output->closeUnorderedListLevel(); |
79 | 0 | else |
80 | 0 | ok=false; |
81 | 0 | } |
82 | 0 | else |
83 | 0 | ok=false; |
84 | 0 | break; |
85 | 0 | case 'E': |
86 | 0 | if (len>=4 && strncmp(psName,"End",3)==0) { |
87 | 0 | psName+=3; |
88 | 0 | if (strcmp(psName,"Document")==0) |
89 | 0 | m_output->endDocument(); |
90 | 0 | else if (strcmp(psName,"EmbeddedGraphics")==0) |
91 | 0 | m_output->endEmbeddedGraphics(); |
92 | 0 | else if (strcmp(psName,"Layer")==0) |
93 | 0 | m_output->endLayer(); |
94 | 0 | else if (strcmp(psName,"MasterPage")==0) |
95 | 0 | m_output->endMasterPage(); |
96 | 0 | else if (strcmp(psName,"Page")==0) |
97 | 0 | m_output->endPage(); |
98 | 0 | else if (strcmp(psName,"TableObject")==0) |
99 | 0 | m_output->endTableObject(); |
100 | 0 | else if (strcmp(psName,"TextObject")==0) |
101 | 0 | m_output->endTextObject(); |
102 | 0 | else |
103 | 0 | ok=false; |
104 | 0 | } |
105 | 0 | else |
106 | 0 | ok=false; |
107 | 0 | break; |
108 | 0 | case 'I': |
109 | 0 | if (len>=7 && strncmp(psName,"Insert",6)==0) { |
110 | 0 | psName+=6; |
111 | 0 | if (strcmp(psName,"LineBreak")==0) |
112 | 0 | m_output->insertLineBreak(); |
113 | 0 | else if (strcmp(psName,"Space")==0) |
114 | 0 | m_output->insertSpace(); |
115 | 0 | else if (strcmp(psName,"Tab")==0) |
116 | 0 | m_output->insertTab(); |
117 | 0 | else |
118 | 0 | ok=false; |
119 | 0 | } |
120 | 0 | else |
121 | 0 | ok=false; |
122 | 0 | break; |
123 | 0 | default: |
124 | 0 | ok=false; |
125 | 0 | break; |
126 | 0 | } |
127 | 0 | if (!ok) { |
128 | 0 | STOFF_DEBUG_MSG(("STOFFGraphicDecoder::insertElement: called with unexpected name %s\n", psName)); |
129 | 0 | } |
130 | 0 | } |
131 | | |
132 | | void STOFFGraphicDecoder::insertElement(const char *psName, const librevenge::RVNGPropertyList &propList) |
133 | 0 | { |
134 | 0 | if (!m_output) return; |
135 | 0 | int len=psName ? int(strlen(psName)) : 0; |
136 | 0 | if (!len) { |
137 | 0 | STOFF_DEBUG_MSG(("STOFFGraphicDecoder::insertElement: called without any name\n")); |
138 | 0 | return; |
139 | 0 | } |
140 | | |
141 | 0 | bool ok=true; |
142 | 0 | switch (psName[0]) { |
143 | 0 | case 'D': |
144 | 0 | if (len>=7 && strncmp(psName,"Define",6)==0) { |
145 | 0 | psName+=6; |
146 | 0 | if (strcmp(psName,"CharacterStyle")==0) |
147 | 0 | m_output->defineCharacterStyle(propList); |
148 | 0 | else if (strcmp(psName,"EmbeddedFont")==0) |
149 | 0 | m_output->defineEmbeddedFont(propList); |
150 | 0 | else if (strcmp(psName,"ParagraphStyle")==0) |
151 | 0 | m_output->defineParagraphStyle(propList); |
152 | 0 | else |
153 | 0 | ok=false; |
154 | 0 | } |
155 | 0 | else if (len>=5 && strncmp(psName,"Draw",4)==0) { |
156 | 0 | psName+=4; |
157 | 0 | if (strcmp(psName,"Connector")==0) |
158 | 0 | m_output->drawConnector(propList); |
159 | 0 | else if (strcmp(psName,"Ellipse")==0) |
160 | 0 | m_output->drawEllipse(propList); |
161 | 0 | else if (strcmp(psName,"GraphicObject")==0) |
162 | 0 | m_output->drawGraphicObject(propList); |
163 | 0 | else if (strcmp(psName,"Path")==0) |
164 | 0 | m_output->drawPath(propList); |
165 | 0 | else if (strcmp(psName,"Polygon")==0) |
166 | 0 | m_output->drawPolygon(propList); |
167 | 0 | else if (strcmp(psName,"Polyline")==0) |
168 | 0 | m_output->drawPolyline(propList); |
169 | 0 | else if (strcmp(psName,"Rectangle")==0) |
170 | 0 | m_output->drawRectangle(propList); |
171 | 0 | else |
172 | 0 | ok=false; |
173 | 0 | } |
174 | 0 | else |
175 | 0 | ok=false; |
176 | 0 | break; |
177 | 0 | case 'I': |
178 | 0 | if (len>=7 && strncmp(psName,"Insert",6)==0) { |
179 | 0 | psName+=6; |
180 | 0 | if (strcmp(psName,"CoveredTableCell")==0) |
181 | 0 | m_output->insertCoveredTableCell(propList); |
182 | 0 | else if (strcmp(psName,"Field")==0) |
183 | 0 | m_output->insertField(propList); |
184 | 0 | else |
185 | 0 | ok=false; |
186 | 0 | } |
187 | 0 | else |
188 | 0 | ok=false; |
189 | 0 | break; |
190 | 0 | case 'O': |
191 | 0 | if (len>=5 && strncmp(psName,"Open",4)==0) { |
192 | 0 | psName+=4; |
193 | 0 | if (strcmp(psName,"Group")==0) |
194 | 0 | m_output->openGroup(propList); |
195 | 0 | else if (strcmp(psName,"Link")==0) |
196 | 0 | m_output->openLink(propList); |
197 | 0 | else if (strcmp(psName,"ListElement")==0) |
198 | 0 | m_output->openListElement(propList); |
199 | 0 | else if (strcmp(psName,"OrderedListLevel")==0) |
200 | 0 | m_output->openOrderedListLevel(propList); |
201 | 0 | else if (strcmp(psName,"Paragraph")==0) |
202 | 0 | m_output->openParagraph(propList); |
203 | 0 | else if (strcmp(psName,"Span")==0) |
204 | 0 | m_output->openSpan(propList); |
205 | 0 | else if (strcmp(psName,"TableCell")==0) |
206 | 0 | m_output->openTableCell(propList); |
207 | 0 | else if (strcmp(psName,"TableRow")==0) |
208 | 0 | m_output->openTableRow(propList); |
209 | 0 | else if (strcmp(psName,"UnorderedListLevel")==0) |
210 | 0 | m_output->openUnorderedListLevel(propList); |
211 | 0 | else |
212 | 0 | ok=false; |
213 | 0 | } |
214 | 0 | else |
215 | 0 | ok=false; |
216 | 0 | break; |
217 | 0 | case 'S': |
218 | 0 | if (len>=4 && strncmp(psName,"Set",3)==0) { |
219 | 0 | psName+=3; |
220 | 0 | if (strcmp(psName,"DocumentMetaData")==0) |
221 | 0 | m_output->setDocumentMetaData(propList); |
222 | 0 | else if (strcmp(psName,"Style")==0) |
223 | 0 | m_output->setStyle(propList); |
224 | 0 | else |
225 | 0 | ok=false; |
226 | 0 | } |
227 | 0 | else if (len>=6 && strncmp(psName,"Start",5)==0) { |
228 | 0 | psName+=5; |
229 | 0 | if (strcmp(psName,"Document")==0) |
230 | 0 | m_output->startDocument(propList); |
231 | 0 | else if (strcmp(psName,"EmbeddedGraphics")==0) |
232 | 0 | m_output->startEmbeddedGraphics(propList); |
233 | 0 | else if (strcmp(psName,"Layer")==0) |
234 | 0 | m_output->startLayer(propList); |
235 | 0 | else if (strcmp(psName,"MasterPage")==0) |
236 | 0 | m_output->startMasterPage(propList); |
237 | 0 | else if (strcmp(psName,"Page")==0) |
238 | 0 | m_output->startPage(propList); |
239 | 0 | else if (strcmp(psName,"TableObject")==0) |
240 | 0 | m_output->startTableObject(propList); |
241 | 0 | else if (strcmp(psName,"TextObject")==0) |
242 | 0 | m_output->startTextObject(propList); |
243 | 0 | else |
244 | 0 | ok=false; |
245 | 0 | } |
246 | 0 | else |
247 | 0 | ok=false; |
248 | 0 | break; |
249 | 0 | default: |
250 | 0 | ok=false; |
251 | 0 | break; |
252 | 0 | } |
253 | 0 | if (!ok) { |
254 | 0 | STOFF_DEBUG_MSG(("STOFFGraphicDecoder::insertElement: called with unexpected name %s\n", psName)); |
255 | 0 | } |
256 | 0 | } |
257 | | |
258 | | // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab: |