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
|
|
|
|
|
2003-06-04 09:16:29 +00:00
|
|
|
#include "inset.h"
|
2001-03-12 11:22:26 +00:00
|
|
|
#include "ExternalTemplate.h"
|
2003-06-04 09:16:29 +00:00
|
|
|
#include "graphics/GraphicsTypes.h"
|
2000-06-12 11:27:15 +00:00
|
|
|
#include "LString.h"
|
2002-05-29 16:21:03 +00:00
|
|
|
|
2003-06-04 09:16:29 +00:00
|
|
|
#include <boost/scoped_ptr.hpp>
|
|
|
|
#include <boost/signals/trackable.hpp>
|
|
|
|
|
|
|
|
|
|
|
|
class GraphicInset;
|
|
|
|
|
2000-06-15 15:44:39 +00:00
|
|
|
///
|
2003-06-04 09:16:29 +00:00
|
|
|
class InsetExternal : public Inset, public boost::signals::trackable {
|
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 {
|
2003-06-04 09:16:29 +00:00
|
|
|
// Params(string const & f = string(),
|
|
|
|
// string const & p = string(),
|
|
|
|
// ExternalTemplate const & t = ExternalTemplate())
|
|
|
|
Params() : display(grfx::NoDisplay), lyxscale(100) {}
|
2001-03-12 11:22:26 +00:00
|
|
|
/// the filename
|
|
|
|
string filename;
|
|
|
|
/// the parameters of the current choice
|
|
|
|
string parameters;
|
|
|
|
/// the current template used
|
|
|
|
ExternalTemplate templ;
|
2003-06-04 09:16:29 +00:00
|
|
|
/// how the inset is displayed by LyX
|
|
|
|
grfx::DisplayType display;
|
|
|
|
/// The scale of the displayed graphic (If shown).
|
|
|
|
unsigned int lyxscale;
|
2001-03-12 11:22:26 +00:00
|
|
|
};
|
|
|
|
|
2000-06-12 11:27:15 +00:00
|
|
|
InsetExternal();
|
|
|
|
///
|
2003-06-04 09:16:29 +00:00
|
|
|
InsetExternal(InsetExternal const &);
|
|
|
|
///
|
2000-06-12 11:27:15 +00:00
|
|
|
virtual ~InsetExternal();
|
2003-03-05 11:33:35 +00:00
|
|
|
///
|
2003-05-26 09:13:55 +00:00
|
|
|
virtual dispatch_result localDispatch(FuncRequest const & cmd);
|
2003-06-04 09:16:29 +00:00
|
|
|
/** Would not be needed if editExternal were dispatched properly from
|
|
|
|
* the frontends rather than being invoked directly.
|
|
|
|
*/
|
|
|
|
virtual void cache(BufferView *) const;
|
|
|
|
///
|
|
|
|
void metrics(MetricsInfo &, Dimension &) const;
|
|
|
|
///
|
|
|
|
void draw(PainterInfo & pi, int x, int y) const;
|
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 22:44:30 +00:00
|
|
|
virtual int latex(Buffer const *, std::ostream &,
|
2003-05-23 08:59:47 +00:00
|
|
|
LatexRunParams const &) 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
|
|
|
///
|
2003-06-03 15:10:14 +00:00
|
|
|
virtual Inset * clone() 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
|
|
|
|
2003-06-04 09:16:29 +00:00
|
|
|
/// Set the inset parameters.
|
|
|
|
virtual void setParams(Params const &, string const & filepath);
|
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
|
|
|
|
2003-06-04 09:16:29 +00:00
|
|
|
/** update the file represented by the template.
|
|
|
|
If \param external_in_tmpdir == true, then the generated file is
|
|
|
|
place in the buffer's temporary directory.
|
|
|
|
*/
|
|
|
|
void updateExternal(string const &, Buffer const *,
|
|
|
|
bool external_in_tmpdir) const;
|
2001-11-02 16:18:07 +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
|
|
|
/// 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
|
|
|
|
2001-03-12 11:22:26 +00:00
|
|
|
private:
|
2003-06-04 09:16:29 +00:00
|
|
|
/** This method is connected to the graphics loader, so we are
|
|
|
|
* informed when the image has been loaded.
|
|
|
|
*/
|
|
|
|
void statusChanged();
|
2000-06-12 11:27:15 +00:00
|
|
|
|
2003-06-04 09:16:29 +00:00
|
|
|
/** Write the output for a specific file format
|
|
|
|
and generate any external data files.
|
|
|
|
If \param external_in_tmpdir == true, then the generated file is
|
|
|
|
place in the buffer's temporary directory.
|
|
|
|
*/
|
|
|
|
int write(string const & format, Buffer const *, std::ostream &,
|
|
|
|
bool external_in_tmpdir = false) const;
|
2000-06-12 11:27:15 +00:00
|
|
|
|
|
|
|
/// 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
|
|
|
/// the current params
|
2001-03-30 09:51:46 +00:00
|
|
|
Params params_;
|
2000-06-12 11:27:15 +00:00
|
|
|
|
|
|
|
/// A temp filename
|
2003-06-04 09:16:29 +00:00
|
|
|
mutable string tempname_;
|
|
|
|
|
|
|
|
/// The thing that actually draws the image on LyX's screen.
|
|
|
|
boost::scoped_ptr<GraphicInset> const graphic_;
|
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
|