15
15
# include "config.h"
18
#include "ui/dialog/print.h"
20
#include "display/drawing.h"
21
#include "display/drawing-item.h"
22
18
#include "inkscape.h"
23
19
#include "desktop.h"
25
20
#include "sp-item.h"
26
21
#include "extension/print.h"
27
22
#include "extension/system.h"
25
#include "ui/dialog/print.h"
28
/* Identity typedef */
30
unsigned int sp_print_bind(SPPrintContext *ctx, Geom::Matrix const &transform, float opacity)
32
Geom::Matrix const ntransform(transform);
33
return sp_print_bind(ctx, &ntransform, opacity);
32
sp_print_bind(SPPrintContext *ctx, Geom::Affine const &transform, float opacity)
37
sp_print_bind(SPPrintContext *ctx, Geom::Matrix const *transform, float opacity)
34
39
return ctx->module->bind(transform, opacity);
50
sp_print_fill(SPPrintContext *ctx, Geom::PathVector const &pathv, Geom::Affine const &ctm, SPStyle const *style,
51
Geom::OptRect const &pbox, Geom::OptRect const &dbox, Geom::OptRect const &bbox)
55
sp_print_fill(SPPrintContext *ctx, Geom::PathVector const &pathv, Geom::Matrix const *ctm, SPStyle const *style,
56
NRRect const *pbox, NRRect const *dbox, NRRect const *bbox)
53
58
return ctx->module->fill(pathv, ctm, style, pbox, dbox, bbox);
57
sp_print_stroke(SPPrintContext *ctx, Geom::PathVector const &pathv, Geom::Affine const &ctm, SPStyle const *style,
58
Geom::OptRect const &pbox, Geom::OptRect const &dbox, Geom::OptRect const &bbox)
62
sp_print_stroke(SPPrintContext *ctx, Geom::PathVector const &pathv, Geom::Matrix const *ctm, SPStyle const *style,
63
NRRect const *pbox, NRRect const *dbox, NRRect const *bbox)
60
65
return ctx->module->stroke(pathv, ctm, style, pbox, dbox, bbox);
74
79
return ctx->module->text(text, p, style);
82
#include "display/nr-arena.h"
83
#include "display/nr-arena-item.h"
88
sp_print_preview_document(SPDocument *doc)
90
Inkscape::Extension::Print *mod;
93
sp_document_ensure_up_to_date(doc);
95
mod = Inkscape::Extension::get_print(SP_MODULE_KEY_PRINT_DEFAULT);
97
ret = mod->set_preview();
100
SPPrintContext context;
101
context.module = mod;
103
/* fixme: This has to go into module constructor somehow */
104
/* Create new arena */
105
mod->base = SP_ITEM(sp_document_root(doc));
106
mod->arena = NRArena::create();
107
mod->dkey = sp_item_display_key_new(1);
108
mod->root = sp_item_invoke_show(mod->base, mod->arena, mod->dkey, SP_ITEM_SHOW_DISPLAY);
110
ret = mod->begin(doc);
111
sp_item_invoke_print(mod->base, &context);
114
sp_item_invoke_hide(mod->base, mod->dkey);
117
nr_object_unref((NRObject *) mod->arena);
80
125
sp_print_document(Gtk::Window& parentWindow, SPDocument *doc)
82
doc->ensureUpToDate();
127
sp_document_ensure_up_to_date(doc);
85
SPItem *base = doc->getRoot();
130
SPItem *base = SP_ITEM(sp_document_root(doc));
131
NRArena *arena = NRArena::create();
132
unsigned int dkey = sp_item_display_key_new(1);
133
NRArenaItem *root = sp_item_invoke_show(base, arena, dkey, SP_ITEM_SHOW_DISPLAY);
87
135
// Run print dialog
88
136
Inkscape::UI::Dialog::Print printop(doc,base);
89
137
Gtk::PrintOperationResult res = printop.run(Gtk::PRINT_OPERATION_ACTION_PRINT_DIALOG, parentWindow);
90
138
(void)res; // TODO handle this
141
sp_item_invoke_hide(base, dkey);
142
nr_object_unref((NRObject *) arena);
93
void sp_print_document_to_file(SPDocument *doc, gchar const *filename)
146
sp_print_document_to_file(SPDocument *doc, gchar const *filename)
95
doc->ensureUpToDate();
97
Inkscape::Extension::Print *mod = Inkscape::Extension::get_print(SP_MODULE_KEY_PRINT_PS);
148
Inkscape::Extension::Print *mod;
98
149
SPPrintContext context;
99
gchar const *oldconst = mod->get_param_string("destination");
100
gchar *oldoutput = g_strdup(oldconst);
150
gchar const *oldconst;
154
sp_document_ensure_up_to_date(doc);
156
mod = Inkscape::Extension::get_print(SP_MODULE_KEY_PRINT_PS);
157
oldconst = mod->get_param_string("destination");
158
oldoutput = g_strdup(oldconst);
102
159
mod->set_param_string("destination", (gchar *)filename);
105
162
context.module = mod;
106
163
/* fixme: This has to go into module constructor somehow */
107
/* Create new drawing */
108
mod->base = doc->getRoot();
109
Inkscape::Drawing drawing;
110
mod->dkey = SPItem::display_key_new(1);
111
mod->root = (mod->base)->invoke_show(drawing, mod->dkey, SP_ITEM_SHOW_DISPLAY);
112
drawing.setRoot(mod->root);
164
/* Create new arena */
165
mod->base = SP_ITEM(sp_document_root(doc));
166
mod->arena = NRArena::create();
167
mod->dkey = sp_item_display_key_new(1);
168
mod->root = sp_item_invoke_show(mod->base, mod->arena, mod->dkey, SP_ITEM_SHOW_DISPLAY);
113
169
/* Print document */
115
(mod->base)->invoke_print(&context);
117
/* Release drawing items */
118
(mod->base)->invoke_hide(mod->dkey);
170
ret = mod->begin(doc);
171
sp_item_invoke_print(mod->base, &context);
174
sp_item_invoke_hide(mod->base, mod->dkey);
119
175
mod->base = NULL;
120
mod->root = NULL; // should be deleted by invoke_hide
177
nr_object_unref((NRObject *) mod->arena);
123
181
mod->set_param_string("destination", oldoutput);
124
182
g_free(oldoutput);