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
|
|
|
|
2009-04-06 12:12:06 +00:00
|
|
|
#include "update_flags.h"
|
|
|
|
|
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"
|
2008-02-09 10:41:49 +00:00
|
|
|
#include "support/SignalSlot.h"
|
2000-04-08 17:02:02 +00:00
|
|
|
|
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;
|
2003-09-06 18:38:02 +00:00
|
|
|
class ErrorItem;
|
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 InsetRef;
|
|
|
|
class InsetLabel;
|
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;
|
1999-09-27 18:44:28 +00:00
|
|
|
class LyXRC;
|
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
|
2003-10-06 15:43:21 +00:00
|
|
|
explicit Buffer(std::string const & file, bool b = false);
|
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();
|
|
|
|
|
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-08 12:52:16 +00:00
|
|
|
///
|
2004-03-25 09:16:36 +00:00
|
|
|
void insertStringAsLines(ParagraphList & plist,
|
2006-10-21 00:16:43 +00:00
|
|
|
pit_type &, pos_type &,
|
2007-04-29 18:17:15 +00:00
|
|
|
Font const &, docstring const &, bool);
|
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;
|
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-02-14 13:52:10 +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);
|
|
|
|
|
|
|
|
/// 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;
|
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
|
|
|
///
|
2001-02-16 09:25:43 +00:00
|
|
|
bool isBakClean() 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
|
|
|
|
|
|
|
///
|
2007-10-03 11:00:18 +00:00
|
|
|
void markBakClean() const;
|
2002-03-21 16:55:34 +00:00
|
|
|
|
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
|
|
|
|
|
|
|
///
|
2004-02-25 12:00:53 +00:00
|
|
|
bool isUnnamed() const;
|
2000-07-26 13:43:16 +00:00
|
|
|
|
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
|
|
|
|
2006-10-22 10:15:23 +00:00
|
|
|
/// Get thee 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
|
|
|
|
|
|
|
/// return a vector with all children and grandchildren
|
|
|
|
std::vector<Buffer *> getChildren() const;
|
2008-07-20 17:52:55 +00:00
|
|
|
|
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
|
2000-04-08 17:02:02 +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
|
|
|
|
2006-04-15 11:46:17 +00:00
|
|
|
/// Update the cache with all bibfiles in use (including bibfiles
|
2006-05-19 07:21:43 +00:00
|
|
|
/// of loaded child documents).
|
2009-03-26 00:48:32 +00:00
|
|
|
void updateBibfilesCache(UpdateScope scope = UpdateMaster) const;
|
2008-06-05 06:42:53 +00:00
|
|
|
///
|
More cache fixing. Similar fix as for InsetBibtex, and I've renamed the key routine.
Unfortunately, we can't do a one-short fix for InsetCommand, requiring that it take
a Buffer & in the constructor, due to problems in mathed, specifically, here:
void InsetMathHull::label(row_type row, docstring const & label)
{
...
label_[row] = new InsetLabel(p);
if (buffer_)
label_[row]->setBuffer(buffer());
}
If InsetLabel has to have a Buffer, then buffer_ has to be set, which means InsetMathHull needs a Buffer. But then truckloads of these are created in Parser, where we don't really seem to have access to a Buffer.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@25137 a592a061-630c-0410-9148-cb99ea01b6c8
2008-06-05 06:55:34 +00:00
|
|
|
void invalidateBibinfoCache();
|
2006-04-15 11:46:17 +00:00
|
|
|
/// Return the cache with all bibfiles in use (including bibfiles
|
2006-05-19 07:21:43 +00:00
|
|
|
/// of loaded child documents).
|
2009-03-26 00:48:32 +00:00
|
|
|
support::FileNameList const &
|
|
|
|
getBibfilesCache(UpdateScope scope = UpdateMaster) 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;
|
|
|
|
/// \return the bibliography information for this buffer ONLY.
|
|
|
|
BiblioInfo const & localBibInfo() 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;
|
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
|
|
|
|
void updateMacros() const;
|
|
|
|
/// 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
|
|
|
|
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.
|
|
|
|
void changed() const;
|
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.
|
|
|
|
void errors(std::string const & err) const;
|
|
|
|
/// 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
|
|
|
/// This function is called when the buffer readonly status change.
|
2007-10-23 21:41:17 +00:00
|
|
|
void setReadOnly(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;
|
|
|
|
///
|
|
|
|
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,
|
2007-11-30 17:41:27 +00:00
|
|
|
std::string & result_file) const;
|
2007-10-20 10:51:13 +00:00
|
|
|
///
|
2007-11-30 17:41:27 +00:00
|
|
|
bool doExport(std::string const & format, bool put_in_tempdir) const;
|
2007-10-20 10:51:13 +00:00
|
|
|
///
|
2007-11-30 17:41:27 +00:00
|
|
|
bool preview(std::string const & format) 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;
|
2008-03-02 15:27:35 +00:00
|
|
|
|
|
|
|
///
|
|
|
|
typedef std::vector<std::pair<InsetRef *, ParIterator> > References;
|
|
|
|
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-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-03-12 20:02:12 +00:00
|
|
|
void updateLabels(UpdateScope = UpdateMaster) const;
|
2008-11-16 17:49:00 +00:00
|
|
|
///
|
|
|
|
void updateLabels(ParIterator & parit) const;
|
2008-11-16 16:43:49 +00:00
|
|
|
|
2009-03-28 19:02:49 +00:00
|
|
|
/// Find next word starting from \p from.
|
|
|
|
/// \p from initial position to search, will then points to the next
|
|
|
|
/// word.
|
|
|
|
/// \p to will points to the end of the next word.
|
|
|
|
/// \p word will contain the found word if any.
|
|
|
|
/// \return true if a new word was found.
|
|
|
|
bool nextWord(DocIterator & from, DocIterator & to,
|
|
|
|
docstring & word) const;
|
|
|
|
|
2009-04-04 16:40:47 +00:00
|
|
|
int spellCheck(DocIterator & from, DocIterator & to,
|
|
|
|
WordLangTuple & word_lang, docstring_list & suggestions) const;
|
|
|
|
|
2003-09-09 11:24:33 +00:00
|
|
|
private:
|
2007-12-21 20:42:46 +00:00
|
|
|
/// search for macro in local (buffer) table or in children
|
|
|
|
MacroData const * getBufferMacro(docstring const & name,
|
|
|
|
DocIterator const & pos) const;
|
2008-03-10 12:49:02 +00:00
|
|
|
/** Update macro table starting with position of it
|
2007-12-21 20:42:46 +00:00
|
|
|
\param it in some text inset
|
|
|
|
*/
|
2008-03-10 12:49:02 +00:00
|
|
|
void updateMacros(DocIterator & it,
|
2007-12-21 20:42:46 +00:00
|
|
|
DocIterator & scope) const;
|
|
|
|
|
2008-11-16 21:28:06 +00:00
|
|
|
///
|
|
|
|
void collectRelatives(BufferSet & bufs) const;
|
|
|
|
|
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);
|
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;
|
2005-07-17 14:29:35 +00:00
|
|
|
|
2007-10-02 18:27:20 +00:00
|
|
|
frontend::GuiBufferDelegate * gui_;
|
2008-02-09 10:41:49 +00:00
|
|
|
|
|
|
|
/// This function is called when the buffer structure is changed.
|
|
|
|
Signal structureChanged_;
|
|
|
|
/// This function is called when some parsing error shows up.
|
|
|
|
//Signal errors(std::string const &) = 0;
|
|
|
|
/// This function is called when some message shows up.
|
|
|
|
//Signal message(docstring const &) = 0;
|
|
|
|
/// This function is called when the buffer busy status change.
|
|
|
|
//Signal setBusy(bool) = 0;
|
|
|
|
/// Reset autosave timers for all users.
|
|
|
|
Signal resetAutosaveTimers_;
|
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
|