2000-02-29 02:19:17 +00:00
|
|
|
|
// -*- C++ -*-
|
2002-09-25 14:26:13 +00:00
|
|
|
|
/**
|
2007-04-25 01:24:38 +00:00
|
|
|
|
* \file InsetGraphics.h
|
2002-09-25 14:26:13 +00:00
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
2000-02-29 02:19:17 +00:00
|
|
|
|
*
|
2002-01-29 09:26:24 +00:00
|
|
|
|
* \author Baruch Even
|
2003-09-07 01:45:40 +00:00
|
|
|
|
* \author Herbert Vo<EFBFBD>
|
2002-09-25 14:26:13 +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-02-29 02:19:17 +00:00
|
|
|
|
|
|
|
|
|
#ifndef INSET_GRAPHICS_H
|
|
|
|
|
#define INSET_GRAPHICS_H
|
|
|
|
|
|
2007-04-29 13:39:47 +00:00
|
|
|
|
#include "Inset.h"
|
2007-04-25 01:24:38 +00:00
|
|
|
|
#include "InsetGraphicsParams.h"
|
|
|
|
|
#include "MailInset.h"
|
2002-05-29 16:21:03 +00:00
|
|
|
|
|
2002-06-26 16:57:59 +00:00
|
|
|
|
#include <boost/scoped_ptr.hpp>
|
2003-06-03 17:49:09 +00:00
|
|
|
|
#include <boost/signals/trackable.hpp>
|
2002-06-25 15:59:10 +00:00
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
|
|
2003-10-10 21:08:55 +00:00
|
|
|
|
class RenderGraphic;
|
2002-02-27 09:59:52 +00:00
|
|
|
|
class LaTeXFeatures;
|
2000-03-09 23:58:55 +00:00
|
|
|
|
|
2000-02-29 02:19:17 +00:00
|
|
|
|
///
|
2007-04-29 13:39:47 +00:00
|
|
|
|
class InsetGraphics : public Inset, public boost::signals::trackable {
|
2000-02-29 02:19:17 +00:00
|
|
|
|
public:
|
2000-03-09 23:58:55 +00:00
|
|
|
|
///
|
|
|
|
|
InsetGraphics();
|
2000-08-14 09:44:53 +00:00
|
|
|
|
///
|
|
|
|
|
~InsetGraphics();
|
2000-02-29 02:19:17 +00:00
|
|
|
|
///
|
2008-03-11 10:27:33 +00:00
|
|
|
|
bool isLabeled() const { return true; }
|
2007-09-21 20:39:47 +00:00
|
|
|
|
void metrics(MetricsInfo &, Dimension &) const;
|
2000-02-29 02:19:17 +00:00
|
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
|
EDITABLE editable() const;
|
2000-02-29 02:19:17 +00:00
|
|
|
|
///
|
2008-02-27 20:43:16 +00:00
|
|
|
|
void write(std::ostream &) const;
|
2000-02-29 02:19:17 +00:00
|
|
|
|
///
|
2008-02-27 20:43:16 +00:00
|
|
|
|
void read(Lexer & lex);
|
2000-07-31 12:30:10 +00:00
|
|
|
|
|
2000-02-29 02:19:17 +00:00
|
|
|
|
/** returns the number of rows (\n's) of generated tex code.
|
2000-09-14 17:53:12 +00:00
|
|
|
|
#fragile == true# means, that the inset should take care about
|
|
|
|
|
fragile commands by adding a #\protect# before.
|
2000-02-29 02:19:17 +00:00
|
|
|
|
*/
|
2008-02-27 20:43:16 +00:00
|
|
|
|
int latex(odocstream &, OutputParams const &) const;
|
2000-03-06 02:42:40 +00:00
|
|
|
|
///
|
2008-02-27 20:43:16 +00:00
|
|
|
|
int plaintext(odocstream &, OutputParams const &) const;
|
2000-04-24 20:58:23 +00:00
|
|
|
|
///
|
2008-02-27 20:43:16 +00:00
|
|
|
|
int docbook(odocstream &, OutputParams const &) const;
|
2000-03-09 23:58:55 +00:00
|
|
|
|
|
2000-07-31 12:30:10 +00:00
|
|
|
|
/** Tell LyX what the latex features you need i.e. what latex packages
|
2000-09-14 17:53:12 +00:00
|
|
|
|
you need to be included.
|
|
|
|
|
*/
|
2001-06-28 10:25:20 +00:00
|
|
|
|
void validate(LaTeXFeatures & features) const;
|
2000-02-29 02:19:17 +00:00
|
|
|
|
|
|
|
|
|
/// returns LyX code associated with the inset. Used for TOC, ...)
|
2007-10-13 09:04:52 +00:00
|
|
|
|
InsetCode lyxCode() const { return GRAPHICS_CODE; }
|
2000-08-14 09:44:53 +00:00
|
|
|
|
|
2000-09-14 17:53:12 +00:00
|
|
|
|
/** Set the inset parameters, used by the GUIndependent dialog.
|
|
|
|
|
Return true of new params are different from what was so far.
|
|
|
|
|
*/
|
2003-06-03 15:10:14 +00:00
|
|
|
|
bool setParams(InsetGraphicsParams const & params);
|
2000-07-31 12:30:10 +00:00
|
|
|
|
|
2000-08-14 09:44:53 +00:00
|
|
|
|
/// Get the inset parameters, used by the GUIndependent dialog.
|
2002-02-27 09:59:52 +00:00
|
|
|
|
InsetGraphicsParams const & params() const;
|
2003-10-12 18:54:12 +00:00
|
|
|
|
///
|
|
|
|
|
void draw(PainterInfo & pi, int x, int y) const;
|
2003-11-04 12:36:59 +00:00
|
|
|
|
///
|
2008-02-11 08:20:13 +00:00
|
|
|
|
void edit(Cursor & cur, bool front, EntryDirection entry_from);
|
2004-04-13 10:36:09 +00:00
|
|
|
|
///
|
|
|
|
|
void editGraphics(InsetGraphicsParams const &, Buffer const &) const;
|
2005-04-22 08:57:22 +00:00
|
|
|
|
///
|
2007-04-26 14:56:30 +00:00
|
|
|
|
bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;
|
2007-08-30 20:46:42 +00:00
|
|
|
|
/// all graphics can be embedded
|
2008-02-27 21:51:29 +00:00
|
|
|
|
void registerEmbeddedFiles(EmbeddedFileList &) const;
|
2007-09-12 14:27:47 +00:00
|
|
|
|
///
|
2008-02-27 21:51:29 +00:00
|
|
|
|
void updateEmbeddedFile(EmbeddedFile const &);
|
2008-03-11 10:27:33 +00:00
|
|
|
|
///
|
|
|
|
|
void addToToc(ParConstIterator const &) const;
|
|
|
|
|
|
2007-11-05 23:44:47 +00:00
|
|
|
|
/// Force inset into LTR environment if surroundings are RTL?
|
|
|
|
|
virtual bool forceLTR() const { return true; }
|
2003-10-17 18:01:15 +00:00
|
|
|
|
protected:
|
2004-11-23 23:04:52 +00:00
|
|
|
|
InsetGraphics(InsetGraphics const &);
|
2003-10-17 18:01:15 +00:00
|
|
|
|
///
|
2007-04-26 14:56:30 +00:00
|
|
|
|
virtual void doDispatch(Cursor & cur, FuncRequest & cmd);
|
2000-02-29 02:19:17 +00:00
|
|
|
|
private:
|
2003-03-07 18:44:57 +00:00
|
|
|
|
friend class InsetGraphicsMailer;
|
|
|
|
|
|
2007-08-30 18:03:17 +00:00
|
|
|
|
virtual Inset * clone() const;
|
2004-11-23 23:04:52 +00:00
|
|
|
|
|
2001-07-28 12:24:16 +00:00
|
|
|
|
/// Read the inset native format
|
2007-04-26 11:30:54 +00:00
|
|
|
|
void readInsetGraphics(Lexer & lex, std::string const & bufpath);
|
2002-03-21 17:09:55 +00:00
|
|
|
|
|
2000-10-12 10:46:06 +00:00
|
|
|
|
/// Get the status message, depends on the image loading status.
|
2003-10-06 15:43:21 +00:00
|
|
|
|
std::string const statusMessage() const;
|
2001-02-08 13:06:55 +00:00
|
|
|
|
/// Create the options for the latex command.
|
2003-10-06 15:43:21 +00:00
|
|
|
|
std::string const createLatexOptions() const;
|
2004-10-04 13:56:04 +00:00
|
|
|
|
/// Create length values for docbook export.
|
2007-04-28 12:58:49 +00:00
|
|
|
|
docstring const toDocbookLength(Length const & len) const;
|
2004-09-29 15:25:54 +00:00
|
|
|
|
/// Create the atributes for docbook export.
|
2006-10-21 19:40:29 +00:00
|
|
|
|
docstring const createDocBookAttributes() const;
|
2001-02-08 13:06:55 +00:00
|
|
|
|
/// Convert the file if needed, and return the location of the file.
|
2008-02-27 20:43:16 +00:00
|
|
|
|
std::string prepareFile(OutputParams const &) const;
|
2002-02-27 09:59:52 +00:00
|
|
|
|
|
|
|
|
|
///
|
|
|
|
|
InsetGraphicsParams params_;
|
|
|
|
|
|
2002-02-20 09:04:56 +00:00
|
|
|
|
/// holds the entity name that defines the graphics location (SGML).
|
2006-10-21 19:40:29 +00:00
|
|
|
|
docstring const graphic_label;
|
2002-02-27 09:59:52 +00:00
|
|
|
|
|
2003-06-03 17:49:09 +00:00
|
|
|
|
/// The thing that actually draws the image on LyX's screen.
|
2003-10-10 21:08:55 +00:00
|
|
|
|
boost::scoped_ptr<RenderGraphic> const graphic_;
|
2000-02-29 02:19:17 +00:00
|
|
|
|
};
|
|
|
|
|
|
2003-03-07 18:44:57 +00:00
|
|
|
|
|
|
|
|
|
class InsetGraphicsMailer : public MailInset {
|
|
|
|
|
public:
|
|
|
|
|
///
|
|
|
|
|
InsetGraphicsMailer(InsetGraphics & inset);
|
|
|
|
|
///
|
2007-04-29 13:39:47 +00:00
|
|
|
|
virtual Inset & inset() const { return inset_; }
|
2003-03-07 18:44:57 +00:00
|
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
|
virtual std::string const & name() const { return name_; }
|
2003-03-07 18:44:57 +00:00
|
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
|
virtual std::string const inset2string(Buffer const &) const;
|
2003-03-07 18:44:57 +00:00
|
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
|
static void string2params(std::string const & data,
|
2003-07-23 09:54:21 +00:00
|
|
|
|
Buffer const & buffer,
|
2003-07-21 21:51:17 +00:00
|
|
|
|
InsetGraphicsParams &);
|
2003-03-07 18:44:57 +00:00
|
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
|
static std::string const params2string(InsetGraphicsParams const &,
|
2003-07-23 09:54:21 +00:00
|
|
|
|
Buffer const &);
|
2003-03-07 18:44:57 +00:00
|
|
|
|
private:
|
|
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
|
static std::string const name_;
|
2003-03-07 18:44:57 +00:00
|
|
|
|
///
|
|
|
|
|
InsetGraphics & inset_;
|
|
|
|
|
};
|
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
} // namespace lyx
|
|
|
|
|
|
2002-03-21 17:09:55 +00:00
|
|
|
|
#endif
|