1 #ifndef SEEN_SP_TREF_REFERENCE_H
2 #define SEEN_SP_TREF_REFERENCE_H
4 /*
5 * The reference corresponding to href of <tref> element.
6 *
7 * This file was created based on sp-use-reference.h
8 *
9 * Copyright (C) 2007 Gail Banaszkiewicz
10 *
11 * Released under GNU GPL, read the file 'COPYING' for more information.
12 */
14 #include <forward.h>
15 #include "sp-item.h"
16 #include <uri-references.h>
17 #include <sigc++/sigc++.h>
19 #include "util/share.h"
20 #include "xml/node-observer.h"
21 #include "xml/subtree.h"
24 class SPTRefReference : public Inkscape::URIReference,
25 public Inkscape::XML::NodeObserver {
26 public:
27 SPTRefReference(SPObject *owner) : URIReference(owner), subtreeObserved(NULL) {
28 updateObserver();
29 }
31 virtual ~SPTRefReference() {
32 if (subtreeObserved) {
33 subtreeObserved->removeObserver(*this);
34 delete subtreeObserved;
35 }
36 }
38 SPItem *getObject() const {
39 return (SPItem *)URIReference::getObject();
40 }
42 void updateObserver();
44 /////////////////////////////////////////////////////////////////////
45 // Node Observer Functions
46 // -----------------------
47 virtual void notifyChildAdded(Inkscape::XML::Node &node, Inkscape::XML::Node &child, Inkscape::XML::Node *prev);
48 virtual void notifyChildRemoved(Inkscape::XML::Node &node, Inkscape::XML::Node &child, Inkscape::XML::Node *prev);
49 virtual void notifyChildOrderChanged(Inkscape::XML::Node &node, Inkscape::XML::Node &child,
50 Inkscape::XML::Node *old_prev, Inkscape::XML::Node *new_prev);
51 virtual void notifyContentChanged(Inkscape::XML::Node &node,
52 Inkscape::Util::ptr_shared<char> old_content,
53 Inkscape::Util::ptr_shared<char> new_content);
54 virtual void notifyAttributeChanged(Inkscape::XML::Node &node, GQuark name,
55 Inkscape::Util::ptr_shared<char> old_value,
56 Inkscape::Util::ptr_shared<char> new_value);
57 /////////////////////////////////////////////////////////////////////
59 protected:
60 virtual bool _acceptObject(SPObject * obj) const;
62 Inkscape::XML::Subtree *subtreeObserved;
63 };
65 #endif /* !SEEN_SP_TREF_REFERENCE_H */
67 /*
68 Local Variables:
69 mode:c++
70 c-file-style:"stroustrup"
71 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
72 indent-tabs-mode:nil
73 fill-column:99
74 End:
75 */
76 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :