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 */
34 #ifdef HAVE_CONFIG_H
35 # include <config.h>
36 #endif
37 #include "odf.h"
38 #include "clear-n_.h"
39 #include "inkscape.h"
40 #include "sp-path.h"
41 #include <style.h>
42 #include "display/curve.h"
43 #include "libnr/n-art-bpath.h"
44 #include "extension/system.h"
46 #include "io/sys.h"
48 #include "dom/ziptool.h"
50 namespace Inkscape
51 {
52 namespace Extension
53 {
54 namespace Internal
55 {
58 //########################################################################
59 //# O U T P U T
60 //########################################################################
63 /**
64 * Make sure that we are in the database
65 */
66 bool
67 OdfOutput::check (Inkscape::Extension::Extension *module)
68 {
69 /* We don't need a Key
70 if (NULL == Inkscape::Extension::db.get(SP_MODULE_KEY_OUTPUT_POV))
71 return FALSE;
72 */
74 return TRUE;
75 }
80 /**
81 * This function searches the Repr tree recursively from the given node,
82 * and adds refs to all nodes with the given name, to the result vector
83 */
84 static void
85 findElementsByTagName(std::vector<Inkscape::XML::Node *> &results,
86 Inkscape::XML::Node *node,
87 char const *name)
88 {
89 if ( !name || strcmp(node->name(), name) == 0 )
90 {
91 results.push_back(node);
92 }
94 for (Inkscape::XML::Node *child = node->firstChild() ; child ; child = child->next())
95 findElementsByTagName( results, child, name );
97 }
100 /**
101 * Descends into the SVG tree, mapping things to ODF when appropriate
102 */
103 void
104 OdfOutput::save(Inkscape::Extension::Output *mod, SPDocument *doc, gchar const *uri)
105 {
106 ZipFile zipFile;
107 zipFile.writeFile(uri);
108 }
111 /**
112 * This is the definition of PovRay output. This function just
113 * calls the extension system with the memory allocated XML that
114 * describes the data.
115 */
116 void
117 OdfOutput::init()
118 {
119 Inkscape::Extension::build_from_mem(
120 "<inkscape-extension>\n"
121 "<name>" N_("OpenDocument Drawing Output") "</name>\n"
122 "<id>org.inkscape.output.odf</id>\n"
123 "<output>\n"
124 "<extension>.odg</extension>\n"
125 "<mimetype>text/x-povray-script</mimetype>\n"
126 "<filetypename>" N_("OpenDocument drawing (*.odg)(placeholder)") "</filetypename>\n"
127 "<filetypetooltip>" N_("OpenDocument drawing file") "</filetypetooltip>\n"
128 "</output>\n"
129 "</inkscape-extension>",
130 new OdfOutput());
131 }
133 //########################################################################
134 //# I N P U T
135 //########################################################################
140 } //namespace Internal
141 } //namespace Extension
142 } //namespace Inkscape
145 /*
146 Local Variables:
147 mode:c++
148 c-file-style:"stroustrup"
149 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
150 indent-tabs-mode:nil
151 fill-column:99
152 End:
153 */
154 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :