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
15 #include "insetcommand.h"
16 #include "renderers.h"
17 #include <boost/scoped_ptr.hpp>
24 // Created by AAS 970521
26 /// for including tex/lyx files
27 class InsetInclude: public InsetOld {
30 Params(InsetCommandParams const & cp = InsetCommandParams("input"),
31 string const & name = string())
33 masterFilename_(name) {}
35 InsetCommandParams cparams;
36 string masterFilename_;
40 InsetInclude(Params const &);
41 InsetInclude(InsetCommandParams const &, Buffer const &);
42 InsetInclude(InsetInclude const &);
47 virtual dispatch_result localDispatch(FuncRequest const & cmd);
49 /// Override these InsetButton methods if Previewing
50 void metrics(MetricsInfo & mi, Dimension & dim) const;
52 void draw(PainterInfo & pi, int x, int y) const;
54 virtual BufferView * view() const;
56 /// get the parameters
57 Params const & params(void) const;
58 /// set the parameters
59 void set(Params const & params);
62 virtual std::auto_ptr<InsetBase> clone() const;
64 InsetOld::Code lyxCode() const { return InsetOld::INCLUDE_CODE; }
65 /// This returns the list of labels on the child buffer
66 void getLabelList(std::vector<string> &) const;
67 /// This returns the list of bibkeys on the child buffer
68 void fillWithBibKeys(std::vector<std::pair<string,string> > & keys) const;
70 EDITABLE editable() const
75 void write(Buffer const &, std::ostream &) const;
77 void read(Buffer const &, LyXLex &);
79 int latex(Buffer const &, std::ostream &,
80 LatexRunParams const &) const;
82 int ascii(Buffer const &, std::ostream &, int linelen) const;
84 int linuxdoc(Buffer const &, std::ostream &) const;
86 int docbook(Buffer const &, std::ostream &, bool mixcont) const;
88 void validate(LaTeXFeatures &) const;
90 /// return true if the file is or got loaded.
91 bool loadIfNeeded() const;
94 void addPreview(lyx::graphics::PreviewLoader &) const;
97 friend class InsetIncludeMailer;
100 void write(std::ostream &) const;
103 /// get the text displayed on the button
104 string const getScreenLabel(Buffer const &) const;
105 /// get the filename of the master buffer
106 string const getMasterFilename() const;
107 /// get the included file name
108 string const getFileName() const;
112 /// holds the entity name that defines the file location (SGML)
113 string const include_label;
115 /// Use the Pimpl idiom to hide the internals of the previewer.
117 friend class PreviewImpl;
118 /// The pointer never changes although *preview_'s contents may.
119 boost::scoped_ptr<PreviewImpl> const preview_;
122 mutable bool set_label_;
123 mutable ButtonRenderer button_;
127 #include "mailinset.h"
129 class InsetIncludeMailer : public MailInset {
132 InsetIncludeMailer(InsetInclude & inset);
134 virtual InsetBase & inset() const { return inset_; }
136 virtual string const & name() const { return name_; }
138 virtual string const inset2string(Buffer const &) const;
140 static void string2params(string const &, InsetInclude::Params &);
142 static string const params2string(InsetInclude::Params const &);
145 static string const name_;
147 InsetInclude & inset_;
150 #endif // INSETINCLUDE_H