]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetSeparator.cpp
Properly communicate forced encodings
[lyx.git] / src / insets / InsetSeparator.cpp
index b981d2cc5dff0b18362c59f08a4bddc301df6eb3..af7fb644cd1b04dd83441e7c8aa11b2f24c9c648 100644 (file)
@@ -20,6 +20,7 @@
 #include "MetricsInfo.h"
 #include "OutputParams.h"
 #include "output_xhtml.h"
+#include "texstream.h"
 
 #include "frontends/Application.h"
 #include "frontends/FontMetrics.h"
@@ -52,6 +53,9 @@ void InsetSeparatorParams::write(ostream & os) const
        case InsetSeparatorParams::PARBREAK:
                os <<  "parbreak";
                break;
+       case InsetSeparatorParams::LATEXPAR:
+               os <<  "latexpar";
+               break;
        }
 }
 
@@ -65,6 +69,8 @@ void InsetSeparatorParams::read(Lexer & lex)
                kind = InsetSeparatorParams::PLAIN;
        else if (token == "parbreak")
                kind = InsetSeparatorParams::PARBREAK;
+       else if (token == "latexpar")
+               kind = InsetSeparatorParams::LATEXPAR;
        else
                lex.printError("Unknown kind: `$$Token'");
 }
@@ -130,7 +136,7 @@ ColorCode InsetSeparator::ColorName() const
 }
 
 
-void InsetSeparator::latex(otexstream & os, OutputParams const &) const
+void InsetSeparator::latex(otexstream & os, OutputParams const & runparams) const
 {
        // Do nothing if a paragraph break was just output
        if (!os.afterParbreak()) {
@@ -139,7 +145,11 @@ void InsetSeparator::latex(otexstream & os, OutputParams const &) const
                                os << breakln << "%\n";
                                break;
                        case InsetSeparatorParams::PARBREAK:
-                               os << breakln << "\n";
+                       case InsetSeparatorParams::LATEXPAR:
+                               if (runparams.inDeletedInset)
+                                       os << breakln << "}\n\n{";
+                               else
+                                       os << breakln << "\n";
                                break;
                        default:
                                os << breakln << "%\n";
@@ -177,7 +187,7 @@ void InsetSeparator::metrics(MetricsInfo & mi, Dimension & dim) const
        dim.asc = fm.maxAscent();
        dim.des = fm.maxDescent();
        dim.wid = fm.width('n');
-       if (params_.kind == InsetSeparatorParams::PLAIN)
+       if (params_.kind != InsetSeparatorParams::LATEXPAR)
                dim.wid *= 8;
 }
 
@@ -194,7 +204,7 @@ void InsetSeparator::draw(PainterInfo & pi, int x, int y) const
        int xp[7];
        int yp[7];
 
-       if (params_.kind == InsetSeparatorParams::PLAIN) {
+       if (params_.kind != InsetSeparatorParams::LATEXPAR) {
                yp[0] = int(y - 0.500 * asc * 0.75);
                yp[1] = yp[0];
 
@@ -202,6 +212,12 @@ void InsetSeparator::draw(PainterInfo & pi, int x, int y) const
                xp[1] = int(x + wid * 8);
 
                pi.pain.lines(xp, yp, 2, ColorName());
+
+               if (params_.kind == InsetSeparatorParams::PARBREAK) {
+                       yp[0] += int(0.25 * asc * 0.75);
+                       yp[1] = yp[0];
+                       pi.pain.lines(xp, yp, 2, ColorName());
+               }
        } else {
                yp[0] = int(y - 0.500 * asc * 0.5);
                yp[1] = int(y - 0.250 * asc * 0.5);
@@ -266,6 +282,9 @@ void InsetSeparator::draw(PainterInfo & pi, int x, int y) const
 
 string InsetSeparator::contextMenuName() const
 {
+       if (params_.kind == InsetSeparatorParams::LATEXPAR)
+               return string();
+
        return "context-separator";
 }