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() const;
52 unsigned char Editable() const
56 /// With lyx3 we won't overload these 3 methods
57 void Write(ostream &);
61 int Latex(ostream &, signed char fragile);
63 int Latex(string & file, signed char fragile);
66 void Validate(LaTeXFeatures &) const;
68 /// Input inserts anything inside a paragraph, Display can give some visual feedback
69 bool display() const { return !(isInput()); }
71 string getScreenLabel() const;
73 void setContents(string const & c) {
74 InsetCommand::setContents(c);
75 filename = MakeAbsPath(contents,
76 OnlyPath(getMasterFilename()));
79 void setFilename(string const & n) { setContents(n); }
81 string getMasterFilename() const { return master->getFileName(); }
83 string getFileName() const {
86 /// In "input" mode uses \input instead of \include.
87 bool isInput() const { return flag == InsetInclude::INPUT; }
88 /// If this is true, the child file shouldn't be loaded by lyx
89 bool isNoLoad() const { return noload; }
91 /** A verbatim file shouldn't be loaded by LyX
92 * No need to generate LaTeX code of a verbatim file
96 bool isVerbVisibleSpace() const { return flag == InsetInclude::VERBAST;}
98 bool isInclude() const { return flag == InsetInclude::INCLUDE;}
102 void setNoLoad(bool);
108 void setVisibleSpace(bool b);
109 /// return true if the file is or got loaded.
110 bool loadIfNeeded() const;
136 bool InsetInclude::isVerb() const
138 return (bool)(flag == InsetInclude::VERB || flag == InsetInclude::VERBAST);
143 void InsetInclude::setInput()
146 flag = InsetInclude::INPUT;
153 void InsetInclude::setNoLoad(bool b)
160 void InsetInclude::setInclude()
163 flag = InsetInclude::INCLUDE;
164 setCmdName("include");
170 void InsetInclude::setVerb()
173 flag = InsetInclude::VERB;
174 setCmdName("verbatiminput");
180 void InsetInclude::setVisibleSpace(bool b)
182 if (b && flag == InsetInclude::VERB) {
183 setCmdName("verbatiminput*");
184 flag = InsetInclude::VERBAST;
185 } else if (!b && flag == InsetInclude::VERBAST) {
186 setCmdName("verbatiminput");
187 flag = InsetInclude::VERB;