2000-06-12 11:27:15 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/* This file is part of*
|
2001-03-12 11:22:26 +00:00
|
|
|
* ======================================================
|
2000-06-12 11:27:15 +00:00
|
|
|
*
|
|
|
|
* LyX, The Document Processor
|
2001-03-12 11:22:26 +00:00
|
|
|
*
|
2000-06-12 11:27:15 +00:00
|
|
|
* Copyright 1995 Matthias Ettrich
|
2001-05-30 13:53:44 +00:00
|
|
|
* Copyright 1995-2001 The LyX Team.
|
2000-06-12 11:27:15 +00:00
|
|
|
*
|
|
|
|
* ====================================================== */
|
|
|
|
|
|
|
|
#ifndef INSET_EXTERNAL_H
|
|
|
|
#define INSET_EXTERNAL_H
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma interface
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "insetbutton.h"
|
2001-03-12 11:22:26 +00:00
|
|
|
#include "ExternalTemplate.h"
|
2000-06-12 11:27:15 +00:00
|
|
|
#include "LString.h"
|
2000-11-28 06:46:06 +00:00
|
|
|
#include <sigc++/signal_system.h>
|
2000-06-15 15:44:39 +00:00
|
|
|
|
|
|
|
///
|
2001-03-12 11:22:26 +00:00
|
|
|
class InsetExternal : public InsetButton {
|
2000-06-12 11:27:15 +00:00
|
|
|
public:
|
2001-03-12 11:22:26 +00:00
|
|
|
/// hold parameters settable from the GUI
|
2001-03-30 09:51:46 +00:00
|
|
|
struct Params {
|
|
|
|
Params(string const & f = string(),
|
2001-03-12 11:22:26 +00:00
|
|
|
string const & p = string(),
|
|
|
|
ExternalTemplate const & t = ExternalTemplate())
|
|
|
|
: filename(f), parameters(p), templ(t) {}
|
|
|
|
/// the filename
|
|
|
|
string filename;
|
|
|
|
/// the parameters of the current choice
|
|
|
|
string parameters;
|
|
|
|
/// the current template used
|
|
|
|
ExternalTemplate templ;
|
|
|
|
};
|
|
|
|
|
2000-06-12 11:27:15 +00:00
|
|
|
InsetExternal();
|
|
|
|
///
|
|
|
|
virtual ~InsetExternal();
|
|
|
|
/// what appears in the minibuffer when opening
|
2001-06-28 10:25:20 +00:00
|
|
|
virtual string const editMessage() const;
|
2000-06-12 11:27:15 +00:00
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
virtual void edit(BufferView *, int x, int y, unsigned int button);
|
2000-06-12 11:27:15 +00:00
|
|
|
///
|
2001-07-20 14:18:48 +00:00
|
|
|
virtual void edit(BufferView * bv, bool front = true);
|
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
virtual EDITABLE editable() const { return IS_EDITABLE; }
|
2000-06-12 11:27:15 +00:00
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
virtual void write(Buffer const *, std::ostream &) const;
|
2000-06-12 11:27:15 +00:00
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
virtual void read(Buffer const *, LyXLex & lex);
|
2001-03-12 11:22:26 +00:00
|
|
|
|
2000-06-12 11:27:15 +00:00
|
|
|
/** returns the number of rows (\n's) of generated tex code.
|
|
|
|
fragile == true means, that the inset should take care about
|
|
|
|
fragile commands by adding a \protect before.
|
|
|
|
If the free_spc (freespacing) variable is set, then this inset
|
|
|
|
is in a free-spacing paragraph.
|
|
|
|
*/
|
2001-06-28 10:25:20 +00:00
|
|
|
virtual int latex(Buffer const *, std::ostream &, bool fragile,
|
2001-07-20 14:18:48 +00:00
|
|
|
bool free_spc) const;
|
2001-03-12 11:22:26 +00:00
|
|
|
/// write ASCII output to the ostream
|
2001-06-28 10:25:20 +00:00
|
|
|
virtual int ascii(Buffer const *, std::ostream &, int linelen) const;
|
2001-03-12 11:22:26 +00:00
|
|
|
/// write LinuxDoc output to the ostream
|
2001-06-28 10:25:20 +00:00
|
|
|
virtual int linuxdoc(Buffer const *, std::ostream &) const;
|
2001-03-12 11:22:26 +00:00
|
|
|
/// write DocBook output to the ostream
|
2001-06-28 10:25:20 +00:00
|
|
|
virtual int docBook(Buffer const *, std::ostream &) const;
|
2001-03-12 11:22:26 +00:00
|
|
|
|
2000-06-12 11:27:15 +00:00
|
|
|
/// Updates needed features for this inset.
|
2001-06-28 10:25:20 +00:00
|
|
|
virtual void validate(LaTeXFeatures & features) const;
|
2000-06-12 11:27:15 +00:00
|
|
|
|
|
|
|
/// returns LyX code associated with the inset. Used for TOC, ...)
|
2001-06-28 10:25:20 +00:00
|
|
|
virtual Inset::Code lyxCode() const { return EXTERNAL_CODE; }
|
2001-03-12 11:22:26 +00:00
|
|
|
|
2000-06-12 11:27:15 +00:00
|
|
|
///
|
2001-07-06 15:57:54 +00:00
|
|
|
virtual Inset * clone(Buffer const &, bool same_id = false) const;
|
2000-06-12 11:27:15 +00:00
|
|
|
|
|
|
|
/// returns the text of the button
|
2001-07-28 12:24:16 +00:00
|
|
|
virtual string const getScreenLabel(Buffer const *) const;
|
2000-06-12 11:27:15 +00:00
|
|
|
|
2001-03-12 11:22:26 +00:00
|
|
|
// The following public members are used from the frontends code
|
2000-06-12 11:27:15 +00:00
|
|
|
|
2001-03-12 11:22:26 +00:00
|
|
|
/// set the parameters from a Params structure
|
2001-03-30 09:51:46 +00:00
|
|
|
virtual void setFromParams(Params const &);
|
2000-06-12 11:27:15 +00:00
|
|
|
|
2001-03-12 11:22:26 +00:00
|
|
|
/// update the file represented by the template
|
|
|
|
void updateExternal() const;
|
2000-06-12 11:27:15 +00:00
|
|
|
|
2001-03-12 11:22:26 +00:00
|
|
|
/// edit file of this template
|
|
|
|
void editExternal() const;
|
2000-06-12 11:27:15 +00:00
|
|
|
|
2001-03-12 11:22:26 +00:00
|
|
|
/// view file of this template
|
|
|
|
void viewExternal() const;
|
2000-06-12 11:27:15 +00:00
|
|
|
|
2001-03-12 11:22:26 +00:00
|
|
|
/// return a copy of our current params
|
2001-03-30 09:51:46 +00:00
|
|
|
Params params() const;
|
2000-06-12 11:27:15 +00:00
|
|
|
|
2001-03-12 11:22:26 +00:00
|
|
|
/// hide connection
|
2001-03-15 18:21:56 +00:00
|
|
|
SigC::Signal0<void> hideDialog;
|
2000-11-28 06:46:06 +00:00
|
|
|
|
2001-03-12 11:22:26 +00:00
|
|
|
private:
|
2000-06-12 11:27:15 +00:00
|
|
|
/// Write the output for a specific file format
|
2000-07-15 23:51:46 +00:00
|
|
|
int write(string const & format, Buffer const *,
|
|
|
|
std::ostream &) const;
|
2000-06-12 11:27:15 +00:00
|
|
|
|
|
|
|
/// Execute this command in the directory of this document
|
|
|
|
void executeCommand(string const & s, Buffer const * buf) const;
|
|
|
|
|
|
|
|
/// Substitute meta-variables in this string
|
2000-09-14 17:53:12 +00:00
|
|
|
string const doSubstitution(Buffer const *, string const & s) const;
|
2000-06-12 11:27:15 +00:00
|
|
|
|
2001-03-12 11:22:26 +00:00
|
|
|
/// our owning view
|
2001-04-11 17:14:20 +00:00
|
|
|
BufferView * view_;
|
2000-06-12 11:27:15 +00:00
|
|
|
|
2001-03-12 11:22:26 +00:00
|
|
|
/// the current params
|
2001-03-30 09:51:46 +00:00
|
|
|
Params params_;
|
2000-06-12 11:27:15 +00:00
|
|
|
|
|
|
|
/// A temp filename
|
2001-04-11 17:14:20 +00:00
|
|
|
string tempname_;
|
2000-06-12 11:27:15 +00:00
|
|
|
};
|
|
|
|
|
2001-03-30 09:51:46 +00:00
|
|
|
///
|
|
|
|
bool operator==(InsetExternal::Params const &, InsetExternal::Params const &);
|
|
|
|
///
|
|
|
|
bool operator!=(InsetExternal::Params const &, InsetExternal::Params const &);
|
|
|
|
|
2000-06-12 11:27:15 +00:00
|
|
|
#endif
|