From 8867de5daf309e4cdd3fce177b408618490be4f3 Mon Sep 17 00:00:00 2001 From: Abhishek Sharma Public Date: Tue, 29 Jun 2010 23:35:42 +0530 Subject: This is the first c++ification commit from me. It handles sp-line, sp-polyline, sp-item and marks the onset of document c++ification as well. Users can check performace increase with [/usr/bin/time -v inkscape_binary_with_commandline_options]. (bzr r9546.1.1) --- src/file.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/file.cpp') diff --git a/src/file.cpp b/src/file.cpp index e0ecd5084..352362424 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -118,7 +118,7 @@ sp_file_new(const Glib::ustring &templ) char *templName = NULL; if (templ.size()>0) templName = (char *)templ.c_str(); - SPDocument *doc = sp_document_new(templName, TRUE, true); + SPDocument *doc = SPDocument::createDoc(templName, TRUE, true); g_return_val_if_fail(doc != NULL, NULL); SPDesktop *dt; @@ -128,7 +128,7 @@ sp_file_new(const Glib::ustring &templ) } else { SPViewWidget *dtw = sp_desktop_widget_new(sp_document_namedview(doc, NULL)); g_return_val_if_fail(dtw != NULL, NULL); - sp_document_unref(doc); + doc->doUnref(); sp_create_window(dtw, TRUE); dt = static_cast(dtw->view); @@ -250,7 +250,7 @@ sp_file_open(const Glib::ustring &uri, doc->virgin = FALSE; // everyone who cares now has a reference, get rid of ours - sp_document_unref(doc); + doc->doUnref(); // resize the window to match the document properties sp_namedview_window_from_document(desktop); sp_namedview_update_layers_from_document(desktop); @@ -1049,7 +1049,7 @@ file_import(SPDocument *in_doc, const Glib::ustring &uri, // preserve parent and viewBox transformations // c2p is identity matrix at this point unless sp_document_ensure_up_to_date is called sp_document_ensure_up_to_date(doc); - Geom::Matrix affine = SP_ROOT(SP_DOCUMENT_ROOT(doc))->c2p * sp_item_i2doc_affine(SP_ITEM(place_to_insert)).inverse(); + Geom::Matrix affine = SP_ROOT(SP_DOCUMENT_ROOT(doc))->c2p * SP_ITEM(place_to_insert)->i2doc_affine().inverse(); sp_selection_apply_affine(selection, desktop->dt2doc() * affine * desktop->doc2dt(), true, false); // move to mouse pointer @@ -1063,7 +1063,7 @@ file_import(SPDocument *in_doc, const Glib::ustring &uri, } } - sp_document_unref(doc); + doc->doUnref(); sp_document_done(in_doc, SP_VERB_FILE_IMPORT, _("Import")); -- cgit v1.2.3 From 121815791be2d24cb745663520b111ee914fbc09 Mon Sep 17 00:00:00 2001 From: Abhishek Sharma Public Date: Thu, 1 Jul 2010 15:36:56 +0530 Subject: C++fied SPDocument added (bzr r9546.1.2) --- src/file.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/file.cpp') diff --git a/src/file.cpp b/src/file.cpp index 352362424..6b162c799 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -118,7 +118,7 @@ sp_file_new(const Glib::ustring &templ) char *templName = NULL; if (templ.size()>0) templName = (char *)templ.c_str(); - SPDocument *doc = SPDocument::createDoc(templName, TRUE, true); + SPDocument *doc = SPDocument::createNewDoc(templName, TRUE, true); g_return_val_if_fail(doc != NULL, NULL); SPDesktop *dt; @@ -234,9 +234,9 @@ sp_file_open(const Glib::ustring &uri, if (existing && existing->virgin && replace_empty) { // If the current desktop is empty, open the document there - sp_document_ensure_up_to_date (doc); + doc->ensure_up_to_date (); desktop->change_document(doc); - sp_document_resized_signal_emit (doc, sp_document_width(doc), sp_document_height(doc)); + doc->resized_signal_emit (doc->getWidth(), doc->getHeight()); } else { if (!Inkscape::NSApplication::Application::getNewGui()) { // create a whole new desktop and window @@ -558,7 +558,7 @@ sp_file_vacuum() { SPDocument *doc = SP_ACTIVE_DOCUMENT; - unsigned int diff = vacuum_document (doc); + unsigned int diff = doc->vacuum_document (); sp_document_done(doc, SP_VERB_FILE_VACUUM, _("Vacuum <defs>")); @@ -1048,13 +1048,13 @@ file_import(SPDocument *in_doc, const Glib::ustring &uri, // preserve parent and viewBox transformations // c2p is identity matrix at this point unless sp_document_ensure_up_to_date is called - sp_document_ensure_up_to_date(doc); + doc->ensure_up_to_date(); Geom::Matrix affine = SP_ROOT(SP_DOCUMENT_ROOT(doc))->c2p * SP_ITEM(place_to_insert)->i2doc_affine().inverse(); sp_selection_apply_affine(selection, desktop->dt2doc() * affine * desktop->doc2dt(), true, false); // move to mouse pointer { - sp_document_ensure_up_to_date(sp_desktop_document(desktop)); + sp_desktop_document(desktop)->ensure_up_to_date(); Geom::OptRect sel_bbox = selection->bounds(); if (sel_bbox) { Geom::Point m( desktop->point() - sel_bbox->midpoint() ); -- cgit v1.2.3 From d25a9a072143eafa4a9823b84e977c4b85d45efe Mon Sep 17 00:00:00 2001 From: Abhishek Sharma Public Date: Fri, 2 Jul 2010 18:05:42 +0530 Subject: New Class SPDocumentUndo created which takes care of c++fying some non SPDocument based methods (bzr r9546.1.3) --- src/file.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/file.cpp') diff --git a/src/file.cpp b/src/file.cpp index 6b162c799..2344c67f2 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -560,7 +560,7 @@ sp_file_vacuum() unsigned int diff = doc->vacuum_document (); - sp_document_done(doc, SP_VERB_FILE_VACUUM, + SPDocumentUndo::done(doc, SP_VERB_FILE_VACUUM, _("Vacuum <defs>")); SPDesktop *dt = SP_ACTIVE_DESKTOP; @@ -1064,7 +1064,7 @@ file_import(SPDocument *in_doc, const Glib::ustring &uri, } doc->doUnref(); - sp_document_done(in_doc, SP_VERB_FILE_IMPORT, + SPDocumentUndo::done(in_doc, SP_VERB_FILE_IMPORT, _("Import")); } else { -- cgit v1.2.3 From 1aad26aea24f62b63c992118f36b12483f9a5414 Mon Sep 17 00:00:00 2001 From: Abhishek Sharma Public Date: Sat, 3 Jul 2010 22:50:36 +0530 Subject: another c++ification for sp-object.h/cpp and still in progress... (bzr r9546.1.4) --- src/file.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/file.cpp') diff --git a/src/file.cpp b/src/file.cpp index 2344c67f2..15e5bbe72 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -976,7 +976,7 @@ file_import(SPDocument *in_doc, const Glib::ustring &uri, // Count the number of top-level items in the imported document. guint items_count = 0; - for (SPObject *child = sp_object_first_child(SP_DOCUMENT_ROOT(doc)); + for (SPObject *child = SP_DOCUMENT_ROOT(doc)->first_child(); child != NULL; child = SP_OBJECT_NEXT(child)) { if (SP_IS_ITEM(child)) items_count++; @@ -1004,7 +1004,7 @@ file_import(SPDocument *in_doc, const Glib::ustring &uri, // Construct a new object representing the imported image, // and insert it into the current document. SPObject *new_obj = NULL; - for (SPObject *child = sp_object_first_child(SP_DOCUMENT_ROOT(doc)); + for (SPObject *child = SP_DOCUMENT_ROOT(doc)->first_child(); child != NULL; child = SP_OBJECT_NEXT(child) ) { if (SP_IS_ITEM(child)) { @@ -1024,7 +1024,7 @@ file_import(SPDocument *in_doc, const Glib::ustring &uri, else if (SP_OBJECT_REPR(child)->type() == Inkscape::XML::ELEMENT_NODE) { const gchar *tag = SP_OBJECT_REPR(child)->name(); if (!strcmp(tag, "svg:defs")) { - for (SPObject *x = sp_object_first_child(child); + for (SPObject *x = child->first_child(); x != NULL; x = SP_OBJECT_NEXT(x)) { SP_OBJECT_REPR(in_defs)->addChild(SP_OBJECT_REPR(x)->duplicate(xml_in_doc), last_def); -- cgit v1.2.3