diff options
| author | Jabiertxo Arraiza Cenoz <jtx@jtx-desktop.markerlab.es> | 2018-01-03 18:34:35 +0000 |
|---|---|---|
| committer | Jabier Arraiza <jabier.arraiza@marker.es> | 2018-01-05 10:39:12 +0000 |
| commit | 68dadd1babd639df493fd2fe75065fb7cd4f4b15 (patch) | |
| tree | c665b68fb9cfe0df97dd5cb2153075eb66a91cb1 /src | |
| parent | Add suport to noty titled symbols sets with filename (diff) | |
| download | inkscape-68dadd1babd639df493fd2fe75065fb7cd4f4b15.tar.gz inkscape-68dadd1babd639df493fd2fe75065fb7cd4f4b15.zip | |
Do not parse visio files, use filename
Diffstat (limited to 'src')
| -rw-r--r-- | src/ui/dialog/symbols.cpp | 120 |
1 files changed, 71 insertions, 49 deletions
diff --git a/src/ui/dialog/symbols.cpp b/src/ui/dialog/symbols.cpp index 8f2e19978..650a19728 100644 --- a/src/ui/dialog/symbols.cpp +++ b/src/ui/dialog/symbols.cpp @@ -812,28 +812,39 @@ void SymbolsDialog::getSymbolsTitle() { number_docs = 0; std::regex matchtitle (".*?<title.*?>(.*?)<(/| /)"); for(auto &filename: get_filenames(SYMBOLS, {".svg", ".vss"})) { - std::ifstream infile(filename); - std::string line; - while (std::getline(infile, line)) { - std::string title_res = std::regex_replace (line, matchtitle,"$1",std::regex_constants::format_no_copy); - if (!title_res.empty()) { - symbol_sets[ellipsize(Glib::ustring(title_res), 33)]= NULL; - ++number_docs; - break; - } - std::string::size_type position_exit = line.find ("<defs"); - if (position_exit != std::string::npos) { - std::size_t found = filename.find_last_of("/\\"); - filename = filename.substr(found+1); - title = filename.erase(filename.rfind('.')); - if(title.empty()) { - title = _("Unnamed Symbols"); - } - symbol_sets[title]= NULL; - ++number_docs; - break; - } - } + if(Glib::str_has_suffix(filename, ".vss")) { + std::size_t found = filename.find_last_of("/\\"); + filename = filename.substr(found+1); + title = filename.erase(filename.rfind('.')); + if(title.empty()) { + title = _("Unnamed Symbols"); + } + symbol_sets[title]= NULL; + ++number_docs; + } else { + std::ifstream infile(filename); + std::string line; + while (std::getline(infile, line)) { + std::string title_res = std::regex_replace (line, matchtitle,"$1",std::regex_constants::format_no_copy); + if (!title_res.empty()) { + symbol_sets[ellipsize(Glib::ustring(title_res), 33)]= NULL; + ++number_docs; + break; + } + std::string::size_type position_exit = line.find ("<defs"); + if (position_exit != std::string::npos) { + std::size_t found = filename.find_last_of("/\\"); + filename = filename.substr(found+1); + title = filename.erase(filename.rfind('.')); + if(title.empty()) { + title = _("Unnamed Symbols"); + } + symbol_sets[title]= NULL; + ++number_docs; + break; + } + } + } } for(auto const &symbol_document_map : symbol_sets) { symbol_set->append(symbol_document_map.first); @@ -864,35 +875,46 @@ SymbolsDialog::getSymbolsSet(Glib::ustring title) std::regex matchtitle (".*?<title.*?>(.*?)<(/| /)"); for(auto &filename: get_filenames(SYMBOLS, {".svg", ".vss"})) { - std::ifstream infile(filename); - std::string line; - while (std::getline(infile, line)) { - std::string title_res = std::regex_replace (line, matchtitle,"$1",std::regex_constants::format_no_copy); - if (!title_res.empty()) { - new_title = ellipsize(Glib::ustring(title_res), 33); - } - std::size_t pos = filename.find_last_of("/\\"); - Glib::ustring filename_short = ""; - if (pos != std::string::npos) { - filename_short = filename.substr(pos+1); - } - if (title == new_title || filename_short == title + ".svg") { - new_title = title; - if(Glib::str_has_suffix(filename, ".svg")) { - symbol_doc = SPDocument::createNewDoc(filename.c_str(), FALSE); - } + if(Glib::str_has_suffix(filename, ".vss")) { + std::size_t pos = filename.find_last_of("/\\"); + Glib::ustring filename_short = ""; + if (pos != std::string::npos) { + filename_short = filename.substr(pos+1); + } + if (filename_short == title + ".svg") { + new_title = title; #ifdef WITH_LIBVISIO - if(Glib::str_has_suffix(filename, ".vss")) { - symbol_doc = read_vss(filename, title); - } + if(Glib::str_has_suffix(filename, ".vss")) { + symbol_doc = read_vss(filename, title); + } #endif - } - if (symbol_doc) { - break; - } - std::string::size_type position_exit = line.find ("<defs"); - if (position_exit != std::string::npos) { - break; + } + } else { + std::ifstream infile(filename); + std::string line; + while (std::getline(infile, line)) { + std::string title_res = std::regex_replace (line, matchtitle,"$1",std::regex_constants::format_no_copy); + if (!title_res.empty()) { + new_title = ellipsize(Glib::ustring(title_res), 33); + } + std::size_t pos = filename.find_last_of("/\\"); + Glib::ustring filename_short = ""; + if (pos != std::string::npos) { + filename_short = filename.substr(pos+1); + } + if (title == new_title || filename_short == title + ".svg") { + new_title = title; + if(Glib::str_has_suffix(filename, ".svg")) { + symbol_doc = SPDocument::createNewDoc(filename.c_str(), FALSE); + } + } + if (symbol_doc) { + break; + } + std::string::size_type position_exit = line.find ("<defs"); + if (position_exit != std::string::npos) { + break; + } } } if (symbol_doc) { |
