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
|
|
|
|
2016-06-02 20:58:52 +00:00
|
|
|
#include "support/unique_ptr.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
|
|
|
|
2010-12-07 08:36:42 +00:00
|
|
|
#include <map>
|
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;
|
2010-12-03 20:08:04 +00:00
|
|
|
class BibTeXInfo;
|
2003-09-09 11:24:33 +00:00
|
|
|
class BufferParams;
|
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;
|
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;
|
2016-06-19 02:39:38 +00:00
|
|
|
class otexstream;
|
2007-04-26 08:30:11 +00:00
|
|
|
class ParagraphList;
|
2020-10-20 08:36:59 +00:00
|
|
|
class ParIterator;
|
|
|
|
class ParConstIterator;
|
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;
|
2017-07-23 11:11:54 +00:00
|
|
|
} // namespace frontend
|
2001-08-03 18:28:11 +00:00
|
|
|
|
2007-12-05 10:32:49 +00:00
|
|
|
namespace support {
|
2016-01-10 18:46:01 +00:00
|
|
|
class DocFileName;
|
2007-12-05 10:32:49 +00:00
|
|
|
class FileName;
|
2020-10-19 08:51:00 +00:00
|
|
|
class FileNameList;
|
2017-07-23 11:11:54 +00:00
|
|
|
} // namespace support
|
2007-12-05 10:32:49 +00:00
|
|
|
|
2011-07-12 12:43:11 +00:00
|
|
|
namespace graphics {
|
|
|
|
class PreviewLoader;
|
2016-11-05 00:00:44 +00:00
|
|
|
class Cache;
|
2017-07-23 11:11:54 +00:00
|
|
|
} // namespace graphics
|
2011-07-12 12:43:11 +00:00
|
|
|
|
2010-09-29 11:55:10 +00:00
|
|
|
|
|
|
|
class Buffer;
|
2010-09-29 12:19:23 +00:00
|
|
|
typedef std::list<Buffer *> ListOfBuffers;
|
2011-11-20 18:49:05 +00:00
|
|
|
/// a list of Buffers we cloned
|
|
|
|
typedef std::set<Buffer *> CloneList;
|
2020-02-23 21:39:00 +00:00
|
|
|
typedef std::shared_ptr<CloneList> CloneList_ptr;
|
2010-09-29 11:55:10 +00:00
|
|
|
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
/** The buffer object.
|
2012-09-12 23:38:26 +00:00
|
|
|
* This is the buffer object. It contains all the information about
|
2005-01-31 16:29:48 +00:00
|
|
|
* 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
|
|
|
*/
|
2013-04-21 01:07:07 +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 {
|
2010-10-25 10:18:42 +00:00
|
|
|
ReadSuccess,
|
|
|
|
ReadCancel,
|
2010-10-25 11:57:56 +00:00
|
|
|
// failures
|
2010-10-25 10:18:42 +00:00
|
|
|
ReadFailure,
|
2010-10-25 11:57:56 +00:00
|
|
|
ReadWrongVersion,
|
|
|
|
ReadFileNotFound,
|
|
|
|
ReadVCError,
|
2011-12-03 22:15:11 +00:00
|
|
|
ReadAutosaveFailure,
|
2010-10-25 11:57:56 +00:00
|
|
|
ReadEmergencyFailure,
|
2010-10-25 13:55:39 +00:00
|
|
|
ReadNoLyXFormat,
|
|
|
|
ReadDocumentFailure,
|
|
|
|
// lyx2lyx
|
|
|
|
LyX2LyXNoTempFile,
|
|
|
|
LyX2LyXNotFound,
|
|
|
|
LyX2LyXOlderFormat,
|
|
|
|
LyX2LyXNewerFormat,
|
2010-10-25 11:57:56 +00:00
|
|
|
// other
|
|
|
|
ReadOriginal
|
2007-01-13 18:29:50 +00:00
|
|
|
};
|
|
|
|
|
2011-10-27 20:00:06 +00:00
|
|
|
enum ExportStatus {
|
2011-10-27 20:00:08 +00:00
|
|
|
// export
|
2011-10-27 20:00:06 +00:00
|
|
|
ExportSuccess,
|
2011-10-30 19:52:27 +00:00
|
|
|
ExportCancel,
|
Fix some problems with background cancellation.
The problem was that, if we killed export when some graphic was
being converted, or some external template was being handled, it
would only cancel that process, and then it would just continue.
To deal with that, we need to do a few things:
1. Modify the return values for some of the Converters routines,
and similarly the routines for external templates, so we can
tell when something has been canceled.
2. Throw an exception from InsetGraphics or InsetExternal when this
has happened during export, but ONLY when the Buffer is a clone.
We shouldn't be able to 'cancel' export when we're, say, generating
code for the preview pane, but this keeps us on the safe side..
The exception then has to be caught, obviously, back in the export
routines in Buffer.
Probably Coverity will be unhappy about something here, but I'll
deal with that problem as it arises.
2018-02-20 03:43:44 +00:00
|
|
|
ExportKilled,
|
2011-10-27 20:00:06 +00:00
|
|
|
ExportError,
|
|
|
|
ExportNoPathToFormat,
|
|
|
|
ExportTexPathHasSpaces,
|
2011-10-27 20:00:08 +00:00
|
|
|
ExportConverterError,
|
|
|
|
// preview
|
2015-03-20 04:13:50 +00:00
|
|
|
// Implies ExportSuccess.
|
2011-10-27 20:00:08 +00:00
|
|
|
PreviewSuccess,
|
2015-03-20 04:13:50 +00:00
|
|
|
// The exported file exists but there was an error when opening
|
|
|
|
// it in a viewer.
|
2011-10-27 20:00:08 +00:00
|
|
|
PreviewError
|
2011-10-27 20:00:06 +00:00
|
|
|
};
|
2007-11-30 09:49:35 +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,
|
2020-02-28 06:39:06 +00:00
|
|
|
Buffer const * cloned_buffer = nullptr);
|
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();
|
|
|
|
|
2018-05-16 06:35:21 +00:00
|
|
|
/// Clones the entire structure of which this Buffer is part,
|
|
|
|
/// cloning all the children, too.
|
|
|
|
Buffer * cloneWithChildren() const;
|
2011-12-03 23:20:18 +00:00
|
|
|
/// Just clones this single Buffer. For autosave.
|
|
|
|
Buffer * cloneBufferOnly() 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
|
|
|
|
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;
|
2010-11-07 21:26:02 +00:00
|
|
|
/// Renames and saves the buffer
|
|
|
|
bool saveAs(support::FileName const & fn);
|
2002-03-21 16:55:34 +00:00
|
|
|
|
2010-12-29 16:57:04 +00:00
|
|
|
/// Write document to stream. Returns \c false if unsuccessful.
|
2007-01-13 18:29:50 +00:00
|
|
|
bool write(std::ostream &) const;
|
2010-12-29 16:57:04 +00:00
|
|
|
/// Write file. Returns \c false if unsuccessful.
|
2006-11-30 16:59:50 +00:00
|
|
|
bool writeFile(support::FileName const &) const;
|
2002-03-21 16:55:34 +00:00
|
|
|
|
2010-10-26 12:54:31 +00:00
|
|
|
/// \name Functions involved in reading files/strings.
|
|
|
|
//@{
|
2010-11-05 21:21:01 +00:00
|
|
|
/// Loads the LyX file into the buffer. This function
|
2010-10-25 11:57:56 +00:00
|
|
|
/// tries to extract the file from version control if it
|
|
|
|
/// cannot be found. If it can be found, it will try to
|
|
|
|
/// read an emergency save file or an autosave file.
|
2010-10-26 13:17:10 +00:00
|
|
|
/// \sa loadThisLyXFile
|
2010-11-05 21:21:01 +00:00
|
|
|
ReadStatus loadLyXFile();
|
|
|
|
/// Loads the LyX file \c fn into the buffer. If you want
|
2010-10-26 13:17:10 +00:00
|
|
|
/// to check for files in a version control container,
|
|
|
|
/// emergency or autosave files, one should use \c loadLyXFile.
|
|
|
|
/// /sa loadLyXFile
|
|
|
|
ReadStatus loadThisLyXFile(support::FileName const & fn);
|
2013-04-14 17:45:36 +00:00
|
|
|
/// import a new document from a string
|
|
|
|
bool importString(std::string const &, docstring const &, ErrorList &);
|
|
|
|
/// import a new file
|
|
|
|
bool importFile(std::string const &, support::FileName const &, ErrorList &);
|
2010-10-26 12:54:31 +00:00
|
|
|
/// read a new document from a string
|
|
|
|
bool readString(std::string const &);
|
|
|
|
/// Reloads the LyX file
|
2013-10-04 13:01:42 +00:00
|
|
|
ReadStatus reload();
|
2010-11-25 16:53:56 +00:00
|
|
|
//FIXME: The following function should be private
|
2010-10-26 12:54:31 +00:00
|
|
|
//private:
|
|
|
|
/// read the header, returns number of unknown tokens
|
|
|
|
int readHeader(Lexer & lex);
|
2010-10-29 23:51:13 +00:00
|
|
|
|
2014-10-18 13:30:58 +00:00
|
|
|
double fontScalingFactor() const;
|
|
|
|
|
2010-10-26 12:54:31 +00:00
|
|
|
private:
|
2011-05-26 13:20:11 +00:00
|
|
|
///
|
|
|
|
typedef std::map<Buffer const *, Buffer *> BufferMap;
|
|
|
|
///
|
2020-02-23 21:39:00 +00:00
|
|
|
void cloneWithChildren(BufferMap &, CloneList_ptr) const;
|
2017-03-01 19:32:33 +00:00
|
|
|
/// save checksum of the given file.
|
2011-12-03 22:15:11 +00:00
|
|
|
void saveCheckSum() const;
|
2010-10-26 13:17:10 +00:00
|
|
|
/// read a new file
|
|
|
|
ReadStatus readFile(support::FileName const & fn);
|
2010-10-26 12:54:31 +00:00
|
|
|
/// Reads a file without header.
|
|
|
|
/// \param par if != 0 insert the file.
|
|
|
|
/// \return \c true if file is not completely read.
|
|
|
|
bool readDocument(Lexer &);
|
2010-10-25 11:57:56 +00:00
|
|
|
/// Try to extract the file from a version control container
|
2012-11-15 21:01:19 +00:00
|
|
|
/// before reading if the file cannot be found.
|
2010-10-25 11:57:56 +00:00
|
|
|
/// \sa LyXVC::file_not_found_hook
|
2010-11-05 21:21:01 +00:00
|
|
|
ReadStatus extractFromVC();
|
2011-12-03 22:15:11 +00:00
|
|
|
/// Reads the first tag of a LyX File and
|
2010-10-26 12:54:31 +00:00
|
|
|
/// returns the file format number.
|
|
|
|
ReadStatus parseLyXFormat(Lexer & lex, support::FileName const & fn,
|
|
|
|
int & file_format) const;
|
|
|
|
/// Convert the LyX file to the LYX_FORMAT using
|
|
|
|
/// the lyx2lyx script and returns the filename
|
|
|
|
/// of the temporary file to be read
|
2011-12-03 22:15:11 +00:00
|
|
|
ReadStatus convertLyXFormat(support::FileName const & fn,
|
2010-10-26 12:54:31 +00:00
|
|
|
support::FileName & tmpfile, int from_format);
|
2015-11-10 17:39:24 +00:00
|
|
|
/// get appropriate name for backing up files from older versions
|
2015-11-13 22:12:52 +00:00
|
|
|
support::FileName getBackupName() const;
|
2010-10-26 12:54:31 +00:00
|
|
|
//@}
|
|
|
|
|
|
|
|
public:
|
|
|
|
/// \name Functions involved in autosave and emergency files.
|
|
|
|
//@{
|
2010-11-17 02:18:12 +00:00
|
|
|
/// Save an autosave file to #filename.lyx#
|
2011-12-03 22:15:11 +00:00
|
|
|
bool autoSave() const;
|
2010-10-26 12:54:31 +00:00
|
|
|
/// save emergency file
|
|
|
|
/// \return a status message towards the user.
|
2020-10-21 08:35:40 +00:00
|
|
|
docstring emergencyWrite() const;
|
2010-10-26 12:54:31 +00:00
|
|
|
|
2010-11-17 03:47:14 +00:00
|
|
|
//FIXME:The following function should be private
|
2010-10-26 12:54:31 +00:00
|
|
|
//private:
|
|
|
|
///
|
|
|
|
void removeAutosaveFile() const;
|
2011-12-03 22:15:11 +00:00
|
|
|
|
2010-10-26 12:54:31 +00:00
|
|
|
private:
|
2010-10-26 13:27:06 +00:00
|
|
|
/// Try to load an autosave file associated to \c fn.
|
2010-11-05 21:21:01 +00:00
|
|
|
ReadStatus loadAutosave();
|
2011-12-03 22:15:11 +00:00
|
|
|
/// Try to load an emergency file associated to \c fn.
|
2010-11-05 21:21:01 +00:00
|
|
|
ReadStatus loadEmergency();
|
2010-10-26 12:54:31 +00:00
|
|
|
/// Get the filename of the emergency file associated with the Buffer
|
|
|
|
support::FileName getEmergencyFileName() const;
|
2010-11-17 02:25:12 +00:00
|
|
|
/// Get the filename of the autosave file associated with the Buffer
|
|
|
|
support::FileName getAutosaveFileName() const;
|
2010-11-17 03:47:14 +00:00
|
|
|
///
|
|
|
|
void moveAutosaveFile(support::FileName const & old) const;
|
2010-10-26 12:54:31 +00:00
|
|
|
//@}
|
2007-10-21 10:50:56 +00:00
|
|
|
|
2010-10-26 12:54:31 +00:00
|
|
|
public:
|
2007-10-21 10:50:56 +00:00
|
|
|
/// Fill in the ErrorList with the TeXErrors
|
|
|
|
void bufferErrors(TeXErrors const &, ErrorList &) const;
|
2019-06-07 14:47:04 +00:00
|
|
|
/// Fill in the Citation/Reference ErrorList from the TeXErrors
|
|
|
|
void bufferRefs(TeXErrors const &, ErrorList &) const;
|
2007-10-21 10:50:56 +00:00
|
|
|
|
2011-10-29 20:14:48 +00:00
|
|
|
enum OutputWhat {
|
|
|
|
FullSource,
|
|
|
|
OnlyBody,
|
2012-04-23 17:55:13 +00:00
|
|
|
IncludedFile,
|
2011-10-29 21:00:23 +00:00
|
|
|
OnlyPreamble,
|
|
|
|
CurrentParagraph
|
2011-10-29 20:14:48 +00:00
|
|
|
};
|
|
|
|
|
2007-01-09 19:25:40 +00:00
|
|
|
/// Just a wrapper for writeLaTeXSource, first creating the ofstream.
|
Fix some problems with background cancellation.
The problem was that, if we killed export when some graphic was
being converted, or some external template was being handled, it
would only cancel that process, and then it would just continue.
To deal with that, we need to do a few things:
1. Modify the return values for some of the Converters routines,
and similarly the routines for external templates, so we can
tell when something has been canceled.
2. Throw an exception from InsetGraphics or InsetExternal when this
has happened during export, but ONLY when the Buffer is a clone.
We shouldn't be able to 'cancel' export when we're, say, generating
code for the preview pane, but this keeps us on the safe side..
The exception then has to be caught, obviously, back in the export
routines in Buffer.
Probably Coverity will be unhappy about something here, but I'll
deal with that problem as it arises.
2018-02-20 03:43:44 +00:00
|
|
|
ExportStatus makeLaTeXFile(support::FileName const & filename,
|
2011-10-22 15:10:43 +00:00
|
|
|
std::string const & original_path,
|
2003-11-05 12:06:20 +00:00
|
|
|
OutputParams const &,
|
2011-10-29 20:14:48 +00:00
|
|
|
OutputWhat output = FullSource) const;
|
2007-01-09 19:25:40 +00:00
|
|
|
/** Export the buffer to LaTeX.
|
2019-04-16 18:17:32 +00:00
|
|
|
If \p os is a file stream, and params().inputenc is "auto-legacy" or
|
|
|
|
"auto-legacy-plain", and the buffer contains text in different languages
|
2007-01-13 14:36:54 +00:00
|
|
|
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;
|
2016-06-19 02:39:38 +00:00
|
|
|
otexstream os(ofs);
|
2007-01-09 19:25:40 +00:00
|
|
|
ofs.open("test.tex");
|
2011-02-13 21:41:44 +00:00
|
|
|
writeLaTeXSource(os, ...);
|
2007-01-09 19:25:40 +00:00
|
|
|
ofs.close();
|
|
|
|
\endcode is NOT equivalent to \code
|
|
|
|
odocstringstream oss;
|
2016-06-19 02:39:38 +00:00
|
|
|
otexstream os(oss);
|
2011-02-13 21:41:44 +00:00
|
|
|
writeLaTeXSource(os, ...);
|
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
|
|
|
|
*/
|
Fix some problems with background cancellation.
The problem was that, if we killed export when some graphic was
being converted, or some external template was being handled, it
would only cancel that process, and then it would just continue.
To deal with that, we need to do a few things:
1. Modify the return values for some of the Converters routines,
and similarly the routines for external templates, so we can
tell when something has been canceled.
2. Throw an exception from InsetGraphics or InsetExternal when this
has happened during export, but ONLY when the Buffer is a clone.
We shouldn't be able to 'cancel' export when we're, say, generating
code for the preview pane, but this keeps us on the safe side..
The exception then has to be caught, obviously, back in the export
routines in Buffer.
Probably Coverity will be unhappy about something here, but I'll
deal with that problem as it arises.
2018-02-20 03:43:44 +00:00
|
|
|
ExportStatus writeLaTeXSource(otexstream & os,
|
2011-10-22 15:10:43 +00:00
|
|
|
std::string const & original_path,
|
2003-11-05 12:06:20 +00:00
|
|
|
OutputParams const &,
|
2011-10-29 20:14:48 +00:00
|
|
|
OutputWhat output = FullSource) const;
|
2001-11-26 11:08:43 +00:00
|
|
|
///
|
Fix some problems with background cancellation.
The problem was that, if we killed export when some graphic was
being converted, or some external template was being handled, it
would only cancel that process, and then it would just continue.
To deal with that, we need to do a few things:
1. Modify the return values for some of the Converters routines,
and similarly the routines for external templates, so we can
tell when something has been canceled.
2. Throw an exception from InsetGraphics or InsetExternal when this
has happened during export, but ONLY when the Buffer is a clone.
We shouldn't be able to 'cancel' export when we're, say, generating
code for the preview pane, but this keeps us on the safe side..
The exception then has to be caught, obviously, back in the export
routines in Buffer.
Probably Coverity will be unhappy about something here, but I'll
deal with that problem as it arises.
2018-02-20 03:43:44 +00:00
|
|
|
ExportStatus makeDocBookFile(support::FileName const & filename,
|
2003-11-05 12:06:20 +00:00
|
|
|
OutputParams const & runparams_in,
|
2011-10-29 20:14:48 +00:00
|
|
|
OutputWhat output = FullSource) const;
|
2006-08-04 13:59:12 +00:00
|
|
|
///
|
2020-06-08 21:27:49 +00:00
|
|
|
ExportStatus writeDocBookSource(odocstream & os,
|
2020-07-08 16:15:34 +00:00
|
|
|
OutputParams const & runparams_in,
|
|
|
|
OutputWhat output = FullSource) const;
|
2009-06-05 17:44:35 +00:00
|
|
|
///
|
Fix some problems with background cancellation.
The problem was that, if we killed export when some graphic was
being converted, or some external template was being handled, it
would only cancel that process, and then it would just continue.
To deal with that, we need to do a few things:
1. Modify the return values for some of the Converters routines,
and similarly the routines for external templates, so we can
tell when something has been canceled.
2. Throw an exception from InsetGraphics or InsetExternal when this
has happened during export, but ONLY when the Buffer is a clone.
We shouldn't be able to 'cancel' export when we're, say, generating
code for the preview pane, but this keeps us on the safe side..
The exception then has to be caught, obviously, back in the export
routines in Buffer.
Probably Coverity will be unhappy about something here, but I'll
deal with that problem as it arises.
2018-02-20 03:43:44 +00:00
|
|
|
ExportStatus makeLyXHTMLFile(support::FileName const & filename,
|
2011-06-20 21:08:56 +00:00
|
|
|
OutputParams const & runparams_in) const;
|
2009-06-05 17:44:35 +00:00
|
|
|
///
|
Fix some problems with background cancellation.
The problem was that, if we killed export when some graphic was
being converted, or some external template was being handled, it
would only cancel that process, and then it would just continue.
To deal with that, we need to do a few things:
1. Modify the return values for some of the Converters routines,
and similarly the routines for external templates, so we can
tell when something has been canceled.
2. Throw an exception from InsetGraphics or InsetExternal when this
has happened during export, but ONLY when the Buffer is a clone.
We shouldn't be able to 'cancel' export when we're, say, generating
code for the preview pane, but this keeps us on the safe side..
The exception then has to be caught, obviously, back in the export
routines in Buffer.
Probably Coverity will be unhappy about something here, but I'll
deal with that problem as it arises.
2018-02-20 03:43:44 +00:00
|
|
|
ExportStatus writeLyXHTMLSource(odocstream & os,
|
2009-06-05 17:44:35 +00:00
|
|
|
OutputParams const & runparams_in,
|
2011-10-29 20:14:48 +00:00
|
|
|
OutputWhat output = FullSource) 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
|
2020-02-28 06:39:06 +00:00
|
|
|
docstring 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
|
|
|
|
2017-03-05 19:12:07 +00:00
|
|
|
/// Whether or not disk file has been externally modified. Uses a checksum
|
|
|
|
/// which is accurate but slow, which can be a problem when it is frequently
|
|
|
|
/// used, or used for a large file on a slow (network) file system.
|
|
|
|
bool isChecksumModified() const;
|
|
|
|
|
|
|
|
/// Flag set by the FileSystemWatcher.
|
|
|
|
/// Fast but (not so) inaccurate, can be cleared by the user.
|
|
|
|
bool notifiesExternalModification() const;
|
|
|
|
void clearExternalModification() const;
|
2007-08-09 20:46:22 +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;
|
|
|
|
|
2012-05-06 18:06:28 +00:00
|
|
|
void setInternal(bool flag);
|
|
|
|
|
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
|
|
|
|
2013-04-19 21:26:58 +00:00
|
|
|
/// Returns 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
|
|
|
|
2016-01-10 18:46:01 +00:00
|
|
|
/** Contructs a file name of a referenced file (child doc, included graphics etc).
|
|
|
|
* Absolute names are returned as is. If the name is relative, it is
|
|
|
|
* interpreted relative to filePath() if the file exists, otherwise
|
|
|
|
* relative to the original path where the document was last saved.
|
|
|
|
* The original path may be different from filePath() if the document was
|
|
|
|
* later manually moved to a different location.
|
Correctly load documents moved elsewhere after save.
It is now possible opening documents that where manually moved to a
different location after they were saved and still produce an output.
Indeed, (hopefully) all needed included files are now still found.
When the moved document is saved again, all paths are accordingly updated.
Of course, for this to work, a document has to be saved in Format 490,
at least.
As an example, after converting the user guide to the last format, it can
be copied anywhere and opened without the need of adapting the paths of
included files or moving them to a proper place.
There is one glitch I am aware of. When moving a child document (but not
the master) the path to the master is correctly updated but it won't be
recognized as such. This is because LyX checks that the parent actually
includes this document but, of course, being the parent document not
touched, it appears not including this child. Anyway, it will also occur
when saving the child to a different location and the user is warned
on the terminal about this fact when the moved child is loaded.
However, there is no problem when it is the master that has been moved.
2015-05-16 17:51:53 +00:00
|
|
|
*/
|
2016-01-10 18:46:01 +00:00
|
|
|
support::DocFileName getReferencedFileName(std::string const & fn) const;
|
Correctly load documents moved elsewhere after save.
It is now possible opening documents that where manually moved to a
different location after they were saved and still produce an output.
Indeed, (hopefully) all needed included files are now still found.
When the moved document is saved again, all paths are accordingly updated.
Of course, for this to work, a document has to be saved in Format 490,
at least.
As an example, after converting the user guide to the last format, it can
be copied anywhere and opened without the need of adapting the paths of
included files or moving them to a proper place.
There is one glitch I am aware of. When moving a child document (but not
the master) the path to the master is correctly updated but it won't be
recognized as such. This is because LyX checks that the parent actually
includes this document but, of course, being the parent document not
touched, it appears not including this child. Anyway, it will also occur
when saving the child to a different location and the user is warned
on the terminal about this fact when the moved child is loaded.
However, there is no problem when it is the master that has been moved.
2015-05-16 17:51:53 +00:00
|
|
|
|
2017-01-08 08:39:46 +00:00
|
|
|
/// Format a file name for LaTeX output (absolute or relative or filename only,
|
|
|
|
/// depending on file and context)
|
|
|
|
std::string const prepareFileNameForLaTeX(std::string const &,
|
|
|
|
std::string const &, bool nice) const;
|
|
|
|
|
|
|
|
/** Returns a vector of bibliography (*.bib) file paths suitable for the
|
2019-03-29 14:45:55 +00:00
|
|
|
* output in the respective BibTeX/Biblatex macro and potential individual encoding
|
2017-01-08 08:39:46 +00:00
|
|
|
*/
|
2019-03-29 14:45:55 +00:00
|
|
|
std::vector<std::pair<docstring, std::string>> const prepareBibFilePaths(OutputParams const &,
|
2018-09-02 04:10:01 +00:00
|
|
|
const docstring_list & bibfilelist,
|
2017-01-08 08:39:46 +00:00
|
|
|
bool const extension = true) const;
|
|
|
|
|
Fix bug #4812 (Layout in local directory lost on Save As, Copying)
The "save-as" part of the bug is fixed by extending the \textclass tag
such that, if a local layout file is used, its path relative to the
document directory is now stored together with the name. If a relative
path cannot be used, an absolute one is used but, in this case, the
document is not usable on a different platform.
The "copy" part is fixed by introducing a new \origin tag, which is
written when the file is saved. This tag stores the absolute path of
the document directory. If the document is manually copied to a
different location, the local layout file is retrivied by using
\origin (which is only updated on save).
This new tag may prove useful also for locating other files when the
document is manually moved to a different directory.
As in the original implementation the files needed for the layout
(for example, a latex class) had to be in the same directory as the
layout file, this directory has also to be added to TEXINPUTS.
2015-05-13 19:40:51 +00:00
|
|
|
/** Returns the path where a local layout file lives.
|
|
|
|
* An empty string is returned for standard system and user layouts.
|
|
|
|
* If possible, it is always relative to the buffer path.
|
|
|
|
*/
|
|
|
|
std::string layoutPos() const;
|
|
|
|
|
|
|
|
/** Set the path to a local layout file.
|
|
|
|
* This must be an absolute path but, if possible, it is always
|
|
|
|
* stored as relative to the buffer path.
|
|
|
|
*/
|
|
|
|
void setLayoutPos(std::string const & path);
|
|
|
|
|
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.
|
2020-02-28 06:39:06 +00:00
|
|
|
std::string logName(LogType * type = nullptr) const;
|
2002-03-21 16:55:34 +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;
|
|
|
|
|
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;
|
2011-12-03 22:15:11 +00:00
|
|
|
|
2010-09-29 12:17:24 +00:00
|
|
|
/// \return true if this \c Buffer has children
|
|
|
|
bool hasChildren() const;
|
2011-12-03 22:15:11 +00:00
|
|
|
|
2010-09-29 13:05:57 +00:00
|
|
|
/// \return a list of the direct children of this Buffer.
|
|
|
|
/// this list has no duplicates and is in the order in which
|
|
|
|
/// the children appear.
|
|
|
|
ListOfBuffers getChildren() const;
|
2011-12-03 22:15:11 +00:00
|
|
|
|
2019-12-16 04:36:17 +00:00
|
|
|
/// \return a list of all descendants of this Buffer (children,
|
2010-09-29 13:05:57 +00:00
|
|
|
/// grandchildren, etc). this list has no duplicates and is in
|
|
|
|
/// the order in which the children appear.
|
2019-12-16 04:36:17 +00:00
|
|
|
ListOfBuffers getDescendants() const;
|
2008-07-20 17:52:55 +00:00
|
|
|
|
2010-09-29 13:05:57 +00:00
|
|
|
/// Collect all relative buffers, in the order in which they appear.
|
|
|
|
/// I.e., the "root" Buffer is first, then its first child, then any
|
|
|
|
/// of its children, etc. However, there are no duplicates in this
|
|
|
|
/// list.
|
|
|
|
/// This is "stable", too, in the sense that it returns the same
|
|
|
|
/// thing from whichever Buffer it is called.
|
|
|
|
ListOfBuffers allRelatives() const;
|
2009-12-30 18:40:18 +00:00
|
|
|
|
2017-03-01 21:03:44 +00:00
|
|
|
/// Is buffer read-only? True if it has either the read-only flag or the
|
|
|
|
/// externally modified flag.
|
2001-02-16 09:25:43 +00:00
|
|
|
bool isReadonly() const;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2017-03-01 21:03:44 +00:00
|
|
|
/// Does the buffer have the read-only flag?
|
|
|
|
bool hasReadonlyFlag() 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
|
|
|
|
|
|
|
/** 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
|
|
|
|
2017-11-05 01:23:25 +00:00
|
|
|
/// Bibliography information is cached in the Buffer, so we do not
|
2011-12-03 22:15:11 +00:00
|
|
|
/// have to check or read things over and over.
|
2017-11-05 01:23:25 +00:00
|
|
|
/// The cache exists only in the master buffer. When it is updated,
|
2010-08-10 14:26:34 +00:00
|
|
|
/// 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;
|
2018-10-13 09:06:24 +00:00
|
|
|
/// Clear the bibfiles cache
|
|
|
|
void clearBibFileCache() const;
|
2010-12-03 19:00:55 +00:00
|
|
|
/// Updates the cached bibliography information, checking first to see
|
|
|
|
/// whether the cache is valid. If so, we do nothing. If not, then we
|
|
|
|
/// reload all the BibTeX info.
|
2010-08-10 14:12:48 +00:00
|
|
|
/// Note that this operates on the master document.
|
2018-07-07 13:25:35 +00:00
|
|
|
void reloadBibInfoCache(bool const force = false) 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;
|
2018-03-22 14:52:23 +00:00
|
|
|
/// \return this buffer's bibliography information
|
|
|
|
BiblioInfo const & bibInfo() const;
|
2010-12-03 20:08:04 +00:00
|
|
|
/// collect bibliography info from the various insets in this buffer.
|
2017-10-18 07:20:31 +00:00
|
|
|
void collectBibKeys(support::FileNameList &) const;
|
2010-12-03 20:08:04 +00:00
|
|
|
/// add some BiblioInfo to our cache
|
|
|
|
void addBiblioInfo(BiblioInfo const & bi) const;
|
|
|
|
/// add a single piece of bibliography info to our cache
|
|
|
|
void addBibTeXInfo(docstring const & key, BibTeXInfo const & bi) const;
|
2000-05-19 16:46:01 +00:00
|
|
|
///
|
2013-02-02 18:23:21 +00:00
|
|
|
void makeCitationLabels() const;
|
|
|
|
///
|
2018-01-29 04:33:45 +00:00
|
|
|
void invalidateCiteLabels() const;
|
|
|
|
///
|
2011-05-07 23:02:53 +00:00
|
|
|
bool citeLabelsValid() const;
|
|
|
|
///
|
2006-10-21 00:16:43 +00:00
|
|
|
void getLabelList(std::vector<docstring> &) const;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2011-12-03 22:58:38 +00:00
|
|
|
/// This removes the .aux and .bbl files from the temp dir.
|
|
|
|
void removeBiblioTempFiles() const;
|
|
|
|
|
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;
|
2014-03-13 05:43:38 +00:00
|
|
|
///
|
|
|
|
BufferParams const & masterParams() 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;
|
2020-12-03 17:02:40 +00:00
|
|
|
/// Is document empty ?
|
|
|
|
bool empty() 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
|
|
|
|
2011-07-12 12:43:11 +00:00
|
|
|
/// FIXME: Needed by RenderPreview.
|
2011-07-12 13:41:42 +00:00
|
|
|
graphics::PreviewLoader * loader() const;
|
2010-10-29 20:00:51 +00:00
|
|
|
/// Update the LaTeX preview snippets associated with this buffer
|
|
|
|
void updatePreviews() const;
|
|
|
|
/// Remove any previewed LaTeX snippets associated with this buffer
|
|
|
|
void removePreviews() const;
|
2016-11-05 00:00:44 +00:00
|
|
|
///
|
|
|
|
graphics::Cache & graphicsCache() const;
|
2010-10-29 20:00:51 +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
|
2011-05-07 11:57:08 +00:00
|
|
|
void updateMacroInstances(UpdateType) const;
|
2007-12-21 20:42:46 +00:00
|
|
|
|
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
|
|
|
|
2010-12-20 18:15:39 +00:00
|
|
|
/// Collect user macro names at loading time
|
|
|
|
typedef std::set<docstring> UserMacroSet;
|
2010-12-21 14:52:18 +00:00
|
|
|
mutable UserMacroSet usermacros;
|
2010-12-20 18:15:39 +00:00
|
|
|
|
2007-10-13 09:04:52 +00:00
|
|
|
/// Replace the inset contents for insets which InsetCode is equal
|
2020-01-12 21:18:36 +00:00
|
|
|
/// to the passed \p inset_code. Handles undo.
|
2013-04-06 16:34:26 +00:00
|
|
|
void changeRefsIfUnique(docstring const & from, docstring const & to);
|
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
|
2016-06-02 20:58:52 +00:00
|
|
|
/// returns nullptr if Id to Row conversion is unsupported
|
|
|
|
unique_ptr<TexRow> getSourceCode(odocstream & os,
|
2015-08-04 22:16:40 +00:00
|
|
|
std::string const & format, pit_type par_begin,
|
|
|
|
pit_type par_end, OutputWhat output, bool master) 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.
|
2011-06-12 18:03:32 +00:00
|
|
|
ErrorList & errorList(std::string const & type) const;
|
2007-11-30 17:41:27 +00:00
|
|
|
|
|
|
|
/// 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
|
|
|
|
2011-10-27 15:50:50 +00:00
|
|
|
///
|
2011-10-27 20:00:11 +00:00
|
|
|
ExportStatus doExport(std::string const & target, bool put_in_tempdir) const;
|
2014-11-17 21:07:38 +00:00
|
|
|
/// Export buffer to format \p format and open the result in a suitable viewer.
|
|
|
|
/// Note: This has nothing to do with preview of graphics or math formulas.
|
2011-10-27 20:00:11 +00:00
|
|
|
ExportStatus preview(std::string const & format) const;
|
2015-05-03 05:22:03 +00:00
|
|
|
/// true if there was a previous preview this session of this buffer and
|
|
|
|
/// there was an error on the previous preview of this buffer.
|
2019-12-24 17:12:22 +00:00
|
|
|
bool freshStartRequired() const;
|
|
|
|
///
|
|
|
|
void requireFreshStart(bool const b) const;
|
2007-11-30 17:41:27 +00:00
|
|
|
|
2011-10-27 15:50:50 +00:00
|
|
|
private:
|
2014-11-16 19:51:42 +00:00
|
|
|
///
|
|
|
|
ExportStatus doExport(std::string const & target, bool put_in_tempdir,
|
|
|
|
std::string & result_file) const;
|
2011-09-15 01:07:49 +00:00
|
|
|
/// target is a format name optionally followed by a space
|
|
|
|
/// and a destination file-name
|
2011-10-27 20:00:06 +00:00
|
|
|
ExportStatus doExport(std::string const & target, 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
|
|
|
///
|
2016-06-29 09:22:13 +00:00
|
|
|
ExportStatus preview(std::string const & format, bool includeall) const;
|
2011-12-06 22:17:06 +00:00
|
|
|
///
|
|
|
|
void setMathFlavor(OutputParams & op) const;
|
2011-10-27 15:50:50 +00:00
|
|
|
|
|
|
|
public:
|
2010-07-21 21:51:33 +00:00
|
|
|
///
|
|
|
|
bool isExporting() const;
|
2008-03-02 15:27:35 +00:00
|
|
|
|
2018-12-29 09:08:02 +00:00
|
|
|
/// A collection of InsetRef insets and their position in the buffer
|
2010-01-28 17:37:22 +00:00
|
|
|
typedef std::vector<std::pair<Inset *, ParIterator> > References;
|
2018-12-29 09:08:02 +00:00
|
|
|
/// Get all InsetRef insets and their positions associated with
|
|
|
|
/// the InsetLabel with the label string \p label
|
2008-03-02 15:27:35 +00:00
|
|
|
References const & references(docstring const & label) const;
|
2018-12-29 09:08:02 +00:00
|
|
|
/// Add an InsetRef at position \p it to the Insetlabel
|
|
|
|
/// with the label string \p label
|
2013-03-18 23:32:30 +00:00
|
|
|
void addReference(docstring const & label, Inset * inset, ParIterator it);
|
2018-12-29 09:08:02 +00:00
|
|
|
/// Clear the whole reference cache
|
2008-03-02 15:27:35 +00:00
|
|
|
void clearReferenceCache() const;
|
2018-12-29 09:08:02 +00:00
|
|
|
/// Set the InsetLabel for a given \p label string. \p active
|
|
|
|
/// determines whether this is an active label (see @ref activeLabel)
|
|
|
|
void setInsetLabel(docstring const & label, InsetLabel const * il,
|
|
|
|
bool const active);
|
|
|
|
/// \return the InsetLabel associated with this \p label string
|
2018-12-29 09:26:28 +00:00
|
|
|
/// If \p active is true we only return active labels
|
|
|
|
/// (see @ref activeLabel)
|
2018-12-29 09:08:02 +00:00
|
|
|
InsetLabel const * insetLabel(docstring const & label,
|
|
|
|
bool const active = false) const;
|
|
|
|
/// \return true if this \param label is an active label.
|
|
|
|
/// Inactive labels are currently deleted labels (in ct mode)
|
|
|
|
bool activeLabel(docstring const & label) const;
|
2008-03-02 15:27:35 +00:00
|
|
|
|
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-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;
|
2011-12-03 22:15:11 +00:00
|
|
|
///
|
2020-03-06 12:23:01 +00:00
|
|
|
void updateBuffer(ParIterator & parit, UpdateType utype, bool const deleted = false) const;
|
2021-01-28 09:10:18 +00:00
|
|
|
/// Forces an updateBuffer() call
|
|
|
|
void forceUpdate() const;
|
|
|
|
/// Do we need to call updateBuffer()?
|
|
|
|
bool needUpdate() 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();
|
2012-05-19 08:16:28 +00:00
|
|
|
///
|
|
|
|
void checkMasterBuffer();
|
2009-04-04 16:40:47 +00:00
|
|
|
|
2015-05-05 20:29:22 +00:00
|
|
|
/// If the document is being saved to a new location and the named file
|
|
|
|
/// exists at the old location, return its updated path relative to the
|
|
|
|
/// new buffer path if possible, otherwise return its absolute path.
|
2015-05-03 21:55:19 +00:00
|
|
|
/// In all other cases, this is a no-op and name is returned unchanged.
|
2015-05-05 20:29:22 +00:00
|
|
|
/// If a non-empty ext is given, the existence of name.ext is checked
|
|
|
|
/// but the returned path will not contain this extension.
|
Correctly load documents moved elsewhere after save.
It is now possible opening documents that where manually moved to a
different location after they were saved and still produce an output.
Indeed, (hopefully) all needed included files are now still found.
When the moved document is saved again, all paths are accordingly updated.
Of course, for this to work, a document has to be saved in Format 490,
at least.
As an example, after converting the user guide to the last format, it can
be copied anywhere and opened without the need of adapting the paths of
included files or moving them to a proper place.
There is one glitch I am aware of. When moving a child document (but not
the master) the path to the master is correctly updated but it won't be
recognized as such. This is because LyX checks that the parent actually
includes this document but, of course, being the parent document not
touched, it appears not including this child. Anyway, it will also occur
when saving the child to a different location and the user is warned
on the terminal about this fact when the moved child is loaded.
However, there is no problem when it is the master that has been moved.
2015-05-16 17:51:53 +00:00
|
|
|
/// Similarly, when loading a document that was moved from the location
|
|
|
|
/// where it was saved, return the correct path relative to the new
|
|
|
|
/// location.
|
2015-05-05 20:29:22 +00:00
|
|
|
std::string includedFilePath(std::string const & name,
|
|
|
|
std::string const & ext = empty_string()) const;
|
2015-05-03 21:55:19 +00:00
|
|
|
|
2012-01-12 07:03:24 +00:00
|
|
|
/// compute statistics between \p from and \p to
|
|
|
|
/// \p from initial position
|
|
|
|
/// \p to points to the end position
|
|
|
|
/// \p skipNoOutput if notes etc. should be ignored
|
|
|
|
void updateStatistics(DocIterator & from, DocIterator & to,
|
|
|
|
bool skipNoOutput = true) const;
|
|
|
|
/// statistics accessor functions
|
|
|
|
int wordCount() const;
|
|
|
|
int charCount(bool with_blanks) const;
|
|
|
|
|
2021-01-28 09:10:18 +00:00
|
|
|
///
|
2020-01-12 19:09:41 +00:00
|
|
|
bool areChangesPresent() const;
|
2020-01-12 17:33:01 +00:00
|
|
|
|
2017-11-05 01:23:25 +00:00
|
|
|
///
|
2018-09-02 04:10:01 +00:00
|
|
|
void registerBibfiles(docstring_list const & bf) const;
|
|
|
|
///
|
|
|
|
support::FileName getBibfilePath(docstring const & bibid) const;
|
2016-01-30 23:14:36 +00:00
|
|
|
|
2020-04-25 21:34:27 +00:00
|
|
|
/// routines for dealing with possible self-inclusion
|
|
|
|
void pushIncludedBuffer(Buffer const * buf) const;
|
|
|
|
void popIncludedBuffer() const;
|
|
|
|
bool isBufferIncluded(Buffer const * buf) const;
|
|
|
|
private:
|
|
|
|
void clearIncludeList() const;
|
|
|
|
|
2003-09-09 11:24:33 +00:00
|
|
|
private:
|
2011-10-30 11:43:45 +00:00
|
|
|
friend class MarkAsExporting;
|
|
|
|
/// mark the buffer as busy exporting something, or not
|
|
|
|
void setExportStatus(bool e) const;
|
|
|
|
|
2013-03-18 23:32:30 +00:00
|
|
|
///
|
|
|
|
References & getReferenceCache(docstring const & label);
|
2010-11-18 17:50:33 +00:00
|
|
|
/// Change name of buffer. Updates "read-only" flag.
|
|
|
|
void setFileName(support::FileName const & fname);
|
2007-10-20 10:51:13 +00:00
|
|
|
///
|
2010-02-08 17:15:00 +00:00
|
|
|
void getLanguages(std::set<Language const *> &) const;
|
2010-12-03 19:00:55 +00:00
|
|
|
/// Checks whether any of the referenced bibfiles have changed since the
|
|
|
|
/// last time we loaded the cache. Note that this does NOT update the
|
|
|
|
/// cached information.
|
|
|
|
void checkIfBibInfoCacheIsValid() const;
|
2010-08-09 17:14:45 +00:00
|
|
|
/// Return the list with all bibfiles in use (including bibfiles
|
|
|
|
/// of loaded child documents).
|
2018-09-02 04:10:01 +00:00
|
|
|
docstring_list const &
|
2017-11-05 01:23:25 +00:00
|
|
|
getBibfiles(UpdateScope scope = UpdateMaster) const;
|
2010-09-29 13:05:57 +00:00
|
|
|
///
|
|
|
|
void collectChildren(ListOfBuffers & children, bool grand_children) const;
|
2003-09-09 11:24:33 +00:00
|
|
|
|
2011-08-24 19:10:40 +00:00
|
|
|
/// noncopyable
|
|
|
|
Buffer(Buffer const &);
|
|
|
|
void operator=(Buffer 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
|
|
|
|
2013-04-21 01:07:07 +00:00
|
|
|
/// Helper class, to guarantee that the export status
|
|
|
|
/// gets reset properly. To use, simply create a local variable:
|
|
|
|
/// MarkAsExporting mex(bufptr);
|
|
|
|
/// and leave the rest to us.
|
|
|
|
class MarkAsExporting {
|
|
|
|
public:
|
|
|
|
MarkAsExporting(Buffer const * buf) : buf_(buf)
|
|
|
|
{
|
|
|
|
buf_->setExportStatus(true);
|
|
|
|
}
|
|
|
|
~MarkAsExporting()
|
|
|
|
{
|
|
|
|
buf_->setExportStatus(false);
|
|
|
|
}
|
|
|
|
private:
|
|
|
|
Buffer const * const buf_;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
} // namespace lyx
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
#endif
|