4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Lars Gullik Bjønnes
9 * Full author contact details are available in file CREDITS.
12 #ifndef INSET_INCLUDE_H
13 #define INSET_INCLUDE_H
16 #include "insetcommandparams.h"
17 #include "render_button.h"
18 #include <boost/scoped_ptr.hpp>
23 class RenderMonitoredPreview;
26 /// for including tex/lyx files
27 class InsetInclude: public InsetOld {
30 InsetInclude(InsetCommandParams const &);
33 /// Override these InsetButton methods if Previewing
34 void metrics(MetricsInfo & mi, Dimension & dim) const;
36 void draw(PainterInfo & pi, int x, int y) const;
38 virtual bool display() const;
40 /// get the parameters
41 InsetCommandParams const & params(void) const;
44 InsetBase::Code lyxCode() const { return InsetBase::INCLUDE_CODE; }
46 * \param buffer the Buffer containing this inset.
47 * \param list the list of labels in the child buffer.
49 void getLabelList(Buffer const & buffer,
50 std::vector<std::string> & list) const;
52 * \param buffer the Buffer containing this inset.
53 * \param keys the list of bibkeys in the child buffer.
55 void fillWithBibKeys(Buffer const & buffer,
56 std::vector<std::pair<std::string,std::string> > & keys) const;
57 /** Update the cache with all bibfiles in use of the child buffer
58 * (including bibfiles of grandchild documents).
59 * Does nothing if the child document is not loaded to prevent
60 * automatic loading of all child documents upon loading the master.
61 * \param buffer the Buffer containing this inset.
63 void updateBibfilesCache(Buffer const & buffer);
64 /** Return the cache with all bibfiles in use of the child buffer
65 * (including bibfiles of grandchild documents).
66 * Return an empty vector if the child doc is not loaded.
67 * \param buffer the Buffer containing this inset.
69 std::vector<std::string> const &
70 getBibfilesCache(Buffer const & buffer) const;
72 EDITABLE editable() const { return IS_EDITABLE; }
74 void write(Buffer const &, std::ostream &) const;
76 void read(Buffer const &, LyXLex &);
78 int latex(Buffer const &, std::ostream &,
79 OutputParams const &) const;
81 int plaintext(Buffer const &, std::ostream &,
82 OutputParams const &) const;
84 int docbook(Buffer const &, std::ostream &,
85 OutputParams const &) const;
87 void validate(LaTeXFeatures &) const;
89 void addPreview(lyx::graphics::PreviewLoader &) const;
91 bool getStatus(LCursor &, FuncRequest const &, FuncStatus &) const;
93 InsetInclude(InsetInclude const &);
95 virtual void doDispatch(LCursor & cur, FuncRequest & cmd);
97 virtual std::auto_ptr<InsetBase> doClone() const;
99 /** Slot receiving a signal that the external file has changed
100 * and the preview should be regenerated.
102 void fileChanged() const;
104 friend class InsetIncludeMailer;
106 /// set the parameters
107 void set(InsetCommandParams const & params, Buffer const &);
108 /// get the text displayed on the button
109 std::string const getScreenLabel(Buffer const &) const;
111 void write(std::ostream &) const;
116 InsetCommandParams params_;
117 /// holds the entity name that defines the file location (SGML)
118 std::string const include_label;
120 /// The pointer never changes although *preview_'s contents may.
121 boost::scoped_ptr<RenderMonitoredPreview> const preview_;
124 mutable bool set_label_;
125 mutable RenderButton button_;
129 #include "mailinset.h"
131 class InsetIncludeMailer : public MailInset {
134 InsetIncludeMailer(InsetInclude & inset);
136 virtual InsetBase & inset() const { return inset_; }
138 virtual std::string const & name() const { return name_; }
140 virtual std::string const inset2string(Buffer const &) const;
142 static void string2params(std::string const &, InsetCommandParams &);
144 static std::string const params2string(InsetCommandParams const &);
147 static std::string const name_;
149 InsetInclude & inset_;
152 #endif // INSETINCLUDE_H