]> git.lyx.org Git - lyx.git/blob - src/insets/InsetInclude.h
Pass XHTMLStream by reference. Problem found by coverity.
[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 "RenderButton.h"
19
20 #include <boost/scoped_ptr.hpp>
21
22 namespace lyx {
23
24 class BiblioInfo;
25 class Buffer;
26 class Dimension;
27 class InsetCommandParams;
28 class InsetLabel;
29 class LaTeXFeatures;
30 class RenderMonitoredPreview;
31
32 namespace support {
33         class FileNameList;
34 }
35
36 /// for including tex/lyx files
37 class InsetInclude : public InsetCommand {
38 public:
39         ///
40         InsetInclude(Buffer * buf, InsetCommandParams const &);
41         ///
42         ~InsetInclude();
43
44         ///
45         void setChildBuffer(Buffer * buffer);
46         /// \return the child buffer if the file is a LyX doc and could be loaded
47         Buffer * getChildBuffer() const;
48
49         /** Update the cache with all bibfiles in use of the child buffer
50          *  (including bibfiles of grandchild documents).
51          *  Does nothing if the child document is not loaded to prevent
52          *  automatic loading of all child documents upon loading the master.
53          *  \param buffer the Buffer containing this inset.
54          */
55         void updateBibfilesCache();
56
57         /** Return the cache with all bibfiles in use of the child buffer
58          *  (including bibfiles of grandchild documents).
59          *  Return an empty vector if the child doc is not loaded.
60          *  \param buffer the Buffer containing this inset.
61          */
62         support::FileNameList const &
63                 getBibfilesCache() const;
64
65         ///
66         void updateCommand();
67         ///
68         void write(std::ostream &) const;
69
70         /// \name Public functions inherited from Inset class
71         //@{
72         ///
73         void setBuffer(Buffer & buffer);
74         ///
75         bool isLabeled() const { return true; }
76         /// Override these InsetButton methods if Previewing
77         void metrics(MetricsInfo & mi, Dimension & dim) const;
78         ///
79         void draw(PainterInfo & pi, int x, int y) const;
80         ///
81         DisplayType display() const;
82         ///
83         InsetCode lyxCode() const { return INCLUDE_CODE; }
84         ///
85         docstring layoutName() const;
86         /** Fills \c key
87          *  \param keys the list of bibkeys in the child buffer.
88          *  \param it not used here
89          */
90         void collectBibKeys(InsetIterator const &) const;
91         ///
92         bool hasSettings() const { return true; }
93         ///
94         void latex(otexstream &, OutputParams const &) const;
95         ///
96         int plaintext(odocstringstream & ods, OutputParams const & op,
97                       size_t max_length = INT_MAX) const;
98         ///
99         int docbook(odocstream &, OutputParams const &) const;
100         ///
101         docstring xhtml(XHTMLStream &, OutputParams const &) const;
102         ///
103         void validate(LaTeXFeatures &) const;
104         ///
105         void addPreview(DocIterator const &, graphics::PreviewLoader &) const;
106         ///
107         void addToToc(DocIterator const & di, bool output_active) const;
108         ///
109         void updateBuffer(ParIterator const &, UpdateType);
110         ///
111         std::string contextMenuName() const;
112         //@}
113
114         /// \name Static public methods obligated for InsetCommand derived classes
115         //@{
116         ///
117         static ParamInfo const & findInfo(std::string const &);
118         ///
119         static std::string defaultCommand() { return "include"; }
120         ///
121         static bool isCompatibleCommand(std::string const & s);
122         //@}
123
124 protected:
125         ///
126         InsetInclude(InsetInclude const &);
127
128 private:
129         /** Slot receiving a signal that the external file has changed
130          *  and the preview should be regenerated.
131          */
132         void fileChanged() const;
133         /// \return loaded Buffer or zero if the file loading did not proceed.
134         Buffer * loadIfNeeded() const;
135         /// launch external application
136         void editIncluded(std::string const & file);
137         ///
138         bool isChildIncluded() const;
139
140         /// \name Private functions inherited from Inset class
141         //@{
142         Inset * clone() const { return new InsetInclude(*this); }
143         ///
144         void doDispatch(Cursor & cur, FuncRequest & cmd);
145         ///
146         bool getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus &) const;
147         //@}
148
149         /// \name Private functions inherited from InsetCommand class
150         //@{
151         /// set the parameters
152         // FIXME:InsetCommmand::setParams is not virtual
153         void setParams(InsetCommandParams const & params);
154         /// get the text displayed on the button
155         docstring screenLabel() const;
156         //@}    
157         
158         /// holds the entity name that defines the file location (SGML)
159         docstring const include_label;
160
161         /// The pointer never changes although *preview_'s contents may.
162         boost::scoped_ptr<RenderMonitoredPreview> const preview_;
163
164         /// 
165         mutable bool failedtoload_;
166         /// cache
167         mutable bool set_label_;
168         mutable RenderButton button_;
169         mutable docstring listings_label_;
170         InsetLabel * label_;
171         mutable Buffer * child_buffer_;
172 };
173
174
175 } // namespace lyx
176
177 #endif // INSET_INCLUDE_H