2000-06-12 11:27:15 +00:00
|
|
|
// -*- C++ -*-
|
2002-09-25 14:26:13 +00:00
|
|
|
/**
|
|
|
|
* \file insetexternal.h
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
2000-06-12 11:27:15 +00:00
|
|
|
*
|
2002-09-25 14:26:13 +00:00
|
|
|
* \author Asger Alstrup Nielsen
|
2002-03-21 17:09:55 +00:00
|
|
|
*
|
2002-09-25 14:26:13 +00:00
|
|
|
* Full author contact details are available in file CREDITS
|
|
|
|
*/
|
2000-06-12 11:27:15 +00:00
|
|
|
|
|
|
|
#ifndef INSET_EXTERNAL_H
|
|
|
|
#define INSET_EXTERNAL_H
|
|
|
|
|
|
|
|
#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"
|
2002-05-29 16:21:03 +00:00
|
|
|
|
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 {
|
2002-03-21 17:09:55 +00:00
|
|
|
Params(string const & f = string(),
|
|
|
|
string const & p = string(),
|
2001-03-12 11:22:26 +00:00
|
|
|
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();
|
2003-03-05 11:33:35 +00:00
|
|
|
///
|
|
|
|
virtual dispatch_result localDispatch(FuncRequest const & cmd);
|
2000-06-12 11:27:15 +00:00
|
|
|
/// 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 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.
|
|
|
|
*/
|
2003-05-22 18:59:10 +00:00
|
|
|
virtual int latex(Buffer const *, std::ostream &, LatexRunParams const &,
|
|
|
|
bool fragile, 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
|
2002-06-18 15:44:30 +00:00
|
|
|
virtual int docbook(Buffer const *, std::ostream &, bool mixcont) 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; }
|
2002-03-21 17:09:55 +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-11-02 16:18:07 +00:00
|
|
|
///
|
2001-03-12 11:22:26 +00:00
|
|
|
void updateExternal() const;
|
2000-06-12 11:27:15 +00:00
|
|
|
|
2001-11-02 16:18:07 +00:00
|
|
|
/// update the file represented by the template
|
|
|
|
void updateExternal(string const &, Buffer const *) const;
|
|
|
|
|
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
|
2003-03-05 11:33:35 +00:00
|
|
|
Params const & params() const;
|
2000-06-12 11:27:15 +00:00
|
|
|
|
2003-03-05 11:33:35 +00:00
|
|
|
///
|
|
|
|
void setView(BufferView * bv) { view_ = bv; }
|
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
|
|
|
|
2003-03-05 11:33:35 +00:00
|
|
|
#include "mailinset.h"
|
|
|
|
|
|
|
|
class InsetExternalMailer : public MailInset {
|
|
|
|
public:
|
|
|
|
///
|
|
|
|
InsetExternalMailer(InsetExternal & inset);
|
|
|
|
///
|
2003-03-10 13:33:39 +00:00
|
|
|
virtual InsetBase & inset() const { return inset_; }
|
2003-03-05 11:33:35 +00:00
|
|
|
///
|
|
|
|
virtual string const & name() const { return name_; }
|
|
|
|
///
|
|
|
|
virtual string const inset2string() const;
|
|
|
|
///
|
|
|
|
static void string2params(string const &, InsetExternal::Params &);
|
|
|
|
///
|
2003-03-07 14:08:10 +00:00
|
|
|
static string const params2string(InsetExternal::Params const &);
|
2003-03-05 11:33:35 +00:00
|
|
|
private:
|
|
|
|
///
|
2003-03-07 14:08:10 +00:00
|
|
|
static string const name_;
|
2003-03-05 11:33:35 +00:00
|
|
|
///
|
|
|
|
InsetExternal & inset_;
|
|
|
|
};
|
|
|
|
|
2000-06-12 11:27:15 +00:00
|
|
|
#endif
|