* Licence details can be found in the file COPYING.
*
* \author John Levon
- * \author Jürgen Spitzmüller
+ * \author Jürgen Spitzmüller
*
* Full author contact details are available in file CREDITS.
*/
#include "InsetNewline.h"
+#include "Dimension.h"
#include "FuncRequest.h"
#include "FuncStatus.h"
-#include "Dimension.h"
#include "Lexer.h"
#include "MetricsInfo.h"
#include "OutputParams.h"
+#include "output_xhtml.h"
+#include "frontends/Application.h"
#include "frontends/FontMetrics.h"
#include "frontends/Painter.h"
#include "support/debug.h"
-#include "support/docstring.h"
#include "support/docstream.h"
+#include "support/docstring.h"
using namespace std;
namespace lyx {
-InsetNewline::InsetNewline()
+InsetNewline::InsetNewline() : Inset(0)
{}
+
void InsetNewlineParams::write(ostream & os) const
{
string command;
void InsetNewlineParams::read(Lexer & lex)
{
- lex.next();
- string const command = lex.getString();
-
- if (command == "newline")
+ string token;
+ lex.setContext("InsetNewlineParams::read");
+ lex >> token;
+ if (token == "newline")
kind = InsetNewlineParams::NEWLINE;
- else if (command == "linebreak")
+ else if (token == "linebreak")
kind = InsetNewlineParams::LINEBREAK;
else
- lex.printError("InsetNewline: Unknown kind: `$$Token'");
-
- string token;
- lex >> token;
- if (!lex)
- return;
- if (token != "\\end_inset")
- lex.printError("Missing \\end_inset at this point. "
- "Read: `$$Token'");
+ lex.printError("Unknown kind: `$$Token'");
}
void InsetNewline::read(Lexer & lex)
{
params_.read(lex);
+ lex >> "\\end_inset";
}
case LFUN_INSET_MODIFY: {
InsetNewlineParams params;
- InsetNewlineMailer::string2params(to_utf8(cmd.argument()), params);
+ string2params(to_utf8(cmd.argument()), params);
params_.kind = params.kind;
break;
}
case LFUN_INSET_MODIFY:
if (cmd.getArg(0) == "newline") {
InsetNewlineParams params;
- InsetNewlineMailer::string2params(to_utf8(cmd.argument()), params);
+ string2params(to_utf8(cmd.argument()), params);
status.setOnOff(params_.kind == params.kind);
- } else
- status.enabled(true);
+ }
+ status.setEnabled(true);
return true;
default:
return Inset::getStatus(cur, cmd, status);
case InsetNewlineParams::LINEBREAK:
return Color_pagebreak;
break;
- default:
- return Color_eolmarker;
- break;
}
+ // not really useful, but to avoids gcc complaints
+ return Color_eolmarker;
}
-int InsetNewline::latex(odocstream & os, OutputParams const &) const
+int InsetNewline::latex(odocstream & os, OutputParams const & rp) const
{
switch (params_.kind) {
case InsetNewlineParams::NEWLINE:
- os << "\\\\\n";
+ if (rp.inTableCell == OutputParams::PLAIN)
+ os << "\\newline\n";
+ else
+ os << "\\\\\n";
break;
case InsetNewlineParams::LINEBREAK:
os << "\\linebreak{}\n";
}
+docstring InsetNewline::xhtml(XHTMLStream & xs, OutputParams const &) const
+{
+ xs << CompTag("br");
+ xs.cr();
+ return docstring();
+}
+
+
void InsetNewline::draw(PainterInfo & pi, int x, int y) const
{
FontInfo font;
}
-string const InsetNewlineMailer::name_ = "newline";
-
-
-InsetNewlineMailer::InsetNewlineMailer(InsetNewline & inset)
- : inset_(inset)
-{}
-
-
-string const InsetNewlineMailer::inset2string(Buffer const &) const
-{
- return params2string(inset_.params());
-}
-
-
-void InsetNewlineMailer::string2params(string const & in, InsetNewlineParams & params)
+void InsetNewline::string2params(string const & in, InsetNewlineParams & params)
{
params = InsetNewlineParams();
if (in.empty())
return;
-
istringstream data(in);
- Lexer lex(0,0);
+ Lexer lex;
lex.setStream(data);
-
- string name;
- lex >> name;
- if (!lex || name != name_)
- return print_mailer_error("InsetNewlineMailer", in, 1, name_);
-
+ lex.setContext("InsetNewline::string2params");
+ lex >> "newline";
params.read(lex);
}
-string const InsetNewlineMailer::params2string(InsetNewlineParams const & params)
+string InsetNewline::params2string(InsetNewlineParams const & params)
{
ostringstream data;
- data << name_ << ' ';
+ data << "newline" << ' ';
params.write(data);
return data.str();
}