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 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 &) 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 &) const;
79 /// returns the text of the button
80 virtual string const getScreenLabel() 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 &);
87 /// update the file represented by the template
88 void updateExternal() 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 params() const;
100 SigC::Signal0<void> hideDialog;
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 bool operator==(InsetExternal::Params const &, InsetExternal::Params const &);
126 bool operator!=(InsetExternal::Params const &, InsetExternal::Params const &);