#include "Converter.h"
#include "Counters.h"
#include "DocIterator.h"
-#include "EmbeddedFiles.h"
#include "Encoding.h"
#include "ErrorList.h"
#include "Exporter.h"
namespace {
-int const LYX_FORMAT = 326;
+int const LYX_FORMAT = 328;
typedef map<string, bool> DepClean;
typedef map<docstring, pair<InsetLabel const *, Buffer::References> > RefCache;
/// Container for all sort of Buffer dependant errors.
map<string, ErrorList> errorLists;
- /// all embedded files of this buffer
- EmbeddedFileList embedded_files;
-
/// timestamp and checksum used to test if the file has been externally
/// modified. (Used to properly enable 'File->Revert to saved', bug 4114).
time_t timestamp_;
/// A cache for the bibfiles (including bibfiles of loaded child
/// documents), needed for appropriate update of natbib labels.
- mutable EmbeddedFileList bibfilesCache_;
+ mutable support::FileNameList bibfilesCache_;
mutable RefCache ref_cache_;
: parent_buffer(0), lyx_clean(true), bak_clean(true), unnamed(false),
read_only(readonly_), filename(file), file_fully_loaded(false),
toc_backend(&parent), macro_lock(false),
- embedded_files(), timestamp_(0), checksum_(0), wa_(0),
- undo_(parent)
+ timestamp_(0), checksum_(0), wa_(0), undo_(parent)
{
temppath = createBufferTmpDir();
lyxvc.setBuffer(&parent);
}
-EmbeddedFileList & Buffer::embeddedFiles()
-{
- return d->embedded_files;
-}
-
-
-EmbeddedFileList const & Buffer::embeddedFiles() const
-{
- return d->embedded_files;
-}
-
-
-bool Buffer::embedded() const
-{
- return params().embedded;
-}
-
-
Undo & Buffer::undo()
{
return d->undo_;
LYXERR(Debug::PARSER, "Handling document header token: `"
<< token << '\'');
- string unknown = params().readToken(lex, token, d->filename.onlyPath(),
- d->temppath);
+ string unknown = params().readToken(lex, token, d->filename.onlyPath());
if (!unknown.empty()) {
if (unknown[0] != '\\' && token == "\\textclass") {
Alert::warning(_("Unknown document class"),
// read main text
bool const res = text().read(*this, lex, errorList, &(d->inset));
- // Enable embeded files, which will set temp path and move
- // inconsistent inzip files if needed.
- 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();
return res;
// decompress to a temp directory
LYXERR(Debug::FILES, filename << " is in zip format. Unzip to " << temppath());
::unzipToDir(filename.toFilesystemEncoding(), temppath());
- //
- FileName lyxfile(addName(temppath(), "content.lyx"));
- // if both manifest.txt and file.lyx exist, this is am embedded file
- if (lyxfile.exists()) {
- // if in bundled format, save checksum of the compressed file, not content.lyx
- saveCheckSum(filename);
- params().embedded = true;
- fname = lyxfile;
- }
}
- // The embedded lyx file can also be compressed, for backward compatibility
- format = fname.guessFormatFromContents();
- if (format == "gzip" || format == "zip" || format == "compress")
- params().compressed = true;
// remove dummy empty par
paragraphs().clear();
bool retval = false;
- FileName content;
- if (params().embedded)
- // first write the .lyx file to the temporary directory
- content = FileName(addName(temppath(), "content.lyx"));
- else
- content = fname;
-
docstring const str = bformat(_("Saving document %1$s..."),
- makeDisplayPath(content.absFilename()));
+ makeDisplayPath(fname.absFilename()));
message(str);
if (params().compressed) {
- gz::ogzstream ofs(content.toFilesystemEncoding().c_str(), ios::out|ios::trunc);
+ gz::ogzstream ofs(fname.toFilesystemEncoding().c_str(), ios::out|ios::trunc);
retval = ofs && write(ofs);
} else {
- ofstream ofs(content.toFilesystemEncoding().c_str(), ios::out|ios::trunc);
+ ofstream ofs(fname.toFilesystemEncoding().c_str(), ios::out|ios::trunc);
retval = ofs && write(ofs);
}
removeAutosaveFile(d->filename.absFilename());
- if (params().embedded) {
- 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!"));
- return false;
- }
- }
saveCheckSum(d->filename);
message(str + _(" done."));
if (it->lyxCode() == BIBTEX_CODE) {
InsetBibtex const & inset =
static_cast<InsetBibtex const &>(*it);
- EmbeddedFileList const bibfiles = inset.getBibFiles();
+ support::FileNameList const bibfiles = inset.getBibFiles();
d->bibfilesCache_.insert(d->bibfilesCache_.end(),
bibfiles.begin(),
bibfiles.end());
InsetInclude & inset =
static_cast<InsetInclude &>(*it);
inset.updateBibfilesCache();
- EmbeddedFileList const & bibfiles =
+ support::FileNameList const & bibfiles =
inset.getBibfilesCache(*this);
d->bibfilesCache_.insert(d->bibfilesCache_.end(),
bibfiles.begin(),
}
-EmbeddedFileList const & Buffer::getBibfilesCache() const
+support::FileNameList const & Buffer::getBibfilesCache() const
{
// If this is a child document, use the parent's cache instead.
if (d->parent_buffer)
}
}
+
} // namespace lyx