From 1113a0e34ffd36b95b07853270c1b986940dbd6b Mon Sep 17 00:00:00 2001 From: johanengelen Date: Mon, 24 Mar 2008 21:58:41 +0000 Subject: [PATCH] whitespace. tab to spaces. improve readability --- src/sp-use.h | 34 ++++---- src/uri-references.cpp | 177 ++++++++++++++++++++------------------ src/uri-references.h | 191 +++++++++++++++++++++-------------------- 3 files changed, 206 insertions(+), 196 deletions(-) diff --git a/src/sp-use.h b/src/sp-use.h index 6927171e1..a8f2745ab 100644 --- a/src/sp-use.h +++ b/src/sp-use.h @@ -29,30 +29,30 @@ class SPUseClass; class SPUseReference; struct SPUse : public SPItem { - // item built from the original's repr (the visible clone) - // relative to the SPUse itself, it is treated as a child, similar to a grouped item relative to its group - SPObject *child; + // item built from the original's repr (the visible clone) + // relative to the SPUse itself, it is treated as a child, similar to a grouped item relative to its group + SPObject *child; - // SVG attrs - SVGLength x; - SVGLength y; - SVGLength width; - SVGLength height; - gchar *href; + // SVG attrs + SVGLength x; + SVGLength y; + SVGLength width; + SVGLength height; + gchar *href; - // the reference to the original object - SPUseReference *ref; + // the reference to the original object + SPUseReference *ref; - // a sigc connection for delete notifications - sigc::connection _delete_connection; - sigc::connection _changed_connection; + // a sigc connection for delete notifications + sigc::connection _delete_connection; + sigc::connection _changed_connection; - // a sigc connection for transformed signal, used to do move compensation - sigc::connection _transformed_connection; + // a sigc connection for transformed signal, used to do move compensation + sigc::connection _transformed_connection; }; struct SPUseClass { - SPItemClass parent_class; + SPItemClass parent_class; }; GType sp_use_get_type (void); diff --git a/src/uri-references.cpp b/src/uri-references.cpp index 8041fbf52..d979fe292 100644 --- a/src/uri-references.cpp +++ b/src/uri-references.cpp @@ -26,120 +26,127 @@ namespace Inkscape { URIReference::URIReference(SPObject *owner) - : _owner(owner), _owner_document(NULL), _obj(NULL), _uri(NULL) + : _owner(owner), _owner_document(NULL), _obj(NULL), _uri(NULL) { - g_assert(_owner != NULL); - /* FIXME !!! attach to owner's destroy signal to clean up in case */ + g_assert(_owner != NULL); + /* FIXME !!! attach to owner's destroy signal to clean up in case */ } URIReference::URIReference(SPDocument *owner_document) - : _owner(NULL), _owner_document(owner_document), _obj(NULL), _uri(NULL) + : _owner(NULL), _owner_document(owner_document), _obj(NULL), _uri(NULL) { - g_assert(_owner_document != NULL); + g_assert(_owner_document != NULL); } -URIReference::~URIReference() { - detach(); +URIReference::~URIReference() +{ + detach(); } void URIReference::attach(const URI &uri) throw(BadURIException) { - SPDocument *document; - if (_owner) { - document = SP_OBJECT_DOCUMENT(_owner); - } else if (_owner_document) { - document = _owner_document; - } else { - g_assert_not_reached(); - } - gchar const *fragment = uri.getFragment(); - if ( !uri.isRelative() || uri.getQuery() || !fragment ) { - throw UnsupportedURIException(); - } - - /* FIXME !!! real xpointer support should be delegated to document */ - /* for now this handles the minimal xpointer form that SVG 1.0 - * requires of us - */ - gchar *id; - if (!strncmp(fragment, "xpointer(", 9)) { - /* FIXME !!! this is wasteful */ - /* FIXME: It looks as though this is including "))" in the id. I suggest moving - the strlen calculation and validity testing to before strdup, and copying just - the id without the "))". -- pjrm */ - if (!strncmp(fragment, "xpointer(id(", 12)) { - id = g_strdup(fragment+12); - size_t const len = strlen(id); - if ( len < 3 || strcmp(id+len-2, "))") ) { - g_free(id); - throw MalformedURIException(); - } - } else { - throw UnsupportedURIException(); - } - } else { - id = g_strdup(fragment); - } - - /* FIXME !!! validate id as an NCName somewhere */ - - if (_uri) { - delete _uri; - } - _uri = new URI(uri); - - _connection.disconnect(); - _setObject(document->getObjectById(id)); - _connection = document->connectIdChanged(id, sigc::mem_fun(*this, &URIReference::_setObject)); - - g_free(id); + SPDocument *document; + if (_owner) { + document = SP_OBJECT_DOCUMENT(_owner); + } else if (_owner_document) { + document = _owner_document; + } else { + g_assert_not_reached(); + } + + gchar const *fragment = uri.getFragment(); + if ( !uri.isRelative() || uri.getQuery() || !fragment ) { + throw UnsupportedURIException(); + } + + /* FIXME !!! real xpointer support should be delegated to document */ + /* for now this handles the minimal xpointer form that SVG 1.0 + * requires of us + */ + gchar *id; + if (!strncmp(fragment, "xpointer(", 9)) { + /* FIXME !!! this is wasteful */ + /* FIXME: It looks as though this is including "))" in the id. I suggest moving + the strlen calculation and validity testing to before strdup, and copying just + the id without the "))". -- pjrm */ + if (!strncmp(fragment, "xpointer(id(", 12)) { + id = g_strdup(fragment+12); + size_t const len = strlen(id); + if ( len < 3 || strcmp(id+len-2, "))") ) { + g_free(id); + throw MalformedURIException(); + } + } else { + throw UnsupportedURIException(); + } + } else { + id = g_strdup(fragment); + } + + /* FIXME !!! validate id as an NCName somewhere */ + + if (_uri) { + delete _uri; + } + _uri = new URI(uri); + + _connection.disconnect(); + _setObject(document->getObjectById(id)); + _connection = document->connectIdChanged(id, sigc::mem_fun(*this, &URIReference::_setObject)); + + g_free(id); } -void URIReference::detach() { - _connection.disconnect(); - delete _uri; - _uri = NULL; - _setObject(NULL); +void URIReference::detach() +{ + _connection.disconnect(); + delete _uri; + _uri = NULL; + _setObject(NULL); } -void URIReference::_setObject(SPObject *obj) { - if ( obj && !_acceptObject(obj) ) { - obj = NULL; - } - - if ( obj == _obj ) return; - - SPObject *old_obj=_obj; - _obj = obj; - - _release_connection.disconnect(); - if (_obj) { - sp_object_href(_obj, _owner); - _release_connection = _obj->connectRelease(sigc::mem_fun(*this, &URIReference::_release)); - } - _changed_signal.emit(old_obj, _obj); - if (old_obj) { - /* release the old object _after_ the signal emission */ - sp_object_hunref(old_obj, _owner); - } +void URIReference::_setObject(SPObject *obj) +{ + if ( obj && !_acceptObject(obj) ) { + obj = NULL; + } + + if ( obj == _obj ) return; + + SPObject *old_obj=_obj; + _obj = obj; + + _release_connection.disconnect(); + if (_obj) { + sp_object_href(_obj, _owner); + _release_connection = _obj->connectRelease(sigc::mem_fun(*this, &URIReference::_release)); + } + _changed_signal.emit(old_obj, _obj); + if (old_obj) { + /* release the old object _after_ the signal emission */ + sp_object_hunref(old_obj, _owner); + } } /* If an object is deleted, current semantics require that we release * it on its "release" signal, rather than later, when its ID is actually * unregistered from the document. */ -void URIReference::_release(SPObject *obj) { - g_assert( _obj == obj ); - _setObject(NULL); +void URIReference::_release(SPObject *obj) +{ + g_assert( _obj == obj ); + _setObject(NULL); } } /* namespace Inkscape */ + + SPObject* sp_css_uri_reference_resolve( SPDocument *document, const gchar *uri ) { SPObject* ref = 0; - if ( document && uri && ( strncmp(uri, "url(", 4) == 0 )) { + if ( document && uri && ( strncmp(uri, "url(", 4) == 0 ) ) { gchar *trimmed = extract_uri( uri ); if ( trimmed ) { ref = sp_uri_reference_resolve( document, trimmed ); diff --git a/src/uri-references.h b/src/uri-references.h index 1d2a3310f..a98c84153 100644 --- a/src/uri-references.h +++ b/src/uri-references.h @@ -34,107 +34,110 @@ namespace Inkscape { */ class URIReference : public sigc::trackable { public: - /** - * Constructor. - * - * @param owner The object on whose behalf this URIReference - * is holding a reference to the target object. - */ - URIReference(SPObject *owner); - URIReference(SPDocument *owner_document); - - /** - * Destructor. Calls shutdown() if the reference has not been - * shut down yet. - */ - virtual ~URIReference(); - - /** - * Attaches to a URI, relative to the specified document. - * - * Throws a BadURIException if the URI is unsupported, - * or the fragment identifier is xpointer and malformed. - * - * @param rel_document document for relative URIs - * @param uri the URI to watch - */ - void attach(const URI &uri) throw(BadURIException); - - /** - * Detaches from the currently attached URI target, if any; - * the current referrent is signaled as NULL. - */ - void detach(); - - /** - * @brief Returns a pointer to the current referrent of the - * attached URI, or NULL. - * - * @return a pointer to the referenced SPObject or NULL - */ - SPObject *getObject() const { return _obj; } - - /** - * @brief Returns a pointer to the URIReference's owner - * - * @return a pointer to the URIReference's owner - */ - SPObject *getOwner() const { return _owner; } - - /** - * Accessor for the referrent change notification signal; - * this signal is emitted whenever the URIReference's - * referrent changes. - * - * Signal handlers take two parameters: the old and new - * referrents. - * - * @returns a signal - */ - sigc::signal changedSignal() { - return _changed_signal; - } - - /** - * Returns a pointer to a URI containing the currently attached - * URI, or NULL if no URI is currently attached. - * - * @returns the currently attached URI, or NULL - */ - const URI *getURI() const { - return _uri; - } - - /** - * Returns true if there is currently an attached URI - * - * @returns true if there is an attached URI - */ - bool isAttached() const { - return (bool)_uri; - } - - SPDocument *getOwnerDocument() {return _owner_document;} - SPObject *getOwnerObject() {return _owner;} + /** + * Constructor. + * + * @param owner The object on whose behalf this URIReference + * is holding a reference to the target object. + */ + URIReference(SPObject *owner); + URIReference(SPDocument *owner_document); + + /** + * Destructor. Calls shutdown() if the reference has not been + * shut down yet. + */ + virtual ~URIReference(); + + /** + * Attaches to a URI, relative to the specified document. + * + * Throws a BadURIException if the URI is unsupported, + * or the fragment identifier is xpointer and malformed. + * + * @param rel_document document for relative URIs + * @param uri the URI to watch + */ + void attach(const URI &uri) throw(BadURIException); + + /** + * Detaches from the currently attached URI target, if any; + * the current referrent is signaled as NULL. + */ + void detach(); + + /** + * @brief Returns a pointer to the current referrent of the + * attached URI, or NULL. + * + * @return a pointer to the referenced SPObject or NULL + */ + SPObject *getObject() const { return _obj; } + + /** + * @brief Returns a pointer to the URIReference's owner + * + * @return a pointer to the URIReference's owner + */ + SPObject *getOwner() const { return _owner; } + + /** + * Accessor for the referrent change notification signal; + * this signal is emitted whenever the URIReference's + * referrent changes. + * + * Signal handlers take two parameters: the old and new + * referrents. + * + * @returns a signal + */ + sigc::signal changedSignal() { + return _changed_signal; + } + + /** + * Returns a pointer to a URI containing the currently attached + * URI, or NULL if no URI is currently attached. + * + * @returns the currently attached URI, or NULL + */ + const URI *getURI() const { + return _uri; + } + + /** + * Returns true if there is currently an attached URI + * + * @returns true if there is an attached URI + */ + bool isAttached() const { + return (bool)_uri; + } + + SPDocument *getOwnerDocument() { return _owner_document; } + SPObject *getOwnerObject() { return _owner; } protected: - virtual bool _acceptObject(SPObject *obj) const { (void)obj; return true; } + virtual bool _acceptObject(SPObject *obj) const { + (void)obj; + return true; + } private: - SPObject *_owner; - SPDocument *_owner_document; - sigc::connection _connection; - sigc::connection _release_connection; - SPObject *_obj; - URI *_uri; + SPObject *_owner; + SPDocument *_owner_document; + sigc::connection _connection; + sigc::connection _release_connection; + SPObject *_obj; + URI *_uri; - sigc::signal _changed_signal; + sigc::signal _changed_signal; - void _setObject(SPObject *object); - void _release(SPObject *object); + void _setObject(SPObject *object); + void _release(SPObject *object); - void operator=(const URIReference &ref); - /* Private and definition-less to prevent accidental use. */ + void operator=(const URIReference &ref); + /* Private and definition-less to prevent accidental use. */ }; } -- 2.30.2