Update of /cvsroot/libwpg/perfectspot/src/odg In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv9173/src/odg Modified Files: FileOutputHandler.cxx FileOutputHandler.hxx GraphicsElement.cxx GraphicsElement.hxx OdgExporter.cxx OdgExporter.hxx Removed Files: GraphicsHandler.hxx Log Message: Branching off the stable branch STABLE-0-1-0 and porting perfectspot to the recent libwpg changes Index: GraphicsElement.hxx =================================================================== RCS file: /cvsroot/libwpg/perfectspot/src/odg/GraphicsElement.hxx,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- GraphicsElement.hxx 10 Jun 2007 20:51:59 -0000 1.2 +++ GraphicsElement.hxx 28 Nov 2008 15:09:15 -0000 1.3 @@ -1,7 +1,7 @@ /* GraphicsElement: The items we are collecting to be put into the Writer * document: paragraph and spans of text, as well as section breaks. * - * Copyright (C) 2002-2003 William Lachance (wil...@sy...) + * Copyright (C) 2002-2003 William Lachance (wr...@gm...) * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -14,9 +14,8 @@ * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02111-1301 USA + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * For further information visit http://libwpd.sourceforge.net * @@ -28,57 +27,58 @@ #ifndef _GRAPHICSELEMENT_H #define _GRAPHICSELEMENT_H -#include <string> -#include <map> +#include <libwpd/libwpd.h> #include <vector> -#include "GraphicsHandler.hxx" +#include "FileOutputHandler.hxx" class GraphicsElement { public: virtual ~GraphicsElement() {} - virtual void write(GraphicsHandler *pHandler) const = 0; + virtual void write(FileOutputHandler *pHandler) const = 0; virtual void print() const {} }; -class TagGraphicsElement : public GraphicsElement +class TagElement : public GraphicsElement { public: - explicit TagGraphicsElement(const char *szTagName) : msTagName(szTagName) {} - const std::string &getTagName() const { return msTagName; } - virtual void print() const; + virtual ~TagElement() {} + TagElement(const char *szTagName) : msTagName(szTagName) {} + const WPXString & getTagName() const { return msTagName; } + virtual void print() const {}; private: - const std::string msTagName; + WPXString msTagName; }; -class OpenTagGraphicsElement : public TagGraphicsElement +class TagOpenElement : public TagElement { public: - explicit OpenTagGraphicsElement(const char *szTagName) : TagGraphicsElement(szTagName) {} - ~OpenTagGraphicsElement() {} - void addAttribute(const std::string &szAttributeName, const std::string &sAttributeValue); - virtual void write(GraphicsHandler *pHandler) const; + TagOpenElement(const char *szTagName) : TagElement(szTagName) {} + virtual ~TagOpenElement() {} + void addAttribute(const char *szAttributeName, const WPXString &sAttributeValue); + virtual void write(FileOutputHandler *pHandler) const; virtual void print () const; private: - std::vector<std::pair<std::string, std::string> > maAttrList; + WPXPropertyList maAttrList; }; -class CloseTagGraphicsElement : public TagGraphicsElement +class TagCloseElement : public TagElement { public: - explicit CloseTagGraphicsElement(const char *szTagName) : TagGraphicsElement(szTagName) {} - virtual void write(GraphicsHandler *pHandler) const; + TagCloseElement(const char *szTagName) : TagElement(szTagName) {} + virtual ~TagCloseElement() {} + virtual void write(FileOutputHandler *pHandler) const; }; -class CharDataGraphicsElement : public GraphicsElement +class CharDataElement : public GraphicsElement { public: - CharDataGraphicsElement(const char *sData) : GraphicsElement(), msData(sData) {} - virtual void write(GraphicsHandler *pHandler) const; + CharDataElement(const char *sData) : GraphicsElement(), msData(sData) {} + virtual ~CharDataElement() {} + virtual void write(FileOutputHandler *pHandler) const; private: - std::string msData; + WPXString msData; }; - #endif Index: GraphicsElement.cxx =================================================================== RCS file: /cvsroot/libwpg/perfectspot/src/odg/GraphicsElement.cxx,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- GraphicsElement.cxx 10 Jun 2007 20:51:59 -0000 1.2 +++ GraphicsElement.cxx 28 Nov 2008 15:09:15 -0000 1.3 @@ -1,7 +1,7 @@ /* GraphicsElement: The items we are collecting to be put into the Writer * document: paragraph and spans of text, as well as section breaks. * - * Copyright (C) 2002-2003 William Lachance (wil...@sy...) + * Copyright (C) 2002-2003 William Lachance (wr...@gm...) * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -14,11 +14,10 @@ * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02111-1301 USA - * - * For further information visit http://libwpg.sourceforge.net + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * For further information visit http://libwpd.sourceforge.net * */ @@ -27,40 +26,30 @@ */ #include "GraphicsElement.hxx" -#include "GraphicsHandler.hxx" +#include "FileOutputHandler.hxx" #include <string.h> -#define ASCII_SPACE 0x0020 - -void TagGraphicsElement::print() const -{ -} - -void OpenTagGraphicsElement::write(GraphicsHandler *pHandler) const +void TagOpenElement::write(FileOutputHandler *pHandler) const { - pHandler->startElement(getTagName().c_str(), maAttrList); + pHandler->startElement(getTagName().cstr(), maAttrList); } -void OpenTagGraphicsElement::print() const +void TagOpenElement::print() const { - TagGraphicsElement::print(); + TagElement::print(); } -void OpenTagGraphicsElement::addAttribute(const std::string &szAttributeName, const std::string &sAttributeValue) +void TagOpenElement::addAttribute(const char *szAttributeName, const WPXString &sAttributeValue) { - std::pair<std::string, std::string> tmpAttribute; - tmpAttribute.first = szAttributeName; - tmpAttribute.second = sAttributeValue; - maAttrList.push_back(tmpAttribute); + maAttrList.insert(szAttributeName, sAttributeValue); } -void CloseTagGraphicsElement::write(GraphicsHandler *pHandler) const +void TagCloseElement::write(FileOutputHandler *pHandler) const { - - pHandler->endElement(getTagName().c_str()); + pHandler->endElement(getTagName().cstr()); } -void CharDataGraphicsElement::write(GraphicsHandler *pHandler) const +void CharDataElement::write(FileOutputHandler *pHandler) const { pHandler->characters(msData); } Index: OdgExporter.cxx =================================================================== RCS file: /cvsroot/libwpg/perfectspot/src/odg/OdgExporter.cxx,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- OdgExporter.cxx 3 Jul 2007 21:16:40 -0000 1.7 +++ OdgExporter.cxx 28 Nov 2008 15:09:15 -0000 1.8 @@ -26,69 +26,64 @@ #include "OdgExporter.hxx" #include "GraphicsElement.hxx" -#include "GraphicsHandler.hxx" +#include "FileOutputHandler.hxx" #include <locale.h> +#include <math.h> +#include <string> -static std::string doubleToString(const double value) -{ [...964 lines suppressed...] + mGraphicsAutomaticStyles.push_back(new TagCloseElement("style:style")); + miGraphicsStyleIndex++; +} + +WPXString OdgExporter::doubleToString(const double value) +{ + WPXString tempString; + tempString.sprintf("%.4f", value); + std::string decimalPoint(localeconv()->decimal_point); + if ((decimalPoint.size() == 0) || (decimalPoint == ".")) + return tempString; + std::string stringValue(tempString.cstr()); + if (!stringValue.empty()) + { + std::string::size_type pos; + while ((pos = stringValue.find(decimalPoint)) != std::string::npos) + stringValue.replace(pos,decimalPoint.size(),"."); + } + return WPXString(stringValue.c_str()); } Index: FileOutputHandler.hxx =================================================================== RCS file: /cvsroot/libwpg/perfectspot/src/odg/FileOutputHandler.hxx,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- FileOutputHandler.hxx 17 May 2007 14:35:12 -0000 1.1 +++ FileOutputHandler.hxx 28 Nov 2008 15:09:15 -0000 1.2 @@ -29,21 +29,22 @@ #include <iostream> #include <sstream> #include <string> -#include "GraphicsHandler.hxx" +#include <libwpd/libwpd.h> +#include "FileOutputHandler.hxx" -class FileOutputHandler : public GraphicsHandler +class FileOutputHandler { public: explicit FileOutputHandler(std::ostringstream &contentStream); virtual void startDocument(); virtual void endDocument(); - virtual void startElement(const char *psName, const std::vector<std::pair<std::string, std::string> > &xPropList); + virtual void startElement(const char *psName, const WPXPropertyList &xPropList); virtual void endElement(const char *psName); - virtual void characters(const std::string &sCharacters); + virtual void characters(const WPXString &sCharacters); private: bool mbIsTagOpened; - std::string msOpenedTagName; + WPXString msOpenedTagName; std::ostringstream &mContentStream; }; #endif Index: FileOutputHandler.cxx =================================================================== RCS file: /cvsroot/libwpg/perfectspot/src/odg/FileOutputHandler.cxx,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- FileOutputHandler.cxx 10 Jun 2007 20:51:59 -0000 1.2 +++ FileOutputHandler.cxx 28 Nov 2008 15:09:15 -0000 1.3 @@ -23,6 +23,7 @@ * Corel Corporation or Corel Corporation Limited." */ +#include <string.h> #include "FileOutputHandler.hxx" #include "femtozip.hxx" @@ -36,7 +37,7 @@ { } -void FileOutputHandler::startElement(const char *psName, const std::vector<std::pair<std::string, std::string> > &xPropList) +void FileOutputHandler::startElement(const char *psName, const WPXPropertyList &xPropList) { if (mbIsTagOpened) { @@ -45,9 +46,12 @@ } mContentStream << "<" << psName; - for (std::vector<std::pair<std::string, std::string> >::const_iterator i = xPropList.begin(); i != xPropList.end(); i++) + WPXPropertyList::Iter i(xPropList); + for (i.rewind(); i.next(); ) { - mContentStream << " " << (*i).first.c_str() << "=\"" << (*i).second.c_str() << "\""; + // filter out libwpd elements + if (strncmp(i.key(), "libwpd", 6) != 0) + mContentStream << " " << i.key() << "=\"" << i()->getStr().cstr() << "\""; } mbIsTagOpened = true; msOpenedTagName = psName; @@ -76,14 +80,14 @@ } } -void FileOutputHandler::characters(const std::string &sCharacters) +void FileOutputHandler::characters(const WPXString &sCharacters) { if (mbIsTagOpened) { mContentStream << ">"; mbIsTagOpened = false; } - mContentStream << sCharacters.c_str(); + mContentStream << sCharacters.cstr(); } void FileOutputHandler::endDocument() --- GraphicsHandler.hxx DELETED --- Index: OdgExporter.hxx =================================================================== RCS file: /cvsroot/libwpg/perfectspot/src/odg/OdgExporter.hxx,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- OdgExporter.hxx 3 Jul 2007 21:16:40 -0000 1.4 +++ OdgExporter.hxx 28 Nov 2008 15:09:15 -0000 1.5 @@ -23,54 +23,63 @@ * Corel Corporation or Corel Corporation Limited." */ -#ifndef __ODGEXPORTER_H__ -#define __ODGEXPORTER_H__ +#ifndef __ODGEXPORTER_HXX__ +#define __ODGEXPORTER_HXX__ #include <iostream> #include <sstream> #include <string> +#include <libwpd/libwpd.h> #include <libwpg/libwpg.h> #include "GraphicsElement.hxx" +#include "FileOutputHandler.hxx" class OdgExporter : public libwpg::WPGPaintInterface { public: - OdgExporter(GraphicsHandler *pHandler, const bool isFlatXML = false); + OdgExporter(FileOutputHandler *pHandler, const bool isFlatXML = false); ~OdgExporter(); - void startGraphics(double imageWidth, double imageHeight); + void startGraphics(const ::WPXPropertyList &propList); void endGraphics(); - void startLayer(unsigned int id); - void endLayer(unsigned int id); + void startLayer(const ::WPXPropertyList &propList); + void endLayer(); + void startEmbeddedGraphics(const ::WPXPropertyList& /*propList*/) {} + void endEmbeddedGraphics() {} - void setPen(const libwpg::WPGPen& pen); - void setBrush(const libwpg::WPGBrush& brush); - void setFillRule(FillRule rule); + void setStyle(const libwpg::WPGPen& pen, const libwpg::WPGBrush& brush, const ::WPXPropertyList &propList); - void drawRectangle(const libwpg::WPGRect& rect, double rx, double ry); - void drawEllipse(const libwpg::WPGPoint& center, double rx, double ry); - void drawPolygon(const libwpg::WPGPointArray& vertices); - void drawPath(const libwpg::WPGPath& path); - void drawBitmap(const libwpg::WPGBitmap& bitmap); - void drawImageObject(const libwpg::WPGBinaryData& binaryData); + void drawRectangle(const ::WPXPropertyList &propList); + void drawEllipse(const ::WPXPropertyList &propList); + void drawPolyline(const ::WPXPropertyListVector& vertices); + void drawPolygon(const ::WPXPropertyListVector& vertices); + void drawPath(const ::WPXPropertyListVector& path); + void drawImageObject(const ::WPXPropertyList &propList, const ::WPXBinaryData& binaryData); private: + void writeGraphicsStyle(); + WPXString doubleToString(const double value); + void drawPolySomething(const ::WPXPropertyListVector& vertices, bool isClosed); + + // body elements std::vector <GraphicsElement *> mBodyElements; - std::vector <GraphicsElement *> mAutomaticStylesElements; - std::vector <GraphicsElement *> mStrokeDashElements; - std::vector <GraphicsElement *> mGradientElements; - GraphicsHandler *mpHandler; - libwpg::WPGPen m_pen; - libwpg::WPGBrush m_brush; - FillRule m_fillRule; - int m_gradientIndex; - int m_dashIndex; - int m_styleIndex; - void writeStyle(); - std::ostringstream m_value, m_name; - double m_width, m_height; - const bool m_isFlatXML; + // graphics styles + std::vector<GraphicsElement *> mGraphicsStrokeDashStyles; + std::vector<GraphicsElement *> mGraphicsGradientStyles; + std::vector<GraphicsElement *> mGraphicsAutomaticStyles; + + FileOutputHandler *mpHandler; + + libwpg::WPGPen mxPen; + libwpg::WPGBrush mxBrush; + int miGradientIndex; + int miDashIndex; + int miGraphicsStyleIndex; + double mfWidth; + double mfHeight; + + const bool mbIsFlatXML; }; -#endif // __ODGEXPORTER_H__ +#endif // __ODGEXPORTER_HXX__ |