]> git.lyx.org Git - lyx.git/blob - src/insets/insetinclude.h
Added various inset functions for Jean-Marc (see Changelog). Small fix in
[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 InsetButton, boost::noncopyable {
28 public:
29         /// the type of inclusion
30         enum Flags {
31                 ///
32                 INCLUDE = 0,
33                 ///
34                 VERB = 1,
35                 ///
36                 INPUT = 2,
37                 ///
38                 VERBAST = 3
39         };
40
41         struct Params {
42                 Params(InsetCommandParams const & cp = InsetCommandParams(),
43                        Flags f = INCLUDE,
44                        bool nl = false,
45                        string const & name = string())
46                         : cparams(cp), flag(f), noload(nl),
47                           masterFilename_(name) {}
48                 InsetCommandParams cparams;
49                 Flags flag;
50                 bool noload;
51                 string masterFilename_;
52
53                 ///
54                 bool operator==(Params const &) const;
55                 ///
56                 bool operator!=(Params const &) const;
57         };
58
59         ///
60         InsetInclude(Params const &);
61         ///
62         InsetInclude(InsetCommandParams const &, Buffer const &);
63         ///
64         ~InsetInclude();
65
66         /// get the parameters
67         Params const & params(void) const;
68         /// set the parameters
69         void set(Params const & params);
70
71         ///
72         virtual Inset * clone(Buffer const &, bool same_id = false) const;
73         ///
74         Inset::Code lyxCode() const { return Inset::INCLUDE_CODE; }
75         /// This returns the list of labels on the child buffer
76         std::vector<string> const getLabelList() const;
77         /// This returns the list of bibkeys on the child buffer
78         std::vector< std::pair<string,string> > const getKeys() const;
79         ///
80         void edit(BufferView *, int x, int y, unsigned int button);
81         ///
82         EDITABLE editable() const
83         {
84                 return IS_EDITABLE;
85         }
86         /// With lyx3 we won't overload these 3 methods
87         void write(Buffer const *, std::ostream &) const;
88         ///
89         void read(Buffer const *, LyXLex &);
90         ///
91         int latex(Buffer const *, std::ostream &,
92                   bool fragile, bool free_spc) const;
93         ///
94         int ascii(Buffer const *, std::ostream &, int linelen) const;
95         ///
96         int linuxdoc(Buffer const *, std::ostream &) const;
97         ///
98         int docBook(Buffer const *, std::ostream &) const;
99         ///
100         void validate(LaTeXFeatures &) const;
101         
102         /** Input inserts anything inside a paragraph.
103             Display can give some visual feedback
104         */
105         bool display() const;
106
107         /// return the filename stub of the included file 
108         string const getRelFileBaseName() const;
109  
110         /// return true if the included file is not loaded
111         bool isIncludeOnly() const;
112
113         /// return true if the file is or got loaded.
114         bool loadIfNeeded() const;
115  
116         /// hide a dialog if about 
117         SigC::Signal0<void> hideDialog;
118 private:
119         /// get the text displayed on the button
120         string const getScreenLabel() const;
121         /// is this a verbatim include ?
122         bool isVerbatim() const;
123         /// get the filename of the master buffer
124         string const getMasterFilename() const;
125         /// get the included file name
126         string const getFileName() const;
127
128         /// the parameters
129         Params params_;
130         ///
131         string include_label;
132 };
133
134
135 inline bool InsetInclude::isVerbatim() const
136 {
137         return params_.flag == VERB || params_.flag == VERBAST;
138 }
139
140
141 inline bool InsetInclude::isIncludeOnly() const
142 {
143         return params_.flag == INCLUDE && params_.noload;
144 }
145
146 #endif