1999-09-27 18:44:28 +00:00
|
|
|
|
// -*- C++ -*-
|
2002-09-09 17:32:53 +00:00
|
|
|
|
/**
|
|
|
|
|
* \file insetinclude.h
|
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
1999-09-27 18:44:28 +00:00
|
|
|
|
*
|
2002-09-25 14:26:13 +00:00
|
|
|
|
* \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-09 17:32:53 +00:00
|
|
|
|
*/
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
1999-10-02 16:21:10 +00:00
|
|
|
|
#ifndef INSET_INCLUDE_H
|
|
|
|
|
#define INSET_INCLUDE_H
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
#include "insetcommand.h"
|
2003-06-12 08:52:36 +00:00
|
|
|
|
#include "renderers.h"
|
2002-08-01 17:28:59 +00:00
|
|
|
|
#include <boost/scoped_ptr.hpp>
|
2002-05-29 16:21:03 +00:00
|
|
|
|
|
2003-06-12 08:52:36 +00:00
|
|
|
|
|
2000-07-27 08:55:59 +00:00
|
|
|
|
class Buffer;
|
2003-09-07 01:45:40 +00:00
|
|
|
|
class Dimension;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
struct LaTeXFeatures;
|
|
|
|
|
|
|
|
|
|
// Created by AAS 970521
|
|
|
|
|
|
2002-09-09 17:32:53 +00:00
|
|
|
|
/// for including tex/lyx files
|
2003-07-25 21:20:24 +00:00
|
|
|
|
class InsetInclude: public InsetOld {
|
1999-09-27 18:44:28 +00:00
|
|
|
|
public:
|
2002-03-21 17:09:55 +00:00
|
|
|
|
/// the type of inclusion
|
|
|
|
|
enum Flags {
|
2002-09-09 17:32:53 +00:00
|
|
|
|
INCLUDE = 0, //<
|
|
|
|
|
VERB = 1, //<
|
|
|
|
|
INPUT = 2, //<
|
|
|
|
|
VERBAST = 3 //<
|
2001-03-14 10:57:39 +00:00
|
|
|
|
};
|
|
|
|
|
|
2001-03-23 17:09:34 +00:00
|
|
|
|
struct Params {
|
2002-09-09 17:32:53 +00:00
|
|
|
|
Params(InsetCommandParams const & cp = InsetCommandParams("input"),
|
|
|
|
|
Flags f = INPUT,
|
2001-03-23 17:09:34 +00:00
|
|
|
|
string const & name = string())
|
2002-09-09 17:32:53 +00:00
|
|
|
|
: cparams(cp), flag(f),
|
2001-03-23 17:09:34 +00:00
|
|
|
|
masterFilename_(name) {}
|
2002-12-01 22:59:25 +00:00
|
|
|
|
|
2001-03-14 10:57:39 +00:00
|
|
|
|
InsetCommandParams cparams;
|
2001-03-23 17:09:34 +00:00
|
|
|
|
Flags flag;
|
|
|
|
|
string masterFilename_;
|
|
|
|
|
|
|
|
|
|
///
|
|
|
|
|
bool operator==(Params const &) const;
|
|
|
|
|
///
|
|
|
|
|
bool operator!=(Params const &) const;
|
2001-03-14 10:57:39 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
///
|
2001-03-23 17:09:34 +00:00
|
|
|
|
InsetInclude(Params const &);
|
2000-10-10 11:50:43 +00:00
|
|
|
|
InsetInclude(InsetCommandParams const &, Buffer const &);
|
2003-06-12 08:52:36 +00:00
|
|
|
|
InsetInclude(InsetInclude const &);
|
2002-09-09 17:32:53 +00:00
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
~InsetInclude();
|
2001-03-14 10:57:39 +00:00
|
|
|
|
|
2003-03-05 14:59:37 +00:00
|
|
|
|
///
|
2003-05-26 09:13:55 +00:00
|
|
|
|
virtual dispatch_result localDispatch(FuncRequest const & cmd);
|
2003-03-05 14:59:37 +00:00
|
|
|
|
|
2002-08-01 17:28:59 +00:00
|
|
|
|
/// Override these InsetButton methods if Previewing
|
2003-06-02 10:03:27 +00:00
|
|
|
|
void metrics(MetricsInfo & mi, Dimension & dim) const;
|
2002-08-01 17:28:59 +00:00
|
|
|
|
///
|
2003-05-30 06:48:24 +00:00
|
|
|
|
void draw(PainterInfo & pi, int x, int y) const;
|
2003-06-12 08:52:36 +00:00
|
|
|
|
///
|
|
|
|
|
virtual BufferView * view() const;
|
2002-08-01 17:28:59 +00:00
|
|
|
|
|
2001-03-14 10:57:39 +00:00
|
|
|
|
/// get the parameters
|
2001-03-23 17:09:34 +00:00
|
|
|
|
Params const & params(void) const;
|
2001-03-14 10:57:39 +00:00
|
|
|
|
/// set the parameters
|
2001-03-23 17:09:34 +00:00
|
|
|
|
void set(Params const & params);
|
2001-03-14 10:57:39 +00:00
|
|
|
|
|
2001-03-23 17:09:34 +00:00
|
|
|
|
///
|
2003-07-25 17:11:25 +00:00
|
|
|
|
virtual std::auto_ptr<InsetBase> clone() const;
|
2003-05-26 09:13:55 +00:00
|
|
|
|
///
|
2003-07-25 21:20:24 +00:00
|
|
|
|
InsetOld::Code lyxCode() const { return InsetOld::INCLUDE_CODE; }
|
1999-09-27 18:44:28 +00:00
|
|
|
|
/// This returns the list of labels on the child buffer
|
2003-06-16 11:49:38 +00:00
|
|
|
|
void getLabelList(std::vector<string> &) const;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
/// This returns the list of bibkeys on the child buffer
|
2003-02-18 14:44:49 +00:00
|
|
|
|
void fillWithBibKeys(std::vector<std::pair<string,string> > & keys) const;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
|
EDITABLE editable() const
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
2000-03-08 13:52:57 +00:00
|
|
|
|
return IS_EDITABLE;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
2001-07-20 14:18:48 +00:00
|
|
|
|
///
|
2003-08-28 07:41:31 +00:00
|
|
|
|
void write(Buffer const &, std::ostream &) const;
|
2001-03-14 10:57:39 +00:00
|
|
|
|
///
|
2003-08-28 07:41:31 +00:00
|
|
|
|
void read(Buffer const &, LyXLex &);
|
|
|
|
|
///
|
|
|
|
|
int latex(Buffer const &, std::ostream &,
|
2003-05-23 08:59:47 +00:00
|
|
|
|
LatexRunParams const &) const;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2003-08-28 07:41:31 +00:00
|
|
|
|
int ascii(Buffer const &, std::ostream &, int linelen) const;
|
2000-12-28 16:22:28 +00:00
|
|
|
|
///
|
2003-08-28 07:41:31 +00:00
|
|
|
|
int linuxdoc(Buffer const &, std::ostream &) const;
|
2000-07-01 12:54:45 +00:00
|
|
|
|
///
|
2003-08-28 07:41:31 +00:00
|
|
|
|
int docbook(Buffer const &, std::ostream &, bool mixcont) const;
|
2000-07-01 12:54:45 +00:00
|
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
|
void validate(LaTeXFeatures &) const;
|
2002-03-21 17:09:55 +00:00
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
/// return true if the file is or got loaded.
|
|
|
|
|
bool loadIfNeeded() const;
|
2002-03-21 17:09:55 +00:00
|
|
|
|
|
2002-08-01 17:28:59 +00:00
|
|
|
|
///
|
2003-07-04 08:23:23 +00:00
|
|
|
|
void addPreview(lyx::graphics::PreviewLoader &) const;
|
2002-08-01 17:28:59 +00:00
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
private:
|
2003-08-28 07:41:31 +00:00
|
|
|
|
friend class InsetIncludeMailer;
|
2003-09-09 18:27:24 +00:00
|
|
|
|
|
2003-08-28 07:41:31 +00:00
|
|
|
|
///
|
|
|
|
|
void write(std::ostream &) const;
|
|
|
|
|
///
|
|
|
|
|
void read(LyXLex &);
|
2001-03-14 10:57:39 +00:00
|
|
|
|
/// get the text displayed on the button
|
2003-08-28 07:41:31 +00:00
|
|
|
|
string const getScreenLabel(Buffer const &) const;
|
2001-03-14 10:57:39 +00:00
|
|
|
|
/// is this a verbatim include ?
|
|
|
|
|
bool isVerbatim() const;
|
2002-03-21 17:09:55 +00:00
|
|
|
|
/// get the filename of the master buffer
|
|
|
|
|
string const getMasterFilename() const;
|
|
|
|
|
/// get the included file name
|
|
|
|
|
string const getFileName() const;
|
2001-03-14 10:57:39 +00:00
|
|
|
|
|
|
|
|
|
/// the parameters
|
2001-03-23 17:09:34 +00:00
|
|
|
|
Params params_;
|
2002-03-21 17:09:55 +00:00
|
|
|
|
/// holds the entity name that defines the file location (SGML)
|
2002-02-20 09:04:56 +00:00
|
|
|
|
string const include_label;
|
2002-08-01 17:28:59 +00:00
|
|
|
|
|
|
|
|
|
/// Use the Pimpl idiom to hide the internals of the previewer.
|
|
|
|
|
class PreviewImpl;
|
|
|
|
|
friend class PreviewImpl;
|
|
|
|
|
/// The pointer never changes although *preview_'s contents may.
|
|
|
|
|
boost::scoped_ptr<PreviewImpl> const preview_;
|
2003-06-02 10:03:27 +00:00
|
|
|
|
|
|
|
|
|
/// cache
|
2003-06-12 08:52:36 +00:00
|
|
|
|
mutable bool set_label_;
|
|
|
|
|
mutable ButtonRenderer button_;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2001-03-14 10:57:39 +00:00
|
|
|
|
inline bool InsetInclude::isVerbatim() const
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
2001-03-14 10:57:39 +00:00
|
|
|
|
return params_.flag == VERB || params_.flag == VERBAST;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-03-05 14:59:37 +00:00
|
|
|
|
#include "mailinset.h"
|
|
|
|
|
|
|
|
|
|
class InsetIncludeMailer : public MailInset {
|
|
|
|
|
public:
|
|
|
|
|
///
|
|
|
|
|
InsetIncludeMailer(InsetInclude & inset);
|
|
|
|
|
///
|
2003-03-10 13:33:39 +00:00
|
|
|
|
virtual InsetBase & inset() const { return inset_; }
|
2003-03-05 14:59:37 +00:00
|
|
|
|
///
|
|
|
|
|
virtual string const & name() const { return name_; }
|
|
|
|
|
///
|
2003-07-23 09:54:21 +00:00
|
|
|
|
virtual string const inset2string(Buffer const &) const;
|
2003-03-05 14:59:37 +00:00
|
|
|
|
///
|
|
|
|
|
static void string2params(string const &, InsetInclude::Params &);
|
|
|
|
|
///
|
2003-03-07 14:08:10 +00:00
|
|
|
|
static string const params2string(InsetInclude::Params const &);
|
2003-03-05 14:59:37 +00:00
|
|
|
|
private:
|
|
|
|
|
///
|
2003-03-07 14:08:10 +00:00
|
|
|
|
static string const name_;
|
2003-03-05 14:59:37 +00:00
|
|
|
|
///
|
|
|
|
|
InsetInclude & inset_;
|
|
|
|
|
};
|
|
|
|
|
|
2002-09-09 17:32:53 +00:00
|
|
|
|
#endif // INSETINCLUDE_H
|