]> git.lyx.org Git - lyx.git/blob - src/insets/insetinclude.h
prepare for 1.1.6pre2
[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 Linuxdoc(Buffer const *, std::ostream &) const;
56         ///
57         int DocBook(Buffer const *, std::ostream &) const;
58         ///
59         void Validate(LaTeXFeatures &) const;
60         
61         /** Input inserts anything inside a paragraph.
62             Display can give some visual feedback
63         */
64         bool display() const;
65         ///
66         string const getScreenLabel() const;
67         ///
68         string const getMasterFilename() const;
69         ///
70         string const getFileName() const;
71
72         ///  In "input" mode uses \input instead of \include.
73         bool isInput() const { return flag == InsetInclude::INPUT; }
74         ///  If this is true, the child file shouldn't be loaded by lyx
75         bool isNoLoad() const { return noload; }
76
77         /**  A verbatim file shouldn't be loaded by LyX
78          *  No need to generate LaTeX code of a verbatim file
79          */ 
80         bool isVerb() const;
81         ///
82         bool isVerbVisibleSpace() const {
83                 return flag == InsetInclude::VERBAST;
84         }
85         ///  
86         bool isInclude() const { return flag == InsetInclude::INCLUDE;}
87         ///  
88         void setInput();
89         ///  
90         void setNoLoad(bool);
91         ///  
92         void setInclude();
93         ///  
94         void setVerb();
95         ///
96         void setVisibleSpace(bool b);
97         /// return true if the file is or got loaded.
98         bool loadIfNeeded() const;
99 private:
100         ///
101         enum Include_Flags {
102                 ///
103                 INCLUDE= 0,
104                 ///
105                 VERB = 1,
106                 ///
107                 INPUT = 2,
108                 ///
109                 VERBAST = 3
110         };
111         
112         ///
113         bool noload;
114         ///
115         int flag;
116         ///
117         Buffer const * master;
118         ///
119         string include_label;
120 };
121
122
123 inline 
124 bool InsetInclude::isVerb() const
125 {
126         return flag == InsetInclude::VERB || flag == InsetInclude::VERBAST; 
127 }
128
129
130 inline
131 void InsetInclude::setInput()
132 {
133         if (!isInput()) {
134             flag = InsetInclude::INPUT;
135             setCmdName("input");
136         }
137 }
138
139
140 inline
141 void InsetInclude::setNoLoad(bool b)
142
143                 noload = b;
144 }
145
146
147 inline
148 void InsetInclude::setInclude()
149 {
150         if (!isInclude()) {
151             flag = InsetInclude::INCLUDE;
152             setCmdName("include");
153         }
154 }
155
156
157 inline
158 void InsetInclude::setVerb()
159
160         if (!isVerb()) {
161             flag = InsetInclude::VERB;
162             setCmdName("verbatiminput");
163         }
164 }
165
166
167 inline
168 void InsetInclude::setVisibleSpace(bool b)
169 {
170         if (b && flag == InsetInclude::VERB) {
171             setCmdName("verbatiminput*");
172             flag = InsetInclude::VERBAST;
173         } else if (!b && flag == InsetInclude::VERBAST) {
174             setCmdName("verbatiminput");
175             flag = InsetInclude::VERB;
176         }
177 }
178 #endif