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
|
|
|
|
|
2003-09-19 10:16:33 +00:00
|
|
|
|
#include "inset.h"
|
|
|
|
|
#include "insetcommandparams.h"
|
2003-10-10 21:08:55 +00:00
|
|
|
|
#include "render_button.h"
|
2006-10-21 00:16:43 +00:00
|
|
|
|
#include "mailinset.h"
|
|
|
|
|
|
2006-12-01 20:09:08 +00:00
|
|
|
|
#include "support/filename.h"
|
|
|
|
|
|
2002-08-01 17:28:59 +00:00
|
|
|
|
#include <boost/scoped_ptr.hpp>
|
2003-06-12 08:52:36 +00:00
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
namespace lyx {
|
|
|
|
|
|
2000-07-27 08:55:59 +00:00
|
|
|
|
class Buffer;
|
2003-09-07 01:45:40 +00:00
|
|
|
|
class Dimension;
|
2005-01-19 15:03:31 +00:00
|
|
|
|
class LaTeXFeatures;
|
2003-10-10 21:08:55 +00:00
|
|
|
|
class RenderMonitoredPreview;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
|
2002-09-09 17:32:53 +00:00
|
|
|
|
/// for including tex/lyx files
|
2006-10-21 00:16:43 +00:00
|
|
|
|
class InsetInclude : public InsetOld {
|
1999-09-27 18:44:28 +00:00
|
|
|
|
public:
|
2001-03-14 10:57:39 +00:00
|
|
|
|
///
|
2003-09-19 10:16:33 +00:00
|
|
|
|
InsetInclude(InsetCommandParams const &);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
~InsetInclude();
|
2001-03-14 10:57:39 +00:00
|
|
|
|
|
2002-08-01 17:28:59 +00:00
|
|
|
|
/// Override these InsetButton methods if Previewing
|
2006-11-28 15:15:49 +00:00
|
|
|
|
bool 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-10-21 13:04:14 +00:00
|
|
|
|
///
|
2004-08-14 19:20:42 +00:00
|
|
|
|
virtual bool display() const;
|
2002-08-01 17:28:59 +00:00
|
|
|
|
|
2001-03-14 10:57:39 +00:00
|
|
|
|
/// get the parameters
|
2006-10-21 00:16:43 +00:00
|
|
|
|
InsetCommandParams const & params() const;
|
2001-03-14 10:57:39 +00:00
|
|
|
|
|
2003-05-26 09:13:55 +00:00
|
|
|
|
///
|
2004-11-25 19:13:07 +00:00
|
|
|
|
InsetBase::Code lyxCode() const { return InsetBase::INCLUDE_CODE; }
|
2003-09-18 20:18:39 +00:00
|
|
|
|
/** Fills \c list
|
|
|
|
|
* \param buffer the Buffer containing this inset.
|
|
|
|
|
* \param list the list of labels in the child buffer.
|
|
|
|
|
*/
|
|
|
|
|
void getLabelList(Buffer const & buffer,
|
2006-10-21 00:16:43 +00:00
|
|
|
|
std::vector<docstring> & list) const;
|
2003-09-18 20:18:39 +00:00
|
|
|
|
/** Fills \c keys
|
|
|
|
|
* \param buffer the Buffer containing this inset.
|
|
|
|
|
* \param keys the list of bibkeys in the child buffer.
|
|
|
|
|
*/
|
|
|
|
|
void fillWithBibKeys(Buffer const & buffer,
|
2003-10-06 15:43:21 +00:00
|
|
|
|
std::vector<std::pair<std::string,std::string> > & keys) const;
|
2006-04-15 11:46:17 +00:00
|
|
|
|
/** Update the cache with all bibfiles in use of the child buffer
|
|
|
|
|
* (including bibfiles of grandchild documents).
|
2006-05-19 07:21:43 +00:00
|
|
|
|
* Does nothing if the child document is not loaded to prevent
|
|
|
|
|
* automatic loading of all child documents upon loading the master.
|
2006-04-15 11:46:17 +00:00
|
|
|
|
* \param buffer the Buffer containing this inset.
|
|
|
|
|
*/
|
|
|
|
|
void updateBibfilesCache(Buffer const & buffer);
|
|
|
|
|
/** Return the cache with all bibfiles in use of the child buffer
|
|
|
|
|
* (including bibfiles of grandchild documents).
|
2006-05-19 07:21:43 +00:00
|
|
|
|
* Return an empty vector if the child doc is not loaded.
|
2006-04-15 11:46:17 +00:00
|
|
|
|
* \param buffer the Buffer containing this inset.
|
|
|
|
|
*/
|
2006-12-01 20:09:08 +00:00
|
|
|
|
std::vector<support::FileName> const &
|
2006-04-15 11:46:17 +00:00
|
|
|
|
getBibfilesCache(Buffer const & buffer) const;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2003-09-19 10:16:33 +00:00
|
|
|
|
EDITABLE editable() const { return IS_EDITABLE; }
|
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 &);
|
|
|
|
|
///
|
2006-10-21 00:16:43 +00:00
|
|
|
|
int latex(Buffer const &, odocstream &,
|
2003-11-05 12:06:20 +00:00
|
|
|
|
OutputParams const &) const;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2006-10-21 00:16:43 +00:00
|
|
|
|
int plaintext(Buffer const &, odocstream &,
|
2003-11-05 12:06:20 +00:00
|
|
|
|
OutputParams const &) const;
|
2000-12-28 16:22:28 +00:00
|
|
|
|
///
|
2006-10-21 00:16:43 +00:00
|
|
|
|
int docbook(Buffer const &, odocstream &,
|
|
|
|
|
OutputParams const &) const;
|
2000-07-01 12:54:45 +00:00
|
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
|
void validate(LaTeXFeatures &) const;
|
2002-08-01 17:28:59 +00:00
|
|
|
|
///
|
2006-10-21 00:16:43 +00:00
|
|
|
|
void addPreview(graphics::PreviewLoader &) const;
|
2005-04-22 08:57:22 +00:00
|
|
|
|
///
|
2006-11-13 16:53:49 +00:00
|
|
|
|
void addToToc(TocList &, Buffer const &) const;
|
|
|
|
|
///
|
|
|
|
|
void updateLabels(Buffer const & buffer) const;
|
|
|
|
|
///
|
2005-04-22 08:57:22 +00:00
|
|
|
|
bool getStatus(LCursor &, FuncRequest const &, FuncStatus &) const;
|
2003-10-17 18:01:15 +00:00
|
|
|
|
protected:
|
2004-11-23 23:04:52 +00:00
|
|
|
|
InsetInclude(InsetInclude const &);
|
2003-10-17 18:01:15 +00:00
|
|
|
|
///
|
2004-11-24 21:58:42 +00:00
|
|
|
|
virtual void doDispatch(LCursor & cur, FuncRequest & cmd);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
private:
|
2004-11-23 23:04:52 +00:00
|
|
|
|
virtual std::auto_ptr<InsetBase> doClone() const;
|
|
|
|
|
|
2003-10-10 21:08:55 +00:00
|
|
|
|
/** Slot receiving a signal that the external file has changed
|
|
|
|
|
* and the preview should be regenerated.
|
|
|
|
|
*/
|
|
|
|
|
void fileChanged() const;
|
|
|
|
|
|
2003-08-28 07:41:31 +00:00
|
|
|
|
friend class InsetIncludeMailer;
|
2003-09-09 18:27:24 +00:00
|
|
|
|
|
2003-09-19 10:16:33 +00:00
|
|
|
|
/// set the parameters
|
|
|
|
|
void set(InsetCommandParams const & params, Buffer const &);
|
|
|
|
|
/// get the text displayed on the button
|
2006-10-21 00:16:43 +00:00
|
|
|
|
docstring const getScreenLabel(Buffer const &) const;
|
2003-08-28 07:41:31 +00:00
|
|
|
|
///
|
|
|
|
|
void write(std::ostream &) const;
|
|
|
|
|
///
|
|
|
|
|
void read(LyXLex &);
|
2001-03-14 10:57:39 +00:00
|
|
|
|
|
|
|
|
|
/// the parameters
|
2003-09-19 10:16:33 +00:00
|
|
|
|
InsetCommandParams params_;
|
2002-03-21 17:09:55 +00:00
|
|
|
|
/// holds the entity name that defines the file location (SGML)
|
2006-10-21 19:40:29 +00:00
|
|
|
|
docstring const include_label;
|
2002-08-01 17:28:59 +00:00
|
|
|
|
|
|
|
|
|
/// The pointer never changes although *preview_'s contents may.
|
2003-10-10 21:08:55 +00:00
|
|
|
|
boost::scoped_ptr<RenderMonitoredPreview> const preview_;
|
2003-06-02 10:03:27 +00:00
|
|
|
|
|
|
|
|
|
/// cache
|
2003-06-12 08:52:36 +00:00
|
|
|
|
mutable bool set_label_;
|
2003-10-10 21:08:55 +00:00
|
|
|
|
mutable RenderButton button_;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2003-03-05 14:59:37 +00:00
|
|
|
|
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
|
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
|
virtual std::string const & name() const { return name_; }
|
2003-03-05 14:59:37 +00:00
|
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
|
virtual std::string const inset2string(Buffer const &) const;
|
2003-03-05 14:59:37 +00:00
|
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
|
static void string2params(std::string const &, InsetCommandParams &);
|
2003-03-05 14:59:37 +00:00
|
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
|
static std::string const params2string(InsetCommandParams const &);
|
2003-03-05 14:59:37 +00:00
|
|
|
|
private:
|
|
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
|
static std::string const name_;
|
2003-03-05 14:59:37 +00:00
|
|
|
|
///
|
|
|
|
|
InsetInclude & inset_;
|
|
|
|
|
};
|
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
} // namespace lyx
|
|
|
|
|
|
2002-09-09 17:32:53 +00:00
|
|
|
|
#endif // INSETINCLUDE_H
|