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
15 #include "insetbutton.h"
16 #include "ExternalTemplate.h"
20 class InsetExternal : public InsetButton {
22 /// hold parameters settable from the GUI
24 Params(string const & f = string(),
25 string const & p = string(),
26 ExternalTemplate const & t = ExternalTemplate())
27 : filename(f), parameters(p), templ(t) {}
30 /// the parameters of the current choice
32 /// the current template used
33 ExternalTemplate templ;
38 virtual ~InsetExternal();
40 virtual dispatch_result localDispatch(FuncRequest const & cmd);
41 /// what appears in the minibuffer when opening
42 virtual string const editMessage() const;
44 virtual EDITABLE editable() const { return IS_EDITABLE; }
46 virtual void write(Buffer const *, std::ostream &) const;
48 virtual void read(Buffer const *, LyXLex & lex);
50 /** returns the number of rows (\n's) of generated tex code.
51 fragile == true means, that the inset should take care about
52 fragile commands by adding a \protect before.
53 If the free_spc (freespacing) variable is set, then this inset
54 is in a free-spacing paragraph.
56 virtual int latex(Buffer const *, std::ostream &,
57 LatexRunParams const &) const;
58 /// write ASCII output to the ostream
59 virtual int ascii(Buffer const *, std::ostream &, int linelen) const;
60 /// write LinuxDoc output to the ostream
61 virtual int linuxdoc(Buffer const *, std::ostream &) const;
62 /// write DocBook output to the ostream
63 virtual int docbook(Buffer const *, std::ostream &, bool mixcont) const;
65 /// Updates needed features for this inset.
66 virtual void validate(LaTeXFeatures & features) const;
68 /// returns LyX code associated with the inset. Used for TOC, ...)
69 virtual Inset::Code lyxCode() const { return EXTERNAL_CODE; }
72 virtual Inset * clone(Buffer const &) const;
74 //virtual Inset * clone(Buffer const &, bool same_id) const;
76 /// returns the text of the button
77 virtual string const getScreenLabel(Buffer const *) const;
79 // The following public members are used from the frontends code
81 /// set the parameters from a Params structure
82 virtual void setFromParams(Params const &);
85 void updateExternal() const;
87 /// update the file represented by the template
88 void updateExternal(string const &, Buffer const *) const;
90 /// edit file of this template
91 void editExternal() const;
93 /// view file of this template
94 void viewExternal() const;
96 /// return a copy of our current params
97 Params const & params() const;
100 void setView(BufferView * bv) { view_ = bv; }
103 /// Write the output for a specific file format
104 int write(string const & format, Buffer const *,
105 std::ostream &) const;
107 /// Execute this command in the directory of this document
108 void executeCommand(string const & s, Buffer const * buf) const;
110 /// Substitute meta-variables in this string
111 string const doSubstitution(Buffer const *, string const & s) const;
116 /// the current params
124 #include "mailinset.h"
126 class InsetExternalMailer : public MailInset {
129 InsetExternalMailer(InsetExternal & inset);
131 virtual InsetBase & inset() const { return inset_; }
133 virtual string const & name() const { return name_; }
135 virtual string const inset2string() const;
137 static void string2params(string const &, InsetExternal::Params &);
139 static string const params2string(InsetExternal::Params const &);
142 static string const name_;
144 InsetExternal & inset_;