From 68dadd1babd639df493fd2fe75065fb7cd4f4b15 Mon Sep 17 00:00:00 2001 From: Jabiertxo Arraiza Cenoz Date: Wed, 3 Jan 2018 19:34:35 +0100 Subject: Do not parse visio files, use filename --- src/ui/dialog/symbols.cpp | 120 +++++++++++++++++++++++++++------------------- 1 file changed, 71 insertions(+), 49 deletions(-) (limited to 'src') 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 (".*?(.*?)<(/| /)"); 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 ("append(symbol_document_map.first); @@ -864,35 +875,46 @@ SymbolsDialog::getSymbolsSet(Glib::ustring title) std::regex matchtitle (".*?(.*?)<(/| /)"); 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 ("