}
+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();
}
EmbeddedFiles::EmbeddedFileList::const_iterator it = begin();
EmbeddedFiles::EmbeddedFileList::const_iterator it_end = end();
for (; it != it_end; ++it) {
- if (!it->valid())
+ // only saved 'extra' files. Other embedded files are saved
+ // with insets.
+ if (!it->valid() || it->refCount() > 0)
continue;
// save the relative path
os << "\\filename "
}
+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() && it->refCount() > 0)
+ it->updateInsets(buffer_);
+}
+
+
}