1999-09-27 18:44:28 +00:00
|
|
|
// -*- C++ -*-
|
2003-05-22 18:59:10 +00:00
|
|
|
/**
|
2007-04-26 04:41:58 +00:00
|
|
|
* \file Buffer.h
|
2003-05-22 18:59:10 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
2002-03-21 16:55:34 +00:00
|
|
|
*
|
2008-11-14 15:58:50 +00:00
|
|
|
* \author Lars Gullik Bjønnes
|
2000-02-04 09:38:32 +00:00
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
* Full author contact details are available in file CREDITS.
|
2003-05-22 18:59:10 +00:00
|
|
|
*/
|
2002-03-21 16:55:34 +00:00
|
|
|
|
1999-11-04 01:40:20 +00:00
|
|
|
#ifndef BUFFER_H
|
|
|
|
#define BUFFER_H
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2010-01-20 19:42:12 +00:00
|
|
|
#include "OutputEnums.h"
|
2009-04-06 12:12:06 +00:00
|
|
|
|
2007-10-13 09:11:10 +00:00
|
|
|
#include "insets/InsetCode.h"
|
|
|
|
|
2007-11-01 22:17:22 +00:00
|
|
|
#include "support/strfwd.h"
|
2007-10-19 14:32:33 +00:00
|
|
|
#include "support/types.h"
|
2000-04-08 17:02:02 +00:00
|
|
|
|
2009-07-09 09:48:34 +00:00
|
|
|
#include <list>
|
2009-11-08 18:47:33 +00:00
|
|
|
#include <set>
|
2006-04-15 11:46:17 +00:00
|
|
|
#include <string>
|
2003-09-06 18:38:02 +00:00
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
namespace lyx {
|
|
|
|
|
2008-04-25 20:03:03 +00:00
|
|
|
class BiblioInfo;
|
2003-09-09 11:24:33 +00:00
|
|
|
class BufferParams;
|
2008-11-16 21:28:06 +00:00
|
|
|
class BufferSet;
|
2009-04-06 12:12:06 +00:00
|
|
|
class DispatchResult;
|
2007-12-21 20:42:46 +00:00
|
|
|
class DocIterator;
|
2009-04-04 16:40:47 +00:00
|
|
|
class docstring_list;
|
2007-06-15 13:13:49 +00:00
|
|
|
class ErrorList;
|
2003-09-21 23:00:47 +00:00
|
|
|
class FuncRequest;
|
2009-04-06 12:12:06 +00:00
|
|
|
class FuncStatus;
|
2007-04-29 13:39:47 +00:00
|
|
|
class Inset;
|
2008-03-02 15:27:35 +00:00
|
|
|
class InsetLabel;
|
2010-03-31 20:06:16 +00:00
|
|
|
class InsetRef;
|
2007-04-29 18:17:15 +00:00
|
|
|
class Font;
|
2007-10-20 10:51:13 +00:00
|
|
|
class Format;
|
2007-04-26 11:30:54 +00:00
|
|
|
class Lexer;
|
2007-04-29 23:33:02 +00:00
|
|
|
class Text;
|
2003-09-09 11:24:33 +00:00
|
|
|
class LyXVC;
|
1999-09-27 18:44:28 +00:00
|
|
|
class LaTeXFeatures;
|
2000-10-10 12:36:36 +00:00
|
|
|
class Language;
|
2004-04-13 06:27:29 +00:00
|
|
|
class MacroData;
|
2008-02-23 18:11:35 +00:00
|
|
|
class MacroNameSet;
|
2008-03-26 12:55:36 +00:00
|
|
|
class MacroSet;
|
2004-01-26 10:13:15 +00:00
|
|
|
class OutputParams;
|
2007-11-01 11:13:07 +00:00
|
|
|
class Paragraph;
|
2002-11-08 01:08:27 +00:00
|
|
|
class ParConstIterator;
|
2004-03-25 09:16:36 +00:00
|
|
|
class ParIterator;
|
2007-04-26 08:30:11 +00:00
|
|
|
class ParagraphList;
|
2003-09-04 03:54:04 +00:00
|
|
|
class TeXErrors;
|
2003-09-09 11:24:33 +00:00
|
|
|
class TexRow;
|
2006-11-11 00:35:14 +00:00
|
|
|
class TocBackend;
|
2003-09-06 18:38:02 +00:00
|
|
|
class Undo;
|
2009-04-04 16:40:47 +00:00
|
|
|
class WordLangTuple;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2007-10-02 09:00:08 +00:00
|
|
|
namespace frontend {
|
2007-10-02 18:27:20 +00:00
|
|
|
class GuiBufferDelegate;
|
2007-10-02 09:00:08 +00:00
|
|
|
class WorkAreaManager;
|
|
|
|
}
|
2001-08-03 18:28:11 +00:00
|
|
|
|
2007-12-05 10:32:49 +00:00
|
|
|
namespace support {
|
|
|
|
class FileName;
|
2008-04-19 15:52:35 +00:00
|
|
|
class FileNameList;
|
2007-12-05 10:32:49 +00:00
|
|
|
}
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
/** The buffer object.
|
2005-01-31 16:29:48 +00:00
|
|
|
* This is the buffer object. It contains all the informations about
|
|
|
|
* a document loaded into LyX.
|
2007-04-29 23:33:02 +00:00
|
|
|
* The buffer object owns the Text (wrapped in an InsetText), which
|
2005-01-31 16:29:48 +00:00
|
|
|
* contains the individual paragraphs of the document.
|
|
|
|
*
|
2005-04-26 11:12:20 +00:00
|
|
|
*
|
2005-01-31 16:29:48 +00:00
|
|
|
* I am not sure if the class is complete or
|
|
|
|
* minimal, probably not.
|
2008-11-14 15:58:50 +00:00
|
|
|
* \author Lars Gullik Bjønnes
|
2007-10-02 18:27:20 +00:00
|
|
|
*/
|
1999-09-27 18:44:28 +00:00
|
|
|
class Buffer {
|
|
|
|
public:
|
2001-02-16 09:25:43 +00:00
|
|
|
/// What type of log will \c getLogName() return?
|
2001-02-09 15:54:30 +00:00
|
|
|
enum LogType {
|
2001-02-16 09:25:43 +00:00
|
|
|
latexlog, ///< LaTeX log
|
|
|
|
buildlog ///< Literate build log
|
2001-02-09 15:54:30 +00:00
|
|
|
};
|
|
|
|
|
2007-01-13 18:29:50 +00:00
|
|
|
/// Result of \c readFile()
|
|
|
|
enum ReadStatus {
|
|
|
|
failure, ///< The file could not be read
|
|
|
|
success, ///< The file could not be read
|
|
|
|
wrongversion ///< The version of the file does not match ours
|
|
|
|
};
|
|
|
|
|
2007-11-30 09:49:35 +00:00
|
|
|
|
2008-10-13 11:25:37 +00:00
|
|
|
/// Method to check if a file is externally modified, used by
|
2007-08-09 20:46:22 +00:00
|
|
|
/// isExternallyModified()
|
|
|
|
/**
|
|
|
|
* timestamp is fast but inaccurate. For example, the granularity
|
|
|
|
* of timestamp on a FAT filesystem is 2 second. Also, various operations
|
|
|
|
* may touch the timestamp of a file even when its content is unchanged.
|
|
|
|
*
|
2008-10-13 11:25:37 +00:00
|
|
|
* checksum is accurate but slow, which can be a problem when it is
|
2007-08-09 20:46:22 +00:00
|
|
|
* frequently used, or used for a large file on a slow (network) file
|
|
|
|
* system.
|
2007-11-30 09:49:35 +00:00
|
|
|
*
|
|
|
|
* FIXME: replace this method with support/FileMonitor.
|
2007-08-09 20:46:22 +00:00
|
|
|
*/
|
|
|
|
enum CheckMethod {
|
2007-11-30 09:23:44 +00:00
|
|
|
checksum_method, ///< Use file checksum
|
2007-08-09 20:46:22 +00:00
|
|
|
timestamp_method, ///< Use timestamp, and checksum if timestamp has changed
|
|
|
|
};
|
2008-10-13 11:25:37 +00:00
|
|
|
|
2009-03-26 00:48:32 +00:00
|
|
|
///
|
|
|
|
enum UpdateScope {
|
|
|
|
UpdateMaster,
|
|
|
|
UpdateChildOnly
|
|
|
|
};
|
|
|
|
|
2008-11-17 11:46:07 +00:00
|
|
|
/// Constructor
|
2009-12-18 22:51:06 +00:00
|
|
|
explicit Buffer(std::string const & file, bool readonly = false,
|
|
|
|
Buffer const * cloned_buffer = 0);
|
2002-03-21 16:55:34 +00:00
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
/// Destructor
|
1999-09-27 18:44:28 +00:00
|
|
|
~Buffer();
|
|
|
|
|
2009-12-13 21:00:46 +00:00
|
|
|
///
|
|
|
|
Buffer * clone() const;
|
2009-12-18 22:59:59 +00:00
|
|
|
///
|
|
|
|
bool isClone() const;
|
2009-12-13 21:00:46 +00:00
|
|
|
|
2000-08-07 20:58:24 +00:00
|
|
|
/** High-level interface to buffer functionality.
|
2009-04-06 12:12:06 +00:00
|
|
|
This function parses a command string and executes it.
|
1999-12-16 06:43:25 +00:00
|
|
|
*/
|
2009-04-06 12:12:06 +00:00
|
|
|
void dispatch(std::string const & command, DispatchResult & result);
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
|
|
/// Maybe we know the function already by number...
|
2009-04-06 12:12:06 +00:00
|
|
|
void dispatch(FuncRequest const & func, DispatchResult & result);
|
|
|
|
|
|
|
|
/// Can this function be exectued?
|
|
|
|
/// \return true if we made a decision
|
|
|
|
bool getStatus(FuncRequest const & cmd, FuncStatus & flag);
|
1999-12-10 00:07:59 +00:00
|
|
|
|
2007-01-13 18:29:50 +00:00
|
|
|
/// read a new document from a string
|
|
|
|
bool readString(std::string const &);
|
2003-03-12 05:46:35 +00:00
|
|
|
/// load a new file
|
2006-12-17 12:12:17 +00:00
|
|
|
bool readFile(support::FileName const & filename);
|
2003-09-02 08:26:20 +00:00
|
|
|
|
2003-03-12 02:39:12 +00:00
|
|
|
/// read the header, returns number of unknown tokens
|
2007-04-26 11:30:54 +00:00
|
|
|
int readHeader(Lexer & lex);
|
2003-03-12 02:39:12 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
/** Reads a file without header.
|
2001-02-16 09:25:43 +00:00
|
|
|
\param par if != 0 insert the file.
|
2009-02-04 09:52:10 +00:00
|
|
|
\return \c true if file is not completely read.
|
2000-08-07 20:58:24 +00:00
|
|
|
*/
|
2007-04-26 11:30:54 +00:00
|
|
|
bool readDocument(Lexer &);
|
2003-03-12 02:39:12 +00:00
|
|
|
|
2001-07-09 09:16:00 +00:00
|
|
|
///
|
2008-02-09 15:23:05 +00:00
|
|
|
DocIterator getParFromID(int id) const;
|
2003-05-05 17:28:21 +00:00
|
|
|
/// do we have a paragraph with this id?
|
|
|
|
bool hasParWithID(int id) const;
|
2003-03-12 05:46:35 +00:00
|
|
|
|
2007-10-02 09:00:08 +00:00
|
|
|
///
|
2007-10-02 14:39:48 +00:00
|
|
|
frontend::WorkAreaManager & workAreaManager() const;
|
2007-10-02 09:00:08 +00:00
|
|
|
|
2001-02-16 09:25:43 +00:00
|
|
|
/** Save file.
|
2000-02-22 00:36:17 +00:00
|
|
|
Takes care of auto-save files and backup file if requested.
|
2001-02-16 09:25:43 +00:00
|
|
|
Returns \c true if the save is successful, \c false otherwise.
|
2000-02-22 00:36:17 +00:00
|
|
|
*/
|
2000-03-20 14:49:54 +00:00
|
|
|
bool save() const;
|
2002-03-21 16:55:34 +00:00
|
|
|
|
2007-01-13 18:29:50 +00:00
|
|
|
/// Write document to stream. Returns \c false if unsuccesful.
|
|
|
|
bool write(std::ostream &) const;
|
2009-08-15 16:34:54 +00:00
|
|
|
/// save emergency file
|
|
|
|
/// \return a status message towards the user.
|
|
|
|
docstring emergencyWrite();
|
2001-02-16 09:25:43 +00:00
|
|
|
/// Write file. Returns \c false if unsuccesful.
|
2006-11-30 16:59:50 +00:00
|
|
|
bool writeFile(support::FileName const &) const;
|
2002-03-21 16:55:34 +00:00
|
|
|
|
2009-11-24 11:12:23 +00:00
|
|
|
/// Loads LyX file \c filename into buffer, * and return success
|
2007-10-21 10:50:56 +00:00
|
|
|
bool loadLyXFile(support::FileName const & s);
|
2010-01-08 02:15:56 +00:00
|
|
|
/// Reloads the LyX file
|
|
|
|
bool reload();
|
2007-10-21 10:50:56 +00:00
|
|
|
|
|
|
|
/// Fill in the ErrorList with the TeXErrors
|
|
|
|
void bufferErrors(TeXErrors const &, ErrorList &) const;
|
|
|
|
|
2007-01-09 19:25:40 +00:00
|
|
|
/// Just a wrapper for writeLaTeXSource, first creating the ofstream.
|
2006-12-04 15:46:57 +00:00
|
|
|
bool makeLaTeXFile(support::FileName const & filename,
|
2003-10-06 15:43:21 +00:00
|
|
|
std::string const & original_path,
|
2003-11-05 12:06:20 +00:00
|
|
|
OutputParams const &,
|
2003-07-26 21:37:10 +00:00
|
|
|
bool output_preamble = true,
|
2007-11-30 17:41:27 +00:00
|
|
|
bool output_body = true) const;
|
2007-01-09 19:25:40 +00:00
|
|
|
/** Export the buffer to LaTeX.
|
2007-01-13 14:36:54 +00:00
|
|
|
If \p os is a file stream, and params().inputenc is "auto" or
|
|
|
|
"default", and the buffer contains text in different languages
|
|
|
|
with more than one encoding, then this method will change the
|
|
|
|
encoding associated to \p os. Therefore you must not call this
|
|
|
|
method with a string stream if the output is supposed to go to a
|
|
|
|
file. \code
|
2008-11-16 12:21:29 +00:00
|
|
|
ofdocstream ofs;
|
2007-01-09 19:25:40 +00:00
|
|
|
ofs.open("test.tex");
|
|
|
|
writeLaTeXSource(ofs, ...);
|
|
|
|
ofs.close();
|
|
|
|
\endcode is NOT equivalent to \code
|
|
|
|
odocstringstream oss;
|
|
|
|
writeLaTeXSource(oss, ...);
|
2008-11-16 12:21:29 +00:00
|
|
|
ofdocstream ofs;
|
2007-01-09 19:25:40 +00:00
|
|
|
ofs.open("test.tex");
|
|
|
|
ofs << oss.str();
|
|
|
|
ofs.close();
|
|
|
|
\endcode
|
|
|
|
*/
|
2006-10-21 00:16:43 +00:00
|
|
|
void writeLaTeXSource(odocstream & os,
|
2003-10-06 15:43:21 +00:00
|
|
|
std::string const & original_path,
|
2003-11-05 12:06:20 +00:00
|
|
|
OutputParams const &,
|
2003-07-26 21:37:10 +00:00
|
|
|
bool output_preamble = true,
|
2007-11-30 17:41:27 +00:00
|
|
|
bool output_body = true) const;
|
2001-11-26 11:08:43 +00:00
|
|
|
///
|
2006-12-04 15:46:57 +00:00
|
|
|
void makeDocBookFile(support::FileName const & filename,
|
2003-11-05 12:06:20 +00:00
|
|
|
OutputParams const & runparams_in,
|
2007-11-30 17:41:27 +00:00
|
|
|
bool only_body = false) const;
|
2006-08-04 13:59:12 +00:00
|
|
|
///
|
2006-10-21 00:16:43 +00:00
|
|
|
void writeDocBookSource(odocstream & os, std::string const & filename,
|
2006-08-04 13:59:12 +00:00
|
|
|
OutputParams const & runparams_in,
|
2007-11-30 17:41:27 +00:00
|
|
|
bool only_body = false) const;
|
2009-06-05 17:44:35 +00:00
|
|
|
///
|
|
|
|
void makeLyXHTMLFile(support::FileName const & filename,
|
|
|
|
OutputParams const & runparams_in,
|
|
|
|
bool only_body = false) const;
|
|
|
|
///
|
|
|
|
void writeLyXHTMLSource(odocstream & os,
|
|
|
|
OutputParams const & runparams_in,
|
|
|
|
bool only_body = false) const;
|
1999-09-27 18:44:28 +00:00
|
|
|
/// returns the main language for the buffer (document)
|
2007-10-20 10:03:45 +00:00
|
|
|
Language const * language() const;
|
2003-04-24 23:19:41 +00:00
|
|
|
/// get l10n translated to the buffers language
|
2006-10-21 00:16:43 +00:00
|
|
|
docstring const B_(std::string const & l10n) const;
|
2003-04-24 23:19:41 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2001-11-07 13:22:43 +00:00
|
|
|
int runChktex();
|
2002-08-04 23:11:50 +00:00
|
|
|
/// return true if the main lyx file does not need saving
|
|
|
|
bool isClean() const;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
bool isDepClean(std::string const & name) const;
|
2002-03-21 16:55:34 +00:00
|
|
|
|
2007-08-09 20:46:22 +00:00
|
|
|
/// whether or not disk file has been externally modified
|
|
|
|
bool isExternallyModified(CheckMethod method) const;
|
|
|
|
|
2007-09-06 15:54:17 +00:00
|
|
|
/// save timestamp and checksum of the given file.
|
2007-10-20 10:03:45 +00:00
|
|
|
void saveCheckSum(support::FileName const & file) const;
|
2007-09-06 15:54:17 +00:00
|
|
|
|
2002-08-04 23:11:50 +00:00
|
|
|
/// mark the main lyx file as not needing saving
|
|
|
|
void markClean() const;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
void markDepClean(std::string const & name);
|
2002-03-21 16:55:34 +00:00
|
|
|
|
2000-07-26 13:43:16 +00:00
|
|
|
///
|
2001-05-09 09:14:50 +00:00
|
|
|
void setUnnamed(bool flag = true);
|
2000-07-26 13:43:16 +00:00
|
|
|
|
2009-09-08 01:29:07 +00:00
|
|
|
/// Whether or not a filename has been assigned to this buffer
|
2004-02-25 12:00:53 +00:00
|
|
|
bool isUnnamed() const;
|
2000-07-26 13:43:16 +00:00
|
|
|
|
2009-09-08 01:29:07 +00:00
|
|
|
/// Whether or not this buffer is internal.
|
|
|
|
///
|
|
|
|
/// An internal buffer does not contain a real document, but some auxiliary text segment.
|
|
|
|
/// It is not associated with a filename, it is never saved, thus it does not need to be
|
|
|
|
/// automatically saved, nor it needs to trigger any "do you want to save ?" question.
|
|
|
|
bool isInternal() const;
|
|
|
|
|
2001-02-16 09:25:43 +00:00
|
|
|
/// Mark this buffer as dirty.
|
|
|
|
void markDirty();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2007-11-03 17:37:37 +00:00
|
|
|
/// Returns the buffer's filename. It is always an absolute path.
|
|
|
|
support::FileName fileName() const;
|
|
|
|
|
2002-01-14 23:31:23 +00:00
|
|
|
/// Returns the buffer's filename. It is always an absolute path.
|
2007-10-20 10:03:45 +00:00
|
|
|
std::string absFileName() const;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2002-01-14 23:31:23 +00:00
|
|
|
/// Returns the the path where the buffer lives.
|
2002-03-21 16:55:34 +00:00
|
|
|
/// It is always an absolute path.
|
2007-11-28 15:25:07 +00:00
|
|
|
std::string filePath() const;
|
2002-01-14 23:31:23 +00:00
|
|
|
|
2001-02-16 09:25:43 +00:00
|
|
|
/** A transformed version of the file name, adequate for LaTeX.
|
|
|
|
\param no_path optional if \c true then the path is stripped.
|
2000-08-07 20:58:24 +00:00
|
|
|
*/
|
2007-10-20 10:03:45 +00:00
|
|
|
std::string latexName(bool no_path = true) const;
|
1999-12-03 13:51:01 +00:00
|
|
|
|
2009-06-21 09:44:10 +00:00
|
|
|
/// Get the name and type of the log.
|
2007-11-01 22:17:22 +00:00
|
|
|
std::string logName(LogType * type = 0) const;
|
2002-03-21 16:55:34 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
/// Change name of buffer. Updates "read-only" flag.
|
2003-10-06 15:43:21 +00:00
|
|
|
void setFileName(std::string const & newfile);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2007-11-30 17:41:27 +00:00
|
|
|
/// Set document's parent Buffer.
|
|
|
|
void setParent(Buffer const *);
|
2008-11-16 21:28:06 +00:00
|
|
|
Buffer const * parent() const;
|
|
|
|
|
|
|
|
// Collect all relative buffer
|
|
|
|
std::vector<Buffer const *> allRelatives() const;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2004-03-25 10:12:44 +00:00
|
|
|
/** Get the document's master (or \c this if this is not a
|
|
|
|
child document)
|
|
|
|
*/
|
2007-10-20 10:03:45 +00:00
|
|
|
Buffer const * masterBuffer() const;
|
2004-03-25 10:12:44 +00:00
|
|
|
|
2008-07-20 17:52:55 +00:00
|
|
|
/// \return true if \p child is a child of this \c Buffer.
|
|
|
|
bool isChild(Buffer * child) const;
|
2009-03-07 16:33:03 +00:00
|
|
|
|
2009-10-29 23:28:08 +00:00
|
|
|
/// return a vector with all children (and grandchildren)
|
|
|
|
std::vector<Buffer *> getChildren(bool grand_children = true) const;
|
2008-07-20 17:52:55 +00:00
|
|
|
|
2009-12-30 18:40:18 +00:00
|
|
|
/// Add all children (and grandchildren) to supplied vector
|
|
|
|
void getChildren(std::vector<Buffer *> & children, bool grand_children = true) const;
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
/// Is buffer read-only?
|
2001-02-16 09:25:43 +00:00
|
|
|
bool isReadonly() const;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
/// Set buffer read-only flag
|
2009-10-25 13:56:44 +00:00
|
|
|
void setReadonly(bool flag = true);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2001-02-16 09:25:43 +00:00
|
|
|
/// returns \c true if the buffer contains a LaTeX document
|
1999-11-15 12:01:38 +00:00
|
|
|
bool isLatex() const;
|
2001-02-16 09:25:43 +00:00
|
|
|
/// returns \c true if the buffer contains a DocBook document
|
1999-11-15 12:01:38 +00:00
|
|
|
bool isDocBook() const;
|
2002-03-21 16:55:34 +00:00
|
|
|
/// returns \c true if the buffer contains a Wed document
|
|
|
|
bool isLiterate() const;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
/** Validate a buffer for LaTeX.
|
1999-12-16 06:43:25 +00:00
|
|
|
This validates the buffer, and returns a struct for use by
|
2000-08-07 20:58:24 +00:00
|
|
|
#makeLaTeX# and others. Its main use is to figure out what
|
2000-04-11 22:55:29 +00:00
|
|
|
commands and packages need to be included in the LaTeX file.
|
|
|
|
It (should) also check that the needed constructs are there
|
|
|
|
(i.e. that the \refs points to coresponding \labels). It
|
|
|
|
should perhaps inset "error" insets to help the user correct
|
|
|
|
obvious mistakes.
|
1999-12-16 06:43:25 +00:00
|
|
|
*/
|
2000-02-04 09:38:32 +00:00
|
|
|
void validate(LaTeXFeatures &) const;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2010-08-10 14:26:34 +00:00
|
|
|
/// Reference information is cached in the Buffer, so we do not
|
|
|
|
/// have to check or read things over and over.
|
|
|
|
///
|
|
|
|
/// There are two caches.
|
|
|
|
///
|
|
|
|
/// One is a cache of the BibTeX files from which reference info is
|
|
|
|
/// being gathered. This cache is PER BUFFER, and the cache for the
|
|
|
|
/// master essentially includes the cache for its children. This gets
|
|
|
|
/// invalidated when an InsetBibtex is created, deleted, or modified.
|
|
|
|
///
|
|
|
|
/// The other is a cache of the reference information itself. This
|
|
|
|
/// exists only in the master buffer, and when it needs to be updated,
|
|
|
|
/// the children add their information to the master's cache.
|
|
|
|
|
2010-01-11 16:29:26 +00:00
|
|
|
/// Calling this method invalidates the cache and so requires a
|
|
|
|
/// re-read.
|
2010-08-10 14:12:48 +00:00
|
|
|
void invalidateBibinfoCache() const;
|
2010-08-09 17:01:51 +00:00
|
|
|
/// This invalidates the cache of files we need to check.
|
2010-08-10 14:12:48 +00:00
|
|
|
void invalidateBibfileCache() const;
|
2010-01-11 16:29:26 +00:00
|
|
|
/// Updates the cached bibliography information.
|
|
|
|
/// Note that you MUST call this method to update the cache. It will
|
|
|
|
/// not happen otherwise. (Currently, it is called at the start of
|
2010-03-03 22:13:45 +00:00
|
|
|
/// updateBuffer() and from GuiCitation.)
|
2010-08-10 14:12:48 +00:00
|
|
|
/// Note that this operates on the master document.
|
2010-01-11 16:29:26 +00:00
|
|
|
void checkBibInfoCache() const;
|
2008-04-25 20:03:03 +00:00
|
|
|
/// \return the bibliography information for this buffer's master,
|
|
|
|
/// or just for it, if it isn't a child.
|
|
|
|
BiblioInfo const & masterBibInfo() const;
|
2010-08-10 14:12:48 +00:00
|
|
|
///
|
|
|
|
void fillWithBibKeys(BiblioInfo & keys) const;
|
2000-05-19 16:46:01 +00:00
|
|
|
///
|
2006-10-21 00:16:43 +00:00
|
|
|
void getLabelList(std::vector<docstring> &) const;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2000-04-10 21:40:13 +00:00
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
void changeLanguage(Language const * from, Language const * to);
|
2003-04-25 01:54:04 +00:00
|
|
|
|
2000-04-10 21:40:13 +00:00
|
|
|
///
|
2004-02-25 12:00:53 +00:00
|
|
|
bool isMultiLingual() const;
|
2010-02-08 17:15:00 +00:00
|
|
|
///
|
|
|
|
std::set<Language const *> getLanguages() const;
|
2000-04-10 21:40:13 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2003-09-09 09:47:59 +00:00
|
|
|
BufferParams & params();
|
|
|
|
BufferParams const & params() const;
|
2002-03-21 16:55:34 +00:00
|
|
|
|
2001-02-16 09:25:43 +00:00
|
|
|
/** The list of paragraphs.
|
|
|
|
This is a linked list of paragraph, this list holds the
|
|
|
|
whole contents of the document.
|
1999-09-27 18:44:28 +00:00
|
|
|
*/
|
2003-09-09 09:47:59 +00:00
|
|
|
ParagraphList & paragraphs();
|
|
|
|
ParagraphList const & paragraphs() const;
|
1999-12-10 00:07:59 +00:00
|
|
|
|
2001-02-16 09:25:43 +00:00
|
|
|
/// LyX version control object.
|
2003-09-09 09:47:59 +00:00
|
|
|
LyXVC & lyxvc();
|
|
|
|
LyXVC const & lyxvc() const;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2001-02-16 09:25:43 +00:00
|
|
|
/// Where to put temporary files.
|
2007-12-17 18:37:13 +00:00
|
|
|
std::string const temppath() const;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2000-01-08 21:02:58 +00:00
|
|
|
/// Used when typesetting to place errorboxes.
|
2003-09-09 09:47:59 +00:00
|
|
|
TexRow const & texrow() const;
|
2008-11-16 00:12:21 +00:00
|
|
|
TexRow & texrow();
|
2003-02-08 19:18:01 +00:00
|
|
|
|
2001-09-01 21:26:34 +00:00
|
|
|
///
|
|
|
|
ParIterator par_iterator_begin();
|
|
|
|
///
|
2002-11-08 01:08:27 +00:00
|
|
|
ParConstIterator par_iterator_begin() const;
|
|
|
|
///
|
2001-09-01 21:26:34 +00:00
|
|
|
ParIterator par_iterator_end();
|
2002-11-08 01:08:27 +00:00
|
|
|
///
|
|
|
|
ParConstIterator par_iterator_end() const;
|
2001-09-01 21:26:34 +00:00
|
|
|
|
2008-11-16 21:28:06 +00:00
|
|
|
// Position of the child buffer where it appears first in the master.
|
|
|
|
DocIterator firstChildPosition(Buffer const * child);
|
|
|
|
|
2003-10-22 13:15:18 +00:00
|
|
|
/** \returns true only when the file is fully loaded.
|
|
|
|
* Used to prevent the premature generation of previews
|
|
|
|
* and by the citation inset.
|
|
|
|
*/
|
2007-10-20 10:03:45 +00:00
|
|
|
bool isFullyLoaded() const;
|
2003-10-22 14:40:24 +00:00
|
|
|
/// Set by buffer_funcs' newFile.
|
2007-10-20 10:03:45 +00:00
|
|
|
void setFullyLoaded(bool);
|
2003-10-22 13:15:18 +00:00
|
|
|
|
2005-07-17 14:29:35 +00:00
|
|
|
/// Our main text (inside the top InsetText)
|
2007-04-29 23:33:02 +00:00
|
|
|
Text & text() const;
|
2005-07-17 14:29:35 +00:00
|
|
|
|
2007-10-20 10:03:45 +00:00
|
|
|
/// Our top InsetText
|
2007-04-29 13:39:47 +00:00
|
|
|
Inset & inset() const;
|
2003-11-28 15:08:38 +00:00
|
|
|
|
2004-04-13 06:27:29 +00:00
|
|
|
//
|
|
|
|
// Macro handling
|
|
|
|
//
|
2007-12-21 20:42:46 +00:00
|
|
|
/// Collect macro definitions in paragraphs
|
2010-07-21 21:58:54 +00:00
|
|
|
void updateMacros() const;
|
2007-12-21 20:42:46 +00:00
|
|
|
/// Iterate through the whole buffer and try to resolve macros
|
|
|
|
void updateMacroInstances() const;
|
|
|
|
|
2008-03-26 12:55:36 +00:00
|
|
|
/// List macro names of this buffer, the parent and the children
|
2007-12-21 20:42:46 +00:00
|
|
|
void listMacroNames(MacroNameSet & macros) const;
|
2008-03-26 12:55:36 +00:00
|
|
|
/// Collect macros of the parent and its children in front of this buffer.
|
|
|
|
void listParentMacros(MacroSet & macros, LaTeXFeatures & features) const;
|
2007-12-21 20:42:46 +00:00
|
|
|
|
|
|
|
/// Return macro defined before pos (or in the master buffer)
|
|
|
|
MacroData const * getMacro(docstring const & name, DocIterator const & pos, bool global = true) const;
|
2007-11-01 11:13:07 +00:00
|
|
|
/// Return macro defined anywhere in the buffer (or in the master buffer)
|
2007-12-21 20:42:46 +00:00
|
|
|
MacroData const * getMacro(docstring const & name, bool global = true) const;
|
|
|
|
/// Return macro defined before the inclusion of the child
|
|
|
|
MacroData const * getMacro(docstring const & name, Buffer const & child, bool global = true) const;
|
2006-10-22 10:15:23 +00:00
|
|
|
|
2009-11-08 18:47:33 +00:00
|
|
|
/// Collect user macro names at loading time
|
|
|
|
typedef std::set<docstring> UserMacroSet;
|
|
|
|
UserMacroSet usermacros;
|
|
|
|
|
2007-10-13 09:04:52 +00:00
|
|
|
/// Replace the inset contents for insets which InsetCode is equal
|
2007-10-11 12:48:24 +00:00
|
|
|
/// to the passed \p inset_code.
|
2006-10-22 11:00:04 +00:00
|
|
|
void changeRefsIfUnique(docstring const & from, docstring const & to,
|
2007-10-13 09:11:10 +00:00
|
|
|
InsetCode code);
|
2007-10-11 12:48:24 +00:00
|
|
|
|
2007-10-20 10:03:45 +00:00
|
|
|
/// get source code (latex/docbook) for some paragraphs, or all paragraphs
|
|
|
|
/// including preamble
|
|
|
|
void getSourceCode(odocstream & os, pit_type par_begin, pit_type par_end,
|
2008-09-29 10:48:49 +00:00
|
|
|
bool full_source) const;
|
2004-04-13 06:27:29 +00:00
|
|
|
|
2007-11-30 17:41:27 +00:00
|
|
|
/// Access to error list.
|
|
|
|
/// This method is used only for GUI visualisation of Buffer related
|
|
|
|
/// errors (like parsing or LateX compilation). This method is const
|
|
|
|
/// because modifying the returned ErrorList does not touch the document
|
|
|
|
/// contents.
|
|
|
|
ErrorList & errorList(std::string const & type) const;
|
|
|
|
|
|
|
|
/// The Toc backend.
|
|
|
|
/// This is useful only for screen visualisation of the Buffer. This
|
|
|
|
/// method is const because modifying this backend does not touch
|
|
|
|
/// the document contents.
|
|
|
|
TocBackend & tocBackend() const;
|
2007-10-18 11:51:17 +00:00
|
|
|
|
2008-04-20 03:08:11 +00:00
|
|
|
///
|
2007-10-18 11:51:17 +00:00
|
|
|
Undo & undo();
|
2008-04-20 03:08:11 +00:00
|
|
|
|
2007-10-02 18:27:20 +00:00
|
|
|
/// This function is called when the buffer is changed.
|
2010-01-08 02:03:54 +00:00
|
|
|
void changed(bool update_metrics) const;
|
2008-09-30 09:50:54 +00:00
|
|
|
///
|
2010-01-09 14:47:47 +00:00
|
|
|
void setChild(DocIterator const & dit, Buffer * child);
|
|
|
|
///
|
2008-09-30 09:50:54 +00:00
|
|
|
void updateTocItem(std::string const &, DocIterator const &) const;
|
2007-10-02 18:27:20 +00:00
|
|
|
/// This function is called when the buffer structure is changed.
|
|
|
|
void structureChanged() const;
|
|
|
|
/// This function is called when some parsing error shows up.
|
2009-06-21 12:26:41 +00:00
|
|
|
void errors(std::string const & err, bool from_master = false) const;
|
2007-10-02 18:27:20 +00:00
|
|
|
/// This function is called when the buffer busy status change.
|
2007-10-21 10:50:56 +00:00
|
|
|
void setBusy(bool on) const;
|
2007-10-02 18:27:20 +00:00
|
|
|
/// Update window titles of all users.
|
|
|
|
void updateTitles() const;
|
|
|
|
/// Reset autosave timers for all users.
|
|
|
|
void resetAutosaveTimers() const;
|
|
|
|
///
|
|
|
|
void message(docstring const & msg) const;
|
|
|
|
|
2009-02-19 00:29:04 +00:00
|
|
|
///
|
2007-10-02 18:27:20 +00:00
|
|
|
void setGuiDelegate(frontend::GuiBufferDelegate * gui);
|
2009-02-19 00:29:04 +00:00
|
|
|
///
|
2009-02-19 04:05:44 +00:00
|
|
|
bool hasGuiDelegate() const;
|
2007-10-02 18:27:20 +00:00
|
|
|
|
2007-10-03 11:00:18 +00:00
|
|
|
///
|
|
|
|
void autoSave() const;
|
2009-04-04 03:13:46 +00:00
|
|
|
///
|
|
|
|
void removeAutosaveFile() const;
|
2009-05-03 10:21:21 +00:00
|
|
|
///
|
|
|
|
void moveAutosaveFile(support::FileName const & old) const;
|
|
|
|
///
|
2010-04-21 01:19:33 +00:00
|
|
|
support::FileName getAutosaveFileName() const;
|
2007-11-30 17:41:27 +00:00
|
|
|
|
2007-10-20 10:03:45 +00:00
|
|
|
/// return the format of the buffer on a string
|
|
|
|
std::string bufferFormat() const;
|
2009-04-07 05:01:08 +00:00
|
|
|
/// return the default output format of the current backend
|
|
|
|
std::string getDefaultOutputFormat() const;
|
2006-11-11 00:35:14 +00:00
|
|
|
|
2007-10-20 10:51:13 +00:00
|
|
|
///
|
|
|
|
bool doExport(std::string const & format, bool put_in_tempdir,
|
2010-01-10 13:25:41 +00:00
|
|
|
bool includeall, std::string & result_file) const;
|
2007-10-20 10:51:13 +00:00
|
|
|
///
|
2010-01-10 13:25:41 +00:00
|
|
|
bool doExport(std::string const & format, bool put_in_tempdir,
|
|
|
|
bool includeall = false) const;
|
2007-10-20 10:51:13 +00:00
|
|
|
///
|
2010-01-10 13:25:41 +00:00
|
|
|
bool preview(std::string const & format, bool includeall = false) const;
|
2007-10-20 10:51:13 +00:00
|
|
|
///
|
|
|
|
bool isExportable(std::string const & format) const;
|
|
|
|
///
|
|
|
|
std::vector<Format const *> exportableFormats(bool only_viewable) const;
|
2009-12-18 22:51:06 +00:00
|
|
|
///
|
|
|
|
bool isExportableFormat(std::string const & format) const;
|
2010-07-21 21:51:33 +00:00
|
|
|
/// mark the buffer as busy exporting something, or not
|
|
|
|
void setExportStatus(bool e) const;
|
|
|
|
///
|
|
|
|
bool isExporting() const;
|
2008-03-02 15:27:35 +00:00
|
|
|
|
|
|
|
///
|
2010-01-28 17:37:22 +00:00
|
|
|
typedef std::vector<std::pair<Inset *, ParIterator> > References;
|
2008-03-02 15:27:35 +00:00
|
|
|
References & references(docstring const & label);
|
|
|
|
References const & references(docstring const & label) const;
|
|
|
|
void clearReferenceCache() const;
|
|
|
|
void setInsetLabel(docstring const & label, InsetLabel const * il);
|
|
|
|
InsetLabel const * insetLabel(docstring const & label) const;
|
|
|
|
|
2009-07-09 09:48:34 +00:00
|
|
|
/// return a list of all used branches (also in children)
|
|
|
|
void getUsedBranches(std::list<docstring> &, bool const from_master = false) const;
|
|
|
|
|
2009-03-12 20:10:46 +00:00
|
|
|
/// sets the buffer_ member for every inset in this buffer.
|
|
|
|
// FIXME This really shouldn't be needed, but at the moment it's not
|
|
|
|
// clear how to do it just for the individual pieces we need.
|
|
|
|
void setBuffersForInsets() const;
|
2009-12-10 13:25:31 +00:00
|
|
|
/// Updates screen labels and some other information associated with
|
|
|
|
/// insets and paragraphs. Actually, it's more like a general "recurse
|
|
|
|
/// through the Buffer" routine, that visits all the insets and paragraphs.
|
2010-03-03 22:13:45 +00:00
|
|
|
void updateBuffer() const { updateBuffer(UpdateMaster, InternalUpdate); }
|
2009-12-10 13:25:31 +00:00
|
|
|
/// \param scope: whether to start with the master document or just
|
|
|
|
/// do this one.
|
|
|
|
/// \param output: whether we are preparing for output.
|
2010-03-03 22:13:45 +00:00
|
|
|
void updateBuffer(UpdateScope scope, UpdateType utype) const;
|
2009-12-10 13:25:31 +00:00
|
|
|
///
|
2010-03-03 22:13:45 +00:00
|
|
|
void updateBuffer(ParIterator & parit, UpdateType utype) const;
|
2008-11-16 16:43:49 +00:00
|
|
|
|
2009-06-22 16:38:11 +00:00
|
|
|
/// Spellcheck starting from \p from.
|
|
|
|
/// \p from initial position, will then points to the next misspelled
|
2009-03-28 19:02:49 +00:00
|
|
|
/// word.
|
2009-06-22 16:38:11 +00:00
|
|
|
/// \p to will points to the end of the next misspelled word.
|
|
|
|
/// \p word_lang will contain the found misspelled word.
|
|
|
|
/// \return progress if a new word was found.
|
2009-04-04 16:40:47 +00:00
|
|
|
int spellCheck(DocIterator & from, DocIterator & to,
|
|
|
|
WordLangTuple & word_lang, docstring_list & suggestions) const;
|
2010-03-09 03:25:47 +00:00
|
|
|
///
|
|
|
|
void checkChildBuffers();
|
2009-04-04 16:40:47 +00:00
|
|
|
|
2003-09-09 11:24:33 +00:00
|
|
|
private:
|
2008-10-13 11:25:37 +00:00
|
|
|
///
|
2007-10-21 10:50:56 +00:00
|
|
|
bool readFileHelper(support::FileName const & s);
|
2007-10-20 10:51:13 +00:00
|
|
|
///
|
|
|
|
std::vector<std::string> backends() const;
|
2003-09-09 11:24:33 +00:00
|
|
|
/** Inserts a file into a document
|
|
|
|
\return \c false if method fails.
|
|
|
|
*/
|
2007-04-26 11:30:54 +00:00
|
|
|
ReadStatus readFile(Lexer &, support::FileName const & filename,
|
2007-05-28 22:27:45 +00:00
|
|
|
bool fromString = false);
|
2010-02-08 17:15:00 +00:00
|
|
|
///
|
|
|
|
void getLanguages(std::set<Language const *> &) const;
|
2010-08-09 17:01:51 +00:00
|
|
|
/// Update the list of all bibfiles in use (including bibfiles
|
|
|
|
/// of loaded child documents).
|
|
|
|
void updateBibfilesCache(UpdateScope scope = UpdateMaster) const;
|
2010-08-09 17:14:45 +00:00
|
|
|
/// Return the list with all bibfiles in use (including bibfiles
|
|
|
|
/// of loaded child documents).
|
|
|
|
support::FileNameList const &
|
|
|
|
getBibfilesCache(UpdateScope scope = UpdateMaster) const;
|
2003-09-09 11:24:33 +00:00
|
|
|
|
|
|
|
/// Use the Pimpl idiom to hide the internals.
|
|
|
|
class Impl;
|
|
|
|
/// The pointer never changes although *pimpl_'s contents may.
|
2007-11-30 17:46:49 +00:00
|
|
|
Impl * const d;
|
1999-09-27 18:44:28 +00:00
|
|
|
};
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
} // namespace lyx
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
#endif
|