]> git.lyx.org Git - lyx.git/blobdiff - src/output_latex.cpp
do what the FIXME suggested
[lyx.git] / src / output_latex.cpp
index b0e42693aa5bb9b840db3a68f0517e0e3771b8f2..335c7d01f9a82a43a7b76b1d89d50db6389189ad 100644 (file)
@@ -14,7 +14,6 @@
 
 #include "Buffer.h"
 #include "BufferParams.h"
-#include "support/debug.h"
 #include "Encoding.h"
 #include "InsetList.h"
 #include "Language.h"
@@ -31,6 +30,7 @@
 #include "insets/InsetBibitem.h"
 #include "insets/InsetOptArg.h"
 
+#include "support/debug.h"
 #include "support/lstrings.h"
 
 #include <boost/next_prior.hpp>
@@ -108,7 +108,8 @@ TeXEnvironment(Buffer const & buf,
 
        BufferParams const & bparams = buf.params();
 
-       LayoutPtr const & style = pit->layout();
+       LayoutPtr const & style = pit->forceEmptyLayout() ?
+                       bparams.documentClass().emptyLayout() : pit->layout();
 
        ParagraphList const & paragraphs = text.paragraphs();
 
@@ -157,7 +158,7 @@ TeXEnvironment(Buffer const & buf,
        if (style->isEnvironment()) {
                os << "\\begin{" << from_ascii(style->latexname()) << '}';
                if (style->optionalargs > 0) {
-                       int ret = latexOptArgInsets(buf, *pit, os, runparams,
+                       int ret = latexOptArgInsets(*pit, os, runparams,
                                                    style->optionalargs);
                        while (ret > 0) {
                                texrow.newline();
@@ -252,8 +253,8 @@ TeXEnvironment(Buffer const & buf,
 }
 
 
-int latexOptArgInsets(Buffer const & buf, Paragraph const & par,
-                     odocstream & os, OutputParams const & runparams, int number)
+int latexOptArgInsets(Paragraph const & par, odocstream & os,
+       OutputParams const & runparams, int number)
 {
        int lines = 0;
 
@@ -263,7 +264,7 @@ int latexOptArgInsets(Buffer const & buf, Paragraph const & par,
                if (it->inset->lyxCode() == OPTARG_CODE) {
                        InsetOptArg * ins =
                                static_cast<InsetOptArg *>(it->inset);
-                       lines += ins->latexOptional(buf, os, runparams);
+                       lines += ins->latexOptional(os, runparams);
                        --number;
                }
        }
@@ -284,7 +285,6 @@ TeXOnePar(Buffer const & buf,
        LYXERR(Debug::LATEX, "TeXOnePar...     " << &*pit << " '"
                << everypar << "'");
        BufferParams const & bparams = buf.params();
-       LayoutPtr style;
        ParagraphList const & paragraphs = text.paragraphs();
 
        if (runparams_in.verbatim) {
@@ -297,18 +297,19 @@ TeXOnePar(Buffer const & buf,
                        texrow.newline();
                }
 
-               /*bool need_par = */ pit->latex(buf, bparams, outerfont,
+               /*bool need_par = */ pit->latex(bparams, outerfont,
                        os, texrow, runparams_in);
 
                return ++pit;
        }
 
+       // FIXME This comment doesn't make sense. What's the
+       // length got to do with forceEmptyLayout()? I.e., what
+       // was forceDefaultParagraphs()?
        // In an inset with unlimited length (all in one row),
        // force layout to default
-       if (!pit->forceDefaultParagraphs())
-               style = pit->layout();
-       else
-               style = bparams.getTextClass().defaultLayout();
+       LayoutPtr const style = pit->forceEmptyLayout() ?
+               bparams.documentClass().emptyLayout() : pit->layout();
 
        OutputParams runparams = runparams_in;
        runparams.moving_arg |= style->needprotect;
@@ -476,10 +477,8 @@ TeXOnePar(Buffer const & buf,
                }
        }
 
-       // In an inset with unlimited length (all in one row),
-       // don't allow any special options in the paragraph
-       bool const useSetSpace = bparams.getTextClass().provides("SetSpace");
-       if (!pit->forceDefaultParagraphs()) {
+       bool const useSetSpace = bparams.documentClass().provides("SetSpace");
+       if (pit->allowParagraphCustomization()) {
                if (pit->params().startOfAppendix()) {
                        os << "\\appendix\n";
                        texrow.newline();
@@ -506,7 +505,7 @@ TeXOnePar(Buffer const & buf,
 
                // Separate handling of optional argument inset.
                if (style->optionalargs > 0) {
-                       int ret = latexOptArgInsets(buf, *pit, os, runparams,
+                       int ret = latexOptArgInsets(*pit, os, runparams,
                                                    style->optionalargs);
                        while (ret > 0) {
                                texrow.newline();
@@ -527,13 +526,12 @@ TeXOnePar(Buffer const & buf,
                break;
        }
 
-       Font const outerfont =
-               outerFont(distance(paragraphs.begin(), pit),
+       Font const outerfont = outerFont(distance(paragraphs.begin(), pit),
                          paragraphs);
 
        // FIXME UNICODE
        os << from_utf8(everypar);
-       bool need_par = pit->latex(buf, bparams, outerfont,
+       bool need_par = pit->latex(bparams, outerfont,
                                             os, texrow, runparams);
 
        // Make sure that \\par is done with the font of the last
@@ -546,10 +544,9 @@ TeXOnePar(Buffer const & buf,
        // We do not need to use to change the font for the last paragraph
        // or for a command.
 
-       Font const font =
-               (pit->empty()
+       Font const font = pit->empty()
                 ? pit->getLayoutFont(bparams, outerfont)
-                : pit->getFont(bparams, pit->size() - 1, outerfont));
+                : pit->getFont(bparams, pit->size() - 1, outerfont);
 
        bool is_command = style->isCommand();
 
@@ -590,7 +587,7 @@ TeXOnePar(Buffer const & buf,
                        pending_newline = true;
        }
 
-       if (!pit->forceDefaultParagraphs()) {
+       if (pit->allowParagraphCustomization()) {
                if (!pit->params().spacing().isDefault()
                        && (boost::next(pit) == paragraphs.end()
                            || !boost::next(pit)->hasSameLayout(*pit)))
@@ -744,7 +741,7 @@ void latexParagraphs(Buffer const & buf,
        bool was_title = false;
        bool already_title = false;
        BufferParams const & bparams = buf.params();
-       TextClass const & tclass = bparams.getTextClass();
+       DocumentClass const & tclass = bparams.documentClass();
        ParagraphList const & paragraphs = text.paragraphs();
        ParagraphList::const_iterator par = paragraphs.begin();
        ParagraphList::const_iterator endpar = paragraphs.end();
@@ -791,8 +788,10 @@ void latexParagraphs(Buffer const & buf,
                // any special options in the paragraph and also we don't allow
                // any environment other than the default layout of the
                // text class to be valid!
-               if (!par->forceDefaultParagraphs()) {
-                       LayoutPtr const & layout = par->layout();
+               if (par->allowParagraphCustomization()) {
+                       LayoutPtr const & layout = par->forceEmptyLayout() ?
+                                       tclass.emptyLayout() :
+                                       par->layout();
 
                        if (layout->intitle) {
                                if (already_title) {