if (&(*it) == ptr) {
// this is basically BufferView::saveBookmark(0)
LyX::ref().session().bookmarks().save(
- FileName(buf->fileName()),
+ FileName(buf->absFileName()),
it.bottom().pit(),
it.bottom().pos(),
it.paragraph().id(),
}
+void EmbeddedFile::updateInsets(Buffer const * buf) const
+{
+ vector<Inset const *>::const_iterator it = inset_list_.begin();
+ vector<Inset const *>::const_iterator it_end = inset_list_.end();
+ for (; it != it_end; ++it)
+ const_cast<Inset *>(*it)->updateEmbeddedFile(*buf, *this);
+}
+
+
bool EmbeddedFiles::enabled() const
{
return buffer_->params().embedded;
// if operation is successful
buffer_->markDirty();
buffer_->params().embedded = flag;
+ if (flag)
+ updateInsets();
}
}
-void EmbeddedFiles::registerFile(string const & filename,
+EmbeddedFile & EmbeddedFiles::registerFile(string const & filename,
bool embed, Inset const * inset, string const & inzipName)
{
// filename can be relative or absolute, translate to absolute filename
if (it != file_list_.end()) {
it->addInset(inset);
it->validate();
- return;
+ return *it;
}
// try to be more careful
file_list_.push_back(EmbeddedFile(abs_filename,
getInzipName(abs_filename, inzipName), embed, inset));
+ return file_list_.back();
}
}
-bool EmbeddedFiles::readManifest(Lexer & lex, ErrorList & errorList)
-{
- int line = -1;
- int begin_manifest_line = -1;
-
- file_list_.clear();
- string filename;
- string inzipName;
- bool embedded = false;
-
- while (lex.isOK()) {
- lex.next();
- string const token = lex.getString();
-
- if (token.empty())
- continue;
-
- if (token == "\\end_manifest")
- break;
-
- ++line;
- if (token == "\\begin_manifest") {
- begin_manifest_line = line;
- continue;
- }
-
- LYXERR(Debug::PARSER) << "Handling document manifest token: `"
- << token << '\'' << endl;
-
- if (token == "\\filename")
- lex >> filename;
- else if (token == "\\inzipName")
- lex >> inzipName;
- else if (token == "\\embed") {
- lex >> embedded;
- registerFile(filename, embedded, NULL, inzipName);
- filename = "";
- inzipName = "";
- } else {
- docstring const s = _("\\begin_file is missing");
- errorList.push_back(ErrorItem(_("Manifest error"),
- s, -1, 0, 0));
- }
- }
- if (begin_manifest_line) {
- docstring const s = _("\\begin_manifest is missing");
- errorList.push_back(ErrorItem(_("Manifest error"),
- s, -1, 0, 0));
- }
- return true;
-}
-
-
-void EmbeddedFiles::writeManifest(ostream & os) const
+void EmbeddedFiles::updateInsets() const
{
EmbeddedFiles::EmbeddedFileList::const_iterator it = begin();
EmbeddedFiles::EmbeddedFileList::const_iterator it_end = end();
- for (; it != it_end; ++it) {
- if (!it->valid())
- continue;
- // save the relative path
- os << "\\filename "
- << to_utf8(makeRelPath(from_utf8(it->absFilename()),
- from_utf8(buffer_->filePath()))) << '\n'
- << "\\inzipName " << it->inzipName() << '\n'
- << "\\embed " << (it->embedded() ? "true" : "false") << '\n';
- }
+ for (; it != it_end; ++it)
+ if (it->valid() && it->refCount() > 0)
+ it->updateInsets(buffer_);
}