]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetFloat.cpp
Handle the case of TeX fonts LuaTeX
[lyx.git] / src / insets / InsetFloat.cpp
index 1cda8d9cbacb0982cf7d2fe57f96e08e3dbb5872..7a95178227230f14607555698c0f1af35ccb8ea0 100644 (file)
@@ -29,6 +29,8 @@
 #include "Lexer.h"
 #include "output_xhtml.h"
 #include "ParIterator.h"
+#include "TexRow.h"
+#include "texstream.h"
 #include "TextClass.h"
 
 #include "support/debug.h"
@@ -304,16 +306,17 @@ docstring InsetFloat::xhtml(XHTMLStream & xs, OutputParams const & rp) const
        docstring deferred = InsetText::insetAsXHTML(newxs, rp, opts);
        newxs << html::EndTag(htmltype);
 
-       if (rp.inFloat == OutputParams::NONFLOAT)
+       if (rp.inFloat == OutputParams::NONFLOAT) {
                // In this case, this float needs to be deferred, but we'll put it
                // before anything the text itself deferred.
                deferred = ods.str() + '\n' + deferred;
-       else 
+       } else {
                // In this case, the whole thing is already being deferred, so
                // we can write to the stream.
                // Note that things will already have been escaped, so we do not 
                // want to escape them again.
                xs << XHTMLStream::ESCAPE_NONE << ods.str();
+       }
        return deferred;
 }
 
@@ -321,16 +324,17 @@ docstring InsetFloat::xhtml(XHTMLStream & xs, OutputParams const & rp) const
 void InsetFloat::latex(otexstream & os, OutputParams const & runparams_in) const
 {
        if (runparams_in.inFloat != OutputParams::NONFLOAT) {
+               if (!paragraphs().empty() && !runparams_in.nice)
+                       // improve TexRow precision in non-nice mode
+                       os << safebreakln;
+
                if (runparams_in.moving_arg)
                        os << "\\protect";
                os << "\\subfloat";
 
                OutputParams rp = runparams_in;
                rp.moving_arg = true;
-               docstring const caption = getCaption(rp);
-               if (!caption.empty()) {
-                       os << caption;
-               }
+               os << getCaption(rp);
                os << '{';
                // The main argument is the contents of the float. This is not a moving argument.
                rp.moving_arg = false;
@@ -488,34 +492,35 @@ void InsetFloat::setNewLabel()
 
 bool InsetFloat::allowsCaptionVariation(std::string const & newtype) const
 {
-       return !params_.subfloat && newtype != "LongTableNoNumber";
+       return !params_.subfloat && newtype != "Unnumbered";
 }
 
 
-docstring InsetFloat::getCaption(OutputParams const & runparams) const
+TexString InsetFloat::getCaption(OutputParams const & runparams) const
 {
-       if (paragraphs().empty())
-               return docstring();
-
        InsetCaption const * ins = getCaptionInset();
        if (ins == 0)
-               return docstring();
+               return TexString();
 
-       TexRow texrow;
-       odocstringstream ods;
-       otexstream os(ods, texrow);
+       otexstringstream os;
        ins->getArgs(os, runparams);
-       ods << '[';
-       odocstringstream odss;
-       otexstream oss(odss, texrow);
-       ins->getArgument(oss, runparams);
-       docstring arg = odss.str();
+
+       if (!runparams.nice)
+               // increase TexRow precision in non-nice mode
+               os << safebreakln;
+       os << '[';
+       otexstringstream os2;
+       ins->getArgument(os2, runparams);
+       TexString ts = os2.release();
+       docstring & arg = ts.str;
        // Protect ']'
        if (arg.find(']') != docstring::npos)
                arg = '{' + arg + '}';
-       ods << arg;
-       ods << ']';
-       return ods.str();
+       os << move(ts);
+       os << ']';
+       if (!runparams.nice)
+               os << safebreakln;
+       return os.release();
 }