1999-09-27 18:44:28 +00:00
|
|
|
// -*- C++ -*-
|
2002-09-09 17:32:53 +00:00
|
|
|
/**
|
2007-04-25 01:24:38 +00:00
|
|
|
* \file InsetInclude.h
|
2002-09-09 17:32:53 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
1999-09-27 18:44:28 +00:00
|
|
|
*
|
2008-11-14 15:58:50 +00:00
|
|
|
* \author Lars Gullik Bjønnes
|
2007-10-23 18:51:04 +00:00
|
|
|
* \author Richard Heck (conversion to InsetCommand)
|
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-09 17:32:53 +00:00
|
|
|
*/
|
1999-09-27 18:44:28 +00:00
|
|
|
|
1999-10-02 16:21:10 +00:00
|
|
|
#ifndef INSET_INCLUDE_H
|
|
|
|
#define INSET_INCLUDE_H
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2007-10-23 15:02:15 +00:00
|
|
|
#include "InsetCommand.h"
|
2008-03-27 22:26:24 +00:00
|
|
|
|
2007-04-25 01:24:38 +00:00
|
|
|
#include "RenderButton.h"
|
2008-04-19 15:52:35 +00:00
|
|
|
|
2016-06-02 22:49:36 +00:00
|
|
|
#include "support/unique_ptr.h"
|
|
|
|
|
2003-06-12 08:52:36 +00:00
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
namespace lyx {
|
|
|
|
|
2010-10-31 00:31:57 +00:00
|
|
|
class BiblioInfo;
|
2000-07-27 08:55:59 +00:00
|
|
|
class Buffer;
|
2003-09-07 01:45:40 +00:00
|
|
|
class Dimension;
|
2010-10-31 00:31:57 +00:00
|
|
|
class InsetCommandParams;
|
2008-03-07 13:33:33 +00:00
|
|
|
class InsetLabel;
|
2005-01-19 15:03:31 +00:00
|
|
|
class LaTeXFeatures;
|
2003-10-10 21:08:55 +00:00
|
|
|
class RenderMonitoredPreview;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2010-10-31 00:31:57 +00:00
|
|
|
namespace support {
|
|
|
|
class FileNameList;
|
|
|
|
}
|
|
|
|
|
2002-09-09 17:32:53 +00:00
|
|
|
/// for including tex/lyx files
|
2007-10-23 15:02:15 +00:00
|
|
|
class InsetInclude : public InsetCommand {
|
2015-10-11 09:16:09 +00:00
|
|
|
// Disable assignment operator, since it is not used, and cannot be
|
|
|
|
// implemented consistently with the copy constructor, because
|
|
|
|
// include_label is const.
|
|
|
|
InsetInclude & operator=(InsetInclude const &);
|
1999-09-27 18:44:28 +00:00
|
|
|
public:
|
2001-03-14 10:57:39 +00:00
|
|
|
///
|
2009-11-08 16:10:34 +00:00
|
|
|
InsetInclude(Buffer * buf, InsetCommandParams const &);
|
2010-10-27 21:35:13 +00:00
|
|
|
///
|
2008-03-06 20:58:59 +00:00
|
|
|
~InsetInclude();
|
2001-03-14 10:57:39 +00:00
|
|
|
|
2010-10-27 21:35:13 +00:00
|
|
|
///
|
|
|
|
void setChildBuffer(Buffer * buffer);
|
|
|
|
/// \return the child buffer if the file is a LyX doc and could be loaded
|
|
|
|
Buffer * getChildBuffer() const;
|
|
|
|
|
|
|
|
/** Update the cache with all bibfiles in use of the child buffer
|
|
|
|
* (including bibfiles of grandchild documents).
|
|
|
|
* Does nothing if the child document is not loaded to prevent
|
|
|
|
* automatic loading of all child documents upon loading the master.
|
|
|
|
* \param buffer the Buffer containing this inset.
|
|
|
|
*/
|
|
|
|
void updateBibfilesCache();
|
|
|
|
|
|
|
|
/** Return the cache with all bibfiles in use of the child buffer
|
|
|
|
* (including bibfiles of grandchild documents).
|
|
|
|
* Return an empty vector if the child doc is not loaded.
|
|
|
|
* \param buffer the Buffer containing this inset.
|
|
|
|
*/
|
|
|
|
support::FileNameList const &
|
|
|
|
getBibfilesCache() const;
|
|
|
|
|
|
|
|
///
|
|
|
|
void updateCommand();
|
2015-05-03 21:55:19 +00:00
|
|
|
///
|
|
|
|
void write(std::ostream &) const;
|
2010-10-27 21:35:13 +00:00
|
|
|
|
|
|
|
/// \name Public functions inherited from Inset class
|
|
|
|
//@{
|
|
|
|
///
|
2008-03-07 13:33:33 +00:00
|
|
|
void setBuffer(Buffer & buffer);
|
2010-10-27 21:35:13 +00:00
|
|
|
///
|
2008-03-11 09:04:09 +00:00
|
|
|
bool isLabeled() const { return true; }
|
2002-08-01 17:28:59 +00:00
|
|
|
/// Override these InsetButton methods if Previewing
|
2007-09-21 20:39:47 +00:00
|
|
|
void metrics(MetricsInfo & mi, Dimension & dim) const;
|
2002-08-01 17:28:59 +00:00
|
|
|
///
|
2003-05-30 06:48:24 +00:00
|
|
|
void draw(PainterInfo & pi, int x, int y) const;
|
2003-10-21 13:04:14 +00:00
|
|
|
///
|
2008-03-05 00:21:05 +00:00
|
|
|
DisplayType display() const;
|
2003-05-26 09:13:55 +00:00
|
|
|
///
|
2007-10-13 09:04:52 +00:00
|
|
|
InsetCode lyxCode() const { return INCLUDE_CODE; }
|
2012-04-10 18:21:01 +00:00
|
|
|
///
|
|
|
|
docstring layoutName() const;
|
2010-10-27 21:35:13 +00:00
|
|
|
/** Fills \c key
|
2003-09-18 20:18:39 +00:00
|
|
|
* \param keys the list of bibkeys in the child buffer.
|
2007-08-16 01:59:20 +00:00
|
|
|
* \param it not used here
|
2003-09-18 20:18:39 +00:00
|
|
|
*/
|
2010-12-03 20:08:04 +00:00
|
|
|
void collectBibKeys(InsetIterator const &) const;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2009-04-22 20:55:13 +00:00
|
|
|
bool hasSettings() const { return true; }
|
2001-07-20 14:18:48 +00:00
|
|
|
///
|
2011-02-10 20:02:48 +00:00
|
|
|
void latex(otexstream &, OutputParams const &) const;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2013-03-08 19:52:18 +00:00
|
|
|
int plaintext(odocstringstream & ods, OutputParams const & op,
|
|
|
|
size_t max_length = INT_MAX) const;
|
2000-12-28 16:22:28 +00:00
|
|
|
///
|
2008-02-27 20:43:16 +00:00
|
|
|
int docbook(odocstream &, OutputParams const &) const;
|
2000-07-01 12:54:45 +00:00
|
|
|
///
|
2009-11-30 17:34:01 +00:00
|
|
|
docstring xhtml(XHTMLStream &, OutputParams const &) const;
|
2009-06-19 15:11:33 +00:00
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
void validate(LaTeXFeatures &) const;
|
2002-08-01 17:28:59 +00:00
|
|
|
///
|
2009-11-22 20:50:35 +00:00
|
|
|
void addPreview(DocIterator const &, graphics::PreviewLoader &) const;
|
2005-04-22 08:57:22 +00:00
|
|
|
///
|
2015-09-27 06:05:00 +00:00
|
|
|
void addToToc(DocIterator const & di, bool output_active,
|
2017-01-13 10:06:48 +00:00
|
|
|
UpdateType utype, TocBackend & backend) const;
|
2006-11-13 16:53:49 +00:00
|
|
|
///
|
2010-03-03 22:13:45 +00:00
|
|
|
void updateBuffer(ParIterator const &, UpdateType);
|
2008-01-08 16:35:43 +00:00
|
|
|
///
|
2011-10-29 14:48:55 +00:00
|
|
|
std::string contextMenuName() const;
|
2010-10-27 21:35:13 +00:00
|
|
|
//@}
|
|
|
|
|
|
|
|
/// \name Static public methods obligated for InsetCommand derived classes
|
|
|
|
//@{
|
|
|
|
///
|
2008-02-23 22:01:02 +00:00
|
|
|
static ParamInfo const & findInfo(std::string const &);
|
2007-10-25 04:13:56 +00:00
|
|
|
///
|
2008-03-27 22:26:24 +00:00
|
|
|
static std::string defaultCommand() { return "include"; }
|
2007-10-25 04:13:56 +00:00
|
|
|
///
|
|
|
|
static bool isCompatibleCommand(std::string const & s);
|
2010-10-27 21:35:13 +00:00
|
|
|
//@}
|
|
|
|
|
2003-10-17 18:01:15 +00:00
|
|
|
protected:
|
|
|
|
///
|
2010-10-27 21:35:13 +00:00
|
|
|
InsetInclude(InsetInclude const &);
|
2004-11-23 23:04:52 +00:00
|
|
|
|
2010-10-27 21:35:13 +00:00
|
|
|
private:
|
2003-10-10 21:08:55 +00:00
|
|
|
/** Slot receiving a signal that the external file has changed
|
|
|
|
* and the preview should be regenerated.
|
|
|
|
*/
|
|
|
|
void fileChanged() const;
|
2009-03-26 00:48:32 +00:00
|
|
|
/// \return loaded Buffer or zero if the file loading did not proceed.
|
|
|
|
Buffer * loadIfNeeded() const;
|
2008-04-27 18:03:21 +00:00
|
|
|
/// launch external application
|
|
|
|
void editIncluded(std::string const & file);
|
2010-10-27 21:35:13 +00:00
|
|
|
///
|
|
|
|
bool isChildIncluded() const;
|
|
|
|
|
|
|
|
/// \name Private functions inherited from Inset class
|
|
|
|
//@{
|
|
|
|
Inset * clone() const { return new InsetInclude(*this); }
|
|
|
|
///
|
|
|
|
void doDispatch(Cursor & cur, FuncRequest & cmd);
|
|
|
|
///
|
|
|
|
bool getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus &) const;
|
|
|
|
//@}
|
|
|
|
|
|
|
|
/// \name Private functions inherited from InsetCommand class
|
|
|
|
//@{
|
2003-09-19 10:16:33 +00:00
|
|
|
/// set the parameters
|
2010-10-27 21:35:13 +00:00
|
|
|
// FIXME:InsetCommmand::setParams is not virtual
|
2008-02-27 20:43:16 +00:00
|
|
|
void setParams(InsetCommandParams const & params);
|
2003-09-19 10:16:33 +00:00
|
|
|
/// get the text displayed on the button
|
2008-02-27 20:43:16 +00:00
|
|
|
docstring screenLabel() const;
|
2017-07-03 17:45:58 +00:00
|
|
|
//@}
|
|
|
|
|
2002-03-21 17:09:55 +00:00
|
|
|
/// holds the entity name that defines the file location (SGML)
|
2006-10-21 19:40:29 +00:00
|
|
|
docstring const include_label;
|
2002-08-01 17:28:59 +00:00
|
|
|
|
|
|
|
/// The pointer never changes although *preview_'s contents may.
|
2016-06-02 22:49:36 +00:00
|
|
|
unique_ptr<RenderMonitoredPreview> const preview_;
|
2003-06-02 10:03:27 +00:00
|
|
|
|
2017-07-03 17:45:58 +00:00
|
|
|
///
|
2008-11-24 12:45:18 +00:00
|
|
|
mutable bool failedtoload_;
|
2003-06-02 10:03:27 +00:00
|
|
|
/// cache
|
2003-06-12 08:52:36 +00:00
|
|
|
mutable bool set_label_;
|
2003-10-10 21:08:55 +00:00
|
|
|
mutable RenderButton button_;
|
2007-08-12 21:43:58 +00:00
|
|
|
mutable docstring listings_label_;
|
2008-03-07 13:33:33 +00:00
|
|
|
InsetLabel * label_;
|
2009-03-25 12:23:07 +00:00
|
|
|
mutable Buffer * child_buffer_;
|
1999-09-27 18:44:28 +00:00
|
|
|
};
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
} // namespace lyx
|
|
|
|
|
2008-03-27 22:26:24 +00:00
|
|
|
#endif // INSET_INCLUDE_H
|