diff options
| author | kamalpreetgrewal <grewalkamal005@gmail.com> | 2016-06-13 06:57:11 +0000 |
|---|---|---|
| committer | kamalpreetgrewal <grewalkamal005@gmail.com> | 2016-06-13 06:57:11 +0000 |
| commit | b9f56542de1f33e8ac45325653dcac11691e3e47 (patch) | |
| tree | acfd3c6c90ac1d2d0deec2c84e8068f431fd6190 /src/ui/dialog/styledialog.cpp | |
| parent | Merge changes from trunk (diff) | |
| download | inkscape-b9f56542de1f33e8ac45325653dcac11691e3e47.tar.gz inkscape-b9f56542de1f33e8ac45325653dcac11691e3e47.zip | |
Correct parsing of style element
(bzr r14949.1.14)
Diffstat (limited to 'src/ui/dialog/styledialog.cpp')
| -rw-r--r-- | src/ui/dialog/styledialog.cpp | 67 |
1 files changed, 40 insertions, 27 deletions
diff --git a/src/ui/dialog/styledialog.cpp b/src/ui/dialog/styledialog.cpp index 14213f97d..9abcc1562 100644 --- a/src/ui/dialog/styledialog.cpp +++ b/src/ui/dialog/styledialog.cpp @@ -19,6 +19,8 @@ using Inkscape::Util::List; using Inkscape::XML::AttributeRecord; +#define REMOVE_SPACES(x) x.erase(std::remove(x.begin(), x.end(), ' '), x.end()); + namespace Inkscape { namespace UI { namespace Dialog { @@ -181,8 +183,8 @@ void StyleDialog::_addSelector() if ( std::string(property) == "style" ) { - selectorValue = row[_mColumns._selectorLabel] + "{" + - "\n" + std::string(value) + "\n" + "}"; + selectorValue = "\n" + row[_mColumns._selectorLabel] + "{" + + std::string(value) + "}"; } } @@ -223,10 +225,10 @@ void StyleDialog::_delSelector() if (iter) { Gtk::TreeModel::Row row = *iter; - for( unsigned it = 0; it < selMap.size(); ++it ) { - std::string key = strtok(strdup(_document->getReprRoot() - ->nthChild(it) - ->firstChild()->content()), " "); +// for( unsigned it = 0; it < selMap.size(); ++it ) { +// std::string key = strtok(strdup(_document->getReprRoot() +// ->nthChild(it) +// ->firstChild()->content()), "{"); /** * @brief toDeleteNode @@ -235,22 +237,22 @@ void StyleDialog::_delSelector() * saved to a map. Keys of this map and labels of selected rows of * dialog are compared and deleted. */ - Inkscape::XML::Node *toDeleteNode = _document->getReprRoot()->nthChild(it); - std::map<std::string, Inkscape::XML::Node*>toDeleteMap; - toDeleteMap[key] = toDeleteNode; - - for( std::map<std::string, Inkscape::XML::Node*>::iterator i = - toDeleteMap.begin(); i != toDeleteMap.end(); ++i ) { - if( row[_mColumns._selectorLabel] == i->first) - { - std::cout << i->second->name() << std::endl; - /** - This should work but uncommenting it causes a crash currently. - */ - //_document->getReprRoot()->removeChild(toDeleteNode); - } - } - } +// Inkscape::XML::Node *toDeleteNode = _document->getReprRoot()->nthChild(it); +// std::map<std::string, Inkscape::XML::Node*>toDeleteMap; +// toDeleteMap[key] = toDeleteNode; + +// for( std::map<std::string, Inkscape::XML::Node*>::iterator i = +// toDeleteMap.begin(); i != toDeleteMap.end(); ++i ) { +// if( row[_mColumns._selectorLabel] == i->first) +// { +// std::cout << i->second->name() << std::endl; +// /** +// This should work but uncommenting it causes a crash currently. +// */ +// //_document->getReprRoot()->removeChild(toDeleteNode); +// } +// } +// } _store->erase(row); } } @@ -290,11 +292,22 @@ std::map<std::string, std::string>StyleDialog::_getSelectorMap() { if ( std::string(_document->getReprRoot()->nthChild(i)->name()) == "svg:style" ) { - char *str = strdup(_document->getReprRoot()->nthChild(i)->firstChild() - ->content()); - key = strtok(str, " "); - value = strtok(NULL, ""); - selMap[key] = value; + std::stringstream str; + str << _document->getReprRoot()->nthChild(i)->firstChild()->content(); + std::string sel; + + while (str != NULL) + { + while(std::getline(str, sel, '\n')){ + REMOVE_SPACES(sel); + if (!sel.empty()) + { + key = strtok(strdup(sel.c_str()), "{"); + value = strtok(NULL, "}"); + selMap[key] = value; + } + } + } } } |
