Code

Extensions. Fix for Bug #668895 (Extensions with <check> tags fail to load).
[inkscape.git] / src / uri-references.h
index 8d4bf70980547b167fd86b874b851fc5b02f4a39..c0f9190b1967a6e84be76c2487b4321714921f27 100644 (file)
@@ -6,6 +6,7 @@
  *
  * Authors:
  *   Lauris Kaplinski <lauris@kaplinski.com>
+ *   Abhishek Sharma
  *
  * Copyright (C) 2001-2002 Lauris Kaplinski
  * Copyright (C) 2001 Ximian, Inc.
@@ -18,6 +19,7 @@
 
 #include "bad-uri-exception.h"
 #include "forward.h"
+#include "sp-object.h"
 
 namespace Inkscape {
 
@@ -34,105 +36,119 @@ 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);
-
-       /**
-        * 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;
-       }
+    /**
+     * 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 { return true; }
+    virtual bool _acceptObject(SPObject *obj) const {
+        (void)obj;
+        return true;
+    }
 
 private:
-       SPObject *_owner;
-       sigc::connection _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);
-       static void _release(SPObject *object, URIReference *reference);
+    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. */
 };
 
 }
 
+/**
+ * Resolves an item referenced by a URI in CSS form contained in "url(...)"
+ */
+SPObject* sp_css_uri_reference_resolve( SPDocument *document, const gchar *uri );
+
 SPObject *sp_uri_reference_resolve (SPDocument *document, const gchar *uri);
 
 #endif