]> git.lyx.org Git - lyx.git/blobdiff - src/Buffer.cpp
Abdel is right.
[lyx.git] / src / Buffer.cpp
index dc7343677e47deeea18f4594bc7cf6c861593f11..78aaf190701e76ea13583563aa4187964d6189a9 100644 (file)
@@ -265,16 +265,9 @@ Buffer::~Buffer()
        // 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"),
@@ -599,7 +592,7 @@ void Buffer::insertStringAsLines(ParagraphList & pars,
                if (*cit == '\n') {
                        if (autobreakrows && (!par.empty() || par.allowEmpty())) {
                                breakParagraph(params(), pars, pit, pos,
-                                              par.layout()->isEnvironment());
+                                              par.layout().isEnvironment());
                                ++pit;
                                pos = 0;
                                space_inserted = true;
@@ -1069,6 +1062,8 @@ void Buffer::writeLaTeXSource(odocstream & os,
                           OutputParams const & runparams_in,
                           bool const output_preamble, bool const output_body) const
 {
+       // The child documents, if any, shall be already loaded at this point.
+
        OutputParams runparams = runparams_in;
 
        // validate the buffer.
@@ -1133,12 +1128,10 @@ void Buffer::writeLaTeXSource(odocstream & os,
        
        LYXERR(Debug::INFO, "preamble finished, now the body.");
 
-       // load children, if not already done. 
-       // This includes an updateMacro() call.
        // Don't move this behind the parent_buffer=0 code below,
        // because then the macros will not get the right "redefinition"
        // flag as they don't see the parent macros which are output before.
-       loadChildDocuments();
+       updateMacros();
 
        // fold macros if possible, still with parent buffer as the
        // macros will be put in the prefix anyway.
@@ -1292,7 +1285,7 @@ void Buffer::writeDocBookSource(odocstream & os, string const & fname,
 
        params().documentClass().counters().reset();
 
-       loadChildDocuments();
+       updateMacros();
 
        sgml::openTag(os, top);
        os << '\n';
@@ -1346,7 +1339,7 @@ void Buffer::validate(LaTeXFeatures & features) const
 {
        params().validate(features);
 
-       loadChildDocuments();
+       updateMacros();
 
        for_each(paragraphs().begin(), paragraphs().end(),
                 boost::bind(&Paragraph::validate, _1, boost::ref(features)));
@@ -1371,7 +1364,7 @@ void Buffer::getLabelList(vector<docstring> & list) const
                return;
        }
 
-       loadChildDocuments();
+       updateMacros();
 
        for (InsetIterator it = inset_iterator_begin(inset()); it; ++it)
                it.nextInset()->getLabelList(list);
@@ -1841,7 +1834,7 @@ void Buffer::updateEnvironmentMacros(DocIterator & it,
                // increased depth?
                if ((par.params().depth() > depth
                     || par.params().leftIndent() != leftIndent)
-                   && par.layout()->isEnvironment()) {
+                   && par.layout().isEnvironment()) {
                        updateBlockMacros(it, scope);
                        continue;
                }
@@ -1931,7 +1924,7 @@ void Buffer::updateBlockMacros(DocIterator & it, DocIterator & scope) const
        // set scope for macros in this paragraph:
        // * either the "old" outer scope
        // * or the scope ending after the environment
-       if (par.layout()->isEnvironment()) {
+       if (par.layout().isEnvironment()) {
                // find end of environment block,
                DocIterator envEnd = it;
                pit_type n = it.lastpit() + 1;
@@ -2359,46 +2352,6 @@ void Buffer::autoSave() const
 }
 
 
-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();
-}
-
-
-void Buffer::loadChildDocuments() const
-{
-       bool parse_error = false;
-               
-       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();
-               Buffer * child = loadIfNeeded(*this, ip);
-               if (!child)
-                       continue;
-               parse_error |= !child->errorList("Parse").empty();
-               child->loadChildDocuments();
-       }
-
-       updateMacros();
-}
-
-
 string Buffer::bufferFormat() const
 {
        if (isDocBook())