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
7 include_directories(${CMAKE_BINARY_DIR}/filters/ ${WPD_INCLUDE_DIR} ${LIBWPG_INCLUDE_DIR}/)
9 -set(wpgimport_PART_SRCS
12 -FileOutputHandler.cxx
14 +set(wpgimport_PART_SRCS WPGImport.cpp)
16 kde4_add_plugin(wpgimport ${wpgimport_PART_SRCS})
18 -target_link_libraries(wpgimport komain ${LIBWPG_LIBRARIES} ${LIBWPG_STREAM_LIBRARIES})
19 +target_link_libraries(wpgimport komain ${LIBWPG_LIBRARIES} ${LIBWPG_STREAM_LIBRARIES} ${WPD_LIBRARIES})
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
28 - * Copyright (C) 2006 Fridrich Strba (fridrich.strba@bluewin.ch)
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.
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.
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
45 - * For further information visit http://libwpg.sourceforge.net
48 -/* "This product is not manufactured, approved, or supported by
49 - * Corel Corporation or Corel Corporation Limited."
52 -#include "FileOutputHandler.hxx"
54 -FileOutputHandler::FileOutputHandler(std::ostringstream &contentStream) :
55 - mbIsTagOpened(false),
56 - mContentStream(contentStream)
60 -void FileOutputHandler::startDocument()
64 -void FileOutputHandler::startElement(const char *psName, const std::vector<std::pair<std::string, std::string> > &xPropList)
68 - mContentStream << ">";
69 - mbIsTagOpened = false;
71 - mContentStream << "<" << psName;
73 - for (std::vector<std::pair<std::string, std::string> >::const_iterator i = xPropList.begin(); i != xPropList.end(); i++)
75 - mContentStream << " " << (*i).first.c_str() << "=\"" << (*i).second.c_str() << "\"";
77 - mbIsTagOpened = true;
78 - msOpenedTagName = psName;
81 -void FileOutputHandler::endElement(const char *psName)
85 - if( msOpenedTagName == psName )
87 - mContentStream << "/>";
88 - mbIsTagOpened = false;
90 - else // should not happen, but handle it
92 - mContentStream << ">";
93 - mContentStream << "</" << psName << ">";
94 - mbIsTagOpened = false;
99 - mContentStream << "</" << psName << ">";
100 - mbIsTagOpened = false;
104 -void FileOutputHandler::characters(const std::string &sCharacters)
108 - mContentStream << ">";
109 - mbIsTagOpened = false;
111 - mContentStream << sCharacters.c_str();
114 -void FileOutputHandler::endDocument()
118 - mContentStream << ">";
119 - mbIsTagOpened = false;
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
127 - * Copyright (C) 2006 Fridrich Strba (fridrich.strba@bluewin.ch)
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.
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.
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
144 - * For further information visit http://libwpg.sourceforge.net
147 -/* "This product is not manufactured, approved, or supported by
148 - * Corel Corporation or Corel Corporation Limited."
151 -#ifndef FILEOUTPUTHANDLER_H
152 -#define FILEOUTPUTHANDLER_H
157 -#include "GraphicsHandler.hxx"
159 -class FileOutputHandler : public GraphicsHandler
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);
170 - bool mbIsTagOpened;
171 - std::string msOpenedTagName;
172 - std::ostringstream &mContentStream;
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
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.
182 - * Copyright (C) 2002-2003 William Lachance (william.lachance@sympatico.ca)
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.
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.
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
199 - * For further information visit http://libwpg.sourceforge.net
203 -/* "This product is not manufactured, approved, or supported by
204 - * Corel Corporation or Corel Corporation Limited."
207 -#include "GraphicsElement.hxx"
208 -#include "GraphicsHandler.hxx"
211 -#define ASCII_SPACE 0x0020
213 -void TagGraphicsElement::print() const
217 -void OpenTagGraphicsElement::write(GraphicsHandler *pHandler) const
219 - pHandler->startElement(getTagName().c_str(), maAttrList);
222 -void OpenTagGraphicsElement::print() const
224 - TagGraphicsElement::print();
227 -void OpenTagGraphicsElement::addAttribute(const std::string &szAttributeName, const std::string &sAttributeValue)
229 - std::pair<std::string, std::string> tmpAttribute;
230 - tmpAttribute.first = szAttributeName;
231 - tmpAttribute.second = sAttributeValue;
232 - maAttrList.push_back(tmpAttribute);
235 -void CloseTagGraphicsElement::write(GraphicsHandler *pHandler) const
238 - pHandler->endElement(getTagName().c_str());
241 -void CharDataGraphicsElement::write(GraphicsHandler *pHandler) const
243 - pHandler->characters(msData);
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
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.
252 - * Copyright (C) 2002-2003 William Lachance (william.lachance@sympatico.ca)
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.
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.
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
269 - * For further information visit http://libwpd.sourceforge.net
273 -/* "This product is not manufactured, approved, or supported by
274 - * Corel Corporation or Corel Corporation Limited."
277 -#ifndef _GRAPHICSELEMENT_H
278 -#define _GRAPHICSELEMENT_H
283 -#include "GraphicsHandler.hxx"
285 -class GraphicsElement
288 - virtual ~GraphicsElement() {}
289 - virtual void write(GraphicsHandler *pHandler) const = 0;
290 - virtual void print() const {}
293 -class TagGraphicsElement : public GraphicsElement
296 - explicit TagGraphicsElement(const char *szTagName) : msTagName(szTagName) {}
297 - const std::string &getTagName() const { return msTagName; }
298 - virtual void print() const;
300 - const std::string msTagName;
303 -class OpenTagGraphicsElement : public TagGraphicsElement
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;
312 - std::vector<std::pair<std::string, std::string> > maAttrList;
315 -class CloseTagGraphicsElement : public TagGraphicsElement
318 - explicit CloseTagGraphicsElement(const char *szTagName) : TagGraphicsElement(szTagName) {}
319 - virtual void write(GraphicsHandler *pHandler) const;
322 -class CharDataGraphicsElement : public GraphicsElement
325 - CharDataGraphicsElement(const char *sData) : GraphicsElement(), msData(sData) {}
326 - virtual void write(GraphicsHandler *pHandler) const;
328 - std::string msData;
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
338 - * Copyright (C) 2004 William Lachance (wlach@interlog.com)
339 - * Copyright (C) 2004 Net Integration Technologies (http://www.net-itech.com)
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.
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.
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
356 - * Contributor(s): Martin Gallwey (gallwey@sun.com)
360 -/* "This product is not manufactured, approved, or supported by
361 - * Corel Corporation or Corel Corporation Limited."
363 -#ifndef _GRAPHICSHANDLER_H
364 -#define _GRAPHICSHANDLER_H
369 -class GraphicsHandler
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;
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
385 - * Copyright (C) 2006 Ariya Hidayat (ariya@kde.org)
386 - * Copyright (C) 2006 Fridrich Strba (fridrich.strba@bluewin.ch)
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.
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.
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
403 - * For further information visit http://libwpg.sourceforge.net
406 -/* "This product is not manufactured, approved, or supported by
407 - * Corel Corporation or Corel Corporation Limited."
410 -#include "OdgExporter.hxx"
411 -#include "GraphicsElement.hxx"
412 -#include "GraphicsHandler.hxx"
415 -static std::string doubleToString(const double value)
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())
425 - std::string::size_type pos;
426 - while ((pos = stringValue.find(decimalPoint)) != std::string::npos)
427 - stringValue.replace(pos,decimalPoint.size(),".");
429 - return stringValue;
433 -OdgExporter::OdgExporter(GraphicsHandler *pHandler, const bool isFlatXML):
434 - mpHandler(pHandler),
435 - m_fillRule(AlternatingFill),
436 - m_gradientIndex(1),
441 - m_isFlatXML(isFlatXML)
445 -OdgExporter::~OdgExporter()
447 - for (std::vector <GraphicsElement *>::iterator iterStroke = mStrokeDashElements.begin();
448 - iterStroke != mStrokeDashElements.end(); iterStroke++)
449 - delete (*iterStroke);
451 - for (std::vector <GraphicsElement *>::iterator iterGradient = mGradientElements.begin();
452 - iterGradient != mGradientElements.end(); iterGradient++)
453 - delete (*iterGradient);
455 - for (std::vector <GraphicsElement *>::iterator iterAutomaticStyles = mAutomaticStylesElements.begin();
456 - iterAutomaticStyles != mAutomaticStylesElements.end(); iterAutomaticStyles++)
457 - delete (*iterAutomaticStyles);
459 - for (std::vector<GraphicsElement *>::iterator bodyIter = mBodyElements.begin();
460 - bodyIter != mBodyElements.end(); bodyIter++)
461 - delete (*bodyIter);
464 -void OdgExporter::startGraphics(double width, double height)
466 - m_gradientIndex = 1;
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");
486 - tmpOfficeDocumentContent.addAttribute("office:mimetype", "application/x-vnd.oasis.openoffice.drawing");
487 - tmpOfficeDocumentContent.write(mpHandler);
489 - OpenTagGraphicsElement("office:settings").write(mpHandler);
491 - OpenTagGraphicsElement configItemSetOpenElement("config:config-item-set");
492 - configItemSetOpenElement.addAttribute("config:name", "ooo:view-settings");
493 - configItemSetOpenElement.write(mpHandler);
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");
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");
509 - OpenTagGraphicsElement configItemOpenElement3("config:config-item");
510 - configItemOpenElement3.addAttribute("config:name", "VisibleAreaWidth");
511 - configItemOpenElement3.addAttribute("config:type", "int");
512 - configItemOpenElement3.write(mpHandler);
514 - m_value << (unsigned)(2540 * width);
515 - mpHandler->characters(m_value.str());
516 - mpHandler->endElement("config:config-item");
518 - OpenTagGraphicsElement configItemOpenElement4("config:config-item");
519 - configItemOpenElement4.addAttribute("config:name", "VisibleAreaHeight");
520 - configItemOpenElement4.addAttribute("config:type", "int");
521 - configItemOpenElement4.write(mpHandler);
523 - m_value << (unsigned)(2540 * height);
524 - mpHandler->characters(m_value.str());
525 - mpHandler->endElement("config:config-item");
527 - mpHandler->endElement("config:config-item-set");
529 - mpHandler->endElement("office:settings");
533 -void OdgExporter::endGraphics()
535 - OpenTagGraphicsElement("office:styles").write(mpHandler);
537 - for (std::vector <GraphicsElement *>::const_iterator iterStroke = mStrokeDashElements.begin();
538 - iterStroke != mStrokeDashElements.end(); iterStroke++)
539 - (*iterStroke)->write(mpHandler);
541 - for (std::vector <GraphicsElement *>::const_iterator iterGradient = mGradientElements.begin();
542 - iterGradient != mGradientElements.end(); iterGradient++)
543 - (*iterGradient)->write(mpHandler);
545 - mpHandler->endElement("office:styles");
547 - OpenTagGraphicsElement("office:automatic-styles").write(mpHandler);
549 - for (std::vector <GraphicsElement *>::const_iterator iterAutomaticStyles = mAutomaticStylesElements.begin();
550 - iterAutomaticStyles != mAutomaticStylesElements.end(); iterAutomaticStyles++)
551 - (*iterAutomaticStyles)->write(mpHandler);
553 - OpenTagGraphicsElement tmpStylePageLayoutOpenElement("style:page-layout");
554 - tmpStylePageLayoutOpenElement.addAttribute("style:name", "PM0");
555 - tmpStylePageLayoutOpenElement.write(mpHandler);
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");
563 - m_value << doubleToString(m_width) << "in";
564 - tmpStylePageLayoutPropertiesOpenElement.addAttribute("fo:page-width", m_value.str());
566 - m_value << doubleToString(m_height) << "in";
567 - tmpStylePageLayoutPropertiesOpenElement.addAttribute("fo:page-height", m_value.str());
569 - tmpStylePageLayoutPropertiesOpenElement.addAttribute("style:print-orientation", "portrait");
570 - tmpStylePageLayoutPropertiesOpenElement.write(mpHandler);
572 - mpHandler->endElement("style:page-layout-properties");
574 - mpHandler->endElement("style:page-layout");
576 - OpenTagGraphicsElement tmpStyleStyleOpenElement("style:style");
577 - tmpStyleStyleOpenElement.addAttribute("style:name", "dp1");
578 - tmpStyleStyleOpenElement.addAttribute("style:family", "drawing-page");
579 - tmpStyleStyleOpenElement.write(mpHandler);
581 - OpenTagGraphicsElement tmpStyleDrawingPagePropertiesOpenElement("style:drawing-page-properties");
582 - // tmpStyleDrawingPagePropertiesOpenElement.addAttribute("draw:background-size", "border");
583 - tmpStyleDrawingPagePropertiesOpenElement.addAttribute("draw:fill", "none");
584 - tmpStyleDrawingPagePropertiesOpenElement.write(mpHandler);
586 - mpHandler->endElement("style:drawing-page-properties");
588 - mpHandler->endElement("style:style");
590 - mpHandler->endElement("office:automatic-styles");
592 - OpenTagGraphicsElement("office:master-styles").write(mpHandler);
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);
600 - mpHandler->endElement("style:master-page");
602 - mpHandler->endElement("office:master-styles");
604 - OpenTagGraphicsElement("office:body").write(mpHandler);
606 - OpenTagGraphicsElement("office:drawing").write(mpHandler);
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);
614 - for (std::vector<GraphicsElement *>::const_iterator bodyIter = mBodyElements.begin();
615 - bodyIter != mBodyElements.end(); bodyIter++)
617 - (*bodyIter)->write(mpHandler);
620 - mpHandler->endElement("draw:page");
621 - mpHandler->endElement("office:drawing");
622 - mpHandler->endElement("office:body");
623 - mpHandler->endElement("office:document");
625 - mpHandler->endDocument();
628 -void OdgExporter::setPen(const libwpg::WPGPen& pen)
633 -void OdgExporter::setBrush(const libwpg::WPGBrush& brush)
638 -void OdgExporter::setFillRule(FillRule rule)
643 -void OdgExporter::startLayer(unsigned int)
647 -void OdgExporter::endLayer(unsigned int)
651 -void OdgExporter::drawRectangle(const libwpg::WPGRect& rect, double rx, double )
654 - OpenTagGraphicsElement *pDrawRectElement = new OpenTagGraphicsElement("draw:rect");
656 - m_value << "gr" << m_styleIndex-1;
657 - pDrawRectElement->addAttribute("draw:style-name", m_value.str());
659 - m_value << doubleToString(rect.x1) << "in";
660 - pDrawRectElement->addAttribute("svg:x", m_value.str());
662 - m_value << doubleToString(rect.y1) << "in";
663 - pDrawRectElement->addAttribute("svg:y", m_value.str());
665 - m_value << doubleToString(rect.x2-rect.x1) << "in";
666 - pDrawRectElement->addAttribute("svg:width", m_value.str());
668 - m_value << doubleToString(rect.y2-rect.y1) << "in";
669 - pDrawRectElement->addAttribute("svg:height", 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());
675 - mBodyElements.push_back(static_cast<GraphicsElement *>(pDrawRectElement));
676 - mBodyElements.push_back(static_cast<GraphicsElement *>(new CloseTagGraphicsElement("draw:rect")));
679 -void OdgExporter::drawEllipse(const libwpg::WPGPoint& center, double rx, double ry)
682 - OpenTagGraphicsElement *pDrawEllipseElement = new OpenTagGraphicsElement("draw:ellipse");
684 - m_value << "gr" << m_styleIndex-1;
685 - pDrawEllipseElement->addAttribute("draw:style-name", m_value.str());
687 - m_value << doubleToString(center.x - rx) << "in";
688 - pDrawEllipseElement->addAttribute("svg:x", m_value.str());
690 - m_value << doubleToString(center.y - ry) << "in";
691 - pDrawEllipseElement->addAttribute("svg:y", m_value.str());
693 - m_value << doubleToString(2 * rx) << "in";
694 - pDrawEllipseElement->addAttribute("svg:width", m_value.str());
696 - m_value << doubleToString(2 * ry) << "in";
697 - pDrawEllipseElement->addAttribute("svg:height", m_value.str());
699 - mBodyElements.push_back(static_cast<GraphicsElement *>(pDrawEllipseElement));
700 - mBodyElements.push_back(static_cast<GraphicsElement *>(new CloseTagGraphicsElement("draw:ellipse")));
703 -void OdgExporter::drawPolygon(const libwpg::WPGPointArray& vertices)
705 - if(vertices.count() < 2)
708 - if(vertices.count() == 2)
710 - const libwpg::WPGPoint& p1 = vertices[0];
711 - const libwpg::WPGPoint& p2 = vertices[1];
714 - OpenTagGraphicsElement *pDrawLineElement = new OpenTagGraphicsElement("draw:line");
716 - m_value << "gr" << m_styleIndex-1;
717 - pDrawLineElement->addAttribute("draw:style-name", 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());
724 - m_value << doubleToString(p1.y) << "in";
725 - pDrawLineElement->addAttribute("svg:y1", m_value.str());
727 - m_value << doubleToString(p2.x) << "in";
728 - pDrawLineElement->addAttribute("svg:x2", m_value.str());
730 - m_value << doubleToString(p2.y) << "in";
731 - pDrawLineElement->addAttribute("svg:y2", m_value.str());
733 - mBodyElements.push_back(static_cast<GraphicsElement *>(pDrawLineElement));
734 - mBodyElements.push_back(static_cast<GraphicsElement *>(new CloseTagGraphicsElement("draw:line")));
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;
748 -void OdgExporter::drawPath(const libwpg::WPGPath& path)
750 - if(path.count() == 0)
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++)
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)
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;
777 - double vw = q.x - p.x;
778 - double vh = q.y - p.y;
782 - OpenTagGraphicsElement *pDrawPathElement = new OpenTagGraphicsElement("draw:path");
784 - m_value << "gr" << m_styleIndex-1;
785 - pDrawPathElement->addAttribute("draw:style-name", 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());
792 - m_value << doubleToString(p.y) << "in";
793 - pDrawPathElement->addAttribute("svg:y", m_value.str());
795 - m_value << doubleToString(vw) << "in";
796 - pDrawPathElement->addAttribute("svg:width", m_value.str());
798 - m_value << doubleToString(vh) << "in";
799 - pDrawPathElement->addAttribute("svg:height", m_value.str());
801 - m_value << "0 0 " << (int)(vw*2540) << " " << (int)(vh*2540);
802 - pDrawPathElement->addAttribute("svg:viewBox", m_value.str());
805 - for(unsigned i = 0; i < path.count(); i++)
807 - libwpg::WPGPathElement element = path.element(i);
808 - libwpg::WPGPoint point = element.point;
809 - switch(element.type)
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);
817 - case libwpg::WPGPathElement::LineToElement:
818 - m_value << "L" << (int)((point.x-p.x)*2540) << " ";
819 - m_value << (int)((point.y-p.y)*2540);
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);
837 - pDrawPathElement->addAttribute("svg:d", m_value.str());
839 - mBodyElements.push_back(static_cast<GraphicsElement *>(pDrawPathElement));
840 - mBodyElements.push_back(static_cast<GraphicsElement *>(new CloseTagGraphicsElement("draw:path")));
844 -void OdgExporter::drawBitmap(const libwpg::WPGBitmap& bitmap)
846 - OpenTagGraphicsElement *pDrawFrameElement = new OpenTagGraphicsElement("draw:frame");
848 - m_value << doubleToString(bitmap.rect.x1) << "in";
849 - pDrawFrameElement->addAttribute("svg:x", m_value.str());
851 - m_value << doubleToString(bitmap.rect.y1) << "in";
852 - pDrawFrameElement->addAttribute("svg:y", m_value.str());
854 - m_value << doubleToString(bitmap.rect.height()) << "in";
855 - pDrawFrameElement->addAttribute("svg:height", 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));
861 - mBodyElements.push_back(static_cast<GraphicsElement *>(new OpenTagGraphicsElement("draw:image")));
863 - mBodyElements.push_back(static_cast<GraphicsElement *>(new OpenTagGraphicsElement("office:binary-data")));
865 - libwpg::WPGString base64Binary;
866 - bitmap.generateBase64DIB(base64Binary);
867 - mBodyElements.push_back(static_cast<GraphicsElement *>(new CharDataGraphicsElement(base64Binary.cstr())));
869 - mBodyElements.push_back(static_cast<GraphicsElement *>(new CloseTagGraphicsElement("office:binary-data")));
871 - mBodyElements.push_back(static_cast<GraphicsElement *>(new CloseTagGraphicsElement("draw:image")));
873 - mBodyElements.push_back(static_cast<GraphicsElement *>(new CloseTagGraphicsElement("draw:frame")));
876 -void OdgExporter::drawImageObject(const libwpg::WPGBinaryData& binaryData)
878 - if (binaryData.mimeType.length() <= 0)
880 - OpenTagGraphicsElement *pDrawFrameElement = new OpenTagGraphicsElement("draw:frame");
882 - m_value << doubleToString(binaryData.rect.x1) << "in";
883 - pDrawFrameElement->addAttribute("svg:x", m_value.str());
885 - m_value << doubleToString(binaryData.rect.y1) << "in";
886 - pDrawFrameElement->addAttribute("svg:y", m_value.str());
888 - m_value << doubleToString(binaryData.rect.height()) << "in";
889 - pDrawFrameElement->addAttribute("svg:height", 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));
895 - mBodyElements.push_back(static_cast<GraphicsElement *>(new OpenTagGraphicsElement("draw:image")));
897 - mBodyElements.push_back(static_cast<GraphicsElement *>(new OpenTagGraphicsElement("office:binary-data")));
899 - libwpg::WPGString base64Binary = binaryData.getBase64Data();
900 - mBodyElements.push_back(static_cast<GraphicsElement *>(new CharDataGraphicsElement(base64Binary.cstr())));
902 - mBodyElements.push_back(static_cast<GraphicsElement *>(new CloseTagGraphicsElement("office:binary-data")));
904 - mBodyElements.push_back(static_cast<GraphicsElement *>(new CloseTagGraphicsElement("draw:image")));
906 - mBodyElements.push_back(static_cast<GraphicsElement *>(new CloseTagGraphicsElement("draw:frame")));
910 -static std::string colorToHex(const libwpg::WPGColor& color)
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);
923 -void OdgExporter::writeStyle()
928 - if(!m_pen.solid && (m_pen.dashArray.count() >=2 ) )
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());
939 - m_value << doubleToString(distance*100) << "%";
940 - tmpDrawStrokeDashElement->addAttribute("draw:distance", m_value.str());
942 - for(unsigned i = 0; i < m_pen.dashArray.count()/2; i++)
944 - m_name << "draw:dots" << i+1;
945 - tmpDrawStrokeDashElement->addAttribute(m_name.str(), "1");
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());
953 - mStrokeDashElements.push_back(static_cast<GraphicsElement *>(tmpDrawStrokeDashElement));
954 - mStrokeDashElements.push_back(static_cast<GraphicsElement *>(new CloseTagGraphicsElement("draw:stroke-dash")));
957 - if(m_brush.style == libwpg::WPGBrush::Gradient)
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());
965 - // ODG angle unit is 0.1 degree
966 - double angle = -m_brush.gradient.angle();
972 - m_value << (unsigned)(angle*10);
973 - tmpDrawGradientElement->addAttribute("draw:angle", m_value.str());
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());
981 - m_value << "#" << colorToHex(stopColor);
982 - tmpDrawGradientElement->addAttribute("draw:end-color", 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")));
991 - OpenTagGraphicsElement *tmpStyleStyleElement = new OpenTagGraphicsElement("style:style");
992 - m_value << "gr" << m_styleIndex;
993 - tmpStyleStyleElement->addAttribute("style:name", 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));
999 - OpenTagGraphicsElement *tmpStyleGraphicPropertiesElement = new OpenTagGraphicsElement("style:graphic-properties");
1001 - if(m_pen.width > 0.0)
1003 - m_value << doubleToString(m_pen.width) << "in";
1004 - tmpStyleGraphicPropertiesElement->addAttribute("svg:stroke-width", m_value.str());
1006 - m_value << "#" << colorToHex(m_pen.foreColor);
1007 - tmpStyleGraphicPropertiesElement->addAttribute("svg:stroke-color", m_value.str());
1012 - tmpStyleGraphicPropertiesElement->addAttribute("draw:stroke", "dash");
1013 - m_value << "Dash_" << m_dashIndex-1;
1014 - tmpStyleGraphicPropertiesElement->addAttribute("draw:stroke-dash", m_value.str());
1019 - tmpStyleGraphicPropertiesElement->addAttribute("draw:stroke", "none");
1021 - if(m_brush.style == libwpg::WPGBrush::NoBrush)
1022 - tmpStyleGraphicPropertiesElement->addAttribute("draw:fill", "none");
1024 - if(m_brush.style == libwpg::WPGBrush::Solid)
1026 - tmpStyleGraphicPropertiesElement->addAttribute("draw:fill", "solid");
1027 - m_value << "#" << colorToHex(m_brush.foreColor);
1028 - tmpStyleGraphicPropertiesElement->addAttribute("draw:fill-color", m_value.str());
1032 - if(m_brush.style == libwpg::WPGBrush::Gradient)
1034 - tmpStyleGraphicPropertiesElement->addAttribute("draw:fill", "gradient");
1035 - m_value << "Gradient_" << m_gradientIndex-1;
1036 - tmpStyleGraphicPropertiesElement->addAttribute("draw:fill-gradient-name", m_value.str());
1040 - mAutomaticStylesElements.push_back(static_cast<GraphicsElement *>(tmpStyleGraphicPropertiesElement));
1041 - mAutomaticStylesElements.push_back(static_cast<GraphicsElement *>(new CloseTagGraphicsElement("style:graphic-properties")));
1043 - mAutomaticStylesElements.push_back(static_cast<GraphicsElement *>(new CloseTagGraphicsElement("style:style")));
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
1051 - * Copyright (C) 2006 Ariya Hidayat (ariya@kde.org)
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.
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.
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
1068 - * For further information visit http://libwpg.sourceforge.net
1071 -/* "This product is not manufactured, approved, or supported by
1072 - * Corel Corporation or Corel Corporation Limited."
1075 -#ifndef __ODGEXPORTER_H__
1076 -#define __ODGEXPORTER_H__
1078 -#include <iostream>
1082 -#include <libwpg/libwpg.h>
1083 -#include "GraphicsElement.hxx"
1085 -class OdgExporter : public libwpg::WPGPaintInterface {
1087 - explicit OdgExporter(GraphicsHandler *pHandler,
1088 - const bool isFlatXML = false);
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);
1097 - void setPen(const libwpg::WPGPen& pen);
1098 - void setBrush(const libwpg::WPGBrush& brush);
1099 - void setFillRule(FillRule rule);
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);
1109 - std::vector <GraphicsElement *> mBodyElements;
1110 - std::vector <GraphicsElement *> mAutomaticStylesElements;
1111 - std::vector <GraphicsElement *> mStrokeDashElements;
1112 - std::vector <GraphicsElement *> mGradientElements;
1113 - GraphicsHandler *mpHandler;
1115 - libwpg::WPGPen m_pen;
1116 - libwpg::WPGBrush m_brush;
1117 - FillRule m_fillRule;
1118 - int m_gradientIndex;
1121 - void writeStyle();
1122 - std::ostringstream m_value, m_name;
1123 - double m_width, m_height;
1124 - const bool m_isFlatXML;
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);
1149 - std::vector <GraphicsElement *> mBodyElements;
1150 - std::vector <GraphicsElement *> mAutomaticStylesElements;
1151 - std::vector <GraphicsElement *> mStrokeDashElements;
1152 - std::vector <GraphicsElement *> mGradientElements;
1153 - GraphicsHandler *mpHandler;
1155 - int m_gradientIndex;
1158 - void writeStyle();
1159 - std::ostringstream m_value, m_name;
1160 - double m_width, m_height;
1161 - const bool m_isFlatXML;
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
1170 #include <WPGImport.h>
1171 #include <WPGImport.moc>
1174 -#include <QByteArray>
1177 -#include <kdebug.h>
1178 #include <KoFilterChain.h>
1179 #include <KoGlobal.h>
1181 +#include <KoXmlWriter.h>
1183 #include <kpluginfactory.h>
1186 -#include <KoXmlWriter.h>
1188 +#include <QtCore/QString>
1189 +#include <QtCore/QFile>
1191 #include <libwpg/libwpg.h>
1192 #if LIBWPG_VERSION_MINOR<2
1193 #include <libwpg/WPGStreamImplementation.h>
1195 #include <libwpd-stream/libwpd-stream.h>
1196 +#include <libwpd/libwpd.h>
1199 -#include "FileOutputHandler.hxx"
1200 -#include "OdgExporter.hxx"
1204 K_PLUGIN_FACTORY(WPGImportFactory, registerPlugin<WPGImport>();)
1209 -static QByteArray createManifest()
1211 - KoXmlWriter* manifestWriter;
1212 - QByteArray manifestData;
1213 - QBuffer manifestBuffer(&manifestData);
1215 - manifestBuffer.open(QIODevice::WriteOnly);
1216 - manifestWriter = new KoXmlWriter(&manifestBuffer);
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;
1228 - return manifestData;
1232 KoFilter::ConversionStatus WPGImport::convert(const QByteArray& from, const QByteArray& to)
1234 if (from != "application/x-wpg")
1235 return KoFilter::NotImplemented;
1237 - if (to != "application/vnd.oasis.opendocument.graphics")
1238 + if (to != "image/svg+xml")
1239 return KoFilter::NotImplemented;
1241 #if LIBWPG_VERSION_MINOR<2
1246 + libwpg::WPGString output;
1248 WPXInputStream* input = new WPXFileStream(m_chain->inputFile().toLocal8Bit());
1249 if (input->isOLEStream()) {
1250 @@ -105,59 +82,31 @@
1254 + ::WPXString output;
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!";
1261 return KoFilter::NotImplemented;
1264 - // do the conversion
1265 - std::ostringstream tmpStringStream;
1266 - FileOutputHandler tmpHandler(tmpStringStream);
1267 - OdgExporter exporter(&tmpHandler);
1268 - libwpg::WPGraphics::parse(input, &exporter);
1272 - // create output store
1273 - KoStore* storeout;
1274 - storeout = KoStore::createStore(m_chain->outputFile(), KoStore::Write,
1275 - "application/vnd.oasis.opendocument.graphics", KoStore::Zip);
1278 - kWarning() << "Couldn't open the requested file.";
1279 - return KoFilter::FileNotFound;
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!";
1289 + return KoFilter::ParsingError;
1291 - //storeout->write( createStyles() );
1292 - storeout->close();
1295 - if (!storeout->open("content.xml")) {
1296 - kWarning() << "Couldn't open the file 'content.xml'.";
1297 - return KoFilter::CreationError;
1299 - storeout->write(tmpStringStream.str().c_str());
1300 - storeout->close();
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;
1313 - storeout->write(createManifest());
1314 - storeout->close();
1318 + outputFile.write(output.cstr());
1319 + outputFile.close();
1321 return KoFilter::OK;