]> git.lyx.org Git - lyx.git/blob - src/insets/insetinclude.h
remove cruft
[lyx.git] / src / insets / insetinclude.h
1 // -*- C++ -*-
2 /* This file is part of*
3  * ======================================================
4  *
5  *           LyX, The Document Processor
6  *       
7  *          Copyright 1997 LyX Team (this file was created this year)
8  * 
9  * ====================================================== */
10
11 #ifndef INSET_INCLUDE_H
12 #define INSET_INCLUDE_H
13
14 #ifdef __GNUG__
15 #pragma interface
16 #endif
17
18 #include "insetcommand.h"
19
20 class Buffer;
21 struct LaTeXFeatures;
22
23 // Created by AAS 970521
24
25 /**  Used to include files
26  */
27 class InsetInclude: public InsetCommand {
28 public:
29         ///
30         InsetInclude(InsetCommandParams const &, Buffer const &);
31         ///
32         ~InsetInclude();
33         ///
34         Inset * Clone(Buffer const &) const;
35         ///
36         Inset::Code LyxCode() const { return Inset::INCLUDE_CODE; }
37         /// This returns the list of labels on the child buffer
38         std::vector<string> const getLabelList() const;
39         /// This returns the list of bibkeys on the child buffer
40         std::vector< std::pair<string,string> > const getKeys() const;
41         ///
42         void Edit(BufferView *, int x, int y, unsigned int button);
43         ///
44         EDITABLE Editable() const
45         {
46                 return IS_EDITABLE;
47         }
48         /// With lyx3 we won't overload these 3 methods
49         void Write(Buffer const *, std::ostream &) const;
50         ///
51         void Read(Buffer const *, LyXLex &);
52         /// 
53         int Latex(Buffer const *, std::ostream &, bool fragile, bool free_spc) const;
54         ///
55         int Ascii(Buffer const *, std::ostream &, int linelen) const;
56         ///
57         int Linuxdoc(Buffer const *, std::ostream &) const;
58         ///
59         int DocBook(Buffer const *, std::ostream &) const;
60         ///
61         void Validate(LaTeXFeatures &) const;
62         
63         /** Input inserts anything inside a paragraph.
64             Display can give some visual feedback
65         */
66         bool display() const;
67         ///
68         string const getScreenLabel() const;
69         ///
70         string const getMasterFilename() const;
71         ///
72         string const getFileName() const;
73
74         ///  In "input" mode uses \input instead of \include.
75         bool isInput() const { return flag == InsetInclude::INPUT; }
76         ///  If this is true, the child file shouldn't be loaded by lyx
77         bool isNoLoad() const { return noload; }
78
79         /**  A verbatim file shouldn't be loaded by LyX
80          *  No need to generate LaTeX code of a verbatim file
81          */ 
82         bool isVerb() const;
83         ///
84         bool isVerbVisibleSpace() const {
85                 return flag == InsetInclude::VERBAST;
86         }
87         ///  
88         bool isInclude() const { return flag == InsetInclude::INCLUDE;}
89         ///  
90         void setInput();
91         ///  
92         void setNoLoad(bool);
93         ///  
94         void setInclude();
95         ///  
96         void setVerb();
97         ///
98         void setVisibleSpace(bool b);
99         /// return true if the file is or got loaded.
100         bool loadIfNeeded() const;
101 private:
102         ///
103         enum Include_Flags {
104                 ///
105                 INCLUDE= 0,
106                 ///
107                 VERB = 1,
108                 ///
109                 INPUT = 2,
110                 ///
111                 VERBAST = 3
112         };
113         
114         ///
115         bool noload;
116         ///
117         int flag;
118         ///
119         Buffer const * master;
120         ///
121         string include_label;
122 };
123
124
125 inline 
126 bool InsetInclude::isVerb() const
127 {
128         return flag == InsetInclude::VERB || flag == InsetInclude::VERBAST; 
129 }
130
131
132 inline
133 void InsetInclude::setInput()
134 {
135         if (!isInput()) {
136             flag = InsetInclude::INPUT;
137             setCmdName("input");
138         }
139 }
140
141
142 inline
143 void InsetInclude::setNoLoad(bool b)
144
145                 noload = b;
146 }
147
148
149 inline
150 void InsetInclude::setInclude()
151 {
152         if (!isInclude()) {
153             flag = InsetInclude::INCLUDE;
154             setCmdName("include");
155         }
156 }
157
158
159 inline
160 void InsetInclude::setVerb()
161
162         if (!isVerb()) {
163             flag = InsetInclude::VERB;
164             setCmdName("verbatiminput");
165         }
166 }
167
168
169 inline
170 void InsetInclude::setVisibleSpace(bool b)
171 {
172         if (b && flag == InsetInclude::VERB) {
173             setCmdName("verbatiminput*");
174             flag = InsetInclude::VERBAST;
175         } else if (!b && flag == InsetInclude::VERBAST) {
176             setCmdName("verbatiminput");
177             flag = InsetInclude::VERB;
178         }
179 }
180 #endif