diff options
| author | Tavmjong Bah <> | 2016-07-13 02:42:57 +0000 |
|---|---|---|
| committer | kamalpreetgrewal <grewalkamal005@gmail.com> | 2016-07-13 02:42:57 +0000 |
| commit | 798cda4430354143e90fb7ce81c3593a6dc24bc5 (patch) | |
| tree | 0daf3d324bf8f2ebc0ac3300bdcb6fff3a6251ad /src/sp-style-elem.cpp | |
| parent | Merge changes from trunk (diff) | |
| download | inkscape-798cda4430354143e90fb7ce81c3593a6dc24bc5.tar.gz inkscape-798cda4430354143e90fb7ce81c3593a6dc24bc5.zip | |
Propagate changes to object tree with changes in style element
(bzr r14949.1.46)
Diffstat (limited to 'src/sp-style-elem.cpp')
| -rw-r--r-- | src/sp-style-elem.cpp | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/src/sp-style-elem.cpp b/src/sp-style-elem.cpp index 80e45677c..0f5af619b 100644 --- a/src/sp-style-elem.cpp +++ b/src/sp-style-elem.cpp @@ -3,6 +3,7 @@ #include "xml/repr.h" #include "document.h" #include "sp-style-elem.h" +#include "sp-root.h" #include "attributes.h" #include "style.h" using Inkscape::XML::TEXT_NODE; @@ -64,6 +65,7 @@ content_changed_cb(Inkscape::XML::Node *, gchar const *, gchar const *, SPObject *obj = reinterpret_cast<SPObject *>(data); g_assert(data != NULL); obj->read_content(); + obj->document->getRoot()->emitModified( SP_OBJECT_MODIFIED_CASCADE ); } static void @@ -249,6 +251,19 @@ property_cb(CRDocHandler *const a_handler, g_return_if_fail(append_status == CR_OK); } +void update_style_recursively( SPObject *object ) { + if (object) { + // std::cout << "update_style_recursively: " + // << (object->getId()?object->getId():"null") << std::endl; + if (object->style) { + object->style->readFromObject( object ); + } + for (SPObject *child = object->children; child; child = child->next) { + update_style_recursively( child ); + } + } +} + void SPStyleElem::read_content() { /* fixme: If there's more than one <style> element in a document, then the document stylesheet * will be set to a random one of them, even switching between them. @@ -315,9 +330,13 @@ void SPStyleElem::read_content() { // the <style> is a child of the object that uses a style from it. It just forces the parent of // <style> to reread its style as soon as the stylesheet is fully loaded. Naturally, this won't // work if the user of the stylesheet is its grandparent or precedent. - if ( parent ) { - parent->style->readFromObject( parent ); - } + // if ( parent ) { + // parent->style->readFromObject( parent ); + // } + + // If style sheet has changed, we need to cascade the entire object tree, top down + // Get root, read style, loop through children + update_style_recursively( (SPObject *)document->getRoot() ); } /** |
