2003-11-12 14:38:26 +00:00
|
|
|
|
/**
|
2007-09-05 15:29:04 +00:00
|
|
|
|
* \file InsetFlex.cpp
|
2003-11-12 14:38:26 +00:00
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
|
*
|
|
|
|
|
* \author Angus Leeming
|
|
|
|
|
* \author Martin Vermeer
|
|
|
|
|
* \author J<EFBFBD>rgen Spitzm<EFBFBD>ller
|
|
|
|
|
*
|
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
2007-09-05 15:29:04 +00:00
|
|
|
|
#include "InsetFlex.h"
|
2003-11-12 14:38:26 +00:00
|
|
|
|
|
2007-04-26 04:41:58 +00:00
|
|
|
|
#include "Buffer.h"
|
|
|
|
|
#include "BufferParams.h"
|
2006-09-26 21:11:22 +00:00
|
|
|
|
#include "BufferView.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
|
#include "DispatchResult.h"
|
|
|
|
|
#include "FuncRequest.h"
|
2004-11-04 19:50:04 +00:00
|
|
|
|
#include "FuncStatus.h"
|
2007-04-26 14:56:30 +00:00
|
|
|
|
#include "Cursor.h"
|
2007-11-29 07:04:28 +00:00
|
|
|
|
#include "support/gettext.h"
|
2008-01-07 16:59:10 +00:00
|
|
|
|
#include "LaTeXFeatures.h"
|
2007-04-26 11:30:54 +00:00
|
|
|
|
#include "Lexer.h"
|
2007-04-29 23:33:02 +00:00
|
|
|
|
#include "Text.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
|
#include "MetricsInfo.h"
|
|
|
|
|
#include "Paragraph.h"
|
2004-10-30 22:14:02 +00:00
|
|
|
|
#include "paragraph_funcs.h"
|
2004-10-28 15:10:10 +00:00
|
|
|
|
#include "sgml.h"
|
2003-11-12 14:38:26 +00:00
|
|
|
|
|
2006-10-16 07:06:41 +00:00
|
|
|
|
#include "support/convert.h"
|
|
|
|
|
|
2004-07-24 10:55:30 +00:00
|
|
|
|
#include <sstream>
|
2003-11-12 14:38:26 +00:00
|
|
|
|
|
2007-12-12 10:16:00 +00:00
|
|
|
|
using namespace std;
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
namespace lyx {
|
2003-11-12 14:38:26 +00:00
|
|
|
|
|
|
|
|
|
|
2008-04-05 20:24:05 +00:00
|
|
|
|
InsetFlex::InsetFlex(Buffer const & buf, string const & layoutName)
|
|
|
|
|
: InsetCollapsable(buf, Collapsed), name_(layoutName)
|
2003-11-12 14:38:26 +00:00
|
|
|
|
{
|
2008-04-05 20:24:05 +00:00
|
|
|
|
// again, because now the name is initialized
|
|
|
|
|
setLayout(buf.params().documentClassPtr());
|
2008-02-22 02:32:52 +00:00
|
|
|
|
packages_ = getLayout().requires();
|
|
|
|
|
preamble_ = getLayout().preamble();
|
2003-11-12 14:38:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-09-05 15:29:04 +00:00
|
|
|
|
InsetFlex::InsetFlex(InsetFlex const & in)
|
2007-11-05 10:14:19 +00:00
|
|
|
|
: InsetCollapsable(in), name_(in.name_)
|
2007-11-03 00:56:48 +00:00
|
|
|
|
{}
|
2003-11-12 14:38:26 +00:00
|
|
|
|
|
|
|
|
|
|
2008-02-27 20:43:16 +00:00
|
|
|
|
docstring InsetFlex::editMessage() const
|
2003-11-12 14:38:26 +00:00
|
|
|
|
{
|
2007-09-08 13:01:29 +00:00
|
|
|
|
return _("Opened Flex Inset");
|
2003-11-12 14:38:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-02-27 20:43:16 +00:00
|
|
|
|
void InsetFlex::write(ostream & os) const
|
2003-11-12 14:38:26 +00:00
|
|
|
|
{
|
2008-02-14 03:42:54 +00:00
|
|
|
|
os << "Flex " <<
|
2008-02-14 03:49:12 +00:00
|
|
|
|
(name_.empty() ? "undefined" : name_) << "\n";
|
2008-02-27 20:43:16 +00:00
|
|
|
|
InsetCollapsable::write(os);
|
2003-11-12 14:38:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-02-27 20:43:16 +00:00
|
|
|
|
void InsetFlex::read(Lexer & lex)
|
2003-11-12 14:38:26 +00:00
|
|
|
|
{
|
2008-04-05 10:34:29 +00:00
|
|
|
|
string token;
|
2007-11-05 10:14:19 +00:00
|
|
|
|
while (lex.isOK()) {
|
2008-04-05 10:34:29 +00:00
|
|
|
|
lex >> token;
|
2007-11-05 10:14:19 +00:00
|
|
|
|
if (token == "Flex") {
|
|
|
|
|
lex.next();
|
|
|
|
|
name_ = lex.getString();
|
2008-04-05 10:34:29 +00:00
|
|
|
|
} else if (token == "status") {
|
|
|
|
|
// This is handled in Collapsable
|
2007-11-05 10:14:19 +00:00
|
|
|
|
lex.pushToken(token);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2008-02-27 20:43:16 +00:00
|
|
|
|
InsetCollapsable::read(lex);
|
2003-11-12 14:38:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-02-27 20:43:16 +00:00
|
|
|
|
int InsetFlex::plaintext(odocstream & os, OutputParams const & runparams) const
|
2007-02-17 15:28:50 +00:00
|
|
|
|
{
|
2008-02-27 20:43:16 +00:00
|
|
|
|
return InsetText::plaintext(os, runparams);
|
2007-02-17 15:28:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-02-27 20:43:16 +00:00
|
|
|
|
int InsetFlex::docbook(odocstream & os, OutputParams const & runparams) const
|
2003-11-12 14:38:26 +00:00
|
|
|
|
{
|
2006-03-23 20:11:06 +00:00
|
|
|
|
ParagraphList::const_iterator beg = paragraphs().begin();
|
2004-10-30 22:14:02 +00:00
|
|
|
|
ParagraphList::const_iterator par = paragraphs().begin();
|
2006-04-05 23:56:29 +00:00
|
|
|
|
ParagraphList::const_iterator end = paragraphs().end();
|
2004-10-30 22:14:02 +00:00
|
|
|
|
|
2005-05-04 11:21:14 +00:00
|
|
|
|
if (!undefined())
|
2008-02-22 02:32:52 +00:00
|
|
|
|
sgml::openTag(os, getLayout().latexname(),
|
2008-02-27 20:43:16 +00:00
|
|
|
|
par->getID(buffer(), runparams) + getLayout().latexparam());
|
2004-10-30 22:14:02 +00:00
|
|
|
|
|
2006-04-05 23:56:29 +00:00
|
|
|
|
for (; par != end; ++par) {
|
2008-02-27 20:43:16 +00:00
|
|
|
|
par->simpleDocBookOnePar(buffer(), os, runparams,
|
2007-12-12 19:28:07 +00:00
|
|
|
|
outerFont(distance(beg, par),
|
2004-10-30 22:14:02 +00:00
|
|
|
|
paragraphs()));
|
2006-04-05 23:56:29 +00:00
|
|
|
|
}
|
2004-10-30 22:14:02 +00:00
|
|
|
|
|
2005-05-04 11:21:14 +00:00
|
|
|
|
if (!undefined())
|
2008-02-22 02:32:52 +00:00
|
|
|
|
sgml::closeTag(os, getLayout().latexname());
|
2005-05-04 11:21:14 +00:00
|
|
|
|
|
2004-10-30 22:14:02 +00:00
|
|
|
|
return 0;
|
2003-11-12 14:38:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-02-27 20:43:16 +00:00
|
|
|
|
void InsetFlex::textString(odocstream & os) const
|
2005-11-25 14:40:34 +00:00
|
|
|
|
{
|
2008-02-27 20:43:16 +00:00
|
|
|
|
os << paragraphs().begin()->asString(true);
|
2005-11-25 14:40:34 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-01-07 16:59:10 +00:00
|
|
|
|
|
|
|
|
|
void InsetFlex::validate(LaTeXFeatures & features) const
|
|
|
|
|
{
|
|
|
|
|
if (!preamble_.empty())
|
|
|
|
|
features.addPreambleSnippet(preamble_);
|
2008-02-01 15:12:04 +00:00
|
|
|
|
features.require(packages_);
|
2008-01-07 16:59:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
} // namespace lyx
|