X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2FInsetNewline.cpp;h=ecfacf47cef19f8e8546454980fea97055021f85;hb=8124e6c02ea1fd6779bb6c47ffe2bca2c8bd2d97;hp=d22bb369ae8c45565b96e0d780e95f56948bade1;hpb=461c973d6213b52cb9ffe72b946f408790b5e7b3;p=lyx.git diff --git a/src/insets/InsetNewline.cpp b/src/insets/InsetNewline.cpp index d22bb369ae..ecfacf47ce 100644 --- a/src/insets/InsetNewline.cpp +++ b/src/insets/InsetNewline.cpp @@ -19,8 +19,9 @@ #include "FuncStatus.h" #include "Lexer.h" #include "MetricsInfo.h" -#include "OutputParams.h" +#include "output_docbook.h" #include "output_xhtml.h" +#include "texstream.h" #include "frontends/Application.h" #include "frontends/FontMetrics.h" @@ -34,13 +35,21 @@ using namespace std; namespace lyx { -InsetNewline::InsetNewline() : Inset(0) +InsetNewline::InsetNewline() : Inset(nullptr) {} +int InsetNewline::rowFlags() const +{ + if (params_.kind == InsetNewlineParams::LINEBREAK) + return AlwaysBreakAfter; + else + return AlwaysBreakAfter | Flush; +} + + void InsetNewlineParams::write(ostream & os) const { - string command; switch (kind) { case InsetNewlineParams::NEWLINE: os << "newline"; @@ -56,7 +65,7 @@ void InsetNewlineParams::read(Lexer & lex) { string token; lex.setContext("InsetNewlineParams::read"); - lex >> token; + lex >> token; if (token == "newline") kind = InsetNewlineParams::NEWLINE; else if (token == "linebreak") @@ -146,7 +155,9 @@ void InsetNewline::latex(otexstream & os, OutputParams const & rp) const { switch (params_.kind) { case InsetNewlineParams::NEWLINE: - if (rp.inTableCell == OutputParams::PLAIN) + if (!rp.newlinecmd.empty()) + os << "\\" << rp.newlinecmd << "\n"; + else if (rp.inTableCell == OutputParams::PLAIN) os << "\\newline\n"; else os << "\\\\\n"; @@ -161,23 +172,23 @@ void InsetNewline::latex(otexstream & os, OutputParams const & rp) const } -int InsetNewline::plaintext(odocstream & os, OutputParams const &) const +int InsetNewline::plaintext(odocstringstream & os, + OutputParams const &, size_t) const { os << '\n'; return PLAINTEXT_NEWLINE; } -int InsetNewline::docbook(odocstream & os, OutputParams const &) const +void InsetNewline::docbook(XMLStream &, OutputParams const &) const { - os << '\n'; - return 0; + // New lines are handled by Paragraph::simpleDocBookOnePar. } -docstring InsetNewline::xhtml(XHTMLStream & xs, OutputParams const &) const +docstring InsetNewline::xhtml(XMLStream & xs, OutputParams const &) const { - xs << html::CR() << html::CompTag("br") << html::CR(); + xs << xml::CR() << xml::CompTag("br") << xml::CR(); return docstring(); } @@ -244,7 +255,7 @@ void InsetNewline::draw(PainterInfo & pi, int x, int y) const yp[0] = int(y - 0.875 * asc * 0.75); yp[1] = int(y - 0.500 * asc * 0.75); yp[2] = int(y - 0.125 * asc * 0.75); - + if (pi.ltr_pos) { xp[0] = int(x + 2 * wid * 0.813); xp[1] = int(x + 2 * wid); @@ -259,9 +270,9 @@ void InsetNewline::draw(PainterInfo & pi, int x, int y) const } -docstring InsetNewline::contextMenuName() const +string InsetNewline::contextMenuName() const { - return from_ascii("context-newline"); + return "context-newline"; }