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
16 #include "graphics/GraphicsTypes.h"
17 #include "support/filename.h"
19 #include <boost/scoped_ptr.hpp>
20 #include <boost/signals/trackable.hpp>
22 #include "support/std_string.h"
27 class InsetExternal : public InsetOld, public boost::signals::trackable
29 /** No two Params variables can have the same temporary file.
30 * This struct has copy-semantics but the copy constructor
31 * and assignment operator simply call the default constructor.
32 * Use of this struct enables us to use the compiler-generated
33 * copy constructor and assignment operator for the Params struct.
37 TempName(TempName const &);
39 TempName & operator=(TempName const &);
40 string const & operator()() const { return tempname_; }
46 /// hold parameters settable from the GUI
50 /// The name of the tempfile used for manipulations.
51 string const & tempname() const { return tempname_(); }
53 /// the current template used
54 void settemplate(string const &);
55 string const & templatename() const { return templatename_; }
58 lyx::support::FileName filename;
59 /// how the inset is displayed by LyX
60 lyx::graphics::DisplayType display;
61 /// The scale of the displayed graphic (If shown).
62 unsigned int lyxscale;
71 InsetExternal(InsetExternal const &);
73 virtual ~InsetExternal();
75 virtual dispatch_result localDispatch(FuncRequest const & cmd);
77 void metrics(MetricsInfo &, Dimension &) const;
79 void draw(PainterInfo & pi, int x, int y) const;
81 virtual EDITABLE editable() const { return IS_EDITABLE; }
83 virtual void write(Buffer const &, std::ostream &) const;
85 virtual void read(Buffer const &, LyXLex & lex);
87 /** returns the number of rows (\n's) of generated tex code.
88 fragile == true means, that the inset should take care about
89 fragile commands by adding a \protect before.
90 If the free_spc (freespacing) variable is set, then this inset
91 is in a free-spacing paragraph.
93 virtual int latex(Buffer const &, std::ostream &,
94 LatexRunParams const &) const;
95 /// write ASCII output to the ostream
96 virtual int ascii(Buffer const &, std::ostream &, int linelen) const;
97 /// write LinuxDoc output to the ostream
98 virtual int linuxdoc(Buffer const &, std::ostream &) const;
99 /// write DocBook output to the ostream
100 virtual int docbook(Buffer const &, std::ostream &, bool mixcont) const;
102 /// Updates needed features for this inset.
103 virtual void validate(LaTeXFeatures & features) const;
105 /// returns LyX code associated with the inset. Used for TOC, ...)
106 virtual InsetOld::Code lyxCode() const { return EXTERNAL_CODE; }
109 virtual std::auto_ptr<InsetBase> clone() const;
111 /// return a copy of our current params
112 Params const & params() const;
114 /// Set the inset parameters.
115 virtual void setParams(Params const &, Buffer const &);
117 /** update the file represented by the template.
118 If \param external_in_tmpdir == true, then the generated file is
119 place in the buffer's temporary directory.
121 void updateExternal(string const &, Buffer const &,
122 bool external_in_tmpdir) const;
125 /** This method is connected to the graphics loader, so we are
126 * informed when the image has been loaded.
128 void statusChanged();
130 /** Write the output for a specific file format
131 and generate any external data files.
132 If \param external_in_tmpdir == true, then the generated file is
133 place in the buffer's temporary directory.
135 int write(string const & format, Buffer const &, std::ostream &,
136 bool external_in_tmpdir = false) const;
138 /// the current params
141 /// The thing that actually draws the image on LyX's screen.
142 boost::scoped_ptr<RenderInset> renderer_;
146 #include "mailinset.h"
148 class InsetExternalMailer : public MailInset {
151 InsetExternalMailer(InsetExternal & inset);
153 virtual InsetBase & inset() const { return inset_; }
155 virtual string const & name() const { return name_; }
157 virtual string const inset2string(Buffer const &) const;
159 static void string2params(string const &, Buffer const &,
160 InsetExternal::Params &);
162 static string const params2string(InsetExternal::Params const &,
166 static string const name_;
168 InsetExternal & inset_;