]> git.pld-linux.org Git - packages/kde4-koffice.git/blob - kde4-koffice-libwpg02.patch
- release 19 (by relup.sh)
[packages/kde4-koffice.git] / kde4-koffice-libwpg02.patch
1 diff -Nur koffice-2.3.1/filters/karbon/wpg/import/CMakeLists.txt koffice-2.3.1-libwpg02/filters/karbon/wpg/import/CMakeLists.txt
2 --- koffice-2.3.1/filters/karbon/wpg/import/CMakeLists.txt      2011-01-15 21:05:35.000000000 +0100
3 +++ koffice-2.3.1-libwpg02/filters/karbon/wpg/import/CMakeLists.txt     2011-01-18 07:40:25.000000000 +0100
4 @@ -1,16 +1,11 @@
5  
6 -
7  include_directories(${CMAKE_BINARY_DIR}/filters/ ${WPD_INCLUDE_DIR} ${LIBWPG_INCLUDE_DIR}/)
8  
9 -set(wpgimport_PART_SRCS 
10 -WPGImport.cpp 
11 -OdgExporter.cxx
12 -FileOutputHandler.cxx
13 -GraphicsElement.cxx)
14 +set(wpgimport_PART_SRCS WPGImport.cpp)
15  
16  kde4_add_plugin(wpgimport ${wpgimport_PART_SRCS})
17  
18 -target_link_libraries(wpgimport komain ${LIBWPG_LIBRARIES} ${LIBWPG_STREAM_LIBRARIES})
19 +target_link_libraries(wpgimport komain ${LIBWPG_LIBRARIES} ${LIBWPG_STREAM_LIBRARIES} ${WPD_LIBRARIES})
20  
21  install(TARGETS wpgimport DESTINATION ${PLUGIN_INSTALL_DIR})
22  install(FILES karbon_wpg_import.desktop DESTINATION ${SERVICES_INSTALL_DIR})
23 diff -Nur koffice-2.3.1/filters/karbon/wpg/import/FileOutputHandler.cxx koffice-2.3.1-libwpg02/filters/karbon/wpg/import/FileOutputHandler.cxx
24 --- koffice-2.3.1/filters/karbon/wpg/import/FileOutputHandler.cxx       2011-01-15 21:05:35.000000000 +0100
25 +++ koffice-2.3.1-libwpg02/filters/karbon/wpg/import/FileOutputHandler.cxx      1970-01-01 01:00:00.000000000 +0100
26 @@ -1,95 +0,0 @@
27 -/* libwpg
28 - * Copyright (C) 2006 Fridrich Strba (fridrich.strba@bluewin.ch)
29 - *
30 - * This library is free software; you can redistribute it and/or
31 - * modify it under the terms of the GNU Library General Public
32 - * License as published by the Free Software Foundation; either
33 - * version 2 of the License, or (at your option) any later version.
34 - *
35 - * This library is distributed in the hope that it will be useful,
36 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
37 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
38 - * Library General Public License for more details.
39 - *
40 - * You should have received a copy of the GNU Library General Public
41 - * License along with this library; if not, write to the 
42 - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 
43 - * Boston, MA  02111-1301 USA
44 - *
45 - * For further information visit http://libwpg.sourceforge.net
46 - */
47 -
48 -/* "This product is not manufactured, approved, or supported by
49 - * Corel Corporation or Corel Corporation Limited."
50 - */
51 -
52 -#include "FileOutputHandler.hxx"
53 -
54 -FileOutputHandler::FileOutputHandler(std::ostringstream &contentStream) :
55 -       mbIsTagOpened(false),
56 -       mContentStream(contentStream)
57 -{
58 -}
59 -
60 -void FileOutputHandler::startDocument()
61 -{
62 -}
63 -
64 -void FileOutputHandler::startElement(const char *psName, const std::vector<std::pair<std::string, std::string> > &xPropList)
65 -{
66 -       if (mbIsTagOpened)
67 -       {
68 -               mContentStream << ">";
69 -               mbIsTagOpened = false;
70 -       }
71 -       mContentStream << "<" << psName;
72 -
73 -       for (std::vector<std::pair<std::string, std::string> >::const_iterator i = xPropList.begin(); i != xPropList.end(); i++)
74 -       {
75 -               mContentStream << " " <<  (*i).first.c_str() << "=\"" << (*i).second.c_str() << "\"";
76 -       }
77 -       mbIsTagOpened = true;
78 -       msOpenedTagName = psName;
79 -}
80 -
81 -void FileOutputHandler::endElement(const char *psName)
82 -{
83 -       if (mbIsTagOpened)
84 -       {
85 -               if( msOpenedTagName == psName )
86 -               {
87 -                       mContentStream << "/>";
88 -                       mbIsTagOpened = false;
89 -               }
90 -               else // should not happen, but handle it
91 -               {
92 -                       mContentStream << ">";
93 -                       mContentStream << "</" << psName << ">";
94 -                       mbIsTagOpened = false;
95 -               }
96 -       }
97 -       else
98 -       {
99 -               mContentStream << "</" << psName << ">";
100 -               mbIsTagOpened = false;
101 -       }
102 -}
103 -
104 -void FileOutputHandler::characters(const std::string &sCharacters)
105 -{
106 -       if (mbIsTagOpened)
107 -       {
108 -               mContentStream << ">";
109 -               mbIsTagOpened = false;
110 -       }
111 -       mContentStream << sCharacters.c_str();
112 -}
113 -
114 -void FileOutputHandler::endDocument()
115 -{
116 -       if (mbIsTagOpened)
117 -       {
118 -               mContentStream << ">";
119 -               mbIsTagOpened = false;
120 -       }
121 -}
122 diff -Nur koffice-2.3.1/filters/karbon/wpg/import/FileOutputHandler.hxx koffice-2.3.1-libwpg02/filters/karbon/wpg/import/FileOutputHandler.hxx
123 --- koffice-2.3.1/filters/karbon/wpg/import/FileOutputHandler.hxx       2011-01-15 21:05:35.000000000 +0100
124 +++ koffice-2.3.1-libwpg02/filters/karbon/wpg/import/FileOutputHandler.hxx      1970-01-01 01:00:00.000000000 +0100
125 @@ -1,49 +0,0 @@
126 -/* libwpg
127 - * Copyright (C) 2006 Fridrich Strba (fridrich.strba@bluewin.ch)
128 - *
129 - * This library is free software; you can redistribute it and/or
130 - * modify it under the terms of the GNU Library General Public
131 - * License as published by the Free Software Foundation; either
132 - * version 2 of the License, or (at your option) any later version.
133 - *
134 - * This library is distributed in the hope that it will be useful,
135 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
136 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
137 - * Library General Public License for more details.
138 - *
139 - * You should have received a copy of the GNU Library General Public
140 - * License along with this library; if not, write to the 
141 - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 
142 - * Boston, MA  02111-1301 USA
143 - *
144 - * For further information visit http://libwpg.sourceforge.net
145 - */
146 -
147 -/* "This product is not manufactured, approved, or supported by
148 - * Corel Corporation or Corel Corporation Limited."
149 - */
150 -
151 -#ifndef FILEOUTPUTHANDLER_H
152 -#define FILEOUTPUTHANDLER_H
153 -
154 -#include <iostream>
155 -#include <sstream>
156 -#include <string>
157 -#include "GraphicsHandler.hxx"
158 -
159 -class FileOutputHandler : public GraphicsHandler
160 -{
161 -  public:
162 -        explicit FileOutputHandler(std::ostringstream &contentStream);
163 -        virtual void startDocument();
164 -        virtual void endDocument();
165 -        virtual void startElement(const char *psName, const std::vector<std::pair<std::string, std::string> > &xPropList);
166 -        virtual void endElement(const char *psName);
167 -        virtual void characters(const std::string &sCharacters);
168 -
169 -  private:
170 -       bool mbIsTagOpened;
171 -       std::string msOpenedTagName;
172 -       std::ostringstream &mContentStream;
173 -};
174 -#endif
175 diff -Nur koffice-2.3.1/filters/karbon/wpg/import/GraphicsElement.cxx koffice-2.3.1-libwpg02/filters/karbon/wpg/import/GraphicsElement.cxx
176 --- koffice-2.3.1/filters/karbon/wpg/import/GraphicsElement.cxx 2011-01-15 21:05:35.000000000 +0100
177 +++ koffice-2.3.1-libwpg02/filters/karbon/wpg/import/GraphicsElement.cxx        1970-01-01 01:00:00.000000000 +0100
178 @@ -1,66 +0,0 @@
179 -/* GraphicsElement: The items we are collecting to be put into the Writer
180 - * document: paragraph and spans of text, as well as section breaks.
181 - *
182 - * Copyright (C) 2002-2003 William Lachance (william.lachance@sympatico.ca)
183 - * 
184 - * This program is free software; you can redistribute it and/or
185 - * modify it under the terms of the GNU Lesser General Public
186 - * License as published by the Free Software Foundation; either
187 - * version 2 of the License, or (at your option) any later version.
188 - *
189 - * This program is distributed in the hope that it will be useful,
190 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
191 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
192 - * Library General Public License for more details.
193 - *
194 - * You should have received a copy of the GNU Library General Public
195 - * License along with this library; if not, write to the 
196 - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 
197 - * Boston, MA  02111-1301 USA
198 - *
199 - * For further information visit http://libwpg.sourceforge.net
200 - *
201 - */
202 -
203 -/* "This product is not manufactured, approved, or supported by 
204 - * Corel Corporation or Corel Corporation Limited."
205 - */
206 -
207 -#include "GraphicsElement.hxx"
208 -#include "GraphicsHandler.hxx"
209 -#include <string.h>
210 -
211 -#define ASCII_SPACE 0x0020
212 -
213 -void TagGraphicsElement::print() const
214 -{
215 -}
216 -
217 -void OpenTagGraphicsElement::write(GraphicsHandler *pHandler) const
218 -{
219 -       pHandler->startElement(getTagName().c_str(), maAttrList);
220 -}
221 -
222 -void OpenTagGraphicsElement::print() const
223 -{ 
224 -       TagGraphicsElement::print();    
225 -}
226 -
227 -void OpenTagGraphicsElement::addAttribute(const std::string &szAttributeName, const std::string &sAttributeValue)
228 -{
229 -       std::pair<std::string, std::string> tmpAttribute;
230 -       tmpAttribute.first = szAttributeName;
231 -       tmpAttribute.second = sAttributeValue;
232 -        maAttrList.push_back(tmpAttribute);
233 -}
234 -
235 -void CloseTagGraphicsElement::write(GraphicsHandler *pHandler) const
236 -{
237 -
238 -       pHandler->endElement(getTagName().c_str());
239 -}
240 -
241 -void CharDataGraphicsElement::write(GraphicsHandler *pHandler) const
242 -{
243 -       pHandler->characters(msData);
244 -}
245 diff -Nur koffice-2.3.1/filters/karbon/wpg/import/GraphicsElement.hxx koffice-2.3.1-libwpg02/filters/karbon/wpg/import/GraphicsElement.hxx
246 --- koffice-2.3.1/filters/karbon/wpg/import/GraphicsElement.hxx 2011-01-15 21:05:35.000000000 +0100
247 +++ koffice-2.3.1-libwpg02/filters/karbon/wpg/import/GraphicsElement.hxx        1970-01-01 01:00:00.000000000 +0100
248 @@ -1,84 +0,0 @@
249 -/* GraphicsElement: The items we are collecting to be put into the Writer
250 - * document: paragraph and spans of text, as well as section breaks.
251 - *
252 - * Copyright (C) 2002-2003 William Lachance (william.lachance@sympatico.ca)
253 - * 
254 - * This program is free software; you can redistribute it and/or
255 - * modify it under the terms of the GNU Lesser General Public
256 - * License as published by the Free Software Foundation; either
257 - * version 2 of the License, or (at your option) any later version.
258 - *
259 - * This program is distributed in the hope that it will be useful,
260 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
261 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
262 - * Library General Public License for more details.
263 - *
264 - * You should have received a copy of the GNU Library General Public
265 - * License along with this library; if not, write to the 
266 - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 
267 - * Boston, MA  02111-1301 USA
268 - *
269 - * For further information visit http://libwpd.sourceforge.net
270 - *
271 - */
272 -
273 -/* "This product is not manufactured, approved, or supported by 
274 - * Corel Corporation or Corel Corporation Limited."
275 - */
276 -
277 -#ifndef _GRAPHICSELEMENT_H
278 -#define _GRAPHICSELEMENT_H
279 -#include <string>
280 -#include <map>
281 -#include <vector>
282 -
283 -#include "GraphicsHandler.hxx"
284 -
285 -class GraphicsElement
286 -{
287 -public:        
288 -       virtual ~GraphicsElement() {}
289 -       virtual void write(GraphicsHandler *pHandler) const = 0;
290 -       virtual void print() const {}
291 -};
292 -
293 -class TagGraphicsElement : public GraphicsElement
294 -{
295 -public:
296 -       explicit TagGraphicsElement(const char *szTagName) : msTagName(szTagName) {}
297 -       const std::string &getTagName() const { return msTagName; }
298 -       virtual void print() const;
299 -private:
300 -       const std::string msTagName;
301 -};
302 -
303 -class OpenTagGraphicsElement : public TagGraphicsElement
304 -{
305 -public:
306 -       explicit OpenTagGraphicsElement(const char *szTagName) : TagGraphicsElement(szTagName) {}
307 -       ~OpenTagGraphicsElement() {}
308 -       void addAttribute(const std::string &szAttributeName, const std::string &sAttributeValue);
309 -       virtual void write(GraphicsHandler *pHandler) const;
310 -       virtual void print () const;
311 -private:
312 -       std::vector<std::pair<std::string, std::string> > maAttrList;
313 -};
314 -
315 -class CloseTagGraphicsElement : public TagGraphicsElement
316 -{
317 -public:
318 -       explicit CloseTagGraphicsElement(const char *szTagName) : TagGraphicsElement(szTagName) {}
319 -       virtual void write(GraphicsHandler *pHandler) const;
320 -};
321 -
322 -class CharDataGraphicsElement : public GraphicsElement
323 -{
324 -public:
325 -       CharDataGraphicsElement(const char *sData) : GraphicsElement(), msData(sData) {}
326 -       virtual void write(GraphicsHandler *pHandler) const;
327 -private:
328 -       std::string msData;
329 -};
330 -
331 -
332 -#endif
333 diff -Nur koffice-2.3.1/filters/karbon/wpg/import/GraphicsHandler.hxx koffice-2.3.1-libwpg02/filters/karbon/wpg/import/GraphicsHandler.hxx
334 --- koffice-2.3.1/filters/karbon/wpg/import/GraphicsHandler.hxx 2011-01-15 21:05:35.000000000 +0100
335 +++ koffice-2.3.1-libwpg02/filters/karbon/wpg/import/GraphicsHandler.hxx        1970-01-01 01:00:00.000000000 +0100
336 @@ -1,43 +0,0 @@
337 -/*
338 - * Copyright (C) 2004 William Lachance (wlach@interlog.com)
339 - * Copyright (C) 2004 Net Integration Technologies (http://www.net-itech.com)
340 - *
341 - * This program is free software; you can redistribute it and/or
342 - * modify it under the terms of the GNU General Public License
343 - * as published by the Free Software Foundation; either version 2
344 - * of the License, or (at your option) any later version.
345 - *
346 - * This program is distributed in the hope that it will be useful,
347 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
348 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
349 - * GNU General Public License for more details.
350 - *
351 - * You should have received a copy of the GNU Library General Public
352 - * License along with this library; if not, write to the 
353 - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 
354 - * Boston, MA  02111-1301 USA
355 - *
356 - *  Contributor(s): Martin Gallwey (gallwey@sun.com)
357 - *
358 - */
359 -
360 -/* "This product is not manufactured, approved, or supported by
361 - * Corel Corporation or Corel Corporation Limited."
362 - */
363 -#ifndef _GRAPHICSHANDLER_H
364 -#define _GRAPHICSHANDLER_H
365 -#include <string>
366 -#include <map>
367 -#include <vector>
368 -
369 -class GraphicsHandler
370 -{
371 -public:
372 -       virtual ~GraphicsHandler() {}
373 -        virtual void startDocument() = 0;
374 -        virtual void endDocument() = 0;
375 -        virtual void startElement(const char *psName, const std::vector< std::pair <std::string, std::string> > &xPropList) = 0;
376 -        virtual void endElement(const char *psName) = 0;
377 -        virtual void characters(const std::string &sCharacters) = 0;
378 -};
379 -#endif
380 diff -Nur koffice-2.3.1/filters/karbon/wpg/import/OdgExporter.cxx koffice-2.3.1-libwpg02/filters/karbon/wpg/import/OdgExporter.cxx
381 --- koffice-2.3.1/filters/karbon/wpg/import/OdgExporter.cxx     2011-01-15 21:05:35.000000000 +0100
382 +++ koffice-2.3.1-libwpg02/filters/karbon/wpg/import/OdgExporter.cxx    1970-01-01 01:00:00.000000000 +0100
383 @@ -1,662 +0,0 @@
384 -/* libwpg
385 - * Copyright (C) 2006 Ariya Hidayat (ariya@kde.org)
386 - * Copyright (C) 2006 Fridrich Strba (fridrich.strba@bluewin.ch)
387 - *
388 - * This library is free software; you can redistribute it and/or
389 - * modify it under the terms of the GNU Library General Public
390 - * License as published by the Free Software Foundation; either
391 - * version 2 of the License, or (at your option) any later version.
392 - *
393 - * This library is distributed in the hope that it will be useful,
394 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
395 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
396 - * Library General Public License for more details.
397 - *
398 - * You should have received a copy of the GNU Library General Public
399 - * License along with this library; if not, write to the
400 - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
401 - * Boston, MA  02111-1301 USA
402 - *
403 - * For further information visit http://libwpg.sourceforge.net
404 - */
405 -
406 -/* "This product is not manufactured, approved, or supported by
407 - * Corel Corporation or Corel Corporation Limited."
408 - */
409 -
410 -#include "OdgExporter.hxx"
411 -#include "GraphicsElement.hxx"
412 -#include "GraphicsHandler.hxx"
413 -#include <locale.h>
414 -
415 -static std::string doubleToString(const double value)
416 -{
417 -  std::ostringstream tempStream;
418 -  tempStream << value;
419 -  std::string decimalPoint(localeconv()->decimal_point);
420 -  if ((decimalPoint.size() == 0) || (decimalPoint == "."))
421 -    return tempStream.str();
422 -  std::string stringValue(tempStream.str());
423 -  if (!stringValue.empty())
424 -  {
425 -    std::string::size_type pos;
426 -    while ((pos = stringValue.find(decimalPoint)) != std::string::npos)
427 -          stringValue.replace(pos,decimalPoint.size(),".");
428 -  }
429 -  return stringValue;
430 -}
431 -
432 -
433 -OdgExporter::OdgExporter(GraphicsHandler *pHandler, const bool isFlatXML):
434 -        mpHandler(pHandler),
435 -        m_fillRule(AlternatingFill),
436 -        m_gradientIndex(1),
437 -        m_dashIndex(1),
438 -        m_styleIndex(1),
439 -        m_width(0.0f),
440 -        m_height(0.0f),
441 -        m_isFlatXML(isFlatXML)
442 -{
443 -}
444 -
445 -OdgExporter::~OdgExporter()
446 -{
447 -        for (std::vector <GraphicsElement *>::iterator iterStroke = mStrokeDashElements.begin();
448 -                iterStroke != mStrokeDashElements.end(); iterStroke++)
449 -                delete (*iterStroke);
450 -
451 -        for (std::vector <GraphicsElement *>::iterator iterGradient = mGradientElements.begin();
452 -                iterGradient != mGradientElements.end(); iterGradient++)
453 -                delete (*iterGradient);
454 -
455 -        for (std::vector <GraphicsElement *>::iterator iterAutomaticStyles = mAutomaticStylesElements.begin();
456 -                iterAutomaticStyles != mAutomaticStylesElements.end(); iterAutomaticStyles++)
457 -                delete (*iterAutomaticStyles);
458 -
459 -        for (std::vector<GraphicsElement *>::iterator bodyIter = mBodyElements.begin();
460 -                bodyIter != mBodyElements.end(); bodyIter++)
461 -                delete (*bodyIter);
462 -}
463 -
464 -void OdgExporter::startGraphics(double width, double height)
465 -{
466 -        m_gradientIndex = 1;
467 -        m_dashIndex = 1;
468 -        m_styleIndex = 1;
469 -        m_width = width;
470 -        m_height = height;
471 -
472 -
473 -        mpHandler->startDocument();
474 -        OpenTagGraphicsElement tmpOfficeDocumentContent("office:document");
475 -        tmpOfficeDocumentContent.addAttribute("xmlns:office", "urn:oasis:names:tc:opendocument:xmlns:office:1.0");
476 -        tmpOfficeDocumentContent.addAttribute("xmlns:style", "urn:oasis:names:tc:opendocument:xmlns:style:1.0");
477 -        tmpOfficeDocumentContent.addAttribute("xmlns:text", "urn:oasis:names:tc:opendocument:xmlns:text:1.0");
478 -        tmpOfficeDocumentContent.addAttribute("xmlns:draw", "urn:oasis:names:tc:opendocument:xmlns:drawing:1.0");
479 -        tmpOfficeDocumentContent.addAttribute("xmlns:dc", "http://purl.org/dc/elements/1.1/");
480 -        tmpOfficeDocumentContent.addAttribute("xmlns:svg", "urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0");
481 -        tmpOfficeDocumentContent.addAttribute("xmlns:fo", "urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0");
482 -        tmpOfficeDocumentContent.addAttribute("xmlns:config", "urn:oasis:names:tc:opendocument:xmlns:config:1.0");
483 -        tmpOfficeDocumentContent.addAttribute("xmlns:ooo", "http://openoffice.org/2004/office");
484 -        tmpOfficeDocumentContent.addAttribute("office:version", "1.0");
485 -        if (m_isFlatXML)
486 -                        tmpOfficeDocumentContent.addAttribute("office:mimetype", "application/x-vnd.oasis.openoffice.drawing");
487 -        tmpOfficeDocumentContent.write(mpHandler);
488 -
489 -        OpenTagGraphicsElement("office:settings").write(mpHandler);
490 -
491 -        OpenTagGraphicsElement configItemSetOpenElement("config:config-item-set");
492 -        configItemSetOpenElement.addAttribute("config:name", "ooo:view-settings");
493 -        configItemSetOpenElement.write(mpHandler);
494 -
495 -        OpenTagGraphicsElement configItemOpenElement1("config:config-item");
496 -        configItemOpenElement1.addAttribute("config:name", "VisibleAreaTop");
497 -        configItemOpenElement1.addAttribute("config:type", "int");
498 -        configItemOpenElement1.write(mpHandler);
499 -        mpHandler->characters("0");
500 -        mpHandler->endElement("config:config-item");
501 -
502 -        OpenTagGraphicsElement configItemOpenElement2("config:config-item");
503 -        configItemOpenElement2.addAttribute("config:name", "VisibleAreaLeft");
504 -        configItemOpenElement2.addAttribute("config:type", "int");
505 -        configItemOpenElement2.write(mpHandler);
506 -        mpHandler->characters("0");
507 -        mpHandler->endElement("config:config-item");
508 -
509 -        OpenTagGraphicsElement configItemOpenElement3("config:config-item");
510 -        configItemOpenElement3.addAttribute("config:name", "VisibleAreaWidth");
511 -        configItemOpenElement3.addAttribute("config:type", "int");
512 -        configItemOpenElement3.write(mpHandler);
513 -        m_value.str("");
514 -        m_value << (unsigned)(2540 * width);
515 -        mpHandler->characters(m_value.str());
516 -        mpHandler->endElement("config:config-item");
517 -
518 -        OpenTagGraphicsElement configItemOpenElement4("config:config-item");
519 -        configItemOpenElement4.addAttribute("config:name", "VisibleAreaHeight");
520 -        configItemOpenElement4.addAttribute("config:type", "int");
521 -        configItemOpenElement4.write(mpHandler);
522 -        m_value.str("");
523 -        m_value << (unsigned)(2540 * height);
524 -        mpHandler->characters(m_value.str());
525 -        mpHandler->endElement("config:config-item");
526 -
527 -        mpHandler->endElement("config:config-item-set");
528 -
529 -        mpHandler->endElement("office:settings");
530 -
531 -}
532 -
533 -void OdgExporter::endGraphics()
534 -{
535 -        OpenTagGraphicsElement("office:styles").write(mpHandler);
536 -
537 -        for (std::vector <GraphicsElement *>::const_iterator iterStroke = mStrokeDashElements.begin();
538 -                iterStroke != mStrokeDashElements.end(); iterStroke++)
539 -                (*iterStroke)->write(mpHandler);
540 -
541 -        for (std::vector <GraphicsElement *>::const_iterator iterGradient = mGradientElements.begin();
542 -                iterGradient != mGradientElements.end(); iterGradient++)
543 -                (*iterGradient)->write(mpHandler);
544 -
545 -        mpHandler->endElement("office:styles");
546 -
547 -        OpenTagGraphicsElement("office:automatic-styles").write(mpHandler);
548 -
549 -        for (std::vector <GraphicsElement *>::const_iterator iterAutomaticStyles = mAutomaticStylesElements.begin();
550 -                iterAutomaticStyles != mAutomaticStylesElements.end(); iterAutomaticStyles++)
551 -                (*iterAutomaticStyles)->write(mpHandler);
552 -
553 -        OpenTagGraphicsElement tmpStylePageLayoutOpenElement("style:page-layout");
554 -        tmpStylePageLayoutOpenElement.addAttribute("style:name", "PM0");
555 -        tmpStylePageLayoutOpenElement.write(mpHandler);
556 -
557 -        OpenTagGraphicsElement tmpStylePageLayoutPropertiesOpenElement("style:page-layout-properties");
558 -        tmpStylePageLayoutPropertiesOpenElement.addAttribute("fo:margin-top", "0in");
559 -        tmpStylePageLayoutPropertiesOpenElement.addAttribute("fo:margin-bottom", "0in");
560 -        tmpStylePageLayoutPropertiesOpenElement.addAttribute("fo:margin-left", "0in");
561 -        tmpStylePageLayoutPropertiesOpenElement.addAttribute("fo:margin-right", "0in");
562 -        m_value.str("");
563 -        m_value <<  doubleToString(m_width) << "in";
564 -        tmpStylePageLayoutPropertiesOpenElement.addAttribute("fo:page-width", m_value.str());
565 -        m_value.str("");
566 -        m_value << doubleToString(m_height)  << "in";
567 -        tmpStylePageLayoutPropertiesOpenElement.addAttribute("fo:page-height", m_value.str());
568 -        m_value.str("");
569 -        tmpStylePageLayoutPropertiesOpenElement.addAttribute("style:print-orientation", "portrait");
570 -        tmpStylePageLayoutPropertiesOpenElement.write(mpHandler);
571 -
572 -        mpHandler->endElement("style:page-layout-properties");
573 -
574 -        mpHandler->endElement("style:page-layout");
575 -
576 -        OpenTagGraphicsElement tmpStyleStyleOpenElement("style:style");
577 -        tmpStyleStyleOpenElement.addAttribute("style:name", "dp1");
578 -        tmpStyleStyleOpenElement.addAttribute("style:family", "drawing-page");
579 -        tmpStyleStyleOpenElement.write(mpHandler);
580 -
581 -        OpenTagGraphicsElement tmpStyleDrawingPagePropertiesOpenElement("style:drawing-page-properties");
582 -        // tmpStyleDrawingPagePropertiesOpenElement.addAttribute("draw:background-size", "border");
583 -        tmpStyleDrawingPagePropertiesOpenElement.addAttribute("draw:fill", "none");
584 -        tmpStyleDrawingPagePropertiesOpenElement.write(mpHandler);
585 -
586 -        mpHandler->endElement("style:drawing-page-properties");
587 -
588 -        mpHandler->endElement("style:style");
589 -
590 -        mpHandler->endElement("office:automatic-styles");
591 -
592 -        OpenTagGraphicsElement("office:master-styles").write(mpHandler);
593 -
594 -        OpenTagGraphicsElement tmpStyleMasterPageOpenElement("style:master-page");
595 -        tmpStyleMasterPageOpenElement.addAttribute("style:name", "Default");
596 -        tmpStyleMasterPageOpenElement.addAttribute("style:page-layout-name", "PM0");
597 -        tmpStyleMasterPageOpenElement.addAttribute("draw:style-name", "dp1");
598 -        tmpStyleMasterPageOpenElement.write(mpHandler);
599 -
600 -        mpHandler->endElement("style:master-page");
601 -
602 -        mpHandler->endElement("office:master-styles");
603 -
604 -        OpenTagGraphicsElement("office:body").write(mpHandler);
605 -
606 -        OpenTagGraphicsElement("office:drawing").write(mpHandler);
607 -
608 -        OpenTagGraphicsElement tmpDrawPageOpenElement("draw:page");
609 -        tmpDrawPageOpenElement.addAttribute("draw:name", "page1");
610 -        tmpDrawPageOpenElement.addAttribute("draw:style-name", "dp1");
611 -        tmpDrawPageOpenElement.addAttribute("draw:master-page-name", "Default");
612 -        tmpDrawPageOpenElement.write(mpHandler);
613 -
614 -        for (std::vector<GraphicsElement *>::const_iterator bodyIter = mBodyElements.begin();
615 -                bodyIter != mBodyElements.end(); bodyIter++)
616 -        {
617 -                (*bodyIter)->write(mpHandler);
618 -        }
619 -
620 -        mpHandler->endElement("draw:page");
621 -        mpHandler->endElement("office:drawing");
622 -        mpHandler->endElement("office:body");
623 -        mpHandler->endElement("office:document");
624 -
625 -        mpHandler->endDocument();
626 -}
627 -
628 -void OdgExporter::setPen(const libwpg::WPGPen& pen)
629 -{
630 -        m_pen = pen;
631 -}
632 -
633 -void OdgExporter::setBrush(const libwpg::WPGBrush& brush)
634 -{
635 -        m_brush = brush;
636 -}
637 -
638 -void OdgExporter::setFillRule(FillRule rule)
639 -{
640 -        m_fillRule = rule;
641 -}
642 -
643 -void OdgExporter::startLayer(unsigned int)
644 -{
645 -}
646 -
647 -void OdgExporter::endLayer(unsigned int)
648 -{
649 -}
650 -
651 -void OdgExporter::drawRectangle(const libwpg::WPGRect& rect, double rx, double )
652 -{
653 -        writeStyle();
654 -        OpenTagGraphicsElement *pDrawRectElement = new OpenTagGraphicsElement("draw:rect");
655 -        m_value.str("");
656 -        m_value << "gr" << m_styleIndex-1;
657 -        pDrawRectElement->addAttribute("draw:style-name", m_value.str());
658 -        m_value.str("");
659 -        m_value << doubleToString(rect.x1) << "in";
660 -        pDrawRectElement->addAttribute("svg:x", m_value.str());
661 -        m_value.str("");
662 -        m_value << doubleToString(rect.y1) << "in";
663 -        pDrawRectElement->addAttribute("svg:y", m_value.str());
664 -        m_value.str("");
665 -        m_value << doubleToString(rect.x2-rect.x1) << "in";
666 -        pDrawRectElement->addAttribute("svg:width", m_value.str());
667 -        m_value.str("");
668 -        m_value << doubleToString(rect.y2-rect.y1) << "in";
669 -        pDrawRectElement->addAttribute("svg:height", m_value.str());
670 -        m_value.str("");
671 -        m_value << doubleToString(rx) << "in";
672 -        // FIXME: what to do when rx != ry ?
673 -        pDrawRectElement->addAttribute("draw:corner-radius", m_value.str());
674 -        m_value.str("");
675 -        mBodyElements.push_back(static_cast<GraphicsElement *>(pDrawRectElement));
676 -        mBodyElements.push_back(static_cast<GraphicsElement *>(new CloseTagGraphicsElement("draw:rect")));
677 -}
678 -
679 -void OdgExporter::drawEllipse(const libwpg::WPGPoint& center, double rx, double ry)
680 -{
681 -        writeStyle();
682 -        OpenTagGraphicsElement *pDrawEllipseElement = new OpenTagGraphicsElement("draw:ellipse");
683 -        m_value.str("");
684 -        m_value << "gr" << m_styleIndex-1;
685 -        pDrawEllipseElement->addAttribute("draw:style-name", m_value.str());
686 -        m_value.str("");
687 -        m_value << doubleToString(center.x - rx) << "in";
688 -        pDrawEllipseElement->addAttribute("svg:x", m_value.str());
689 -        m_value.str("");
690 -        m_value << doubleToString(center.y - ry) << "in";
691 -        pDrawEllipseElement->addAttribute("svg:y", m_value.str());
692 -        m_value.str("");
693 -        m_value << doubleToString(2 * rx) << "in";
694 -        pDrawEllipseElement->addAttribute("svg:width", m_value.str());
695 -        m_value.str("");
696 -        m_value << doubleToString(2 * ry) << "in";
697 -        pDrawEllipseElement->addAttribute("svg:height", m_value.str());
698 -        m_value.str("");
699 -        mBodyElements.push_back(static_cast<GraphicsElement *>(pDrawEllipseElement));
700 -        mBodyElements.push_back(static_cast<GraphicsElement *>(new CloseTagGraphicsElement("draw:ellipse")));
701 -}
702 -
703 -void OdgExporter::drawPolygon(const libwpg::WPGPointArray& vertices)
704 -{
705 -        if(vertices.count() < 2)
706 -                return;
707 -
708 -        if(vertices.count() == 2)
709 -        {
710 -                const libwpg::WPGPoint& p1 = vertices[0];
711 -                const libwpg::WPGPoint& p2 = vertices[1];
712 -
713 -                writeStyle();
714 -                OpenTagGraphicsElement *pDrawLineElement = new OpenTagGraphicsElement("draw:line");
715 -                m_value.str("");
716 -                m_value << "gr" << m_styleIndex-1;
717 -                pDrawLineElement->addAttribute("draw:style-name", m_value.str());
718 -                m_value.str("");
719 -                pDrawLineElement->addAttribute("draw:text-style-name", "P1");
720 -                pDrawLineElement->addAttribute("draw:layer", "layout");
721 -                m_value << doubleToString(p1.x)  << "in";
722 -                pDrawLineElement->addAttribute("svg:x1", m_value.str());
723 -                m_value.str("");
724 -                m_value << doubleToString(p1.y)  << "in";
725 -                pDrawLineElement->addAttribute("svg:y1", m_value.str());
726 -                m_value.str("");
727 -                m_value  << doubleToString(p2.x)  << "in";
728 -                pDrawLineElement->addAttribute("svg:x2", m_value.str());
729 -                m_value.str("");
730 -                m_value << doubleToString(p2.y)  << "in";
731 -                pDrawLineElement->addAttribute("svg:y2", m_value.str());
732 -                m_value.str("");
733 -                mBodyElements.push_back(static_cast<GraphicsElement *>(pDrawLineElement));
734 -                mBodyElements.push_back(static_cast<GraphicsElement *>(new CloseTagGraphicsElement("draw:line")));
735 -        }
736 -        else
737 -        {
738 -                // draw as path
739 -                libwpg::WPGPath path;
740 -                path.moveTo(vertices[0]);
741 -                for(unsigned long ii = 1; ii < vertices.count(); ii++)
742 -                        path.lineTo(vertices[ii]);
743 -                path.closed = true;
744 -                drawPath(path);
745 -        }
746 -}
747 -
748 -void OdgExporter::drawPath(const libwpg::WPGPath& path)
749 -{
750 -        if(path.count() == 0)
751 -                return;
752 -
753 -        // try to find the bounding box
754 -        // this is simple convex hull technique, the bounding box might not be
755 -        // accurate but that should be enough for this purpose
756 -        libwpg::WPGPoint p = path.element(0).point;
757 -        libwpg::WPGPoint q = path.element(0).point;
758 -        for(unsigned k = 0; k < path.count(); k++)
759 -        {
760 -                libwpg::WPGPathElement element = path.element(k);
761 -                p.x = (p.x > element.point.x) ? element.point.x : p.x;
762 -                p.y = (p.y > element.point.y) ? element.point.y : p.y;
763 -                q.x = (q.x < element.point.x) ? element.point.x : q.x;
764 -                q.y = (q.y < element.point.y) ? element.point.y : q.y;
765 -                if(element.type == libwpg::WPGPathElement::CurveToElement)
766 -                {
767 -                        p.x = (p.x > element.extra1.x) ? element.extra1.x : p.x;
768 -                        p.y = (p.y > element.extra1.y) ? element.extra1.y : p.y;
769 -                        q.x = (q.x < element.extra1.x) ? element.extra1.x : q.x;
770 -                        q.y = (q.y < element.extra1.y) ? element.extra1.y : q.y;
771 -                        p.x = (p.x > element.extra2.x) ? element.extra2.x : p.x;
772 -                        p.y = (p.y > element.extra2.y) ? element.extra2.y : p.y;
773 -                        q.x = (q.x < element.extra2.x) ? element.extra2.x : q.x;
774 -                        q.y = (q.y < element.extra2.y) ? element.extra2.y : q.y;
775 -                }
776 -        }
777 -        double vw = q.x - p.x;
778 -        double vh = q.y - p.y;
779 -
780 -        writeStyle();
781 -
782 -        OpenTagGraphicsElement *pDrawPathElement = new OpenTagGraphicsElement("draw:path");
783 -        m_value.str("");
784 -        m_value << "gr" << m_styleIndex-1;
785 -        pDrawPathElement->addAttribute("draw:style-name", m_value.str());
786 -        m_value.str("");
787 -        pDrawPathElement->addAttribute("draw:text-style-name", "P1");
788 -        pDrawPathElement->addAttribute("draw:layer", "layout");
789 -        m_value << doubleToString(p.x)  << "in";
790 -        pDrawPathElement->addAttribute("svg:x", m_value.str());
791 -        m_value.str("");
792 -        m_value << doubleToString(p.y)  << "in";
793 -        pDrawPathElement->addAttribute("svg:y", m_value.str());
794 -        m_value.str("");
795 -        m_value << doubleToString(vw) << "in";
796 -        pDrawPathElement->addAttribute("svg:width", m_value.str());
797 -        m_value.str("");
798 -        m_value << doubleToString(vh) << "in";
799 -        pDrawPathElement->addAttribute("svg:height", m_value.str());
800 -        m_value.str("");
801 -        m_value << "0 0 " << (int)(vw*2540) << " " << (int)(vh*2540);
802 -        pDrawPathElement->addAttribute("svg:viewBox", m_value.str());
803 -        m_value.str("");
804 -
805 -        for(unsigned i = 0; i < path.count(); i++)
806 -        {
807 -                libwpg::WPGPathElement element = path.element(i);
808 -                libwpg::WPGPoint point = element.point;
809 -                switch(element.type)
810 -                {
811 -                        // 2540 is 2.54*1000, 2.54 in = 1 in
812 -                        case libwpg::WPGPathElement::MoveToElement:
813 -                                m_value << "M" << (int)((point.x-p.x)*2540) << " ";
814 -                                m_value << (int)((point.y-p.y)*2540);
815 -                                break;
816 -
817 -                        case libwpg::WPGPathElement::LineToElement:
818 -                                m_value << "L" << (int)((point.x-p.x)*2540) << " ";
819 -                                m_value << (int)((point.y-p.y)*2540);
820 -                                break;
821 -
822 -                        case libwpg::WPGPathElement::CurveToElement:
823 -                                m_value << "C" << (int)((element.extra1.x-p.x)*2540) << " ";
824 -                                m_value << (int)((element.extra1.y-p.y)*2540) << " ";
825 -                                m_value << (int)((element.extra2.x-p.x)*2540) << " ";
826 -                                m_value << (int)((element.extra2.y-p.y)*2540) << " ";
827 -                                m_value << (int)((point.x-p.x)*2540) << " ";
828 -                                m_value << (int)((point.y-p.y)*2540);
829 -                                break;
830 -
831 -                        default:
832 -                                break;
833 -                }
834 -        }
835 -        if(path.closed)
836 -                m_value << " Z";
837 -        pDrawPathElement->addAttribute("svg:d", m_value.str());
838 -        m_value.str("");
839 -        mBodyElements.push_back(static_cast<GraphicsElement *>(pDrawPathElement));
840 -        mBodyElements.push_back(static_cast<GraphicsElement *>(new CloseTagGraphicsElement("draw:path")));
841 -}
842 -
843 -
844 -void OdgExporter::drawBitmap(const libwpg::WPGBitmap& bitmap)
845 -{
846 -        OpenTagGraphicsElement *pDrawFrameElement = new OpenTagGraphicsElement("draw:frame");
847 -        m_value.str("");
848 -        m_value << doubleToString(bitmap.rect.x1) << "in";
849 -        pDrawFrameElement->addAttribute("svg:x", m_value.str());
850 -        m_value.str("");
851 -        m_value << doubleToString(bitmap.rect.y1) << "in";
852 -        pDrawFrameElement->addAttribute("svg:y", m_value.str());
853 -        m_value.str("");
854 -        m_value << doubleToString(bitmap.rect.height()) << "in";
855 -        pDrawFrameElement->addAttribute("svg:height", m_value.str());
856 -        m_value.str("");
857 -        m_value << doubleToString(bitmap.rect.width()) << "in";
858 -        pDrawFrameElement->addAttribute("svg:width", m_value.str());
859 -        mBodyElements.push_back(static_cast<GraphicsElement *>(pDrawFrameElement));
860 -
861 -        mBodyElements.push_back(static_cast<GraphicsElement *>(new OpenTagGraphicsElement("draw:image")));
862 -
863 -        mBodyElements.push_back(static_cast<GraphicsElement *>(new OpenTagGraphicsElement("office:binary-data")));
864 -
865 -        libwpg::WPGString base64Binary;
866 -        bitmap.generateBase64DIB(base64Binary);
867 -        mBodyElements.push_back(static_cast<GraphicsElement *>(new CharDataGraphicsElement(base64Binary.cstr())));
868 -
869 -        mBodyElements.push_back(static_cast<GraphicsElement *>(new CloseTagGraphicsElement("office:binary-data")));
870 -
871 -        mBodyElements.push_back(static_cast<GraphicsElement *>(new CloseTagGraphicsElement("draw:image")));
872 -
873 -        mBodyElements.push_back(static_cast<GraphicsElement *>(new CloseTagGraphicsElement("draw:frame")));
874 -}
875 -
876 -void OdgExporter::drawImageObject(const libwpg::WPGBinaryData& binaryData)
877 -{
878 -        if (binaryData.mimeType.length() <= 0)
879 -                return;
880 -        OpenTagGraphicsElement *pDrawFrameElement = new OpenTagGraphicsElement("draw:frame");
881 -        m_value.str("");
882 -        m_value << doubleToString(binaryData.rect.x1) << "in";
883 -        pDrawFrameElement->addAttribute("svg:x", m_value.str());
884 -        m_value.str("");
885 -        m_value << doubleToString(binaryData.rect.y1) << "in";
886 -        pDrawFrameElement->addAttribute("svg:y", m_value.str());
887 -        m_value.str("");
888 -        m_value << doubleToString(binaryData.rect.height()) << "in";
889 -        pDrawFrameElement->addAttribute("svg:height", m_value.str());
890 -        m_value.str("");
891 -        m_value << doubleToString(binaryData.rect.width()) << "in";
892 -        pDrawFrameElement->addAttribute("svg:width", m_value.str());
893 -        mBodyElements.push_back(static_cast<GraphicsElement *>(pDrawFrameElement));
894 -
895 -        mBodyElements.push_back(static_cast<GraphicsElement *>(new OpenTagGraphicsElement("draw:image")));
896 -
897 -        mBodyElements.push_back(static_cast<GraphicsElement *>(new OpenTagGraphicsElement("office:binary-data")));
898 -
899 -        libwpg::WPGString base64Binary = binaryData.getBase64Data();
900 -        mBodyElements.push_back(static_cast<GraphicsElement *>(new CharDataGraphicsElement(base64Binary.cstr())));
901 -
902 -        mBodyElements.push_back(static_cast<GraphicsElement *>(new CloseTagGraphicsElement("office:binary-data")));
903 -
904 -        mBodyElements.push_back(static_cast<GraphicsElement *>(new CloseTagGraphicsElement("draw:image")));
905 -
906 -        mBodyElements.push_back(static_cast<GraphicsElement *>(new CloseTagGraphicsElement("draw:frame")));
907 -}
908 -
909 -
910 -static std::string colorToHex(const libwpg::WPGColor& color)
911 -{
912 -        char hexdigits[] = "0123456789abcdef";
913 -        char buffer[] = "123456";
914 -        buffer[0] = hexdigits[(color.red >> 4) & 15];
915 -        buffer[1] = hexdigits[color.red & 15];
916 -        buffer[2] = hexdigits[(color.green >> 4) & 15];
917 -        buffer[3] = hexdigits[color.green & 15];
918 -        buffer[4] = hexdigits[(color.blue >> 4) & 15];
919 -        buffer[5] = hexdigits[color.blue & 15];
920 -        return std::string(buffer);
921 -}
922 -
923 -void OdgExporter::writeStyle()
924 -{
925 -        m_value.str("");
926 -        m_name.str("");
927 -
928 -        if(!m_pen.solid && (m_pen.dashArray.count() >=2 ) )
929 -        {
930 -                // ODG only supports dashes with the same length of spaces inbetween
931 -                // here we take the first space and assume everything else the same
932 -                // note that dash length is written in percentage
933 -                double distance = m_pen.dashArray.at(1);
934 -                OpenTagGraphicsElement *tmpDrawStrokeDashElement = new OpenTagGraphicsElement("draw:stroke-dash");
935 -                tmpDrawStrokeDashElement->addAttribute("draw:style", "rect");
936 -                m_value << "Dash_" << m_dashIndex++;
937 -                tmpDrawStrokeDashElement->addAttribute("draw:name", m_value.str());
938 -                m_value.str("");
939 -                m_value << doubleToString(distance*100) << "%";
940 -                tmpDrawStrokeDashElement->addAttribute("draw:distance", m_value.str());
941 -                m_value.str("");
942 -                for(unsigned i = 0; i < m_pen.dashArray.count()/2; i++)
943 -                {
944 -                        m_name << "draw:dots" << i+1;
945 -                        tmpDrawStrokeDashElement->addAttribute(m_name.str(), "1");
946 -                        m_name.str("");
947 -                        m_name << "draw:dots" << i+1 << "-length";
948 -                        m_value << doubleToString(100*m_pen.dashArray.at(i*2)) << "%";
949 -                        tmpDrawStrokeDashElement->addAttribute(m_name.str(), m_value.str());
950 -                        m_name.str("");
951 -                        m_value.str("");
952 -                }
953 -                mStrokeDashElements.push_back(static_cast<GraphicsElement *>(tmpDrawStrokeDashElement));
954 -                mStrokeDashElements.push_back(static_cast<GraphicsElement *>(new CloseTagGraphicsElement("draw:stroke-dash")));
955 -        }
956 -
957 -        if(m_brush.style == libwpg::WPGBrush::Gradient)
958 -        {
959 -                OpenTagGraphicsElement *tmpDrawGradientElement = new OpenTagGraphicsElement("draw:gradient");
960 -                tmpDrawGradientElement->addAttribute("draw:style", "linear");
961 -                m_value << "Gradient_" << m_gradientIndex++;
962 -                tmpDrawGradientElement->addAttribute("draw:name", m_value.str());
963 -                m_value.str("");
964 -
965 -                // ODG angle unit is 0.1 degree
966 -                double angle = -m_brush.gradient.angle();
967 -                while(angle < 0)
968 -                        angle += 360;
969 -                while(angle > 360)
970 -                        angle -= 360;
971 -
972 -                m_value << (unsigned)(angle*10);
973 -                tmpDrawGradientElement->addAttribute("draw:angle", m_value.str());
974 -                m_value.str("");
975 -
976 -                libwpg::WPGColor startColor = m_brush.gradient.stopColor(0);
977 -                libwpg::WPGColor stopColor = m_brush.gradient.stopColor(1);
978 -                m_value << "#" << colorToHex(startColor);
979 -                tmpDrawGradientElement->addAttribute("draw:start-color", m_value.str());
980 -                m_value.str("");
981 -                m_value << "#" << colorToHex(stopColor);
982 -                tmpDrawGradientElement->addAttribute("draw:end-color", m_value.str());
983 -                m_value.str("");
984 -                tmpDrawGradientElement->addAttribute("draw:start-intensity", "100%");
985 -                tmpDrawGradientElement->addAttribute("draw:end-intensity", "100%");
986 -                tmpDrawGradientElement->addAttribute("draw:border", "0%");
987 -                mGradientElements.push_back(static_cast<GraphicsElement *>(tmpDrawGradientElement));
988 -                mGradientElements.push_back(static_cast<GraphicsElement *>(new CloseTagGraphicsElement("draw:gradient")));
989 -        }
990 -
991 -        OpenTagGraphicsElement *tmpStyleStyleElement = new OpenTagGraphicsElement("style:style");
992 -        m_value << "gr" << m_styleIndex;
993 -        tmpStyleStyleElement->addAttribute("style:name", m_value.str());
994 -        m_value.str("");
995 -        tmpStyleStyleElement->addAttribute("style:family", "graphic");
996 -        tmpStyleStyleElement->addAttribute("style:parent-style-name", "standard");
997 -        mAutomaticStylesElements.push_back(static_cast<GraphicsElement *>(tmpStyleStyleElement));
998 -
999 -        OpenTagGraphicsElement *tmpStyleGraphicPropertiesElement = new OpenTagGraphicsElement("style:graphic-properties");
1000 -
1001 -        if(m_pen.width > 0.0)
1002 -        {
1003 -                m_value << doubleToString(m_pen.width) << "in";
1004 -                tmpStyleGraphicPropertiesElement->addAttribute("svg:stroke-width", m_value.str());
1005 -                m_value.str("");
1006 -                m_value << "#" << colorToHex(m_pen.foreColor);
1007 -                tmpStyleGraphicPropertiesElement->addAttribute("svg:stroke-color", m_value.str());
1008 -                m_value.str("");
1009 -
1010 -                if(!m_pen.solid)
1011 -                {
1012 -                        tmpStyleGraphicPropertiesElement->addAttribute("draw:stroke", "dash");
1013 -                        m_value << "Dash_" << m_dashIndex-1;
1014 -                        tmpStyleGraphicPropertiesElement->addAttribute("draw:stroke-dash", m_value.str());
1015 -                        m_value.str("");
1016 -                }
1017 -        }
1018 -        else
1019 -                tmpStyleGraphicPropertiesElement->addAttribute("draw:stroke", "none");
1020 -
1021 -        if(m_brush.style == libwpg::WPGBrush::NoBrush)
1022 -                tmpStyleGraphicPropertiesElement->addAttribute("draw:fill", "none");
1023 -
1024 -        if(m_brush.style == libwpg::WPGBrush::Solid)
1025 -        {
1026 -                tmpStyleGraphicPropertiesElement->addAttribute("draw:fill", "solid");
1027 -                m_value << "#" << colorToHex(m_brush.foreColor);
1028 -                tmpStyleGraphicPropertiesElement->addAttribute("draw:fill-color", m_value.str());
1029 -                m_value.str("");
1030 -        }
1031 -
1032 -        if(m_brush.style == libwpg::WPGBrush::Gradient)
1033 -        {
1034 -                tmpStyleGraphicPropertiesElement->addAttribute("draw:fill", "gradient");
1035 -                m_value << "Gradient_" << m_gradientIndex-1;
1036 -                tmpStyleGraphicPropertiesElement->addAttribute("draw:fill-gradient-name", m_value.str());
1037 -                m_value.str("");
1038 -        }
1039 -
1040 -        mAutomaticStylesElements.push_back(static_cast<GraphicsElement *>(tmpStyleGraphicPropertiesElement));
1041 -        mAutomaticStylesElements.push_back(static_cast<GraphicsElement *>(new CloseTagGraphicsElement("style:graphic-properties")));
1042 -
1043 -        mAutomaticStylesElements.push_back(static_cast<GraphicsElement *>(new CloseTagGraphicsElement("style:style")));
1044 -        m_styleIndex++;
1045 -}
1046 diff -Nur koffice-2.3.1/filters/karbon/wpg/import/OdgExporter.hxx koffice-2.3.1-libwpg02/filters/karbon/wpg/import/OdgExporter.hxx
1047 --- koffice-2.3.1/filters/karbon/wpg/import/OdgExporter.hxx     2011-01-15 21:05:35.000000000 +0100
1048 +++ koffice-2.3.1-libwpg02/filters/karbon/wpg/import/OdgExporter.hxx    1970-01-01 01:00:00.000000000 +0100
1049 @@ -1,116 +0,0 @@
1050 -/* libwpg
1051 - * Copyright (C) 2006 Ariya Hidayat (ariya@kde.org)
1052 - *
1053 - * This library is free software; you can redistribute it and/or
1054 - * modify it under the terms of the GNU Library General Public
1055 - * License as published by the Free Software Foundation; either
1056 - * version 2 of the License, or (at your option) any later version.
1057 - *
1058 - * This library is distributed in the hope that it will be useful,
1059 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
1060 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1061 - * Library General Public License for more details.
1062 - *
1063 - * You should have received a copy of the GNU Library General Public
1064 - * License along with this library; if not, write to the 
1065 - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 
1066 - * Boston, MA  02111-1301 USA
1067 - *
1068 - * For further information visit http://libwpg.sourceforge.net
1069 - */
1070 -
1071 -/* "This product is not manufactured, approved, or supported by
1072 - * Corel Corporation or Corel Corporation Limited."
1073 - */
1074 -
1075 -#ifndef __ODGEXPORTER_H__
1076 -#define __ODGEXPORTER_H__
1077 -
1078 -#include <iostream>
1079 -#include <sstream>
1080 -#include <string>
1081 -
1082 -#include <libwpg/libwpg.h>
1083 -#include "GraphicsElement.hxx"
1084 -
1085 -class OdgExporter : public libwpg::WPGPaintInterface {
1086 -public:
1087 -       explicit OdgExporter(GraphicsHandler *pHandler,
1088 -                            const bool isFlatXML = false);
1089 -       ~OdgExporter();
1090 -
1091 -#if LIBWPG_VERSION_MINOR<2
1092 -       void startGraphics(double imageWidth, double imageHeight);
1093 -       void endGraphics();
1094 -       void startLayer(unsigned int id);
1095 -       void endLayer(unsigned int id);
1096 -
1097 -       void setPen(const libwpg::WPGPen& pen);
1098 -       void setBrush(const libwpg::WPGBrush& brush);
1099 -       void setFillRule(FillRule rule);
1100 -
1101 -       void drawRectangle(const libwpg::WPGRect& rect, double rx, double ry);
1102 -       void drawEllipse(const libwpg::WPGPoint& center, double rx, double ry);
1103 -       void drawPolygon(const libwpg::WPGPointArray& vertices);
1104 -       void drawPath(const libwpg::WPGPath& path);
1105 -       void drawBitmap(const libwpg::WPGBitmap& bitmap);
1106 -       void drawImageObject(const libwpg::WPGBinaryData& binaryData);
1107 -
1108 -private:
1109 -       std::vector <GraphicsElement *> mBodyElements;
1110 -       std::vector <GraphicsElement *> mAutomaticStylesElements;
1111 -       std::vector <GraphicsElement *> mStrokeDashElements;
1112 -       std::vector <GraphicsElement *> mGradientElements;
1113 -       GraphicsHandler *mpHandler;
1114 -
1115 -       libwpg::WPGPen m_pen;
1116 -       libwpg::WPGBrush m_brush;
1117 -       FillRule m_fillRule;
1118 -       int m_gradientIndex;
1119 -       int m_dashIndex;
1120 -       int m_styleIndex;
1121 -       void writeStyle();
1122 -       std::ostringstream m_value, m_name;
1123 -       double m_width, m_height;
1124 -       const bool m_isFlatXML;
1125 -#else
1126 -       virtual void startGraphics(const ::WPXPropertyList &propList);
1127 -       virtual void endGraphics();
1128 -       virtual void setStyle(const ::WPXPropertyList &propList, const ::WPXPropertyListVector &gradient);
1129 -       virtual void startLayer(const ::WPXPropertyList &propList);
1130 -       virtual void endLayer();
1131 -       virtual void drawRectangle(const ::WPXPropertyList& propList);
1132 -       virtual void drawEllipse(const ::WPXPropertyList& propList);
1133 -       virtual void drawPolygon(const ::WPXPropertyListVector &vertices);
1134 -       virtual void drawPath(const ::WPXPropertyListVector &path);
1135 -       virtual void drawGraphicObject(const ::WPXPropertyList &propList, const ::WPXBinaryData &binaryData);
1136 -       virtual void startEmbeddedGraphics(const ::WPXPropertyList &propList);
1137 -       virtual void endEmbeddedGraphics();
1138 -       virtual void drawPolyline(const ::WPXPropertyListVector &vertices);
1139 -       virtual void startTextObject(const ::WPXPropertyList &propList, const ::WPXPropertyListVector &path);
1140 -       virtual void endTextObject();
1141 -       virtual void startTextLine(const ::WPXPropertyList &propList);
1142 -       virtual void endTextLine();
1143 -       virtual void startTextSpan(const ::WPXPropertyList &propList);
1144 -       virtual void endTextSpan();
1145 -       virtual void insertText(const ::WPXString &str);
1146 -
1147 -
1148 -private:
1149 -       std::vector <GraphicsElement *> mBodyElements;
1150 -       std::vector <GraphicsElement *> mAutomaticStylesElements;
1151 -       std::vector <GraphicsElement *> mStrokeDashElements;
1152 -       std::vector <GraphicsElement *> mGradientElements;
1153 -       GraphicsHandler *mpHandler;
1154 -
1155 -       int m_gradientIndex;
1156 -       int m_dashIndex;
1157 -       int m_styleIndex;
1158 -       void writeStyle();
1159 -       std::ostringstream m_value, m_name;
1160 -       double m_width, m_height;
1161 -       const bool m_isFlatXML;
1162 -#endif
1163 -};
1164 -
1165 -#endif // __ODGEXPORTER_H__
1166 diff -Nur koffice-2.3.1/filters/karbon/wpg/import/WPGImport.cpp koffice-2.3.1-libwpg02/filters/karbon/wpg/import/WPGImport.cpp
1167 --- koffice-2.3.1/filters/karbon/wpg/import/WPGImport.cpp       2011-01-15 21:05:35.000000000 +0100
1168 +++ koffice-2.3.1-libwpg02/filters/karbon/wpg/import/WPGImport.cpp      2011-01-02 17:46:15.000000000 +0100
1169 @@ -20,28 +20,26 @@
1170  #include <WPGImport.h>
1171  #include <WPGImport.moc>
1172  
1173 -#include <QBuffer>
1174 -#include <QByteArray>
1175 -#include <QString>
1176 -
1177 -#include <kdebug.h>
1178  #include <KoFilterChain.h>
1179  #include <KoGlobal.h>
1180  #include <KoUnit.h>
1181 +#include <KoXmlWriter.h>
1182 +
1183  #include <kpluginfactory.h>
1184 +#include <KDebug>
1185  
1186 -#include <KoXmlWriter.h>
1187 +
1188 +#include <QtCore/QString>
1189 +#include <QtCore/QFile>
1190  
1191  #include <libwpg/libwpg.h>
1192  #if LIBWPG_VERSION_MINOR<2
1193  #include <libwpg/WPGStreamImplementation.h>
1194  #else
1195  #include <libwpd-stream/libwpd-stream.h>
1196 +#include <libwpd/libwpd.h>
1197  #endif
1198  
1199 -#include "FileOutputHandler.hxx"
1200 -#include "OdgExporter.hxx"
1201 -
1202  #include <iostream>
1203  
1204  K_PLUGIN_FACTORY(WPGImportFactory, registerPlugin<WPGImport>();)
1205 @@ -56,35 +54,13 @@
1206  {
1207  }
1208  
1209 -static QByteArray createManifest()
1210 -{
1211 -    KoXmlWriter* manifestWriter;
1212 -    QByteArray manifestData;
1213 -    QBuffer manifestBuffer(&manifestData);
1214 -
1215 -    manifestBuffer.open(QIODevice::WriteOnly);
1216 -    manifestWriter = new KoXmlWriter(&manifestBuffer);
1217 -
1218 -    manifestWriter->startDocument("manifest:manifest");
1219 -    manifestWriter->startElement("manifest:manifest");
1220 -    manifestWriter->addAttribute("xmlns:manifest", "urn:oasis:names:tc:openoffice:xmlns:manifest:1.0");
1221 -    manifestWriter->addManifestEntry("/", "application/vnd.oasis.opendocument.graphics");
1222 -    //manifestWriter->addManifestEntry( "styles.xml", "text/xml" );
1223 -    manifestWriter->addManifestEntry("content.xml", "text/xml");
1224 -    manifestWriter->endElement();
1225 -    manifestWriter->endDocument();
1226 -    delete manifestWriter;
1227 -
1228 -    return manifestData;
1229 -}
1230 -
1231  
1232  KoFilter::ConversionStatus WPGImport::convert(const QByteArray& from, const QByteArray& to)
1233  {
1234      if (from != "application/x-wpg")
1235          return KoFilter::NotImplemented;
1236  
1237 -    if (to != "application/vnd.oasis.opendocument.graphics")
1238 +    if (to != "image/svg+xml")
1239          return KoFilter::NotImplemented;
1240  
1241  #if LIBWPG_VERSION_MINOR<2
1242 @@ -96,6 +72,7 @@
1243              input = olestream;
1244          }
1245      }
1246 +    libwpg::WPGString output;
1247  #else
1248      WPXInputStream* input = new WPXFileStream(m_chain->inputFile().toLocal8Bit());
1249      if (input->isOLEStream()) {
1250 @@ -105,59 +82,31 @@
1251              input = olestream;
1252          }
1253       }
1254 +     ::WPXString output;
1255  #endif
1256  
1257      if (!libwpg::WPGraphics::isSupported(input)) {
1258 -        std::cerr << "ERROR: Unsupported file format (unsupported version) or file is encrypted!" << std::endl;
1259 +        kWarning() << "ERROR: Unsupported file format (unsupported version) or file is encrypted!";
1260          delete input;
1261          return KoFilter::NotImplemented;
1262      }
1263  
1264 -    // do the conversion
1265 -    std::ostringstream tmpStringStream;
1266 -    FileOutputHandler tmpHandler(tmpStringStream);
1267 -    OdgExporter exporter(&tmpHandler);
1268 -    libwpg::WPGraphics::parse(input, &exporter);
1269 -    delete input;
1270 -
1271 -
1272 -    // create output store
1273 -    KoStore* storeout;
1274 -    storeout = KoStore::createStore(m_chain->outputFile(), KoStore::Write,
1275 -                                    "application/vnd.oasis.opendocument.graphics", KoStore::Zip);
1276 -
1277 -    if (!storeout) {
1278 -        kWarning() << "Couldn't open the requested file.";
1279 -        return KoFilter::FileNotFound;
1280 -    }
1281 -
1282 -#if 0
1283 -    if (!storeout->open("styles.xml")) {
1284 -        kWarning() << "Couldn't open the file 'styles.xml'.";
1285 -        return KoFilter::CreationError;
1286 +    if (!libwpg::WPGraphics::generateSVG(input, output)) {
1287 +        kWarning() << "ERROR: SVG Generation failed!";
1288 +        delete input;
1289 +        return KoFilter::ParsingError;
1290      }
1291 -    //storeout->write( createStyles() );
1292 -    storeout->close();
1293 -#endif
1294  
1295 -    if (!storeout->open("content.xml")) {
1296 -        kWarning() << "Couldn't open the file 'content.xml'.";
1297 -        return KoFilter::CreationError;
1298 -    }
1299 -    storeout->write(tmpStringStream.str().c_str());
1300 -    storeout->close();
1301 +    delete input;
1302  
1303 -    // store document manifest
1304 -    storeout->enterDirectory("META-INF");
1305 -    if (!storeout->open("manifest.xml")) {
1306 -        kWarning() << "Couldn't open the file 'META-INF/manifest.xml'.";
1307 -        return KoFilter::CreationError;
1308 +    QFile outputFile(m_chain->outputFile());
1309 +    if(!outputFile.open(QIODevice::WriteOnly | QIODevice::Text)) {
1310 +        kWarning() << "ERROR: Could not open output file" << m_chain->outputFile();
1311 +        return KoFilter::InternalError;
1312      }
1313 -    storeout->write(createManifest());
1314 -    storeout->close();
1315  
1316 -    // we are done!
1317 -    delete storeout;
1318 +    outputFile.write(output.cstr());
1319 +    outputFile.close();
1320  
1321      return KoFilter::OK;
1322  }
1323
This page took 0.158279 seconds and 3 git commands to generate.