]> git.lyx.org Git - lyx.git/blob - src/insets/InsetInclude.h
Remove all BufferParam arguments in InsetXXX methods (since insets know about their...
[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 "InsetCommand.h"
17
18 #include "BiblioInfo.h"
19 #include "Counters.h"
20 #include "InsetCommandParams.h"
21 #include "RenderButton.h"
22
23 #include "support/FileNameList.h"
24
25 #include <boost/scoped_ptr.hpp>
26
27 namespace lyx {
28
29 class Buffer;
30 class Dimension;
31 class InsetLabel;
32 class LaTeXFeatures;
33 class RenderMonitoredPreview;
34
35 /// for including tex/lyx files
36 class InsetInclude : public InsetCommand {
37 public:
38         ///
39         InsetInclude(InsetCommandParams const &);
40         ~InsetInclude();
41
42         void setBuffer(Buffer & buffer);
43         bool isLabeled() const { return true; }
44
45         /// Override these InsetButton methods if Previewing
46         void metrics(MetricsInfo & mi, Dimension & dim) const;
47         ///
48         void draw(PainterInfo & pi, int x, int y) const;
49         ///
50         DisplayType display() const;
51         ///
52         InsetCode lyxCode() const { return INCLUDE_CODE; }
53         /** Fills \c keys
54          *  \param buffer the Buffer containing this inset.
55          *  \param keys the list of bibkeys in the child buffer.
56          *  \param it not used here
57          */
58         void fillWithBibKeys(BiblioInfo & keys, InsetIterator const & it) const;
59         
60         /** Update the cache with all bibfiles in use of the child buffer
61          *  (including bibfiles of grandchild documents).
62          *  Does nothing if the child document is not loaded to prevent
63          *  automatic loading of all child documents upon loading the master.
64          *  \param buffer the Buffer containing this inset.
65          */
66         void updateBibfilesCache();
67         /** Return the cache with all bibfiles in use of the child buffer
68          *  (including bibfiles of grandchild documents).
69          *  Return an empty vector if the child doc is not loaded.
70          *  \param buffer the Buffer containing this inset.
71          */
72         support::FileNameList const &
73                 getBibfilesCache() const;
74         ///
75         bool hasSettings() const { return true; }
76         ///
77         int latex(odocstream &, OutputParams const &) const;
78         ///
79         int plaintext(odocstream &, OutputParams const &) const;
80         ///
81         int docbook(odocstream &, OutputParams const &) const;
82         ///
83         docstring xhtml(odocstream &, OutputParams const &) const;
84         ///
85         void validate(LaTeXFeatures &) const;
86         ///
87         void addPreview(graphics::PreviewLoader &) const;
88         ///
89         void addToToc(DocIterator const &);
90         ///
91         void updateCommand();
92         ///
93         void updateLabels(ParIterator const &);
94         ///
95         static ParamInfo const & findInfo(std::string const &);
96         ///
97         static std::string defaultCommand() { return "include"; }
98         ///
99         static bool isCompatibleCommand(std::string const & s);
100         ///
101         docstring contextMenu(BufferView const & bv, int x, int y) const;
102         /// \return the child buffer if the file is a LyX doc and could be loaded
103         Buffer * getChildBuffer() const;
104 protected:
105         InsetInclude(InsetInclude const &);
106         ///
107         void doDispatch(Cursor & cur, FuncRequest & cmd);
108         ///
109         bool getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus &) const;
110 private:
111         Inset * clone() const { return new InsetInclude(*this); }
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         /// \return loaded Buffer or zero if the file loading did not proceed.
119         Buffer * loadIfNeeded() const;
120         /// launch external application
121         void editIncluded(std::string const & file);
122         /// set the parameters
123         void setParams(InsetCommandParams const & params);
124         /// get the text displayed on the button
125         docstring screenLabel() const;
126         /// holds the entity name that defines the file location (SGML)
127         docstring const include_label;
128
129         /// The pointer never changes although *preview_'s contents may.
130         boost::scoped_ptr<RenderMonitoredPreview> const preview_;
131
132         /// 
133         mutable bool failedtoload_;
134         /// cache
135         mutable bool set_label_;
136         mutable RenderButton button_;
137         mutable docstring listings_label_;
138         InsetLabel * label_;
139         mutable Buffer * child_buffer_;
140 };
141
142
143 } // namespace lyx
144
145 #endif // INSET_INCLUDE_H