1999-09-27 18:44:28 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/* This file is part of*
|
|
|
|
* ======================================================
|
|
|
|
*
|
|
|
|
* LyX, The Document Processor
|
2002-03-21 17:09:55 +00:00
|
|
|
*
|
2000-03-09 03:36:48 +00:00
|
|
|
* Copyright 1997 LyX Team (this file was created this year)
|
2001-03-14 10:57:39 +00:00
|
|
|
*
|
1999-11-15 10:58:38 +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
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma interface
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "insetcommand.h"
|
|
|
|
|
2002-05-29 16:21:03 +00:00
|
|
|
#include <boost/signals/signal0.hpp>
|
|
|
|
|
2000-07-27 08:55:59 +00:00
|
|
|
class Buffer;
|
1999-09-27 18:44:28 +00:00
|
|
|
struct LaTeXFeatures;
|
|
|
|
|
|
|
|
// Created by AAS 970521
|
|
|
|
|
|
|
|
/** Used to include files
|
|
|
|
*/
|
2001-04-17 14:17:11 +00:00
|
|
|
class InsetInclude: public InsetButton, boost::noncopyable {
|
1999-09-27 18:44:28 +00:00
|
|
|
public:
|
2002-03-21 17:09:55 +00:00
|
|
|
/// the type of inclusion
|
|
|
|
enum Flags {
|
2001-03-14 10:57:39 +00:00
|
|
|
///
|
2001-03-23 17:09:34 +00:00
|
|
|
INCLUDE = 0,
|
2001-03-14 10:57:39 +00:00
|
|
|
///
|
|
|
|
VERB = 1,
|
|
|
|
///
|
|
|
|
INPUT = 2,
|
|
|
|
///
|
|
|
|
VERBAST = 3
|
|
|
|
};
|
|
|
|
|
2001-03-23 17:09:34 +00:00
|
|
|
struct Params {
|
|
|
|
Params(InsetCommandParams const & cp = InsetCommandParams(),
|
|
|
|
Flags f = INCLUDE,
|
|
|
|
bool nl = false,
|
|
|
|
string const & name = string())
|
|
|
|
: cparams(cp), flag(f), noload(nl),
|
|
|
|
masterFilename_(name) {}
|
2001-03-14 10:57:39 +00:00
|
|
|
InsetCommandParams cparams;
|
2001-03-23 17:09:34 +00:00
|
|
|
Flags flag;
|
2001-03-14 10:57:39 +00:00
|
|
|
bool noload;
|
2001-03-23 17:09:34 +00:00
|
|
|
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 &);
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2000-10-10 11:50:43 +00:00
|
|
|
InsetInclude(InsetCommandParams const &, Buffer const &);
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
|
|
|
~InsetInclude();
|
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
|
|
|
///
|
2001-07-06 15:57:54 +00:00
|
|
|
virtual Inset * clone(Buffer const &, bool same_id = false) const;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
Inset::Code lyxCode() const { return Inset::INCLUDE_CODE; }
|
1999-09-27 18:44:28 +00:00
|
|
|
/// This returns the list of labels on the child buffer
|
2000-09-14 17:53:12 +00:00
|
|
|
std::vector<string> const getLabelList() const;
|
1999-09-27 18:44:28 +00:00
|
|
|
/// This returns the list of bibkeys on the child buffer
|
2000-09-14 17:53:12 +00:00
|
|
|
std::vector< std::pair<string,string> > const getKeys() const;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2002-05-26 17:33:14 +00:00
|
|
|
void edit(BufferView *, int x, int y, mouse_button::state button);
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2001-07-20 14:18:48 +00:00
|
|
|
void edit(BufferView * bv, bool front = true);
|
|
|
|
///
|
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
|
|
|
/// With lyx3 we won't overload these 3 methods
|
|
|
|
void write(Buffer const *, std::ostream &) const;
|
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
void read(Buffer const *, LyXLex &);
|
2001-03-14 10:57:39 +00:00
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
int latex(Buffer const *, std::ostream &,
|
2002-03-21 17:09:55 +00:00
|
|
|
bool fragile, bool free_spc) const;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
int ascii(Buffer const *, std::ostream &, int linelen) const;
|
2000-12-28 16:22:28 +00:00
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
int linuxdoc(Buffer const *, std::ostream &) const;
|
2000-07-01 12:54:45 +00:00
|
|
|
///
|
2001-09-04 11:02:09 +00:00
|
|
|
int docbook(Buffer const *, std::ostream &) 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
|
|
|
|
|
|
|
/** Input inserts anything inside a paragraph.
|
2000-07-15 23:51:46 +00:00
|
|
|
Display can give some visual feedback
|
|
|
|
*/
|
2000-04-04 00:19:15 +00:00
|
|
|
bool display() const;
|
2000-07-27 08:55:59 +00:00
|
|
|
|
2002-03-21 17:09:55 +00:00
|
|
|
/// return the filename stub of the included file
|
2001-03-14 10:57:39 +00:00
|
|
|
string const getRelFileBaseName() const;
|
2002-03-21 17:09:55 +00:00
|
|
|
|
2001-03-14 10:57:39 +00:00
|
|
|
/// return true if the included file is not loaded
|
|
|
|
bool isIncludeOnly() const;
|
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
|
|
|
|
|
|
|
/// hide a dialog if about
|
2002-05-29 16:21:03 +00:00
|
|
|
boost::signal0<void> hideDialog;
|
1999-09-27 18:44:28 +00:00
|
|
|
private:
|
2001-03-14 10:57:39 +00:00
|
|
|
/// get the text displayed on the button
|
2001-07-28 12:24:16 +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;
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-03-14 10:57:39 +00:00
|
|
|
inline bool InsetInclude::isIncludeOnly() const
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2001-03-14 10:57:39 +00:00
|
|
|
return params_.flag == INCLUDE && params_.noload;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|