summaryrefslogtreecommitdiffstats
path: root/src/sp-tref-reference.cpp
diff options
context:
space:
mode:
authorRichard Hughes <cyreve@gmail.com>2007-07-11 21:44:47 +0000
committercyreve <cyreve@users.sourceforge.net>2007-07-11 21:44:47 +0000
commit0a0ca7dcf7791fe236ea233c0622ccc40ee0c175 (patch)
tree3ab83295f558b8c66e6a8c6c4f1ca79a9dde4efa /src/sp-tref-reference.cpp
parentMove 3D axis manipulation functions to separate file (diff)
downloadinkscape-0a0ca7dcf7791fe236ea233c0622ccc40ee0c175.tar.gz
inkscape-0a0ca7dcf7791fe236ea233c0622ccc40ee0c175.zip
bug 1243190: add tref element support; limited editing support thus far (patch by gbanaszk)
(bzr r3227)
Diffstat (limited to '')
-rw-r--r--src/sp-tref-reference.cpp108
1 files changed, 108 insertions, 0 deletions
diff --git a/src/sp-tref-reference.cpp b/src/sp-tref-reference.cpp
new file mode 100644
index 000000000..f3b6ef329
--- /dev/null
+++ b/src/sp-tref-reference.cpp
@@ -0,0 +1,108 @@
+/*
+ * 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, read the file 'COPYING' for more information.
+ */
+
+//#include "enums.h"
+#include "sp-tref-reference.h"
+
+#include "sp-text.h"
+#include "sp-tref.h"
+#include "sp-tspan.h"
+
+
+
+bool SPTRefReference::_acceptObject(SPObject * const obj) const
+{
+ SPObject *owner = getOwner();
+ if (SP_IS_TREF(owner))
+ return sp_tref_reference_allowed(SP_TREF(getOwner()), obj);
+ else
+ return false;
+}
+
+
+void SPTRefReference::updateObserver()
+{
+ SPObject *referred = getObject();
+
+ if (referred) {
+ if (subtreeObserved) {
+ subtreeObserved->removeObserver(*this);
+ delete subtreeObserved;
+ }
+
+ subtreeObserved = new Inkscape::XML::Subtree(*SP_OBJECT_REPR(referred));
+ 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<char> old_content,
+ Inkscape::Util::ptr_shared<char> 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<char> old_value,
+ Inkscape::Util::ptr_shared<char> 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 :