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 void addToToc(TocList &, Buffer const &) const;
97 void updateLabels(Buffer const & buffer) const;
99 bool getStatus(LCursor &, FuncRequest const &, FuncStatus &) const;
101 InsetInclude(InsetInclude const &);
103 virtual void doDispatch(LCursor & cur, FuncRequest & cmd);
105 virtual std::auto_ptr<InsetBase> doClone() const;
107 /** Slot receiving a signal that the external file has changed
108 * and the preview should be regenerated.
110 void fileChanged() const;
112 friend class InsetIncludeMailer;
114 /// set the parameters
115 void set(InsetCommandParams const & params, Buffer const &);
116 /// get the text displayed on the button
117 docstring const getScreenLabel(Buffer const &) const;
119 void write(std::ostream &) const;
124 InsetCommandParams params_;
125 /// holds the entity name that defines the file location (SGML)
126 docstring const include_label;
128 /// The pointer never changes although *preview_'s contents may.
129 boost::scoped_ptr<RenderMonitoredPreview> const preview_;
132 mutable bool set_label_;
133 mutable RenderButton button_;
137 class InsetIncludeMailer : public MailInset {
140 InsetIncludeMailer(InsetInclude & inset);
142 virtual InsetBase & inset() const { return inset_; }
144 virtual std::string const & name() const { return name_; }
146 virtual std::string const inset2string(Buffer const &) const;
148 static void string2params(std::string const &, InsetCommandParams &);
150 static std::string const params2string(InsetCommandParams const &);
153 static std::string const name_;
155 InsetInclude & inset_;
161 #endif // INSETINCLUDE_H