083f571d62930918c7732e739b9b62f01f4dc6c9
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(const std::string &nameArg, const std::string &styleArg)
66 {
67 name = nameArg;
68 style = styleArg;
69 fill = "none";
70 stroke = "none";
71 }
73 virtual ~StyleInfo()
74 {}
76 std::string getName()
77 {
78 return name;
79 }
81 std::string getCssStyle()
82 {
83 return cssStyle;
84 }
86 std::string getStroke()
87 {
88 return stroke;
89 }
91 std::string getStrokeColor()
92 {
93 return strokeColor;
94 }
96 std::string getStrokeWidth()
97 {
98 return strokeWidth;
99 }
102 std::string getFill()
103 {
104 return fill;
105 }
107 std::string getFillColor()
108 {
109 return fillColor;
110 }
112 std::string name;
113 std::string style;
114 std::string cssStyle;
115 std::string stroke;
116 std::string strokeColor;
117 std::string strokeWidth;
118 std::string fill;
119 std::string fillColor;
121 };
125 class OdfOutput : public Inkscape::Extension::Implementation::Implementation
126 {
128 public:
130 bool check (Inkscape::Extension::Extension * module);
132 void save (Inkscape::Extension::Output *mod,
133 SPDocument *doc,
134 const gchar *uri);
136 static void init (void);
138 private:
140 std::map<std::string, StyleInfo> styleTable;
142 //for renaming image file names
143 std::map<std::string, std::string> imageTable;
145 void preprocess(ZipFile &zf, SPDocument *doc);
146 void preprocess(ZipFile &zf, Inkscape::XML::Node *node);
148 bool writeManifest(ZipFile &zf);
150 bool writeStyle(Writer &outs);
152 bool writeTree(Writer &outs, Inkscape::XML::Node *node);
154 bool writeContent(ZipFile &zf, Inkscape::XML::Node *node);
156 };
161 } //namespace Internal
162 } //namespace Extension
163 } //namespace Inkscape
167 #endif /* EXTENSION_INTERNAL_ODG_OUT_H */