mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 18:08:10 +00:00
Introduce findFile() and simplify registerFile().
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@24037 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
2ce335e013
commit
eae4e41141
@ -493,27 +493,48 @@ void EmbeddedFileList::registerFile(EmbeddedFile const & file,
|
||||
{
|
||||
BOOST_ASSERT(!buffer.embedded() || file.enabled());
|
||||
|
||||
string newfile = file.absFilename();
|
||||
EmbeddedFile * efp = findFile(newfile);
|
||||
if (efp) {
|
||||
if (efp->embedded() != file.embedded()) {
|
||||
Alert::error(_("Wrong embedding status."),
|
||||
bformat(_("File %1$s is included in more than one insets, "
|
||||
"but with different embedding status. Assuming embedding status."),
|
||||
from_utf8(efp->outputFilename())));
|
||||
efp->setEmbed(true);
|
||||
// update the inset with this embedding status.
|
||||
const_cast<Inset*>(inset)->updateEmbeddedFile(*efp);
|
||||
}
|
||||
efp->addInset(inset);
|
||||
return;
|
||||
}
|
||||
file.clearInsets();
|
||||
push_back(file);
|
||||
back().addInset(inset);
|
||||
}
|
||||
|
||||
|
||||
EmbeddedFile const * EmbeddedFileList::findFile(std::string const & filename) const
|
||||
{
|
||||
// try to find this file from the list
|
||||
std::vector<EmbeddedFile>::const_iterator it = begin();
|
||||
std::vector<EmbeddedFile>::const_iterator it_end = end();
|
||||
for (; it != it_end; ++it)
|
||||
if (it->absFilename() == filename)
|
||||
return &*it;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
EmbeddedFile * EmbeddedFileList::findFile(std::string const & filename)
|
||||
{
|
||||
// try to find this file from the list
|
||||
std::vector<EmbeddedFile>::iterator it = begin();
|
||||
std::vector<EmbeddedFile>::iterator it_end = end();
|
||||
for (; it != it_end; ++it)
|
||||
if (it->absFilename() == file.absFilename()) {
|
||||
if (it->embedded() != file.embedded()) {
|
||||
Alert::error(_("Wrong embedding status."),
|
||||
bformat(_("File %1$s is included in more than one insets, "
|
||||
"but with different embedding status. Assuming embedding status."),
|
||||
from_utf8(it->outputFilename())));
|
||||
it->setEmbed(true);
|
||||
// update the inset with this embedding status.
|
||||
const_cast<Inset*>(inset)->updateEmbeddedFile(*it);
|
||||
}
|
||||
it->addInset(inset);
|
||||
return;
|
||||
}
|
||||
//
|
||||
file.clearInsets();
|
||||
push_back(file);
|
||||
back().addInset(inset);
|
||||
if (it->absFilename() == filename)
|
||||
return &*it;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -209,13 +209,14 @@ public:
|
||||
*/
|
||||
void registerFile(EmbeddedFile const & file, Inset const * inset,
|
||||
Buffer const & buffer);
|
||||
|
||||
/// returns a pointer to the Embedded file representing this object,
|
||||
/// or null if not found. The filename should be absolute.
|
||||
EmbeddedFile const * findFile(std::string const & filename) const;
|
||||
EmbeddedFile * findFile(std::string const & filename);
|
||||
/// validate embedded fies after a file is read.
|
||||
void validate(Buffer const & buffer);
|
||||
|
||||
/// scan the buffer and get a list of EmbeddedFile
|
||||
void update(Buffer const & buffer);
|
||||
|
||||
/// write a zip file
|
||||
bool writeFile(support::DocFileName const & filename, Buffer const & buffer);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user