]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetInclude.cpp
Fix layout bug. Pasting text into a cell tried to set Standard layout, because
[lyx.git] / src / insets / InsetInclude.cpp
index f04f170b05a2a7862344f2aab40e6d013f36d039..5d84f0e03f0e38c2c7a09df501a6231a5c0b16d2 100644 (file)
@@ -13,7 +13,6 @@
 
 #include "InsetInclude.h"
 
-#include "LayoutFile.h"
 #include "Buffer.h"
 #include "buffer_funcs.h"
 #include "BufferList.h"
@@ -27,6 +26,7 @@
 #include "FuncRequest.h"
 #include "FuncStatus.h"
 #include "LaTeXFeatures.h"
+#include "LayoutFile.h"
 #include "LyX.h"
 #include "LyXFunc.h"
 #include "LyXRC.h"
 #include "insets/InsetListingsParams.h"
 #include "insets/RenderPreview.h"
 
-#include "support/lassert.h"
+#include "support/convert.h"
 #include "support/debug.h"
 #include "support/docstream.h"
 #include "support/FileNameList.h"
 #include "support/filetools.h"
 #include "support/gettext.h"
+#include "support/lassert.h"
 #include "support/lstrings.h" // contains
 #include "support/lyxalgo.h"
-#include "support/convert.h"
 
 #include <boost/bind.hpp>
 
@@ -185,28 +185,6 @@ InsetInclude::InsetInclude(InsetInclude const & other)
 InsetInclude::~InsetInclude()
 {
        delete label_;
-       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);
 }
 
 
@@ -303,7 +281,8 @@ bool InsetInclude::getStatus(Cursor & cur, FuncRequest const & cmd,
        switch (cmd.action) {
 
        case LFUN_INSET_EDIT:
-               flag.enabled(true);
+       case LFUN_INSET_MODIFY:
+               flag.setEnabled(true);
                return true;
 
        default:
@@ -392,7 +371,7 @@ Buffer * loadIfNeeded(Buffer const & parent, InsetCommandParams const & params)
        if (!isLyXFilename(included_file.absFilename()))
                return 0;
 
-       Buffer * child = theBufferList().getBuffer(included_file.absFilename());
+       Buffer * child = theBufferList().getBuffer(included_file);
        if (!child) {
                // the readonly flag can/will be wrong, not anymore I think.
                if (!included_file.exists())
@@ -480,7 +459,7 @@ int InsetInclude::latex(odocstream & os, OutputParams const & runparams) const
                if (!loadIfNeeded(buffer(), params()))
                        return false;
 
-               Buffer * tmp = theBufferList().getBuffer(included_file.absFilename());
+               Buffer * tmp = theBufferList().getBuffer(included_file);
 
                if (tmp->params().baseClass() != masterBuffer->params().baseClass()) {
                        // FIXME UNICODE
@@ -638,7 +617,7 @@ int InsetInclude::docbook(odocstream & os, OutputParams const & runparams) const
        DocFileName writefile(changeExtension(included_file, ".sgml"));
 
        if (loadIfNeeded(buffer(), params())) {
-               Buffer * tmp = theBufferList().getBuffer(included_file);
+               Buffer * tmp = theBufferList().getBuffer(FileName(included_file));
 
                string const mangled = writefile.mangledFilename();
                writefile = makeAbsPath(mangled,
@@ -702,7 +681,7 @@ void InsetInclude::validate(LaTeXFeatures & features) const
        // to be loaded:
        if (loadIfNeeded(buffer(), params())) {
                // a file got loaded
-               Buffer * const tmp = theBufferList().getBuffer(included_file);
+               Buffer * const tmp = theBufferList().getBuffer(FileName(included_file));
                // make sure the buffer isn't us
                // FIXME RECURSIVE INCLUDES
                // This is not sufficient, as recursive includes could be
@@ -724,7 +703,7 @@ void InsetInclude::fillWithBibKeys(BiblioInfo & keys,
 {
        if (loadIfNeeded(buffer(), params())) {
                string const included_file = includedFilename(buffer(), params()).absFilename();
-               Buffer * tmp = theBufferList().getBuffer(included_file);
+               Buffer * tmp = theBufferList().getBuffer(FileName(included_file));
                BiblioInfo const & newkeys = tmp->localBibInfo();
                keys.mergeBiblioInfo(newkeys);
        }
@@ -896,7 +875,6 @@ void InsetInclude::addToToc(DocIterator const & cpit)
                docstring str = convert<docstring>(toc.size() + 1)
                        + ". " +  from_utf8(caption);
                DocIterator pit = cpit;
-               pit.push_back(CursorSlice(*this));
                toc.push_back(TocItem(pit, 0, str));
                return;
        }
@@ -909,6 +887,7 @@ void InsetInclude::addToToc(DocIterator const & cpit)
        toc.push_back(TocItem(cpit, 0, str));
 
        TocList & toclist = backend.tocs();
+       childbuffer->tocBackend().update();
        TocList const & childtoclist = childbuffer->tocBackend().tocs();
        TocList::const_iterator it = childtoclist.begin();
        TocList::const_iterator const end = childtoclist.end();
@@ -933,12 +912,13 @@ void InsetInclude::updateLabels(ParIterator const & it)
 
        InsetListingsParams const par(to_utf8(params()["lstparams"]));
        if (par.getParamValue("caption").empty()) {
-               listings_label_.clear();
+               listings_label_ = buffer().B_("Program Listing");
                return;
        }
-       Counters & counters = buffer().params().documentClass().counters();
+       Buffer const & master = *buffer().masterBuffer();
+       Counters & counters = master.params().documentClass().counters();
        docstring const cnt = from_ascii("listing");
-       listings_label_ = buffer().B_("Program Listing");
+       listings_label_ = master.B_("Program Listing");
        if (counters.hasCounter(cnt)) {
                counters.step(cnt);
                listings_label_ += " " + convert<docstring>(counters.value(cnt));