summaryrefslogtreecommitdiffstats
path: root/src/object/sp-tref-reference.cpp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:24:48 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:24:48 +0000
commitcca66b9ec4e494c1d919bff0f71a820d8afab1fa (patch)
tree146f39ded1c938019e1ed42d30923c2ac9e86789 /src/object/sp-tref-reference.cpp
parentInitial commit. (diff)
downloadinkscape-cca66b9ec4e494c1d919bff0f71a820d8afab1fa.tar.xz
inkscape-cca66b9ec4e494c1d919bff0f71a820d8afab1fa.zip
Adding upstream version 1.2.2.upstream/1.2.2upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/object/sp-tref-reference.cpp')
-rw-r--r--src/object/sp-tref-reference.cpp107
1 files changed, 107 insertions, 0 deletions
diff --git a/src/object/sp-tref-reference.cpp b/src/object/sp-tref-reference.cpp
new file mode 100644
index 0000000..798e74a
--- /dev/null
+++ b/src/object/sp-tref-reference.cpp
@@ -0,0 +1,107 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * The reference corresponding to href of <tref> element.
+ *
+ * Copyright (C) 2007 Gail Banaszkiewicz
+ *
+ * This file was created based on sp-use-reference.cpp
+ *
+ * Released under GNU GPL v2+, read the file 'COPYING' for more information.
+ */
+
+//#include "enums.h"
+#include "sp-tref-reference.h"
+
+#include "sp-text.h"
+#include "sp-tref.h"
+
+
+bool SPTRefReference::_acceptObject(SPObject * const obj) const
+{
+ SPObject *owner = getOwner();
+ if (SP_IS_TREF(owner))
+ return URIReference::_acceptObject(obj);
+ else
+ return false;
+}
+
+
+void SPTRefReference::updateObserver()
+{
+ SPObject *referred = getObject();
+
+ if (referred) {
+ if (subtreeObserved) {
+ subtreeObserved->removeObserver(*this);
+ delete subtreeObserved;
+ }
+
+ subtreeObserved = new Inkscape::XML::Subtree(*referred->getRepr());
+ subtreeObserved->addObserver(*this);
+ }
+}
+
+
+void SPTRefReference::notifyChildAdded(Inkscape::XML::Node &/*node*/, Inkscape::XML::Node &/*child*/,
+ Inkscape::XML::Node */*prev*/)
+{
+ SPObject *owner = getOwner();
+
+ if (owner && SP_IS_TREF(owner)) {
+ sp_tref_update_text(SP_TREF(owner));
+ }
+}
+
+
+void SPTRefReference::notifyChildRemoved(Inkscape::XML::Node &/*node*/, Inkscape::XML::Node &/*child*/,
+ Inkscape::XML::Node */*prev*/)
+{
+ SPObject *owner = getOwner();
+
+ if (owner && SP_IS_TREF(owner)) {
+ sp_tref_update_text(SP_TREF(owner));
+ }
+}
+
+
+void SPTRefReference::notifyChildOrderChanged(Inkscape::XML::Node &/*node*/, Inkscape::XML::Node &/*child*/,
+ Inkscape::XML::Node */*old_prev*/, Inkscape::XML::Node */*new_prev*/)
+{
+ SPObject *owner = getOwner();
+
+ if (owner && SP_IS_TREF(owner)) {
+ sp_tref_update_text(SP_TREF(owner));
+ }
+}
+
+
+void SPTRefReference::notifyContentChanged(Inkscape::XML::Node &/*node*/,
+ Inkscape::Util::ptr_shared /*old_content*/,
+ Inkscape::Util::ptr_shared /*new_content*/)
+{
+ SPObject *owner = getOwner();
+
+ if (owner && SP_IS_TREF(owner)) {
+ sp_tref_update_text(SP_TREF(owner));
+ }
+}
+
+
+void SPTRefReference::notifyAttributeChanged(Inkscape::XML::Node &/*node*/, GQuark /*name*/,
+ Inkscape::Util::ptr_shared /*old_value*/,
+ Inkscape::Util::ptr_shared /*new_value*/)
+{
+ // Do nothing - tref only cares about textual content
+}
+
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :