summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 0edc248)
raw | patch | inline | side by side (parent: 0edc248)
| author | johanengelen <johanengelen@users.sourceforge.net> | |
| Mon, 24 Mar 2008 21:58:41 +0000 (21:58 +0000) | ||
| committer | johanengelen <johanengelen@users.sourceforge.net> | |
| Mon, 24 Mar 2008 21:58:41 +0000 (21:58 +0000) |
| src/sp-use.h | patch | blob | history | |
| src/uri-references.cpp | patch | blob | history | |
| src/uri-references.h | patch | blob | history |
diff --git a/src/sp-use.h b/src/sp-use.h
index 6927171e102e6f1d96498ebe606b92187614bed4..a8f2745ab5dde32e51e10b22dfaec372d29ee2b0 100644 (file)
--- a/src/sp-use.h
+++ b/src/sp-use.h
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 8041fbf520f46fafbe098569f117aabd21a1c858..d979fe29230da90439f3955e835504b8c8f7f067 100644 (file)
--- a/src/uri-references.cpp
+++ b/src/uri-references.cpp
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 1d2a3310ffe4de5be545091908aa2c1e6fecb783..a98c84153bf382603295d212b2f69444a4a2690d 100644 (file)
--- a/src/uri-references.h
+++ b/src/uri-references.h
*/
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<void, SPObject *, SPObject *> 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<void, SPObject *, SPObject *> 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<void, SPObject *, SPObject *> _changed_signal;
+ sigc::signal<void, SPObject *, SPObject *> _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. */
};
}