Code

moving trunk for module inkscape
[inkscape.git] / src / extension / internal / eps-out.cpp
1 /*
2  * Authors:
3  *   Ted Gould <ted@gould.cx>
4  *
5  * Copyright (C) 2004 Authors
6  *
7  * Released under GNU GPL, read the file 'COPYING' for more information
8  */
10 #ifdef HAVE_CONFIG_H
11 # include <config.h>
12 #endif
13 #include "eps-out.h"
14 #include <print.h>
15 #include "extension/system.h"
16 #include "extension/db.h"
17 #include "extension/output.h"
19 namespace Inkscape {
20 namespace Extension {
21 namespace Internal {
23 bool
24 EpsOutput::check (Inkscape::Extension::Extension * module)
25 {
26     if (NULL == Inkscape::Extension::db.get(SP_MODULE_KEY_PRINT_PS))
27         return FALSE;
29     return TRUE;
30 }
32 /**
33     \brief  This function calls the print system with the filename
34     \param  mod   unused
35     \param  doc   Document to be saved
36     \param  uri   Filename to save to (probably will end in .eps)
38     The most interesting thing that this function does is just attach
39     an '>' on the front of the filename.  This is the syntax used to
40     tell the printing system to save to file.
41 */
42 void
43 EpsOutput::save (Inkscape::Extension::Output *mod, SPDocument *doc, const gchar *uri)
44 {
45     gchar * final_name;
46     Inkscape::Extension::Extension * ext;
48     ext = Inkscape::Extension::db.get(SP_MODULE_KEY_PRINT_PS);
49     if (ext == NULL)
50         return;
52     bool old_pageBoundingBox = ext->get_param_bool("pageBoundingBox");
53     bool new_val             = mod->get_param_bool("pageBoundingBox");
54     ext->set_param_bool("pageBoundingBox", new_val);
56     bool old_textToPath      = ext->get_param_bool("textToPath");
57     new_val                  = mod->get_param_bool("textToPath");
58     ext->set_param_bool("textToPath", new_val);
60     final_name = g_strdup_printf("> %s", uri);
61     sp_print_document_to_file(doc, final_name);
62     g_free(final_name);
64     ext->set_param_bool("pageBoundingBox", old_pageBoundingBox);
65     ext->set_param_bool("textToPath", old_textToPath);
67     return;
68 }
70 /**
71     \brief   A function allocate a copy of this function.
73     This is the definition of postscript out.  This function just
74     calls the extension system with the memory allocated XML that
75     describes the data.
76 */
77 void
78 EpsOutput::init (void)
79 {
80     Inkscape::Extension::build_from_mem(
81         "<inkscape-extension>\n"
82             "<name>Encapsulated Postscript Output</name>\n"
83             "<id>org.inkscape.output.eps</id>\n"
84             "<param name=\"pageBoundingBox\" type=\"boolean\" gui-text=\"Make bounding box around full page\">FALSE</param>\n"
85             "<param name=\"textToPath\" type=\"boolean\" gui-text=\"Convert text to path\">TRUE</param>\n"
86             "<output>\n"
87                 "<extension>.eps</extension>\n"
88                 "<mimetype>image/x-e-postscript</mimetype>\n"
89                 "<filetypename>Encapsulated Postscript (*.eps)</filetypename>\n"
90                 "<filetypetooltip>Encapsulated Postscript File</filetypetooltip>\n"
91             "</output>\n"
92         "</inkscape-extension>", new EpsOutput());
94     return;
95 }
97 } } }  /* namespace Inkscape, Extension, Implementation */
99 /*
100   Local Variables:
101   mode:c++
102   c-file-style:"stroustrup"
103   c-file-offsets:((innamespace . 0)(inline-open . 0))
104   indent-tabs-mode:nil
105   fill-column:99
106   End:
107 */
108 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :