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 "insetcommand.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 int ascent(BufferView *, LyXFont const &) const;
66 int descent(BufferView *, LyXFont const &) const;
68 int width(BufferView *, LyXFont const &) const;
70 void draw(BufferView *, LyXFont const &, int, float &) const;
72 /// get the parameters
73 Params const & params(void) const;
74 /// set the parameters
75 void set(Params const & params);
78 virtual Inset * clone(Buffer const &, bool same_id = false) const;
80 Inset::Code lyxCode() const { return Inset::INCLUDE_CODE; }
81 /// This returns the list of labels on the child buffer
82 std::vector<string> const getLabelList() const;
83 /// This returns the list of bibkeys on the child buffer
84 void fillWithBibKeys(std::vector<std::pair<string,string> > & keys) const;
86 void edit(BufferView *, int x, int y, mouse_button::state button);
88 void edit(BufferView * bv, bool front = true);
90 EDITABLE editable() const
94 /// With lyx3 we won't overload these 3 methods
95 void write(Buffer const *, std::ostream &) const;
97 void read(Buffer const *, LyXLex &);
99 int latex(Buffer const *, std::ostream &,
100 bool fragile, bool free_spc) const;
102 int ascii(Buffer const *, std::ostream &, int linelen) const;
104 int linuxdoc(Buffer const *, std::ostream &) const;
106 int docbook(Buffer const *, std::ostream &, bool mixcont) const;
108 void validate(LaTeXFeatures &) const;
110 /// take up a whole row if we're not type INPUT
111 bool display() const;
113 /// return true if the file is or got loaded.
114 bool loadIfNeeded() const;
117 void addPreview(grfx::PreviewLoader &) const;
120 /// get the text displayed on the button
121 string const getScreenLabel(Buffer const *) const;
122 /// is this a verbatim include ?
123 bool isVerbatim() const;
124 /// get the filename of the master buffer
125 string const getMasterFilename() const;
126 /// get the included file name
127 string const getFileName() const;
131 /// holds the entity name that defines the file location (SGML)
132 string const include_label;
134 /// Use the Pimpl idiom to hide the internals of the previewer.
136 friend class PreviewImpl;
137 /// The pointer never changes although *preview_'s contents may.
138 boost::scoped_ptr<PreviewImpl> const preview_;
142 inline bool InsetInclude::isVerbatim() const
144 return params_.flag == VERB || params_.flag == VERBAST;
147 #include "mailinset.h"
149 class InsetIncludeMailer : public MailInset {
152 InsetIncludeMailer(InsetInclude & inset);
154 virtual InsetBase & inset() const { return inset_; }
156 virtual string const & name() const { return name_; }
158 virtual string const inset2string() const;
160 static void string2params(string const &, InsetInclude::Params &);
162 static string const params2string(InsetInclude::Params const &);
165 static string const name_;
167 InsetInclude & inset_;
170 #endif // INSETINCLUDE_H