]> git.lyx.org Git - features.git/blobdiff - src/insets/InsetInclude.cpp
Use new display() values to remove some inset hardcoding.
[features.git] / src / insets / InsetInclude.cpp
index d7095cc80f2584ee46ee9a8341b1078d36e000a7..d6936c837e6f3668ea279d3c78056aacfde06cd9 100644 (file)
@@ -236,6 +236,13 @@ bool InsetInclude::isCompatibleCommand(string const & s)
 }
 
 
+bool InsetInclude::needsCProtection(bool const /*maintext*/, bool const fragile) const
+{
+       // We need to \cprotect all types in fragile context
+       return fragile;
+}
+
+
 void InsetInclude::doDispatch(Cursor & cur, FuncRequest & cmd)
 {
        switch (cmd.action()) {
@@ -788,8 +795,16 @@ void InsetInclude::latex(otexstream & os, OutputParams const & runparams) const
                runparams.par_begin = 0;
                runparams.par_end = tmp->paragraphs().size();
                runparams.is_child = true;
-               if (!tmp->makeLaTeXFile(tmpwritefile, masterFileName(buffer()).
-                               onlyPath().absFileName(), runparams, Buffer::OnlyBody)) {
+               Buffer::ExportStatus retval =
+                       tmp->makeLaTeXFile(tmpwritefile, masterFileName(buffer()).
+                               onlyPath().absFileName(), runparams, Buffer::OnlyBody);
+               if (retval == Buffer::ExportKilled && buffer().isClone() &&
+                     buffer().isExporting()) {
+                 // We really shouldn't get here, I don't think.
+                 LYXERR0("No conversion exception?");
+                       throw ConversionException();
+               }
+               else if (retval != Buffer::ExportSuccess) {
                        if (!runparams.silent) {
                                docstring msg = bformat(_("Included file `%1$s' "
                                        "was not exported correctly.\n "
@@ -798,10 +813,8 @@ void InsetInclude::latex(otexstream & os, OutputParams const & runparams) const
                                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);
-                               throw ExceptionMessage(ErrorException, _("Error: "),
-                                                      msg);
+                                               msg, el.begin()->error, el.begin()->description);
+                               throw ExceptionMessage(ErrorException, _("Error: "), msg);
                        }
                }
                runparams.encoding = oldEnc;
@@ -811,22 +824,23 @@ void InsetInclude::latex(otexstream & os, OutputParams const & runparams) const
                // If needed, use converters to produce a latex file from the child
                if (tmpwritefile != writefile) {
                        ErrorList el;
-                       bool const success =
+                       Converters::RetVal const retval =
                                theConverters().convert(tmp, tmpwritefile, writefile,
-                                                       included_file,
-                                                       inc_format, tex_format, el);
-
-                       if (!success && !runparams.silent) {
+                                   included_file, inc_format, tex_format, el);
+                       if (retval == Converters::KILLED && buffer().isClone() &&
+                           buffer().isExporting()) {
+                               // We really shouldn't get here, I don't think.
+                               LYXERR0("No conversion exception?");
+                               throw ConversionException();
+                       } else if (retval != Converters::SUCCESS && !runparams.silent) {
                                docstring msg = bformat(_("Included file `%1$s' "
                                                "was not exported correctly.\n "
                                                "LaTeX export is probably incomplete."),
                                                included_file.displayName());
                                if (!el.empty())
                                        msg = bformat(from_ascii("%1$s\n\n%2$s\n\n%3$s"),
-                                                       msg, el.begin()->error,
-                                                       el.begin()->description);
-                               throw ExceptionMessage(ErrorException, _("Error: "),
-                                                      msg);
+                                               msg, el.begin()->error, el.begin()->description);
+                               throw ExceptionMessage(ErrorException, _("Error: "), msg);
                        }
                }
        } else {
@@ -1145,7 +1159,7 @@ string InsetInclude::contextMenuName() const
 
 Inset::DisplayType InsetInclude::display() const
 {
-       return type(params()) == INPUT ? Inline : AlignCenter;
+       return type(params()) == INPUT ? Inline : Display;
 }