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"
|
|
|
|
#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-05 22:46:49 +00:00
|
|
|
Params();
|
2003-06-11 11:01:34 +00:00
|
|
|
~Params();
|
2001-03-12 11:22:26 +00:00
|
|
|
/// the filename
|
|
|
|
string filename;
|
2003-06-11 14:30:04 +00:00
|
|
|
/// the current template used
|
|
|
|
string templatename;
|
2003-06-11 11:01:34 +00:00
|
|
|
/// The name of the tempfile used for manipulations.
|
|
|
|
string tempname;
|
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
|
|
|
///
|
|
|
|
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
|
|
|
|
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
|
|
|
|
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
|
|
|
/// 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
|
|
|
|
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
|
|
|
|
2003-06-04 09:16:29 +00:00
|
|
|
/// The thing that actually draws the image on LyX's screen.
|
2003-06-10 11:54:31 +00:00
|
|
|
boost::scoped_ptr<GraphicInset> const renderer_;
|
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
|