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-25 01:24:38 +00:00
|
|
|
#include "Inset.h"
|
2003-10-07 22:59:58 +00:00
|
|
|
#include "ExternalTransforms.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"
|
|
|
|
#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>
|
|
|
|
|
2007-04-25 01:24:38 +00:00
|
|
|
#include "MailInset.h"
|
2006-10-21 00:16:43 +00:00
|
|
|
|
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 &);
|
2006-11-26 21:30:39 +00:00
|
|
|
support::FileName const & operator()() const { return tempname_; }
|
2003-10-07 20:25:10 +00:00
|
|
|
private:
|
2006-11-26 21:30:39 +00:00
|
|
|
support::FileName tempname_;
|
2003-10-07 20:25:10 +00:00
|
|
|
};
|
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;
|
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.
|
2006-11-26 21:30:39 +00:00
|
|
|
support::FileName 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
|
|
|
///
|
2006-11-28 15:15:49 +00:00
|
|
|
bool 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
|
|
|
///
|
2003-08-28 07:41:31 +00:00
|
|
|
virtual void write(Buffer const &, std::ostream &) const;
|
2000-06-12 11:27:15 +00:00
|
|
|
///
|
2007-04-26 11:30:54 +00:00
|
|
|
virtual void read(Buffer const &, Lexer & 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.
|
2007-02-18 10:57:23 +00:00
|
|
|
int latex(Buffer const &, odocstream &,
|
|
|
|
OutputParams const &) const;
|
2003-10-07 20:25:10 +00:00
|
|
|
///
|
2007-02-18 10:57:23 +00:00
|
|
|
int plaintext(Buffer const &, odocstream &,
|
|
|
|
OutputParams const &) const;
|
2003-10-07 20:25:10 +00:00
|
|
|
///
|
2007-02-18 10:57:23 +00:00
|
|
|
int docbook(Buffer const &, odocstream &,
|
|
|
|
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
|