2 /* This file is part of*
3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright (C) 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 unsigned char Editable() const
56 /// With lyx3 we won't overload these 3 methods
57 void Write(ostream &) const;
61 int Latex(ostream &, signed char fragile) const;
62 #ifndef USE_OSTREAM_ONLY
64 int Latex(string & file, signed char fragile) const;
67 void Validate(LaTeXFeatures &) const;
69 /// Input inserts anything inside a paragraph, Display can give some visual feedback
70 bool display() const { return !(isInput()); }
72 string getScreenLabel() const;
74 void setContents(string const & c) {
75 InsetCommand::setContents(c);
76 filename = MakeAbsPath(contents,
77 OnlyPath(getMasterFilename()));
80 void setFilename(string const & n) { setContents(n); }
82 string getMasterFilename() const { return master->fileName(); }
84 string getFileName() const {
87 /// In "input" mode uses \input instead of \include.
88 bool isInput() const { return flag == InsetInclude::INPUT; }
89 /// If this is true, the child file shouldn't be loaded by lyx
90 bool isNoLoad() const { return noload; }
92 /** A verbatim file shouldn't be loaded by LyX
93 * No need to generate LaTeX code of a verbatim file
97 bool isVerbVisibleSpace() const { return flag == InsetInclude::VERBAST;}
99 bool isInclude() const { return flag == InsetInclude::INCLUDE;}
103 void setNoLoad(bool);
109 void setVisibleSpace(bool b);
110 /// return true if the file is or got loaded.
111 bool loadIfNeeded() const;
137 bool InsetInclude::isVerb() const
139 return flag == InsetInclude::VERB || flag == InsetInclude::VERBAST;
144 void InsetInclude::setInput()
147 flag = InsetInclude::INPUT;
154 void InsetInclude::setNoLoad(bool b)
161 void InsetInclude::setInclude()
164 flag = InsetInclude::INCLUDE;
165 setCmdName("include");
171 void InsetInclude::setVerb()
174 flag = InsetInclude::VERB;
175 setCmdName("verbatiminput");
181 void InsetInclude::setVisibleSpace(bool b)
183 if (b && flag == InsetInclude::VERB) {
184 setCmdName("verbatiminput*");
185 flag = InsetInclude::VERBAST;
186 } else if (!b && flag == InsetInclude::VERBAST) {
187 setCmdName("verbatiminput");
188 flag = InsetInclude::VERB;