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; }
66 * \param buffer the Buffer containing this inset.
67 * \param list the list of labels in the child buffer.
69 void getLabelList(Buffer const & buffer,
70 std::vector<string> & list) const;
72 * \param buffer the Buffer containing this inset.
73 * \param keys the list of bibkeys in the child buffer.
76 void fillWithBibKeys(Buffer const & buffer,
77 std::vector<std::pair<string,string> > & keys) const;
79 EDITABLE editable() const
84 void write(Buffer const &, std::ostream &) const;
86 void read(Buffer const &, LyXLex &);
88 int latex(Buffer const &, std::ostream &,
89 LatexRunParams const &) const;
91 int ascii(Buffer const &, std::ostream &, int linelen) const;
93 int linuxdoc(Buffer const &, std::ostream &) const;
95 int docbook(Buffer const &, std::ostream &, bool mixcont) const;
97 void validate(LaTeXFeatures &) const;
100 void addPreview(lyx::graphics::PreviewLoader &) const;
103 friend class InsetIncludeMailer;
105 /// return true if the file is or got loaded.
106 bool loadIfNeeded() const;
109 void write(std::ostream &) const;
112 /// get the text displayed on the button
113 string const getScreenLabel(Buffer const &) const;
114 /// get the filename of the master buffer
115 string const getMasterFilename() const;
116 /// get the included file name
117 string const getFileName() const;
121 /// holds the entity name that defines the file location (SGML)
122 string const include_label;
124 /// Use the Pimpl idiom to hide the internals of the previewer.
126 friend class PreviewImpl;
127 /// The pointer never changes although *preview_'s contents may.
128 boost::scoped_ptr<PreviewImpl> const preview_;
131 mutable bool set_label_;
132 mutable ButtonRenderer button_;
136 #include "mailinset.h"
138 class InsetIncludeMailer : public MailInset {
141 InsetIncludeMailer(InsetInclude & inset);
143 virtual InsetBase & inset() const { return inset_; }
145 virtual string const & name() const { return name_; }
147 virtual string const inset2string(Buffer const &) const;
149 static void string2params(string const &, InsetInclude::Params &);
151 static string const params2string(InsetInclude::Params const &);
154 static string const name_;
156 InsetInclude & inset_;
159 #endif // INSETINCLUDE_H