diff options
| author | Jabiertxof <jabier.arraiza@marker.es> | 2019-06-19 11:03:46 +0000 |
|---|---|---|
| committer | Jabier Arraiza <jabier.arraiza@marker.es> | 2019-07-08 21:04:12 +0000 |
| commit | 08b64685a1a55a681ded366c680817b6d92646ea (patch) | |
| tree | 92ba04750a866dcdb7f7e6549fd0bad5c6b5e1a6 /src/ui/dialog/styledialog.cpp | |
| parent | Fixing coding style (diff) | |
| download | inkscape-08b64685a1a55a681ded366c680817b6d92646ea.tar.gz inkscape-08b64685a1a55a681ded366c680817b6d92646ea.zip | |
Add initial commit
Diffstat (limited to 'src/ui/dialog/styledialog.cpp')
| -rw-r--r-- | src/ui/dialog/styledialog.cpp | 53 |
1 files changed, 36 insertions, 17 deletions
diff --git a/src/ui/dialog/styledialog.cpp b/src/ui/dialog/styledialog.cpp index d867bce76..d89114ca5 100644 --- a/src/ui/dialog/styledialog.cpp +++ b/src/ui/dialog/styledialog.cpp @@ -23,6 +23,8 @@ #include "style-internal.h" #include "style.h" #include "svg/svg-color.h" +#include "object/sp-style-elem.h" +#include "object/sp-root.h" #include "ui/icon-loader.h" #include "ui/widget/iconrenderer.h" #include "verbs.h" @@ -266,27 +268,22 @@ Inkscape::XML::Node *StyleDialog::_getStyleTextNode() Inkscape::XML::Node *textNode = nullptr; Inkscape::XML::Node *root = SP_ACTIVE_DOCUMENT->getReprRoot(); - bool first = false; for (unsigned i = 0; i < root->childCount(); ++i) { if (Glib::ustring(root->nthChild(i)->name()) == "svg:style") { styleNode = root->nthChild(i); - if (!first) { - for (unsigned j = 0; j < styleNode->childCount(); ++j) { - if (styleNode->nthChild(j)->type() == Inkscape::XML::TEXT_NODE) { - textNode = styleNode->nthChild(j); - } - } - - if (textNode == nullptr) { - // Style element found but does not contain text node! - std::cerr << "StyleDialog::_getStyleTextNode(): No text node!" << std::endl; - textNode = SP_ACTIVE_DOCUMENT->getReprDoc()->createTextNode(""); - styleNode->appendChild(textNode); - Inkscape::GC::release(textNode); + for (unsigned j = 0; j < styleNode->childCount(); ++j) { + if (styleNode->nthChild(j)->type() == Inkscape::XML::TEXT_NODE) { + textNode = styleNode->nthChild(j); } - first = true; } - styleNode->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG); + if (textNode == nullptr) { + // Style element found but does not contain text node! + std::cerr << "StyleDialog::_getStyleTextNode(): No text node!" << std::endl; + textNode = SP_ACTIVE_DOCUMENT->getReprDoc()->createTextNode(""); + styleNode->appendChild(textNode); + Inkscape::GC::release(textNode); + } + break; } } @@ -311,6 +308,23 @@ Inkscape::XML::Node *StyleDialog::_getStyleTextNode() return textNode; } +/** + * Ditto for update stylesheets. + */ +void StyleDialog::_updateStyleSheets() +{ + SPDocument *document = SP_ACTIVE_DOCUMENT; + document->setStyleSheet(nullptr); + Inkscape::XML::Node *root = document->getReprRoot(); + for (unsigned i = 0; i < root->childCount(); --i) { + gchar const * name = root->nthChild(i)->name(); + if (name && strcmp(name,"svg:style") == 0) { + SPStyleElem *styleelem = dynamic_cast<SPStyleElem *>(document->getObjectByRepr(root->nthChild(i))); + styleelem->read_content(); + } + } + document->getRoot()->emitModified( SP_OBJECT_MODIFIED_CASCADE ); +} Glib::RefPtr<Gtk::TreeModel> StyleDialog::_selectTree(Glib::ustring selector) { @@ -1003,11 +1017,16 @@ void StyleDialog::_writeStyleElement(Glib::RefPtr<Gtk::TreeStore> store, Glib::u std::string result; std::regex_replace(std::back_inserter(result), content.begin(), content.end(), e, "$1" + styleContent + "$3"); textNode->setContent(result.c_str()); +<<<<<<< HEAD INKSCAPE.readStyleSheets(true); for (auto iter : document->getObjectsBySelector(selector)) { +======= + _updateStyleSheets(); + /* for (auto iter : document->getObjectsBySelector(selector)) { +>>>>>>> Add initial commit iter->style->readFromObject(iter); iter->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG); - } + } */ } _updating = false; _readStyleElement(); |
