4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Lars Gullik Bjønnes
9 * Full author contact details are available in file CREDITS.
12 #ifndef INSET_INCLUDE_H
13 #define INSET_INCLUDE_H
15 #include "BiblioInfo.h"
16 #include "InsetCommand.h"
17 #include "InsetCommandParams.h"
18 #include "RenderButton.h"
19 #include "MailInset.h"
21 #include "EmbeddedFiles.h"
23 #include "support/FileName.h"
25 #include <boost/scoped_ptr.hpp>
32 class RenderMonitoredPreview;
35 /// for including tex/lyx files
36 class InsetInclude : public InsetCommand {
39 InsetInclude(InsetCommandParams const &);
41 /// Override these InsetButton methods if Previewing
42 void metrics(MetricsInfo & mi, Dimension & dim) const;
44 void draw(PainterInfo & pi, int x, int y) const;
46 virtual DisplayType display() const;
48 InsetCode lyxCode() const { return INCLUDE_CODE; }
50 * \param buffer the Buffer containing this inset.
51 * \param list the list of labels in the child buffer.
53 void getLabelList(Buffer const & buffer,
54 std::vector<docstring> & list) const;
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
60 virtual void fillWithBibKeys(Buffer const & buffer,
61 BiblioInfo & keys, InsetIterator const & it) const;
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.
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.
75 std::vector<support::FileName> const &
76 getBibfilesCache(Buffer const & buffer) const;
78 EDITABLE editable() const { return IS_EDITABLE; }
80 int latex(Buffer const &, odocstream &,
81 OutputParams const &) const;
83 int plaintext(Buffer const &, odocstream &,
84 OutputParams const &) const;
86 int docbook(Buffer const &, odocstream &,
87 OutputParams const &) const;
89 void validate(LaTeXFeatures &) const;
91 void addPreview(graphics::PreviewLoader &) const;
93 void addToToc(TocList &, Buffer const &, ParConstIterator const &) const;
95 void updateLabels(Buffer const & buffer, ParIterator const &);
96 /// child document can be embedded
97 void registerEmbeddedFiles(Buffer const &, EmbeddedFiles &) const;
99 InsetInclude(InsetInclude const &);
101 virtual void doDispatch(Cursor & cur, FuncRequest & cmd);
103 virtual Inset * clone() const;
105 /** Slot receiving a signal that the external file has changed
106 * and the preview should be regenerated.
108 void fileChanged() const;
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;
117 /// The pointer never changes although *preview_'s contents may.
118 boost::scoped_ptr<RenderMonitoredPreview> const preview_;
121 mutable bool set_label_;
122 mutable RenderButton button_;
123 mutable docstring listings_label_;
127 /// return loaded Buffer or zero if the file loading did not proceed.
128 Buffer * loadIfNeeded(Buffer const & parent, InsetCommandParams const & params);
132 #endif // INSETINCLUDE_H