~centralelyon2010/inkscape/imagelinks2

« back to all changes in this revision

Viewing changes to src/extension/internal/ps-out.cpp

  • Committer: Ted Gould
  • Date: 2008-11-21 05:24:08 UTC
  • Revision ID: ted@canonical.com-20081121052408-tilucis2pjrrpzxx
MergeĀ fromĀ fe-moved

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * A quick hack to use the print output to write out a file.  This
3
 
 * then makes 'save as...' Postscript.
4
 
 *
5
 
 * Authors:
6
 
 *   Ted Gould <ted@gould.cx>
7
 
 *
8
 
 * Copyright (C) 2004 Authors
9
 
 *
10
 
 * Released under GNU GPL, read the file 'COPYING' for more information
11
 
 */
12
 
 
13
 
#ifdef HAVE_CONFIG_H
14
 
# include <config.h>
15
 
#endif
16
 
#include "ps-out.h"
17
 
#include <print.h>
18
 
#include "extension/system.h"
19
 
#include "extension/db.h"
20
 
#include "extension/output.h"
21
 
 
22
 
namespace Inkscape {
23
 
namespace Extension {
24
 
namespace Internal {
25
 
 
26
 
bool
27
 
PsOutput::check( Inkscape::Extension::Extension * /*module*/ )
28
 
{
29
 
    if (NULL == Inkscape::Extension::db.get(SP_MODULE_KEY_PRINT_PS))
30
 
        return FALSE;
31
 
 
32
 
    return TRUE;
33
 
}
34
 
 
35
 
/**
36
 
    \brief  This function calls the print system with the filename
37
 
        \param  mod   unused
38
 
        \param  doc   Document to be saved
39
 
    \param  uri   Filename to save to (probably will end in .ps)
40
 
 
41
 
        The most interesting thing that this function does is just attach
42
 
        an '>' on the front of the filename.  This is the syntax used to
43
 
        tell the printing system to save to file.
44
 
*/
45
 
void
46
 
PsOutput::save (Inkscape::Extension::Output *mod, SPDocument *doc, const gchar *uri)
47
 
{
48
 
    Inkscape::Extension::Extension * ext;
49
 
 
50
 
    ext = Inkscape::Extension::db.get(SP_MODULE_KEY_PRINT_PS);
51
 
    if (ext == NULL)
52
 
        return;
53
 
 
54
 
    bool old_textToPath  = ext->get_param_bool("textToPath");
55
 
    bool new_val         = mod->get_param_bool("textToPath");
56
 
    ext->set_param_bool("textToPath", new_val);
57
 
 
58
 
        gchar * final_name;
59
 
        final_name = g_strdup_printf("> %s", uri);
60
 
        sp_print_document_to_file(doc, final_name);
61
 
        g_free(final_name);
62
 
 
63
 
    ext->set_param_bool("textToPath", old_textToPath);
64
 
 
65
 
        return;
66
 
}
67
 
 
68
 
#include "clear-n_.h"
69
 
 
70
 
/**
71
 
        \brief   A function allocate a copy of this function.
72
 
 
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
 
PsOutput::init (void)
79
 
{
80
 
        Inkscape::Extension::build_from_mem(
81
 
                "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
82
 
                        "<name>" N_("Postscript Output") "</name>\n"
83
 
                        "<id>org.inkscape.output.ps</id>\n"
84
 
                        "<param name=\"textToPath\" gui-text=\"" N_("Convert texts to paths") "\" type=\"boolean\">true</param>\n"
85
 
                        "<param name=\"fontEmbedded\" gui-text=\"" N_("Embed fonts (Type 1 only)") "\" type=\"boolean\">false</param>\n"
86
 
                        "<output>\n"
87
 
                                "<extension>.ps</extension>\n"
88
 
                                "<mimetype>image/x-postscript</mimetype>\n"
89
 
                                "<filetypename>" N_("PostScript (old exporter via print) (*.ps)") "</filetypename>\n"
90
 
                                "<filetypetooltip>" N_("PostScript File") "</filetypetooltip>\n"
91
 
                        "</output>\n"
92
 
                "</inkscape-extension>", new PsOutput());
93
 
 
94
 
        return;
95
 
}
96
 
 
97
 
} } }  /* namespace Inkscape, Extension, Implementation */