X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FBuffer.cpp;h=d68ef97c7a48c9eccce5515598ecdc983665eb51;hb=0011f47885e070cf36e92d3a2f11f29ce1d4fdf4;hp=a5df4bd9f5f6d1a99645076273dcede11e7eb080;hpb=76dc2c0d3002db400f4826e6f3b3e8bf84f830f4;p=lyx.git diff --git a/src/Buffer.cpp b/src/Buffer.cpp index a5df4bd9f5..d68ef97c7a 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -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 DepClean; typedef map > RefCache; @@ -174,6 +173,8 @@ public: typedef pair ScopeMacro; typedef map PositionScopeMacroMap; typedef map 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 BufferPositionMap; typedef pair ScopeBuffer; typedef map 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; } }