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 string getKeys(char delim) 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(std::ostream &) const;
59 int Latex(std::ostream &, bool fragile, bool free_spc) const;
61 void Validate(LaTeXFeatures &) const;
63 /// Input inserts anything inside a paragraph, Display can give some visual feedback
66 string getScreenLabel() const;
68 void setContents(string const & c);
70 void setFilename(string const & n) { setContents(n); }
72 string getMasterFilename() const { return master->fileName(); }
74 string getFileName() const {
77 /// In "input" mode uses \input instead of \include.
78 bool isInput() const { return flag == InsetInclude::INPUT; }
79 /// If this is true, the child file shouldn't be loaded by lyx
80 bool isNoLoad() const { return noload; }
82 /** A verbatim file shouldn't be loaded by LyX
83 * No need to generate LaTeX code of a verbatim file
87 bool isVerbVisibleSpace() const { return flag == InsetInclude::VERBAST;}
89 bool isInclude() const { return flag == InsetInclude::INCLUDE;}
99 void setVisibleSpace(bool b);
100 /// return true if the file is or got loaded.
101 bool loadIfNeeded() const;
127 bool InsetInclude::isVerb() const
129 return flag == InsetInclude::VERB || flag == InsetInclude::VERBAST;
134 void InsetInclude::setInput()
137 flag = InsetInclude::INPUT;
144 void InsetInclude::setNoLoad(bool b)
151 void InsetInclude::setInclude()
154 flag = InsetInclude::INCLUDE;
155 setCmdName("include");
161 void InsetInclude::setVerb()
164 flag = InsetInclude::VERB;
165 setCmdName("verbatiminput");
171 void InsetInclude::setVisibleSpace(bool b)
173 if (b && flag == InsetInclude::VERB) {
174 setCmdName("verbatiminput*");
175 flag = InsetInclude::VERBAST;
176 } else if (!b && flag == InsetInclude::VERBAST) {
177 setCmdName("verbatiminput");
178 flag = InsetInclude::VERB;