Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
sp-tref-reference.cpp
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * The reference corresponding to href of <tref> element.
4 *
5 * Copyright (C) 2007 Gail Banaszkiewicz
6 *
7 * This file was created based on sp-use-reference.cpp
8 *
9 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
10 */
11
12//#include "enums.h"
13#include "sp-tref-reference.h"
14
15#include "sp-text.h"
16#include "sp-tref.h"
17
18
20{
21 SPObject *owner = getOwner();
22 if (is<SPTRef>(owner))
23 return URIReference::_acceptObject(obj);
24 else
25 return false;
26}
27
28
30{
31 SPObject *referred = getObject();
32
33 if (referred) {
34 if (subtreeObserved) {
35 subtreeObserved->removeObserver(*this);
36 }
37
38 subtreeObserved = std::make_unique<Inkscape::XML::Subtree>(*referred->getRepr());
39 subtreeObserved->addObserver(*this);
40 }
41}
42
43
45 Inkscape::XML::Node */*prev*/)
46{
47 SPObject *owner = getOwner();
48
49 if (owner && is<SPTRef>(owner)) {
50 sp_tref_update_text(cast<SPTRef>(owner));
51 }
52}
53
54
56 Inkscape::XML::Node */*prev*/)
57{
58 SPObject *owner = getOwner();
59
60 if (owner && is<SPTRef>(owner)) {
61 sp_tref_update_text(cast<SPTRef>(owner));
62 }
63}
64
65
67 Inkscape::XML::Node */*old_prev*/, Inkscape::XML::Node */*new_prev*/)
68{
69 SPObject *owner = getOwner();
70
71 if (owner && is<SPTRef>(owner)) {
72 sp_tref_update_text(cast<SPTRef>(owner));
73 }
74}
75
76
78 Inkscape::Util::ptr_shared /*old_content*/,
79 Inkscape::Util::ptr_shared /*new_content*/)
80{
81 SPObject *owner = getOwner();
82
83 if (owner && is<SPTRef>(owner)) {
84 sp_tref_update_text(cast<SPTRef>(owner));
85 }
86}
87
88
90 Inkscape::Util::ptr_shared /*old_value*/,
91 Inkscape::Util::ptr_shared /*new_value*/)
92{
93 // Do nothing - tref only cares about textual content
94}
95
96
97/*
98 Local Variables:
99 mode:c++
100 c-file-style:"stroustrup"
101 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
102 indent-tabs-mode:nil
103 fill-column:99
104 End:
105*/
106// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
SPObject * getOwner() const
Returns a pointer to the URIReference's owner.
Interface for refcounted XML nodes.
Definition node.h:80
SPObject is an abstract base class of all of the document nodes at the SVG document level.
Definition sp-object.h:160
Inkscape::XML::Node * getRepr()
Returns the XML representation of tree.
void notifyChildRemoved(Inkscape::XML::Node &node, Inkscape::XML::Node &child, Inkscape::XML::Node *prev) override
Child removal callback.
void notifyChildAdded(Inkscape::XML::Node &node, Inkscape::XML::Node &child, Inkscape::XML::Node *prev) override
Child addition callback.
void notifyAttributeChanged(Inkscape::XML::Node &node, GQuark name, Inkscape::Util::ptr_shared old_value, Inkscape::Util::ptr_shared new_value) override
Attribute change callback.
std::unique_ptr< Inkscape::XML::Subtree > subtreeObserved
SPItem * getObject() const
void notifyChildOrderChanged(Inkscape::XML::Node &node, Inkscape::XML::Node &child, Inkscape::XML::Node *old_prev, Inkscape::XML::Node *new_prev) override
Child order change callback.
void notifyContentChanged(Inkscape::XML::Node &node, Inkscape::Util::ptr_shared old_content, Inkscape::Util::ptr_shared new_content) override
Content change callback.
bool _acceptObject(SPObject *obj) const override
unsigned int GQuark
void sp_tref_update_text(SPTRef *tref)
Definition sp-tref.cpp:371
SVG <tref> implementation, see sp-tref.cpp.