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
|
2008-11-14 15:58:50 +00:00
|
|
|
* \author Herbert Voß
|
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"
|
2002-05-29 16:21:03 +00:00
|
|
|
|
2010-10-31 01:04:03 +00:00
|
|
|
#include <set>
|
|
|
|
|
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
|
|
|
|
2008-03-27 22:26:24 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// InsetGraphics
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
/// Used for images etc.
|
2008-09-19 21:18:18 +00:00
|
|
|
class InsetGraphics : public Inset
|
2008-03-27 22:26:24 +00:00
|
|
|
{
|
2000-02-29 02:19:17 +00:00
|
|
|
public:
|
2000-03-09 23:58:55 +00:00
|
|
|
///
|
2019-09-17 21:06:18 +00:00
|
|
|
explicit InsetGraphics(Buffer * buf);
|
2000-08-14 09:44:53 +00:00
|
|
|
///
|
|
|
|
~InsetGraphics();
|
2008-03-27 22:26:24 +00:00
|
|
|
|
|
|
|
///
|
|
|
|
static void string2params(std::string const & data,
|
|
|
|
Buffer const & buffer,
|
|
|
|
InsetGraphicsParams &);
|
|
|
|
///
|
|
|
|
static std::string params2string(InsetGraphicsParams const &,
|
|
|
|
Buffer const &);
|
2008-05-06 21:13:09 +00:00
|
|
|
|
2008-03-27 22:26:24 +00:00
|
|
|
/** Set the inset parameters, used by the GUIndependent dialog.
|
|
|
|
Return true of new params are different from what was so far.
|
|
|
|
*/
|
|
|
|
bool setParams(InsetGraphicsParams const & params);
|
|
|
|
|
2008-05-06 21:13:09 +00:00
|
|
|
InsetGraphicsParams getParams() const { return params_;}
|
2010-10-24 20:11:40 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
bool clickable(BufferView const &, int, int) const override { return true; }
|
2016-05-23 16:01:48 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
bool canPaintChange(BufferView const &) const override { return true; }
|
2018-01-21 03:59:12 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
InsetGraphics * asInsetGraphics() override { return this; }
|
2018-01-21 03:59:12 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
InsetGraphics const * asInsetGraphics() const override { return this; }
|
2008-05-06 21:13:09 +00:00
|
|
|
|
2008-03-15 04:48:31 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
bool isLabeled() const override { return true; }
|
2000-02-29 02:19:17 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
bool hasSettings() const override { return true; }
|
2000-02-29 02:19:17 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
void write(std::ostream &) const override;
|
2000-02-29 02:19:17 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
void read(Lexer & lex) override;
|
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
|
|
|
*/
|
2020-10-01 07:42:11 +00:00
|
|
|
void latex(otexstream &, OutputParams const &) const override;
|
2000-03-06 02:42:40 +00:00
|
|
|
///
|
2013-03-08 19:52:18 +00:00
|
|
|
int plaintext(odocstringstream & ods, OutputParams const & op,
|
2020-10-01 07:42:11 +00:00
|
|
|
size_t max_length = INT_MAX) const override;
|
2000-04-24 20:58:23 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
void docbook(XMLStream &, OutputParams const &) const override;
|
2009-11-14 14:00:18 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
docstring xhtml(XMLStream & os, OutputParams const &) const override;
|
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.
|
|
|
|
*/
|
2020-10-01 07:42:11 +00:00
|
|
|
void validate(LaTeXFeatures & features) const override;
|
2000-02-29 02:19:17 +00:00
|
|
|
/// returns LyX code associated with the inset. Used for TOC, ...)
|
2020-10-01 07:42:11 +00:00
|
|
|
InsetCode lyxCode() const override { return GRAPHICS_CODE; }
|
2013-03-22 19:09:59 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
docstring layoutName() const override { return from_ascii("Graphics"); }
|
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;
|
2020-01-15 14:54:47 +00:00
|
|
|
|
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
int topOffset(BufferView const *) const override { return 0; }
|
2020-01-15 14:54:47 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
int bottomOffset(BufferView const *) const override { return 0; }
|
2020-01-15 14:54:47 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
int leftOffset(BufferView const *) const override { return 0; }
|
2020-01-15 14:54:47 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
int rightOffset(BufferView const *) const override { return 0; }
|
2020-01-15 14:54:47 +00:00
|
|
|
|
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
void metrics(MetricsInfo &, Dimension &) const override;
|
2003-10-12 18:54:12 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
void draw(PainterInfo & pi, int x, int y) const override;
|
2003-11-04 12:36:59 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
bool showInsetDialog(BufferView * bv) const override;
|
2009-04-10 00:20:12 +00:00
|
|
|
///
|
2009-07-13 13:53:58 +00:00
|
|
|
void editGraphics(InsetGraphicsParams const &) const;
|
2005-04-22 08:57:22 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const override;
|
2008-03-11 10:27:33 +00:00
|
|
|
///
|
2015-09-27 06:05:00 +00:00
|
|
|
void addToToc(DocIterator const & di, bool output_active,
|
2020-10-01 07:42:11 +00:00
|
|
|
UpdateType utype, TocBackend & backend) const override;
|
2008-03-24 04:27:43 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
std::string contextMenuName() const override;
|
2010-05-22 02:00:41 +00:00
|
|
|
/// Force inset into LTR environment if surroundings are RTL
|
2020-10-01 07:42:11 +00:00
|
|
|
bool forceLTR(OutputParams const &) const override { return true; }
|
2003-10-17 18:01:15 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
void doDispatch(Cursor & cur, FuncRequest & cmd) override;
|
2008-03-27 22:26:24 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
Inset * clone() const override;
|
2000-10-12 10:46:06 +00:00
|
|
|
/// Get the status message, depends on the image loading status.
|
2008-03-27 22:26:24 +00:00
|
|
|
std::string statusMessage() const;
|
2018-06-24 18:06:40 +00:00
|
|
|
/// Get the output bounding box accounting for raster formats.
|
|
|
|
void outBoundingBox(graphics::BoundingBox &) const;
|
2001-02-08 13:06:55 +00:00
|
|
|
/// Create the options for the latex command.
|
2017-10-12 13:38:59 +00:00
|
|
|
std::string createLatexOptions(bool const ps) const;
|
2004-10-04 13:56:04 +00:00
|
|
|
/// Create length values for docbook export.
|
2008-03-27 22:26:24 +00:00
|
|
|
docstring toDocbookLength(Length const & len) const;
|
Run codespell on src/insets
Command was
codespell -w -i 3 -S Makefile.in -L mathed,afe,tthe,ue,fro,uint,larg,alph,te,thes,alle,Claus,pres,pass-thru src/insets/
2020-06-25 21:46:16 +00:00
|
|
|
/// Create the attributes for docbook export.
|
2008-03-27 22:26:24 +00:00
|
|
|
docstring createDocBookAttributes() const;
|
2001-02-08 13:06:55 +00:00
|
|
|
/// Convert the file if needed, and return the location of the file.
|
2009-11-14 14:00:18 +00:00
|
|
|
/// This version is for use with LaTeX-style output.
|
2008-02-27 20:43:16 +00:00
|
|
|
std::string prepareFile(OutputParams const &) const;
|
2009-11-14 14:00:18 +00:00
|
|
|
/// Convert the file if needed, and return the location of the file.
|
|
|
|
/// This version is for use with HTML-style output.
|
|
|
|
/// \return the new filename, relative to the location of the HTML file,
|
|
|
|
/// or an empty string on error.
|
|
|
|
std::string prepareHTMLFile(OutputParams const & runparams) const;
|
2019-12-28 12:43:17 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
OutputParams::CtObject CtObject(OutputParams const &) const override { return OutputParams::CT_OBJECT; }
|
2002-02-27 09:59:52 +00:00
|
|
|
|
2020-01-15 14:54:47 +00:00
|
|
|
private:
|
|
|
|
///
|
|
|
|
InsetGraphics(InsetGraphics 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;
|
2012-02-25 23:05:28 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
docstring toolTip(BufferView const & bv, int x, int y) const override;
|
2003-06-03 17:49:09 +00:00
|
|
|
/// The thing that actually draws the image on LyX's screen.
|
2008-09-19 21:18:18 +00:00
|
|
|
RenderGraphic * graphic_;
|
2000-02-29 02:19:17 +00:00
|
|
|
};
|
|
|
|
|
2008-05-27 12:06:34 +00:00
|
|
|
namespace graphics {
|
|
|
|
|
|
|
|
/// Saves the list of currently used groups in the document.
|
|
|
|
void getGraphicsGroups(Buffer const &, std::set<std::string> &);
|
|
|
|
|
2009-01-17 08:02:52 +00:00
|
|
|
/// how many members has the current group?
|
|
|
|
int countGroupMembers(Buffer const &, std::string const &);
|
|
|
|
|
2008-05-27 12:06:34 +00:00
|
|
|
/// Returns parameters of a given graphics group (except filename).
|
|
|
|
std::string getGroupParams(Buffer const &, std::string const &);
|
|
|
|
|
|
|
|
/** Synchronize all Graphics insets of the group.
|
|
|
|
Both groupId and params are taken from argument.
|
|
|
|
*/
|
2008-09-17 14:54:37 +00:00
|
|
|
void unifyGraphicsGroups(Buffer &, std::string const &);
|
2008-05-27 12:06:34 +00:00
|
|
|
InsetGraphics * getCurrentGraphicsInset(Cursor const &);
|
|
|
|
|
2017-07-23 11:11:54 +00:00
|
|
|
} // namespace graphics
|
2008-05-27 12:06:34 +00:00
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
} // namespace lyx
|
|
|
|
|
2008-03-27 22:26:24 +00:00
|
|
|
#endif // INSET_GRAPHICS_H
|