Code

Merge from trunk
[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     bool old_fontEmbedded    = ext->get_param_bool("fontEmbedded");
61     new_val                  = mod->get_param_bool("fontEmbedded");
62     ext->set_param_bool("fontEmbedded", new_val);
64     final_name = g_strdup_printf("> %s", uri);
65     sp_print_document_to_file(doc, final_name);
66     g_free(final_name);
68     ext->set_param_bool("pageBoundingBox", old_pageBoundingBox);
69     ext->set_param_bool("textToPath", old_textToPath);
70     ext->set_param_bool("fontEmbedded", old_fontEmbedded);
72     return;
73 }
75 #include "clear-n_.h"
77 /**
78     \brief   A function allocate a copy of this function.
80     This is the definition of postscript out.  This function just
81     calls the extension system with the memory allocated XML that
82     describes the data.
83 */
84 void
85 EpsOutput::init (void)
86 {
87     Inkscape::Extension::build_from_mem(
88         "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
89             "<name>" N_("Encapsulated Postscript Output") "</name>\n"
90             "<id>org.inkscape.output.eps</id>\n"
91             "<param name=\"pageBoundingBox\" type=\"boolean\" gui-text=\"" N_("Make bounding box around full page") "\">false</param>\n"
92             "<param name=\"textToPath\" type=\"boolean\" gui-text=\"" N_("Convert texts to paths") "\">true</param>\n"
93             "<param name=\"fontEmbedded\" type=\"boolean\" gui-text=\"" N_("Embed fonts (Type 1 only)") "\">false</param>\n"
94             "<output>\n"
95                 "<extension>.eps</extension>\n"
96                 "<mimetype>image/x-eps</mimetype>\n"
97                 "<filetypename>" N_("Encapsulated Postscript (*.eps)") "</filetypename>\n"
98                 "<filetypetooltip>" N_("Encapsulated Postscript File") "</filetypetooltip>\n"
99             "</output>\n"
100         "</inkscape-extension>", new EpsOutput());
102     return;
105 } } }  /* namespace Inkscape, Extension, Implementation */
107 /*
108   Local Variables:
109   mode:c++
110   c-file-style:"stroustrup"
111   c-file-offsets:((innamespace . 0)(inline-open . 0))
112   indent-tabs-mode:nil
113   fill-column:99
114   End:
115 */
116 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :