00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 00002 /* 00003 * This file is part of the libfreehand project. 00004 * 00005 * This Source Code Form is subject to the terms of the Mozilla Public 00006 * License, v. 2.0. If a copy of the MPL was not distributed with this 00007 * file, You can obtain one at http://mozilla.org/MPL/2.0/. 00008 */ 00009 00010 #ifndef __FHSVGGENERATOR_H__ 00011 #define __FHSVGGENERATOR_H__ 00012 00013 #include <stdio.h> 00014 #include <iostream> 00015 #include <sstream> 00016 #include <libwpd/libwpd.h> 00017 #include <libwpg/libwpg.h> 00018 #include <libfreehand/libfreehand.h> 00019 00020 namespace libfreehand 00021 { 00022 00023 class FHSVGGenerator : public libwpg::WPGPaintInterface 00024 { 00025 public: 00026 FHSVGGenerator(FHStringVector &vec); 00027 ~FHSVGGenerator(); 00028 00029 void startGraphics(const ::WPXPropertyList &propList); 00030 void endGraphics(); 00031 void startLayer(const ::WPXPropertyList &propList); 00032 void endLayer(); 00033 void startEmbeddedGraphics(const ::WPXPropertyList & /*propList*/) {} 00034 void endEmbeddedGraphics() {} 00035 00036 void setStyle(const ::WPXPropertyList &propList, const ::WPXPropertyListVector &gradient); 00037 00038 void drawRectangle(const ::WPXPropertyList &propList); 00039 void drawEllipse(const ::WPXPropertyList &propList); 00040 void drawPolyline(const ::WPXPropertyListVector &vertices); 00041 void drawPolygon(const ::WPXPropertyListVector &vertices); 00042 void drawPath(const ::WPXPropertyListVector &path); 00043 void drawGraphicObject(const ::WPXPropertyList &propList, const ::WPXBinaryData &binaryData); 00044 void startTextObject(const ::WPXPropertyList &propList, const ::WPXPropertyListVector &path); 00045 void endTextObject(); 00046 void startTextLine(const ::WPXPropertyList & /* propList */) {} 00047 void endTextLine() {} 00048 void startTextSpan(const ::WPXPropertyList &propList); 00049 void endTextSpan(); 00050 void insertText(const ::WPXString &str); 00051 00052 private: 00053 ::WPXPropertyListVector m_gradient; 00054 ::WPXPropertyList m_style; 00055 int m_gradientIndex; 00056 int m_patternIndex; 00057 int m_shadowIndex; 00058 void writeStyle(bool isClosed=true); 00059 void drawPolySomething(const ::WPXPropertyListVector &vertices, bool isClosed); 00060 00061 std::ostringstream m_outputSink; 00062 FHStringVector &m_vec; 00063 }; 00064 00065 } // namespace libfreehand 00066 00067 #endif // __FHSVGGENERATOR_H__ 00068 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */