X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fbuffer.C;h=429907f18ac17076db2828ad70f51d5e4f806cce;hb=2486c96b8d9086471299bf207b85b1ce848246aa;hp=a62baf1fae9bec9a5b155b92c42045e1b85465cf;hpb=82765345acde2d8cbcc3f700f97ef312aaa1b120;p=lyx.git diff --git a/src/buffer.C b/src/buffer.C index a62baf1fae..429907f18a 100644 --- a/src/buffer.C +++ b/src/buffer.C @@ -144,7 +144,7 @@ extern BufferList bufferlist; namespace { -int const LYX_FORMAT = 244; +int const LYX_FORMAT = 245; } // namespace anon @@ -470,25 +470,23 @@ bool Buffer::readDocument(LyXLex & lex) error(ErrorItem(_("Document header error"), s, -1, 0, 0)); } - if (paragraphs().empty()) { - readHeader(lex); - if (!params().getLyXTextClass().load()) { - string theclass = params().getLyXTextClass().name(); - Alert::error(_("Can't load document class"), bformat( - "Using the default document class, because the " - " class %1$s could not be loaded.", theclass)); - params().textclass = 0; - } - } else { - // We don't want to adopt the parameters from the - // document we insert, so read them into a temporary buffer - // and then discard it + // we are reading in a brand new document + BOOST_ASSERT(paragraphs().empty()); - Buffer tmpbuf("", false); - tmpbuf.readHeader(lex); + readHeader(lex); + if (!params().getLyXTextClass().load()) { + string theclass = params().getLyXTextClass().name(); + Alert::error(_("Can't load document class"), bformat( + "Using the default document class, because the " + " class %1$s could not be loaded.", theclass)); + params().textclass = 0; } - return text().read(*this, lex); + bool const res = text().read(*this, lex); + for_each(text().paragraphs().begin(), + text().paragraphs().end(), + bind(&Paragraph::setInsetOwner, _1, &inset())); + return res; } @@ -556,7 +554,9 @@ bool Buffer::readFile(string const & filename) // remove dummy empty par paragraphs().clear(); - bool ret = readFile(filename, paragraphs().size()); + LyXLex lex(0, 0); + lex.setFile(filename); + bool ret = readFile(lex, filename); // After we have read a file, we must ensure that the buffer // language is set and used in the gui. @@ -567,14 +567,6 @@ bool Buffer::readFile(string const & filename) } -bool Buffer::readFile(string const & filename, pit_type const pit) -{ - LyXLex lex(0, 0); - lex.setFile(filename); - return readFile(lex, filename, pit); -} - - bool Buffer::fully_loaded() const { return pimpl_->file_fully_loaded; @@ -587,7 +579,7 @@ void Buffer::fully_loaded(bool const value) } -bool Buffer::readFile(LyXLex & lex, string const & filename, pit_type const pit) +bool Buffer::readFile(LyXLex & lex, string const & filename) { BOOST_ASSERT(!filename.empty()); @@ -668,7 +660,7 @@ bool Buffer::readFile(LyXLex & lex, string const & filename, pit_type const pit) filename)); return false; } else { - bool const ret = readFile(tmpfile, pit); + bool const ret = readFile(tmpfile); // Do stuff with tmpfile name and buffer name here. return ret; }