From 9b39c142b6a7b1f7a131906b15cdd602cc0237f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20P=C3=B6nitz?= Date: Wed, 27 Feb 2008 21:51:29 +0000 Subject: [PATCH] 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 --- src/Buffer.cpp | 2 +- src/EmbeddedFiles.cpp | 16 +++++++------- src/EmbeddedFiles.h | 2 +- src/insets/Inset.cpp | 2 +- src/insets/Inset.h | 4 ++-- src/insets/InsetBibtex.cpp | 41 ++++++++++++++++++------------------ src/insets/InsetBibtex.h | 14 ++++++------ src/insets/InsetExternal.cpp | 10 ++++----- src/insets/InsetExternal.h | 4 ++-- src/insets/InsetGraphics.cpp | 10 ++++----- src/insets/InsetGraphics.h | 4 ++-- src/insets/InsetInclude.cpp | 8 +++---- src/insets/InsetInclude.h | 4 ++-- 13 files changed, 57 insertions(+), 64 deletions(-) diff --git a/src/Buffer.cpp b/src/Buffer.cpp index 70ab9f8f97..3a6109c6c3 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -1388,7 +1388,7 @@ void Buffer::updateBibfilesCache() const if (it->lyxCode() == BIBTEX_CODE) { InsetBibtex const & inset = static_cast(*it); - EmbeddedFileList const bibfiles = inset.getFiles(*this); + EmbeddedFileList const bibfiles = inset.embeddedFiles(); d->bibfilesCache_.insert(d->bibfilesCache_.end(), bibfiles.begin(), bibfiles.end()); diff --git a/src/EmbeddedFiles.cpp b/src/EmbeddedFiles.cpp index 59e9371015..9d6edc3411 100644 --- a/src/EmbeddedFiles.cpp +++ b/src/EmbeddedFiles.cpp @@ -246,12 +246,12 @@ bool EmbeddedFile::updateFromExternalFile() const } -void EmbeddedFile::updateInsets(Buffer const * buf) const +void EmbeddedFile::updateInsets() const { vector::const_iterator it = inset_list_.begin(); vector::const_iterator it_end = inset_list_.end(); for (; it != it_end; ++it) - const_cast(*it)->updateEmbeddedFile(*buf, *this); + const_cast(*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)->updateEmbeddedFile(buffer, *it); + const_cast(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 diff --git a/src/EmbeddedFiles.h b/src/EmbeddedFiles.h index b0d719ba85..0a6e3894b8 100644 --- a/src/EmbeddedFiles.h +++ b/src/EmbeddedFiles.h @@ -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; diff --git a/src/insets/Inset.cpp b/src/insets/Inset.cpp index 1a9ee79b4d..8a028096de 100644 --- a/src/insets/Inset.cpp +++ b/src/insets/Inset.cpp @@ -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 diff --git a/src/insets/Inset.h b/src/insets/Inset.h index 679fd62a64..c2d1a21b90 100644 --- a/src/insets/Inset.h +++ b/src/insets/Inset.h @@ -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 diff --git a/src/insets/InsetBibtex.cpp b/src/insets/InsetBibtex.cpp index b898efd814..4d79ffa7fa 100644 --- a/src/insets/InsetBibtex.cpp +++ b/src/insets/InsetBibtex.cpp @@ -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::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::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()); } diff --git a/src/insets/InsetBibtex.h b/src/insets/InsetBibtex.h index 9348d277f8..5c825f8773 100644 --- a/src/insets/InsetBibtex.h +++ b/src/insets/InsetBibtex.h @@ -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; }; diff --git a/src/insets/InsetExternal.cpp b/src/insets/InsetExternal.cpp index ee7bc0508e..633175c4b2 100644 --- a/src/insets/InsetExternal.cpp +++ b/src/insets/InsetExternal.cpp @@ -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; } diff --git a/src/insets/InsetExternal.h b/src/insets/InsetExternal.h index 94d48e597b..fa07e0ac08 100644 --- a/src/insets/InsetExternal.h +++ b/src/insets/InsetExternal.h @@ -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 &); diff --git a/src/insets/InsetGraphics.cpp b/src/insets/InsetGraphics.cpp index 0bc5a6187d..eb6fbb0572 100644 --- a/src/insets/InsetGraphics.cpp +++ b/src/insets/InsetGraphics.cpp @@ -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; diff --git a/src/insets/InsetGraphics.h b/src/insets/InsetGraphics.h index 9adef61744..6d2da3bc6a 100644 --- a/src/insets/InsetGraphics.h +++ b/src/insets/InsetGraphics.h @@ -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: diff --git a/src/insets/InsetInclude.cpp b/src/insets/InsetInclude.cpp index be7d0c330e..0e0ace5bc4 100644 --- a/src/insets/InsetInclude.cpp +++ b/src/insets/InsetInclude.cpp @@ -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()); diff --git a/src/insets/InsetInclude.h b/src/insets/InsetInclude.h index f1bdf3c07b..e715b8b4a6 100644 --- a/src/insets/InsetInclude.h +++ b/src/insets/InsetInclude.h @@ -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 &); ///