2 /* This file is part of*
3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright 1995 Matthias Ettrich
8 * Copyright 1995-2000 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>
24 #ifdef SIGC_CXX_NAMESPACES
29 class InsetExternal : public InsetButton {
31 /// hold parameters settable from the GUI
32 struct InsetExternalParams {
33 InsetExternalParams(string const & f = string(),
34 string const & p = string(),
35 ExternalTemplate const & t = ExternalTemplate())
36 : filename(f), parameters(p), templ(t) {}
39 /// the parameters of the current choice
41 /// the current template used
42 ExternalTemplate templ;
47 virtual ~InsetExternal();
48 /// what appears in the minibuffer when opening
49 virtual string const EditMessage() const;
51 virtual void Edit(BufferView *, int x, int y, unsigned int button);
53 virtual EDITABLE Editable() const { return IS_EDITABLE; }
55 virtual void Write(Buffer const *, std::ostream &) const;
57 virtual void Read(Buffer const *, LyXLex & lex);
59 /** returns the number of rows (\n's) of generated tex code.
60 fragile == true means, that the inset should take care about
61 fragile commands by adding a \protect before.
62 If the free_spc (freespacing) variable is set, then this inset
63 is in a free-spacing paragraph.
65 virtual int Latex(Buffer const *, std::ostream &, bool fragile,
67 /// write ASCII output to the ostream
68 virtual int Ascii(Buffer const *, std::ostream &, int linelen) const;
69 /// write LinuxDoc output to the ostream
70 virtual int Linuxdoc(Buffer const *, std::ostream &) const;
71 /// write DocBook output to the ostream
72 virtual int DocBook(Buffer const *, std::ostream &) const;
74 /// Updates needed features for this inset.
75 virtual void Validate(LaTeXFeatures & features) const;
77 /// returns LyX code associated with the inset. Used for TOC, ...)
78 virtual Inset::Code LyxCode() const { return EXTERNAL_CODE; }
81 virtual Inset * Clone(Buffer const &) const;
83 /// returns the text of the button
84 virtual string const getScreenLabel() const;
86 // The following public members are used from the frontends code
88 /// set the parameters from a Params structure
89 virtual void setFromParams(InsetExternalParams const &);
91 /// update the file represented by the template
92 void updateExternal() const;
94 /// edit file of this template
95 void editExternal() const;
97 /// view file of this template
98 void viewExternal() const;
100 /// return a copy of our current params
101 InsetExternalParams params() const;
104 Signal0<void> hideDialog;
107 /// Write the output for a specific file format
108 int write(string const & format, Buffer const *,
109 std::ostream &) const;
111 /// Execute this command in the directory of this document
112 void executeCommand(string const & s, Buffer const * buf) const;
114 /// Substitute meta-variables in this string
115 string const doSubstitution(Buffer const *, string const & s) const;
120 /// the current params
121 InsetExternalParams params_;