summaryrefslogtreecommitdiffstats
path: root/src/print.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/print.cpp')
-rw-r--r--src/print.cpp89
1 files changed, 17 insertions, 72 deletions
diff --git a/src/print.cpp b/src/print.cpp
index fe52ea6dd..d2fc72175 100644
--- a/src/print.cpp
+++ b/src/print.cpp
@@ -15,26 +15,20 @@
# include "config.h"
#endif
+#include "display/drawing.h"
+#include "display/drawing-item.h"
#include "inkscape.h"
#include "desktop.h"
#include "sp-item.h"
#include "extension/print.h"
#include "extension/system.h"
#include "print.h"
+#include "sp-root.h"
#include "ui/dialog/print.h"
-
-/* Identity typedef */
-
-unsigned int sp_print_bind(SPPrintContext *ctx, Geom::Affine const &transform, float opacity)
-{
- Geom::Affine const ntransform(transform);
- return sp_print_bind(ctx, &ntransform, opacity);
-}
-
unsigned int
-sp_print_bind(SPPrintContext *ctx, Geom::Affine const *transform, float opacity)
+sp_print_bind(SPPrintContext *ctx, Geom::Affine const &transform, float opacity)
{
return ctx->module->bind(transform, opacity);
}
@@ -52,15 +46,15 @@ sp_print_comment(SPPrintContext *ctx, char const *comment)
}
unsigned int
-sp_print_fill(SPPrintContext *ctx, Geom::PathVector const &pathv, Geom::Affine const *ctm, SPStyle const *style,
- NRRect const *pbox, NRRect const *dbox, NRRect const *bbox)
+sp_print_fill(SPPrintContext *ctx, Geom::PathVector const &pathv, Geom::Affine const &ctm, SPStyle const *style,
+ Geom::OptRect const &pbox, Geom::OptRect const &dbox, Geom::OptRect const &bbox)
{
return ctx->module->fill(pathv, ctm, style, pbox, dbox, bbox);
}
unsigned int
-sp_print_stroke(SPPrintContext *ctx, Geom::PathVector const &pathv, Geom::Affine const *ctm, SPStyle const *style,
- NRRect const *pbox, NRRect const *dbox, NRRect const *bbox)
+sp_print_stroke(SPPrintContext *ctx, Geom::PathVector const &pathv, Geom::Affine const &ctm, SPStyle const *style,
+ Geom::OptRect const &pbox, Geom::OptRect const &dbox, Geom::OptRect const &bbox)
{
return ctx->module->stroke(pathv, ctm, style, pbox, dbox, bbox);
}
@@ -68,7 +62,7 @@ sp_print_stroke(SPPrintContext *ctx, Geom::PathVector const &pathv, Geom::Affine
unsigned int
sp_print_image_R8G8B8A8_N(SPPrintContext *ctx,
guchar *px, unsigned int w, unsigned int h, unsigned int rs,
- Geom::Affine const *transform, SPStyle const *style)
+ Geom::Affine const &transform, SPStyle const *style)
{
return ctx->module->image(px, w, h, rs, transform, style);
}
@@ -79,68 +73,20 @@ unsigned int sp_print_text(SPPrintContext *ctx, char const *text, Geom::Point p,
return ctx->module->text(text, p, style);
}
-#include "display/nr-arena.h"
-#include "display/nr-arena-item.h"
-
/* UI */
void
-sp_print_preview_document(SPDocument *doc)
-{
- Inkscape::Extension::Print *mod;
- unsigned int ret;
-
- doc->ensureUpToDate();
-
- mod = Inkscape::Extension::get_print(SP_MODULE_KEY_PRINT_DEFAULT);
-
- ret = mod->set_preview();
-
- if (ret) {
- SPPrintContext context;
- context.module = mod;
-
- /* fixme: This has to go into module constructor somehow */
- /* Create new arena */
- mod->base = SP_ITEM(doc->getRoot());
- mod->arena = NRArena::create();
- mod->dkey = SPItem::display_key_new(1);
- mod->root = (mod->base)->invoke_show(mod->arena, mod->dkey, SP_ITEM_SHOW_DISPLAY);
- /* Print document */
- ret = mod->begin(doc);
- (mod->base)->invoke_print(&context);
- ret = mod->finish();
- /* Release arena */
- (mod->base)->invoke_hide(mod->dkey);
- mod->base = NULL;
- mod->root = NULL;
- nr_object_unref((NRObject *) mod->arena);
- mod->arena = NULL;
- }
-
- return;
-}
-
-void
sp_print_document(Gtk::Window& parentWindow, SPDocument *doc)
{
doc->ensureUpToDate();
// Build arena
- SPItem *base = SP_ITEM(doc->getRoot());
- NRArena *arena = NRArena::create();
- unsigned int dkey = SPItem::display_key_new(1);
- // TODO investigate why we are grabbing root and then ignoring it.
- NRArenaItem *root = base->invoke_show(arena, dkey, SP_ITEM_SHOW_DISPLAY);
+ SPItem *base = doc->getRoot();
// Run print dialog
Inkscape::UI::Dialog::Print printop(doc,base);
Gtk::PrintOperationResult res = printop.run(Gtk::PRINT_OPERATION_ACTION_PRINT_DIALOG, parentWindow);
(void)res; // TODO handle this
-
- // Release arena
- base->invoke_hide(dkey);
- nr_object_unref((NRObject *) arena);
}
void
@@ -162,21 +108,20 @@ sp_print_document_to_file(SPDocument *doc, gchar const *filename)
/* Start */
context.module = mod;
/* fixme: This has to go into module constructor somehow */
- /* Create new arena */
- mod->base = SP_ITEM(doc->getRoot());
- mod->arena = NRArena::create();
+ /* Create new drawing */
+ mod->base = doc->getRoot();
+ Inkscape::Drawing drawing;
mod->dkey = SPItem::display_key_new(1);
- mod->root = (mod->base)->invoke_show(mod->arena, mod->dkey, SP_ITEM_SHOW_DISPLAY);
+ mod->root = (mod->base)->invoke_show(drawing, mod->dkey, SP_ITEM_SHOW_DISPLAY);
+ drawing.setRoot(mod->root);
/* Print document */
ret = mod->begin(doc);
(mod->base)->invoke_print(&context);
ret = mod->finish();
- /* Release arena */
+ /* Release drawing items */
(mod->base)->invoke_hide(mod->dkey);
mod->base = NULL;
- mod->root = NULL;
- nr_object_unref((NRObject *) mod->arena);
- mod->arena = NULL;
+ mod->root = NULL; // should be deleted by invoke_hide
/* end */
mod->set_param_string("destination", oldoutput);