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
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
* Full author contact details are available in file CREDITS.
|
2002-09-25 14:26:13 +00:00
|
|
|
*/
|
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"
|
2003-10-07 22:59:58 +00:00
|
|
|
#include "ExternalTransforms.h"
|
2003-09-30 13:51:00 +00:00
|
|
|
|
2003-07-23 09:17:04 +00:00
|
|
|
#include "support/filename.h"
|
2003-10-22 22:26:47 +00:00
|
|
|
#include "support/translator.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>
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
#include "mailinset.h"
|
|
|
|
|
2003-06-04 09:16:29 +00:00
|
|
|
|
2003-10-07 20:25:10 +00:00
|
|
|
/** No two InsetExternalParams variables can have the same temporary file.
|
2005-01-19 15:03:31 +00:00
|
|
|
* This class has copy-semantics but the copy constructor
|
2003-10-07 20:25:10 +00:00
|
|
|
* and assignment operator simply call the default constructor.
|
2005-01-19 15:03:31 +00:00
|
|
|
* Use of this class enables us to use the compiler-generated
|
2003-10-07 20:25:10 +00:00
|
|
|
* copy constructor and assignment operator for the
|
2005-01-19 15:03:31 +00:00
|
|
|
* InsetExternalParams class.
|
2003-10-07 20:25:10 +00:00
|
|
|
*/
|
|
|
|
namespace lyx {
|
2006-10-21 00:16:43 +00:00
|
|
|
|
2003-10-07 20:25:10 +00:00
|
|
|
namespace external {
|
|
|
|
|
2005-01-19 15:03:31 +00:00
|
|
|
class TempName {
|
|
|
|
public:
|
2003-10-07 20:25:10 +00:00
|
|
|
TempName();
|
|
|
|
TempName(TempName const &);
|
|
|
|
~TempName();
|
|
|
|
TempName & operator=(TempName const &);
|
|
|
|
std::string const & operator()() const { return tempname_; }
|
|
|
|
private:
|
|
|
|
std::string tempname_;
|
|
|
|
};
|
2003-06-04 09:16:29 +00:00
|
|
|
|
2003-10-22 22:26:47 +00:00
|
|
|
/// How is the image to be displayed on the LyX screen?
|
|
|
|
enum DisplayType {
|
|
|
|
DefaultDisplay,
|
|
|
|
MonochromeDisplay,
|
|
|
|
GrayscaleDisplay,
|
|
|
|
ColorDisplay,
|
|
|
|
PreviewDisplay,
|
|
|
|
NoDisplay
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/// The translator between the Display enum and corresponding lyx string.
|
|
|
|
Translator<DisplayType, std::string> const & displayTranslator();
|
|
|
|
|
2003-10-07 20:25:10 +00:00
|
|
|
} // namespace external
|
2003-09-25 10:49:13 +00:00
|
|
|
|
|
|
|
|
2003-10-07 20:25:10 +00:00
|
|
|
/// hold parameters settable from the GUI
|
2005-01-19 15:03:31 +00:00
|
|
|
class InsetExternalParams {
|
|
|
|
public:
|
2003-10-07 20:25:10 +00:00
|
|
|
InsetExternalParams();
|
2003-09-30 13:51:00 +00:00
|
|
|
|
2003-10-07 20:25:10 +00:00
|
|
|
void write(Buffer const &, std::ostream &) const;
|
|
|
|
bool read(Buffer const &, LyXLex &);
|
2003-09-25 10:49:13 +00:00
|
|
|
|
2003-10-07 20:25:10 +00:00
|
|
|
/// The name of the tempfile used for manipulations.
|
|
|
|
std::string const & tempname() const { return tempname_(); }
|
2003-09-25 10:49:13 +00:00
|
|
|
|
2003-10-07 20:25:10 +00:00
|
|
|
/// The template currently in use.
|
|
|
|
void settemplate(std::string const &);
|
|
|
|
std::string const & templatename() const { return templatename_; }
|
2003-09-25 10:49:13 +00:00
|
|
|
|
2003-10-07 20:25:10 +00:00
|
|
|
/// The external file.
|
2006-11-18 12:49:47 +00:00
|
|
|
support::DocFileName filename;
|
2003-10-07 20:25:10 +00:00
|
|
|
/// How the inset is to be displayed by LyX.
|
2006-10-21 00:16:43 +00:00
|
|
|
external::DisplayType display;
|
2003-10-07 20:25:10 +00:00
|
|
|
/// The scale of the displayed graphic (if shown).
|
|
|
|
unsigned int lyxscale;
|
2001-03-12 11:22:26 +00:00
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
external::ClipData clipdata;
|
|
|
|
external::ExtraData extradata;
|
|
|
|
external::ResizeData resizedata;
|
|
|
|
external::RotationData rotationdata;
|
2003-10-07 22:59:58 +00:00
|
|
|
|
2003-12-11 11:16:19 +00:00
|
|
|
/** if \c true, simply output the filename, maybe wrapped in a
|
|
|
|
* box, rather than generate and display the image etc.
|
|
|
|
*/
|
|
|
|
bool draft;
|
|
|
|
|
2003-10-07 20:25:10 +00:00
|
|
|
private:
|
2006-10-21 00:16:43 +00:00
|
|
|
external::TempName tempname_;
|
2003-10-07 20:25:10 +00:00
|
|
|
std::string templatename_;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2003-10-10 21:08:55 +00:00
|
|
|
class RenderBase;
|
2003-10-07 20:25:10 +00:00
|
|
|
|
|
|
|
///
|
|
|
|
class InsetExternal : public InsetOld, public boost::signals::trackable
|
|
|
|
{
|
|
|
|
public:
|
2000-06-12 11:27:15 +00:00
|
|
|
InsetExternal();
|
|
|
|
///
|
|
|
|
virtual ~InsetExternal();
|
2003-03-05 11:33:35 +00:00
|
|
|
///
|
2004-11-25 19:13:07 +00:00
|
|
|
virtual InsetBase::Code lyxCode() const { return EXTERNAL_CODE; }
|
2003-10-07 20:25:10 +00:00
|
|
|
///
|
|
|
|
virtual EDITABLE editable() const { return IS_EDITABLE; }
|
|
|
|
|
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
|
|
|
///
|
2003-08-28 07:41:31 +00:00
|
|
|
virtual void write(Buffer const &, std::ostream &) const;
|
2000-06-12 11:27:15 +00:00
|
|
|
///
|
2003-08-28 07:41:31 +00:00
|
|
|
virtual void read(Buffer const &, LyXLex & lex);
|
2001-03-12 11:22:26 +00:00
|
|
|
|
2003-10-07 20:25:10 +00:00
|
|
|
/// \returns the number of rows (\n's) of generated code.
|
2006-10-21 00:16:43 +00:00
|
|
|
virtual int latex(Buffer const &, odocstream &,
|
2003-11-05 12:06:20 +00:00
|
|
|
OutputParams const &) const;
|
2003-10-07 20:25:10 +00:00
|
|
|
///
|
2006-10-21 00:16:43 +00:00
|
|
|
virtual int plaintext(Buffer const &, odocstream &,
|
2003-11-05 12:06:20 +00:00
|
|
|
OutputParams const &) const;
|
2003-10-07 20:25:10 +00:00
|
|
|
///
|
2006-10-21 00:16:43 +00:00
|
|
|
virtual int docbook(Buffer const &, odocstream &,
|
2003-11-05 12:06:20 +00:00
|
|
|
OutputParams const &) const;
|
2001-03-12 11:22:26 +00:00
|
|
|
|
2003-10-07 20:25:10 +00:00
|
|
|
/// Update 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
|
|
|
|
|
|
|
///
|
2003-10-07 20:25:10 +00:00
|
|
|
InsetExternalParams const & params() const;
|
2004-02-13 13:51:12 +00:00
|
|
|
///
|
2003-10-07 20:25:10 +00:00
|
|
|
void setParams(InsetExternalParams const &, Buffer const &);
|
2003-10-22 22:26:47 +00:00
|
|
|
///
|
2006-10-21 00:16:43 +00:00
|
|
|
void addPreview(graphics::PreviewLoader &) const;
|
2003-11-04 12:36:59 +00:00
|
|
|
///
|
2004-02-13 13:51:12 +00:00
|
|
|
void edit(LCursor & cur, bool left);
|
2005-04-22 08:57:22 +00:00
|
|
|
///
|
|
|
|
bool getStatus(LCursor &, FuncRequest const &, FuncStatus &) const;
|
2003-10-22 22:26:47 +00:00
|
|
|
|
2003-10-17 18:01:15 +00:00
|
|
|
protected:
|
2004-11-23 23:04:52 +00:00
|
|
|
InsetExternal(InsetExternal const &);
|
2003-10-17 18:01:15 +00:00
|
|
|
///
|
2004-11-24 21:58:42 +00:00
|
|
|
virtual void doDispatch(LCursor & cur, FuncRequest & cmd);
|
2001-03-12 11:22:26 +00:00
|
|
|
private:
|
2004-11-23 23:04:52 +00:00
|
|
|
virtual std::auto_ptr<InsetBase> doClone() const;
|
|
|
|
|
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.
|
|
|
|
*/
|
2003-10-09 19:27:07 +00:00
|
|
|
void statusChanged() const;
|
2000-06-12 11:27:15 +00:00
|
|
|
|
2003-10-22 22:26:47 +00:00
|
|
|
/** Slot receiving a signal that the external file has changed
|
|
|
|
* and the preview should be regenerated.
|
|
|
|
*/
|
|
|
|
void fileChanged() const;
|
|
|
|
|
2003-10-07 20:25:10 +00:00
|
|
|
/// The current params
|
|
|
|
InsetExternalParams params_;
|
2003-06-04 09:16:29 +00:00
|
|
|
/// The thing that actually draws the image on LyX's screen.
|
2003-10-10 21:08:55 +00:00
|
|
|
boost::scoped_ptr<RenderBase> 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
|
|
|
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
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
virtual std::string const & name() const { return name_; }
|
2003-03-05 11:33:35 +00:00
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
virtual std::string const inset2string(Buffer const &) const;
|
2003-03-05 11:33:35 +00:00
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
static void string2params(std::string const &, Buffer const &,
|
2003-10-07 20:25:10 +00:00
|
|
|
InsetExternalParams &);
|
2003-03-05 11:33:35 +00:00
|
|
|
///
|
2003-10-07 20:25:10 +00:00
|
|
|
static std::string const params2string(InsetExternalParams const &,
|
|
|
|
Buffer const &);
|
2003-03-05 11:33:35 +00:00
|
|
|
private:
|
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
static std::string const name_;
|
2003-03-05 11:33:35 +00:00
|
|
|
///
|
|
|
|
InsetExternal & inset_;
|
|
|
|
};
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
} // namespace lyx
|
|
|
|
|
2000-06-12 11:27:15 +00:00
|
|
|
#endif
|