]> git.lyx.org Git - lyx.git/blob - src/insets/insetexternal.h
remove CXX_WORKING_NAMESPACES
[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-2000 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 InsetExternalParams {
29                 InsetExternalParams(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 EDITABLE Editable() const { return IS_EDITABLE; }
50         ///
51         virtual void Write(Buffer const *, std::ostream &) const;
52         ///
53         virtual void Read(Buffer const *, LyXLex & lex);
54
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.
60          */
61         virtual int Latex(Buffer const *, std::ostream &, bool fragile,
62                           bool free_spc) const;
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;
69
70         /// Updates needed features for this inset.
71         virtual void Validate(LaTeXFeatures & features) const;
72
73         /// returns LyX code associated with the inset. Used for TOC, ...)
74         virtual Inset::Code LyxCode() const { return EXTERNAL_CODE; }
75  
76         ///
77         virtual Inset * Clone(Buffer const &) const;
78
79         /// returns the text of the button
80         virtual string const getScreenLabel() const;
81
82         // The following public members are used from the frontends code
83
84         /// set the parameters from a Params structure
85         virtual void setFromParams(InsetExternalParams const &);
86
87         /// update the file represented by the template
88         void updateExternal() const;
89
90         /// edit file of this template
91         void editExternal() const;
92
93         /// view file of this template
94         void viewExternal() const;
95
96         /// return a copy of our current params
97         InsetExternalParams params() const;
98
99         /// hide connection
100         SigC::Signal0<void> hideDialog;
101
102 private:
103         /// Write the output for a specific file format
104         int write(string const & format, Buffer const *,
105                   std::ostream &) const;
106
107         /// Execute this command in the directory of this document
108         void executeCommand(string const & s, Buffer const * buf) const;
109
110         /// Substitute meta-variables in this string
111         string const doSubstitution(Buffer const *, string const & s) const;
112
113         /// our owning view
114         BufferView * view;
115
116         /// the current params
117         InsetExternalParams params_;
118
119         /// A temp filename
120         string tempname;
121 };
122
123 #endif