]> git.lyx.org Git - lyx.git/blobdiff - src/output_latex.C
* Replace all use of 'slashify_path' with 'internal_path'.
[lyx.git] / src / output_latex.C
index f1fcc38d9671adc251650d3f156d881fe4858856..3fb0fe5d3dc461d86f7f12aef525868941985033 100644 (file)
@@ -18,6 +18,7 @@
 #include "encoding.h"
 #include "language.h"
 #include "lyxrc.h"
+#include "outputparams.h"
 #include "paragraph.h"
 #include "paragraph_funcs.h"
 #include "ParagraphParameters.h"
@@ -194,18 +195,22 @@ TeXEnvironment(Buffer const & buf,
 }
 
 
-InsetOptArg * optArgInset(Paragraph const & par)
+int latexOptArgInsets(Buffer const & buf, Paragraph const & par,
+                     ostream & os, OutputParams const & runparams, int number)
 {
-       // Find the entry.
+       int lines = 0;
+
        InsetList::const_iterator it = par.insetlist.begin();
        InsetList::const_iterator end = par.insetlist.end();
-       for (; it != end; ++it) {
-               InsetBase * ins = it->inset;
-               if (ins->lyxCode() == InsetBase::OPTARG_CODE) {
-                       return static_cast<InsetOptArg *>(ins);
+       for (; it != end && number > 0 ; ++it) {
+               if (it->inset->lyxCode() == InsetBase::OPTARG_CODE) {
+                       InsetOptArg * ins =
+                               static_cast<InsetOptArg *>(it->inset);
+                       lines += ins->latexOptional(buf, os, runparams);
+                       --number;
                }
        }
-       return 0;
+       return lines;
 }
 
 
@@ -214,7 +219,7 @@ TeXOnePar(Buffer const & buf,
          ParagraphList const & paragraphs,
          ParagraphList::const_iterator pit,
          ostream & os, TexRow & texrow,
-         OutputParams const & runparams,
+         OutputParams const & runparams_in,
          string const & everypar)
 {
        lyxerr[Debug::LATEX] << "TeXOnePar...     " << &*pit << " '"
@@ -225,11 +230,14 @@ TeXOnePar(Buffer const & buf,
 
        // In an an inset with unlimited length (all in one row),
        // force layout to default
-       if (!pit->forceDefaultParagraphs()) 
+       if (!pit->forceDefaultParagraphs())
                style = pit->layout();
        else
                style = bparams.getLyXTextClass().defaultLayout();
 
+       OutputParams runparams = runparams_in;
+       runparams.moving_arg |= style->needprotect;
+
        Language const * language = pit->getParLanguage(bparams);
        Language const * doc_language = bparams.language;
        Language const * previous_language =
@@ -297,17 +305,20 @@ TeXOnePar(Buffer const & buf,
                        os << '\n';
                        texrow.newline();
                }
-       } 
+       }
 
        switch (style->latextype) {
        case LATEX_COMMAND:
                os << '\\' << style->latexname();
 
                // Separate handling of optional argument inset.
-               if (style->optionalargs == 1) {
-                       InsetOptArg * it = optArgInset(*pit);
-                       if (it)
-                               it->latexOptional(buf, os, runparams);
+               if (style->optionalargs > 0) {
+                       int ret = latexOptArgInsets(buf, *pit, os, runparams,
+                                                   style->optionalargs);
+                       while (ret > 0) {
+                               texrow.newline();
+                               --ret;
+                       }
                }
                else
                        os << style->latexparam();