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"
22 #include <sigc++/signal_system.h>
25 class InsetExternal : public InsetButton {
27 /// hold parameters settable from the GUI
29 Params(string const & f = string(),
30 string const & p = string(),
31 ExternalTemplate const & t = ExternalTemplate())
32 : filename(f), parameters(p), templ(t) {}
35 /// the parameters of the current choice
37 /// the current template used
38 ExternalTemplate templ;
43 virtual ~InsetExternal();
44 /// what appears in the minibuffer when opening
45 virtual string const editMessage() const;
47 virtual void edit(BufferView *, int x, int y, unsigned int button);
49 virtual void edit(BufferView * bv, bool front = true);
51 virtual EDITABLE editable() const { return IS_EDITABLE; }
53 virtual void write(Buffer const *, std::ostream &) const;
55 virtual void read(Buffer const *, LyXLex & lex);
57 /** returns the number of rows (\n's) of generated tex code.
58 fragile == true means, that the inset should take care about
59 fragile commands by adding a \protect before.
60 If the free_spc (freespacing) variable is set, then this inset
61 is in a free-spacing paragraph.
63 virtual int latex(Buffer const *, std::ostream &, bool fragile,
65 /// write ASCII output to the ostream
66 virtual int ascii(Buffer const *, std::ostream &, int linelen) const;
67 /// write LinuxDoc output to the ostream
68 virtual int linuxdoc(Buffer const *, std::ostream &) const;
69 /// write DocBook output to the ostream
70 virtual int docbook(Buffer const *, std::ostream &) const;
72 /// Updates needed features for this inset.
73 virtual void validate(LaTeXFeatures & features) const;
75 /// returns LyX code associated with the inset. Used for TOC, ...)
76 virtual Inset::Code lyxCode() const { return EXTERNAL_CODE; }
79 virtual Inset * clone(Buffer const &, bool same_id = false) const;
81 /// returns the text of the button
82 virtual string const getScreenLabel(Buffer const *) const;
84 // The following public members are used from the frontends code
86 /// set the parameters from a Params structure
87 virtual void setFromParams(Params const &);
89 /// update the file represented by the template
90 void updateExternal() const;
92 /// edit file of this template
93 void editExternal() const;
95 /// view file of this template
96 void viewExternal() const;
98 /// return a copy of our current params
99 Params params() const;
102 SigC::Signal0<void> hideDialog;
105 /// Write the output for a specific file format
106 int write(string const & format, Buffer const *,
107 std::ostream &) const;
109 /// Execute this command in the directory of this document
110 void executeCommand(string const & s, Buffer const * buf) const;
112 /// Substitute meta-variables in this string
113 string const doSubstitution(Buffer const *, string const & s) const;
118 /// the current params
126 bool operator==(InsetExternal::Params const &, InsetExternal::Params const &);
128 bool operator!=(InsetExternal::Params const &, InsetExternal::Params const &);