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"
26 // Created by AAS 970521
28 /** Used to include files
30 class InsetInclude: public InsetCommand {
33 InsetInclude(): InsetCommand("include")
35 flag = InsetInclude::INCLUDE;
38 InsetInclude(string const &, Buffer *);
42 Inset * Clone() const;
44 Inset::Code LyxCode() const { return Inset::INCLUDE_CODE; }
45 /// This is 1 if the childs have labels, 0 otherwise
46 int GetNumberOfLabels() const;
47 /// This returns the list of labels on the child buffer
48 string getLabel(int) const;
49 /// This returns the list of bibkeys on the child buffer
50 string getKeys(char delim) const;
52 void Edit(BufferView *, int x, int y, unsigned int button);
54 EDITABLE Editable() const
58 /// With lyx3 we won't overload these 3 methods
59 void Write(ostream &) const;
63 int Latex(ostream &, signed char fragile, bool free_spc) const;
65 void Validate(LaTeXFeatures &) const;
67 /// Input inserts anything inside a paragraph, Display can give some visual feedback
68 bool display() const { return !(isInput()); }
70 string getScreenLabel() const;
72 void setContents(string const & c) {
73 InsetCommand::setContents(c);
74 filename = MakeAbsPath(contents,
75 OnlyPath(getMasterFilename()));
78 void setFilename(string const & n) { setContents(n); }
80 string getMasterFilename() const { return master->fileName(); }
82 string getFileName() const {
85 /// In "input" mode uses \input instead of \include.
86 bool isInput() const { return flag == InsetInclude::INPUT; }
87 /// If this is true, the child file shouldn't be loaded by lyx
88 bool isNoLoad() const { return noload; }
90 /** A verbatim file shouldn't be loaded by LyX
91 * No need to generate LaTeX code of a verbatim file
95 bool isVerbVisibleSpace() const { return flag == InsetInclude::VERBAST;}
97 bool isInclude() const { return flag == InsetInclude::INCLUDE;}
101 void setNoLoad(bool);
107 void setVisibleSpace(bool b);
108 /// return true if the file is or got loaded.
109 bool loadIfNeeded() const;
135 bool InsetInclude::isVerb() const
137 return flag == InsetInclude::VERB || flag == InsetInclude::VERBAST;
142 void InsetInclude::setInput()
145 flag = InsetInclude::INPUT;
152 void InsetInclude::setNoLoad(bool b)
159 void InsetInclude::setInclude()
162 flag = InsetInclude::INCLUDE;
163 setCmdName("include");
169 void InsetInclude::setVerb()
172 flag = InsetInclude::VERB;
173 setCmdName("verbatiminput");
179 void InsetInclude::setVisibleSpace(bool b)
181 if (b && flag == InsetInclude::VERB) {
182 setCmdName("verbatiminput*");
183 flag = InsetInclude::VERBAST;
184 } else if (!b && flag == InsetInclude::VERBAST) {
185 setCmdName("verbatiminput");
186 flag = InsetInclude::VERB;