]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetInclude.cpp
Typos and style.
[lyx.git] / src / insets / InsetInclude.cpp
index 9a6ed47fcfd9b34037f0af69b8b844a6519a4996..506f3586e071e50f833578198cd83bb4a7d4a4ca 100644 (file)
@@ -76,6 +76,7 @@ namespace {
 
 docstring const uniqueID()
 {
+       // FIXME THREAD
        static unsigned int seed = 1000;
        return "file" + convert<docstring>(++seed);
 }
@@ -407,7 +408,9 @@ Buffer * InsetInclude::getChildBuffer() const
 {
        Buffer * childBuffer = loadIfNeeded(); 
 
-       // FIXME: recursive includes
+       // FIXME RECURSIVE INCLUDE
+       // This isn't sufficient, as the inclusion could be downstream.
+       // But it'll have to do for now.
        return (childBuffer == &buffer()) ? 0 : childBuffer;
 }
 
@@ -536,6 +539,8 @@ void InsetInclude::latex(otexstream & os, OutputParams const & runparams) const
 
        if (!runparams.nice)
                incfile = mangled;
+       else if (!runparams.silent)
+               ; // no warning wanted
        else if (!isValidLaTeXFileName(incfile)) {
                frontend::Alert::warning(_("Invalid filename"),
                        _("The following filename will cause troubles "
@@ -626,42 +631,46 @@ void InsetInclude::latex(otexstream & os, OutputParams const & runparams) const
 
                Buffer * tmp = loadIfNeeded();
                if (!tmp) {
-                       docstring text = bformat(_("Could not load included "
-                               "file\n`%1$s'\n"
-                               "Please, check whether it actually exists."),
-                               included_file.displayName());
-                       Alert::warning(_("Missing included file"), text);
+                       if (!runparams.silent) {
+                               docstring text = bformat(_("Could not load included "
+                                       "file\n`%1$s'\n"
+                                       "Please, check whether it actually exists."),
+                                       included_file.displayName());
+                               Alert::warning(_("Missing included file"), text);
+                       }
                        return;
                }
 
-               if (tmp->params().baseClass() != masterBuffer->params().baseClass()) {
-                       // FIXME UNICODE
-                       docstring text = bformat(_("Included file `%1$s'\n"
-                               "has textclass `%2$s'\n"
-                               "while parent file has textclass `%3$s'."),
-                               included_file.displayName(),
-                               from_utf8(tmp->params().documentClass().name()),
-                               from_utf8(masterBuffer->params().documentClass().name()));
-                       Alert::warning(_("Different textclasses"), text, true);
-               }
-
-               // Make sure modules used in child are all included in master
-               // FIXME It might be worth loading the children's modules into the master
-               // over in BufferParams rather than doing this check.
-               LayoutModuleList const masterModules = masterBuffer->params().getModules();
-               LayoutModuleList const childModules = tmp->params().getModules();
-               LayoutModuleList::const_iterator it = childModules.begin();
-               LayoutModuleList::const_iterator end = childModules.end();
-               for (; it != end; ++it) {
-                       string const module = *it;
-                       LayoutModuleList::const_iterator found =
-                               find(masterModules.begin(), masterModules.end(), module);
-                       if (found == masterModules.end()) {
+               if (!runparams.silent) {
+                       if (tmp->params().baseClass() != masterBuffer->params().baseClass()) {
+                               // FIXME UNICODE
                                docstring text = bformat(_("Included file `%1$s'\n"
-                                       "uses module `%2$s'\n"
-                                       "which is not used in parent file."),
-                                       included_file.displayName(), from_utf8(module));
-                               Alert::warning(_("Module not found"), text);
+                                       "has textclass `%2$s'\n"
+                                       "while parent file has textclass `%3$s'."),
+                                       included_file.displayName(),
+                                       from_utf8(tmp->params().documentClass().name()),
+                                       from_utf8(masterBuffer->params().documentClass().name()));
+                               Alert::warning(_("Different textclasses"), text, true);
+                       }
+
+                       // Make sure modules used in child are all included in master
+                       // FIXME It might be worth loading the children's modules into the master
+                       // over in BufferParams rather than doing this check.
+                       LayoutModuleList const masterModules = masterBuffer->params().getModules();
+                       LayoutModuleList const childModules = tmp->params().getModules();
+                       LayoutModuleList::const_iterator it = childModules.begin();
+                       LayoutModuleList::const_iterator end = childModules.end();
+                       for (; it != end; ++it) {
+                               string const module = *it;
+                               LayoutModuleList::const_iterator found =
+                                       find(masterModules.begin(), masterModules.end(), module);
+                               if (found == masterModules.end()) {
+                                       docstring text = bformat(_("Included file `%1$s'\n"
+                                               "uses module `%2$s'\n"
+                                               "which is not used in parent file."),
+                                               included_file.displayName(), from_utf8(module));
+                                       Alert::warning(_("Module not found"), text);
+                               }
                        }
                }
 
@@ -688,16 +697,18 @@ void InsetInclude::latex(otexstream & os, OutputParams const & runparams) const
                runparams.is_child = true;
                if (!tmp->makeLaTeXFile(tmpwritefile, masterFileName(buffer()).
                                onlyPath().absFileName(), runparams, Buffer::OnlyBody)) {
-                       docstring msg = bformat(_("Included file `%1$s' "
+                       if (!runparams.silent) {
+                               docstring msg = bformat(_("Included file `%1$s' "
                                        "was not exported correctly.\nWarning: "
                                        "LaTeX export is probably incomplete."),
                                        included_file.displayName());
-                       ErrorList const & el = tmp->errorList("Export");
-                       if (!el.empty())
-                               msg = bformat(from_ascii("%1$s\n\n%2$s\n\n%3$s"),
+                               ErrorList const & el = tmp->errorList("Export");
+                               if (!el.empty())
+                                       msg = bformat(from_ascii("%1$s\n\n%2$s\n\n%3$s"),
                                                msg, el.begin()->error,
                                                el.begin()->description);
-                       Alert::warning(_("Export failure"), msg);
+                               Alert::warning(_("Export failure"), msg);
+                       }
                }
                runparams.encoding = oldEnc;
                runparams.master_language = oldLang;
@@ -711,7 +722,7 @@ void InsetInclude::latex(otexstream & os, OutputParams const & runparams) const
                                                        included_file,
                                                        inc_format, tex_format, el);
 
-                       if (!success) {
+                       if (!success && !runparams.silent) {
                                docstring msg = bformat(_("Included file `%1$s' "
                                                "was not exported correctly.\nWarning: "
                                                "LaTeX export is probably incomplete."),
@@ -769,7 +780,8 @@ docstring InsetInclude::xhtml(XHTMLStream & xs, OutputParams const & rp) const
        // converter on the included file. But that's just masochistic.)
        FileName const included_file = includedFileName(buffer(), params());
        if (!isLyXFileName(included_file.absFileName())) {
-               frontend::Alert::warning(_("Unsupported Inclusion"),
+               if (!rp.silent)
+                       frontend::Alert::warning(_("Unsupported Inclusion"),
                                         bformat(_("LyX does not know how to include non-LyX files when "
                                                   "generating HTML output. Offending file:\n%1$s"),
                                                    params()["filename"]));
@@ -963,6 +975,11 @@ void InsetInclude::collectBibKeys(InsetIterator const & /*di*/) const
        Buffer * child = loadIfNeeded();
        if (!child)
                return;
+       // FIXME RECURSIVE INCLUDE
+       // This isn't sufficient, as the inclusion could be downstream.
+       // But it'll have to do for now.
+       if (child == &buffer())
+               return;
        child->collectBibKeys();
 }