mutable TocBackend toc_backend;
/// macro tables
- typedef pair<DocIterator, MacroData> ScopeMacro;
+ struct ScopeMacro {
+ ScopeMacro() {}
+ ScopeMacro(DocIterator const & s, MacroData const & m)
+ : scope(s), macro(m) {}
+ DocIterator scope;
+ MacroData macro;
+ };
typedef map<DocIterator, ScopeMacro> PositionScopeMacroMap;
typedef map<docstring, PositionScopeMacroMap> NamePositionScopeMacroMap;
/// map from the macro name to the position map,
/// positions of child buffers in the buffer
typedef map<Buffer const * const, DocIterator> BufferPositionMap;
- typedef pair<DocIterator, Buffer const *> ScopeBuffer;
+ struct ScopeBuffer {
+ ScopeBuffer() {}
+ ScopeBuffer(DocIterator const & s,Buffer const * b)
+ : scope(s), buffer(b) {}
+ DocIterator scope;
+ Buffer const * buffer;
+ };
typedef map<DocIterator, ScopeBuffer> PositionScopeBufferMap;
/// position of children buffers in this buffer
BufferPositionMap children_positions;
/// we ran updateBuffer(), i.e., whether citation labels may need
/// to be updated.
mutable bool cite_labels_valid_;
+ /// these hold the file name and format, written to by Buffer::preview
+ /// and read from by LFUN_BUFFER_VIEW_CACHE.
+ FileName preview_file_;
+ string preview_format_;
mutable RefCache ref_cache_;
static FileName createBufferTmpDir()
{
// FIXME This would be the ideal application for a TempDir class (like
- // TempFile but for directories)
+ // TempFile but for directories)
string counter;
{
static int count;
file_fully_loaded(false), ignore_parent(false), toc_backend(owner),
macro_lock(false), timestamp_(0), checksum_(0), wa_(0), gui_(0),
undo_(*owner), bibinfo_cache_valid_(false), bibfile_cache_valid_(false),
- cite_labels_valid_(false), preview_loader_(0),
+ cite_labels_valid_(false), inset(0), preview_loader_(0),
cloned_buffer_(cloned_buffer), clone_list_(0),
- doing_export(false), parent_buffer(0)
+ doing_export(false), parent_buffer(0),
+ word_count_(0), char_count_(0), blank_count_(0)
{
if (!cloned_buffer_) {
temppath = createBufferTmpDir();
cite_labels_valid_ = cloned_buffer_->d->cite_labels_valid_;
unnamed = cloned_buffer_->d->unnamed;
internal_buffer = cloned_buffer_->d->internal_buffer;
+ preview_file_ = cloned_buffer_->d->preview_file_;
+ preview_format_ = cloned_buffer_->d->preview_format_;
}
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());
}
for (; it != end; ++it) {
DocIterator dit = it->first.clone(buffer_clone);
dit.setBuffer(buffer_clone);
- Buffer * child = const_cast<Buffer *>(it->second.second);
+ Buffer * child = const_cast<Buffer *>(it->second.buffer);
child->cloneWithChildren(bufmap, clones);
BufferMap::iterator const bit = bufmap.find(child);
// Also consider the master buffer log file
FileName masterfname = fname;
- LogType mtype;
+ LogType mtype = latexlog;
if (masterBuffer() != this) {
string const mlogfile = masterBuffer()->logName(&mtype);
masterfname = FileName(mlogfile);
d->texrow.reset();
DocumentClass const & tclass = params().documentClass();
- string const top_element = tclass.latexname();
+ string const & top_element = tclass.latexname();
bool const output_preamble =
output == FullSource || output == OnlyPreamble;
enable = !isReadonly();
break;
+ case LFUN_BUFFER_VIEW_CACHE:
+ enable = (d->preview_file_).exists();
+ break;
+
default:
return false;
}
break;
}
+ case LFUN_BUFFER_VIEW_CACHE:
+ if (!formats.view(*this, d->preview_file_,
+ d->preview_format_))
+ dr.setMessage(_("Error viewing the output file."));
+ break;
+
default:
dispatched = false;
break;
if (it != nameIt->second.end()) {
while (true) {
// scope ends behind pos?
- if (pos < it->second.first) {
+ if (pos < it->second.scope) {
// Looks good, remember this. If there
// is no external macro behind this,
// we found the right one already.
bestPos = it->first;
- bestData = &it->second.second;
+ bestData = &it->second.macro;
break;
}
break;
// scope ends behind pos?
- if (pos < it->second.first
+ if (pos < it->second.scope
&& (cloned_buffer_ ||
- theBufferList().isLoaded(it->second.second))) {
+ theBufferList().isLoaded(it->second.buffer))) {
// look for macro in external file
macro_lock = true;
MacroData const * data
- = it->second.second->getMacro(name, false);
+ = it->second.buffer->getMacro(name, false);
macro_lock = false;
if (data) {
bestPos = it->first;
continue;
// register macro
- // FIXME (Abdel), I don't understandt why we pass 'it' here
+ // FIXME (Abdel), I don't understand why we pass 'it' here
// instead of 'macroTemplate' defined above... is this correct?
macros[macroTemplate.name()][it] =
Impl::ScopeMacro(scope, MacroData(const_cast<Buffer *>(owner_), it));
setMathFlavor(runparams);
xhtmlParagraphs(text(), *this, xs, runparams);
} else if (runparams.flavor == OutputParams::TEXT) {
- bool dummy;
+ bool dummy = false;
// FIXME Handles only one paragraph, unlike the others.
// Probably should have some routine with a signature like them.
writePlaintextParagraph(*this,
d->cloned_buffer_->d->errorLists[error_type] = d->errorLists[error_type];
}
- if (!success)
- return ExportConverterError;
if (put_in_tempdir) {
result_file = tmp_result_file.absFileName();
- return ExportSuccess;
+ return success ? ExportSuccess : ExportConverterError;
}
if (dest_filename.empty())
formats.prettyName(format)));
}
- return ExportSuccess;
+ return success ? ExportSuccess : ExportConverterError;
}
}
// (2) export with included children only
ExportStatus const status = doExport(format, true, false, result_file);
+ FileName const previewFile(result_file);
+
+ LATTEST (isClone());
+ d->cloned_buffer_->d->preview_file_ = previewFile;
+ d->cloned_buffer_->d->preview_format_ = format;
+
if (status != ExportSuccess)
return status;
- if (!formats.view(*this, FileName(result_file), format))
- return PreviewError;
- return PreviewSuccess;
+ if (previewFile.exists()) {
+ if (!formats.view(*this, previewFile, format))
+ return PreviewError;
+ else
+ return PreviewSuccess;
+ }
+ else {
+ // Successful export but no output file?
+ // Probably a bug in error detection.
+ LATTEST (status != ExportSuccess);
+
+ return status;
+ }
}
if (master != this) {
bufToUpdate.insert(this);
master->updateBuffer(UpdateMaster, utype);
- // If the master buffer has no gui associated with it, then the TocModel is
- // not updated during the updateBuffer call and TocModel::toc_ is invalid
- // (bug 5699). The same happens if the master buffer is open in a different
+ // If the master buffer has no gui associated with it, then the TocModel is
+ // not updated during the updateBuffer call and TocModel::toc_ is invalid
+ // (bug 5699). The same happens if the master buffer is open in a different
// window. This test catches both possibilities.
// See: http://marc.info/?l=lyx-devel&m=138590578911716&w=2
// There remains a problem here: If there is another child open in yet a third