1999-09-27 18:44:28 +00:00
|
|
|
|
// -*- C++ -*-
|
|
|
|
|
/* This file is part of
|
1999-12-16 06:43:25 +00:00
|
|
|
|
* ======================================================
|
2000-02-04 09:38:32 +00:00
|
|
|
|
*
|
|
|
|
|
* LyX, The Document Processor
|
|
|
|
|
* Copyright 1995 Matthias Ettrich
|
|
|
|
|
*
|
|
|
|
|
* This file is Copyleft 1996
|
|
|
|
|
* Lars Gullik Bj<EFBFBD>nnes
|
|
|
|
|
*
|
|
|
|
|
* ====================================================== */
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
1999-11-04 01:40:20 +00:00
|
|
|
|
#ifndef BUFFER_H
|
|
|
|
|
#define BUFFER_H
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
|
#pragma interface
|
|
|
|
|
#endif
|
|
|
|
|
|
2000-02-04 09:38:32 +00:00
|
|
|
|
#include "LString.h"
|
2001-06-25 00:06:33 +00:00
|
|
|
|
#include "undo.h"
|
|
|
|
|
#include "undostack.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
|
#include "lyxvc.h"
|
|
|
|
|
#include "bufferparams.h"
|
|
|
|
|
#include "texrow.h"
|
2001-06-25 00:06:33 +00:00
|
|
|
|
#include "paragraph.h"
|
2000-04-08 17:02:02 +00:00
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
|
class BufferView;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
class LyXRC;
|
|
|
|
|
class TeXErrors;
|
|
|
|
|
class LaTeXFeatures;
|
2000-10-10 12:36:36 +00:00
|
|
|
|
class Language;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2001-08-03 18:28:11 +00:00
|
|
|
|
// When lyx 1.3.x starts we should enable this
|
|
|
|
|
// btw. we should also test this with 1.2 so that we
|
|
|
|
|
// do not get any surprises. (Lgb)
|
|
|
|
|
//#define NO_COMPABILITY 1
|
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
|
|
|
|
struct DEPCLEAN {
|
|
|
|
|
///
|
|
|
|
|
bool clean;
|
|
|
|
|
///
|
1999-10-02 16:21:10 +00:00
|
|
|
|
string master;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2000-01-24 18:34:46 +00:00
|
|
|
|
DEPCLEAN * next;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/** The buffer object.
|
2001-06-25 00:06:33 +00:00
|
|
|
|
This is the buffer object. It contains all the informations about
|
1999-09-27 18:44:28 +00:00
|
|
|
|
a document loaded into LyX. I am not sure if the class is complete or
|
|
|
|
|
minimal, probably not.
|
2001-02-16 09:25:43 +00:00
|
|
|
|
\author Lars Gullik Bj<EFBFBD>nnes
|
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
|
|
|
|
};
|
|
|
|
|
|
2001-02-16 09:25:43 +00:00
|
|
|
|
/** Constructor
|
|
|
|
|
\param file
|
|
|
|
|
\param b optional \c false by default
|
|
|
|
|
*/
|
2000-04-08 17:02:02 +00:00
|
|
|
|
explicit Buffer(string const & file, bool b = false);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
|
/// Destructor
|
1999-09-27 18:44:28 +00:00
|
|
|
|
~Buffer();
|
|
|
|
|
|
2001-02-16 09:25:43 +00:00
|
|
|
|
/** Save the buffer's parameters as user default.
|
|
|
|
|
This function saves a file \c user_lyxdir/templates/defaults.lyx
|
1999-12-16 06:43:25 +00:00
|
|
|
|
which parameters are those of the current buffer. This file
|
|
|
|
|
is used as a default template when creating a new
|
2001-02-16 09:25:43 +00:00
|
|
|
|
file. Returns \c true on success.
|
1999-12-16 06:43:25 +00:00
|
|
|
|
*/
|
1999-09-27 18:44:28 +00:00
|
|
|
|
bool saveParamsAsDefaults();
|
|
|
|
|
|
2000-08-07 20:58:24 +00:00
|
|
|
|
/** High-level interface to buffer functionality.
|
1999-12-16 06:43:25 +00:00
|
|
|
|
This function parses a command string and executes it
|
|
|
|
|
*/
|
2001-06-28 10:25:20 +00:00
|
|
|
|
bool dispatch(string const & command);
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
|
|
|
|
/// Maybe we know the function already by number...
|
2001-06-28 10:25:20 +00:00
|
|
|
|
bool dispatch(int ac, string const & argument);
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
2001-02-16 09:25:43 +00:00
|
|
|
|
///
|
2000-07-14 14:57:20 +00:00
|
|
|
|
void resizeInsets(BufferView *);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2001-02-16 09:25:43 +00:00
|
|
|
|
/// Update window titles of all users.
|
2000-02-22 00:36:17 +00:00
|
|
|
|
void updateTitles() const;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2001-02-16 09:25:43 +00:00
|
|
|
|
/// Reset autosave timers for all users.
|
2000-02-22 00:36:17 +00:00
|
|
|
|
void resetAutosaveTimers() const;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
/** Adds the BufferView to the users list.
|
2001-02-16 09:25:43 +00:00
|
|
|
|
Later this func will insert the \c BufferView into a real list,
|
1999-12-16 06:43:25 +00:00
|
|
|
|
not just setting a pointer.
|
|
|
|
|
*/
|
2001-02-16 09:25:43 +00:00
|
|
|
|
void addUser(BufferView * u);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2000-08-07 20:58:24 +00:00
|
|
|
|
/** Removes the #BufferView# from the users list.
|
1999-12-16 06:43:25 +00:00
|
|
|
|
Since we only can have one at the moment, we just reset it.
|
|
|
|
|
*/
|
2001-02-16 09:25:43 +00:00
|
|
|
|
void delUser(BufferView *);
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2001-02-16 09:25:43 +00:00
|
|
|
|
void redraw();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2001-02-16 09:25:43 +00:00
|
|
|
|
/// Load the autosaved file.
|
1999-09-27 18:44:28 +00:00
|
|
|
|
void loadAutoSaveFile();
|
|
|
|
|
|
|
|
|
|
/** Reads a file.
|
2001-02-16 09:25:43 +00:00
|
|
|
|
\param par if != 0 insert the file.
|
|
|
|
|
\return \c false if method fails.
|
2000-08-07 20:58:24 +00:00
|
|
|
|
*/
|
2001-06-25 00:06:33 +00:00
|
|
|
|
bool readFile(LyXLex &, Paragraph * par = 0);
|
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.
|
|
|
|
|
\return \c false if file is not completely read.
|
2000-08-07 20:58:24 +00:00
|
|
|
|
*/
|
2001-06-25 00:06:33 +00:00
|
|
|
|
bool readLyXformat2(LyXLex &, Paragraph * par = 0);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2000-08-07 20:58:24 +00:00
|
|
|
|
/// This parses a single LyXformat-Token.
|
2001-06-25 00:06:33 +00:00
|
|
|
|
bool parseSingleLyXformat2Token(LyXLex &, Paragraph *& par,
|
|
|
|
|
Paragraph *& return_par,
|
2000-04-08 17:02:02 +00:00
|
|
|
|
string const & token, int & pos,
|
2001-06-25 00:06:33 +00:00
|
|
|
|
Paragraph::depth_type & depth,
|
|
|
|
|
LyXFont &);
|
2001-07-08 12:52:16 +00:00
|
|
|
|
///
|
2001-07-23 09:11:14 +00:00
|
|
|
|
void insertStringAsLines(Paragraph *&, Paragraph::size_type &,
|
|
|
|
|
LyXFont const &, string const &) const;
|
2001-08-03 18:28:11 +00:00
|
|
|
|
#ifndef NO_COMPABILITY
|
2001-07-23 09:11:14 +00:00
|
|
|
|
///
|
2001-07-08 12:52:16 +00:00
|
|
|
|
void insertErtContents(Paragraph * par, int & pos,
|
|
|
|
|
LyXFont const & font,
|
|
|
|
|
bool set_inactive = true);
|
2001-08-03 18:28:11 +00:00
|
|
|
|
#endif
|
2001-07-09 09:16:00 +00:00
|
|
|
|
///
|
|
|
|
|
Paragraph * getParFromID(int id) const;
|
2000-07-24 21:49:58 +00:00
|
|
|
|
private:
|
2000-08-07 20:58:24 +00:00
|
|
|
|
/// Parse a single inset.
|
2001-06-25 00:06:33 +00:00
|
|
|
|
void readInset(LyXLex &, Paragraph *& par, int & pos, LyXFont &);
|
2000-07-24 21:49:58 +00:00
|
|
|
|
public:
|
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;
|
2000-02-22 00:36:17 +00:00
|
|
|
|
|
2001-02-16 09:25:43 +00:00
|
|
|
|
/// Write file. Returns \c false if unsuccesful.
|
2000-02-22 00:36:17 +00:00
|
|
|
|
bool writeFile(string const &, bool) const;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
///
|
1999-10-02 16:21:10 +00:00
|
|
|
|
void writeFileAscii(string const & , int);
|
2000-09-27 17:07:33 +00:00
|
|
|
|
///
|
2000-09-26 15:25:14 +00:00
|
|
|
|
void writeFileAscii(std::ostream &, int);
|
2000-09-27 17:07:33 +00:00
|
|
|
|
///
|
2001-06-25 00:06:33 +00:00
|
|
|
|
string const asciiParagraph(Paragraph const *,
|
2000-09-27 17:07:33 +00:00
|
|
|
|
unsigned int linelen) const;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
1999-10-02 16:21:10 +00:00
|
|
|
|
void makeLaTeXFile(string const & filename,
|
|
|
|
|
string const & original_path,
|
1999-09-27 18:44:28 +00:00
|
|
|
|
bool nice, bool only_body = false);
|
2000-08-07 20:58:24 +00:00
|
|
|
|
/** LaTeX all paragraphs from par to endpar.
|
2001-02-16 09:25:43 +00:00
|
|
|
|
\param \a endpar if == 0 then to the end
|
2000-08-07 20:58:24 +00:00
|
|
|
|
*/
|
2001-06-25 00:06:33 +00:00
|
|
|
|
void latexParagraphs(std::ostream & os, Paragraph * par,
|
|
|
|
|
Paragraph * endpar, TexRow & texrow) const;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2000-10-27 10:04:51 +00:00
|
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
|
void simpleDocBookOnePar(std::ostream &, string & extra,
|
2001-06-25 00:06:33 +00:00
|
|
|
|
Paragraph * par, int & desc_on,
|
|
|
|
|
Paragraph::depth_type depth) const ;
|
2000-10-27 10:04:51 +00:00
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
|
|
|
|
int runChktex();
|
|
|
|
|
|
|
|
|
|
///
|
2000-07-01 12:54:45 +00:00
|
|
|
|
void makeLinuxDocFile(string const & filename,
|
|
|
|
|
bool nice, bool only_body = false);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2000-07-01 12:54:45 +00:00
|
|
|
|
void makeDocBookFile(string const & filename,
|
|
|
|
|
bool nice, bool only_body = false);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
/// returns the main language for the buffer (document)
|
2001-06-28 10:25:20 +00:00
|
|
|
|
Language const * getLanguage() const;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2001-02-16 09:25:43 +00:00
|
|
|
|
bool isLyxClean() 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
|
|
|
|
///
|
1999-10-02 16:21:10 +00:00
|
|
|
|
bool isDepClean(string const & name) const;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
///
|
2001-02-16 09:25:43 +00:00
|
|
|
|
void markLyxClean() const;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
///
|
2001-02-16 09:25:43 +00:00
|
|
|
|
void markBakClean();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
///
|
1999-10-02 16:21:10 +00:00
|
|
|
|
void markDepClean(string const & name);
|
1999-09-27 18:44:28 +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
|
|
|
|
|
|
|
|
|
///
|
2001-02-16 09:25:43 +00:00
|
|
|
|
bool isUnnamed();
|
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
|
|
|
|
|
2001-02-16 09:25:43 +00:00
|
|
|
|
/// Returns the buffers filename.
|
|
|
|
|
string const & fileName() const;
|
1999-09-27 18:44:28 +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
|
|
|
|
*/
|
2000-09-14 17:53:12 +00:00
|
|
|
|
string const getLatexName(bool no_path = true) const;
|
1999-12-03 13:51:01 +00:00
|
|
|
|
|
2001-02-16 09:25:43 +00:00
|
|
|
|
/// Get the name and type of the log.
|
|
|
|
|
std::pair<LogType, string> const getLogName() const;
|
2001-02-06 17:41:42 +00:00
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
/// Change name of buffer. Updates "read-only" flag.
|
2000-10-12 00:11:06 +00:00
|
|
|
|
void setFileName(string const & newfile);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
/// Name of the document's parent
|
1999-10-02 16:21:10 +00:00
|
|
|
|
void setParentName(string 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
|
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 LinuxDoc document
|
1999-11-15 12:01:38 +00:00
|
|
|
|
bool isLinuxDoc() 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;
|
2001-02-16 09:25:43 +00:00
|
|
|
|
/** returns \c true if the buffer contains either a LinuxDoc
|
2000-04-11 22:55:29 +00:00
|
|
|
|
or DocBook document */
|
1999-11-15 12:01:38 +00:00
|
|
|
|
bool isSGML() const;
|
2001-02-16 09:25:43 +00:00
|
|
|
|
/// returns \c true if the buffer contains a Wed document
|
1999-11-15 12:01:38 +00:00
|
|
|
|
bool isLiterate() const;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
///
|
|
|
|
|
void setPaperStuff();
|
|
|
|
|
|
|
|
|
|
/** 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
|
|
|
|
|
|
|
|
|
///
|
2000-09-14 17:53:12 +00:00
|
|
|
|
string const getIncludeonlyList(char delim = ',');
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2001-03-11 18:39:00 +00:00
|
|
|
|
std::vector<std::pair<string, string> > const getBibkeyList();
|
2000-05-19 16:46:01 +00:00
|
|
|
|
///
|
|
|
|
|
struct TocItem {
|
2001-06-25 00:06:33 +00:00
|
|
|
|
TocItem(Paragraph * p, int d, string const & s)
|
2001-03-13 13:53:58 +00:00
|
|
|
|
: par(p), depth(d), str(s) {}
|
2000-08-07 20:58:24 +00:00
|
|
|
|
///
|
2001-06-25 00:06:33 +00:00
|
|
|
|
Paragraph * par;
|
2000-08-07 20:58:24 +00:00
|
|
|
|
///
|
2000-05-19 16:46:01 +00:00
|
|
|
|
int depth;
|
2000-08-07 20:58:24 +00:00
|
|
|
|
///
|
2000-05-19 16:46:01 +00:00
|
|
|
|
string str;
|
|
|
|
|
};
|
2000-05-20 21:37:05 +00:00
|
|
|
|
///
|
2001-03-12 01:43:12 +00:00
|
|
|
|
typedef std::vector<TocItem> SingleList;
|
|
|
|
|
///
|
|
|
|
|
typedef std::map<string, SingleList> Lists;
|
|
|
|
|
///
|
|
|
|
|
Lists const getLists() const;
|
2000-05-19 16:46:01 +00:00
|
|
|
|
///
|
2000-09-14 17:53:12 +00:00
|
|
|
|
std::vector<string> const getLabelList();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
/** This will clearly have to change later. Later we can have more
|
1999-12-16 06:43:25 +00:00
|
|
|
|
than one user per buffer. */
|
2001-02-16 09:25:43 +00:00
|
|
|
|
BufferView * getUser() 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);
|
2000-04-10 21:40:13 +00:00
|
|
|
|
///
|
|
|
|
|
bool isMultiLingual();
|
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
/// Does this mean that this is buffer local?
|
|
|
|
|
UndoStack undostack;
|
|
|
|
|
|
|
|
|
|
/// Does this mean that this is buffer local?
|
|
|
|
|
UndoStack redostack;
|
|
|
|
|
|
|
|
|
|
///
|
|
|
|
|
BufferParams params;
|
|
|
|
|
|
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
|
|
|
|
*/
|
2001-06-25 00:06:33 +00:00
|
|
|
|
Paragraph * paragraph;
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
2001-02-16 09:25:43 +00:00
|
|
|
|
/// LyX version control object.
|
1999-09-27 18:44:28 +00:00
|
|
|
|
LyXVC lyxvc;
|
|
|
|
|
|
2001-02-16 09:25:43 +00:00
|
|
|
|
/// Where to put temporary files.
|
1999-10-02 16:21:10 +00:00
|
|
|
|
string tmppath;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2001-02-16 09:25:43 +00:00
|
|
|
|
/// The path to the document file.
|
1999-10-02 16:21:10 +00:00
|
|
|
|
string filepath;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2001-02-16 09:25:43 +00:00
|
|
|
|
/** If we are writing a nice LaTeX file or not.
|
|
|
|
|
While writing as LaTeX, tells whether we are
|
1999-09-27 18:44:28 +00:00
|
|
|
|
doing a 'nice' LaTeX file */
|
|
|
|
|
bool niceFile;
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
2000-01-08 21:02:58 +00:00
|
|
|
|
/// Used when typesetting to place errorboxes.
|
|
|
|
|
TexRow texrow;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
private:
|
|
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
|
void docBookHandleCaption(std::ostream & os, string & inner_tag,
|
2001-06-25 00:06:33 +00:00
|
|
|
|
Paragraph::depth_type depth, int desc_on,
|
|
|
|
|
Paragraph * & par);
|
2001-03-21 23:38:07 +00:00
|
|
|
|
/// Open SGML/XML tag.
|
2001-06-25 00:06:33 +00:00
|
|
|
|
void sgmlOpenTag(std::ostream & os, Paragraph::depth_type depth,
|
1999-11-15 12:01:38 +00:00
|
|
|
|
string const & latexname) const;
|
2001-03-21 23:38:07 +00:00
|
|
|
|
/// Closes SGML/XML tag.
|
2001-06-25 00:06:33 +00:00
|
|
|
|
void sgmlCloseTag(std::ostream & os, Paragraph::depth_type depth,
|
1999-11-15 12:01:38 +00:00
|
|
|
|
string const & latexname) const;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
|
void linuxDocError(Paragraph * par, int pos,
|
2000-09-14 17:53:12 +00:00
|
|
|
|
string const & message);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
|
void simpleLinuxDocOnePar(std::ostream & os, Paragraph * par,
|
2001-06-25 00:06:33 +00:00
|
|
|
|
Paragraph::depth_type depth);
|
2000-02-29 02:19:17 +00:00
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
/// is save needed
|
2000-02-22 00:36:17 +00:00
|
|
|
|
mutable bool lyx_clean;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
/// is autosave needed
|
2000-02-22 00:36:17 +00:00
|
|
|
|
mutable bool bak_clean;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2000-07-26 13:43:16 +00:00
|
|
|
|
/// is this a unnamed file (New...)
|
|
|
|
|
bool unnamed;
|
|
|
|
|
|
2000-08-07 20:58:24 +00:00
|
|
|
|
/// is regenerating #.tex# necessary
|
1999-11-15 12:01:38 +00:00
|
|
|
|
DEPCLEAN * dep_clean;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
/// buffer is r/o
|
|
|
|
|
bool read_only;
|
|
|
|
|
|
|
|
|
|
/// name of the file the buffer is associated with.
|
1999-10-02 16:21:10 +00:00
|
|
|
|
string filename;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
/// Format number of buffer
|
2001-01-11 11:06:10 +00:00
|
|
|
|
int file_format;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
/** A list of views using this buffer.
|
1999-12-16 06:43:25 +00:00
|
|
|
|
Why not keep a list of the BufferViews that use this buffer?
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
1999-12-16 06:43:25 +00:00
|
|
|
|
At least then we don't have to do a lot of magic like:
|
2000-08-07 20:58:24 +00:00
|
|
|
|
#buffer->lyx_gui->bufferview->updateLayoutChoice#. Just ask each
|
|
|
|
|
of the buffers in the list of users to do a #updateLayoutChoice#.
|
1999-12-16 06:43:25 +00:00
|
|
|
|
*/
|
1999-11-15 12:01:38 +00:00
|
|
|
|
BufferView * users;
|
2000-05-19 16:46:01 +00:00
|
|
|
|
|
2000-05-20 21:37:05 +00:00
|
|
|
|
public:
|
2000-08-07 20:58:24 +00:00
|
|
|
|
///
|
2000-05-19 16:46:01 +00:00
|
|
|
|
class inset_iterator {
|
|
|
|
|
public:
|
2000-10-12 15:17:42 +00:00
|
|
|
|
typedef std::input_iterator_tag iterator_category;
|
2000-10-11 21:06:43 +00:00
|
|
|
|
typedef Inset value_type;
|
|
|
|
|
typedef ptrdiff_t difference_type;
|
|
|
|
|
typedef Inset * pointer;
|
|
|
|
|
typedef Inset & reference;
|
|
|
|
|
|
|
|
|
|
|
2000-08-07 20:58:24 +00:00
|
|
|
|
///
|
2000-05-19 16:46:01 +00:00
|
|
|
|
inset_iterator() : par(0) /*, it(0)*/ {}
|
2000-08-07 20:58:24 +00:00
|
|
|
|
//
|
2001-06-25 00:06:33 +00:00
|
|
|
|
inset_iterator(Paragraph * paragraph) : par(paragraph) {
|
2001-06-28 10:25:20 +00:00
|
|
|
|
setParagraph();
|
2000-05-19 16:46:01 +00:00
|
|
|
|
}
|
2000-08-07 20:58:24 +00:00
|
|
|
|
///
|
2001-06-25 00:06:33 +00:00
|
|
|
|
inset_iterator(Paragraph * paragraph,
|
|
|
|
|
Paragraph::size_type pos);
|
2000-08-07 20:58:24 +00:00
|
|
|
|
///
|
2000-10-11 21:06:43 +00:00
|
|
|
|
inset_iterator & operator++() { // prefix ++
|
2000-05-19 16:46:01 +00:00
|
|
|
|
if (par) {
|
|
|
|
|
++it;
|
|
|
|
|
if (it == par->inset_iterator_end()) {
|
2001-03-09 00:56:42 +00:00
|
|
|
|
par = par->next();
|
2001-06-28 10:25:20 +00:00
|
|
|
|
setParagraph();
|
2000-05-19 16:46:01 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
2000-08-07 20:58:24 +00:00
|
|
|
|
///
|
2000-10-11 21:06:43 +00:00
|
|
|
|
inset_iterator operator++(int) { // postfix ++
|
|
|
|
|
inset_iterator tmp(par, it.getPos());
|
|
|
|
|
if (par) {
|
|
|
|
|
++it;
|
|
|
|
|
if (it == par->inset_iterator_end()) {
|
2001-03-09 00:56:42 +00:00
|
|
|
|
par = par->next();
|
2001-06-28 10:25:20 +00:00
|
|
|
|
setParagraph();
|
2000-10-11 21:06:43 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return tmp;
|
|
|
|
|
}
|
|
|
|
|
///
|
|
|
|
|
Inset * operator*() { return *it; }
|
|
|
|
|
|
2000-08-07 20:58:24 +00:00
|
|
|
|
///
|
2001-06-25 00:06:33 +00:00
|
|
|
|
Paragraph * getPar() { return par; }
|
2000-08-07 20:58:24 +00:00
|
|
|
|
///
|
2001-06-25 00:06:33 +00:00
|
|
|
|
Paragraph::size_type getPos() const { return it.getPos(); }
|
2000-08-07 20:58:24 +00:00
|
|
|
|
///
|
2000-05-20 21:37:05 +00:00
|
|
|
|
friend
|
|
|
|
|
bool operator==(inset_iterator const & iter1,
|
2000-08-07 20:58:24 +00:00
|
|
|
|
inset_iterator const & iter2);
|
2000-05-19 16:46:01 +00:00
|
|
|
|
private:
|
2000-08-07 20:58:24 +00:00
|
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
|
void setParagraph();
|
2000-08-07 20:58:24 +00:00
|
|
|
|
///
|
2001-06-25 00:06:33 +00:00
|
|
|
|
Paragraph * par;
|
2000-08-07 20:58:24 +00:00
|
|
|
|
///
|
2001-06-25 00:06:33 +00:00
|
|
|
|
Paragraph::inset_iterator it;
|
2000-05-19 16:46:01 +00:00
|
|
|
|
};
|
2000-05-20 21:37:05 +00:00
|
|
|
|
|
2000-05-19 16:46:01 +00:00
|
|
|
|
///
|
|
|
|
|
inset_iterator inset_iterator_begin() {
|
|
|
|
|
return inset_iterator(paragraph);
|
|
|
|
|
}
|
|
|
|
|
///
|
|
|
|
|
inset_iterator inset_iterator_end() {
|
|
|
|
|
return inset_iterator();
|
|
|
|
|
}
|
2001-07-06 15:57:54 +00:00
|
|
|
|
///
|
|
|
|
|
inset_iterator inset_const_iterator_begin() const {
|
|
|
|
|
return inset_iterator(paragraph);
|
|
|
|
|
}
|
|
|
|
|
///
|
|
|
|
|
inset_iterator inset_const_iterator_end() const {
|
|
|
|
|
return inset_iterator();
|
|
|
|
|
}
|
|
|
|
|
///
|
|
|
|
|
Inset * getInsetFromID(int id_arg) const;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2001-02-16 09:25:43 +00:00
|
|
|
|
inline
|
|
|
|
|
void Buffer::addUser(BufferView * u)
|
|
|
|
|
{
|
|
|
|
|
users = u;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline
|
|
|
|
|
void Buffer::delUser(BufferView *)
|
|
|
|
|
{
|
|
|
|
|
users = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline
|
2001-06-28 10:25:20 +00:00
|
|
|
|
Language const * Buffer::getLanguage() const
|
2001-02-16 09:25:43 +00:00
|
|
|
|
{
|
|
|
|
|
return params.language;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline
|
|
|
|
|
bool Buffer::isLyxClean() const
|
|
|
|
|
{
|
|
|
|
|
return lyx_clean;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline
|
|
|
|
|
bool Buffer::isBakClean() const
|
|
|
|
|
{
|
|
|
|
|
return bak_clean;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline
|
|
|
|
|
void Buffer::markLyxClean() const
|
|
|
|
|
{
|
|
|
|
|
if (!lyx_clean) {
|
|
|
|
|
lyx_clean = true;
|
|
|
|
|
updateTitles();
|
|
|
|
|
}
|
|
|
|
|
// if the .lyx file has been saved, we don't need an
|
|
|
|
|
// autosave
|
|
|
|
|
bak_clean = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline
|
|
|
|
|
void Buffer::markBakClean()
|
|
|
|
|
{
|
|
|
|
|
bak_clean = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline
|
2001-02-19 16:01:31 +00:00
|
|
|
|
void Buffer::setUnnamed(bool flag)
|
2001-02-16 09:25:43 +00:00
|
|
|
|
{
|
|
|
|
|
unnamed = flag;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline
|
|
|
|
|
bool Buffer::isUnnamed()
|
|
|
|
|
{
|
|
|
|
|
return unnamed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline
|
|
|
|
|
void Buffer::markDirty()
|
|
|
|
|
{
|
|
|
|
|
if (lyx_clean) {
|
|
|
|
|
lyx_clean = false;
|
|
|
|
|
updateTitles();
|
|
|
|
|
}
|
|
|
|
|
bak_clean = false;
|
|
|
|
|
DEPCLEAN * tmp = dep_clean;
|
|
|
|
|
while (tmp) {
|
|
|
|
|
tmp->clean = false;
|
|
|
|
|
tmp = tmp->next;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline
|
|
|
|
|
string const & Buffer::fileName() const
|
|
|
|
|
{
|
|
|
|
|
return filename;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline
|
|
|
|
|
bool Buffer::isReadonly() const
|
|
|
|
|
{
|
|
|
|
|
return read_only;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline
|
|
|
|
|
BufferView * Buffer::getUser() const
|
|
|
|
|
{
|
|
|
|
|
return users;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
inline
|
2001-02-19 16:01:31 +00:00
|
|
|
|
void Buffer::setParentName(string const & name)
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
1999-12-16 06:43:25 +00:00
|
|
|
|
params.parentname = name;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-02-16 09:25:43 +00:00
|
|
|
|
|
2000-08-07 20:58:24 +00:00
|
|
|
|
///
|
2000-05-19 16:46:01 +00:00
|
|
|
|
inline
|
|
|
|
|
bool operator==(Buffer::TocItem const & a, Buffer::TocItem const & b) {
|
|
|
|
|
return a.par == b.par && a.str == b.str;
|
|
|
|
|
// No need to compare depth.
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2000-08-07 20:58:24 +00:00
|
|
|
|
///
|
2000-05-19 16:46:01 +00:00
|
|
|
|
inline
|
|
|
|
|
bool operator!=(Buffer::TocItem const & a, Buffer::TocItem const & b) {
|
|
|
|
|
return !(a == b);
|
|
|
|
|
// No need to compare depth.
|
|
|
|
|
}
|
|
|
|
|
|
2001-05-09 09:14:50 +00:00
|
|
|
|
|
2000-08-07 20:58:24 +00:00
|
|
|
|
///
|
|
|
|
|
inline
|
|
|
|
|
bool operator==(Buffer::inset_iterator const & iter1,
|
|
|
|
|
Buffer::inset_iterator const & iter2) {
|
|
|
|
|
return iter1.par == iter2.par
|
|
|
|
|
&& (iter1.par == 0 || iter1.it == iter2.it);
|
|
|
|
|
}
|
|
|
|
|
|
2001-05-09 09:14:50 +00:00
|
|
|
|
|
2000-08-07 20:58:24 +00:00
|
|
|
|
///
|
|
|
|
|
inline
|
|
|
|
|
bool operator!=(Buffer::inset_iterator const & iter1,
|
|
|
|
|
Buffer::inset_iterator const & iter2) {
|
|
|
|
|
return !(iter1 == iter2);
|
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
#endif
|