]> git.lyx.org Git - lyx.git/blob - src/insets/insetinclude.h
drop linuxdoc support (part 1)
[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 "inset.h"
16 #include "insetcommandparams.h"
17 #include "render_button.h"
18 #include <boost/scoped_ptr.hpp>
19
20 class Buffer;
21 class Dimension;
22 class LaTeXFeatures;
23 class RenderMonitoredPreview;
24
25
26 /// for including tex/lyx files
27 class InsetInclude: public InsetOld {
28 public:
29         ///
30         InsetInclude(InsetCommandParams const &);
31         ~InsetInclude();
32
33         /// Override these InsetButton methods if Previewing
34         void metrics(MetricsInfo & mi, Dimension & dim) const;
35         ///
36         void draw(PainterInfo & pi, int x, int y) const;
37         ///
38         virtual bool display() const;
39
40         /// get the parameters
41         InsetCommandParams const & params(void) const;
42
43         ///
44         InsetBase::Code lyxCode() const { return InsetBase::INCLUDE_CODE; }
45         /** Fills \c list
46          *  \param buffer the Buffer containing this inset.
47          *  \param list the list of labels in the child buffer.
48          */
49         void getLabelList(Buffer const & buffer,
50                           std::vector<std::string> & list) const;
51         /** Fills \c keys
52          *  \param buffer the Buffer containing this inset.
53          *  \param keys the list of bibkeys in the child buffer.
54          */
55         void fillWithBibKeys(Buffer const & buffer,
56                 std::vector<std::pair<std::string,std::string> > & keys) const;
57         /** Update the cache with all bibfiles in use of the child buffer
58          *  (including bibfiles of grandchild documents).
59          *  Does nothing if the child document is not loaded to prevent
60          *  automatic loading of all child documents upon loading the master.
61          *  \param buffer the Buffer containing this inset.
62          */
63         void updateBibfilesCache(Buffer const & buffer);
64         /** Return the cache with all bibfiles in use of the child buffer
65          *  (including bibfiles of grandchild documents).
66          *  Return an empty vector if the child doc is not loaded.
67          *  \param buffer the Buffer containing this inset.
68          */
69         std::vector<std::string> const &
70         getBibfilesCache(Buffer const & buffer) const;
71         ///
72         EDITABLE editable() const { return IS_EDITABLE; }
73         ///
74         void write(Buffer const &, std::ostream &) const;
75         ///
76         void read(Buffer const &, LyXLex &);
77         ///
78         int latex(Buffer const &, std::ostream &,
79                   OutputParams const &) const;
80         ///
81         int plaintext(Buffer const &, std::ostream &,
82                   OutputParams const &) const;
83         ///
84         int docbook(Buffer const &, std::ostream &,
85                     OutputParams const &) const;
86         ///
87         void validate(LaTeXFeatures &) const;
88         ///
89         void addPreview(lyx::graphics::PreviewLoader &) const;
90         ///
91         bool getStatus(LCursor &, FuncRequest const &, FuncStatus &) const;
92 protected:
93         InsetInclude(InsetInclude const &);
94         ///
95         virtual void doDispatch(LCursor & cur, FuncRequest & cmd);
96 private:
97         virtual std::auto_ptr<InsetBase> doClone() const;
98
99         /** Slot receiving a signal that the external file has changed
100          *  and the preview should be regenerated.
101          */
102         void fileChanged() const;
103
104         friend class InsetIncludeMailer;
105
106         /// set the parameters
107         void set(InsetCommandParams const & params, Buffer const &);
108         /// get the text displayed on the button
109         std::string const getScreenLabel(Buffer const &) const;
110         ///
111         void write(std::ostream &) const;
112         ///
113         void read(LyXLex &);
114
115         /// the parameters
116         InsetCommandParams params_;
117         /// holds the entity name that defines the file location (SGML)
118         std::string const include_label;
119
120         /// The pointer never changes although *preview_'s contents may.
121         boost::scoped_ptr<RenderMonitoredPreview> const preview_;
122
123         /// cache
124         mutable bool set_label_;
125         mutable RenderButton button_;
126 };
127
128
129 #include "mailinset.h"
130
131 class InsetIncludeMailer : public MailInset {
132 public:
133         ///
134         InsetIncludeMailer(InsetInclude & inset);
135         ///
136         virtual InsetBase & inset() const { return inset_; }
137         ///
138         virtual std::string const & name() const { return name_; }
139         ///
140         virtual std::string const inset2string(Buffer const &) const;
141         ///
142         static void string2params(std::string const &, InsetCommandParams &);
143         ///
144         static std::string const params2string(InsetCommandParams const &);
145 private:
146         ///
147         static std::string const name_;
148         ///
149         InsetInclude & inset_;
150 };
151
152 #endif // INSETINCLUDE_H