]> git.lyx.org Git - lyx.git/blob - src/insets/InsetInclude.h
Move disabling LFUNS from ERT to Collapsable
[lyx.git] / src / insets / InsetInclude.h
1 // -*- C++ -*-
2 /**
3  * \file InsetInclude.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Lars Gullik Bjønnes
8  * \author Richard Heck (conversion to InsetCommand)
9  *
10  * Full author contact details are available in file CREDITS.
11  */
12
13 #ifndef INSET_INCLUDE_H
14 #define INSET_INCLUDE_H
15
16 #include "BiblioInfo.h"
17 #include "InsetCommand.h"
18 #include "InsetCommandParams.h"
19 #include "RenderButton.h"
20 #include "MailInset.h"
21 #include "Counters.h"
22 #include "EmbeddedFiles.h"
23
24 #include "support/FileName.h"
25
26 #include <boost/scoped_ptr.hpp>
27
28 namespace lyx {
29
30 class Buffer;
31 class Dimension;
32 class LaTeXFeatures;
33 class RenderMonitoredPreview;
34
35
36 /// for including tex/lyx files
37 class InsetInclude : public InsetCommand {
38 public:
39         ///
40         InsetInclude(InsetCommandParams const &);
41
42         /// Override these InsetButton methods if Previewing
43         void metrics(MetricsInfo & mi, Dimension & dim) const;
44         ///
45         void draw(PainterInfo & pi, int x, int y) const;
46         ///
47         virtual DisplayType display() const;
48         ///
49         InsetCode lyxCode() const { return INCLUDE_CODE; }
50         /** Fills \c list
51          *  \param buffer the Buffer containing this inset.
52          *  \param list the list of labels in the child buffer.
53          */
54         void getLabelList(Buffer const & buffer,
55                           std::vector<docstring> & list) const;
56         /** Fills \c keys
57          *  \param buffer the Buffer containing this inset.
58          *  \param keys the list of bibkeys in the child buffer.
59          *  \param it not used here
60          */
61         virtual void fillWithBibKeys(Buffer const & buffer,
62                 BiblioInfo & keys, InsetIterator const & it) const;
63         
64         /** Update the cache with all bibfiles in use of the child buffer
65          *  (including bibfiles of grandchild documents).
66          *  Does nothing if the child document is not loaded to prevent
67          *  automatic loading of all child documents upon loading the master.
68          *  \param buffer the Buffer containing this inset.
69          */
70         void updateBibfilesCache(Buffer const & buffer);
71         /** Return the cache with all bibfiles in use of the child buffer
72          *  (including bibfiles of grandchild documents).
73          *  Return an empty vector if the child doc is not loaded.
74          *  \param buffer the Buffer containing this inset.
75          */
76         std::vector<support::FileName> const &
77                 getBibfilesCache(Buffer const & buffer) const;
78         ///
79         EDITABLE editable() const { return IS_EDITABLE; }
80         ///
81         int latex(Buffer const &, odocstream &,
82                   OutputParams const &) const;
83         ///
84         int plaintext(Buffer const &, odocstream &,
85                       OutputParams const &) const;
86         ///
87         int docbook(Buffer const &, odocstream &,
88                     OutputParams const &) const;
89         ///
90         void validate(LaTeXFeatures &) const;
91         ///
92         void addPreview(graphics::PreviewLoader &) const;
93         ///
94         void addToToc(TocList &, Buffer const &, ParConstIterator const &) const;
95         ///
96         void updateLabels(Buffer const & buffer, ParIterator const &);
97         /// child document can be embedded
98         void registerEmbeddedFiles(Buffer const &, EmbeddedFiles &) const;
99 protected:
100         InsetInclude(InsetInclude const &);
101         ///
102         virtual void doDispatch(Cursor & cur, FuncRequest & cmd);
103 private:
104         virtual Inset * clone() const;
105
106         /** Slot receiving a signal that the external file has changed
107          *  and the preview should be regenerated.
108          */
109         void fileChanged() const;
110
111         /// set the parameters
112         void set(InsetCommandParams const & params, Buffer const &);
113         /// get the text displayed on the button
114         docstring const getScreenLabel(Buffer const &) const;
115         /// holds the entity name that defines the file location (SGML)
116         docstring const include_label;
117
118         /// The pointer never changes although *preview_'s contents may.
119         boost::scoped_ptr<RenderMonitoredPreview> const preview_;
120
121         /// cache
122         mutable bool set_label_;
123         mutable RenderButton button_;
124         mutable docstring listings_label_;
125 };
126
127
128 /// return loaded Buffer or zero if the file loading did not proceed.
129 Buffer * loadIfNeeded(Buffer const & parent, InsetCommandParams const & params);
130
131 } // namespace lyx
132
133 #endif // INSETINCLUDE_H