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 "insetbutton.h"
17 #include "ExternalTemplate.h"
21 class InsetExternal : public InsetButton {
23 /// hold parameters settable from the GUI
25 Params(string const & f = string(),
26 string const & p = string(),
27 ExternalTemplate const & t = ExternalTemplate())
28 : filename(f), parameters(p), templ(t) {}
31 /// the parameters of the current choice
33 /// the current template used
34 ExternalTemplate templ;
39 virtual ~InsetExternal();
41 virtual dispatch_result localDispatch(FuncRequest const & cmd);
42 /// what appears in the minibuffer when opening
43 virtual string const editMessage() const;
45 virtual void edit(BufferView *, int x, int y, mouse_button::state button);
47 virtual void edit(BufferView * bv, bool front = true);
49 virtual EDITABLE editable() const { return IS_EDITABLE; }
51 virtual void write(Buffer const *, std::ostream &) const;
53 virtual void read(Buffer const *, LyXLex & lex);
55 /** returns the number of rows (\n's) of generated tex code.
56 fragile == true means, that the inset should take care about
57 fragile commands by adding a \protect before.
58 If the free_spc (freespacing) variable is set, then this inset
59 is in a free-spacing paragraph.
61 virtual int latex(Buffer const *, std::ostream &, bool fragile,
63 /// write ASCII output to the ostream
64 virtual int ascii(Buffer const *, std::ostream &, int linelen) const;
65 /// write LinuxDoc output to the ostream
66 virtual int linuxdoc(Buffer const *, std::ostream &) const;
67 /// write DocBook output to the ostream
68 virtual int docbook(Buffer const *, std::ostream &, bool mixcont) const;
70 /// Updates needed features for this inset.
71 virtual void validate(LaTeXFeatures & features) const;
73 /// returns LyX code associated with the inset. Used for TOC, ...)
74 virtual Inset::Code lyxCode() const { return EXTERNAL_CODE; }
77 virtual Inset * clone(Buffer const &, bool same_id = false) const;
79 /// returns the text of the button
80 virtual string const getScreenLabel(Buffer const *) const;
82 // The following public members are used from the frontends code
84 /// set the parameters from a Params structure
85 virtual void setFromParams(Params const &);
88 void updateExternal() const;
90 /// update the file represented by the template
91 void updateExternal(string const &, Buffer const *) const;
93 /// edit file of this template
94 void editExternal() const;
96 /// view file of this template
97 void viewExternal() const;
99 /// return a copy of our current params
100 Params const & params() const;
103 void setView(BufferView * bv) { view_ = bv; }
106 /// Write the output for a specific file format
107 int write(string const & format, Buffer const *,
108 std::ostream &) const;
110 /// Execute this command in the directory of this document
111 void executeCommand(string const & s, Buffer const * buf) const;
113 /// Substitute meta-variables in this string
114 string const doSubstitution(Buffer const *, string const & s) const;
119 /// the current params
127 bool operator==(InsetExternal::Params const &, InsetExternal::Params const &);
129 bool operator!=(InsetExternal::Params const &, InsetExternal::Params const &);
131 #include "mailinset.h"
133 class InsetExternalMailer : public MailInset {
136 InsetExternalMailer(InsetExternal & inset);
138 virtual Inset & inset() const { return inset_; }
140 virtual string const & name() const { return name_; }
142 virtual string const inset2string() const;
144 static void string2params(string const &, InsetExternal::Params &);
146 static string const params2string(InsetExternal::Params const &);
149 static string const name_;
151 InsetExternal & inset_;