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 "mailinset.h"
20 #include <boost/scoped_ptr.hpp>
27 class RenderMonitoredPreview;
30 /// for including tex/lyx files
31 class InsetInclude : public InsetOld {
34 InsetInclude(InsetCommandParams const &);
37 /// Override these InsetButton methods if Previewing
38 void metrics(MetricsInfo & mi, Dimension & dim) const;
40 void draw(PainterInfo & pi, int x, int y) const;
42 virtual bool display() const;
44 /// get the parameters
45 InsetCommandParams const & params() const;
48 InsetBase::Code lyxCode() const { return InsetBase::INCLUDE_CODE; }
50 * \param buffer the Buffer containing this inset.
51 * \param list the list of labels in the child buffer.
53 void getLabelList(Buffer const & buffer,
54 std::vector<docstring> & list) const;
56 * \param buffer the Buffer containing this inset.
57 * \param keys the list of bibkeys in the child buffer.
59 void fillWithBibKeys(Buffer const & buffer,
60 std::vector<std::pair<std::string,std::string> > & keys) const;
61 /** Update the cache with all bibfiles in use of the child buffer
62 * (including bibfiles of grandchild documents).
63 * Does nothing if the child document is not loaded to prevent
64 * automatic loading of all child documents upon loading the master.
65 * \param buffer the Buffer containing this inset.
67 void updateBibfilesCache(Buffer const & buffer);
68 /** Return the cache with all bibfiles in use of the child buffer
69 * (including bibfiles of grandchild documents).
70 * Return an empty vector if the child doc is not loaded.
71 * \param buffer the Buffer containing this inset.
73 std::vector<std::string> const &
74 getBibfilesCache(Buffer const & buffer) const;
76 EDITABLE editable() const { return IS_EDITABLE; }
78 void write(Buffer const &, std::ostream &) const;
80 void read(Buffer const &, LyXLex &);
82 int latex(Buffer const &, odocstream &,
83 OutputParams const &) const;
85 int plaintext(Buffer const &, odocstream &,
86 OutputParams const &) const;
88 int docbook(Buffer const &, odocstream &,
89 OutputParams const &) const;
91 void validate(LaTeXFeatures &) const;
93 void addPreview(graphics::PreviewLoader &) const;
95 bool getStatus(LCursor &, FuncRequest const &, FuncStatus &) const;
97 InsetInclude(InsetInclude const &);
99 virtual void doDispatch(LCursor & cur, FuncRequest & cmd);
101 virtual std::auto_ptr<InsetBase> doClone() const;
103 /** Slot receiving a signal that the external file has changed
104 * and the preview should be regenerated.
106 void fileChanged() const;
108 friend class InsetIncludeMailer;
110 /// set the parameters
111 void set(InsetCommandParams const & params, Buffer const &);
112 /// get the text displayed on the button
113 docstring const getScreenLabel(Buffer const &) const;
115 void write(std::ostream &) const;
120 InsetCommandParams params_;
121 /// holds the entity name that defines the file location (SGML)
122 docstring const include_label;
124 /// The pointer never changes although *preview_'s contents may.
125 boost::scoped_ptr<RenderMonitoredPreview> const preview_;
128 mutable bool set_label_;
129 mutable RenderButton button_;
133 class InsetIncludeMailer : public MailInset {
136 InsetIncludeMailer(InsetInclude & inset);
138 virtual InsetBase & inset() const { return inset_; }
140 virtual std::string const & name() const { return name_; }
142 virtual std::string const inset2string(Buffer const &) const;
144 static void string2params(std::string const &, InsetCommandParams &);
146 static std::string const params2string(InsetCommandParams const &);
149 static std::string const name_;
151 InsetInclude & inset_;
157 #endif // INSETINCLUDE_H