Code

e1cf133db7fc5b051b287061eabbbafb997d437a
[inkscape.git] / src / extension / internal / odf.h
1 /**
2  * OpenDocument <drawing> input and output
3  *
4  * This is an an entry in the extensions mechanism to begin to enable
5  * the inputting and outputting of OpenDocument Format (ODF) files from
6  * within Inkscape.  Although the initial implementations will be very lossy
7  * do to the differences in the models of SVG and ODF, they will hopefully
8  * improve greatly with time.
9  *
10  * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html
11  *
12  * Authors:
13  *   Bob Jamison
14  *
15  * Copyright (C) 2006 Bob Jamison
16  *
17  *  This library is free software; you can redistribute it and/or
18  *  modify it under the terms of the GNU Lesser General Public
19  *  License as published by the Free Software Foundation; either
20  *  version 2.1 of the License, or (at your option) any later version.
21  *
22  *  This library is distributed in the hope that it will be useful,
23  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
24  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
25  *  Lesser General Public License for more details.
26  *
27  *  You should have received a copy of the GNU Lesser General Public
28  *  License along with this library; if not, write to the Free Software
29  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
30  */
32 #ifndef EXTENSION_INTERNAL_ODG_OUT_H
33 #define EXTENSION_INTERNAL_ODG_OUT_H
35 #include <dom/dom.h>
36 #include <dom/io/stringstream.h>
38 #include <glib.h>
39 #include "extension/implementation/implementation.h"
42 #include <xml/repr.h>
44 #include <string>
45 #include <map>
47 #include <dom/util/ziptool.h>
48 #include <dom/io/domstream.h>
50 typedef org::w3c::dom::io::Writer Writer;
52 namespace Inkscape
53 {
54 namespace Extension
55 {
56 namespace Internal
57 {
61 class StyleInfo
62 {
63 public:
65     StyleInfo()
66         {
67         init();
68         }
70     StyleInfo(const std::string &nameArg, const std::string &styleArg)
71         {
72         init();
73         name   = nameArg;
74         style  = styleArg;
75         }
77     StyleInfo(const StyleInfo &other)
78         {
79         assign(other);
80         }
82     StyleInfo &operator=(const StyleInfo &other)
83         {
84         assign(other);
85         return *this;
86         }
88     void assign(const StyleInfo &other)
89         {
90         name        = other.name;
91         style       = other.style;
92         cssStyle    = other.cssStyle;
93         stroke      = other.stroke;
94         strokeColor = other.strokeColor;
95         strokeWidth = other.strokeWidth;
96         fill        = other.fill;
97         fillColor   = other.fillColor;
98         }
100     void init()
101         {
102         name        = "none";
103         style       = "none";
104         cssStyle    = "none";
105         stroke      = "none";
106         strokeColor = "none";
107         strokeWidth = "none";
108         fill        = "none";
109         fillColor   = "none";
110         }
112     virtual ~StyleInfo()
113         {}
115     std::string getName()
116         {
117         return name;
118         }
120     std::string getCssStyle()
121         {
122         return cssStyle;
123         }
125     std::string getStroke()
126         {
127         return stroke;
128         }
130     std::string getStrokeColor()
131         {
132         return strokeColor;
133         }
135     std::string getStrokeWidth()
136         {
137         return strokeWidth;
138         }
141     std::string getFill()
142         {
143         return fill;
144         }
146     std::string getFillColor()
147         {
148         return fillColor;
149         }
151     std::string name;
152     std::string style;
153     std::string cssStyle;
154     std::string stroke;
155     std::string strokeColor;
156     std::string strokeWidth;
157     std::string fill;
158     std::string fillColor;
160 };
164 class OdfOutput : public Inkscape::Extension::Implementation::Implementation
167 public:
169     bool check (Inkscape::Extension::Extension * module);
171     void save  (Inkscape::Extension::Output *mod,
172                 SPDocument *doc,
173                 const gchar *uri);
175     static void   init  (void);
177 private:
179     std::map<std::string, StyleInfo> styleTable;
181     //for renaming image file names
182     std::map<std::string, std::string> imageTable;
184     void preprocess(ZipFile &zf, Inkscape::XML::Node *node);
186     bool writeManifest(ZipFile &zf);
188     bool writeMeta(ZipFile &zf);
190     bool writeStyle(Writer &outs);
192     bool writeTree(Writer &outs, Inkscape::XML::Node *node);
194     bool writeContent(ZipFile &zf, Inkscape::XML::Node *node);
196 };
201 }  //namespace Internal
202 }  //namespace Extension
203 }  //namespace Inkscape
207 #endif /* EXTENSION_INTERNAL_ODG_OUT_H */