2
* OpenDocument <drawing> input and output
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.
10
* http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html
15
* Copyright (C) 2006 Bob Jamison
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.
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.
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
32
#ifndef EXTENSION_INTERNAL_ODG_OUT_H
33
#define EXTENSION_INTERNAL_ODG_OUT_H
36
#include <dom/io/stringstream.h>
40
#include "extension/implementation/implementation.h"
48
#include <dom/util/ziptool.h>
49
#include <dom/io/domstream.h>
59
typedef org::w3c::dom::URI URI;
60
typedef org::w3c::dom::io::Writer Writer;
72
StyleInfo(const StyleInfo &other)
77
StyleInfo &operator=(const StyleInfo &other)
83
void assign(const StyleInfo &other)
86
stroke = other.stroke;
87
strokeColor = other.strokeColor;
88
strokeWidth = other.strokeWidth;
89
strokeOpacity = other.strokeOpacity;
91
fillColor = other.fillColor;
92
fillOpacity = other.fillOpacity;
100
strokeWidth = "none";
101
strokeOpacity = "none";
104
fillOpacity = "none";
110
//used for eliminating duplicates in the styleTable
111
bool equals(const StyleInfo &other)
114
stroke != other.stroke ||
115
strokeColor != other.strokeColor ||
116
strokeWidth != other.strokeWidth ||
117
strokeOpacity != other.strokeOpacity ||
118
fill != other.fill ||
119
fillColor != other.fillColor ||
120
fillOpacity != other.fillOpacity
127
Glib::ustring stroke;
128
Glib::ustring strokeColor;
129
Glib::ustring strokeWidth;
130
Glib::ustring strokeOpacity;
132
Glib::ustring fillColor;
133
Glib::ustring fillOpacity;
145
GradientStop(unsigned long rgbArg, double opacityArg)
146
{ rgb = rgbArg; opacity = opacityArg; }
147
virtual ~GradientStop()
149
GradientStop(const GradientStop &other)
151
virtual GradientStop operator=(const GradientStop &other)
152
{ assign(other); return *this; }
153
void assign(const GradientStop &other)
156
opacity = other.opacity;
173
GradientInfo(const GradientInfo &other)
178
GradientInfo &operator=(const GradientInfo &other)
184
void assign(const GradientInfo &other)
216
virtual ~GradientInfo()
219
//used for eliminating duplicates in the styleTable
220
bool equals(const GradientInfo &other)
223
name != other.name ||
224
style != other.style ||
236
if (stops.size() != other.stops.size())
238
for (unsigned int i=0 ; i<stops.size() ; i++)
240
GradientStop g1 = stops[i];
241
GradientStop g2 = other.stops[i];
242
if (g1.rgb != g2.rgb)
244
if (g1.opacity != g2.opacity)
261
std::vector<GradientStop> stops;
267
class OdfOutput : public Inkscape::Extension::Implementation::Implementation
272
bool check (Inkscape::Extension::Extension * module);
274
void save (Inkscape::Extension::Output *mod,
276
gchar const *filename);
278
static void init (void);
286
//cc or dc metadata name/value pairs
287
std::map<Glib::ustring, Glib::ustring> metadata;
290
Uses a two-stage lookup to avoid style duplication.
292
StyleInfo si = styleTable[styleLookupTable[id]];
293
but check for errors, of course
295
//element id -> style entry name
296
std::map<Glib::ustring, Glib::ustring> styleLookupTable;
297
//style entry name -> style info
298
std::vector<StyleInfo> styleTable;
300
//element id -> gradient entry name
301
std::map<Glib::ustring, Glib::ustring> gradientLookupTable;
302
//gradient entry name -> gradient info
303
std::vector<GradientInfo> gradientTable;
305
//for renaming image file names
306
std::map<Glib::ustring, Glib::ustring> imageTable;
308
void preprocess(ZipFile &zf, Inkscape::XML::Node *node);
310
bool writeManifest(ZipFile &zf);
312
bool writeMeta(ZipFile &zf);
314
bool writeStyle(ZipFile &zf);
316
bool processStyle(Writer &outs, SPItem *item, const Glib::ustring &id);
318
bool processGradient(Writer &outs, SPItem *item,
319
const Glib::ustring &id, Geom::Matrix &tf);
321
bool writeStyleHeader(Writer &outs);
323
bool writeStyleFooter(Writer &outs);
325
bool writeContentHeader(Writer &outs);
327
bool writeContentFooter(Writer &outs);
329
bool writeTree(Writer &couts, Writer &souts, Inkscape::XML::Node *node);
331
bool writeContent(ZipFile &zf, Inkscape::XML::Node *node);
338
} //namespace Internal
339
} //namespace Extension
340
} //namespace Inkscape
344
#endif /* EXTENSION_INTERNAL_ODG_OUT_H */