2 /* This file is part of*
3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright 1997 LyX Team (this file was created this year)
9 * ====================================================== */
11 #ifndef INSET_INCLUDE_H
12 #define INSET_INCLUDE_H
18 #include "insetcommand.h"
20 #include <boost/signals/signal0.hpp>
21 #include <boost/scoped_ptr.hpp>
26 // Created by AAS 970521
28 /** Used to include files
30 class InsetInclude: public InsetButton, boost::noncopyable {
32 /// the type of inclusion
45 Params(InsetCommandParams const & cp = InsetCommandParams(),
48 string const & name = string())
49 : cparams(cp), flag(f), noload(nl),
50 masterFilename_(name) {}
51 InsetCommandParams cparams;
54 string masterFilename_;
57 bool operator==(Params const &) const;
59 bool operator!=(Params const &) const;
63 InsetInclude(Params const &);
65 InsetInclude(InsetCommandParams const &, Buffer const &);
69 /// Override these InsetButton methods if Previewing
70 int ascent(BufferView *, LyXFont const &) const;
72 int descent(BufferView *, LyXFont const &) const;
74 int width(BufferView *, LyXFont const &) const;
76 void draw(BufferView *, LyXFont const &, int, float &, bool) const;
78 /// get the parameters
79 Params const & params(void) const;
80 /// set the parameters
81 void set(Params const & params);
84 virtual Inset * clone(Buffer const &, bool same_id = false) const;
86 Inset::Code lyxCode() const { return Inset::INCLUDE_CODE; }
87 /// This returns the list of labels on the child buffer
88 std::vector<string> const getLabelList() const;
89 /// This returns the list of bibkeys on the child buffer
90 std::vector< std::pair<string,string> > const getKeys() const;
92 void edit(BufferView *, int x, int y, mouse_button::state button);
94 void edit(BufferView * bv, bool front = true);
96 EDITABLE editable() const
100 /// With lyx3 we won't overload these 3 methods
101 void write(Buffer const *, std::ostream &) const;
103 void read(Buffer const *, LyXLex &);
105 int latex(Buffer const *, std::ostream &,
106 bool fragile, bool free_spc) const;
108 int ascii(Buffer const *, std::ostream &, int linelen) const;
110 int linuxdoc(Buffer const *, std::ostream &) const;
112 int docbook(Buffer const *, std::ostream &, bool mixcont) const;
114 void validate(LaTeXFeatures &) const;
116 /** Input inserts anything inside a paragraph.
117 Display can give some visual feedback
119 bool display() const;
121 /// return the filename stub of the included file
122 string const getRelFileBaseName() const;
124 /// return true if the included file is not loaded
125 bool isIncludeOnly() const;
127 /// return true if the file is or got loaded.
128 bool loadIfNeeded() const;
131 void addPreview(grfx::PreviewLoader &) const;
133 /// hide a dialog if about
134 boost::signal0<void> hideDialog;
136 /// get the text displayed on the button
137 string const getScreenLabel(Buffer const *) const;
138 /// is this a verbatim include ?
139 bool isVerbatim() const;
140 /// get the filename of the master buffer
141 string const getMasterFilename() const;
142 /// get the included file name
143 string const getFileName() const;
147 /// holds the entity name that defines the file location (SGML)
148 string const include_label;
150 /// Use the Pimpl idiom to hide the internals of the previewer.
152 friend class PreviewImpl;
153 /// The pointer never changes although *preview_'s contents may.
154 boost::scoped_ptr<PreviewImpl> const preview_;
158 inline bool InsetInclude::isVerbatim() const
160 return params_.flag == VERB || params_.flag == VERBAST;
164 inline bool InsetInclude::isIncludeOnly() const
166 return params_.flag == INCLUDE && params_.noload;