2002-09-25 14:26:13 +00:00
|
|
|
|
/**
|
|
|
|
|
* \file insetinclude.C
|
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
|
*
|
|
|
|
|
* \author Lars Gullik Bj<EFBFBD>nnes
|
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* Full author contact details are available in file CREDITS.
|
2002-09-25 14:26:13 +00:00
|
|
|
|
*/
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2003-05-13 09:48:57 +00:00
|
|
|
|
#include <config.h>
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
#include "insetinclude.h"
|
2003-09-05 09:01:27 +00:00
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
#include "buffer.h"
|
2003-06-20 12:46:28 +00:00
|
|
|
|
#include "buffer_funcs.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
|
#include "bufferlist.h"
|
2003-09-09 11:24:33 +00:00
|
|
|
|
#include "bufferparams.h"
|
2001-06-25 00:06:33 +00:00
|
|
|
|
#include "BufferView.h"
|
1999-10-07 18:44:17 +00:00
|
|
|
|
#include "debug.h"
|
2003-10-29 10:47:21 +00:00
|
|
|
|
#include "dispatchresult.h"
|
2003-03-05 14:59:37 +00:00
|
|
|
|
#include "funcrequest.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
|
#include "gettext.h"
|
2003-03-05 14:59:37 +00:00
|
|
|
|
#include "LaTeXFeatures.h"
|
2003-10-14 21:30:23 +00:00
|
|
|
|
#include "lyx_main.h"
|
2003-03-05 14:59:37 +00:00
|
|
|
|
#include "lyxlex.h"
|
2003-05-30 06:48:24 +00:00
|
|
|
|
#include "metricsinfo.h"
|
2003-11-05 12:06:20 +00:00
|
|
|
|
#include "outputparams.h"
|
2001-12-28 13:26:54 +00:00
|
|
|
|
|
2003-10-12 18:54:12 +00:00
|
|
|
|
#include "frontends/LyXView.h"
|
2002-08-01 17:28:59 +00:00
|
|
|
|
#include "frontends/Painter.h"
|
2001-12-28 13:26:54 +00:00
|
|
|
|
|
2003-10-10 21:08:55 +00:00
|
|
|
|
#include "graphics/PreviewLoader.h"
|
|
|
|
|
|
|
|
|
|
#include "insets/render_preview.h"
|
2003-09-05 09:01:27 +00:00
|
|
|
|
|
1999-10-02 16:21:10 +00:00
|
|
|
|
#include "support/FileInfo.h"
|
2003-09-05 09:01:27 +00:00
|
|
|
|
#include "support/filetools.h"
|
2003-05-13 14:36:24 +00:00
|
|
|
|
#include "support/lstrings.h" // contains
|
|
|
|
|
#include "support/tostr.h"
|
2001-12-28 13:26:54 +00:00
|
|
|
|
|
2002-08-06 14:02:59 +00:00
|
|
|
|
#include <boost/bind.hpp>
|
|
|
|
|
|
2003-10-10 21:08:55 +00:00
|
|
|
|
#include "support/std_ostream.h"
|
2003-09-05 17:23:11 +00:00
|
|
|
|
#include "support/std_sstream.h"
|
2001-12-28 13:26:54 +00:00
|
|
|
|
|
2003-09-09 22:13:45 +00:00
|
|
|
|
using lyx::support::AddName;
|
|
|
|
|
using lyx::support::ChangeExtension;
|
|
|
|
|
using lyx::support::contains;
|
|
|
|
|
using lyx::support::FileInfo;
|
|
|
|
|
using lyx::support::GetFileContents;
|
|
|
|
|
using lyx::support::IsFileReadable;
|
|
|
|
|
using lyx::support::IsLyXFilename;
|
|
|
|
|
using lyx::support::MakeAbsPath;
|
|
|
|
|
using lyx::support::MakeDisplayPath;
|
2003-09-19 10:16:33 +00:00
|
|
|
|
using lyx::support::OnlyFilename;
|
2003-09-09 22:13:45 +00:00
|
|
|
|
using lyx::support::OnlyPath;
|
|
|
|
|
using lyx::support::subst;
|
2003-06-30 23:56:22 +00:00
|
|
|
|
|
2000-03-28 02:18:55 +00:00
|
|
|
|
using std::endl;
|
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 18:02:24 +00:00
|
|
|
|
using std::istringstream;
|
2003-09-05 09:01:27 +00:00
|
|
|
|
using std::ostream;
|
2003-09-05 18:02:24 +00:00
|
|
|
|
using std::ostringstream;
|
2003-07-25 17:11:25 +00:00
|
|
|
|
|
2000-03-28 02:18:55 +00:00
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
extern BufferList bufferlist;
|
2002-08-02 16:30:58 +00:00
|
|
|
|
|
2002-08-01 17:28:59 +00:00
|
|
|
|
|
2001-03-20 01:22:46 +00:00
|
|
|
|
namespace {
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2002-06-05 15:07:44 +00:00
|
|
|
|
string const uniqueID()
|
2001-03-23 17:09:34 +00:00
|
|
|
|
{
|
2000-09-26 13:54:57 +00:00
|
|
|
|
static unsigned int seed = 1000;
|
2003-05-13 16:24:49 +00:00
|
|
|
|
return "file" + tostr(++seed);
|
2000-07-02 09:52:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-03-20 01:22:46 +00:00
|
|
|
|
} // namespace anon
|
|
|
|
|
|
2000-07-02 09:52:44 +00:00
|
|
|
|
|
2003-09-19 10:16:33 +00:00
|
|
|
|
InsetInclude::InsetInclude(InsetCommandParams const & p)
|
2002-08-01 17:28:59 +00:00
|
|
|
|
: params_(p), include_label(uniqueID()),
|
2003-10-10 21:08:55 +00:00
|
|
|
|
preview_(new RenderMonitoredPreview),
|
2003-06-12 08:52:36 +00:00
|
|
|
|
set_label_(false)
|
2003-10-09 19:27:07 +00:00
|
|
|
|
{
|
|
|
|
|
preview_->connect(boost::bind(&InsetInclude::statusChanged, this));
|
2003-10-10 21:08:55 +00:00
|
|
|
|
preview_->fileChanged(boost::bind(&InsetInclude::fileChanged, this));
|
2003-10-09 19:27:07 +00:00
|
|
|
|
}
|
2001-03-14 10:57:39 +00:00
|
|
|
|
|
|
|
|
|
|
2003-06-12 08:52:36 +00:00
|
|
|
|
InsetInclude::InsetInclude(InsetInclude const & other)
|
2003-07-25 21:20:24 +00:00
|
|
|
|
: InsetOld(other),
|
2003-06-12 08:52:36 +00:00
|
|
|
|
params_(other.params_),
|
|
|
|
|
include_label(other.include_label),
|
2003-10-10 21:08:55 +00:00
|
|
|
|
preview_(new RenderMonitoredPreview),
|
2003-06-12 08:52:36 +00:00
|
|
|
|
set_label_(other.set_label_)
|
2003-10-09 19:27:07 +00:00
|
|
|
|
{
|
|
|
|
|
preview_->connect(boost::bind(&InsetInclude::statusChanged, this));
|
2003-10-10 21:08:55 +00:00
|
|
|
|
preview_->fileChanged(boost::bind(&InsetInclude::fileChanged, this));
|
2003-10-09 19:27:07 +00:00
|
|
|
|
}
|
2003-06-12 08:52:36 +00:00
|
|
|
|
|
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
InsetInclude::~InsetInclude()
|
|
|
|
|
{
|
2003-11-28 17:13:41 +00:00
|
|
|
|
InsetIncludeMailer(*this).hideDialog();
|
2003-03-05 14:59:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-10-29 10:47:21 +00:00
|
|
|
|
DispatchResult
|
2003-10-17 18:01:15 +00:00
|
|
|
|
InsetInclude::priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &)
|
2003-03-05 14:59:37 +00:00
|
|
|
|
{
|
2003-03-07 15:58:02 +00:00
|
|
|
|
switch (cmd.action) {
|
2003-05-16 07:44:00 +00:00
|
|
|
|
|
2003-03-07 15:58:02 +00:00
|
|
|
|
case LFUN_INSET_MODIFY: {
|
2003-09-19 10:16:33 +00:00
|
|
|
|
InsetCommandParams p;
|
2003-03-07 15:58:02 +00:00
|
|
|
|
InsetIncludeMailer::string2params(cmd.argument, p);
|
2003-09-19 10:16:33 +00:00
|
|
|
|
if (!p.getCmdName().empty()) {
|
|
|
|
|
set(p, *cmd.view()->buffer());
|
2003-11-10 13:23:14 +00:00
|
|
|
|
cmd.view()->update();
|
2003-05-16 07:44:00 +00:00
|
|
|
|
}
|
2003-11-03 19:52:47 +00:00
|
|
|
|
return DispatchResult(true, true);
|
2003-03-07 15:58:02 +00:00
|
|
|
|
}
|
2003-03-05 14:59:37 +00:00
|
|
|
|
|
2003-05-26 09:13:55 +00:00
|
|
|
|
case LFUN_INSET_DIALOG_UPDATE:
|
2003-05-16 07:44:00 +00:00
|
|
|
|
InsetIncludeMailer(*this).updateDialog(cmd.view());
|
2003-11-03 19:52:47 +00:00
|
|
|
|
return DispatchResult(true, true);
|
2003-03-07 15:58:02 +00:00
|
|
|
|
|
2003-03-09 09:38:47 +00:00
|
|
|
|
case LFUN_MOUSE_RELEASE:
|
2003-09-04 14:02:05 +00:00
|
|
|
|
if (button_.box().contains(cmd.x, cmd.y))
|
|
|
|
|
InsetIncludeMailer(*this).showDialog(cmd.view());
|
2003-11-03 19:52:47 +00:00
|
|
|
|
return DispatchResult(true, true);
|
2003-09-09 17:25:35 +00:00
|
|
|
|
|
2003-09-04 14:02:05 +00:00
|
|
|
|
case LFUN_INSET_DIALOG_SHOW:
|
2003-05-16 07:44:00 +00:00
|
|
|
|
InsetIncludeMailer(*this).showDialog(cmd.view());
|
2003-11-03 19:52:47 +00:00
|
|
|
|
return DispatchResult(true, true);
|
2003-03-09 09:38:47 +00:00
|
|
|
|
|
2003-03-07 15:58:02 +00:00
|
|
|
|
default:
|
2003-11-01 15:45:19 +00:00
|
|
|
|
return DispatchResult(false);
|
2003-03-07 15:58:02 +00:00
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-12-07 00:44:53 +00:00
|
|
|
|
|
2003-09-19 10:16:33 +00:00
|
|
|
|
InsetCommandParams const & InsetInclude::params() const
|
2001-03-14 10:57:39 +00:00
|
|
|
|
{
|
|
|
|
|
return params_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-09-18 17:22:36 +00:00
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
|
|
/// the type of inclusion
|
|
|
|
|
enum Types {
|
|
|
|
|
INCLUDE = 0,
|
|
|
|
|
VERB = 1,
|
|
|
|
|
INPUT = 2,
|
|
|
|
|
VERBAST = 3
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2003-09-19 10:16:33 +00:00
|
|
|
|
Types type(InsetCommandParams const & params)
|
2001-03-14 10:57:39 +00:00
|
|
|
|
{
|
2003-09-19 10:16:33 +00:00
|
|
|
|
string const command_name = params.getCmdName();
|
2001-03-14 10:57:39 +00:00
|
|
|
|
|
2003-09-18 17:22:36 +00:00
|
|
|
|
if (command_name == "input")
|
|
|
|
|
return INPUT;
|
|
|
|
|
if (command_name == "verbatiminput")
|
|
|
|
|
return VERB;
|
|
|
|
|
if (command_name == "verbatiminput*")
|
|
|
|
|
return VERBAST;
|
|
|
|
|
return INCLUDE;
|
|
|
|
|
}
|
2003-10-06 15:43:21 +00:00
|
|
|
|
|
2001-03-14 10:57:39 +00:00
|
|
|
|
|
2003-09-19 10:16:33 +00:00
|
|
|
|
bool isVerbatim(InsetCommandParams const & params)
|
2001-03-23 17:09:34 +00:00
|
|
|
|
{
|
2003-09-19 10:16:33 +00:00
|
|
|
|
string const command_name = params.getCmdName();
|
2003-10-13 01:53:45 +00:00
|
|
|
|
return command_name == "verbatiminput" ||
|
2003-09-18 17:22:36 +00:00
|
|
|
|
command_name == "verbatiminput*";
|
2001-03-23 17:09:34 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-10-10 21:08:55 +00:00
|
|
|
|
|
|
|
|
|
string const masterFilename(Buffer const & buffer)
|
|
|
|
|
{
|
|
|
|
|
return buffer.fileName();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
string const includedFilename(Buffer const & buffer,
|
|
|
|
|
InsetCommandParams const & params)
|
|
|
|
|
{
|
|
|
|
|
return MakeAbsPath(params.getContents(),
|
|
|
|
|
OnlyPath(masterFilename(buffer)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-10-22 22:26:47 +00:00
|
|
|
|
void add_preview(RenderMonitoredPreview &, InsetInclude const &, Buffer const &);
|
2003-10-10 21:08:55 +00:00
|
|
|
|
|
2003-09-18 17:22:36 +00:00
|
|
|
|
} // namespace anon
|
|
|
|
|
|
2001-03-14 10:57:39 +00:00
|
|
|
|
|
2003-09-19 10:16:33 +00:00
|
|
|
|
void InsetInclude::set(InsetCommandParams const & p, Buffer const & buffer)
|
2001-03-23 17:09:34 +00:00
|
|
|
|
{
|
|
|
|
|
params_ = p;
|
2003-09-19 10:16:33 +00:00
|
|
|
|
set_label_ = false;
|
2001-03-23 17:09:34 +00:00
|
|
|
|
|
2002-08-06 14:02:59 +00:00
|
|
|
|
if (preview_->monitoring())
|
|
|
|
|
preview_->stopMonitoring();
|
|
|
|
|
|
2003-10-10 21:08:55 +00:00
|
|
|
|
if (type(params_) == INPUT)
|
2003-10-22 22:26:47 +00:00
|
|
|
|
add_preview(*preview_, *this, buffer);
|
2001-03-14 10:57:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-07-25 17:11:25 +00:00
|
|
|
|
auto_ptr<InsetBase> InsetInclude::clone() const
|
2001-03-14 10:57:39 +00:00
|
|
|
|
{
|
2003-09-19 10:16:33 +00:00
|
|
|
|
return auto_ptr<InsetBase>(new InsetInclude(*this));
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-12-07 00:44:53 +00:00
|
|
|
|
|
2003-08-28 07:41:31 +00:00
|
|
|
|
void InsetInclude::write(Buffer const &, ostream & os) const
|
|
|
|
|
{
|
|
|
|
|
write(os);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void InsetInclude::write(ostream & os) const
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
2003-09-19 10:16:33 +00:00
|
|
|
|
os << "Include " << params_.getCommand() << '\n'
|
|
|
|
|
<< "preview " << tostr(params_.preview()) << '\n';
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-08-28 07:41:31 +00:00
|
|
|
|
void InsetInclude::read(Buffer const &, LyXLex & lex)
|
|
|
|
|
{
|
|
|
|
|
read(lex);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void InsetInclude::read(LyXLex & lex)
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
2003-09-19 10:16:33 +00:00
|
|
|
|
params_.read(lex);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-08-28 07:41:31 +00:00
|
|
|
|
string const InsetInclude::getScreenLabel(Buffer const &) const
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
1999-10-02 16:21:10 +00:00
|
|
|
|
string temp;
|
2001-03-14 10:57:39 +00:00
|
|
|
|
|
2003-09-18 17:22:36 +00:00
|
|
|
|
switch (type(params_)) {
|
2001-03-14 10:57:39 +00:00
|
|
|
|
case INPUT: temp += _("Input"); break;
|
|
|
|
|
case VERB: temp += _("Verbatim Input"); break;
|
|
|
|
|
case VERBAST: temp += _("Verbatim Input*"); break;
|
|
|
|
|
case INCLUDE: temp += _("Include"); break;
|
|
|
|
|
}
|
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
temp += ": ";
|
2002-03-21 17:09:55 +00:00
|
|
|
|
|
2003-09-19 10:16:33 +00:00
|
|
|
|
if (params_.getContents().empty())
|
2001-03-14 10:57:39 +00:00
|
|
|
|
temp += "???";
|
|
|
|
|
else
|
2003-09-19 10:16:33 +00:00
|
|
|
|
temp += OnlyFilename(params_.getContents());
|
2001-03-14 10:57:39 +00:00
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
return temp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-09-19 10:16:33 +00:00
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
|
|
/// return true if the file is or got loaded.
|
|
|
|
|
bool loadIfNeeded(Buffer const & buffer, InsetCommandParams const & params)
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
2003-09-19 10:16:33 +00:00
|
|
|
|
if (isVerbatim(params))
|
2001-03-14 10:57:39 +00:00
|
|
|
|
return false;
|
|
|
|
|
|
2003-09-19 10:16:33 +00:00
|
|
|
|
string const included_file = includedFilename(buffer, params);
|
|
|
|
|
if (!IsLyXFilename(included_file))
|
2001-03-14 10:57:39 +00:00
|
|
|
|
return false;
|
2002-03-21 17:09:55 +00:00
|
|
|
|
|
2003-09-19 10:16:33 +00:00
|
|
|
|
if (bufferlist.exists(included_file))
|
2001-03-14 10:57:39 +00:00
|
|
|
|
return true;
|
2002-03-21 17:09:55 +00:00
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
// the readonly flag can/will be wrong, not anymore I think.
|
2003-09-19 10:16:33 +00:00
|
|
|
|
FileInfo finfo(included_file);
|
2002-01-13 21:35:50 +00:00
|
|
|
|
if (!finfo.isOK())
|
|
|
|
|
return false;
|
2003-09-19 10:16:33 +00:00
|
|
|
|
return loadLyXFile(bufferlist.newBuffer(included_file),
|
|
|
|
|
included_file);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-09-19 10:16:33 +00:00
|
|
|
|
} // namespace anon
|
|
|
|
|
|
|
|
|
|
|
2003-08-28 07:41:31 +00:00
|
|
|
|
int InsetInclude::latex(Buffer const & buffer, ostream & os,
|
2003-11-05 12:06:20 +00:00
|
|
|
|
OutputParams const & runparams) const
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
2003-09-19 10:16:33 +00:00
|
|
|
|
string incfile(params_.getContents());
|
2002-03-21 17:09:55 +00:00
|
|
|
|
|
2000-03-02 02:19:43 +00:00
|
|
|
|
// Do nothing if no file name has been specified
|
2000-09-26 13:54:57 +00:00
|
|
|
|
if (incfile.empty())
|
2000-03-02 02:19:43 +00:00
|
|
|
|
return 0;
|
2002-03-21 17:09:55 +00:00
|
|
|
|
|
2003-09-19 10:16:33 +00:00
|
|
|
|
string const included_file = includedFilename(buffer, params_);
|
|
|
|
|
|
|
|
|
|
if (loadIfNeeded(buffer, params_)) {
|
|
|
|
|
Buffer * tmp = bufferlist.getBuffer(included_file);
|
2000-03-02 02:19:43 +00:00
|
|
|
|
|
2001-03-14 10:57:39 +00:00
|
|
|
|
// FIXME: this should be a GUI warning
|
2003-09-09 09:47:59 +00:00
|
|
|
|
if (tmp->params().textclass != buffer.params().textclass) {
|
2001-03-13 13:40:08 +00:00
|
|
|
|
lyxerr << "WARNING: Included file `"
|
2003-09-19 10:16:33 +00:00
|
|
|
|
<< MakeDisplayPath(included_file)
|
2001-03-13 13:40:08 +00:00
|
|
|
|
<< "' has textclass `"
|
2003-09-09 09:47:59 +00:00
|
|
|
|
<< tmp->params().getLyXTextClass().name()
|
2001-03-13 13:40:08 +00:00
|
|
|
|
<< "' while parent file has textclass `"
|
2003-09-09 09:47:59 +00:00
|
|
|
|
<< buffer.params().getLyXTextClass().name()
|
2000-03-02 02:19:43 +00:00
|
|
|
|
<< "'." << endl;
|
2001-03-13 13:40:08 +00:00
|
|
|
|
//return 0;
|
2000-03-02 02:19:43 +00:00
|
|
|
|
}
|
2002-03-21 17:09:55 +00:00
|
|
|
|
|
2000-03-02 02:19:43 +00:00
|
|
|
|
// write it to a file (so far the complete file)
|
2003-09-19 10:16:33 +00:00
|
|
|
|
string writefile = ChangeExtension(included_file, ".tex");
|
2001-03-14 10:57:39 +00:00
|
|
|
|
|
2003-09-09 09:47:59 +00:00
|
|
|
|
if (!buffer.temppath().empty() && !runparams.nice) {
|
2000-03-02 02:19:43 +00:00
|
|
|
|
incfile = subst(incfile, '/','@');
|
|
|
|
|
#ifdef __EMX__
|
|
|
|
|
incfile = subst(incfile, ':', '$');
|
|
|
|
|
#endif
|
2003-09-09 09:47:59 +00:00
|
|
|
|
writefile = AddName(buffer.temppath(), incfile);
|
2000-03-02 02:19:43 +00:00
|
|
|
|
} else
|
2003-09-19 10:16:33 +00:00
|
|
|
|
writefile = included_file;
|
2000-05-11 16:12:46 +00:00
|
|
|
|
writefile = ChangeExtension(writefile, ".tex");
|
2000-03-02 02:19:43 +00:00
|
|
|
|
lyxerr[Debug::LATEX] << "incfile:" << incfile << endl;
|
|
|
|
|
lyxerr[Debug::LATEX] << "writefile:" << writefile << endl;
|
2002-03-21 17:09:55 +00:00
|
|
|
|
|
2003-09-09 09:47:59 +00:00
|
|
|
|
tmp->markDepClean(buffer.temppath());
|
2002-03-21 17:09:55 +00:00
|
|
|
|
|
2003-09-19 10:16:33 +00:00
|
|
|
|
tmp->makeLaTeXFile(writefile,
|
|
|
|
|
OnlyPath(masterFilename(buffer)),
|
2003-07-26 21:37:10 +00:00
|
|
|
|
runparams, false);
|
2001-03-14 10:57:39 +00:00
|
|
|
|
}
|
2000-03-02 02:19:43 +00:00
|
|
|
|
|
2003-09-18 17:22:36 +00:00
|
|
|
|
if (isVerbatim(params_)) {
|
2003-09-19 10:16:33 +00:00
|
|
|
|
os << '\\' << params_.getCmdName() << '{' << incfile << '}';
|
2003-09-18 17:22:36 +00:00
|
|
|
|
} else if (type(params_) == INPUT) {
|
2000-03-02 02:19:43 +00:00
|
|
|
|
// \input wants file with extension (default is .tex)
|
2003-09-19 10:16:33 +00:00
|
|
|
|
if (!IsLyXFilename(included_file)) {
|
|
|
|
|
os << '\\' << params_.getCmdName() << '{' << incfile << '}';
|
2000-03-02 02:19:43 +00:00
|
|
|
|
} else {
|
2003-09-19 10:16:33 +00:00
|
|
|
|
os << '\\' << params_.getCmdName() << '{'
|
2000-05-11 16:12:46 +00:00
|
|
|
|
<< ChangeExtension(incfile, ".tex")
|
2000-03-02 02:19:43 +00:00
|
|
|
|
<< '}';
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// \include don't want extension and demands that the
|
|
|
|
|
// file really have .tex
|
2003-09-19 10:16:33 +00:00
|
|
|
|
os << '\\' << params_.getCmdName() << '{'
|
2000-05-11 16:12:46 +00:00
|
|
|
|
<< ChangeExtension(incfile, string())
|
2000-03-02 02:19:43 +00:00
|
|
|
|
<< '}';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-11-05 12:06:20 +00:00
|
|
|
|
int InsetInclude::plaintext(Buffer const & buffer, ostream & os,
|
|
|
|
|
OutputParams const &) const
|
2000-12-28 16:22:28 +00:00
|
|
|
|
{
|
2003-09-18 17:22:36 +00:00
|
|
|
|
if (isVerbatim(params_))
|
2003-09-19 10:16:33 +00:00
|
|
|
|
os << GetFileContents(includedFilename(buffer, params_));
|
2000-12-28 16:22:28 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-10-31 18:45:43 +00:00
|
|
|
|
int InsetInclude::linuxdoc(Buffer const & buffer, ostream & os,
|
2003-11-05 12:06:20 +00:00
|
|
|
|
OutputParams const & runparams) const
|
2000-07-01 12:54:45 +00:00
|
|
|
|
{
|
2003-09-19 10:16:33 +00:00
|
|
|
|
string incfile(params_.getContents());
|
2002-03-21 17:09:55 +00:00
|
|
|
|
|
2000-07-01 12:54:45 +00:00
|
|
|
|
// Do nothing if no file name has been specified
|
2000-09-26 13:54:57 +00:00
|
|
|
|
if (incfile.empty())
|
2000-07-01 12:54:45 +00:00
|
|
|
|
return 0;
|
2002-03-21 17:09:55 +00:00
|
|
|
|
|
2003-09-19 10:16:33 +00:00
|
|
|
|
string const included_file = includedFilename(buffer, params_);
|
|
|
|
|
|
|
|
|
|
if (loadIfNeeded(buffer, params_)) {
|
|
|
|
|
Buffer * tmp = bufferlist.getBuffer(included_file);
|
2000-07-01 12:54:45 +00:00
|
|
|
|
|
|
|
|
|
// write it to a file (so far the complete file)
|
2003-09-19 10:16:33 +00:00
|
|
|
|
string writefile = ChangeExtension(included_file, ".sgml");
|
2003-09-09 09:47:59 +00:00
|
|
|
|
if (!buffer.temppath().empty() && !buffer.niceFile()) {
|
2000-07-01 12:54:45 +00:00
|
|
|
|
incfile = subst(incfile, '/','@');
|
2003-09-09 09:47:59 +00:00
|
|
|
|
writefile = AddName(buffer.temppath(), incfile);
|
2000-07-01 12:54:45 +00:00
|
|
|
|
} else
|
2003-09-19 10:16:33 +00:00
|
|
|
|
writefile = included_file;
|
2000-07-01 12:54:45 +00:00
|
|
|
|
|
2003-09-19 10:16:33 +00:00
|
|
|
|
if (IsLyXFilename(included_file))
|
2000-07-01 12:54:45 +00:00
|
|
|
|
writefile = ChangeExtension(writefile, ".sgml");
|
|
|
|
|
|
|
|
|
|
lyxerr[Debug::LATEX] << "incfile:" << incfile << endl;
|
|
|
|
|
lyxerr[Debug::LATEX] << "writefile:" << writefile << endl;
|
2002-03-21 17:09:55 +00:00
|
|
|
|
|
2003-11-05 12:06:20 +00:00
|
|
|
|
OutputParams runp = runparams;
|
|
|
|
|
runp.nice = buffer.niceFile();
|
2003-10-31 18:45:43 +00:00
|
|
|
|
tmp->makeLinuxDocFile(writefile, runp, true);
|
2001-03-14 10:57:39 +00:00
|
|
|
|
}
|
2000-07-01 12:54:45 +00:00
|
|
|
|
|
2003-09-18 17:22:36 +00:00
|
|
|
|
if (isVerbatim(params_)) {
|
2002-01-16 12:04:16 +00:00
|
|
|
|
os << "<![CDATA["
|
2003-09-19 10:16:33 +00:00
|
|
|
|
<< GetFileContents(included_file)
|
2002-01-16 12:04:16 +00:00
|
|
|
|
<< "]]>";
|
2001-03-14 10:57:39 +00:00
|
|
|
|
} else
|
2000-07-01 12:54:45 +00:00
|
|
|
|
os << '&' << include_label << ';';
|
2002-03-21 17:09:55 +00:00
|
|
|
|
|
2000-07-01 12:54:45 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-08-28 07:41:31 +00:00
|
|
|
|
int InsetInclude::docbook(Buffer const & buffer, ostream & os,
|
2003-11-05 12:06:20 +00:00
|
|
|
|
OutputParams const & runparams) const
|
2000-07-01 12:54:45 +00:00
|
|
|
|
{
|
2003-09-19 10:16:33 +00:00
|
|
|
|
string incfile(params_.getContents());
|
2000-09-26 13:54:57 +00:00
|
|
|
|
|
2000-07-01 12:54:45 +00:00
|
|
|
|
// Do nothing if no file name has been specified
|
2000-09-26 13:54:57 +00:00
|
|
|
|
if (incfile.empty())
|
2000-07-01 12:54:45 +00:00
|
|
|
|
return 0;
|
2002-03-21 17:09:55 +00:00
|
|
|
|
|
2003-09-19 10:16:33 +00:00
|
|
|
|
string const included_file = includedFilename(buffer, params_);
|
|
|
|
|
|
|
|
|
|
if (loadIfNeeded(buffer, params_)) {
|
|
|
|
|
Buffer * tmp = bufferlist.getBuffer(included_file);
|
2000-07-01 12:54:45 +00:00
|
|
|
|
|
|
|
|
|
// write it to a file (so far the complete file)
|
2003-09-19 10:16:33 +00:00
|
|
|
|
string writefile = ChangeExtension(included_file, ".sgml");
|
2003-09-09 09:47:59 +00:00
|
|
|
|
if (!buffer.temppath().empty() && !buffer.niceFile()) {
|
2000-07-01 12:54:45 +00:00
|
|
|
|
incfile = subst(incfile, '/','@');
|
2003-09-09 09:47:59 +00:00
|
|
|
|
writefile = AddName(buffer.temppath(), incfile);
|
2000-07-01 12:54:45 +00:00
|
|
|
|
} else
|
2003-09-19 10:16:33 +00:00
|
|
|
|
writefile = included_file;
|
|
|
|
|
if (IsLyXFilename(included_file))
|
2000-07-01 12:54:45 +00:00
|
|
|
|
writefile = ChangeExtension(writefile, ".sgml");
|
|
|
|
|
|
|
|
|
|
lyxerr[Debug::LATEX] << "incfile:" << incfile << endl;
|
|
|
|
|
lyxerr[Debug::LATEX] << "writefile:" << writefile << endl;
|
2002-03-21 17:09:55 +00:00
|
|
|
|
|
2003-11-05 12:06:20 +00:00
|
|
|
|
OutputParams runp = runparams;
|
2003-10-31 18:45:43 +00:00
|
|
|
|
runp.nice = buffer.niceFile();
|
|
|
|
|
tmp->makeDocBookFile(writefile, runp, true);
|
2001-03-14 10:57:39 +00:00
|
|
|
|
}
|
2000-07-01 12:54:45 +00:00
|
|
|
|
|
2003-09-18 17:22:36 +00:00
|
|
|
|
if (isVerbatim(params_)) {
|
2002-01-16 12:04:16 +00:00
|
|
|
|
os << "<inlinegraphic fileref=\""
|
|
|
|
|
<< '&' << include_label << ';'
|
2002-01-16 12:54:52 +00:00
|
|
|
|
<< "\" format=\"linespecific\">";
|
2001-03-14 10:57:39 +00:00
|
|
|
|
} else
|
2000-07-01 12:54:45 +00:00
|
|
|
|
os << '&' << include_label << ';';
|
2002-03-21 17:09:55 +00:00
|
|
|
|
|
2000-07-01 12:54:45 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
|
void InsetInclude::validate(LaTeXFeatures & features) const
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
2003-09-19 10:16:33 +00:00
|
|
|
|
string incfile(params_.getContents());
|
2001-03-14 10:57:39 +00:00
|
|
|
|
string writefile;
|
|
|
|
|
|
2003-09-19 10:16:33 +00:00
|
|
|
|
Buffer const & buffer = features.buffer();
|
|
|
|
|
|
|
|
|
|
string const included_file = includedFilename(buffer, params_);
|
2000-11-13 15:43:36 +00:00
|
|
|
|
|
2003-09-19 10:16:33 +00:00
|
|
|
|
if (!buffer.temppath().empty() &&
|
|
|
|
|
!buffer.niceFile() &&
|
|
|
|
|
!isVerbatim(params_)) {
|
2002-02-20 09:04:56 +00:00
|
|
|
|
incfile = subst(incfile, '/','@');
|
2003-09-19 10:16:33 +00:00
|
|
|
|
writefile = AddName(buffer.temppath(), incfile);
|
2002-02-20 09:04:56 +00:00
|
|
|
|
} else
|
2003-09-19 10:16:33 +00:00
|
|
|
|
writefile = included_file;
|
2000-07-01 12:54:45 +00:00
|
|
|
|
|
2003-09-19 10:16:33 +00:00
|
|
|
|
if (IsLyXFilename(included_file))
|
2002-02-20 09:04:56 +00:00
|
|
|
|
writefile = ChangeExtension(writefile, ".sgml");
|
2000-07-01 12:54:45 +00:00
|
|
|
|
|
2001-11-19 15:34:11 +00:00
|
|
|
|
features.includeFile(include_label, writefile);
|
2000-07-01 12:54:45 +00:00
|
|
|
|
|
2003-09-18 17:22:36 +00:00
|
|
|
|
if (isVerbatim(params_))
|
2001-11-19 15:34:11 +00:00
|
|
|
|
features.require("verbatim");
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
// Here we must do the fun stuff...
|
|
|
|
|
// Load the file in the include if it needs
|
|
|
|
|
// to be loaded:
|
2003-09-19 10:16:33 +00:00
|
|
|
|
if (loadIfNeeded(buffer, params_)) {
|
1999-09-27 18:44:28 +00:00
|
|
|
|
// a file got loaded
|
2003-09-19 10:16:33 +00:00
|
|
|
|
Buffer * const tmp = bufferlist.getBuffer(included_file);
|
2002-03-05 13:38:40 +00:00
|
|
|
|
if (tmp) {
|
2003-09-19 10:16:33 +00:00
|
|
|
|
tmp->niceFile() = buffer.niceFile();
|
2001-03-23 17:09:34 +00:00
|
|
|
|
tmp->validate(features);
|
2002-03-05 13:38:40 +00:00
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-09-19 10:16:33 +00:00
|
|
|
|
void InsetInclude::getLabelList(Buffer const & buffer,
|
|
|
|
|
std::vector<string> & list) const
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
2003-09-19 10:16:33 +00:00
|
|
|
|
if (loadIfNeeded(buffer, params_)) {
|
|
|
|
|
string const included_file = includedFilename(buffer, params_);
|
|
|
|
|
Buffer * tmp = bufferlist.getBuffer(included_file);
|
2001-03-14 10:57:39 +00:00
|
|
|
|
tmp->setParentName("");
|
2003-06-16 11:49:38 +00:00
|
|
|
|
tmp->getLabelList(list);
|
2003-09-19 10:16:33 +00:00
|
|
|
|
tmp->setParentName(masterFilename(buffer));
|
2000-09-26 13:54:57 +00:00
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-09-19 10:16:33 +00:00
|
|
|
|
void InsetInclude::fillWithBibKeys(Buffer const & buffer,
|
2003-09-18 20:18:39 +00:00
|
|
|
|
std::vector<std::pair<string,string> > & keys) const
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
2003-09-19 10:16:33 +00:00
|
|
|
|
if (loadIfNeeded(buffer, params_)) {
|
|
|
|
|
string const included_file = includedFilename(buffer, params_);
|
|
|
|
|
Buffer * tmp = bufferlist.getBuffer(included_file);
|
2001-03-14 10:57:39 +00:00
|
|
|
|
tmp->setParentName("");
|
2003-02-18 13:25:18 +00:00
|
|
|
|
tmp->fillWithBibKeys(keys);
|
2003-09-19 10:16:33 +00:00
|
|
|
|
tmp->setParentName(masterFilename(buffer));
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2002-08-01 17:28:59 +00:00
|
|
|
|
|
|
|
|
|
|
2003-06-02 10:03:27 +00:00
|
|
|
|
void InsetInclude::metrics(MetricsInfo & mi, Dimension & dim) const
|
2002-08-01 17:28:59 +00:00
|
|
|
|
{
|
2003-10-14 13:54:16 +00:00
|
|
|
|
if (RenderPreview::activated() && preview_->previewReady()) {
|
2003-10-10 21:24:06 +00:00
|
|
|
|
preview_->metrics(mi, dim);
|
2003-06-02 10:03:27 +00:00
|
|
|
|
} else {
|
2003-06-12 08:52:36 +00:00
|
|
|
|
if (!set_label_) {
|
|
|
|
|
set_label_ = true;
|
2003-08-28 07:41:31 +00:00
|
|
|
|
button_.update(getScreenLabel(*mi.base.bv->buffer()),
|
2003-06-12 08:52:36 +00:00
|
|
|
|
editable() != NOT_EDITABLE);
|
|
|
|
|
}
|
|
|
|
|
button_.metrics(mi, dim);
|
2003-06-02 10:03:27 +00:00
|
|
|
|
}
|
2003-09-18 17:22:36 +00:00
|
|
|
|
int center_indent = type(params_) == INPUT ?
|
|
|
|
|
0 : (mi.base.textwidth - dim.wid) / 2;
|
2003-09-04 14:02:05 +00:00
|
|
|
|
Box b(center_indent, center_indent + dim.wid, -dim.asc, dim.des);
|
|
|
|
|
button_.setBox(b);
|
|
|
|
|
|
2003-08-26 10:33:59 +00:00
|
|
|
|
dim.wid = mi.base.textwidth;
|
2003-06-02 10:03:27 +00:00
|
|
|
|
dim_ = dim;
|
2002-08-01 17:28:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-05-30 06:48:24 +00:00
|
|
|
|
void InsetInclude::draw(PainterInfo & pi, int x, int y) const
|
2002-08-01 17:28:59 +00:00
|
|
|
|
{
|
2003-12-12 10:20:17 +00:00
|
|
|
|
xo_ = x;
|
|
|
|
|
yo_ = y;
|
|
|
|
|
|
2003-10-14 13:54:16 +00:00
|
|
|
|
if (!RenderPreview::activated() || !preview_->previewReady()) {
|
2003-09-04 14:02:05 +00:00
|
|
|
|
button_.draw(pi, x + button_.box().x1, y);
|
2002-08-01 17:28:59 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2003-10-10 21:24:06 +00:00
|
|
|
|
preview_->draw(pi, x + button_.box().x1, y);
|
2002-08-01 17:28:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// preview stuff
|
|
|
|
|
//
|
|
|
|
|
|
2003-10-09 19:27:07 +00:00
|
|
|
|
void InsetInclude::statusChanged() const
|
|
|
|
|
{
|
2003-10-14 21:30:23 +00:00
|
|
|
|
LyX::cref().updateInset(this);
|
2003-10-09 19:27:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-10-10 21:08:55 +00:00
|
|
|
|
void InsetInclude::fileChanged() const
|
2002-08-01 17:28:59 +00:00
|
|
|
|
{
|
2003-10-14 21:30:23 +00:00
|
|
|
|
Buffer const * const buffer_ptr = LyX::cref().updateInset(this);
|
|
|
|
|
if (!buffer_ptr)
|
2003-10-10 21:08:55 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2003-10-14 21:30:23 +00:00
|
|
|
|
Buffer const & buffer = *buffer_ptr;
|
2003-10-10 21:08:55 +00:00
|
|
|
|
preview_->removePreview(buffer);
|
2003-10-22 22:26:47 +00:00
|
|
|
|
add_preview(*preview_.get(), *this, buffer);
|
|
|
|
|
preview_->startLoading(buffer);
|
2002-08-01 17:28:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-10-10 21:08:55 +00:00
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
|
|
bool preview_wanted(InsetCommandParams const & params, Buffer const & buffer)
|
2002-08-01 17:28:59 +00:00
|
|
|
|
{
|
2003-10-10 21:08:55 +00:00
|
|
|
|
string const included_file = includedFilename(buffer, params);
|
2003-09-19 10:16:33 +00:00
|
|
|
|
|
2003-10-10 21:08:55 +00:00
|
|
|
|
return type(params) == INPUT && params.preview() &&
|
2003-09-19 10:16:33 +00:00
|
|
|
|
IsFileReadable(included_file);
|
2002-08-01 17:28:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-10-10 21:08:55 +00:00
|
|
|
|
string const latex_string(InsetInclude const & inset, Buffer const & buffer)
|
2002-08-01 17:28:59 +00:00
|
|
|
|
{
|
|
|
|
|
ostringstream os;
|
2003-11-05 12:06:20 +00:00
|
|
|
|
OutputParams runparams;
|
|
|
|
|
runparams.flavor = OutputParams::LATEX;
|
2003-10-10 21:08:55 +00:00
|
|
|
|
inset.latex(buffer, os, runparams);
|
2002-08-01 17:28:59 +00:00
|
|
|
|
|
2003-09-15 11:00:00 +00:00
|
|
|
|
return os.str();
|
2002-08-01 17:28:59 +00:00
|
|
|
|
}
|
2002-08-06 14:02:59 +00:00
|
|
|
|
|
|
|
|
|
|
2003-10-22 22:26:47 +00:00
|
|
|
|
void add_preview(RenderMonitoredPreview & renderer, InsetInclude const & inset,
|
|
|
|
|
Buffer const & buffer)
|
2002-08-06 14:02:59 +00:00
|
|
|
|
{
|
2003-10-10 21:08:55 +00:00
|
|
|
|
InsetCommandParams const & params = inset.params();
|
|
|
|
|
if (RenderPreview::activated() && preview_wanted(params, buffer)) {
|
2003-10-22 22:26:47 +00:00
|
|
|
|
renderer.setAbsFile(includedFilename(buffer, params));
|
2003-10-10 21:08:55 +00:00
|
|
|
|
string const snippet = latex_string(inset, buffer);
|
2003-10-22 22:26:47 +00:00
|
|
|
|
renderer.addPreview(snippet, buffer);
|
2003-10-10 21:08:55 +00:00
|
|
|
|
}
|
2002-08-06 14:02:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-10-10 21:08:55 +00:00
|
|
|
|
} // namespace anon
|
|
|
|
|
|
2002-08-06 14:02:59 +00:00
|
|
|
|
|
2003-10-10 21:08:55 +00:00
|
|
|
|
void InsetInclude::addPreview(lyx::graphics::PreviewLoader & ploader) const
|
2002-08-06 14:02:59 +00:00
|
|
|
|
{
|
2003-10-22 22:26:47 +00:00
|
|
|
|
Buffer const & buffer = ploader.buffer();
|
|
|
|
|
if (preview_wanted(params(), buffer)) {
|
|
|
|
|
preview_->setAbsFile(includedFilename(buffer, params()));
|
|
|
|
|
string const snippet = latex_string(*this, buffer);
|
2003-10-10 21:08:55 +00:00
|
|
|
|
preview_->addPreview(snippet, ploader);
|
2003-10-09 14:36:16 +00:00
|
|
|
|
}
|
2002-08-06 14:02:59 +00:00
|
|
|
|
}
|
2003-03-05 14:59:37 +00:00
|
|
|
|
|
|
|
|
|
|
2003-03-07 14:08:10 +00:00
|
|
|
|
string const InsetIncludeMailer::name_("include");
|
|
|
|
|
|
2003-03-05 14:59:37 +00:00
|
|
|
|
InsetIncludeMailer::InsetIncludeMailer(InsetInclude & inset)
|
2003-03-07 14:08:10 +00:00
|
|
|
|
: inset_(inset)
|
2003-03-05 14:59:37 +00:00
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
2003-07-23 09:54:21 +00:00
|
|
|
|
string const InsetIncludeMailer::inset2string(Buffer const &) const
|
2003-03-05 14:59:37 +00:00
|
|
|
|
{
|
2003-03-07 14:08:10 +00:00
|
|
|
|
return params2string(inset_.params());
|
2003-03-05 14:59:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void InsetIncludeMailer::string2params(string const & in,
|
2003-09-19 10:16:33 +00:00
|
|
|
|
InsetCommandParams & params)
|
2003-03-05 14:59:37 +00:00
|
|
|
|
{
|
2003-09-19 10:16:33 +00:00
|
|
|
|
params = InsetCommandParams();
|
2003-04-24 20:02:49 +00:00
|
|
|
|
if (in.empty())
|
|
|
|
|
return;
|
2003-05-26 09:13:55 +00:00
|
|
|
|
|
2003-09-15 11:00:00 +00:00
|
|
|
|
istringstream data(in);
|
2003-03-07 14:08:10 +00:00
|
|
|
|
LyXLex lex(0,0);
|
|
|
|
|
lex.setStream(data);
|
2003-03-05 14:59:37 +00:00
|
|
|
|
|
2003-12-11 15:23:15 +00:00
|
|
|
|
string name;
|
|
|
|
|
lex >> name;
|
|
|
|
|
if (!lex || name != name_)
|
|
|
|
|
return print_mailer_error("InsetIncludeMailer", in, 1, name_);
|
2003-03-05 14:59:37 +00:00
|
|
|
|
|
|
|
|
|
// This is part of the inset proper that is usually swallowed
|
2003-12-11 15:23:15 +00:00
|
|
|
|
// by LyXText::readInset
|
|
|
|
|
string id;
|
|
|
|
|
lex >> id;
|
|
|
|
|
if (!lex || id != "Include")
|
|
|
|
|
return print_mailer_error("InsetBoxMailer", in, 2, "Include");
|
2003-03-05 14:59:37 +00:00
|
|
|
|
|
2003-12-11 15:23:15 +00:00
|
|
|
|
InsetInclude inset(params);
|
|
|
|
|
inset.read(lex);
|
|
|
|
|
params = inset.params();
|
2003-03-05 14:59:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
string const
|
2003-09-19 10:16:33 +00:00
|
|
|
|
InsetIncludeMailer::params2string(InsetCommandParams const & params)
|
2003-03-05 14:59:37 +00:00
|
|
|
|
{
|
|
|
|
|
InsetInclude inset(params);
|
|
|
|
|
ostringstream data;
|
2003-03-07 14:08:10 +00:00
|
|
|
|
data << name_ << ' ';
|
2003-08-28 07:41:31 +00:00
|
|
|
|
inset.write(data);
|
2003-03-05 14:59:37 +00:00
|
|
|
|
data << "\\end_inset\n";
|
2003-09-15 11:00:00 +00:00
|
|
|
|
return data.str();
|
2003-03-05 14:59:37 +00:00
|
|
|
|
}
|