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/document.h | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'src/document.h') diff --git a/src/document.h b/src/document.h index e70582006..2f9da7817 100644 --- a/src/document.h +++ b/src/document.h @@ -64,10 +64,11 @@ namespace Proj { class SPDocumentPrivate; /// Typed SVG document implementation. -struct SPDocument : public Inkscape::GC::Managed<>, +class SPDocument : public Inkscape::GC::Managed<>, public Inkscape::GC::Finalized, public Inkscape::GC::Anchored { + public: typedef sigc::signal IDChangedSignal; typedef sigc::signal ResourcesChangedSignal; typedef sigc::signal ModifiedSignal; @@ -180,13 +181,17 @@ public: sigc::connection _desktop_activated_connection; void fitToRect(Geom::Rect const &rect, bool with_margins = false); + static SPDocument *createDoc(const gchar *uri, unsigned int keepalive, bool make_new = false); + static SPDocument *createDocFromMem(const gchar *buffer, gint length, unsigned int keepalive); + SPDocument *doRef(); + SPDocument *doUnref(); }; -SPDocument *sp_document_new(const gchar *uri, unsigned int keepalive, bool make_new = false); -SPDocument *sp_document_new_from_mem(const gchar *buffer, gint length, unsigned int keepalive); +//SPDocument *sp_document_new(const gchar *uri, unsigned int keepalive, bool make_new = false); +//SPDocument *sp_document_new_from_mem(const gchar *buffer, gint length, unsigned int keepalive); -SPDocument *sp_document_ref(SPDocument *doc); -SPDocument *sp_document_unref(SPDocument *doc); +//SPDocument *sp_document_ref(SPDocument *doc); +//SPDocument *sp_document_unref(SPDocument *doc); SPDocument *sp_document_create(Inkscape::XML::Document *rdoc, gchar const *uri, gchar const *base, gchar const *name, unsigned int keepalive); -- 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/document.h | 86 ++++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 57 insertions(+), 29 deletions(-) (limited to 'src/document.h') diff --git a/src/document.h b/src/document.h index 2f9da7817..3fa83c779 100644 --- a/src/document.h +++ b/src/document.h @@ -181,10 +181,38 @@ public: sigc::connection _desktop_activated_connection; void fitToRect(Geom::Rect const &rect, bool with_margins = false); - static SPDocument *createDoc(const gchar *uri, unsigned int keepalive, bool make_new = false); - static SPDocument *createDocFromMem(const gchar *buffer, gint length, unsigned int keepalive); + static SPDocument *createNewDoc(const gchar *uri, unsigned int keepalive, bool make_new = false); + static SPDocument *createNewDocFromMem(const gchar *buffer, gint length, unsigned int keepalive); + + /* ToDo - Merge createDoc with createNewDoc */ + static SPDocument *createDoc(Inkscape::XML::Document *rdoc, gchar const *uri, gchar const *base, gchar const *name, unsigned int keepalive); + SPDocument *doRef(); SPDocument *doUnref(); + gdouble getWidth(); + gdouble getHeight(); + Geom::Point getDimensions(); + void setWidth(gdouble width, const SPUnit *unit); + void setHeight(gdouble height, const SPUnit *unit); + //void setUndoSensitive(bool sensitive); + void request_modified(); + gint ensure_up_to_date(); + gboolean add_resource(const gchar *key, SPObject *object); + gboolean remove_resource(const gchar *key, SPObject *object); + const GSList *get_resource_list(const gchar *key); + sigc::connection resources_changed_connect(const gchar *key, SPDocument::ResourcesChangedSignal::slot_type slot); + GSList * items_in_box(unsigned int dkey, Geom::Rect const &box); + GSList *partial_items_in_box(unsigned int dkey, Geom::Rect const &box); + static SPItem *item_from_list_at_point_bottom(unsigned int dkey, SPGroup *group, const GSList *list, Geom::Point const p, bool take_insensitive = false); + SPItem *item_at_point (unsigned int key, Geom::Point const p, gboolean into_groups, SPItem *upto = NULL); + GSList *items_at_points(unsigned const key, std::vector points); + SPItem *group_at_point (unsigned int key, Geom::Point const p); + + void setUri(gchar const *uri); + void change_uri_and_hrefs(gchar const *uri); + void resized_signal_emit(gdouble width, gdouble height); + + unsigned int vacuum_document(); }; //SPDocument *sp_document_new(const gchar *uri, unsigned int keepalive, bool make_new = false); @@ -194,7 +222,7 @@ public: //SPDocument *sp_document_unref(SPDocument *doc); -SPDocument *sp_document_create(Inkscape::XML::Document *rdoc, gchar const *uri, gchar const *base, gchar const *name, unsigned int keepalive); +//SPDocument *sp_document_create(Inkscape::XML::Document *rdoc, gchar const *uri, gchar const *base, gchar const *name, unsigned int keepalive); /* * Access methods @@ -205,14 +233,14 @@ SPDocument *sp_document_create(Inkscape::XML::Document *rdoc, gchar const *uri, #define sp_document_root(d) (d->root) #define SP_DOCUMENT_ROOT(d) (d->root) -gdouble sp_document_width(SPDocument *document); -gdouble sp_document_height(SPDocument *document); -Geom::Point sp_document_dimensions(SPDocument *document); +//gdouble sp_document_width(SPDocument *document); +//gdouble sp_document_height(SPDocument *document); +//Geom::Point sp_document_dimensions(SPDocument *document); struct SPUnit; -void sp_document_set_width(SPDocument *document, gdouble width, const SPUnit *unit); -void sp_document_set_height(SPDocument *document, gdouble height, const SPUnit *unit); +//void sp_document_set_width(SPDocument *document, gdouble width, const SPUnit *unit); +//void sp_document_set_height(SPDocument *document, gdouble height, const SPUnit *unit); #define SP_DOCUMENT_URI(d) (d->uri) #define SP_DOCUMENT_NAME(d) (d->name) @@ -232,15 +260,15 @@ bool sp_document_get_undo_sensitive(SPDocument const *document); void sp_document_clear_undo(SPDocument *document); void sp_document_clear_redo(SPDocument *document); -void sp_document_child_added(SPDocument *doc, SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref); -void sp_document_child_removed(SPDocument *doc, SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref); -void sp_document_attr_changed(SPDocument *doc, SPObject *object, const gchar *key, const gchar *oldval, const gchar *newval); -void sp_document_content_changed(SPDocument *doc, SPObject *object, const gchar *oldcontent, const gchar *newcontent); -void sp_document_order_changed(SPDocument *doc, SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *oldref, Inkscape::XML::Node *newref); +//void sp_document_child_added(SPDocument *doc, SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref); +//void sp_document_child_removed(SPDocument *doc, SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref); +//void sp_document_attr_changed(SPDocument *doc, SPObject *object, const gchar *key, const gchar *oldval, const gchar *newval); +//void sp_document_content_changed(SPDocument *doc, SPObject *object, const gchar *oldcontent, const gchar *newcontent); +//void sp_document_order_changed(SPDocument *doc, SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *oldref, Inkscape::XML::Node *newref); /* Object modification root handler */ -void sp_document_request_modified(SPDocument *doc); -gint sp_document_ensure_up_to_date(SPDocument *doc); +//void sp_document_request_modified(SPDocument *doc); +//gint sp_document_ensure_up_to_date(SPDocument *doc); /* Save all previous actions to stack, as one undo step */ void sp_document_done(SPDocument *document, unsigned int event_type, Glib::ustring event_description); @@ -255,10 +283,10 @@ gboolean sp_document_undo(SPDocument *document); gboolean sp_document_redo(SPDocument *document); /* Resource management */ -gboolean sp_document_add_resource(SPDocument *document, const gchar *key, SPObject *object); -gboolean sp_document_remove_resource(SPDocument *document, const gchar *key, SPObject *object); -const GSList *sp_document_get_resource_list(SPDocument *document, const gchar *key); -sigc::connection sp_document_resources_changed_connect(SPDocument *document, const gchar *key, SPDocument::ResourcesChangedSignal::slot_type slot); +//gboolean sp_document_add_resource(SPDocument *document, const gchar *key, SPObject *object); +//gboolean sp_document_remove_resource(SPDocument *document, const gchar *key, SPObject *object); +//const GSList *sp_document_get_resource_list(SPDocument *document, const gchar *key); +//sigc::connection sp_document_resources_changed_connect(SPDocument *document, const gchar *key, SPDocument::ResourcesChangedSignal::slot_type slot); /* @@ -279,19 +307,19 @@ sigc::connection sp_document_resources_changed_connect(SPDocument *document, con * Misc */ -GSList *sp_document_items_in_box(SPDocument *document, unsigned int dkey, Geom::Rect const &box); -GSList *sp_document_partial_items_in_box(SPDocument *document, unsigned int dkey, Geom::Rect const &box); -SPItem *sp_document_item_from_list_at_point_bottom(unsigned int dkey, SPGroup *group, const GSList *list, Geom::Point const p, bool take_insensitive = false); -SPItem *sp_document_item_at_point (SPDocument *document, unsigned int key, Geom::Point const p, gboolean into_groups, SPItem *upto = NULL); -GSList *sp_document_items_at_points(SPDocument *document, unsigned const key, std::vector points); -SPItem *sp_document_group_at_point (SPDocument *document, unsigned int key, Geom::Point const p); +//GSList *sp_document_items_in_box(SPDocument *document, unsigned int dkey, Geom::Rect const &box); +//GSList *sp_document_partial_items_in_box(SPDocument *document, unsigned int dkey, Geom::Rect const &box); +//SPItem *sp_document_item_from_list_at_point_bottom(unsigned int dkey, SPGroup *group, const GSList *list, Geom::Point const p, bool take_insensitive = false); +//SPItem *sp_document_item_at_point (SPDocument *document, unsigned int key, Geom::Point const p, gboolean into_groups, SPItem *upto = NULL); +//GSList *sp_document_items_at_points(SPDocument *document, unsigned const key, std::vector points); +//SPItem *sp_document_group_at_point (SPDocument *document, unsigned int key, Geom::Point const p); -void sp_document_set_uri(SPDocument *document, gchar const *uri); -void sp_document_change_uri_and_hrefs(SPDocument *document, gchar const *uri); +//void sp_document_set_uri(SPDocument *document, gchar const *uri); +//void sp_document_change_uri_and_hrefs(SPDocument *document, gchar const *uri); -void sp_document_resized_signal_emit(SPDocument *doc, gdouble width, gdouble height); +//void sp_document_resized_signal_emit(SPDocument *doc, gdouble width, gdouble height); -unsigned int vacuum_document(SPDocument *document); +//unsigned int vacuum_document(SPDocument *document); #endif -- 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/document.h | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'src/document.h') diff --git a/src/document.h b/src/document.h index 3fa83c779..38f930c31 100644 --- a/src/document.h +++ b/src/document.h @@ -28,6 +28,7 @@ #include "gc-anchored.h" #include #include "verbs.h" +#include "document-undo.h" #include #include @@ -213,6 +214,9 @@ public: void resized_signal_emit(gdouble width, gdouble height); unsigned int vacuum_document(); + + private: + void do_change_uri(gchar const *const filename, bool const rebase); }; //SPDocument *sp_document_new(const gchar *uri, unsigned int keepalive, bool make_new = false); @@ -254,11 +258,11 @@ struct SPUnit; * Undo & redo */ -void sp_document_set_undo_sensitive(SPDocument *document, bool sensitive); -bool sp_document_get_undo_sensitive(SPDocument const *document); +//void sp_document_set_undo_sensitive(SPDocument *document, bool sensitive); +//bool sp_document_get_undo_sensitive(SPDocument const *document); -void sp_document_clear_undo(SPDocument *document); -void sp_document_clear_redo(SPDocument *document); +//void sp_document_clear_undo(SPDocument *document); +//void sp_document_clear_redo(SPDocument *document); //void sp_document_child_added(SPDocument *doc, SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref); //void sp_document_child_removed(SPDocument *doc, SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref); @@ -271,16 +275,16 @@ void sp_document_clear_redo(SPDocument *document); //gint sp_document_ensure_up_to_date(SPDocument *doc); /* Save all previous actions to stack, as one undo step */ -void sp_document_done(SPDocument *document, unsigned int event_type, Glib::ustring event_description); -void sp_document_maybe_done(SPDocument *document, const gchar *keyconst, unsigned int event_type, Glib::ustring event_description); -void sp_document_reset_key(Inkscape::Application *inkscape, SPDesktop *desktop, GtkObject *base); +//void sp_document_done(SPDocument *document, unsigned int event_type, Glib::ustring event_description); +//void sp_document_maybe_done(SPDocument *document, const gchar *keyconst, unsigned int event_type, Glib::ustring event_description); +//void sp_document_reset_key(Inkscape::Application *inkscape, SPDesktop *desktop, GtkObject *base); /* Cancel (and revert) current unsaved actions */ -void sp_document_cancel(SPDocument *document); +//void sp_document_cancel(SPDocument *document); /* Undo and redo */ -gboolean sp_document_undo(SPDocument *document); -gboolean sp_document_redo(SPDocument *document); +//gboolean sp_document_undo(SPDocument *document); +//gboolean sp_document_redo(SPDocument *document); /* Resource management */ //gboolean sp_document_add_resource(SPDocument *document, const gchar *key, SPObject *object); -- cgit v1.2.3 From 1aaf9a0ee3da28012bf43cfa61e2e5fa933edd2e Mon Sep 17 00:00:00 2001 From: Abhishek Sharma Public Date: Tue, 6 Jul 2010 12:52:32 +0530 Subject: C++ification of SPObject continued along with the onset of XML Privatisation. Users may checkout [grep -Ir XML Tree *] in the source code and all the places where the XML node/Tree is being used shall be reflected. (bzr r9546.1.5) --- src/document.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/document.h') diff --git a/src/document.h b/src/document.h index 38f930c31..a91d1e57f 100644 --- a/src/document.h +++ b/src/document.h @@ -162,8 +162,10 @@ sigc::connection connectCommit(CommitSignal::slot_type slot); void setModifiedSinceSave(bool modified = true) { modified_since_save = modified; } + //Inkscape::XML::Document * getRdoc(){ return rdoc; } private: + //Inkscape::XML::Document *rdoc; ///< Our Inkscape::XML::Document SPDocument(SPDocument const &); // no copy void operator=(SPDocument const &); // no assign -- cgit v1.2.3