]> git.lyx.org Git - lyx.git/blob - src/insets/InsetInclude.h
Make members of FuncRequest private, per the FIXME there. Again, this is
[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(Buffer * buf, 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
54         ///
55         void setChildBuffer(Buffer * buffer);
56
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         void fillWithBibKeys(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();
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         support::FileNameList const &
77                 getBibfilesCache() const;
78         ///
79         bool hasSettings() const { return true; }
80         ///
81         int latex(odocstream &, OutputParams const &) const;
82         ///
83         int plaintext(odocstream &, OutputParams const &) const;
84         ///
85         int docbook(odocstream &, OutputParams const &) const;
86         ///
87         docstring xhtml(XHTMLStream &, OutputParams const &) const;
88         ///
89         void validate(LaTeXFeatures &) const;
90         ///
91         void addPreview(DocIterator const &, graphics::PreviewLoader &) const;
92         ///
93         void addToToc(DocIterator const &);
94         ///
95         void updateCommand();
96         ///
97         void updateBuffer(ParIterator const &, UpdateType);
98         ///
99         static ParamInfo const & findInfo(std::string const &);
100         ///
101         static std::string defaultCommand() { return "include"; }
102         ///
103         static bool isCompatibleCommand(std::string const & s);
104         ///
105         docstring contextMenu(BufferView const & bv, int x, int y) const;
106         /// \return the child buffer if the file is a LyX doc and could be loaded
107         Buffer * getChildBuffer() const;
108 protected:
109         InsetInclude(InsetInclude const &);
110         ///
111         void doDispatch(Cursor & cur, FuncRequest & cmd);
112         ///
113         bool getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus &) const;
114 private:
115         Inset * clone() const { return new InsetInclude(*this); }
116
117         /** Slot receiving a signal that the external file has changed
118          *  and the preview should be regenerated.
119          */
120         void fileChanged() const;
121
122         /// \return loaded Buffer or zero if the file loading did not proceed.
123         Buffer * loadIfNeeded() const;
124         /// launch external application
125         void editIncluded(std::string const & file);
126         /// set the parameters
127         void setParams(InsetCommandParams const & params);
128         /// get the text displayed on the button
129         docstring screenLabel() const;
130         /// holds the entity name that defines the file location (SGML)
131         docstring const include_label;
132         ///
133         bool isChildIncluded() const;
134
135         /// The pointer never changes although *preview_'s contents may.
136         boost::scoped_ptr<RenderMonitoredPreview> const preview_;
137
138         /// 
139         mutable bool failedtoload_;
140         /// cache
141         mutable bool set_label_;
142         mutable RenderButton button_;
143         mutable docstring listings_label_;
144         InsetLabel * label_;
145         mutable Buffer * child_buffer_;
146 };
147
148
149 } // namespace lyx
150
151 #endif // INSET_INCLUDE_H