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
|
|
|
|
|
|
|
|
|
// Change Log:
|
1999-11-15 12:01:38 +00:00
|
|
|
|
// ===========
|
1999-09-27 18:44:28 +00:00
|
|
|
|
// 23/03/98 Heinrich Bauer (heinrich.bauer@t-mobil.de)
|
|
|
|
|
// Spots marked "changed Heinrich Bauer, 23/03/98" modified due to the
|
|
|
|
|
// following bug: dvi file export did not work after printing (or previewing)
|
|
|
|
|
// and vice versa as long as the same file was concerned. This happened
|
|
|
|
|
// every time the LyX-file was left unchanged between the two actions mentioned
|
|
|
|
|
// above.
|
|
|
|
|
|
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"
|
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
#include "BufferView.h"
|
|
|
|
|
#include "lyxvc.h"
|
|
|
|
|
#include "bufferparams.h"
|
|
|
|
|
#include "texrow.h"
|
2000-04-08 17:02:02 +00:00
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
///
|
|
|
|
|
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.
|
|
|
|
|
The is is the buffer object. It contains all the informations about
|
|
|
|
|
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-02-16 09:25:43 +00:00
|
|
|
|
/// Destrucotr
|
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
|
|
|
|
|
*/
|
2000-04-28 11:18:04 +00:00
|
|
|
|
bool Dispatch(string const & command);
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
|
|
|
|
/// Maybe we know the function already by number...
|
2000-04-28 11:18:04 +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
|
|
|
|
/// Should be changed to work for a list.
|
2000-06-23 15:02:46 +00:00
|
|
|
|
void resize();
|
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
|
|
|
|
*/
|
1999-11-15 12:01:38 +00:00
|
|
|
|
bool readFile(LyXLex &, LyXParagraph * 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
|
|
|
|
*/
|
1999-11-15 12:01:38 +00:00
|
|
|
|
bool readLyXformat2(LyXLex &, LyXParagraph * par = 0);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2000-08-07 20:58:24 +00:00
|
|
|
|
/// This parses a single LyXformat-Token.
|
2000-03-01 14:13:21 +00:00
|
|
|
|
bool parseSingleLyXformat2Token(LyXLex &, LyXParagraph *& par,
|
|
|
|
|
LyXParagraph *& return_par,
|
2000-04-08 17:02:02 +00:00
|
|
|
|
string const & token, int & pos,
|
2000-07-19 17:16:27 +00:00
|
|
|
|
char & depth, LyXFont &
|
|
|
|
|
#ifndef NEW_INSETS
|
|
|
|
|
,LyXParagraph::footnote_flag &,
|
|
|
|
|
LyXParagraph::footnote_kind &
|
|
|
|
|
#endif
|
|
|
|
|
);
|
2000-07-24 21:49:58 +00:00
|
|
|
|
private:
|
2000-08-07 20:58:24 +00:00
|
|
|
|
/// Parse a single inset.
|
2000-07-24 21:49:58 +00:00
|
|
|
|
void readInset(LyXLex &, LyXParagraph *& par, int & pos, LyXFont &);
|
|
|
|
|
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
|
|
|
|
///
|
|
|
|
|
string const asciiParagraph(LyXParagraph const *,
|
|
|
|
|
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
|
|
|
|
*/
|
|
|
|
|
void latexParagraphs(std::ostream & os, LyXParagraph * par,
|
|
|
|
|
LyXParagraph * endpar, TexRow & texrow) const;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2000-10-27 10:04:51 +00:00
|
|
|
|
///
|
|
|
|
|
void SimpleDocBookOnePar(std::ostream &, string & extra,
|
|
|
|
|
LyXParagraph * par, int & desc_on,
|
|
|
|
|
int depth) const ;
|
|
|
|
|
|
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-02-16 09:25:43 +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-02-16 09:25:43 +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-03-13 13:53:58 +00:00
|
|
|
|
TocItem(LyXParagraph * p, int d, string const & s)
|
|
|
|
|
: par(p), depth(d), str(s) {}
|
2000-08-07 20:58:24 +00:00
|
|
|
|
///
|
2000-05-21 20:41:06 +00:00
|
|
|
|
LyXParagraph * 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
|
|
|
|
///
|
|
|
|
|
void ChangeLanguage(Language const * from, Language const * to);
|
|
|
|
|
///
|
|
|
|
|
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
|
|
|
|
*/
|
1999-11-15 12:01:38 +00:00
|
|
|
|
LyXParagraph * 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:
|
2000-07-19 17:16:27 +00:00
|
|
|
|
#ifndef NEW_INSETS
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2000-04-04 00:19:15 +00:00
|
|
|
|
void linuxDocHandleFootnote(std::ostream & os,
|
2000-09-29 18:44:07 +00:00
|
|
|
|
LyXParagraph * & par, int depth);
|
2000-07-19 17:16:27 +00:00
|
|
|
|
#endif
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2000-04-04 00:19:15 +00:00
|
|
|
|
void DocBookHandleCaption(std::ostream & os, string & inner_tag,
|
2000-09-29 18:44:07 +00:00
|
|
|
|
int depth, int desc_on,
|
1999-12-10 00:07:59 +00:00
|
|
|
|
LyXParagraph * & par);
|
2000-07-19 17:16:27 +00:00
|
|
|
|
#ifndef NEW_INSETS
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2000-04-04 00:19:15 +00:00
|
|
|
|
void DocBookHandleFootnote(std::ostream & os,
|
2000-09-29 18:44:07 +00:00
|
|
|
|
LyXParagraph * & par, int depth);
|
2000-07-19 17:16:27 +00:00
|
|
|
|
#endif
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2000-04-04 00:19:15 +00:00
|
|
|
|
void sgmlOpenTag(std::ostream & os, int depth,
|
1999-11-15 12:01:38 +00:00
|
|
|
|
string const & latexname) const;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2000-04-04 00:19:15 +00:00
|
|
|
|
void sgmlCloseTag(std::ostream & os, int depth,
|
1999-11-15 12:01:38 +00:00
|
|
|
|
string const & latexname) const;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2000-09-14 17:53:12 +00:00
|
|
|
|
void LinuxDocError(LyXParagraph * par, int pos,
|
|
|
|
|
string const & message);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2000-04-04 00:19:15 +00:00
|
|
|
|
void SimpleLinuxDocOnePar(std::ostream & os, LyXParagraph * par,
|
2000-09-29 18:44:07 +00:00
|
|
|
|
int desc_on, int depth);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
/// LinuxDoc.
|
2000-09-14 17:53:12 +00:00
|
|
|
|
void push_tag(std::ostream & os, string const & tag,
|
1999-11-15 12:01:38 +00:00
|
|
|
|
int & pos, char stack[5][3]);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
/// LinuxDoc.
|
2000-09-14 17:53:12 +00:00
|
|
|
|
void pop_tag(std::ostream & os, string const & tag,
|
1999-11-15 12:01:38 +00:00
|
|
|
|
int & pos, char stack[5][3]);
|
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
|
|
|
|
//
|
2000-05-19 16:46:01 +00:00
|
|
|
|
inset_iterator(LyXParagraph * paragraph) : par(paragraph) {
|
|
|
|
|
SetParagraph();
|
|
|
|
|
}
|
2000-08-07 20:58:24 +00:00
|
|
|
|
///
|
|
|
|
|
inset_iterator(LyXParagraph * paragraph,
|
|
|
|
|
LyXParagraph::size_type pos);
|
|
|
|
|
///
|
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
|
|
|
|
#ifndef NEW_INSETS
|
|
|
|
|
par = par->next_;
|
|
|
|
|
#else
|
|
|
|
|
par = par->next();
|
|
|
|
|
#endif
|
2000-05-19 16:46:01 +00:00
|
|
|
|
SetParagraph();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
#ifndef NEW_INSETS
|
|
|
|
|
par = par->next_;
|
|
|
|
|
#else
|
|
|
|
|
par = par->next();
|
|
|
|
|
#endif
|
2000-10-11 21:06:43 +00:00
|
|
|
|
SetParagraph();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return tmp;
|
|
|
|
|
}
|
|
|
|
|
///
|
|
|
|
|
Inset * operator*() { return *it; }
|
|
|
|
|
|
2000-08-07 20:58:24 +00:00
|
|
|
|
///
|
2000-05-19 16:46:01 +00:00
|
|
|
|
LyXParagraph * getPar() { return par; }
|
2000-08-07 20:58:24 +00:00
|
|
|
|
///
|
2000-10-11 21:06:43 +00:00
|
|
|
|
LyXParagraph::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
|
|
|
|
///
|
2000-05-19 16:46:01 +00:00
|
|
|
|
void SetParagraph();
|
2000-08-07 20:58:24 +00:00
|
|
|
|
///
|
2000-05-19 16:46:01 +00:00
|
|
|
|
LyXParagraph * par;
|
2000-08-07 20:58:24 +00:00
|
|
|
|
///
|
2000-05-19 16:46:01 +00:00
|
|
|
|
LyXParagraph::inset_iterator it;
|
|
|
|
|
};
|
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();
|
|
|
|
|
}
|
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
|
|
|
|
|
void Buffer::redraw()
|
|
|
|
|
{
|
|
|
|
|
users->redraw();
|
|
|
|
|
users->fitCursor(users->text);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline
|
|
|
|
|
Language const * Buffer::GetLanguage() const
|
|
|
|
|
{
|
|
|
|
|
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.
|
|
|
|
|
}
|
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///
|
|
|
|
|
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
|
2000-08-07 20:58:24 +00:00
|
|
|
|
|