]> git.lyx.org Git - lyx.git/blob - src/insets/insetinclude.h
fix compilation pb ; update eu.po
[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         Inset * Clone(Buffer const &) 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 &, bool fragile, bool free_spc) const;
92         ///
93         int Ascii(Buffer const *, std::ostream &, int linelen) const;
94         ///
95         int Linuxdoc(Buffer const *, std::ostream &) const;
96         ///
97         int DocBook(Buffer const *, std::ostream &) const;
98         ///
99         void Validate(LaTeXFeatures &) const;
100         
101         /** Input inserts anything inside a paragraph.
102             Display can give some visual feedback
103         */
104         bool display() const;
105
106         /// return the filename stub of the included file 
107         string const getRelFileBaseName() const;
108  
109         /// return true if the included file is not loaded
110         bool isIncludeOnly() const;
111
112         /// return true if the file is or got loaded.
113         bool loadIfNeeded() const;
114  
115         /// hide a dialog if about 
116         SigC::Signal0<void> hideDialog;
117 private:
118         /// get the text displayed on the button
119         string const getScreenLabel() const;
120         /// is this a verbatim include ?
121         bool isVerbatim() const;
122         /// get the filename of the master buffer
123         string const getMasterFilename() const;
124         /// get the included file name
125         string const getFileName() const;
126
127         /// the parameters
128         Params params_;
129         ///
130         string include_label;
131 };
132
133
134 inline bool InsetInclude::isVerbatim() const
135 {
136         return params_.flag == VERB || params_.flag == VERBAST;
137 }
138
139
140 inline bool InsetInclude::isIncludeOnly() const
141 {
142         return params_.flag == INCLUDE && params_.noload;
143 }
144
145 #endif