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"
|
2003-11-12 14:38:26 +00:00
|
|
|
|
#include "gettext.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-07 16:15:06 +00:00
|
|
|
|
#include "frontends/FontMetrics.h"
|
2003-12-06 09:31:30 +00:00
|
|
|
|
#include "frontends/Painter.h"
|
2004-07-24 10:55:30 +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
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
namespace lyx {
|
2003-11-12 14:38:26 +00:00
|
|
|
|
|
|
|
|
|
using std::string;
|
|
|
|
|
using std::ostream;
|
|
|
|
|
|
|
|
|
|
|
2007-09-05 15:29:04 +00:00
|
|
|
|
InsetFlex::InsetFlex(BufferParams const & bp,
|
2007-11-03 00:35:07 +00:00
|
|
|
|
InsetLayout const & il)
|
2007-11-03 09:03:08 +00:00
|
|
|
|
: InsetCollapsable(bp, Collapsed, &il)
|
2003-11-12 14:38:26 +00:00
|
|
|
|
{
|
2007-08-25 14:43:59 +00:00
|
|
|
|
params_.name = il.name;
|
2003-11-12 14:38:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-09-05 15:29:04 +00:00
|
|
|
|
InsetFlex::InsetFlex(InsetFlex const & in)
|
2004-10-31 12:30:26 +00:00
|
|
|
|
: InsetCollapsable(in), params_(in.params_)
|
2007-11-03 00:56:48 +00:00
|
|
|
|
{}
|
2003-11-12 14:38:26 +00:00
|
|
|
|
|
|
|
|
|
|
2007-09-05 15:29:04 +00:00
|
|
|
|
Inset * InsetFlex::clone() const
|
2003-11-12 14:38:26 +00:00
|
|
|
|
{
|
2007-09-05 15:29:04 +00:00
|
|
|
|
return new InsetFlex(*this);
|
2003-11-12 14:38:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-09-05 15:29:04 +00:00
|
|
|
|
bool InsetFlex::undefined() const
|
2005-05-04 11:21:14 +00:00
|
|
|
|
{
|
2007-11-03 00:35:07 +00:00
|
|
|
|
return layout_->labelstring == from_utf8("UNDEFINED");
|
2005-05-04 11:21:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-09-05 15:29:04 +00:00
|
|
|
|
docstring const 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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-09-05 15:29:04 +00:00
|
|
|
|
void InsetFlex::write(Buffer const & buf, ostream & os) const
|
2003-11-12 14:38:26 +00:00
|
|
|
|
{
|
|
|
|
|
params_.write(os);
|
|
|
|
|
InsetCollapsable::write(buf, os);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-09-05 15:29:04 +00:00
|
|
|
|
void InsetFlex::read(Buffer const & buf, Lexer & lex)
|
2003-11-12 14:38:26 +00:00
|
|
|
|
{
|
2006-10-16 07:06:41 +00:00
|
|
|
|
params_.read(lex);
|
2003-11-12 14:38:26 +00:00
|
|
|
|
InsetCollapsable::read(buf, lex);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-09-05 15:29:04 +00:00
|
|
|
|
int InsetFlex::plaintext(Buffer const & buf, odocstream & os,
|
2007-05-28 22:27:45 +00:00
|
|
|
|
OutputParams const & runparams) const
|
2007-02-17 15:28:50 +00:00
|
|
|
|
{
|
|
|
|
|
return InsetText::plaintext(buf, os, runparams);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-09-05 15:29:04 +00:00
|
|
|
|
int InsetFlex::docbook(Buffer const & buf, odocstream & os,
|
2007-05-28 22:27:45 +00:00
|
|
|
|
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())
|
2007-11-03 00:35:07 +00:00
|
|
|
|
sgml::openTag(os, layout_->latexname,
|
|
|
|
|
par->getID(buf, runparams) + layout_->latexparam);
|
2004-10-30 22:14:02 +00:00
|
|
|
|
|
2006-04-05 23:56:29 +00:00
|
|
|
|
for (; par != end; ++par) {
|
2004-10-30 22:14:02 +00:00
|
|
|
|
par->simpleDocBookOnePar(buf, os, runparams,
|
2006-03-23 20:11:06 +00:00
|
|
|
|
outerFont(std::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())
|
2007-11-03 00:35:07 +00:00
|
|
|
|
sgml::closeTag(os, layout_->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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-09-05 15:29:04 +00:00
|
|
|
|
void InsetFlex::textString(Buffer const & buf, odocstream & os) const
|
2005-11-25 14:40:34 +00:00
|
|
|
|
{
|
2007-01-19 16:23:13 +00:00
|
|
|
|
os << paragraphs().begin()->asString(buf, true);
|
2005-11-25 14:40:34 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-09-05 15:29:04 +00:00
|
|
|
|
void InsetFlexParams::write(ostream & os) const
|
2003-11-12 14:38:26 +00:00
|
|
|
|
{
|
2007-09-08 13:01:29 +00:00
|
|
|
|
os << "Flex " << name << "\n";
|
2003-11-12 14:38:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-09-05 15:29:04 +00:00
|
|
|
|
void InsetFlexParams::read(Lexer & lex)
|
2003-11-12 14:38:26 +00:00
|
|
|
|
{
|
2006-10-16 07:06:41 +00:00
|
|
|
|
while (lex.isOK()) {
|
2003-11-12 14:38:26 +00:00
|
|
|
|
lex.next();
|
|
|
|
|
string token = lex.getString();
|
|
|
|
|
|
2007-09-08 13:01:29 +00:00
|
|
|
|
if (token == "Flex") {
|
2006-10-16 07:06:41 +00:00
|
|
|
|
lex.next();
|
2007-08-19 10:08:09 +00:00
|
|
|
|
name = lex.getString();
|
2006-10-16 07:06:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-08-18 23:26:07 +00:00
|
|
|
|
// This is handled in Collapsable
|
2006-10-16 07:06:41 +00:00
|
|
|
|
else if (token == "status") {
|
|
|
|
|
lex.pushToken(token);
|
|
|
|
|
break;
|
|
|
|
|
}
|
2003-11-12 14:38:26 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace lyx
|