]> git.lyx.org Git - lyx.git/blob - src/insets/insetexternal.h
Don't remove cell selections after fontchange.
[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 #include <sigc++/signal_system.h>
23
24 ///
25 class InsetExternal : public InsetButton {
26 public:
27         /// hold parameters settable from the GUI
28         struct Params {
29                 Params(string const & f = string(), 
30                                         string const & p = string(), 
31                                         ExternalTemplate const & t = ExternalTemplate())
32                         : filename(f), parameters(p), templ(t) {}
33                 /// the filename
34                 string filename;
35                 /// the parameters of the current choice
36                 string parameters;
37                 /// the current template used
38                 ExternalTemplate templ;
39         };
40
41         InsetExternal();
42         ///
43         virtual ~InsetExternal();
44         /// what appears in the minibuffer when opening
45         virtual string const editMessage() const;
46         ///
47         virtual void edit(BufferView *, int x, int y, unsigned int button);
48         ///
49         virtual void edit(BufferView * bv, bool front = true);
50         ///
51         virtual EDITABLE editable() const { return IS_EDITABLE; }
52         ///
53         virtual void write(Buffer const *, std::ostream &) const;
54         ///
55         virtual void read(Buffer const *, LyXLex & lex);
56
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.
62          */
63         virtual int latex(Buffer const *, std::ostream &, bool fragile,
64                           bool free_spc) const;
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;
71
72         /// Updates needed features for this inset.
73         virtual void validate(LaTeXFeatures & features) const;
74
75         /// returns LyX code associated with the inset. Used for TOC, ...)
76         virtual Inset::Code lyxCode() const { return EXTERNAL_CODE; }
77  
78         ///
79         virtual Inset * clone(Buffer const &, bool same_id = false) const;
80
81         /// returns the text of the button
82         virtual string const getScreenLabel(Buffer const *) const;
83
84         // The following public members are used from the frontends code
85
86         /// set the parameters from a Params structure
87         virtual void setFromParams(Params const &);
88
89         ///
90         void updateExternal() const;
91
92         /// update the file represented by the template
93         void updateExternal(string const &, Buffer const *) const;
94
95         /// edit file of this template
96         void editExternal() const;
97
98         /// view file of this template
99         void viewExternal() const;
100
101         /// return a copy of our current params
102         Params params() const;
103
104         /// hide connection
105         SigC::Signal0<void> hideDialog;
106
107 private:
108         /// Write the output for a specific file format
109         int write(string const & format, Buffer const *,
110                   std::ostream &) const;
111
112         /// Execute this command in the directory of this document
113         void executeCommand(string const & s, Buffer const * buf) const;
114
115         /// Substitute meta-variables in this string
116         string const doSubstitution(Buffer const *, string const & s) const;
117
118         /// our owning view
119         BufferView * view_;
120
121         /// the current params
122         Params params_;
123
124         /// A temp filename
125         string tempname_;
126 };
127
128 ///
129 bool operator==(InsetExternal::Params const &, InsetExternal::Params const &);
130 ///
131 bool operator!=(InsetExternal::Params const &, InsetExternal::Params const &);
132
133 #endif