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 "dimension.h"
18 #include <boost/scoped_ptr.hpp>
23 // Created by AAS 970521
25 /// for including tex/lyx files
26 class InsetInclude: public InsetButton, boost::noncopyable {
28 /// the type of inclusion
37 Params(InsetCommandParams const & cp = InsetCommandParams("input"),
39 string const & name = string())
40 : cparams(cp), flag(f),
41 masterFilename_(name) {}
43 InsetCommandParams cparams;
45 string masterFilename_;
48 bool operator==(Params const &) const;
50 bool operator!=(Params const &) const;
54 InsetInclude(Params const &);
56 InsetInclude(InsetCommandParams const &, Buffer const &);
61 virtual dispatch_result localDispatch(FuncRequest const & cmd);
63 /// Override these InsetButton methods if Previewing
64 void metrics(MetricsInfo & mi, Dimension & dim) const;
66 void draw(PainterInfo & pi, int x, int y) const;
68 /// get the parameters
69 Params const & params(void) const;
70 /// set the parameters
71 void set(Params const & params);
74 virtual Inset * clone() const;
76 Inset::Code lyxCode() const { return Inset::INCLUDE_CODE; }
77 /// This returns the list of labels on the child buffer
78 std::vector<string> const getLabelList() const;
79 /// This returns the list of bibkeys on the child buffer
80 void fillWithBibKeys(std::vector<std::pair<string,string> > & keys) const;
82 EDITABLE editable() const
86 /// With lyx3 we won't overload these 3 methods
87 void write(Buffer const *, std::ostream &) const;
89 void read(Buffer const *, LyXLex &);
91 int latex(Buffer const *, std::ostream &,
92 LatexRunParams const &) const;
94 int ascii(Buffer const *, std::ostream &, int linelen) const;
96 int linuxdoc(Buffer const *, std::ostream &) const;
98 int docbook(Buffer const *, std::ostream &, bool mixcont) const;
100 void validate(LaTeXFeatures &) const;
102 /// take up a whole row if we're not type INPUT
103 bool display() const;
105 /// return true if the file is or got loaded.
106 bool loadIfNeeded() const;
109 void addPreview(grfx::PreviewLoader &) const;
112 /// get the text displayed on the button
113 string const getScreenLabel(Buffer const *) const;
114 /// is this a verbatim include ?
115 bool isVerbatim() const;
116 /// get the filename of the master buffer
117 string const getMasterFilename() const;
118 /// get the included file name
119 string const getFileName() const;
123 /// holds the entity name that defines the file location (SGML)
124 string const include_label;
126 /// Use the Pimpl idiom to hide the internals of the previewer.
128 friend class PreviewImpl;
129 /// The pointer never changes although *preview_'s contents may.
130 boost::scoped_ptr<PreviewImpl> const preview_;
133 mutable Dimension dim_;
137 inline bool InsetInclude::isVerbatim() const
139 return params_.flag == VERB || params_.flag == VERBAST;
142 #include "mailinset.h"
144 class InsetIncludeMailer : public MailInset {
147 InsetIncludeMailer(InsetInclude & inset);
149 virtual InsetBase & inset() const { return inset_; }
151 virtual string const & name() const { return name_; }
153 virtual string const inset2string() const;
155 static void string2params(string const &, InsetInclude::Params &);
157 static string const params2string(InsetInclude::Params const &);
160 static string const name_;
162 InsetInclude & inset_;
165 #endif // INSETINCLUDE_H