From 3093434e177d4bb7ccc57c1339fad00d47431c17 Mon Sep 17 00:00:00 2001 From: "Liam P. White" Date: Tue, 4 Mar 2014 21:24:03 -0500 Subject: Added a few swatch related functions (does not compile) (bzr r13090.1.15) --- src/sp-tag-use-reference.cpp | 147 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 147 insertions(+) create mode 100644 src/sp-tag-use-reference.cpp (limited to 'src/sp-tag-use-reference.cpp') diff --git a/src/sp-tag-use-reference.cpp b/src/sp-tag-use-reference.cpp new file mode 100644 index 000000000..8e48c0285 --- /dev/null +++ b/src/sp-tag-use-reference.cpp @@ -0,0 +1,147 @@ +/* + * The reference corresponding to href of element. + * + * Copyright (C) Theodore Janeczko 2012 + * + * Released under GNU GPL, read the file 'COPYING' for more information. + */ + +#include +#include +#include + +#include "enums.h" +#include "sp-tag-use-reference.h" + +#include "display/curve.h" +#include "livarot/Path.h" +#include "preferences.h" +#include "sp-shape.h" +#include "sp-text.h" +#include "uri.h" + + + +bool SPTagUseReference::_acceptObject(SPObject * const obj) const +{ + if (SP_IS_ITEM(obj)) { + SPObject * const owner = getOwner(); + // Refuse references to us or to an ancestor. + for ( SPObject *iter = owner ; iter ; iter = iter->parent ) { + if ( iter == obj ) { + return false; + } + } + return true; + } else { + return false; + } +} + + +static void sp_usepath_href_changed(SPObject *old_ref, SPObject *ref, SPTagUsePath *offset); +static void sp_usepath_delete_self(SPObject *deleted, SPTagUsePath *offset); + +SPTagUsePath::SPTagUsePath(SPObject* i_owner):SPTagUseReference(i_owner) +{ + owner=i_owner; + originalPath = NULL; + sourceDirty=false; + sourceHref = NULL; + sourceRepr = NULL; + sourceObject = NULL; + _changed_connection = changedSignal().connect(sigc::bind(sigc::ptr_fun(sp_usepath_href_changed), this)); // listening to myself, this should be virtual instead + + user_unlink = NULL; +} + +SPTagUsePath::~SPTagUsePath(void) +{ + delete originalPath; + originalPath = NULL; + + _changed_connection.disconnect(); // to do before unlinking + + quit_listening(); + unlink(); +} + +void +SPTagUsePath::link(char *to) +{ + if ( to == NULL ) { + quit_listening(); + unlink(); + } else { + if ( !sourceHref || ( strcmp(to, sourceHref) != 0 ) ) { + g_free(sourceHref); + sourceHref = g_strdup(to); + try { + attach(Inkscape::URI(to)); + } catch (Inkscape::BadURIException &e) { + /* TODO: Proper error handling as per + * http://www.w3.org/TR/SVG11/implnote.html#ErrorProcessing. + */ + g_warning("%s", e.what()); + detach(); + } + } + } +} + +void +SPTagUsePath::unlink(void) +{ + g_free(sourceHref); + sourceHref = NULL; + detach(); +} + +void +SPTagUsePath::start_listening(SPObject* to) +{ + if ( to == NULL ) { + return; + } + sourceObject = to; + sourceRepr = to->getRepr(); + _delete_connection = to->connectDelete(sigc::bind(sigc::ptr_fun(&sp_usepath_delete_self), this)); +} + +void +SPTagUsePath::quit_listening(void) +{ + if ( sourceObject == NULL ) { + return; + } + _delete_connection.disconnect(); + sourceRepr = NULL; + sourceObject = NULL; +} + +static void +sp_usepath_href_changed(SPObject */*old_ref*/, SPObject */*ref*/, SPTagUsePath *offset) +{ + offset->quit_listening(); + SPItem *refobj = offset->getObject(); + if ( refobj ) { + offset->start_listening(refobj); + } +} + +static void +sp_usepath_delete_self(SPObject */*deleted*/, SPTagUsePath *offset) +{ + offset->owner->deleteObject(); +} + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : -- cgit v1.2.3 From c3edf2beebfdf0cbb505d2accbddc4fec17dff7d Mon Sep 17 00:00:00 2001 From: "Liam P. White" Date: Thu, 6 Mar 2014 21:05:19 -0500 Subject: Start cleanup for merge into trunk (bzr r13090.1.20) --- src/sp-tag-use-reference.cpp | 147 ------------------------------------------- 1 file changed, 147 deletions(-) delete mode 100644 src/sp-tag-use-reference.cpp (limited to 'src/sp-tag-use-reference.cpp') diff --git a/src/sp-tag-use-reference.cpp b/src/sp-tag-use-reference.cpp deleted file mode 100644 index 8e48c0285..000000000 --- a/src/sp-tag-use-reference.cpp +++ /dev/null @@ -1,147 +0,0 @@ -/* - * The reference corresponding to href of element. - * - * Copyright (C) Theodore Janeczko 2012 - * - * Released under GNU GPL, read the file 'COPYING' for more information. - */ - -#include -#include -#include - -#include "enums.h" -#include "sp-tag-use-reference.h" - -#include "display/curve.h" -#include "livarot/Path.h" -#include "preferences.h" -#include "sp-shape.h" -#include "sp-text.h" -#include "uri.h" - - - -bool SPTagUseReference::_acceptObject(SPObject * const obj) const -{ - if (SP_IS_ITEM(obj)) { - SPObject * const owner = getOwner(); - // Refuse references to us or to an ancestor. - for ( SPObject *iter = owner ; iter ; iter = iter->parent ) { - if ( iter == obj ) { - return false; - } - } - return true; - } else { - return false; - } -} - - -static void sp_usepath_href_changed(SPObject *old_ref, SPObject *ref, SPTagUsePath *offset); -static void sp_usepath_delete_self(SPObject *deleted, SPTagUsePath *offset); - -SPTagUsePath::SPTagUsePath(SPObject* i_owner):SPTagUseReference(i_owner) -{ - owner=i_owner; - originalPath = NULL; - sourceDirty=false; - sourceHref = NULL; - sourceRepr = NULL; - sourceObject = NULL; - _changed_connection = changedSignal().connect(sigc::bind(sigc::ptr_fun(sp_usepath_href_changed), this)); // listening to myself, this should be virtual instead - - user_unlink = NULL; -} - -SPTagUsePath::~SPTagUsePath(void) -{ - delete originalPath; - originalPath = NULL; - - _changed_connection.disconnect(); // to do before unlinking - - quit_listening(); - unlink(); -} - -void -SPTagUsePath::link(char *to) -{ - if ( to == NULL ) { - quit_listening(); - unlink(); - } else { - if ( !sourceHref || ( strcmp(to, sourceHref) != 0 ) ) { - g_free(sourceHref); - sourceHref = g_strdup(to); - try { - attach(Inkscape::URI(to)); - } catch (Inkscape::BadURIException &e) { - /* TODO: Proper error handling as per - * http://www.w3.org/TR/SVG11/implnote.html#ErrorProcessing. - */ - g_warning("%s", e.what()); - detach(); - } - } - } -} - -void -SPTagUsePath::unlink(void) -{ - g_free(sourceHref); - sourceHref = NULL; - detach(); -} - -void -SPTagUsePath::start_listening(SPObject* to) -{ - if ( to == NULL ) { - return; - } - sourceObject = to; - sourceRepr = to->getRepr(); - _delete_connection = to->connectDelete(sigc::bind(sigc::ptr_fun(&sp_usepath_delete_self), this)); -} - -void -SPTagUsePath::quit_listening(void) -{ - if ( sourceObject == NULL ) { - return; - } - _delete_connection.disconnect(); - sourceRepr = NULL; - sourceObject = NULL; -} - -static void -sp_usepath_href_changed(SPObject */*old_ref*/, SPObject */*ref*/, SPTagUsePath *offset) -{ - offset->quit_listening(); - SPItem *refobj = offset->getObject(); - if ( refobj ) { - offset->start_listening(refobj); - } -} - -static void -sp_usepath_delete_self(SPObject */*deleted*/, SPTagUsePath *offset) -{ - offset->owner->deleteObject(); -} - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : -- cgit v1.2.3 From 4038de8b4763974c97aa8fcb9d87b83c1a5daac7 Mon Sep 17 00:00:00 2001 From: "Liam P. White" Date: Sat, 10 May 2014 15:16:24 -0400 Subject: Add selection sets (bzr r13090.1.75) --- src/sp-tag-use-reference.cpp | 156 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 156 insertions(+) create mode 100644 src/sp-tag-use-reference.cpp (limited to 'src/sp-tag-use-reference.cpp') diff --git a/src/sp-tag-use-reference.cpp b/src/sp-tag-use-reference.cpp new file mode 100644 index 000000000..50c011812 --- /dev/null +++ b/src/sp-tag-use-reference.cpp @@ -0,0 +1,156 @@ +/* + * The reference corresponding to href of element. + * + * Copyright (C) Theodore Janeczko 2012-2014 + * + * Released under GNU GPL, read the file 'COPYING' for more information. + */ + +#include +#include +#include + +#include "enums.h" +#include "sp-tag-use-reference.h" + +#include "display/curve.h" +#include "livarot/Path.h" +#include "preferences.h" +#include "sp-shape.h" +#include "sp-text.h" +#include "uri.h" + +#if 0 +namespace { + SPObject* createTagUseReference() { + return new SPTag(); + } + bool tagUseReferencesRegistered = SPFactory::instance().registerObject("inkscape:tag", createTag); +} +// this SPObject doesn't need to be registered +#endif + + +bool SPTagUseReference::_acceptObject(SPObject * const obj) const +{ + if (SP_IS_ITEM(obj)) { + SPObject * const owner = getOwner(); + // Refuse references to us or to an ancestor. + for ( SPObject *iter = owner ; iter ; iter = iter->parent ) { + if ( iter == obj ) { + return false; + } + } + return true; + } else { + return false; + } +} + + +static void sp_usepath_href_changed(SPObject *old_ref, SPObject *ref, SPTagUsePath *offset); +static void sp_usepath_delete_self(SPObject *deleted, SPTagUsePath *offset); + +SPTagUsePath::SPTagUsePath(SPObject* i_owner):SPTagUseReference(i_owner) +{ + owner=i_owner; + originalPath = NULL; + sourceDirty=false; + sourceHref = NULL; + sourceRepr = NULL; + sourceObject = NULL; + _changed_connection = changedSignal().connect(sigc::bind(sigc::ptr_fun(sp_usepath_href_changed), this)); // listening to myself, this should be virtual instead + + user_unlink = NULL; +} + +SPTagUsePath::~SPTagUsePath(void) +{ + delete originalPath; + originalPath = NULL; + + _changed_connection.disconnect(); // to do before unlinking + + quit_listening(); + unlink(); +} + +void +SPTagUsePath::link(char *to) +{ + if ( to == NULL ) { + quit_listening(); + unlink(); + } else { + if ( !sourceHref || ( strcmp(to, sourceHref) != 0 ) ) { + g_free(sourceHref); + sourceHref = g_strdup(to); + try { + attach(Inkscape::URI(to)); + } catch (Inkscape::BadURIException &e) { + /* TODO: Proper error handling as per + * http://www.w3.org/TR/SVG11/implnote.html#ErrorProcessing. + */ + g_warning("%s", e.what()); + detach(); + } + } + } +} + +void +SPTagUsePath::unlink(void) +{ + g_free(sourceHref); + sourceHref = NULL; + detach(); +} + +void +SPTagUsePath::start_listening(SPObject* to) +{ + if ( to == NULL ) { + return; + } + sourceObject = to; + sourceRepr = to->getRepr(); + _delete_connection = to->connectDelete(sigc::bind(sigc::ptr_fun(&sp_usepath_delete_self), this)); +} + +void +SPTagUsePath::quit_listening(void) +{ + if ( sourceObject == NULL ) { + return; + } + _delete_connection.disconnect(); + sourceRepr = NULL; + sourceObject = NULL; +} + +static void +sp_usepath_href_changed(SPObject */*old_ref*/, SPObject */*ref*/, SPTagUsePath *offset) +{ + offset->quit_listening(); + SPItem *refobj = offset->getObject(); + if ( refobj ) { + offset->start_listening(refobj); + } +} + +static void +sp_usepath_delete_self(SPObject */*deleted*/, SPTagUsePath *offset) +{ + offset->owner->deleteObject(); +} + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : -- cgit v1.2.3