1 /*************************************************************************
2 ** EPSToSVG.h                                                           **
3 **                                                                      **
4 ** This file is part of dvisvgm -- the DVI to SVG converter             **
5 ** Copyright (C) 2005-2015 Martin Gieseking <martin.gieseking@uos.de>   **
6 **                                                                      **
7 ** This program is free software; you can redistribute it and/or        **
8 ** modify it under the terms of the GNU General Public License as       **
9 ** published by the Free Software Foundation; either version 3 of       **
10 ** the License, or (at your option) any later version.                  **
11 **                                                                      **
12 ** This program is distributed in the hope that it will be useful, but  **
13 ** WITHOUT ANY WARRANTY; without even the implied warranty of           **
14 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the         **
15 ** GNU General Public License for more details.                         **
16 **                                                                      **
17 ** You should have received a copy of the GNU General Public License    **
18 ** along with this program; if not, see <http://www.gnu.org/licenses/>. **
19 *************************************************************************/
20 
21 #ifndef DVISVGM_EPSTOSVG_H
22 #define DVISVGM_EPSTOSVG_H
23 
24 #include <string>
25 #include "SpecialActions.h"
26 #include "SVGTree.h"
27 
28 struct SVGOutputBase;
29 
30 class EPSToSVG : protected SpecialActions
31 {
32 	public:
EPSToSVG(const std::string & fname,SVGOutputBase & out)33 		EPSToSVG (const std::string &fname, SVGOutputBase &out) : _fname(fname), _out(out), _x(0), _y(0) {}
34 		void convert ();
35 		void setTransformation (const Matrix &m);
36 		void setPageSize (const std::string &name);
37 
38 	protected:
39 		// implement abstract base class SpecialActions
getX()40 		double getX () const                           {return _x;}
getY()41 		double getY () const                           {return _y;}
setX(double x)42 		void setX (double x)                           {_x = x; _svg.setX(x);}
setY(double y)43 		void setY (double y)                           {_y = y; _svg.setY(y);}
finishLine()44 		void finishLine ()                             {}
setColor(const Color & color)45 		void setColor (const Color &color)             {_svg.setColor(color);}
getColor()46 		Color getColor () const                        {return _svg.getColor();}
setMatrix(const Matrix & m)47 		void setMatrix (const Matrix &m)               {_svg.setMatrix(m);}
getMatrix()48 		const Matrix& getMatrix () const               {return _svg.getMatrix();}
getPageTransform(Matrix & matrix)49 		void getPageTransform (Matrix &matrix) const   {}
setBgColor(const Color & color)50 		void setBgColor (const Color &color)           {}
appendToPage(XMLNode * node)51 		void appendToPage (XMLNode *node)              {_svg.appendToPage(node);}
appendToDefs(XMLNode * node)52 		void appendToDefs (XMLNode *node)              {_svg.appendToDefs(node);}
prependToPage(XMLNode * node)53 		void prependToPage (XMLNode *node)             {_svg.prependToPage(node);}
pushContextElement(XMLElementNode * node)54 		void pushContextElement (XMLElementNode *node) {_svg.pushContextElement(node);}
popContextElement()55 		void popContextElement ()                      {_svg.popContextElement();}
embed(const BoundingBox & bbox)56 		void embed (const BoundingBox &bbox)           {_bbox.embed(bbox);}
57 		void embed (const DPair &p, double r=0)        {if (r==0) _bbox.embed(p); else _bbox.embed(p, r);}
58 		void progress (const char *id);
getCurrentPageNumber()59 		unsigned getCurrentPageNumber() const          {return 0;}
bbox()60 		BoundingBox& bbox ()                           {return _bbox;}
61 		BoundingBox& bbox (const std::string &name, bool reset=false) {return _bbox;}
62 		std::string getSVGFilename (unsigned pageno) const;
63 
64 	private:
65 		std::string _fname;   ///< name of EPS file
66 		SVGTree _svg;
67 		SVGOutputBase &_out;
68 		double _x, _y;
69 		BoundingBox _bbox;
70 };
71 
72 #endif
73