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 "support/filetools.h"
24 // Created by AAS 970521
26 /** Used to include files
28 class InsetInclude: public InsetCommand {
31 InsetInclude(): InsetCommand("include")
33 flag = InsetInclude::INCLUDE;
36 InsetInclude(string const &, Buffer *);
40 Inset * Clone() const;
42 Inset::Code LyxCode() const { return Inset::INCLUDE_CODE; }
43 /// This returns the list of labels on the child buffer
44 std::vector<string> getLabelList() const;
45 /// This returns the list of bibkeys on the child buffer
46 std::vector< std::pair<string,string> > getKeys() const;
48 void Edit(BufferView *, int x, int y, unsigned int button);
50 EDITABLE Editable() const
54 /// With lyx3 we won't overload these 3 methods
55 void Write(Buffer const *, std::ostream &) const;
57 void Read(Buffer const *, LyXLex &);
59 int Latex(Buffer const *, std::ostream &, bool fragile, bool free_spc) const;
61 int Linuxdoc(Buffer const *, std::ostream &) const;
63 int DocBook(Buffer const *, std::ostream &) const;
65 void Validate(LaTeXFeatures &) const;
67 /// Input inserts anything inside a paragraph, Display can give some visual feedback
70 string getScreenLabel() const;
72 void setContents(string const & c);
74 void setFilename(string const & n) { setContents(n); }
76 string getMasterFilename() const { return master->fileName(); }
78 string getFileName() const {
81 /// In "input" mode uses \input instead of \include.
82 bool isInput() const { return flag == InsetInclude::INPUT; }
83 /// If this is true, the child file shouldn't be loaded by lyx
84 bool isNoLoad() const { return noload; }
86 /** A verbatim file shouldn't be loaded by LyX
87 * No need to generate LaTeX code of a verbatim file
91 bool isVerbVisibleSpace() const { return flag == InsetInclude::VERBAST;}
93 bool isInclude() const { return flag == InsetInclude::INCLUDE;}
103 void setVisibleSpace(bool b);
104 /// return true if the file is or got loaded.
105 bool loadIfNeeded() const;
128 mutable string include_label;
133 bool InsetInclude::isVerb() const
135 return flag == InsetInclude::VERB || flag == InsetInclude::VERBAST;
140 void InsetInclude::setInput()
143 flag = InsetInclude::INPUT;
150 void InsetInclude::setNoLoad(bool b)
157 void InsetInclude::setInclude()
160 flag = InsetInclude::INCLUDE;
161 setCmdName("include");
167 void InsetInclude::setVerb()
170 flag = InsetInclude::VERB;
171 setCmdName("verbatiminput");
177 void InsetInclude::setVisibleSpace(bool b)
179 if (b && flag == InsetInclude::VERB) {
180 setCmdName("verbatiminput*");
181 flag = InsetInclude::VERBAST;
182 } else if (!b && flag == InsetInclude::VERBAST) {
183 setCmdName("verbatiminput");
184 flag = InsetInclude::VERB;