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 "ExternalTemplate.h"
17 #include "graphics/GraphicsTypes.h"
20 #include <boost/scoped_ptr.hpp>
21 #include <boost/signals/trackable.hpp>
27 class InsetExternal : public Inset, public boost::signals::trackable {
29 /// hold parameters settable from the GUI
34 /// the current template used
35 ExternalTemplate templ;
36 /// how the inset is displayed by LyX
37 grfx::DisplayType display;
38 /// The scale of the displayed graphic (If shown).
39 unsigned int lyxscale;
44 InsetExternal(InsetExternal const &);
46 virtual ~InsetExternal();
48 virtual dispatch_result localDispatch(FuncRequest const & cmd);
49 /** Would not be needed if editExternal were dispatched properly from
50 * the frontends rather than being invoked directly.
52 virtual void cache(BufferView *) const;
54 void metrics(MetricsInfo &, Dimension &) const;
56 void draw(PainterInfo & pi, int x, int y) const;
57 /// what appears in the minibuffer when opening
58 virtual string const editMessage() const;
60 virtual EDITABLE editable() const { return IS_EDITABLE; }
62 virtual void write(Buffer const *, std::ostream &) const;
64 virtual void read(Buffer const *, LyXLex & lex);
66 /** returns the number of rows (\n's) of generated tex code.
67 fragile == true means, that the inset should take care about
68 fragile commands by adding a \protect before.
69 If the free_spc (freespacing) variable is set, then this inset
70 is in a free-spacing paragraph.
72 virtual int latex(Buffer const *, std::ostream &,
73 LatexRunParams const &) const;
74 /// write ASCII output to the ostream
75 virtual int ascii(Buffer const *, std::ostream &, int linelen) const;
76 /// write LinuxDoc output to the ostream
77 virtual int linuxdoc(Buffer const *, std::ostream &) const;
78 /// write DocBook output to the ostream
79 virtual int docbook(Buffer const *, std::ostream &, bool mixcont) const;
81 /// Updates needed features for this inset.
82 virtual void validate(LaTeXFeatures & features) const;
84 /// returns LyX code associated with the inset. Used for TOC, ...)
85 virtual Inset::Code lyxCode() const { return EXTERNAL_CODE; }
88 virtual Inset * clone() const;
90 /// Set the inset parameters.
91 virtual void setParams(Params const &, string const & filepath);
93 /** update the file represented by the template.
94 If \param external_in_tmpdir == true, then the generated file is
95 place in the buffer's temporary directory.
97 void updateExternal(string const &, Buffer const *,
98 bool external_in_tmpdir) const;
100 /// edit file of this template
101 void editExternal() const;
103 /// return a copy of our current params
104 Params const & params() const;
107 /** This method is connected to the graphics loader, so we are
108 * informed when the image has been loaded.
110 void statusChanged();
112 /** Write the output for a specific file format
113 and generate any external data files.
114 If \param external_in_tmpdir == true, then the generated file is
115 place in the buffer's temporary directory.
117 int write(string const & format, Buffer const *, std::ostream &,
118 bool external_in_tmpdir = false) const;
120 /// Substitute meta-variables in this string
121 string const doSubstitution(Buffer const *, string const & s) const;
123 /// the current params
127 mutable string tempname_;
129 /// The thing that actually draws the image on LyX's screen.
130 boost::scoped_ptr<GraphicInset> const renderer_;
134 #include "mailinset.h"
136 class InsetExternalMailer : public MailInset {
139 InsetExternalMailer(InsetExternal & inset);
141 virtual InsetBase & inset() const { return inset_; }
143 virtual string const & name() const { return name_; }
145 virtual string const inset2string() const;
147 static void string2params(string const &, InsetExternal::Params &);
149 static string const params2string(InsetExternal::Params const &);
152 static string const name_;
154 InsetExternal & inset_;