]> git.lyx.org Git - lyx.git/blob - src/insets/insetexternal.h
remove noload/don't typeset
[lyx.git] / src / insets / insetexternal.h
1 // -*- C++ -*-
2 /* This file is part of*
3  * ======================================================
4  *
5  *           LyX, The Document Processor
6  *
7  *           Copyright 1995 Matthias Ettrich
8  *           Copyright 1995-2001 The LyX Team.
9  *
10  * ====================================================== */
11
12 #ifndef INSET_EXTERNAL_H
13 #define INSET_EXTERNAL_H
14
15 #ifdef __GNUG__
16 #pragma interface
17 #endif
18
19 #include "insetbutton.h"
20 #include "ExternalTemplate.h"
21 #include "LString.h"
22
23 #include <boost/signals/signal0.hpp>
24
25 ///
26 class InsetExternal : public InsetButton {
27 public:
28         /// hold parameters settable from the GUI
29         struct Params {
30                 Params(string const & f = string(),
31                                         string const & p = string(),
32                                         ExternalTemplate const & t = ExternalTemplate())
33                         : filename(f), parameters(p), templ(t) {}
34                 /// the filename
35                 string filename;
36                 /// the parameters of the current choice
37                 string parameters;
38                 /// the current template used
39                 ExternalTemplate templ;
40         };
41
42         InsetExternal();
43         ///
44         virtual ~InsetExternal();
45         /// what appears in the minibuffer when opening
46         virtual string const editMessage() const;
47         ///
48         virtual void edit(BufferView *, int x, int y, mouse_button::state button);
49         ///
50         virtual void edit(BufferView * bv, bool front = true);
51         ///
52         virtual EDITABLE editable() const { return IS_EDITABLE; }
53         ///
54         virtual void write(Buffer const *, std::ostream &) const;
55         ///
56         virtual void read(Buffer const *, LyXLex & lex);
57
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.
63          */
64         virtual int latex(Buffer const *, std::ostream &, bool fragile,
65                           bool free_spc) const;
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;
72
73         /// Updates needed features for this inset.
74         virtual void validate(LaTeXFeatures & features) const;
75
76         /// returns LyX code associated with the inset. Used for TOC, ...)
77         virtual Inset::Code lyxCode() const { return EXTERNAL_CODE; }
78
79         ///
80         virtual Inset * clone(Buffer const &, bool same_id = false) const;
81
82         /// returns the text of the button
83         virtual string const getScreenLabel(Buffer const *) const;
84
85         // The following public members are used from the frontends code
86
87         /// set the parameters from a Params structure
88         virtual void setFromParams(Params const &);
89
90         ///
91         void updateExternal() const;
92
93         /// update the file represented by the template
94         void updateExternal(string const &, Buffer const *) const;
95
96         /// edit file of this template
97         void editExternal() const;
98
99         /// view file of this template
100         void viewExternal() const;
101
102         /// return a copy of our current params
103         Params params() const;
104
105         /// hide connection
106         boost::signal0<void> hideDialog;
107
108 private:
109         /// Write the output for a specific file format
110         int write(string const & format, Buffer const *,
111                   std::ostream &) const;
112
113         /// Execute this command in the directory of this document
114         void executeCommand(string const & s, Buffer const * buf) const;
115
116         /// Substitute meta-variables in this string
117         string const doSubstitution(Buffer const *, string const & s) const;
118
119         /// our owning view
120         BufferView * view_;
121
122         /// the current params
123         Params params_;
124
125         /// A temp filename
126         string tempname_;
127 };
128
129 ///
130 bool operator==(InsetExternal::Params const &, InsetExternal::Params const &);
131 ///
132 bool operator!=(InsetExternal::Params const &, InsetExternal::Params const &);
133
134 #endif