3 * \file insetexternal.h
4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Asger Alstrup Nielsen
9 * Full author contact details are available in file CREDITS.
12 #ifndef INSET_EXTERNAL_H
13 #define INSET_EXTERNAL_H
17 #include "graphics/GraphicsTypes.h"
19 #include "support/filename.h"
21 #include <boost/scoped_ptr.hpp>
22 #include <boost/signals/trackable.hpp>
24 #include "support/std_string.h"
29 class InsetExternal : public InsetOld, public boost::signals::trackable
31 /** No two Params variables can have the same temporary file.
32 * This struct has copy-semantics but the copy constructor
33 * and assignment operator simply call the default constructor.
34 * Use of this struct enables us to use the compiler-generated
35 * copy constructor and assignment operator for the Params struct.
39 TempName(TempName const &);
41 TempName & operator=(TempName const &);
42 string const & operator()() const { return tempname_; }
48 /// hold parameters settable from the GUI
52 void write(Buffer const &, std::ostream &) const;
53 bool read(Buffer const &, LyXLex &);
55 /// The name of the tempfile used for manipulations.
56 string const & tempname() const { return tempname_(); }
58 /// the current template used
59 void settemplate(string const &);
60 string const & templatename() const { return templatename_; }
63 lyx::support::FileName filename;
64 /// how the inset is displayed by LyX
65 lyx::graphics::DisplayType display;
66 /// The scale of the displayed graphic (If shown).
67 unsigned int lyxscale;
76 InsetExternal(InsetExternal const &);
78 virtual ~InsetExternal();
80 virtual dispatch_result localDispatch(FuncRequest const & cmd);
82 void metrics(MetricsInfo &, Dimension &) const;
84 void draw(PainterInfo & pi, int x, int y) const;
86 virtual EDITABLE editable() const { return IS_EDITABLE; }
88 virtual void write(Buffer const &, std::ostream &) const;
90 virtual void read(Buffer const &, LyXLex & lex);
92 /** returns the number of rows (\n's) of generated tex code.
93 fragile == true means, that the inset should take care about
94 fragile commands by adding a \protect before.
95 If the free_spc (freespacing) variable is set, then this inset
96 is in a free-spacing paragraph.
98 virtual int latex(Buffer const &, std::ostream &,
99 LatexRunParams const &) const;
100 /// write ASCII output to the ostream
101 virtual int ascii(Buffer const &, std::ostream &, int linelen) const;
102 /// write LinuxDoc output to the ostream
103 virtual int linuxdoc(Buffer const &, std::ostream &) const;
104 /// write DocBook output to the ostream
105 virtual int docbook(Buffer const &, std::ostream &, bool mixcont) const;
107 /// Updates needed features for this inset.
108 virtual void validate(LaTeXFeatures & features) const;
110 /// returns LyX code associated with the inset. Used for TOC, ...)
111 virtual InsetOld::Code lyxCode() const { return EXTERNAL_CODE; }
114 virtual std::auto_ptr<InsetBase> clone() const;
116 /// return a copy of our current params
117 Params const & params() const;
119 /// Set the inset parameters.
120 virtual void setParams(Params const &, Buffer const &);
122 /** update the file represented by the template.
123 If \param external_in_tmpdir == true, then the generated file is
124 place in the buffer's temporary directory.
126 void updateExternal(string const &, Buffer const &,
127 bool external_in_tmpdir) const;
130 /** This method is connected to the graphics loader, so we are
131 * informed when the image has been loaded.
133 void statusChanged();
135 /** Write the output for a specific file format
136 and generate any external data files.
137 If \param external_in_tmpdir == true, then the generated file is
138 place in the buffer's temporary directory.
140 int write(string const & format, Buffer const &, std::ostream &,
141 bool external_in_tmpdir = false) const;
143 /// the current params
146 /// The thing that actually draws the image on LyX's screen.
147 boost::scoped_ptr<RenderInset> renderer_;
151 #include "mailinset.h"
153 class InsetExternalMailer : public MailInset {
156 InsetExternalMailer(InsetExternal & inset);
158 virtual InsetBase & inset() const { return inset_; }
160 virtual string const & name() const { return name_; }
162 virtual string const inset2string(Buffer const &) const;
164 static void string2params(string const &, Buffer const &,
165 InsetExternal::Params &);
167 static string const params2string(InsetExternal::Params const &,
171 static string const name_;
173 InsetExternal & inset_;