diff options
| author | Tavmjong Bah <tavmjong@free.fr> | 2019-09-06 09:10:24 +0000 |
|---|---|---|
| committer | Tavmjong Bah <tavmjong@free.fr> | 2019-09-06 09:10:24 +0000 |
| commit | 8a2c433d2042c1389dbc235278d20e70e3b92c0d (patch) | |
| tree | 0acf40642441c89d2ea77bdc947a5a44cebf5c57 /src/style-internal.cpp | |
| parent | Fix error in GTK launch script (diff) | |
| download | inkscape-8a2c433d2042c1389dbc235278d20e70e3b92c0d.tar.gz inkscape-8a2c433d2042c1389dbc235278d20e70e3b92c0d.zip | |
Add listeners for when shapes used by text are changed.
Diffstat (limited to 'src/style-internal.cpp')
| -rw-r--r-- | src/style-internal.cpp | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/src/style-internal.cpp b/src/style-internal.cpp index 15c080d62..6a8ff6f89 100644 --- a/src/style-internal.cpp +++ b/src/style-internal.cpp @@ -35,6 +35,8 @@ #include "streq.h" #include "strneq.h" +#include "object/sp-text.h" + #include "svg/svg.h" #include "svg/svg-color.h" #include "svg/css-ostringstream.h" @@ -1099,6 +1101,61 @@ SPIString::operator==(const SPIBase& rhs) { } +// SPIShapes ------------------------------------------------------------ + +// Used to add/remove listeners for text wrapped in shapes. +// Note: this is done differently than for patterns, etc. where presentation attributes can be used. +// 'shape-inside' and 'shape-subtract' are only properties. +void +SPIShapes::read( gchar const *str) { + + if (!style) { + std::cerr << "SPIShapes::read: no style!" << std::endl; + return; + } + + if( !str ) return; + + set = true; + inherit = false; + value = g_strdup(str); + + // The object/repr this property is connected to.. + SPObject* object = style->object; + SPDocument* document = object->document; + Inkscape::XML::Node *text_repr = object->getRepr(); + + // Clear previously set listeners + for (auto shape_id : shape_ids) { + SPObject* shape_object = document->getObjectById (shape_id); + if (shape_object) { + Inkscape::XML::Node *shape_node = shape_object->getRepr(); + shape_node->removeListenerByData(object); + } + } + shape_ids.clear(); + + // Add new listeners + std::vector<Glib::ustring> shapes_url = Glib::Regex::split_simple(" ", str); + for (auto shape_url : shapes_url) { + + if ( shape_url.compare(0,5,"url(#") != 0 || shape_url.compare(shape_url.size()-1,1,")") != 0 ){ + std::cerr << "SPIShapes::read: Invalid shape value: " << shape_url << std::endl; + } else { + shape_url.erase(0,5); + shape_url.erase(shape_url.size()-1,1); + + shape_ids.push_back(shape_url); + + SPObject* shape_object = document->getObjectById (shape_url); + if (shape_object) { + Inkscape::XML::Node *shape_node = shape_object->getRepr(); + shape_node->addListener(&text_shape_events, object); + } + } + } +} + // SPIColor ------------------------------------------------------------- |
