]> git.lyx.org Git - lyx.git/blobdiff - src/Buffer.cpp
speed up symbol panel population
[lyx.git] / src / Buffer.cpp
index a5df4bd9f5f6d1a99645076273dcede11e7eb080..d68ef97c7a48c9eccce5515598ecdc983665eb51 100644 (file)
@@ -51,7 +51,6 @@
 #include "ParagraphParameters.h"
 #include "ParIterator.h"
 #include "PDFOptions.h"
-#include "Session.h"
 #include "sgml.h"
 #include "TexRow.h"
 #include "TexStream.h"
@@ -117,7 +116,7 @@ namespace os = support::os;
 
 namespace {
 
-int const LYX_FORMAT = 318;
+int const LYX_FORMAT = 321;
 
 typedef map<string, bool> DepClean;
 typedef map<docstring, pair<InsetLabel const *, Buffer::References> > RefCache;
@@ -174,6 +173,8 @@ public:
        typedef pair<DocIterator, MacroData> ScopeMacro;
        typedef map<DocIterator, ScopeMacro> PositionScopeMacroMap;
        typedef map<docstring, PositionScopeMacroMap> NamePositionScopeMacroMap;
+       /// map from the macro name to the position map,
+       /// which maps the macro definition position to the scope and the MacroData.
        NamePositionScopeMacroMap macros;
        bool macro_lock;
        
@@ -181,7 +182,9 @@ public:
        typedef map<Buffer const * const, DocIterator> BufferPositionMap;
        typedef pair<DocIterator, Buffer const *> ScopeBuffer;
        typedef map<DocIterator, ScopeBuffer> PositionScopeBufferMap;
+       /// position of children buffers in this buffer
        BufferPositionMap children_positions;
+       /// map from children inclusion positions to their scope and their buffer
        PositionScopeBufferMap position_to_children;
 
        /// Container for all sort of Buffer dependant errors.
@@ -498,7 +501,8 @@ int Buffer::readHeader(Lexer & lex)
                LYXERR(Debug::PARSER, "Handling document header token: `"
                                      << token << '\'');
 
-               string unknown = params().readToken(lex, token, d->filename.onlyPath());
+               string unknown = params().readToken(lex, token, d->filename.onlyPath(),
+                       d->temppath);
                if (!unknown.empty()) {
                        if (unknown[0] != '\\' && token == "\\textclass") {
                                Alert::warning(_("Unknown document class"),
@@ -573,7 +577,19 @@ bool Buffer::readDocument(Lexer & lex)
 
        // Enable embeded files, which will set temp path and move
        // inconsistent inzip files if needed.
-       embeddedFiles().enable(params().embedded, *this, false);
+       try {
+               embeddedFiles().validate(*this);
+               embeddedFiles().enable(params().embedded, *this, false);
+       } catch (ExceptionMessage const & message) {
+               Alert::error(message.title_, message.details_);
+               Alert::warning(_("Failed to read embedded files"),
+                      _("Due to most likely a bug, LyX failed to locate all embedded "
+                                "file. If you unzip the LyX file, you should be able to see and "
+                                "open content.lyx which is your main text. You may also be able "
+                                "to recover some embedded files. Please report this bug to the "
+                                "lyx-devel mailing list."));
+               return false;
+       }
 
        updateMacros();
        updateMacroInstances();
@@ -909,18 +925,18 @@ bool Buffer::writeFile(FileName const & fname) const
        }
 
        if (!retval) {
-               message(str + _(" could not write file!."));
+               message(str + _(" could not write file!"));
                return false;
        }
 
        removeAutosaveFile(d->filename.absFilename());
 
        if (params().embedded) {
-               message(str + _(" writing embedded files!."));
+               message(str + _(" writing embedded files."));
                // if embedding is enabled, write file.lyx and all the embedded files
                // to the zip file fname.
                if (!d->embedded_files.writeFile(fname, *this)) {
-                       message(str + _(" could not write embedded files!."));
+                       message(str + _(" could not write embedded files!"));
                        return false;
                }
        }