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 is 1 if the childs have labels, 0 otherwise
44 int GetNumberOfLabels() const;
45 /// This returns the list of labels on the child buffer
46 string getLabel(int) const;
47 /// This returns the list of bibkeys on the child buffer
48 string getKeys(char delim) const;
50 void Edit(BufferView *, int x, int y, unsigned int button);
52 EDITABLE Editable() const
56 /// With lyx3 we won't overload these 3 methods
57 void Write(std::ostream &) const;
61 int Latex(std::ostream &, bool fragile, bool free_spc) const;
63 void Validate(LaTeXFeatures &) const;
65 /// Input inserts anything inside a paragraph, Display can give some visual feedback
68 string getScreenLabel() const;
70 void setContents(string const & c);
72 void setFilename(string const & n) { setContents(n); }
74 string getMasterFilename() const { return master->fileName(); }
76 string getFileName() const {
79 /// In "input" mode uses \input instead of \include.
80 bool isInput() const { return flag == InsetInclude::INPUT; }
81 /// If this is true, the child file shouldn't be loaded by lyx
82 bool isNoLoad() const { return noload; }
84 /** A verbatim file shouldn't be loaded by LyX
85 * No need to generate LaTeX code of a verbatim file
89 bool isVerbVisibleSpace() const { return flag == InsetInclude::VERBAST;}
91 bool isInclude() const { return flag == InsetInclude::INCLUDE;}
101 void setVisibleSpace(bool b);
102 /// return true if the file is or got loaded.
103 bool loadIfNeeded() const;
129 bool InsetInclude::isVerb() const
131 return flag == InsetInclude::VERB || flag == InsetInclude::VERBAST;
136 void InsetInclude::setInput()
139 flag = InsetInclude::INPUT;
146 void InsetInclude::setNoLoad(bool b)
153 void InsetInclude::setInclude()
156 flag = InsetInclude::INCLUDE;
157 setCmdName("include");
163 void InsetInclude::setVerb()
166 flag = InsetInclude::VERB;
167 setCmdName("verbatiminput");
173 void InsetInclude::setVisibleSpace(bool b)
175 if (b && flag == InsetInclude::VERB) {
176 setCmdName("verbatiminput*");
177 flag = InsetInclude::VERBAST;
178 } else if (!b && flag == InsetInclude::VERBAST) {
179 setCmdName("verbatiminput");
180 flag = InsetInclude::VERB;