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
|
|
|
|
* Copyright 1995-2000 The LyX Team.
|
|
|
|
*
|
|
|
|
* ====================================================== */
|
|
|
|
|
|
|
|
#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
|
|
|
|
struct InsetExternalParams {
|
|
|
|
InsetExternalParams(string const & f = string(),
|
|
|
|
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
|
2000-09-14 17:53:12 +00:00
|
|
|
virtual string const EditMessage() const;
|
2000-06-12 11:27:15 +00:00
|
|
|
///
|
|
|
|
virtual void Edit(BufferView *, int x, int y, unsigned int button);
|
|
|
|
///
|
|
|
|
virtual EDITABLE Editable() const { return IS_EDITABLE; }
|
|
|
|
///
|
|
|
|
virtual void Write(Buffer const *, std::ostream &) const;
|
|
|
|
///
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
virtual int Latex(Buffer const *, std::ostream &, bool fragile,
|
|
|
|
bool free_spc) const;
|
2001-03-12 11:22:26 +00:00
|
|
|
/// write ASCII output to the ostream
|
2000-09-26 15:25:14 +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
|
2000-06-12 11:27:15 +00:00
|
|
|
virtual int Linuxdoc(Buffer const *, std::ostream &) const;
|
2001-03-12 11:22:26 +00:00
|
|
|
/// write DocBook output to the ostream
|
2000-06-12 11:27:15 +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.
|
|
|
|
virtual void Validate(LaTeXFeatures & features) const;
|
|
|
|
|
|
|
|
/// returns LyX code associated with the inset. Used for TOC, ...)
|
|
|
|
virtual Inset::Code LyxCode() const { return EXTERNAL_CODE; }
|
2001-03-12 11:22:26 +00:00
|
|
|
|
2000-06-12 11:27:15 +00:00
|
|
|
///
|
2000-10-10 11:50:43 +00:00
|
|
|
virtual Inset * Clone(Buffer const &) const;
|
2000-06-12 11:27:15 +00:00
|
|
|
|
|
|
|
/// returns the text of the button
|
2000-09-14 17:53:12 +00:00
|
|
|
virtual string const getScreenLabel() 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
|
|
|
|
virtual void setFromParams(InsetExternalParams 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
|
|
|
|
InsetExternalParams 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
|
|
|
|
BufferView * view;
|
2000-06-12 11:27:15 +00:00
|
|
|
|
2001-03-12 11:22:26 +00:00
|
|
|
/// the current params
|
|
|
|
InsetExternalParams params_;
|
2000-06-12 11:27:15 +00:00
|
|
|
|
|
|
|
/// A temp filename
|
|
|
|
string tempname;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|