diff options
| author | Jon A. Cruz <jon@joncruz.org> | 2010-12-12 09:05:21 +0000 |
|---|---|---|
| committer | Jon A. Cruz <jon@joncruz.org> | 2010-12-12 09:05:21 +0000 |
| commit | 7ddc9f155a2a0822e2e56d828bbdccc65c141081 (patch) | |
| tree | 3f890c0c112433fd850d59558208addf1baa85da /src/helper | |
| parent | Pot and Dutch translation update (diff) | |
| parent | Merge and cleanup of GSoC C++-ification project. (diff) | |
| download | inkscape-7ddc9f155a2a0822e2e56d828bbdccc65c141081.tar.gz inkscape-7ddc9f155a2a0822e2e56d828bbdccc65c141081.zip | |
GSoC C++-ificiation merge and cleanup.
(bzr r9946)
Diffstat (limited to 'src/helper')
| -rw-r--r-- | src/helper/pixbuf-ops.cpp | 24 | ||||
| -rw-r--r-- | src/helper/png-write.cpp | 23 | ||||
| -rw-r--r-- | src/helper/stock-items.cpp | 42 |
3 files changed, 41 insertions, 48 deletions
diff --git a/src/helper/pixbuf-ops.cpp b/src/helper/pixbuf-ops.cpp index f50062d2d..69becad5d 100644 --- a/src/helper/pixbuf-ops.cpp +++ b/src/helper/pixbuf-ops.cpp @@ -1,10 +1,10 @@ -#define __SP_PIXBUF_OPS_C__ - /* * Helpers for SPItem -> gdk_pixbuf related stuff * * Authors: * John Cliff <simarilius@yahoo.com> + * Jon A. Cruz <jon@joncruz.org> + * Abhishek Sharma * * Copyright (C) 2008 John Cliff * @@ -38,11 +38,11 @@ #include "pixbuf-ops.h" +// TODO look for copy-n-past duplication of this function: /** * Hide all items that are not listed in list, recursively, skipping groups and defs. */ -static void -hide_other_items_recursively(SPObject *o, GSList *list, unsigned dkey) +static void hide_other_items_recursively(SPObject *o, GSList *list, unsigned dkey) { if ( SP_IS_ITEM(o) && !SP_IS_DEFS(o) @@ -51,12 +51,12 @@ hide_other_items_recursively(SPObject *o, GSList *list, unsigned dkey) && !SP_IS_USE(o) && !g_slist_find(list, o) ) { - sp_item_invoke_hide(SP_ITEM(o), dkey); + SP_ITEM(o)->invoke_hide(dkey); } // recurse if (!g_slist_find(list, o)) { - for (SPObject *child = sp_object_first_child(o) ; child != NULL; child = SP_OBJECT_NEXT(child) ) { + for ( SPObject *child = o->firstChild() ; child; child = child->getNext() ) { hide_other_items_recursively(child, list, dkey); } } @@ -104,16 +104,16 @@ sp_generate_internal_bitmap(SPDocument *doc, gchar const */*filename*/, /* Create new arena for offscreen rendering*/ NRArena *arena = NRArena::create(); nr_arena_set_renderoffscreen(arena); - unsigned dkey = sp_item_display_key_new(1); + unsigned dkey = SPItem::display_key_new(1); - sp_document_ensure_up_to_date (doc); + doc->ensureUpToDate(); Geom::Rect screen=Geom::Rect(Geom::Point(x0,y0), Geom::Point(x1, y1)); double padding = 1.0; Geom::Point origin(screen.min()[Geom::X], - sp_document_height(doc) - screen[Geom::Y].extent() - screen.min()[Geom::Y]); + doc->getHeight() - screen[Geom::Y].extent() - screen.min()[Geom::Y]); origin[Geom::X] = origin[Geom::X] + (screen[Geom::X].extent() * ((1 - padding) / 2)); origin[Geom::Y] = origin[Geom::Y] + (screen[Geom::Y].extent() * ((1 - padding) / 2)); @@ -122,7 +122,7 @@ sp_generate_internal_bitmap(SPDocument *doc, gchar const */*filename*/, Geom::Matrix affine = scale * Geom::Translate(-origin * scale); /* Create ArenaItems and set transform */ - NRArenaItem *root = sp_item_invoke_show(SP_ITEM(sp_document_root(doc)), arena, dkey, SP_ITEM_SHOW_DISPLAY); + NRArenaItem *root = SP_ITEM(doc->getRoot())->invoke_show( arena, dkey, SP_ITEM_SHOW_DISPLAY); nr_arena_item_set_transform(NR_ARENA_ITEM(root), affine); NRGC gc(NULL); @@ -131,7 +131,7 @@ sp_generate_internal_bitmap(SPDocument *doc, gchar const */*filename*/, // We show all and then hide all items we don't want, instead of showing only requested items, // because that would not work if the shown item references something in defs if (items_only) { - hide_other_items_recursively(sp_document_root(doc), items_only, dkey); + hide_other_items_recursively(doc->getRoot(), items_only, dkey); } NRRectL final_bbox; @@ -186,7 +186,7 @@ sp_generate_internal_bitmap(SPDocument *doc, gchar const */*filename*/, { g_warning("sp_generate_internal_bitmap: not enough memory to create pixel buffer. Need %lld.", size); } - sp_item_invoke_hide (SP_ITEM(sp_document_root(doc)), dkey); + SP_ITEM(doc->getRoot())->invoke_hide(dkey); nr_object_unref((NRObject *) arena); // gdk_pixbuf_save (pixbuf, "C:\\temp\\internal.jpg", "jpeg", NULL, "quality","100", NULL); diff --git a/src/helper/png-write.cpp b/src/helper/png-write.cpp index 754372f23..d3fe2771f 100644 --- a/src/helper/png-write.cpp +++ b/src/helper/png-write.cpp @@ -1,11 +1,11 @@ -#define __SP_PNG_WRITE_C__ - /* * PNG file format utilities * * Authors: * Lauris Kaplinski <lauris@kaplinski.com> * Whoever wrote this example in libpng documentation + * Jon A. Cruz <jon@joncruz.org> + * Abhishek Sharma * * Copyright (C) 1999-2002 authors * @@ -362,8 +362,7 @@ sp_export_get_rows(guchar const **rows, int row, int num_rows, void *data) /** * Hide all items that are not listed in list, recursively, skipping groups and defs. */ -static void -hide_other_items_recursively(SPObject *o, GSList *list, unsigned dkey) +static void hide_other_items_recursively(SPObject *o, GSList *list, unsigned dkey) { if ( SP_IS_ITEM(o) && !SP_IS_DEFS(o) @@ -371,12 +370,12 @@ hide_other_items_recursively(SPObject *o, GSList *list, unsigned dkey) && !SP_IS_GROUP(o) && !g_slist_find(list, o) ) { - sp_item_invoke_hide(SP_ITEM(o), dkey); + SP_ITEM(o)->invoke_hide(dkey); } // recurse if (!g_slist_find(list, o)) { - for (SPObject *child = sp_object_first_child(o) ; child != NULL; child = SP_OBJECT_NEXT(child) ) { + for ( SPObject *child = o->firstChild() ; child; child = child->getNext() ) { hide_other_items_recursively(child, list, dkey); } } @@ -422,10 +421,10 @@ sp_export_png_file(SPDocument *doc, gchar const *filename, return true; } - sp_document_ensure_up_to_date(doc); + doc->ensureUpToDate(); /* Calculate translation by transforming to document coordinates (flipping Y)*/ - Geom::Point translation = Geom::Point(-area[Geom::X][0], area[Geom::Y][1] - sp_document_height(doc)); + Geom::Point translation = Geom::Point(-area[Geom::X][0], area[Geom::Y][1] - doc->getHeight()); /* This calculation is only valid when assumed that (x0,y0)= area.corner(0) and (x1,y1) = area.corner(2) * 1) a[0] * x0 + a[2] * y1 + a[4] = 0.0 @@ -461,16 +460,16 @@ sp_export_png_file(SPDocument *doc, gchar const *filename, NRArena *const arena = NRArena::create(); // export with maximum blur rendering quality nr_arena_set_renderoffscreen(arena); - unsigned const dkey = sp_item_display_key_new(1); + unsigned const dkey = SPItem::display_key_new(1); /* Create ArenaItems and set transform */ - ebp.root = sp_item_invoke_show(SP_ITEM(sp_document_root(doc)), arena, dkey, SP_ITEM_SHOW_DISPLAY); + ebp.root = SP_ITEM(doc->getRoot())->invoke_show(arena, dkey, SP_ITEM_SHOW_DISPLAY); nr_arena_item_set_transform(NR_ARENA_ITEM(ebp.root), affine); // We show all and then hide all items we don't want, instead of showing only requested items, // because that would not work if the shown item references something in defs if (items_only) { - hide_other_items_recursively(sp_document_root(doc), items_only, dkey); + hide_other_items_recursively(doc->getRoot(), items_only, dkey); } ebp.status = status; @@ -490,7 +489,7 @@ sp_export_png_file(SPDocument *doc, gchar const *filename, } // Hide items, this releases arenaitem - sp_item_invoke_hide(SP_ITEM(sp_document_root(doc)), dkey); + SP_ITEM(doc->getRoot())->invoke_hide(dkey); /* Free arena */ nr_object_unref((NRObject *) arena); diff --git a/src/helper/stock-items.cpp b/src/helper/stock-items.cpp index 1c184da72..4ec61c54a 100644 --- a/src/helper/stock-items.cpp +++ b/src/helper/stock-items.cpp @@ -1,5 +1,3 @@ -#define __INK_STOCK_ITEMS__ - /* * Stock-items * @@ -7,6 +5,8 @@ * * Authors: * John Cliff <simarilius@yahoo.com> + * Jon A. Cruz <jon@joncruz.org> + * Abhishek Sharma * * Copyright 2004 John Cliff * @@ -56,11 +56,11 @@ static SPObject * sp_marker_load_from_svg(gchar const *name, SPDocument *current if (!edoc && !doc) { gchar *markers = g_build_filename(INKSCAPE_MARKERSDIR, "/markers.svg", NULL); if (Inkscape::IO::file_test(markers, G_FILE_TEST_IS_REGULAR)) { - doc = sp_document_new(markers, FALSE); + doc = SPDocument::createNewDoc(markers, FALSE); } g_free(markers); if (doc) { - sp_document_ensure_up_to_date(doc); + doc->ensureUpToDate(); } else { edoc = TRUE; } @@ -70,7 +70,7 @@ static SPObject * sp_marker_load_from_svg(gchar const *name, SPDocument *current SPObject *object = doc->getObjectById(name); if (object && SP_IS_MARKER(object)) { SPDefs *defs= (SPDefs *) SP_DOCUMENT_DEFS(current_doc); - Inkscape::XML::Document *xml_doc = sp_document_repr_doc(current_doc); + Inkscape::XML::Document *xml_doc = current_doc->getReprDoc(); Inkscape::XML::Node *mark_repr = SP_OBJECT_REPR(object)->duplicate(xml_doc); SP_OBJECT_REPR(defs)->addChild(mark_repr, NULL); SPObject *cloned_item = current_doc->getObjectByRepr(mark_repr); @@ -94,16 +94,16 @@ sp_pattern_load_from_svg(gchar const *name, SPDocument *current_doc) if (!edoc && !doc) { gchar *patterns = g_build_filename(INKSCAPE_PATTERNSDIR, "/patterns.svg", NULL); if (Inkscape::IO::file_test(patterns, G_FILE_TEST_IS_REGULAR)) { - doc = sp_document_new(patterns, FALSE); + doc = SPDocument::createNewDoc(patterns, FALSE); } if (!doc) { gchar *patterns = g_build_filename(CREATE_PATTERNSDIR, "/patterns.svg", NULL); if (Inkscape::IO::file_test(patterns, G_FILE_TEST_IS_REGULAR)) { - doc = sp_document_new(patterns, FALSE); + doc = SPDocument::createNewDoc(patterns, FALSE); } g_free(patterns); if (doc) { - sp_document_ensure_up_to_date(doc); + doc->ensureUpToDate(); } else { edoc = TRUE; } @@ -114,7 +114,7 @@ sp_pattern_load_from_svg(gchar const *name, SPDocument *current_doc) SPObject *object = doc->getObjectById(name); if (object && SP_IS_PATTERN(object)) { SPDefs *defs= (SPDefs *) SP_DOCUMENT_DEFS(current_doc); - Inkscape::XML::Document *xml_doc = sp_document_repr_doc(current_doc); + Inkscape::XML::Document *xml_doc = current_doc->getReprDoc(); Inkscape::XML::Node *pat_repr = SP_OBJECT_REPR(object)->duplicate(xml_doc); SP_OBJECT_REPR(defs)->addChild(pat_repr, NULL); Inkscape::GC::release(pat_repr); @@ -137,16 +137,16 @@ sp_gradient_load_from_svg(gchar const *name, SPDocument *current_doc) if (!edoc && !doc) { gchar *gradients = g_build_filename(INKSCAPE_GRADIENTSDIR, "/gradients.svg", NULL); if (Inkscape::IO::file_test(gradients, G_FILE_TEST_IS_REGULAR)) { - doc = sp_document_new(gradients, FALSE); + doc = SPDocument::createNewDoc(gradients, FALSE); } if (!doc) { gchar *gradients = g_build_filename(CREATE_GRADIENTSDIR, "/gradients.svg", NULL); if (Inkscape::IO::file_test(gradients, G_FILE_TEST_IS_REGULAR)) { - doc = sp_document_new(gradients, FALSE); + doc = SPDocument::createNewDoc(gradients, FALSE); } g_free(gradients); if (doc) { - sp_document_ensure_up_to_date(doc); + doc->ensureUpToDate(); } else { edoc = TRUE; } @@ -157,7 +157,7 @@ sp_gradient_load_from_svg(gchar const *name, SPDocument *current_doc) SPObject *object = doc->getObjectById(name); if (object && SP_IS_GRADIENT(object)) { SPDefs *defs= (SPDefs *) SP_DOCUMENT_DEFS(current_doc); - Inkscape::XML::Document *xml_doc = sp_document_repr_doc(current_doc); + Inkscape::XML::Document *xml_doc = current_doc->getReprDoc(); Inkscape::XML::Node *pat_repr = SP_OBJECT_REPR(object)->duplicate(xml_doc); SP_OBJECT_REPR(defs)->addChild(pat_repr, NULL); Inkscape::GC::release(pat_repr); @@ -195,13 +195,11 @@ SPObject *get_stock_item(gchar const *urn) SPDesktop *desktop = inkscape_active_desktop(); SPDocument *doc = sp_desktop_document(desktop); - SPDefs *defs= (SPDefs *) SP_DOCUMENT_DEFS(doc); + SPDefs *defs = reinterpret_cast<SPDefs *>(SP_DOCUMENT_DEFS(doc)); SPObject *object = NULL; if (!strcmp(base, "marker")) { - for (SPObject *child = sp_object_first_child(SP_OBJECT(defs)); - child != NULL; - child = SP_OBJECT_NEXT(child)) + for ( SPObject *child = defs->firstChild(); child; child = child->getNext() ) { if (SP_OBJECT_REPR(child)->attribute("inkscape:stockid") && !strcmp(name_p, SP_OBJECT_REPR(child)->attribute("inkscape:stockid")) && @@ -213,11 +211,9 @@ SPObject *get_stock_item(gchar const *urn) } else if (!strcmp(base,"pattern")) { - for (SPObject *child = sp_object_first_child(SP_OBJECT(defs)) ; - child != NULL; - child = SP_OBJECT_NEXT(child) ) + for ( SPObject *child = defs->firstChild() ; child; child = child->getNext() ) { - if (SP_OBJECT_REPR(child)->attribute("inkscape:stockid") && + if (child->getRepr()->attribute("inkscape:stockid") && !strcmp(name_p, SP_OBJECT_REPR(child)->attribute("inkscape:stockid")) && SP_IS_PATTERN(child)) { @@ -227,9 +223,7 @@ SPObject *get_stock_item(gchar const *urn) } else if (!strcmp(base,"gradient")) { - for (SPObject *child = sp_object_first_child(SP_OBJECT(defs)); - child != NULL; - child = SP_OBJECT_NEXT(child)) + for ( SPObject *child = defs->firstChild(); child; child = child->getNext() ) { if (SP_OBJECT_REPR(child)->attribute("inkscape:stockid") && !strcmp(name_p, SP_OBJECT_REPR(child)->attribute("inkscape:stockid")) && |
