1
#ifndef __SP_URI_REFERENCES_H__
2
#define __SP_URI_REFERENCES_H__
5
* Helper methods for resolving URI References
8
* Lauris Kaplinski <lauris@kaplinski.com>
10
* Copyright (C) 2001-2002 Lauris Kaplinski
11
* Copyright (C) 2001 Ximian, Inc.
13
* Released under GNU GPL, read the file 'COPYING' for more information
16
#include <sigc++/connection.h>
17
#include <sigc++/trackable.h>
19
#include "bad-uri-exception.h"
25
* A class encapsulating a reference to a particular URI; observers can
26
* be notified when the URI comes to reference a different SPObject.
28
* The URIReference increments and decrements the SPObject's hrefcount
33
* @see sp_object_hunref
35
class URIReference : public sigc::trackable {
40
* @param owner The object on whose behalf this URIReference
41
* is holding a reference to the target object.
43
URIReference(SPObject *owner);
44
URIReference(SPDocument *owner_document);
47
* Destructor. Calls shutdown() if the reference has not been
50
virtual ~URIReference();
53
* Attaches to a URI, relative to the specified document.
55
* Throws a BadURIException if the URI is unsupported,
56
* or the fragment identifier is xpointer and malformed.
58
* @param rel_document document for relative URIs
59
* @param uri the URI to watch
61
void attach(const URI &uri) throw(BadURIException);
64
* Detaches from the currently attached URI target, if any;
65
* the current referrent is signaled as NULL.
70
* @brief Returns a pointer to the current referrent of the
71
* attached URI, or NULL.
73
* @return a pointer to the referenced SPObject or NULL
75
SPObject *getObject() const { return _obj; }
78
* @brief Returns a pointer to the URIReference's owner
80
* @return a pointer to the URIReference's owner
82
SPObject *getOwner() const { return _owner; }
85
* Accessor for the referrent change notification signal;
86
* this signal is emitted whenever the URIReference's
89
* Signal handlers take two parameters: the old and new
94
sigc::signal<void, SPObject *, SPObject *> changedSignal() {
95
return _changed_signal;
99
* Returns a pointer to a URI containing the currently attached
100
* URI, or NULL if no URI is currently attached.
102
* @returns the currently attached URI, or NULL
104
const URI *getURI() const {
109
* Returns true if there is currently an attached URI
111
* @returns true if there is an attached URI
113
bool isAttached() const {
117
SPDocument *getOwnerDocument() { return _owner_document; }
118
SPObject *getOwnerObject() { return _owner; }
121
virtual bool _acceptObject(SPObject *obj) const {
128
SPDocument *_owner_document;
129
sigc::connection _connection;
130
sigc::connection _release_connection;
134
sigc::signal<void, SPObject *, SPObject *> _changed_signal;
136
void _setObject(SPObject *object);
137
void _release(SPObject *object);
139
void operator=(const URIReference &ref);
140
/* Private and definition-less to prevent accidental use. */
146
* Resolves an item referenced by a URI in CSS form contained in "url(...)"
148
SPObject* sp_css_uri_reference_resolve( SPDocument *document, const gchar *uri );
150
SPObject *sp_uri_reference_resolve (SPDocument *document, const gchar *uri);