mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-23 10:18:50 +00:00
Make getChildBuffer() and loadIfNeeded() methods rather than standalone
functions. Preparatory to another patch. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@27687 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
78ab480e72
commit
aeb997e3f0
@ -1925,11 +1925,10 @@ void Buffer::updateMacros(DocIterator & it, DocIterator & scope) const
|
||||
// is it an external file?
|
||||
if (iit->inset->lyxCode() == INCLUDE_CODE) {
|
||||
// get buffer of external file
|
||||
InsetCommand const & inset
|
||||
= static_cast<InsetCommand const &>(*iit->inset);
|
||||
InsetCommandParams const & ip = inset.params();
|
||||
InsetInclude const & inset
|
||||
= static_cast<InsetInclude const &>(*iit->inset);
|
||||
d->macro_lock = true;
|
||||
Buffer * child = loadIfNeeded(*this, ip);
|
||||
Buffer * child = inset.loadIfNeeded(*this);
|
||||
d->macro_lock = false;
|
||||
if (!child)
|
||||
continue;
|
||||
|
@ -351,31 +351,31 @@ docstring InsetInclude::screenLabel() const
|
||||
}
|
||||
|
||||
|
||||
/// return the child buffer if the file is a LyX doc and is loaded
|
||||
Buffer * getChildBuffer(Buffer const & buffer, InsetCommandParams const & params)
|
||||
Buffer * InsetInclude::getChildBuffer(Buffer const & buffer) const
|
||||
{
|
||||
if (isVerbatim(params) || isListings(params))
|
||||
InsetCommandParams const & p = params();
|
||||
if (isVerbatim(p) || isListings(p))
|
||||
return 0;
|
||||
|
||||
string const included_file = includedFilename(buffer, params).absFilename();
|
||||
string const included_file = includedFilename(buffer, p).absFilename();
|
||||
if (!isLyXFilename(included_file))
|
||||
return 0;
|
||||
|
||||
Buffer * childBuffer = loadIfNeeded(buffer, params);
|
||||
Buffer * childBuffer = loadIfNeeded(buffer);
|
||||
|
||||
// FIXME: recursive includes
|
||||
return (childBuffer == &buffer) ? 0 : childBuffer;
|
||||
}
|
||||
|
||||
|
||||
/// return true if the file is or got loaded.
|
||||
Buffer * loadIfNeeded(Buffer const & parent, InsetCommandParams const & params)
|
||||
Buffer * InsetInclude::loadIfNeeded(Buffer const & parent) const
|
||||
{
|
||||
if (isVerbatim(params) || isListings(params))
|
||||
InsetCommandParams const & p = params();
|
||||
if (isVerbatim(p) || isListings(p))
|
||||
return 0;
|
||||
|
||||
string const parent_filename = parent.absFileName();
|
||||
FileName const included_file = makeAbsPath(to_utf8(params["filename"]),
|
||||
FileName const included_file = makeAbsPath(to_utf8(p["filename"]),
|
||||
onlyPath(parent_filename));
|
||||
|
||||
if (!isLyXFilename(included_file.absFilename()))
|
||||
@ -466,7 +466,7 @@ int InsetInclude::latex(odocstream & os, OutputParams const & runparams) const
|
||||
isLyXFilename(included_file.absFilename())) {
|
||||
//if it's a LyX file and we're inputting or including,
|
||||
//try to load it so we can write the associated latex
|
||||
if (!loadIfNeeded(buffer(), params()))
|
||||
if (!loadIfNeeded(buffer()))
|
||||
return false;
|
||||
|
||||
Buffer * tmp = theBufferList().getBuffer(included_file);
|
||||
@ -626,7 +626,7 @@ int InsetInclude::docbook(odocstream & os, OutputParams const & runparams) const
|
||||
string const exportfile = changeExtension(incfile, ".sgml");
|
||||
DocFileName writefile(changeExtension(included_file, ".sgml"));
|
||||
|
||||
if (loadIfNeeded(buffer(), params())) {
|
||||
if (loadIfNeeded(buffer())) {
|
||||
Buffer * tmp = theBufferList().getBuffer(FileName(included_file));
|
||||
|
||||
string const mangled = writefile.mangledFilename();
|
||||
@ -689,7 +689,7 @@ void InsetInclude::validate(LaTeXFeatures & features) const
|
||||
// Here we must do the fun stuff...
|
||||
// Load the file in the include if it needs
|
||||
// to be loaded:
|
||||
if (loadIfNeeded(buffer(), params())) {
|
||||
if (loadIfNeeded(buffer())) {
|
||||
// a file got loaded
|
||||
Buffer * const tmp = theBufferList().getBuffer(FileName(included_file));
|
||||
// make sure the buffer isn't us
|
||||
@ -711,7 +711,7 @@ void InsetInclude::validate(LaTeXFeatures & features) const
|
||||
void InsetInclude::fillWithBibKeys(BiblioInfo & keys,
|
||||
InsetIterator const & /*di*/) const
|
||||
{
|
||||
if (loadIfNeeded(buffer(), params())) {
|
||||
if (loadIfNeeded(buffer())) {
|
||||
string const included_file = includedFilename(buffer(), params()).absFilename();
|
||||
Buffer * tmp = theBufferList().getBuffer(FileName(included_file));
|
||||
BiblioInfo const & newkeys = tmp->localBibInfo();
|
||||
@ -722,7 +722,7 @@ void InsetInclude::fillWithBibKeys(BiblioInfo & keys,
|
||||
|
||||
void InsetInclude::updateBibfilesCache()
|
||||
{
|
||||
Buffer * const tmp = getChildBuffer(buffer(), params());
|
||||
Buffer * const tmp = getChildBuffer(buffer());
|
||||
if (tmp) {
|
||||
tmp->setParent(0);
|
||||
tmp->updateBibfilesCache();
|
||||
@ -734,7 +734,7 @@ void InsetInclude::updateBibfilesCache()
|
||||
support::FileNameList const &
|
||||
InsetInclude::getBibfilesCache(Buffer const & buffer) const
|
||||
{
|
||||
Buffer * const tmp = getChildBuffer(buffer, params());
|
||||
Buffer * const tmp = getChildBuffer(buffer);
|
||||
if (tmp) {
|
||||
tmp->setParent(0);
|
||||
support::FileNameList const & cache = tmp->getBibfilesCache();
|
||||
@ -888,7 +888,7 @@ void InsetInclude::addToToc(DocIterator const & cpit)
|
||||
toc.push_back(TocItem(pit, 0, str));
|
||||
return;
|
||||
}
|
||||
Buffer const * const childbuffer = getChildBuffer(buffer(), params());
|
||||
Buffer const * const childbuffer = getChildBuffer(buffer());
|
||||
if (!childbuffer)
|
||||
return;
|
||||
|
||||
@ -909,7 +909,7 @@ void InsetInclude::addToToc(DocIterator const & cpit)
|
||||
|
||||
void InsetInclude::updateLabels(ParIterator const & it)
|
||||
{
|
||||
Buffer const * const childbuffer = getChildBuffer(buffer(), params());
|
||||
Buffer const * const childbuffer = getChildBuffer(buffer());
|
||||
if (childbuffer) {
|
||||
childbuffer->updateLabels(true);
|
||||
return;
|
||||
|
@ -95,6 +95,10 @@ public:
|
||||
static bool isCompatibleCommand(std::string const & s);
|
||||
///
|
||||
docstring contextMenu(BufferView const & bv, int x, int y) const;
|
||||
/// \return the child buffer if the file is a LyX doc and is loaded
|
||||
Buffer * getChildBuffer(Buffer const & buffer) const;
|
||||
/// \return loaded Buffer or zero if the file loading did not proceed.
|
||||
Buffer * loadIfNeeded(Buffer const & parent) const;
|
||||
protected:
|
||||
InsetInclude(InsetInclude const &);
|
||||
///
|
||||
@ -128,8 +132,6 @@ private:
|
||||
InsetLabel * label_;
|
||||
};
|
||||
|
||||
/// return loaded Buffer or zero if the file loading did not proceed.
|
||||
Buffer * loadIfNeeded(Buffer const & parent, InsetCommandParams const & params);
|
||||
|
||||
} // namespace lyx
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user