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>
19 #include <boost/weak_ptr.hpp>
25 class RenderMonitoredPreview;
28 /// for including tex/lyx files
29 class InsetInclude: public InsetOld {
32 InsetInclude(InsetCommandParams const &);
33 InsetInclude(InsetInclude const &);
37 virtual std::auto_ptr<InsetBase> clone() const;
40 virtual dispatch_result localDispatch(FuncRequest const & cmd);
42 /// Override these InsetButton methods if Previewing
43 void metrics(MetricsInfo & mi, Dimension & dim) const;
45 void draw(PainterInfo & pi, int x, int y) const;
47 /// get the parameters
48 InsetCommandParams const & params(void) const;
51 InsetOld::Code lyxCode() const { return InsetOld::INCLUDE_CODE; }
53 * \param buffer the Buffer containing this inset.
54 * \param list the list of labels in the child buffer.
56 void getLabelList(Buffer const & buffer,
57 std::vector<std::string> & list) const;
59 * \param buffer the Buffer containing this inset.
60 * \param keys the list of bibkeys in the child buffer.
63 void fillWithBibKeys(Buffer const & buffer,
64 std::vector<std::pair<std::string,std::string> > & keys) const;
66 EDITABLE editable() const { return IS_EDITABLE; }
68 void write(Buffer const &, std::ostream &) const;
70 void read(Buffer const &, LyXLex &);
72 int latex(Buffer const &, std::ostream &, LatexRunParams const &) const;
74 int ascii(Buffer const &, std::ostream &, int linelen) const;
76 int linuxdoc(Buffer const &, std::ostream &) const;
78 int docbook(Buffer const &, std::ostream &, bool mixcont) const;
80 void validate(LaTeXFeatures &) const;
82 void addPreview(lyx::graphics::PreviewLoader &) const;
85 void cache(BufferView *) const;
86 BufferView * view() const;
88 /// Slot receiving a signal that the preview is ready to display.
89 void statusChanged() const;
90 /** Slot receiving a signal that the external file has changed
91 * and the preview should be regenerated.
93 void fileChanged() const;
95 friend class InsetIncludeMailer;
97 /// set the parameters
98 void set(InsetCommandParams const & params, Buffer const &);
99 /// get the text displayed on the button
100 std::string const getScreenLabel(Buffer const &) const;
102 void write(std::ostream &) const;
107 InsetCommandParams params_;
108 /// holds the entity name that defines the file location (SGML)
109 std::string const include_label;
111 /// The pointer never changes although *preview_'s contents may.
112 boost::scoped_ptr<RenderMonitoredPreview> const preview_;
115 mutable boost::weak_ptr<BufferView> view_;
116 mutable bool set_label_;
117 mutable RenderButton button_;
121 #include "mailinset.h"
123 class InsetIncludeMailer : public MailInset {
126 InsetIncludeMailer(InsetInclude & inset);
128 virtual InsetBase & inset() const { return inset_; }
130 virtual std::string const & name() const { return name_; }
132 virtual std::string const inset2string(Buffer const &) const;
134 static void string2params(std::string const &, InsetCommandParams &);
136 static std::string const params2string(InsetCommandParams const &);
139 static std::string const name_;
141 InsetInclude & inset_;
144 #endif // INSETINCLUDE_H