X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FBuffer.cpp;h=9b8730d4658f080f398f3b1917b26efbc843ca04;hb=2098f1d8c20d51e63e670bcdc9da8996068975bf;hp=bd7305701785929e0afe9bc9cb65aa89cb375e28;hpb=28e9474f7a244cbadf454cfaff65f33f2b4740e4;p=lyx.git diff --git a/src/Buffer.cpp b/src/Buffer.cpp index bd73057017..9b8730d465 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -127,7 +127,7 @@ namespace { // Do not remove the comment below, so we get merge conflict in // independent branches. Instead add your own. -int const LYX_FORMAT = 374; // rgheck: HTML output options +int const LYX_FORMAT = 375; // jspitzm: includeonly support typedef map DepClean; typedef map > RefCache; @@ -315,9 +315,15 @@ Buffer::Buffer(string const & file, bool readonly, Buffer const * cloned_buffer) { LYXERR(Debug::INFO, "Buffer::Buffer()"); if (cloned_buffer) { - d->inset = static_cast(cloned_buffer->d->inset->clone()); + d->inset = new InsetText(*cloned_buffer->d->inset); d->inset->setBuffer(*this); - } else + // FIXME: optimize this loop somewhat, maybe by creating a new + // general recursive Inset::setId(). + DocIterator it = doc_iterator_begin(this); + DocIterator cloned_it = doc_iterator_begin(cloned_buffer); + for (; !it.atEnd(); it.forwardPar(), cloned_it.forwardPar()) + it.paragraph().setId(cloned_it.paragraph().id()); + } else d->inset = new InsetText(this); d->inset->setAutoBreakRows(true); d->inset->getText(0)->setMacrocontextPosition(par_iterator_begin()); @@ -374,6 +380,8 @@ Buffer::~Buffer() Buffer * Buffer::clone() const { + // FIXME for asynchronous export and preview: We must also clone all + // the child buffers! return new Buffer(fileName().absFilename(), false, this); } @@ -384,10 +392,10 @@ bool Buffer::isClone() const } -void Buffer::changed() const +void Buffer::changed(bool update_metrics) const { if (d->wa_) - d->wa_->redrawAll(); + d->wa_->redrawAll(update_metrics); } @@ -599,6 +607,7 @@ int Buffer::readHeader(Lexer & lex) params().listings_params.clear(); params().clearLayoutModules(); params().clearRemovedModules(); + params().clearIncludedChildren(); params().pdfoptions().clear(); params().indiceslist().clear(); params().backgroundcolor = lyx::rgbFromHexName("#ffffff"); @@ -1251,7 +1260,9 @@ void Buffer::writeLaTeXSource(odocstream & os, listParentMacros(parentMacros, features); // Write the preamble - runparams.use_babel = params().writeLaTeX(os, features, d->texrow); + runparams.use_babel = params().writeLaTeX(os, features, + d->texrow, + d->filename.onlyPath()); runparams.use_japanese = features.isRequired("japanese"); @@ -1446,8 +1457,8 @@ void Buffer::writeLyXHTMLSource(odocstream & os, LaTeXFeatures features(*this, params(), runparams); validate(features); updateLabels(UpdateMaster, true); - - d->texrow.reset(); + checkBibInfoCache(); + d->bibinfo_.collectCitedEntries(*this); if (!only_body) { os << "\n"; @@ -1629,18 +1640,23 @@ BiblioInfo const & Buffer::masterBibInfo() const BiblioInfo const & Buffer::localBibInfo() const { - if (d->bibinfoCacheValid_) { - support::FileNameList const & bibfilesCache = getBibfilesCache(); - // compare the cached timestamps with the actual ones. - support::FileNameList::const_iterator ei = bibfilesCache.begin(); - support::FileNameList::const_iterator en = bibfilesCache.end(); - for (; ei != en; ++ ei) { - time_t lastw = ei->lastModified(); - if (lastw != d->bibfileStatus_[*ei]) { - d->bibinfoCacheValid_ = false; - d->bibfileStatus_[*ei] = lastw; - break; - } + checkBibInfoCache(); + return d->bibinfo_; +} + + +void Buffer::checkBibInfoCache() const +{ + support::FileNameList const & bibfilesCache = getBibfilesCache(); + // compare the cached timestamps with the actual ones. + support::FileNameList::const_iterator ei = bibfilesCache.begin(); + support::FileNameList::const_iterator en = bibfilesCache.end(); + for (; ei != en; ++ ei) { + time_t lastw = ei->lastModified(); + time_t prevw = d->bibfileStatus_[*ei]; + if (lastw != prevw) { + d->bibinfoCacheValid_ = false; + d->bibfileStatus_[*ei] = lastw; } } @@ -1649,8 +1665,7 @@ BiblioInfo const & Buffer::localBibInfo() const for (InsetIterator it = inset_iterator_begin(inset()); it; ++it) it->fillWithBibKeys(d->bibinfo_, it); d->bibinfoCacheValid_ = true; - } - return d->bibinfo_; + } } @@ -3192,6 +3207,14 @@ bool Buffer::doExport(string const & format, bool put_in_tempdir, if (!success) return false; + if (d->cloned_buffer_) { + // Enable reverse dvi or pdf to work by copying back the texrow + // object to the cloned buffer. + // FIXME: There is a possibility of concurrent access to texrow + // here from the main GUI thread that should be securized. + d->cloned_buffer_->d->texrow = d->texrow; + } + if (put_in_tempdir) { result_file = tmp_result_file.absFilename(); return true; @@ -3755,4 +3778,26 @@ int Buffer::spellCheck(DocIterator & from, DocIterator & to, return progress; } + +bool Buffer::reload() +{ + setBusy(true); + // e.g., read-only status could have changed due to version control + d->filename.refresh(); + docstring const disp_fn = makeDisplayPath(d->filename.absFilename()); + + bool const success = loadLyXFile(d->filename); + if (success) { + updateLabels(); + changed(true); + errors("Parse"); + message(bformat(_("Document %1$s reloaded."), disp_fn)); + } else { + message(bformat(_("Could not reload document %1$s."), disp_fn)); + } + setBusy(false); + return success; +} + + } // namespace lyx