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(ostream &) const;
61 int Latex(ostream &, signed char fragile, bool free_spc) const;
63 void Validate(LaTeXFeatures &) const;
65 /// Input inserts anything inside a paragraph, Display can give some visual feedback
66 bool display() const { return !(isInput()); }
68 string getScreenLabel() const;
70 void setContents(string const & c) {
71 InsetCommand::setContents(c);
72 filename = MakeAbsPath(contents,
73 OnlyPath(getMasterFilename()));
76 void setFilename(string const & n) { setContents(n); }
78 string getMasterFilename() const { return master->fileName(); }
80 string getFileName() const {
83 /// In "input" mode uses \input instead of \include.
84 bool isInput() const { return flag == InsetInclude::INPUT; }
85 /// If this is true, the child file shouldn't be loaded by lyx
86 bool isNoLoad() const { return noload; }
88 /** A verbatim file shouldn't be loaded by LyX
89 * No need to generate LaTeX code of a verbatim file
93 bool isVerbVisibleSpace() const { return flag == InsetInclude::VERBAST;}
95 bool isInclude() const { return flag == InsetInclude::INCLUDE;}
105 void setVisibleSpace(bool b);
106 /// return true if the file is or got loaded.
107 bool loadIfNeeded() const;
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;