]> git.lyx.org Git - lyx.git/blobdiff - src/paragraph.C
more guii moving around.
[lyx.git] / src / paragraph.C
index ae7a8a0f04fb862204ad2c9aa1f961f1fcd9ba61..e52de16bcc07183b4c44f1acbe4a073f4fa3223b 100644 (file)
@@ -231,7 +231,11 @@ void Paragraph::writeFile(Buffer const * buf, ostream & os,
        // Noindent?
        if (params().noindent())
                os << "\\noindent ";
-
+       
+       // Do we have a manual left indent?
+       if (!params().leftIndent().zero())
+               os << "\\leftindent " << params().leftIndent().asString() << " ";
+       
        // Alignment?
        if (params().align() != LYX_ALIGN_LAYOUT) {
                int h = 0;
@@ -389,6 +393,9 @@ void Paragraph::validate(LaTeXFeatures & features) const
                }
        }
 
+       if (!params().leftIndent().zero())
+               features.require("ParagraphLeftIndent");
+
        // then the insets
        LyXLayout const & lout = textclasslist[bparams.textclass][layout()];
 
@@ -884,7 +891,9 @@ void Paragraph::breakParagraph(BufferParams const & bparams,
                tmp->setLabelWidthString(params().labelWidthString());
        }
 
-       if (size() > pos || !size() || flag == 2) {
+       bool isempty = (textclasslist[bparams.textclass][layout()].keepempty &&
+                       !size());
+       if (!isempty && (size() > pos || !size() || flag == 2)) {
                tmp->layout(layout());
                tmp->params().align(params().align());
                tmp->setLabelWidthString(params().labelWidthString());
@@ -915,7 +924,7 @@ void Paragraph::breakParagraph(BufferParams const & bparams,
        }
 
        // just an idea of me
-       if (!pos) {
+       if (!isempty && !pos) {
                tmp->params().lineTop(params().lineTop());
                tmp->params().pagebreakTop(params().pagebreakTop());
                tmp->params().spaceTop(params().spaceTop());
@@ -1633,7 +1642,7 @@ bool Paragraph::simpleTeXOnePar(Buffer const * buf,
                // Fully instantiated font
                LyXFont font = getFont(bparams, i);
 
-               LyXFont const last_font = running_font;
+               LyXFont const last_font = running_font;
 
                // Spaces at end of font change are simulated to be
                // outside font change, i.e. we write "\textXX{text} "
@@ -1647,7 +1656,10 @@ bool Paragraph::simpleTeXOnePar(Buffer const * buf,
                }
 
                // We end font definition before blanks
-               if (font != running_font && open_font) {
+               if (open_font &&
+                   (font != running_font ||
+                    font.language() != running_font.language()))
+               {
                        column += running_font.latexWriteEndChanges(os,
                                                                    basefont,
                                                                    (i == main_body-1) ? basefont : font);
@@ -1665,7 +1677,10 @@ bool Paragraph::simpleTeXOnePar(Buffer const * buf,
                }
 
                // Do we need to change font?
-               if (font != running_font && i != main_body - 1) {
+               if ((font != running_font ||
+                    font.language() != running_font.language()) &&
+                       i != main_body - 1)
+               {
                        column += font.latexWriteStartChanges(os, basefont,
                                                              last_font);
                        running_font = font;
@@ -1836,6 +1851,14 @@ Paragraph * Paragraph::TeXEnvironment(Buffer const * buf,
                        texrow.newline();
                }
        }
+       
+       bool leftindent_open = false;
+       if (!params().leftIndent().zero()) {
+               os << "\\begin{LyXParagraphLeftIndent}{" <<
+                       params().leftIndent().asLatexString() << "}\n";
+               texrow.newline();
+               leftindent_open = true;
+       }
 
        if (style.isEnvironment()) {
                if (style.latextype == LATEX_LIST_ENVIRONMENT) {
@@ -1881,13 +1904,19 @@ Paragraph * Paragraph::TeXEnvironment(Buffer const * buf,
                }
        } while (par
                 && par->layout() == layout()
-                && par->params().depth() == params().depth());
+                && par->params().depth() == params().depth()
+                && par->params().leftIndent() == params().leftIndent());
 
        if (style.isEnvironment()) {
                os << "\\end{" << style.latexname() << "}\n";
                texrow.newline();
        }
 
+       if (leftindent_open) {
+               os << "\\end{LyXParagraphLeftIndent}\n";
+               texrow.newline();
+       }
+       
        lyxerr[Debug::LATEX] << "TeXEnvironment...done " << par << endl;
        return par;  // ale970302
 }
@@ -1977,7 +2006,9 @@ Paragraph::getParLanguage(BufferParams const & bparams) const
 bool Paragraph::isRightToLeftPar(BufferParams const & bparams) const
 {
        return lyxrc.rtl_support
-               && getParLanguage(bparams)->RightToLeft();
+               && getParLanguage(bparams)->RightToLeft()
+               && !(inInset() && inInset()->owner() &&
+                    inInset()->owner()->lyxCode() == Inset::ERT_CODE);
 }