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