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 {
32 InsetInclude(): InsetCommand("include")
34 flag = InsetInclude::INCLUDE;
38 InsetInclude(string const &, Buffer *);
42 Inset * Clone() const;
44 Inset::Code LyxCode() const { return Inset::INCLUDE_CODE; }
45 /// This returns the list of labels on the child buffer
46 std::vector<string> getLabelList() const;
47 /// This returns the list of bibkeys on the child buffer
48 std::vector< std::pair<string,string> > getKeys() 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(Buffer const *, std::ostream &) const;
59 void Read(Buffer const *, LyXLex &);
61 int Latex(Buffer const *, std::ostream &, bool fragile, bool free_spc) const;
63 int Linuxdoc(Buffer const *, std::ostream &) const;
65 int DocBook(Buffer const *, std::ostream &) const;
67 void Validate(LaTeXFeatures &) const;
69 /** Input inserts anything inside a paragraph.
70 Display can give some visual feedback
74 string getScreenLabel() const;
76 void setContents(string const & c);
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 {
96 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;
134 mutable string include_label;
139 bool InsetInclude::isVerb() const
141 return flag == InsetInclude::VERB || flag == InsetInclude::VERBAST;
146 void InsetInclude::setInput()
149 flag = InsetInclude::INPUT;
156 void InsetInclude::setNoLoad(bool b)
163 void InsetInclude::setInclude()
166 flag = InsetInclude::INCLUDE;
167 setCmdName("include");
173 void InsetInclude::setVerb()
176 flag = InsetInclude::VERB;
177 setCmdName("verbatiminput");
183 void InsetInclude::setVisibleSpace(bool b)
185 if (b && flag == InsetInclude::VERB) {
186 setCmdName("verbatiminput*");
187 flag = InsetInclude::VERBAST;
188 } else if (!b && flag == InsetInclude::VERBAST) {
189 setCmdName("verbatiminput");
190 flag = InsetInclude::VERB;