]> git.lyx.org Git - lyx.git/blob - src/insets/insetinclude.h
Don't remove cell selections after fontchange.
[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         void edit(BufferView * bv, bool front = true);
83         ///
84         EDITABLE editable() const
85         {
86                 return IS_EDITABLE;
87         }
88         /// With lyx3 we won't overload these 3 methods
89         void write(Buffer const *, std::ostream &) const;
90         ///
91         void read(Buffer const *, LyXLex &);
92         ///
93         int latex(Buffer const *, std::ostream &,
94                   bool fragile, bool free_spc) const;
95         ///
96         int ascii(Buffer const *, std::ostream &, int linelen) const;
97         ///
98         int linuxdoc(Buffer const *, std::ostream &) const;
99         ///
100         int docbook(Buffer const *, std::ostream &) const;
101         ///
102         void validate(LaTeXFeatures &) const;
103         
104         /** Input inserts anything inside a paragraph.
105             Display can give some visual feedback
106         */
107         bool display() const;
108
109         /// return the filename stub of the included file 
110         string const getRelFileBaseName() const;
111  
112         /// return true if the included file is not loaded
113         bool isIncludeOnly() const;
114
115         /// return true if the file is or got loaded.
116         bool loadIfNeeded() const;
117  
118         /// hide a dialog if about 
119         SigC::Signal0<void> hideDialog;
120 private:
121         /// get the text displayed on the button
122         string const getScreenLabel(Buffer const *) const;
123         /// is this a verbatim include ?
124         bool isVerbatim() const;
125         /// get the filename of the master buffer
126         string const getMasterFilename() const;
127         /// get the included file name
128         string const getFileName() const;
129
130         /// the parameters
131         Params params_;
132         /// holds the entity name that defines the file location (SGML) 
133         string const include_label;
134 };
135
136
137 inline bool InsetInclude::isVerbatim() const
138 {
139         return params_.flag == VERB || params_.flag == VERBAST;
140 }
141
142
143 inline bool InsetInclude::isIncludeOnly() const
144 {
145         return params_.flag == INCLUDE && params_.noload;
146 }
147
148 #endif