]> git.lyx.org Git - features.git/blob - src/insets/InsetInclude.h
* Lazy MathData to avoid unneeded interpretation of macro definitions
[features.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 <boost/scoped_ptr.hpp>
25
26 namespace lyx {
27
28 class Buffer;
29 class Dimension;
30 class LaTeXFeatures;
31 class RenderMonitoredPreview;
32
33 namespace support {
34 class FileNameList;
35 }
36
37 /// for including tex/lyx files
38 class InsetInclude : public InsetCommand {
39 public:
40         ///
41         InsetInclude(InsetCommandParams const &);
42
43         /// Override these InsetButton methods if Previewing
44         void metrics(MetricsInfo & mi, Dimension & dim) const;
45         ///
46         void draw(PainterInfo & pi, int x, int y) const;
47         ///
48         virtual DisplayType display() const;
49         ///
50         InsetCode lyxCode() const { return INCLUDE_CODE; }
51         /** Fills \c list
52          *  \param buffer the Buffer containing this inset.
53          *  \param list the list of labels in the child buffer.
54          */
55         void getLabelList(Buffer const & buffer,
56                           std::vector<docstring> & list) const;
57         /** Fills \c keys
58          *  \param buffer the Buffer containing this inset.
59          *  \param keys the list of bibkeys in the child buffer.
60          *  \param it not used here
61          */
62         virtual void fillWithBibKeys(Buffer const & buffer,
63                 BiblioInfo & keys, InsetIterator const & it) const;
64         
65         /** Update the cache with all bibfiles in use of the child buffer
66          *  (including bibfiles of grandchild documents).
67          *  Does nothing if the child document is not loaded to prevent
68          *  automatic loading of all child documents upon loading the master.
69          *  \param buffer the Buffer containing this inset.
70          */
71         void updateBibfilesCache(Buffer const & buffer);
72         /** Return the cache with all bibfiles in use of the child buffer
73          *  (including bibfiles of grandchild documents).
74          *  Return an empty vector if the child doc is not loaded.
75          *  \param buffer the Buffer containing this inset.
76          */
77         support::FileNameList const &
78                 getBibfilesCache(Buffer const & buffer) const;
79         ///
80         EDITABLE editable() const { return IS_EDITABLE; }
81         ///
82         int latex(Buffer const &, odocstream &,
83                   OutputParams const &) const;
84         ///
85         int plaintext(Buffer const &, odocstream &,
86                       OutputParams const &) const;
87         ///
88         int docbook(Buffer const &, odocstream &,
89                     OutputParams const &) const;
90         ///
91         void validate(LaTeXFeatures &) const;
92         ///
93         void addPreview(graphics::PreviewLoader &) const;
94         ///
95         void addToToc(TocList &, Buffer const &, ParConstIterator const &) const;
96         ///
97         void updateLabels(Buffer const & buffer, ParIterator const &);
98         /// child document can be embedded
99         void registerEmbeddedFiles(Buffer const &, EmbeddedFiles &) const;
100         ///
101         static CommandInfo const * findInfo(std::string const &);
102         ///
103         static std::string defaultCommand() { return "include"; };
104         ///
105         static bool isCompatibleCommand(std::string const & s);
106 protected:
107         InsetInclude(InsetInclude const &);
108         ///
109         virtual void doDispatch(Cursor & cur, FuncRequest & cmd);
110 private:
111         virtual Inset * clone() const;
112
113         /** Slot receiving a signal that the external file has changed
114          *  and the preview should be regenerated.
115          */
116         void fileChanged() const;
117
118         /// set the parameters
119         void set(InsetCommandParams const & params, Buffer const &);
120         /// get the text displayed on the button
121         docstring const getScreenLabel(Buffer const &) const;
122         /// holds the entity name that defines the file location (SGML)
123         docstring const include_label;
124
125         /// The pointer never changes although *preview_'s contents may.
126         boost::scoped_ptr<RenderMonitoredPreview> const preview_;
127
128         /// cache
129         mutable bool set_label_;
130         mutable RenderButton button_;
131         mutable docstring listings_label_;
132 };
133
134 /// return the child buffer if the file is a LyX doc and is loaded
135 Buffer * getChildBuffer(Buffer const & buffer, InsetCommandParams const & params);
136         
137 /// return loaded Buffer or zero if the file loading did not proceed.
138 Buffer * loadIfNeeded(Buffer const & parent, InsetCommandParams const & params);
139
140 ///
141 void resetParentBuffer(Buffer const * parent, InsetCommandParams const & params,
142         bool close_it);
143
144 } // namespace lyx
145
146 #endif // INSETINCLUDE_H