1999-09-27 18:44:28 +00:00
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma implementation
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "insetinclude.h"
|
|
|
|
#include "buffer.h"
|
|
|
|
#include "bufferlist.h"
|
2001-06-25 00:06:33 +00:00
|
|
|
#include "BufferView.h"
|
1999-10-07 18:44:17 +00:00
|
|
|
#include "debug.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
#include "lyxrc.h"
|
|
|
|
#include "LyXView.h"
|
|
|
|
#include "LaTeXFeatures.h"
|
|
|
|
#include "gettext.h"
|
2001-12-28 13:26:54 +00:00
|
|
|
#include "lyxtextclasslist.h"
|
|
|
|
|
|
|
|
#include "frontends/Dialogs.h"
|
|
|
|
|
|
|
|
#include "support/filetools.h"
|
1999-10-02 16:21:10 +00:00
|
|
|
#include "support/FileInfo.h"
|
2001-07-29 17:39:01 +00:00
|
|
|
#include "support/lstrings.h"
|
2001-12-28 13:26:54 +00:00
|
|
|
|
|
|
|
#include <cstdlib>
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2000-04-04 00:19:15 +00:00
|
|
|
using std::ostream;
|
2000-03-28 02:18:55 +00:00
|
|
|
using std::endl;
|
2000-05-19 16:46:01 +00:00
|
|
|
using std::vector;
|
2000-06-07 08:53:40 +00:00
|
|
|
using std::pair;
|
2000-03-28 02:18:55 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
extern BufferList bufferlist;
|
|
|
|
|
2001-03-20 01:22:46 +00:00
|
|
|
namespace {
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2001-03-23 17:09:34 +00:00
|
|
|
string const unique_id()
|
|
|
|
{
|
2000-09-26 13:54:57 +00:00
|
|
|
static unsigned int seed = 1000;
|
2000-07-02 09:52:44 +00:00
|
|
|
|
2001-07-13 14:03:48 +00:00
|
|
|
ostringstream ost;
|
2000-07-02 09:52:44 +00:00
|
|
|
ost << "file" << ++seed;
|
2000-07-25 16:15:35 +00:00
|
|
|
|
|
|
|
// Needed if we use lyxstring.
|
|
|
|
return ost.str().c_str();
|
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
|
|
|
|
2001-03-23 17:09:34 +00:00
|
|
|
InsetInclude::InsetInclude(Params const & p)
|
|
|
|
: params_(p), include_label(unique_id())
|
|
|
|
{}
|
2001-03-14 10:57:39 +00:00
|
|
|
|
|
|
|
|
|
|
|
InsetInclude::InsetInclude(InsetCommandParams const & p, Buffer const & b)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2001-03-23 17:09:34 +00:00
|
|
|
params_.cparams = p;
|
|
|
|
params_.masterFilename_ = b.fileName();
|
2000-07-02 09:52:44 +00:00
|
|
|
include_label = unique_id();
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
InsetInclude::~InsetInclude()
|
|
|
|
{
|
2001-03-14 10:57:39 +00:00
|
|
|
hideDialog();
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
1999-12-07 00:44:53 +00:00
|
|
|
|
2001-03-23 17:09:34 +00:00
|
|
|
InsetInclude::Params const & InsetInclude::params() const
|
2001-03-14 10:57:39 +00:00
|
|
|
{
|
|
|
|
return params_;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-03-23 17:09:34 +00:00
|
|
|
bool InsetInclude::Params::operator==(Params const & o) const
|
2001-03-14 10:57:39 +00:00
|
|
|
{
|
2001-03-23 17:09:34 +00:00
|
|
|
if (cparams == o.cparams && flag == o.flag &&
|
|
|
|
noload == o.noload && masterFilename_ == o.masterFilename_)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2001-03-14 10:57:39 +00:00
|
|
|
|
|
|
|
|
2001-03-23 17:09:34 +00:00
|
|
|
bool InsetInclude::Params::operator!=(Params const & o) const
|
|
|
|
{
|
|
|
|
return !(*this == o);
|
|
|
|
}
|
|
|
|
|
2001-03-14 10:57:39 +00:00
|
|
|
|
2001-03-23 17:09:34 +00:00
|
|
|
void InsetInclude::set(Params const & p)
|
|
|
|
{
|
|
|
|
params_ = p;
|
|
|
|
|
|
|
|
// Just to be safe...
|
|
|
|
string command;
|
|
|
|
|
2001-03-14 10:57:39 +00:00
|
|
|
switch (params_.flag) {
|
2001-03-23 17:09:34 +00:00
|
|
|
case INCLUDE:
|
|
|
|
command="include";
|
|
|
|
break;
|
|
|
|
case VERB:
|
|
|
|
command="verbatiminput";
|
|
|
|
break;
|
|
|
|
case INPUT:
|
|
|
|
command="input";
|
|
|
|
break;
|
|
|
|
case VERBAST:
|
|
|
|
command="verbatiminput*";
|
|
|
|
break;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
2001-03-23 17:09:34 +00:00
|
|
|
|
2001-03-14 10:57:39 +00:00
|
|
|
params_.cparams.setCmdName(command);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-07-06 15:57:54 +00:00
|
|
|
Inset * InsetInclude::clone(Buffer const & buffer, bool) const
|
2001-03-14 10:57:39 +00:00
|
|
|
{
|
2001-03-23 17:09:34 +00:00
|
|
|
Params p(params_);
|
|
|
|
p.masterFilename_ = buffer.fileName();
|
2001-03-14 10:57:39 +00:00
|
|
|
|
2001-03-23 17:09:34 +00:00
|
|
|
return new InsetInclude(p);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
1999-12-07 00:44:53 +00:00
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
void InsetInclude::edit(BufferView * bv, int, int, unsigned int)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2001-02-12 14:09:09 +00:00
|
|
|
bv->owner()->getDialogs()->showInclude(this);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-07-20 14:18:48 +00:00
|
|
|
void InsetInclude::edit(BufferView * bv, bool)
|
|
|
|
{
|
|
|
|
edit(bv, 0, 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
void InsetInclude::write(Buffer const *, ostream & os) const
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2001-03-14 10:57:39 +00:00
|
|
|
os << "Include " << params_.cparams.getCommand() << "\n";
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
void InsetInclude::read(Buffer const *, LyXLex & lex)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2001-06-28 10:25:20 +00:00
|
|
|
params_.cparams.read(lex);
|
2001-03-14 10:57:39 +00:00
|
|
|
|
|
|
|
if (params_.cparams.getCmdName() == "include")
|
|
|
|
params_.flag = INCLUDE;
|
|
|
|
else if (params_.cparams.getCmdName() == "input")
|
|
|
|
params_.flag = INPUT;
|
|
|
|
/* FIXME: is this logic necessary now ? */
|
|
|
|
else if (contains(params_.cparams.getCmdName(), "verbatim")) {
|
|
|
|
params_.flag = VERB;
|
|
|
|
if (params_.cparams.getCmdName() == "verbatiminput*")
|
|
|
|
params_.flag = VERBAST;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-03-14 10:57:39 +00:00
|
|
|
bool InsetInclude::display() const
|
2000-04-04 00:19:15 +00:00
|
|
|
{
|
2001-03-14 10:57:39 +00:00
|
|
|
return !(params_.flag == INPUT);
|
2000-04-04 00:19:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-07-28 12:24:16 +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
|
|
|
|
|
|
|
switch (params_.flag) {
|
|
|
|
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 += ": ";
|
|
|
|
|
2001-03-14 10:57:39 +00:00
|
|
|
if (params_.cparams.getContents().empty())
|
|
|
|
temp += "???";
|
|
|
|
else
|
|
|
|
temp += params_.cparams.getContents();
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
return temp;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-03-14 10:57:39 +00:00
|
|
|
string const InsetInclude::getRelFileBaseName() const
|
|
|
|
{
|
|
|
|
return OnlyFilename(ChangeExtension(params_.cparams.getContents(), string()));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-09-14 17:53:12 +00:00
|
|
|
string const InsetInclude::getFileName() const
|
2000-07-27 08:55:59 +00:00
|
|
|
{
|
2001-03-14 10:57:39 +00:00
|
|
|
return MakeAbsPath(params_.cparams.getContents(),
|
2000-07-27 08:55:59 +00:00
|
|
|
OnlyPath(getMasterFilename()));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-09-14 17:53:12 +00:00
|
|
|
string const InsetInclude::getMasterFilename() const
|
2000-04-04 00:19:15 +00:00
|
|
|
{
|
2001-03-23 17:09:34 +00:00
|
|
|
return params_.masterFilename_;
|
2000-04-04 00:19:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
bool InsetInclude::loadIfNeeded() const
|
|
|
|
{
|
2001-03-14 10:57:39 +00:00
|
|
|
if (params_.noload || isVerbatim())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (!IsLyXFilename(getFileName()))
|
|
|
|
return false;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2001-03-14 10:57:39 +00:00
|
|
|
if (bufferlist.exists(getFileName()))
|
|
|
|
return true;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
// the readonly flag can/will be wrong, not anymore I think.
|
|
|
|
FileInfo finfo(getFileName());
|
2002-01-07 10:17:44 +00:00
|
|
|
bool const ro = !(!finfo.isOK() || finfo.writable());
|
2000-09-26 13:54:57 +00:00
|
|
|
return bufferlist.readFile(getFileName(), ro) != 0;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
int InsetInclude::latex(Buffer const * buffer, ostream & os,
|
2000-04-19 01:42:55 +00:00
|
|
|
bool /*fragile*/, bool /*fs*/) const
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2001-03-14 10:57:39 +00:00
|
|
|
string incfile(params_.cparams.getContents());
|
2000-09-26 13:54:57 +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;
|
2001-03-14 10:57:39 +00:00
|
|
|
|
2000-03-02 02:19:43 +00:00
|
|
|
if (loadIfNeeded()) {
|
|
|
|
Buffer * tmp = bufferlist.getBuffer(getFileName());
|
|
|
|
|
2001-03-14 10:57:39 +00:00
|
|
|
// FIXME: this should be a GUI warning
|
2000-10-03 09:13:34 +00:00
|
|
|
if (tmp->params.textclass != buffer->params.textclass) {
|
2001-03-13 13:40:08 +00:00
|
|
|
lyxerr << "WARNING: Included file `"
|
2000-03-02 02:19:43 +00:00
|
|
|
<< MakeDisplayPath(getFileName())
|
2001-03-13 13:40:08 +00:00
|
|
|
<< "' has textclass `"
|
2000-03-02 02:19:43 +00:00
|
|
|
<< textclasslist.NameOfClass(tmp->params.textclass)
|
2001-03-13 13:40:08 +00:00
|
|
|
<< "' while parent file has textclass `"
|
2000-10-03 09:13:34 +00:00
|
|
|
<< textclasslist.NameOfClass(buffer->params.textclass)
|
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
|
|
|
}
|
|
|
|
|
|
|
|
// write it to a file (so far the complete file)
|
2000-05-11 16:12:46 +00:00
|
|
|
string writefile = ChangeExtension(getFileName(), ".tex");
|
2001-03-14 10:57:39 +00:00
|
|
|
|
2000-10-03 09:13:34 +00:00
|
|
|
if (!buffer->tmppath.empty()
|
|
|
|
&& !buffer->niceFile) {
|
2000-03-02 02:19:43 +00:00
|
|
|
incfile = subst(incfile, '/','@');
|
|
|
|
#ifdef __EMX__
|
|
|
|
incfile = subst(incfile, ':', '$');
|
|
|
|
#endif
|
2000-10-03 09:13:34 +00:00
|
|
|
writefile = AddName(buffer->tmppath, incfile);
|
2000-03-02 02:19:43 +00:00
|
|
|
} else
|
|
|
|
writefile = getFileName();
|
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;
|
|
|
|
|
2000-10-03 09:13:34 +00:00
|
|
|
tmp->markDepClean(buffer->tmppath);
|
2000-03-02 02:19:43 +00:00
|
|
|
|
|
|
|
tmp->makeLaTeXFile(writefile,
|
2001-03-14 10:57:39 +00:00
|
|
|
OnlyPath(getMasterFilename()),
|
2000-10-03 09:13:34 +00:00
|
|
|
buffer->niceFile, true);
|
2001-03-14 10:57:39 +00:00
|
|
|
}
|
2000-03-02 02:19:43 +00:00
|
|
|
|
2001-03-14 10:57:39 +00:00
|
|
|
if (isVerbatim()) {
|
|
|
|
os << '\\' << params_.cparams.getCmdName() << '{' << incfile << '}';
|
|
|
|
} else if (params_.flag == INPUT) {
|
2000-03-02 02:19:43 +00:00
|
|
|
// \input wants file with extension (default is .tex)
|
|
|
|
if (!IsLyXFilename(getFileName())) {
|
2001-03-14 10:57:39 +00:00
|
|
|
os << '\\' << params_.cparams.getCmdName() << '{' << incfile << '}';
|
2000-03-02 02:19:43 +00:00
|
|
|
} else {
|
2001-03-14 10:57:39 +00:00
|
|
|
os << '\\' << params_.cparams.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
|
2001-03-14 10:57:39 +00:00
|
|
|
os << '\\' << params_.cparams.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
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
int InsetInclude::ascii(Buffer const *, std::ostream & os, int) const
|
2000-12-28 16:22:28 +00:00
|
|
|
{
|
2001-03-14 10:57:39 +00:00
|
|
|
if (isVerbatim())
|
2000-12-28 16:22:28 +00:00
|
|
|
os << GetFileContents(getFileName());
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
int InsetInclude::linuxdoc(Buffer const * buffer, ostream & os) const
|
2000-07-01 12:54:45 +00:00
|
|
|
{
|
2001-03-14 10:57:39 +00:00
|
|
|
string incfile(params_.cparams.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;
|
2001-03-14 10:57:39 +00:00
|
|
|
|
2000-07-01 12:54:45 +00:00
|
|
|
if (loadIfNeeded()) {
|
|
|
|
Buffer * tmp = bufferlist.getBuffer(getFileName());
|
|
|
|
|
|
|
|
// write it to a file (so far the complete file)
|
|
|
|
string writefile = ChangeExtension(getFileName(), ".sgml");
|
2000-10-03 09:13:34 +00:00
|
|
|
if (!buffer->tmppath.empty() && !buffer->niceFile) {
|
2000-07-01 12:54:45 +00:00
|
|
|
incfile = subst(incfile, '/','@');
|
2000-10-03 09:13:34 +00:00
|
|
|
writefile = AddName(buffer->tmppath, incfile);
|
2000-07-01 12:54:45 +00:00
|
|
|
} else
|
|
|
|
writefile = getFileName();
|
|
|
|
|
2000-11-04 10:00:12 +00:00
|
|
|
if (IsLyXFilename(getFileName()))
|
2000-07-01 12:54:45 +00:00
|
|
|
writefile = ChangeExtension(writefile, ".sgml");
|
|
|
|
|
|
|
|
lyxerr[Debug::LATEX] << "incfile:" << incfile << endl;
|
|
|
|
lyxerr[Debug::LATEX] << "writefile:" << writefile << endl;
|
|
|
|
|
2000-10-03 09:13:34 +00:00
|
|
|
tmp->makeLinuxDocFile(writefile, buffer->niceFile, true);
|
2001-03-14 10:57:39 +00:00
|
|
|
}
|
2000-07-01 12:54:45 +00:00
|
|
|
|
2001-03-14 10:57:39 +00:00
|
|
|
if (isVerbatim()) {
|
2000-11-13 15:43:36 +00:00
|
|
|
os << "<inlinegraphic fileref=\"" << '&' << include_label << ';'
|
|
|
|
<< "\" format=\"linespecific\">"
|
|
|
|
<< "</inlinegraphic>";
|
2001-03-14 10:57:39 +00:00
|
|
|
} else
|
2000-07-01 12:54:45 +00:00
|
|
|
os << '&' << include_label << ';';
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-09-04 11:02:09 +00:00
|
|
|
int InsetInclude::docbook(Buffer const * buffer, ostream & os) const
|
2000-07-01 12:54:45 +00:00
|
|
|
{
|
2001-03-14 10:57:39 +00:00
|
|
|
string incfile(params_.cparams.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;
|
2001-03-14 10:57:39 +00:00
|
|
|
|
2000-07-01 12:54:45 +00:00
|
|
|
if (loadIfNeeded()) {
|
|
|
|
Buffer * tmp = bufferlist.getBuffer(getFileName());
|
|
|
|
|
|
|
|
// write it to a file (so far the complete file)
|
|
|
|
string writefile = ChangeExtension(getFileName(), ".sgml");
|
2000-10-03 09:13:34 +00:00
|
|
|
if (!buffer->tmppath.empty() && !buffer->niceFile) {
|
2000-07-01 12:54:45 +00:00
|
|
|
incfile = subst(incfile, '/','@');
|
2000-10-03 09:13:34 +00:00
|
|
|
writefile = AddName(buffer->tmppath, incfile);
|
2000-07-01 12:54:45 +00:00
|
|
|
} else
|
|
|
|
writefile = getFileName();
|
2000-11-04 10:00:12 +00:00
|
|
|
if (IsLyXFilename(getFileName()))
|
2000-07-01 12:54:45 +00:00
|
|
|
writefile = ChangeExtension(writefile, ".sgml");
|
|
|
|
|
|
|
|
lyxerr[Debug::LATEX] << "incfile:" << incfile << endl;
|
|
|
|
lyxerr[Debug::LATEX] << "writefile:" << writefile << endl;
|
|
|
|
|
2000-10-03 09:13:34 +00:00
|
|
|
tmp->makeDocBookFile(writefile, buffer->niceFile, true);
|
2001-03-14 10:57:39 +00:00
|
|
|
}
|
2000-07-01 12:54:45 +00:00
|
|
|
|
2001-03-14 10:57:39 +00:00
|
|
|
if (isVerbatim()) {
|
2000-11-13 15:43:36 +00:00
|
|
|
os << "<inlinegraphic fileref=\"" << '&' << include_label << ';'
|
|
|
|
<< "\" format=\"linespecific\">"
|
|
|
|
<< "</inlinegraphic>";
|
2001-03-14 10:57:39 +00:00
|
|
|
} else
|
2000-07-01 12:54:45 +00:00
|
|
|
os << '&' << include_label << ';';
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
void InsetInclude::validate(LaTeXFeatures & features) const
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2000-07-01 12:54:45 +00:00
|
|
|
|
2001-03-14 10:57:39 +00:00
|
|
|
string incfile(params_.cparams.getContents());
|
|
|
|
string writefile;
|
|
|
|
|
2001-03-23 17:09:34 +00:00
|
|
|
Buffer const * const b = bufferlist.getBuffer(getMasterFilename());
|
2000-11-13 15:43:36 +00:00
|
|
|
|
2001-03-23 17:09:34 +00:00
|
|
|
if (b && !b->tmppath.empty() && b->niceFile) {
|
2000-07-01 12:54:45 +00:00
|
|
|
incfile = subst(incfile, '/','@');
|
2001-03-23 17:09:34 +00:00
|
|
|
writefile = AddName(b->tmppath, incfile);
|
2000-07-01 12:54:45 +00:00
|
|
|
} else
|
2000-11-13 15:43:36 +00:00
|
|
|
writefile = getFileName();
|
2000-07-01 12:54:45 +00:00
|
|
|
|
2000-11-04 10:00:12 +00:00
|
|
|
if (IsLyXFilename(getFileName()))
|
2000-07-01 12:54:45 +00:00
|
|
|
writefile = ChangeExtension(writefile, ".sgml");
|
|
|
|
|
2001-11-19 15:34:11 +00:00
|
|
|
features.includeFile(include_label, writefile);
|
2000-07-01 12:54:45 +00:00
|
|
|
|
2001-03-14 10:57:39 +00:00
|
|
|
if (isVerbatim())
|
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:
|
|
|
|
if (loadIfNeeded()) {
|
|
|
|
// a file got loaded
|
2001-03-23 17:09:34 +00:00
|
|
|
Buffer const * const tmp = bufferlist.getBuffer(getFileName());
|
|
|
|
if (tmp)
|
|
|
|
tmp->validate(features);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-09-14 17:53:12 +00:00
|
|
|
vector<string> const InsetInclude::getLabelList() const
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2000-09-26 13:54:57 +00:00
|
|
|
vector<string> l;
|
2000-05-19 16:46:01 +00:00
|
|
|
|
2000-09-26 13:54:57 +00:00
|
|
|
if (loadIfNeeded()) {
|
|
|
|
Buffer * tmp = bufferlist.getBuffer(getFileName());
|
2001-03-14 10:57:39 +00:00
|
|
|
tmp->setParentName("");
|
2000-09-26 13:54:57 +00:00
|
|
|
l = tmp->getLabelList();
|
|
|
|
tmp->setParentName(getMasterFilename());
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2000-09-26 13:54:57 +00:00
|
|
|
return l;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-09-14 17:53:12 +00:00
|
|
|
vector<pair<string,string> > const InsetInclude::getKeys() const
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2000-06-07 08:53:40 +00:00
|
|
|
vector<pair<string,string> > keys;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
if (loadIfNeeded()) {
|
2000-09-26 13:54:57 +00:00
|
|
|
Buffer * tmp = bufferlist.getBuffer(getFileName());
|
2001-03-14 10:57:39 +00:00
|
|
|
tmp->setParentName("");
|
2000-09-26 13:54:57 +00:00
|
|
|
keys = tmp->getBibkeyList();
|
1999-09-27 18:44:28 +00:00
|
|
|
tmp->setParentName(getMasterFilename());
|
|
|
|
}
|
|
|
|
|
2000-06-07 08:53:40 +00:00
|
|
|
return keys;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|