mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-27 03:36:39 +00:00
remove Buffer & argument in functions realted to embedded files
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23292 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
f8ba8db758
commit
9b39c142b6
@ -1388,7 +1388,7 @@ void Buffer::updateBibfilesCache() const
|
||||
if (it->lyxCode() == BIBTEX_CODE) {
|
||||
InsetBibtex const & inset =
|
||||
static_cast<InsetBibtex const &>(*it);
|
||||
EmbeddedFileList const bibfiles = inset.getFiles(*this);
|
||||
EmbeddedFileList const bibfiles = inset.embeddedFiles();
|
||||
d->bibfilesCache_.insert(d->bibfilesCache_.end(),
|
||||
bibfiles.begin(),
|
||||
bibfiles.end());
|
||||
|
@ -246,12 +246,12 @@ bool EmbeddedFile::updateFromExternalFile() const
|
||||
}
|
||||
|
||||
|
||||
void EmbeddedFile::updateInsets(Buffer const * buf) const
|
||||
void EmbeddedFile::updateInsets() 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);
|
||||
const_cast<Inset *>(*it)->updateEmbeddedFile(*this);
|
||||
}
|
||||
|
||||
|
||||
@ -386,9 +386,9 @@ void EmbeddedFileList::enable(bool flag, Buffer & buffer)
|
||||
for (; it != it_end; ++it) {
|
||||
it->enable(flag, &buffer);
|
||||
if (it->embedded())
|
||||
count_embedded ++;
|
||||
++count_embedded;
|
||||
else
|
||||
count_external ++;
|
||||
++count_external;
|
||||
}
|
||||
// if operation is successful (no exception is thrown)
|
||||
buffer.markDirty();
|
||||
@ -396,7 +396,7 @@ void EmbeddedFileList::enable(bool flag, Buffer & buffer)
|
||||
|
||||
// if the operation is successful, update insets
|
||||
for (it = begin(); it != it_end; ++it)
|
||||
it->updateInsets(&buffer);
|
||||
it->updateInsets();
|
||||
|
||||
// show result
|
||||
if (flag) {
|
||||
@ -429,7 +429,7 @@ void EmbeddedFileList::registerFile(EmbeddedFile const & file,
|
||||
from_utf8(it->outputFilename())));
|
||||
it->setEmbed(true);
|
||||
// update the inset with this embedding status.
|
||||
const_cast<Inset*>(inset)->updateEmbeddedFile(buffer, *it);
|
||||
const_cast<Inset*>(inset)->updateEmbeddedFile(*it);
|
||||
}
|
||||
it->addInset(inset);
|
||||
return;
|
||||
@ -445,7 +445,7 @@ void EmbeddedFileList::update(Buffer const & buffer)
|
||||
clear();
|
||||
|
||||
for (InsetIterator it = inset_iterator_begin(buffer.inset()); it; ++it)
|
||||
it->registerEmbeddedFiles(buffer, *this);
|
||||
it->registerEmbeddedFiles(*this);
|
||||
}
|
||||
|
||||
|
||||
@ -492,4 +492,4 @@ bool EmbeddedFileList::writeFile(DocFileName const & filename, Buffer const & bu
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace lyx
|
||||
|
@ -160,7 +160,7 @@ public:
|
||||
/// embedded file instead of external file. To make sure inset pointers
|
||||
/// are up to date, please make sure there is no modification to the
|
||||
/// document between EmbeddedFiles::update() and this function.
|
||||
void updateInsets(Buffer const * buf) const;
|
||||
void updateInsets() const;
|
||||
|
||||
/// Check readability of availableFile
|
||||
bool isReadableFile() const;
|
||||
|
@ -418,7 +418,7 @@ void Inset::setDimCache(MetricsInfo const & mi, Dimension const & dim) const
|
||||
|
||||
Buffer const * Inset::updateFrontend() const
|
||||
{
|
||||
return theApp()? theApp()->updateInset(this) : 0;
|
||||
return theApp() ? theApp()->updateInset(this) : 0;
|
||||
}
|
||||
|
||||
} // namespace lyx
|
||||
|
@ -423,9 +423,9 @@ public:
|
||||
/// pit is the ParConstIterator of the paragraph containing the inset
|
||||
virtual void addToToc(ParConstIterator const &) const {}
|
||||
/// report files that can be embedded with the lyx file
|
||||
virtual void registerEmbeddedFiles(Buffer const &, EmbeddedFileList &) const {}
|
||||
virtual void registerEmbeddedFiles(EmbeddedFileList &) const {}
|
||||
/// use embedded or external file after the embedding status of a file is changed
|
||||
virtual void updateEmbeddedFile(Buffer const &, EmbeddedFile const &) {}
|
||||
virtual void updateEmbeddedFile(EmbeddedFile const &) {}
|
||||
/// Fill keys with BibTeX information
|
||||
virtual void fillWithBibKeys(BiblioInfo &, InsetIterator const &) const {}
|
||||
/// Update the counters of this inset and of its contents
|
||||
|
@ -107,7 +107,7 @@ void InsetBibtex::doDispatch(Cursor & cur, FuncRequest & cmd)
|
||||
bibfiles = split(bibfiles, tmp, ',');
|
||||
embedStatus = split(embedStatus, emb, ',');
|
||||
while (!tmp.empty()) {
|
||||
EmbeddedFile file(changeExtension(tmp, "bib"), cur.buffer().filePath());
|
||||
EmbeddedFile file(changeExtension(tmp, "bib"), buffer().filePath());
|
||||
if (!newBibfiles.empty())
|
||||
newBibfiles += ",";
|
||||
newBibfiles += tmp;
|
||||
@ -128,14 +128,14 @@ void InsetBibtex::doDispatch(Cursor & cur, FuncRequest & cmd)
|
||||
setParams(p);
|
||||
try {
|
||||
// test parameter and copy files
|
||||
getFiles(cur.buffer());
|
||||
embeddedFiles();
|
||||
} catch (ExceptionMessage const & message) {
|
||||
Alert::error(message.title_, message.details_);
|
||||
// do not set parameter if an error happens
|
||||
setParams(orig);
|
||||
break;
|
||||
}
|
||||
cur.buffer().updateBibfilesCache();
|
||||
buffer().updateBibfilesCache();
|
||||
break;
|
||||
}
|
||||
|
||||
@ -189,7 +189,7 @@ int InsetBibtex::latex(odocstream & os, OutputParams const & runparams) const
|
||||
// use such filenames.)
|
||||
// Otherwise, store the (maybe absolute) path to the original,
|
||||
// unmangled database name.
|
||||
EmbeddedFileList const bibs = getFiles(buffer());
|
||||
EmbeddedFileList const bibs = embeddedFiles();
|
||||
EmbeddedFileList::const_iterator it = bibs.begin();
|
||||
EmbeddedFileList::const_iterator it_end = bibs.end();
|
||||
odocstringstream dbs;
|
||||
@ -343,9 +343,9 @@ int InsetBibtex::latex(odocstream & os, OutputParams const & runparams) const
|
||||
}
|
||||
|
||||
|
||||
EmbeddedFileList const InsetBibtex::getFiles(Buffer const & buffer) const
|
||||
EmbeddedFileList InsetBibtex::embeddedFiles() const
|
||||
{
|
||||
FileName path(buffer.filePath());
|
||||
FileName path(buffer().filePath());
|
||||
PathChanger p(path);
|
||||
|
||||
EmbeddedFileList vec;
|
||||
@ -359,10 +359,10 @@ EmbeddedFileList const InsetBibtex::getFiles(Buffer const & buffer) const
|
||||
embedStatus = split(embedStatus, emb, ',');
|
||||
while (!tmp.empty()) {
|
||||
if (!emb.empty()) {
|
||||
EmbeddedFile file(changeExtension(tmp, "bib"), buffer.filePath());
|
||||
EmbeddedFile file(changeExtension(tmp, "bib"), buffer().filePath());
|
||||
// If the file structure is correct, this should not fail.
|
||||
file.setEmbed(true);
|
||||
file.enable(buffer.embedded(), &buffer);
|
||||
file.enable(buffer().embedded(), &buffer());
|
||||
vec.push_back(file);
|
||||
} else {
|
||||
// this includes the cases when the embed parameter is empty
|
||||
@ -370,9 +370,9 @@ EmbeddedFileList const InsetBibtex::getFiles(Buffer const & buffer) const
|
||||
|
||||
// If we didn't find a matching file name just fail silently
|
||||
if (!file.empty()) {
|
||||
EmbeddedFile efile = EmbeddedFile(file.absFilename(), buffer.filePath());
|
||||
EmbeddedFile efile = EmbeddedFile(file.absFilename(), buffer().filePath());
|
||||
efile.setEmbed(false);
|
||||
efile.enable(buffer.embedded(), &buffer);
|
||||
efile.enable(buffer().embedded(), &buffer());
|
||||
vec.push_back(efile);
|
||||
}
|
||||
}
|
||||
@ -627,7 +627,7 @@ namespace {
|
||||
void InsetBibtex::fillWithBibKeys(BiblioInfo & keylist,
|
||||
InsetIterator const & /*di*/) const
|
||||
{
|
||||
EmbeddedFileList const files = getFiles(buffer());
|
||||
EmbeddedFileList const files = embeddedFiles();
|
||||
for (vector<EmbeddedFile>::const_iterator it = files.begin();
|
||||
it != files.end(); ++ it) {
|
||||
// This bibtex parser is a first step to parse bibtex files
|
||||
@ -822,25 +822,25 @@ void InsetBibtex::validate(LaTeXFeatures & features) const
|
||||
}
|
||||
|
||||
|
||||
void InsetBibtex::registerEmbeddedFiles(Buffer const & buffer, EmbeddedFileList & files) const
|
||||
void InsetBibtex::registerEmbeddedFiles(EmbeddedFileList & files) const
|
||||
{
|
||||
EmbeddedFileList const dbs = getFiles(buffer);
|
||||
EmbeddedFileList const dbs = embeddedFiles();
|
||||
for (vector<EmbeddedFile>::const_iterator it = dbs.begin();
|
||||
it != dbs.end(); ++ it)
|
||||
files.registerFile(*it, this, buffer);
|
||||
it != dbs.end(); ++it)
|
||||
files.registerFile(*it, this, buffer());
|
||||
}
|
||||
|
||||
|
||||
void InsetBibtex::updateEmbeddedFile(Buffer const & buf, EmbeddedFile const & file)
|
||||
void InsetBibtex::updateEmbeddedFile(EmbeddedFile const & file)
|
||||
{
|
||||
// look for the item and update status
|
||||
docstring bibfiles;
|
||||
docstring embed;
|
||||
|
||||
bool first = true;
|
||||
EmbeddedFileList dbs = getFiles(buf);
|
||||
EmbeddedFileList dbs = embeddedFiles();
|
||||
for (EmbeddedFileList::iterator it = dbs.begin();
|
||||
it != dbs.end(); ++ it) {
|
||||
it != dbs.end(); ++it) {
|
||||
// update from file
|
||||
if (it->absFilename() == file.absFilename())
|
||||
it->setEmbed(file.embedded());
|
||||
@ -848,9 +848,10 @@ void InsetBibtex::updateEmbeddedFile(Buffer const & buf, EmbeddedFile const & fi
|
||||
if (!first) {
|
||||
bibfiles += ',';
|
||||
embed += ',';
|
||||
} else
|
||||
} else {
|
||||
first = false;
|
||||
bibfiles += from_utf8(it->outputFilename(buf.filePath()));
|
||||
}
|
||||
bibfiles += from_utf8(it->outputFilename(buffer().filePath()));
|
||||
if (it->embedded())
|
||||
embed += from_utf8(it->inzipName());
|
||||
}
|
||||
|
@ -38,9 +38,9 @@ public:
|
||||
///
|
||||
int latex(odocstream &, OutputParams const &) const;
|
||||
///
|
||||
virtual void fillWithBibKeys(BiblioInfo &, InsetIterator const &) const;
|
||||
void fillWithBibKeys(BiblioInfo &, InsetIterator const &) const;
|
||||
///
|
||||
EmbeddedFileList const getFiles(Buffer const &) const;
|
||||
EmbeddedFileList embeddedFiles() const;
|
||||
///
|
||||
bool addDatabase(std::string const &);
|
||||
///
|
||||
@ -55,17 +55,15 @@ public:
|
||||
static bool isCompatibleCommand(std::string const & s)
|
||||
{ return s == "bibtex"; }
|
||||
///
|
||||
void registerEmbeddedFiles(Buffer const &, EmbeddedFileList &) const;
|
||||
void registerEmbeddedFiles(EmbeddedFileList &) const;
|
||||
///
|
||||
void updateEmbeddedFile(Buffer const & buf, EmbeddedFile const & file);
|
||||
|
||||
void updateEmbeddedFile(EmbeddedFile const & file);
|
||||
protected:
|
||||
///
|
||||
virtual void doDispatch(Cursor & cur, FuncRequest & cmd);
|
||||
void doDispatch(Cursor & cur, FuncRequest & cmd);
|
||||
private:
|
||||
///
|
||||
virtual Inset * clone() const;
|
||||
|
||||
Inset * clone() const;
|
||||
};
|
||||
|
||||
|
||||
|
@ -495,19 +495,17 @@ bool InsetExternal::getStatus(Cursor & cur, FuncRequest const & cmd,
|
||||
}
|
||||
|
||||
|
||||
void InsetExternal::registerEmbeddedFiles(Buffer const & buffer,
|
||||
EmbeddedFileList & files) const
|
||||
void InsetExternal::registerEmbeddedFiles(EmbeddedFileList & files) const
|
||||
{
|
||||
files.registerFile(params_.filename, this, buffer);
|
||||
files.registerFile(params_.filename, this, buffer());
|
||||
}
|
||||
|
||||
|
||||
void InsetExternal::updateEmbeddedFile(Buffer const & buf,
|
||||
EmbeddedFile const & file)
|
||||
void InsetExternal::updateEmbeddedFile(EmbeddedFile const & file)
|
||||
{
|
||||
// when embedding is enabled, change of embedding status leads to actions
|
||||
EmbeddedFile temp = file;
|
||||
temp.enable(buf.embedded(), &buf);
|
||||
temp.enable(buffer().embedded(), &buffer());
|
||||
// this will not be set if an exception is thorwn in enable()
|
||||
params_.filename = temp;
|
||||
}
|
||||
|
@ -146,9 +146,9 @@ public:
|
||||
///
|
||||
bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;
|
||||
/// external file can be embedded
|
||||
void registerEmbeddedFiles(Buffer const &, EmbeddedFileList &) const;
|
||||
void registerEmbeddedFiles(EmbeddedFileList &) const;
|
||||
///
|
||||
void updateEmbeddedFile(Buffer const &, EmbeddedFile const &);
|
||||
void updateEmbeddedFile(EmbeddedFile const &);
|
||||
|
||||
protected:
|
||||
InsetExternal(InsetExternal const &);
|
||||
|
@ -214,19 +214,17 @@ bool InsetGraphics::getStatus(Cursor & cur, FuncRequest const & cmd,
|
||||
}
|
||||
|
||||
|
||||
void InsetGraphics::registerEmbeddedFiles(Buffer const & buffer,
|
||||
EmbeddedFileList & files) const
|
||||
void InsetGraphics::registerEmbeddedFiles(EmbeddedFileList & files) const
|
||||
{
|
||||
files.registerFile(params().filename, this, buffer);
|
||||
files.registerFile(params().filename, this, buffer());
|
||||
}
|
||||
|
||||
|
||||
void InsetGraphics::updateEmbeddedFile(Buffer const & buf,
|
||||
EmbeddedFile const & file)
|
||||
void InsetGraphics::updateEmbeddedFile(EmbeddedFile const & file)
|
||||
{
|
||||
// when embedding is enabled, change of embedding status leads to actions
|
||||
EmbeddedFile temp = file;
|
||||
temp.enable(buf.embedded(), &buf);
|
||||
temp.enable(buffer().embedded(), &buffer());
|
||||
// this will not be set if an exception is thorwn in enable()
|
||||
params_.filename = temp;
|
||||
|
||||
|
@ -76,9 +76,9 @@ public:
|
||||
///
|
||||
bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;
|
||||
/// all graphics can be embedded
|
||||
void registerEmbeddedFiles(Buffer const &, EmbeddedFileList &) const;
|
||||
void registerEmbeddedFiles(EmbeddedFileList &) const;
|
||||
///
|
||||
void updateEmbeddedFile(Buffer const &, EmbeddedFile const &);
|
||||
void updateEmbeddedFile(EmbeddedFile const &);
|
||||
/// Force inset into LTR environment if surroundings are RTL?
|
||||
virtual bool forceLTR() const { return true; }
|
||||
protected:
|
||||
|
@ -908,15 +908,13 @@ void InsetInclude::updateLabels(ParIterator const &)
|
||||
}
|
||||
|
||||
|
||||
void InsetInclude::registerEmbeddedFiles(Buffer const & buffer,
|
||||
EmbeddedFileList & files) const
|
||||
void InsetInclude::registerEmbeddedFiles(EmbeddedFileList & files) const
|
||||
{
|
||||
files.registerFile(includedFilename(buffer, params()), this, buffer);
|
||||
files.registerFile(includedFilename(buffer(), params()), this, buffer());
|
||||
}
|
||||
|
||||
|
||||
void InsetInclude::updateEmbeddedFile(Buffer const & buf,
|
||||
EmbeddedFile const & file)
|
||||
void InsetInclude::updateEmbeddedFile(EmbeddedFile const & file)
|
||||
{
|
||||
InsetCommandParams p = params();
|
||||
p["filename"] = from_utf8(file.outputFilename());
|
||||
|
@ -87,9 +87,9 @@ public:
|
||||
///
|
||||
void updateLabels(ParIterator const &);
|
||||
/// child document can be embedded
|
||||
void registerEmbeddedFiles(Buffer const &, EmbeddedFileList &) const;
|
||||
void registerEmbeddedFiles(EmbeddedFileList &) const;
|
||||
///
|
||||
void updateEmbeddedFile(Buffer const & buf, EmbeddedFile const & file);
|
||||
void updateEmbeddedFile(EmbeddedFile const & file);
|
||||
///
|
||||
static ParamInfo const & findInfo(std::string const &);
|
||||
///
|
||||
|
Loading…
Reference in New Issue
Block a user