2000-06-12 11:27:15 +00:00
|
|
|
// -*- C++ -*-
|
2002-09-25 14:26:13 +00:00
|
|
|
/**
|
2007-04-25 01:24:38 +00:00
|
|
|
* \file InsetExternal.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-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
|
|
|
|
|
2007-04-29 13:39:47 +00:00
|
|
|
#include "Inset.h"
|
2010-10-31 01:04:03 +00:00
|
|
|
|
2008-06-13 07:34:55 +00:00
|
|
|
#include "ExternalTemplate.h"
|
2003-09-30 13:51:00 +00:00
|
|
|
|
Rename files in src/support, step one.
src/support/package.h src/support/Package.h Package
src/support/package.C.in src/support/Package.C.in Package
src/support/path.h src/support/Path.h Path
src/support/fs_extras.h src/support/fs_extras.h NOCLASSES
src/support/RandomAccessList.h src/support/RandomAccessList.h RandomAccessList
src/support/lyxmanip.h src/support/lyxmanip.h NOCLASSES
src/support/rename.C src/support/rename.cpp NOCLASSES
src/support/abort.C src/support/abort.cpp NOCLASSES
src/support/lyxlib.h src/support/lyxlib.h NOCLASSES
src/support/ExceptionMessage.h src/support/ExceptionMessage.h ExceptionMessage
src/support/copy.C src/support/copy.cpp NOCLASSES
src/support/limited_stack.h src/support/limited_stack.h limited_stack
src/support/filefilterlist.C src/support/FileFilterList.cpp ['FileFilterList', 'Filter']
src/support/cow_ptr.h src/support/cow_ptr.h cow_ptr
src/support/os_unix.C src/support/os_unix.cpp NOCLASSES
src/support/socktools.h src/support/socktools.h NOCLASSES
src/support/forkedcontr.h src/support/ForkedcallsController.h ForkedcallsController
src/support/os.h src/support/os.h NOCLASSES
src/support/FileMonitor.h src/support/FileMonitor.h FileMonitor
src/support/copied_ptr.h src/support/copied_ptr.h copied_ptr
src/support/translator.h src/support/Translator.h Translator
src/support/filetools.C src/support/filetools.cpp NOCLASSES
src/support/unlink.C src/support/unlink.cpp NOCLASSES
src/support/os_win32.C src/support/os_win32.cpp GetFolderPath
src/support/lstrings.C src/support/lstrings.cpp NOCLASSES
src/support/qstring_helpers.C src/support/qstring_helpers.cpp NOCLASSES
src/support/getcwd.C src/support/getcwd.cpp NOCLASSES
src/support/systemcall.C src/support/Systemcall.cpp Systemcall
src/support/lyxalgo.h src/support/lyxalgo.h NOCLASSES
src/support/filefilterlist.h src/support/FileFilterList.h ['FileFilterList', 'Filter']
src/support/unicode.C src/support/unicode.cpp IconvProcessor
src/support/userinfo.C src/support/userinfo.cpp NOCLASSES
src/support/lyxtime.C src/support/lyxtime.cpp NOCLASSES
src/support/kill.C src/support/kill.cpp NOCLASSES
src/support/docstring.C src/support/docstring.cpp to_local8bit_failure
src/support/os_cygwin.C src/support/os_cygwin.cpp NOCLASSES
src/support/lyxsum.C src/support/lyxsum.cpp NOCLASSES
src/support/environment.C src/support/environment.cpp NOCLASSES
src/support/filetools.h src/support/filetools.h NOCLASSES
src/support/textutils.C src/support/textutils.cpp NOCLASSES
src/support/mkdir.C src/support/mkdir.cpp NOCLASSES
src/support/forkedcall.C src/support/Forkedcall.cpp ['ForkedProcess', 'Forkedcall']
src/support/tempname.C src/support/tempname.cpp NOCLASSES
src/support/os_win32.h src/support/os_win32.h GetFolderPath
src/support/types.h src/support/types.h NOCLASSES
src/support/lstrings.h src/support/lstrings.h NOCLASSES
src/support/forkedcallqueue.C src/support/ForkedCallQueue.cpp ForkedCallQueue
src/support/qstring_helpers.h src/support/qstring_helpers.h NOCLASSES
src/support/convert.C src/support/convert.cpp NOCLASSES
src/support/filename.C src/support/FileName.cpp ['FileName', 'DocFileName']
src/support/tests/convert.C src/support/tests/convert.cpp NOCLASSES
src/support/tests/filetools.C src/support/tests/filetools.cpp NOCLASSES
src/support/tests/lstrings.C src/support/tests/lstrings.cpp NOCLASSES
src/support/tests/boost.C src/support/tests/boost.cpp NOCLASSES
src/support/docstream.C src/support/docstream.cpp ['iconv_codecvt_facet_exception', 'idocfstream', 'odocfstream']
src/support/std_istream.h src/support/std_istream.h NOCLASSES
src/support/systemcall.h src/support/Systemcall.h Systemcall
src/support/chdir.C src/support/chdir.cpp NOCLASSES
src/support/std_ostream.h src/support/std_ostream.h NOCLASSES
src/support/unicode.h src/support/unicode.h IconvProcessor
src/support/path.C src/support/Path.cpp Path
src/support/fs_extras.C src/support/fs_extras.cpp NOCLASSES
src/support/userinfo.h src/support/userinfo.h NOCLASSES
src/support/lyxtime.h src/support/lyxtime.h NOCLASSES
src/support/docstring.h src/support/docstring.h to_local8bit_failure
src/support/debugstream.h src/support/debugstream.h basic_debugstream
src/support/environment.h src/support/environment.h NOCLASSES
src/support/textutils.h src/support/textutils.h NOCLASSES
src/support/forkedcall.h src/support/Forkedcall.h ['ForkedProcess', 'Forkedcall']
src/support/socktools.C src/support/socktools.cpp NOCLASSES
src/support/forkedcallqueue.h src/support/ForkedCallQueue.h ForkedCallQueue
src/support/forkedcontr.C src/support/ForkedcallsController.cpp ForkedcallsController
src/support/os.C src/support/os.cpp NOCLASSES
src/support/convert.h src/support/convert.h NOCLASSES
src/support/filename.h src/support/FileName.h ['FileName', 'DocFileName']
src/support/docstream.h src/support/docstream.h ['iconv_codecvt_facet_exception', 'idocfstream', 'odocfstream']
src/support/FileMonitor.C src/support/FileMonitor.cpp FileMonitor
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@18024 a592a061-630c-0410-9148-cb99ea01b6c8
2007-04-26 05:12:52 +00:00
|
|
|
#include "support/FileName.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>
|
|
|
|
|
|
|
|
|
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
|
|
|
|
2014-06-09 11:05:50 +00:00
|
|
|
namespace support {
|
|
|
|
class TempFile;
|
|
|
|
}
|
|
|
|
|
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 &);
|
2014-06-09 11:05:50 +00:00
|
|
|
support::FileName operator()() const;
|
2003-10-07 20:25:10 +00:00
|
|
|
private:
|
2014-06-09 11:05:50 +00:00
|
|
|
support::TempFile * tempfile_;
|
2003-10-07 20:25:10 +00:00
|
|
|
};
|
2003-06-04 09:16:29 +00:00
|
|
|
|
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;
|
2007-04-26 11:30:54 +00:00
|
|
|
bool read(Buffer const &, Lexer &);
|
2003-09-25 10:49:13 +00:00
|
|
|
|
2003-10-07 20:25:10 +00:00
|
|
|
/// The name of the tempfile used for manipulations.
|
2014-06-09 11:05:50 +00:00
|
|
|
support::FileName 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.
|
2008-04-20 03:08:11 +00:00
|
|
|
support::DocFileName filename;
|
2008-06-13 07:34:55 +00:00
|
|
|
/// If the inset is to be displayed by LyX.
|
|
|
|
bool display;
|
|
|
|
/// If the inset is to use the preview mechanism.
|
|
|
|
PreviewMode preview_mode;
|
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
|
|
|
|
|
|
|
///
|
2007-04-29 13:39:47 +00:00
|
|
|
class InsetExternal : public Inset, public boost::signals::trackable
|
2003-10-07 20:25:10 +00:00
|
|
|
{
|
|
|
|
public:
|
2009-11-08 15:53:21 +00:00
|
|
|
InsetExternal(Buffer *);
|
2000-06-12 11:27:15 +00:00
|
|
|
///
|
2008-02-27 20:43:16 +00:00
|
|
|
~InsetExternal();
|
2003-03-05 11:33:35 +00:00
|
|
|
///
|
2008-03-27 22:26:24 +00:00
|
|
|
static void string2params(std::string const &, Buffer const &,
|
|
|
|
InsetExternalParams &);
|
|
|
|
///
|
|
|
|
static std::string params2string(InsetExternalParams const &,
|
|
|
|
Buffer const &);
|
|
|
|
///
|
|
|
|
InsetExternalParams const & params() const;
|
|
|
|
///
|
|
|
|
void setParams(InsetExternalParams const &);
|
2008-12-21 01:53:47 +00:00
|
|
|
/// Update not loaded previews
|
|
|
|
void updatePreview();
|
2008-03-27 22:26:24 +00:00
|
|
|
/// \returns the number of rows (\n's) of generated code.
|
2011-02-10 20:02:48 +00:00
|
|
|
void latex(otexstream &, OutputParams const &) const;
|
2008-04-28 05:12:28 +00:00
|
|
|
///
|
2011-10-29 14:48:55 +00:00
|
|
|
std::string contextMenuName() const;
|
2010-10-24 19:25:36 +00:00
|
|
|
///
|
2012-10-14 12:34:46 +00:00
|
|
|
bool setMouseHover(BufferView const * bv, bool mouse_hover) const;
|
2010-10-24 20:11:40 +00:00
|
|
|
///
|
2010-10-24 21:46:28 +00:00
|
|
|
bool clickable(int, int) const { return true; }
|
2015-10-04 18:48:31 +00:00
|
|
|
///
|
|
|
|
void addToToc(DocIterator const & di, bool output_active,
|
|
|
|
UpdateType utype) const;
|
2008-03-27 22:26:24 +00:00
|
|
|
private:
|
|
|
|
///
|
|
|
|
InsetExternal(InsetExternal const &);
|
2008-03-15 04:48:31 +00:00
|
|
|
///
|
2008-02-27 20:43:16 +00:00
|
|
|
InsetCode lyxCode() const { return EXTERNAL_CODE; }
|
2003-10-07 20:25:10 +00:00
|
|
|
///
|
2009-04-22 20:55:13 +00:00
|
|
|
bool hasSettings() const { return true; }
|
2003-06-04 09:16:29 +00:00
|
|
|
///
|
2007-09-21 20:39:47 +00:00
|
|
|
void metrics(MetricsInfo &, Dimension &) const;
|
2003-06-04 09:16:29 +00:00
|
|
|
///
|
|
|
|
void draw(PainterInfo & pi, int x, int y) const;
|
2000-06-12 11:27:15 +00:00
|
|
|
///
|
2008-02-27 20:43:16 +00:00
|
|
|
void write(std::ostream &) const;
|
2000-06-12 11:27:15 +00:00
|
|
|
///
|
2008-02-27 20:43:16 +00:00
|
|
|
void read(Lexer & lex);
|
2003-10-07 20:25:10 +00:00
|
|
|
///
|
2013-03-08 19:52:18 +00:00
|
|
|
int plaintext(odocstringstream & ods, OutputParams const & op,
|
|
|
|
size_t max_length = INT_MAX) const;
|
2003-10-07 20:25:10 +00:00
|
|
|
///
|
2008-02-27 20:43:16 +00:00
|
|
|
int docbook(odocstream &, OutputParams const &) const;
|
2009-06-18 20:44:38 +00:00
|
|
|
/// For now, this does nothing. Someone who knows about this
|
|
|
|
/// should see what needs doing for XHTML output.
|
2009-11-21 23:26:10 +00:00
|
|
|
docstring xhtml(XHTMLStream &, OutputParams const &) const;
|
2003-10-07 20:25:10 +00:00
|
|
|
/// Update needed features for this inset.
|
2008-03-27 22:26:24 +00:00
|
|
|
void validate(LaTeXFeatures & features) const;
|
2003-10-22 22:26:47 +00:00
|
|
|
///
|
2009-11-22 20:50:35 +00:00
|
|
|
void addPreview(DocIterator const &, graphics::PreviewLoader &) const;
|
2003-11-04 12:36:59 +00:00
|
|
|
///
|
2009-04-10 00:20:12 +00:00
|
|
|
bool showInsetDialog(BufferView * bv) const;
|
|
|
|
///
|
2007-04-26 14:56:30 +00:00
|
|
|
bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;
|
2003-10-17 18:01:15 +00:00
|
|
|
///
|
2008-02-27 20:43:16 +00:00
|
|
|
void doDispatch(Cursor & cur, FuncRequest & cmd);
|
2008-03-05 00:21:05 +00:00
|
|
|
///
|
|
|
|
Inset * clone() const { return new InsetExternal(*this); }
|
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;
|
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_;
|
2010-10-24 19:25:36 +00:00
|
|
|
/// changes color of the button when mouse enters/leaves this inset
|
|
|
|
mutable std::map<BufferView const *, bool> mouse_hover_;
|
2000-06-12 11:27:15 +00:00
|
|
|
};
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
} // namespace lyx
|
|
|
|
|
2008-03-27 22:26:24 +00:00
|
|
|
#endif // INSET_EXTERNAL_H
|