Line data Source code
1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* libcdr
3 : * Version: MPL 1.1 / GPLv2+ / LGPLv2+
4 : *
5 : * The contents of this file are subject to the Mozilla Public License Version
6 : * 1.1 (the "License"); you may not use this file except in compliance with
7 : * the License or as specified alternatively below. You may obtain a copy of
8 : * the License at http://www.mozilla.org/MPL/
9 : *
10 : * Software distributed under the License is distributed on an "AS IS" basis,
11 : * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 : * for the specific language governing rights and limitations under the
13 : * License.
14 : *
15 : * Major Contributor(s):
16 : * Copyright (C) 2012 Fridrich Strba <fridrich.strba@bluewin.ch>
17 : *
18 : *
19 : * All Rights Reserved.
20 : *
21 : * For minor contributions see the git repository.
22 : *
23 : * Alternatively, the contents of this file may be used under the terms of
24 : * either the GNU General Public License Version 2 or later (the "GPLv2+"), or
25 : * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
26 : * in which case the provisions of the GPLv2+ or the LGPLv2+ are applicable
27 : * instead of those above.
28 : */
29 :
30 : #include "CDROutputElementList.h"
31 :
32 : namespace libcdr
33 : {
34 :
35 : class CDROutputElement
36 : {
37 : public:
38 0 : CDROutputElement() {}
39 0 : virtual ~CDROutputElement() {}
40 : virtual void draw(libwpg::WPGPaintInterface *painter) = 0;
41 : virtual CDROutputElement *clone() = 0;
42 : };
43 :
44 :
45 : class CDRStyleOutputElement : public CDROutputElement
46 : {
47 : public:
48 : CDRStyleOutputElement(const WPXPropertyList &propList, const WPXPropertyListVector &propListVec);
49 0 : virtual ~CDRStyleOutputElement() {}
50 : virtual void draw(libwpg::WPGPaintInterface *painter);
51 0 : virtual CDROutputElement *clone()
52 : {
53 0 : return new CDRStyleOutputElement(m_propList, m_propListVec);
54 : }
55 : private:
56 : WPXPropertyList m_propList;
57 : WPXPropertyListVector m_propListVec;
58 : };
59 :
60 :
61 : class CDRPathOutputElement : public CDROutputElement
62 : {
63 : public:
64 : CDRPathOutputElement(const WPXPropertyListVector &propListVec);
65 0 : virtual ~CDRPathOutputElement() {}
66 : virtual void draw(libwpg::WPGPaintInterface *painter);
67 0 : virtual CDROutputElement *clone()
68 : {
69 0 : return new CDRPathOutputElement(m_propListVec);
70 : }
71 : private:
72 : WPXPropertyListVector m_propListVec;
73 : };
74 :
75 :
76 : class CDRGraphicObjectOutputElement : public CDROutputElement
77 : {
78 : public:
79 : CDRGraphicObjectOutputElement(const WPXPropertyList &propList, const ::WPXBinaryData &binaryData);
80 0 : virtual ~CDRGraphicObjectOutputElement() {}
81 : virtual void draw(libwpg::WPGPaintInterface *painter);
82 0 : virtual CDROutputElement *clone()
83 : {
84 0 : return new CDRGraphicObjectOutputElement(m_propList, m_binaryData);
85 : }
86 : private:
87 : WPXPropertyList m_propList;
88 : WPXBinaryData m_binaryData;
89 : };
90 :
91 :
92 : class CDRStartTextObjectOutputElement : public CDROutputElement
93 : {
94 : public:
95 : CDRStartTextObjectOutputElement(const WPXPropertyList &propList, const WPXPropertyListVector &propListVec);
96 0 : virtual ~CDRStartTextObjectOutputElement() {}
97 : virtual void draw(libwpg::WPGPaintInterface *painter);
98 0 : virtual CDROutputElement *clone()
99 : {
100 0 : return new CDRStartTextObjectOutputElement(m_propList, m_propListVec);
101 : }
102 : private:
103 : WPXPropertyList m_propList;
104 : WPXPropertyListVector m_propListVec;
105 : };
106 :
107 :
108 : class CDRStartTextLineOutputElement : public CDROutputElement
109 : {
110 : public:
111 : CDRStartTextLineOutputElement(const WPXPropertyList &propList);
112 0 : virtual ~CDRStartTextLineOutputElement() {}
113 : virtual void draw(libwpg::WPGPaintInterface *painter);
114 0 : virtual CDROutputElement *clone()
115 : {
116 0 : return new CDRStartTextLineOutputElement(m_propList);
117 : }
118 : private:
119 : WPXPropertyList m_propList;
120 : };
121 :
122 :
123 : class CDRStartTextSpanOutputElement : public CDROutputElement
124 : {
125 : public:
126 : CDRStartTextSpanOutputElement(const WPXPropertyList &propList);
127 0 : virtual ~CDRStartTextSpanOutputElement() {}
128 : virtual void draw(libwpg::WPGPaintInterface *painter);
129 0 : virtual CDROutputElement *clone()
130 : {
131 0 : return new CDRStartTextSpanOutputElement(m_propList);
132 : }
133 : private:
134 : WPXPropertyList m_propList;
135 : };
136 :
137 :
138 : class CDRInsertTextOutputElement : public CDROutputElement
139 : {
140 : public:
141 : CDRInsertTextOutputElement(const WPXString &text);
142 0 : virtual ~CDRInsertTextOutputElement() {}
143 : virtual void draw(libwpg::WPGPaintInterface *painter);
144 0 : virtual CDROutputElement *clone()
145 : {
146 0 : return new CDRInsertTextOutputElement(m_text);
147 : }
148 : private:
149 : WPXString m_text;
150 : };
151 :
152 :
153 : class CDREndTextSpanOutputElement : public CDROutputElement
154 : {
155 : public:
156 : CDREndTextSpanOutputElement();
157 0 : virtual ~CDREndTextSpanOutputElement() {}
158 : virtual void draw(libwpg::WPGPaintInterface *painter);
159 0 : virtual CDROutputElement *clone()
160 : {
161 0 : return new CDREndTextSpanOutputElement();
162 : }
163 : };
164 :
165 :
166 : class CDREndTextLineOutputElement : public CDROutputElement
167 : {
168 : public:
169 : CDREndTextLineOutputElement();
170 0 : virtual ~CDREndTextLineOutputElement() {}
171 : virtual void draw(libwpg::WPGPaintInterface *painter);
172 0 : virtual CDROutputElement *clone()
173 : {
174 0 : return new CDREndTextLineOutputElement();
175 : }
176 : };
177 :
178 :
179 : class CDREndTextObjectOutputElement : public CDROutputElement
180 : {
181 : public:
182 : CDREndTextObjectOutputElement();
183 0 : virtual ~CDREndTextObjectOutputElement() {}
184 : virtual void draw(libwpg::WPGPaintInterface *painter);
185 0 : virtual CDROutputElement *clone()
186 : {
187 0 : return new CDREndTextObjectOutputElement();
188 : }
189 : };
190 :
191 : class CDRStartLayerOutputElement : public CDROutputElement
192 : {
193 : public:
194 : CDRStartLayerOutputElement(const WPXPropertyList &propList);
195 0 : virtual ~CDRStartLayerOutputElement() {}
196 : virtual void draw(libwpg::WPGPaintInterface *painter);
197 0 : virtual CDROutputElement *clone()
198 : {
199 0 : return new CDRStartLayerOutputElement(m_propList);
200 : }
201 : private:
202 : WPXPropertyList m_propList;
203 : };
204 :
205 : class CDREndLayerOutputElement : public CDROutputElement
206 : {
207 : public:
208 : CDREndLayerOutputElement();
209 0 : virtual ~CDREndLayerOutputElement() {}
210 : virtual void draw(libwpg::WPGPaintInterface *painter);
211 0 : virtual CDROutputElement *clone()
212 : {
213 0 : return new CDREndLayerOutputElement();
214 : }
215 : };
216 :
217 : } // namespace libcdr
218 :
219 0 : libcdr::CDRStyleOutputElement::CDRStyleOutputElement(const WPXPropertyList &propList, const WPXPropertyListVector &propListVec) :
220 0 : m_propList(propList), m_propListVec(propListVec) {}
221 :
222 0 : void libcdr::CDRStyleOutputElement::draw(libwpg::WPGPaintInterface *painter)
223 : {
224 0 : if (painter)
225 0 : painter->setStyle(m_propList, m_propListVec);
226 0 : }
227 :
228 :
229 0 : libcdr::CDRPathOutputElement::CDRPathOutputElement(const WPXPropertyListVector &propListVec) :
230 0 : m_propListVec(propListVec) {}
231 :
232 0 : void libcdr::CDRPathOutputElement::draw(libwpg::WPGPaintInterface *painter)
233 : {
234 0 : if (painter)
235 0 : painter->drawPath(m_propListVec);
236 0 : }
237 :
238 :
239 0 : libcdr::CDRGraphicObjectOutputElement::CDRGraphicObjectOutputElement(const WPXPropertyList &propList, const ::WPXBinaryData &binaryData) :
240 0 : m_propList(propList), m_binaryData(binaryData) {}
241 :
242 0 : void libcdr::CDRGraphicObjectOutputElement::draw(libwpg::WPGPaintInterface *painter)
243 : {
244 0 : if (painter)
245 0 : painter->drawGraphicObject(m_propList, m_binaryData);
246 0 : }
247 :
248 :
249 0 : libcdr::CDRStartTextObjectOutputElement::CDRStartTextObjectOutputElement(const WPXPropertyList &propList, const WPXPropertyListVector &propListVec) :
250 0 : m_propList(propList), m_propListVec(propListVec) {}
251 :
252 0 : void libcdr::CDRStartTextObjectOutputElement::draw(libwpg::WPGPaintInterface *painter)
253 : {
254 0 : if (painter)
255 0 : painter->startTextObject(m_propList, m_propListVec);
256 0 : }
257 :
258 0 : libcdr::CDRStartTextSpanOutputElement::CDRStartTextSpanOutputElement(const WPXPropertyList &propList) :
259 0 : m_propList(propList) {}
260 :
261 0 : void libcdr::CDRStartTextSpanOutputElement::draw(libwpg::WPGPaintInterface *painter)
262 : {
263 0 : if (painter)
264 0 : painter->startTextSpan(m_propList);
265 0 : }
266 :
267 :
268 0 : libcdr::CDRStartTextLineOutputElement::CDRStartTextLineOutputElement(const WPXPropertyList &propList) :
269 0 : m_propList(propList) {}
270 :
271 0 : void libcdr::CDRStartTextLineOutputElement::draw(libwpg::WPGPaintInterface *painter)
272 : {
273 0 : if (painter)
274 0 : painter->startTextLine(m_propList);
275 0 : }
276 :
277 :
278 0 : libcdr::CDRInsertTextOutputElement::CDRInsertTextOutputElement(const WPXString &text) :
279 0 : m_text(text) {}
280 :
281 0 : void libcdr::CDRInsertTextOutputElement::draw(libwpg::WPGPaintInterface *painter)
282 : {
283 0 : if (painter)
284 0 : painter->insertText(m_text);
285 0 : }
286 :
287 0 : libcdr::CDREndTextSpanOutputElement::CDREndTextSpanOutputElement() {}
288 :
289 0 : void libcdr::CDREndTextSpanOutputElement::draw(libwpg::WPGPaintInterface *painter)
290 : {
291 0 : if (painter)
292 0 : painter->endTextSpan();
293 0 : }
294 :
295 :
296 0 : libcdr::CDREndTextLineOutputElement::CDREndTextLineOutputElement() {}
297 :
298 0 : void libcdr::CDREndTextLineOutputElement::draw(libwpg::WPGPaintInterface *painter)
299 : {
300 0 : if (painter)
301 0 : painter->endTextLine();
302 0 : }
303 :
304 :
305 0 : libcdr::CDREndTextObjectOutputElement::CDREndTextObjectOutputElement() {}
306 :
307 0 : void libcdr::CDREndTextObjectOutputElement::draw(libwpg::WPGPaintInterface *painter)
308 : {
309 0 : if (painter)
310 0 : painter->endTextObject();
311 0 : }
312 :
313 :
314 0 : libcdr::CDREndLayerOutputElement::CDREndLayerOutputElement() {}
315 :
316 0 : void libcdr::CDREndLayerOutputElement::draw(libwpg::WPGPaintInterface *painter)
317 : {
318 0 : if (painter)
319 0 : painter->endLayer();
320 0 : }
321 :
322 :
323 0 : libcdr::CDRStartLayerOutputElement::CDRStartLayerOutputElement(const WPXPropertyList &propList) :
324 0 : m_propList(propList) {}
325 :
326 0 : void libcdr::CDRStartLayerOutputElement::draw(libwpg::WPGPaintInterface *painter)
327 : {
328 0 : if (painter)
329 0 : painter->startLayer(m_propList);
330 0 : }
331 :
332 :
333 0 : libcdr::CDROutputElementList::CDROutputElementList()
334 0 : : m_elements()
335 : {
336 0 : }
337 :
338 0 : libcdr::CDROutputElementList::CDROutputElementList(const libcdr::CDROutputElementList &elementList)
339 0 : : m_elements()
340 : {
341 0 : std::vector<libcdr::CDROutputElement *>::const_iterator iter;
342 0 : for (iter = elementList.m_elements.begin(); iter != elementList.m_elements.end(); ++iter)
343 0 : m_elements.push_back((*iter)->clone());
344 0 : }
345 :
346 0 : libcdr::CDROutputElementList &libcdr::CDROutputElementList::operator=(const libcdr::CDROutputElementList &elementList)
347 : {
348 0 : for (std::vector<CDROutputElement *>::iterator iter = m_elements.begin(); iter != m_elements.end(); ++iter)
349 0 : delete (*iter);
350 :
351 0 : m_elements.clear();
352 :
353 0 : for (std::vector<CDROutputElement *>::const_iterator cstiter = elementList.m_elements.begin(); cstiter != elementList.m_elements.end(); ++cstiter)
354 0 : m_elements.push_back((*cstiter)->clone());
355 :
356 0 : return *this;
357 : }
358 :
359 0 : void libcdr::CDROutputElementList::append(const libcdr::CDROutputElementList &elementList)
360 : {
361 0 : for (std::vector<CDROutputElement *>::const_iterator cstiter = elementList.m_elements.begin(); cstiter != elementList.m_elements.end(); ++cstiter)
362 0 : m_elements.push_back((*cstiter)->clone());
363 0 : }
364 :
365 0 : libcdr::CDROutputElementList::~CDROutputElementList()
366 : {
367 0 : for (std::vector<CDROutputElement *>::iterator iter = m_elements.begin(); iter != m_elements.end(); ++iter)
368 0 : delete (*iter);
369 0 : m_elements.clear();
370 0 : }
371 :
372 0 : void libcdr::CDROutputElementList::draw(libwpg::WPGPaintInterface *painter) const
373 : {
374 0 : for (std::vector<CDROutputElement *>::const_iterator iter = m_elements.begin(); iter != m_elements.end(); ++iter)
375 0 : (*iter)->draw(painter);
376 0 : }
377 :
378 0 : void libcdr::CDROutputElementList::addStyle(const WPXPropertyList &propList, const WPXPropertyListVector &propListVec)
379 : {
380 0 : m_elements.push_back(new CDRStyleOutputElement(propList, propListVec));
381 0 : }
382 :
383 0 : void libcdr::CDROutputElementList::addPath(const WPXPropertyListVector &propListVec)
384 : {
385 0 : m_elements.push_back(new CDRPathOutputElement(propListVec));
386 0 : }
387 :
388 0 : void libcdr::CDROutputElementList::addGraphicObject(const WPXPropertyList &propList, const ::WPXBinaryData &binaryData)
389 : {
390 0 : m_elements.push_back(new CDRGraphicObjectOutputElement(propList, binaryData));
391 0 : }
392 :
393 0 : void libcdr::CDROutputElementList::addStartTextObject(const WPXPropertyList &propList, const WPXPropertyListVector &propListVec)
394 : {
395 0 : m_elements.push_back(new CDRStartTextObjectOutputElement(propList, propListVec));
396 0 : }
397 :
398 0 : void libcdr::CDROutputElementList::addStartTextLine(const WPXPropertyList &propList)
399 : {
400 0 : m_elements.push_back(new CDRStartTextLineOutputElement(propList));
401 0 : }
402 :
403 0 : void libcdr::CDROutputElementList::addStartTextSpan(const WPXPropertyList &propList)
404 : {
405 0 : m_elements.push_back(new CDRStartTextSpanOutputElement(propList));
406 0 : }
407 :
408 0 : void libcdr::CDROutputElementList::addInsertText(const WPXString &text)
409 : {
410 0 : m_elements.push_back(new CDRInsertTextOutputElement(text));
411 0 : }
412 :
413 0 : void libcdr::CDROutputElementList::addEndTextSpan()
414 : {
415 0 : m_elements.push_back(new CDREndTextSpanOutputElement());
416 0 : }
417 :
418 0 : void libcdr::CDROutputElementList::addEndTextLine()
419 : {
420 0 : m_elements.push_back(new CDREndTextLineOutputElement());
421 0 : }
422 :
423 0 : void libcdr::CDROutputElementList::addEndTextObject()
424 : {
425 0 : m_elements.push_back(new CDREndTextObjectOutputElement());
426 0 : }
427 :
428 0 : void libcdr::CDROutputElementList::addStartGroup(const WPXPropertyList &propList)
429 : {
430 0 : m_elements.push_back(new CDRStartLayerOutputElement(propList));
431 0 : }
432 :
433 0 : void libcdr::CDROutputElementList::addEndGroup()
434 : {
435 0 : m_elements.push_back(new CDREndLayerOutputElement());
436 0 : }
437 :
438 : /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
|