2003-03-13 10:06:11 +00:00
|
|
|
|
/**
|
2007-04-28 20:44:46 +00:00
|
|
|
|
* \file InsetEnvironment.cpp
|
2003-03-13 10:06:11 +00:00
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
|
*
|
|
|
|
|
* \author Andr<EFBFBD> P<EFBFBD>nitz
|
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* Full author contact details are available in file CREDITS.
|
2003-03-13 10:06:11 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
2007-04-28 20:44:46 +00:00
|
|
|
|
#include "InsetEnvironment.h"
|
2003-09-05 09:01:27 +00:00
|
|
|
|
|
2007-04-26 04:41:58 +00:00
|
|
|
|
#include "BufferParams.h"
|
2003-03-13 10:06:11 +00:00
|
|
|
|
#include "gettext.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
|
#include "Paragraph.h"
|
|
|
|
|
#include "OutputParams.h"
|
2003-11-05 12:06:20 +00:00
|
|
|
|
#include "output_latex.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
|
#include "TexRow.h"
|
2003-03-13 10:06:11 +00:00
|
|
|
|
|
2003-10-06 15:43:21 +00:00
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
namespace lyx {
|
2006-09-09 18:52:00 +00:00
|
|
|
|
|
2003-10-06 15:43:21 +00:00
|
|
|
|
using std::string;
|
2003-07-25 17:11:25 +00:00
|
|
|
|
using std::auto_ptr;
|
2003-09-05 09:01:27 +00:00
|
|
|
|
using std::ostream;
|
2003-03-13 10:06:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
InsetEnvironment::InsetEnvironment
|
|
|
|
|
(BufferParams const & bp, string const & name)
|
2003-05-19 07:12:09 +00:00
|
|
|
|
: InsetText(bp), layout_(bp.getLyXTextClass()[name])
|
2003-03-13 10:06:11 +00:00
|
|
|
|
{
|
2006-10-22 10:15:23 +00:00
|
|
|
|
setInsetName(from_utf8(name));
|
2003-09-16 10:01:29 +00:00
|
|
|
|
setAutoBreakRows(true);
|
2004-08-14 15:55:22 +00:00
|
|
|
|
setDrawFrame(true);
|
2003-03-13 10:06:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-05-26 09:13:55 +00:00
|
|
|
|
InsetEnvironment::InsetEnvironment(InsetEnvironment const & in)
|
|
|
|
|
: InsetText(in), layout_(in.layout_)
|
2003-03-13 10:06:11 +00:00
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
2004-11-23 23:04:52 +00:00
|
|
|
|
auto_ptr<InsetBase> InsetEnvironment::doClone() const
|
2003-03-13 10:06:11 +00:00
|
|
|
|
{
|
2003-07-25 17:11:25 +00:00
|
|
|
|
return auto_ptr<InsetBase>(new InsetEnvironment(*this));
|
2003-03-13 10:06:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-08-28 07:41:31 +00:00
|
|
|
|
void InsetEnvironment::write(Buffer const & buf, ostream & os) const
|
2003-03-13 10:06:11 +00:00
|
|
|
|
{
|
2006-10-22 10:15:23 +00:00
|
|
|
|
os << "Environment " << to_utf8(getInsetName()) << "\n";
|
2003-04-25 15:28:41 +00:00
|
|
|
|
InsetText::write(buf, os);
|
2003-03-13 10:06:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-04-26 11:30:54 +00:00
|
|
|
|
void InsetEnvironment::read(Buffer const & buf, Lexer & lex)
|
2003-03-13 10:06:11 +00:00
|
|
|
|
{
|
2003-04-25 15:28:41 +00:00
|
|
|
|
InsetText::read(buf, lex);
|
2003-03-13 10:06:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-09-09 18:52:00 +00:00
|
|
|
|
docstring const InsetEnvironment::editMessage() const
|
2003-03-13 10:06:11 +00:00
|
|
|
|
{
|
2006-10-22 10:15:23 +00:00
|
|
|
|
return _("Opened Environment Inset: ") + getInsetName();
|
2003-03-13 10:06:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-10-19 16:51:30 +00:00
|
|
|
|
int InsetEnvironment::latex(Buffer const & buf, odocstream & os,
|
2007-02-16 10:05:30 +00:00
|
|
|
|
OutputParams const & runparams) const
|
2003-03-13 10:06:11 +00:00
|
|
|
|
{
|
2006-10-19 16:51:30 +00:00
|
|
|
|
// FIXME UNICODE
|
2006-10-21 00:16:43 +00:00
|
|
|
|
os << from_utf8(layout_->latexheader);
|
2003-05-19 07:12:09 +00:00
|
|
|
|
TexRow texrow;
|
2003-12-01 13:35:49 +00:00
|
|
|
|
latexParagraphs(buf, paragraphs(), os, texrow, runparams,
|
2003-05-22 22:44:30 +00:00
|
|
|
|
layout_->latexparagraph);
|
2006-10-19 16:51:30 +00:00
|
|
|
|
// FIXME UNICODE
|
2006-10-21 00:16:43 +00:00
|
|
|
|
os << from_utf8(layout_->latexfooter);
|
2003-05-19 07:12:09 +00:00
|
|
|
|
return texrow.rows();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-02-16 10:05:30 +00:00
|
|
|
|
int InsetEnvironment::plaintext(Buffer const & buf, odocstream & os,
|
|
|
|
|
OutputParams const & runparams) const
|
|
|
|
|
{
|
|
|
|
|
os << '[' << to_utf8(getInsetName()) << ":\n";
|
|
|
|
|
InsetText::plaintext(buf, os, runparams);
|
|
|
|
|
os << "\n]";
|
|
|
|
|
|
2007-02-20 17:52:41 +00:00
|
|
|
|
return PLAINTEXT_NEWLINE + 1; // one char on a separate line
|
2007-02-16 10:05:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-05-19 07:12:09 +00:00
|
|
|
|
LyXLayout_ptr const & InsetEnvironment::layout() const
|
|
|
|
|
{
|
|
|
|
|
return layout_;
|
2003-03-13 10:06:11 +00:00
|
|
|
|
}
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace lyx
|