]> git.lyx.org Git - lyx.git/blobdiff - src/LyXRC.cpp
tex2lyx/text.cpp: code simplification
[lyx.git] / src / LyXRC.cpp
index 35e51bcec1a68d03169a6e31d7d47cf202a4b277..b678af0a8bc72c37c8977c178029765412695cc3 100644 (file)
@@ -26,6 +26,7 @@
 #include "LyX.h"
 #include "Mover.h"
 #include "Session.h"
+#include "SpellChecker.h"
 #include "version.h"
 
 #include "graphics/GraphicsTypes.h"
@@ -54,7 +55,7 @@ namespace os = support::os;
 
 namespace {
 
-static unsigned int const LYXRC_FILEFORMAT = 1;
+static unsigned int const LYXRC_FILEFORMAT = 3;
 
 // when adding something to this array keep it sorted!
 LexerKeyword lyxrcTags[] = {
@@ -401,11 +402,15 @@ bool LyXRC::read(FileName const & filename, bool check_format)
                LYXERR0 ("Unable to convert " << filename.absFileName() <<
                        " to format " << LYXRC_FILEFORMAT);
                return false;
+       } else {
+               // Keep this in the else branch, such that lexrc2 goes out
+               // of scope and releases the lock on tempfile before we
+               // attempt to remove it. This matters on Windows.
+               Lexer lexrc2(lyxrcTags);
+               lexrc2.setFile(tempfile);
+               LYXERR(Debug::LYXRC, "Reading '" << tempfile << "'...");
+               retval = read(lexrc2, check_format);
        }
-       Lexer lexrc2(lyxrcTags);
-       lexrc2.setFile(tempfile);
-       LYXERR(Debug::LYXRC, "Reading '" << tempfile << "'...");
-       retval = read(lexrc2, check_format);
        tempfile.removeFile();
        return retval == ReadOK;
 }
@@ -1087,8 +1092,8 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc, bool check_format)
                        break;
                }
                case RC_FILEFORMAT: {
-                       string format, extension, prettyname, shortcut;
-                       lexrc >> format >> extension >> prettyname >> shortcut;
+                       string format, extensions, prettyname, shortcut;
+                       lexrc >> format >> extensions >> prettyname >> shortcut;
                        string viewer, editor;
                        if (lexrc.next(true))
                                viewer = lexrc.getString();
@@ -1117,6 +1122,8 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc, bool check_format)
                                        flgs |= Format::document;
                                else if (flag == "vector")
                                        flgs |= Format::vector;
+                               else if (flag == "zipped=native")
+                                       flgs |= Format::zipped_native;
                                else if (flag == "menu=export")
                                        flgs |= Format::export_menu;
                                else
@@ -1130,7 +1137,7 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc, bool check_format)
                                else
                                        formats.erase(format);
                        } else {
-                               formats.add(format, extension, prettyname,
+                               formats.add(format, extensions, prettyname,
                                            shortcut, viewer, editor, flgs);
                        }
                        break;
@@ -1612,8 +1619,9 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c
                if (tag != RC_LAST)
                        break;
        case RC_TEX_EXPECTS_WINDOWS_PATHS:
-               if (ignore_system_lyxrc ||
-                   windows_style_tex_paths != system_lyxrc.windows_style_tex_paths) {
+               // Don't write this setting to the preferences file,
+               // but allow temporary changes (bug 7557).
+               if (ignore_system_lyxrc) {
                        os << "\\tex_expects_windows_paths "
                           << convert<string>(windows_style_tex_paths) << '\n';
                }
@@ -2729,7 +2737,7 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c
                        Format const * format =
                                system_formats.getFormat(cit->name());
                        if (!format ||
-                           format->extension() != cit->extension() ||
+                           format->extensions() != cit->extensions() ||
                            format->prettyname() != cit->prettyname() ||
                            format->shortcut() != cit->shortcut() ||
                            format->viewer() != cit->viewer() ||
@@ -2738,7 +2746,7 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c
                            format->vectorFormat() != cit->vectorFormat() ||
                            format->inExportMenu() != cit->inExportMenu()) {
                                os << "\\format \"" << cit->name() << "\" \""
-                                  << cit->extension() << "\" \""
+                                  << cit->extensions() << "\" \""
                                   << cit->prettyname() << "\" \""
                                   << cit->shortcut() << "\" \""
                                   << escapeCommand(cit->viewer()) << "\" \""
@@ -2748,6 +2756,8 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c
                                        flags.push_back("document");
                                if (cit->vectorFormat())
                                        flags.push_back("vector");
+                               if (cit->zippedNative())
+                                       flags.push_back("zipped=native");
                                if (cit->inExportMenu())
                                        flags.push_back("menu=export");
 
@@ -2902,6 +2912,8 @@ void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new)
        switch (tag) {
        case LyXRC::RC_LAST:
        case LyXRC::RC_ACCEPT_COMPOUND:
+               if (lyxrc_orig.spellchecker_accept_compound != lyxrc_new.spellchecker_accept_compound)
+                       if (theSpellChecker()) theSpellChecker()->advanceChangeNumber();
        case LyXRC::RC_ALT_LANG:
        case LyXRC::RC_PLAINTEXT_LINELEN:
        case LyXRC::RC_AUTOCORRECTION_MATH:
@@ -3023,6 +3035,8 @@ void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new)
        case LyXRC::RC_SHOW_BANNER:
        case LyXRC::RC_OPEN_BUFFERS_IN_TABS:
        case LyXRC::RC_SPELLCHECKER:
+               if (lyxrc_orig.spellchecker != lyxrc_new.spellchecker)
+                       setSpellChecker();
        case LyXRC::RC_SPELLCHECK_CONTINUOUSLY:
        case LyXRC::RC_SPELLCHECK_NOTES:
        case LyXRC::RC_SPLITINDEX_COMMAND: