]> git.lyx.org Git - lyx.git/blobdiff - src/LyXRC.cpp
Routines for calculating numerical labels for BibTeX citations.
[lyx.git] / src / LyXRC.cpp
index 92850061d03a4e5e68a0f56a615b21b63f18832a..ece84acc8e8d97bd914471cc2c88c0701fff99bf 100644 (file)
@@ -277,7 +277,13 @@ void LyXRC::setDefaults()
        backupdir_path.erase();
        display_graphics = true;
        // Spellchecker settings:
+#if defined(USE_ASPELL)
        spellchecker = "aspell";
+#elif defined(USE_HUNSPELL)
+       spellchecker = "hunspell";
+#else
+       spellchecker = "aspell";
+#endif
        spellchecker_accept_compound = false;
        spellcheck_continuously = false;
        use_kbmap = false;
@@ -1044,13 +1050,13 @@ int LyXRC::read(Lexer & lexrc)
                                format = lexrc.getString();
                        if (lexrc.eatLine())
                                command = lexrc.getString();
-                       viewer_alternatives.push_back(make_pair(format, command));
+                       viewer_alternatives[format].insert(command);
                        break;
                }
                case RC_EDITOR_ALTERNATIVES:  {
                        string format, command;
                        lexrc >> format >> command;
-                       editor_alternatives.push_back(make_pair(format, command));
+                       editor_alternatives[format].insert(command);
                        break;
                }
 
@@ -1393,8 +1399,8 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c
                if (tag != RC_LAST)
                        break;
        case RC_BIBTEX_ALTERNATIVES: {
-               set<string>::const_iterator it = bibtex_alternatives.begin();
-               set<string>::const_iterator end = bibtex_alternatives.end();
+               CommandSet::const_iterator it = bibtex_alternatives.begin();
+               CommandSet::const_iterator end = bibtex_alternatives.end();
                for ( ; it != end; ++it) {
                        if (ignore_system_lyxrc
                            || !system_lyxrc.bibtex_alternatives.count(*it))
@@ -1419,8 +1425,8 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c
                if (tag != RC_LAST)
                        break;
        case RC_INDEX_ALTERNATIVES: {
-               set<string>::const_iterator it = index_alternatives.begin();
-               set<string>::const_iterator end = index_alternatives.end();
+               CommandSet::const_iterator it = index_alternatives.begin();
+               CommandSet::const_iterator end = index_alternatives.end();
                for ( ; it != end; ++it) {
                        if (ignore_system_lyxrc
                            || !system_lyxrc.index_alternatives.count(*it))
@@ -2491,26 +2497,56 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c
                                   << "\" \"\" \"\" \"\" \"\" \"\" \"\"\n";
                if (tag != RC_LAST)
                        break;
-       case RC_VIEWER_ALTERNATIVES:
-               if (ignore_system_lyxrc ||
-                   viewer_alternatives != system_lyxrc.viewer_alternatives) {
-                       for (vector<pair<string, string> >::const_iterator it = viewer_alternatives.begin();
-                            it != viewer_alternatives.end(); ++it)
-                       os << "\\viewer_alternatives "
-                          << it->first << " " << it->second << "\n";
+       case RC_VIEWER_ALTERNATIVES: {
+               Alternatives::const_iterator it = viewer_alternatives.begin();
+               Alternatives::const_iterator const en = viewer_alternatives.end();
+               Alternatives::const_iterator const sysend = 
+                               system_lyxrc.viewer_alternatives.end();
+               for (; it != en; ++it) {
+                       string const & fmt = it->first;
+                       CommandSet const & cmd = it->second;
+                       CommandSet::const_iterator sit = cmd.begin();
+                       CommandSet::const_iterator const sen = cmd.end();
+                       Alternatives::const_iterator const sysfmt = ignore_system_lyxrc ? 
+                                       system_lyxrc.viewer_alternatives.begin() : // we won't use it in this case
+                                       system_lyxrc.viewer_alternatives.find(fmt);
+                       for (; sit != sen; ++sit) {
+                               string const & cmd = *sit;
+                               if (ignore_system_lyxrc 
+                                   || sysfmt == sysend               // format not found
+                                        || sysfmt->second.count(cmd) == 0 // this command not found
+                                  )
+                                       os << "\\viewer_alternatives " << fmt << " " << cmd << "\n";
+                       }
                }
                if (tag != RC_LAST)
                        break;
-       case RC_EDITOR_ALTERNATIVES:
-               if (ignore_system_lyxrc ||
-                   editor_alternatives != system_lyxrc.editor_alternatives) {
-                       for (vector<pair<string, string> >::const_iterator it = editor_alternatives.begin();
-                            it != editor_alternatives.end(); ++it)
-                       os << "\\editor_alternatives "
-                          << it->first << " " << it->second << "\n";
+       }
+       case RC_EDITOR_ALTERNATIVES: {
+               Alternatives::const_iterator it = editor_alternatives.begin();
+               Alternatives::const_iterator const en = editor_alternatives.end();
+               Alternatives::const_iterator const sysend = 
+                               system_lyxrc.editor_alternatives.end();
+               for (; it != en; ++it) {
+                       string const & fmt = it->first;
+                       CommandSet const & cmd = it->second;
+                       CommandSet::const_iterator sit = cmd.begin();
+                       CommandSet::const_iterator const sen = cmd.end();
+                       Alternatives::const_iterator const sysfmt = ignore_system_lyxrc ? 
+                                       system_lyxrc.editor_alternatives.begin() : // we won't use it in this case
+                                       system_lyxrc.editor_alternatives.find(fmt);
+                       for (; sit != sen; ++sit) {
+                               string const & cmd = *sit;
+                               if (ignore_system_lyxrc 
+                                   || sysfmt == sysend               // format not found
+                                   || sysfmt->second.count(cmd) == 0 // this command not found
+                                  )
+                                       os << "\\editor_alternatives " << fmt << " " << cmd << "\n";
+                       }
                }
                if (tag != RC_LAST)
                        break;
+       }
        case RC_DEFAULT_VIEW_FORMAT:
                if (ignore_system_lyxrc ||
                    default_view_format != system_lyxrc.default_view_format) {