// GuiView already destroyed
gui_ = 0;
- Buffer const * master = masterBuffer();
- if (master != this && use_gui) {
- // We are closing buf which was a child document so we
- // must update the labels and section numbering of its master
- // Buffer.
- updateLabels(*master);
- master->updateMacros();
- }
-
- resetChildDocuments(false);
+ // clear references to children in macro tables
+ d->children_positions.clear();
+ d->position_to_children.clear();
if (!d->temppath.destroyDirectory()) {
Alert::warning(_("Could not remove temporary directory"),
}
-void Buffer::resetChildDocuments(bool close_them) const
-{
- if (text().empty())
- return;
-
- for (InsetIterator it = inset_iterator_begin(inset()); it; ++it) {
- if (it->lyxCode() != INCLUDE_CODE)
- continue;
- InsetCommand const & inset = static_cast<InsetCommand const &>(*it);
- InsetCommandParams const & ip = inset.params();
-
- resetParentBuffer(this, ip, close_them);
- }
-
- // clear references to children in macro tables
- d->children_positions.clear();
- d->position_to_children.clear();
-}
-
-
string Buffer::bufferFormat() const
{
if (isDocBook())
///
void autoSave() const;
- ///
- void resetChildDocuments(bool close_them) const;
/// return the format of the buffer on a string
std::string bufferFormat() const;
}
+InsetInclude::~InsetInclude()
+{
+ if (isVerbatim(params()) || isListings(params()))
+ return;
+
+
+ string const parent_filename = buffer().absFileName();
+ FileName const included_file = makeAbsPath(to_utf8(params()["filename"]),
+ onlyPath(parent_filename));
+
+ if (!isLyXFilename(included_file.absFilename()))
+ return;
+
+ Buffer * child = theBufferList().getBuffer(included_file.absFilename());
+ // File not opened, nothing to close.
+ if (!child)
+ return;
+
+ // Child document has a different parent, don't close it.
+ if (child->parent() != &buffer())
+ return;
+
+ //close the buffer.
+ theBufferList().release(child);
+}
+
+
ParamInfo const & InsetInclude::findInfo(string const & /* cmdName */)
{
// FIXME
}
-void resetParentBuffer(Buffer const * parent, InsetCommandParams const & params,
- bool close_it)
-{
- if (isVerbatim(params) || isListings(params))
- return;
-
- string const parent_filename = parent->absFileName();
- FileName const included_file = makeAbsPath(to_utf8(params["filename"]),
- onlyPath(parent_filename));
-
- if (!isLyXFilename(included_file.absFilename()))
- return;
-
- Buffer * child = theBufferList().getBuffer(included_file.absFilename());
- // File not opened, nothing to close.
- if (!child)
- return;
-
- // Child document has a different parent, don't close it.
- if (child->parent() != parent)
- return;
-
- //close the buffer.
- child->setParent(0);
- if (close_it)
- theBufferList().release(child);
- else
- updateLabels(*child);
-}
-
-
int InsetInclude::latex(odocstream & os, OutputParams const & runparams) const
{
string incfile = to_utf8(params()["filename"]);
public:
///
InsetInclude(InsetCommandParams const &);
+ ~InsetInclude();
/// Override these InsetButton methods if Previewing
void metrics(MetricsInfo & mi, Dimension & dim) const;
mutable docstring listings_label_;
};
-/// return the child buffer if the file is a LyX doc and is loaded
-Buffer * getChildBuffer(Buffer const & buffer, InsetCommandParams const & params);
-
/// return loaded Buffer or zero if the file loading did not proceed.
Buffer * loadIfNeeded(Buffer const & parent, InsetCommandParams const & params);
-///
-void resetParentBuffer(Buffer const * parent, InsetCommandParams const & params,
- bool close_it);
-
} // namespace lyx
#endif // INSETINCLUDE_H