]> git.lyx.org Git - lyx.git/blob - src/insets/InsetInclude.h
Further cleanup of collapsable insets. The layouts are now properly read and applied.
[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         ///
100         static CommandInfo const * findInfo(std::string const &);
101         ///
102         static std::string defaultCommand() { return "include"; };
103         ///
104         static bool isCompatibleCommand(std::string const & s);
105 protected:
106         InsetInclude(InsetInclude const &);
107         ///
108         virtual void doDispatch(Cursor & cur, FuncRequest & cmd);
109 private:
110         virtual Inset * clone() const;
111
112         /** Slot receiving a signal that the external file has changed
113          *  and the preview should be regenerated.
114          */
115         void fileChanged() const;
116
117         /// set the parameters
118         void set(InsetCommandParams const & params, Buffer const &);
119         /// get the text displayed on the button
120         docstring const getScreenLabel(Buffer const &) const;
121         /// holds the entity name that defines the file location (SGML)
122         docstring const include_label;
123
124         /// The pointer never changes although *preview_'s contents may.
125         boost::scoped_ptr<RenderMonitoredPreview> const preview_;
126
127         /// cache
128         mutable bool set_label_;
129         mutable RenderButton button_;
130         mutable docstring listings_label_;
131 };
132
133
134 /// return loaded Buffer or zero if the file loading did not proceed.
135 Buffer * loadIfNeeded(Buffer const & parent, InsetCommandParams const & params);
136
137 } // namespace lyx
138
139 #endif // INSETINCLUDE_H