2 /* This file is part of*
3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright 1995 Matthias Ettrich
8 * Copyright 1995-2001 The LyX Team.
10 * ====================================================== */
12 #ifndef INSET_EXTERNAL_H
13 #define INSET_EXTERNAL_H
19 #include "insetbutton.h"
20 #include "ExternalTemplate.h"
23 #include <boost/signals/signal0.hpp>
26 class InsetExternal : public InsetButton {
28 /// hold parameters settable from the GUI
30 Params(string const & f = string(),
31 string const & p = string(),
32 ExternalTemplate const & t = ExternalTemplate())
33 : filename(f), parameters(p), templ(t) {}
36 /// the parameters of the current choice
38 /// the current template used
39 ExternalTemplate templ;
44 virtual ~InsetExternal();
45 /// what appears in the minibuffer when opening
46 virtual string const editMessage() const;
48 virtual void edit(BufferView *, int x, int y, mouse_button::state button);
50 virtual void edit(BufferView * bv, bool front = true);
52 virtual EDITABLE editable() const { return IS_EDITABLE; }
54 virtual void write(Buffer const *, std::ostream &) const;
56 virtual void read(Buffer const *, LyXLex & lex);
58 /** returns the number of rows (\n's) of generated tex code.
59 fragile == true means, that the inset should take care about
60 fragile commands by adding a \protect before.
61 If the free_spc (freespacing) variable is set, then this inset
62 is in a free-spacing paragraph.
64 virtual int latex(Buffer const *, std::ostream &, bool fragile,
66 /// write ASCII output to the ostream
67 virtual int ascii(Buffer const *, std::ostream &, int linelen) const;
68 /// write LinuxDoc output to the ostream
69 virtual int linuxdoc(Buffer const *, std::ostream &) const;
70 /// write DocBook output to the ostream
71 virtual int docbook(Buffer const *, std::ostream &, bool mixcont) const;
73 /// Updates needed features for this inset.
74 virtual void validate(LaTeXFeatures & features) const;
76 /// returns LyX code associated with the inset. Used for TOC, ...)
77 virtual Inset::Code lyxCode() const { return EXTERNAL_CODE; }
80 virtual Inset * clone(Buffer const &, bool same_id = false) const;
82 /// returns the text of the button
83 virtual string const getScreenLabel(Buffer const *) const;
85 // The following public members are used from the frontends code
87 /// set the parameters from a Params structure
88 virtual void setFromParams(Params const &);
91 void updateExternal() const;
93 /// update the file represented by the template
94 void updateExternal(string const &, Buffer const *) const;
96 /// edit file of this template
97 void editExternal() const;
99 /// view file of this template
100 void viewExternal() const;
102 /// return a copy of our current params
103 Params params() const;
106 boost::signal0<void> hideDialog;
109 /// Write the output for a specific file format
110 int write(string const & format, Buffer const *,
111 std::ostream &) const;
113 /// Execute this command in the directory of this document
114 void executeCommand(string const & s, Buffer const * buf) const;
116 /// Substitute meta-variables in this string
117 string const doSubstitution(Buffer const *, string const & s) const;
122 /// the current params
130 bool operator==(InsetExternal::Params const &, InsetExternal::Params const &);
132 bool operator!=(InsetExternal::Params const &, InsetExternal::Params const &);