1 // SPDX-License-Identifier: GPL-2.0-or-later
2 #ifndef SP_TREF_H
3 #define SP_TREF_H
4 
5 /** \file
6  * SVG <tref> implementation, see sp-tref.cpp.
7  *
8  * This file was created based on skeleton.h
9  */
10 /*
11  * Authors:
12  *   Gail Banaszkiewicz <Gail.Banaszkiewicz@gmail.com>
13  *
14  * Copyright (C) 2007 Gail Banaszkiewicz
15  *
16  * Released under GNU GPL v2+, read the file 'COPYING' for more information.
17  */
18 
19 #include "sp-item.h"
20 #include "sp-tref-reference.h"
21 #include "text-tag-attributes.h"
22 
23 
24 /* tref base class */
25 
26 #define SP_TREF(obj) (dynamic_cast<SPTRef*>((SPObject*)obj))
27 #define SP_IS_TREF(obj) (dynamic_cast<const SPTRef*>((SPObject*)obj) != NULL)
28 
29 class SPTRef : public SPItem {
30 public:
31 	SPTRef();
32 	~SPTRef() override;
33 
34     // Attributes that are used in the same way they would be in a tspan
35     TextTagAttributes attributes;
36 
37     // Text stored in the xlink:href attribute
38     char *href;
39 
40     // URI reference to original object
41     SPTRefReference *uriOriginalRef;
42 
43     // Shortcut pointer to the child of the tref (which is a copy
44     // of the character data stored at and/or below the node
45     // referenced by uriOriginalRef)
46     SPObject *stringChild;
47 
48     // The sigc connections for various notifications
49     sigc::connection _delete_connection;
50     sigc::connection _changed_connection;
51 
52     SPObject * getObjectReferredTo();
53     SPObject const *getObjectReferredTo() const;
54 
55 	void build(SPDocument* doc, Inkscape::XML::Node* repr) override;
56 	void release() override;
57 	void set(SPAttr key, char const* value) override;
58 	void update(SPCtx* ctx, unsigned int flags) override;
59 	void modified(unsigned int flags) override;
60 	Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, guint flags) override;
61 
62 	Geom::OptRect bbox(Geom::Affine const &transform, SPItem::BBoxType type) const override;
63         const char* displayName() const override;
64 	char* description() const override;
65 };
66 
67 void sp_tref_update_text(SPTRef *tref);
68 bool sp_tref_reference_allowed(SPTRef *tref, SPObject *possible_ref);
69 bool sp_tref_fully_contained(SPObject *start_item, Glib::ustring::iterator &start,
70                              SPObject *end_item, Glib::ustring::iterator &end);
71 SPObject * sp_tref_convert_to_tspan(SPObject *item);
72 
73 
74 #endif /* !SP_TREF_H */
75 
76 /*
77   Local Variables:
78   mode:c++
79   c-file-style:"stroustrup"
80   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
81   indent-tabs-mode:nil
82   fill-column:99
83   End:
84 */
85 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
86