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"
17 #include "renderers.h"
18 #include <boost/scoped_ptr.hpp>
24 // Created by AAS 970521
26 /// for including tex/lyx files
27 class InsetInclude: public Inset {
29 /// the type of inclusion
38 Params(InsetCommandParams const & cp = InsetCommandParams("input"),
40 string const & name = string())
41 : cparams(cp), flag(f),
42 masterFilename_(name) {}
44 InsetCommandParams cparams;
46 string masterFilename_;
49 bool operator==(Params const &) const;
51 bool operator!=(Params const &) const;
55 InsetInclude(Params const &);
56 InsetInclude(InsetCommandParams const &, Buffer const &);
57 InsetInclude(InsetInclude const &);
62 virtual dispatch_result localDispatch(FuncRequest const & cmd);
64 /// Override these InsetButton methods if Previewing
65 void metrics(MetricsInfo & mi, Dimension & dim) const;
67 void draw(PainterInfo & pi, int x, int y) const;
69 virtual BufferView * view() const;
71 /// get the parameters
72 Params const & params(void) const;
73 /// set the parameters
74 void set(Params const & params);
77 virtual InsetBase * clone() const;
79 Inset::Code lyxCode() const { return Inset::INCLUDE_CODE; }
80 /// This returns the list of labels on the child buffer
81 void getLabelList(std::vector<string> &) const;
82 /// This returns the list of bibkeys on the child buffer
83 void fillWithBibKeys(std::vector<std::pair<string,string> > & keys) const;
85 EDITABLE editable() const
89 /// With lyx3 we won't overload these 3 methods
90 void write(Buffer const *, std::ostream &) const;
92 void read(Buffer const *, LyXLex &);
94 int latex(Buffer const *, std::ostream &,
95 LatexRunParams const &) const;
97 int ascii(Buffer const *, std::ostream &, int linelen) const;
99 int linuxdoc(Buffer const *, std::ostream &) const;
101 int docbook(Buffer const *, std::ostream &, bool mixcont) const;
103 void validate(LaTeXFeatures &) const;
105 /// take up a whole row if we're not type INPUT
106 bool display() const;
108 /// return true if the file is or got loaded.
109 bool loadIfNeeded() const;
112 void addPreview(lyx::graphics::PreviewLoader &) const;
115 /// get the text displayed on the button
116 string const getScreenLabel(Buffer const *) const;
117 /// is this a verbatim include ?
118 bool isVerbatim() const;
119 /// get the filename of the master buffer
120 string const getMasterFilename() const;
121 /// get the included file name
122 string const getFileName() const;
126 /// holds the entity name that defines the file location (SGML)
127 string const include_label;
129 /// Use the Pimpl idiom to hide the internals of the previewer.
131 friend class PreviewImpl;
132 /// The pointer never changes although *preview_'s contents may.
133 boost::scoped_ptr<PreviewImpl> const preview_;
136 mutable Dimension dim_;
137 mutable bool set_label_;
138 mutable ButtonRenderer button_;
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