From 179fa413b047bede6e32109e2ce82437c5fb8d34 Mon Sep 17 00:00:00 2001 From: MenTaLguY Date: Mon, 16 Jan 2006 02:36:01 +0000 Subject: moving trunk for module inkscape (bzr r1) --- src/extension/internal/ps-out.cpp | 94 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 src/extension/internal/ps-out.cpp (limited to 'src/extension/internal/ps-out.cpp') diff --git a/src/extension/internal/ps-out.cpp b/src/extension/internal/ps-out.cpp new file mode 100644 index 000000000..a41b90007 --- /dev/null +++ b/src/extension/internal/ps-out.cpp @@ -0,0 +1,94 @@ +/* + * A quick hack to use the print output to write out a file. This + * then makes 'save as...' Postscript. + * + * Authors: + * Ted Gould + * + * Copyright (C) 2004 Authors + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#ifdef HAVE_CONFIG_H +# include +#endif +#include "ps-out.h" +#include +#include "extension/system.h" +#include "extension/db.h" +#include "extension/output.h" + +namespace Inkscape { +namespace Extension { +namespace Internal { + +bool +PsOutput::check (Inkscape::Extension::Extension * module) +{ + if (NULL == Inkscape::Extension::db.get(SP_MODULE_KEY_PRINT_PS)) + return FALSE; + + return TRUE; +} + +/** + \brief This function calls the print system with the filename + \param mod unused + \param doc Document to be saved + \param uri Filename to save to (probably will end in .ps) + + The most interesting thing that this function does is just attach + an '>' on the front of the filename. This is the syntax used to + tell the printing system to save to file. +*/ +void +PsOutput::save (Inkscape::Extension::Output *mod, SPDocument *doc, const gchar *uri) +{ + Inkscape::Extension::Extension * ext; + + ext = Inkscape::Extension::db.get(SP_MODULE_KEY_PRINT_PS); + if (ext == NULL) + return; + + bool old_textToPath = ext->get_param_bool("textToPath"); + bool new_val = mod->get_param_bool("textToPath"); + ext->set_param_bool("textToPath", new_val); + + gchar * final_name; + final_name = g_strdup_printf("> %s", uri); + sp_print_document_to_file(doc, final_name); + g_free(final_name); + + ext->set_param_bool("textToPath", old_textToPath); + + return; +} + +/** + \brief A function allocate a copy of this function. + + This is the definition of postscript out. This function just + calls the extension system with the memory allocated XML that + describes the data. +*/ +void +PsOutput::init (void) +{ + Inkscape::Extension::build_from_mem( + "\n" + "Postscript Output\n" + "org.inkscape.output.ps\n" + "true\n" + "\n" + ".ps\n" + "image/x-postscript\n" + "Postscript (*.ps)\n" + "Postscript File\n" + "\n" + "", new PsOutput()); + + return; +} + +} } } /* namespace Inkscape, Extension, Implementation */ -- cgit v1.2.3