1999-09-27 18:44:28 +00:00
|
|
|
|
/* This file is part of
|
1999-11-15 12:01:38 +00:00
|
|
|
|
* ======================================================
|
1999-09-27 18:44:28 +00:00
|
|
|
|
*
|
|
|
|
|
* LyX, The Document Processor
|
|
|
|
|
*
|
1999-10-02 16:21:10 +00:00
|
|
|
|
* Copyright 1995 Matthias Ettrich
|
2000-03-16 04:29:22 +00:00
|
|
|
|
* Copyright 1995-2000 The LyX Team.
|
1999-09-27 18:44:28 +00:00
|
|
|
|
*
|
1999-10-02 16:21:10 +00:00
|
|
|
|
* This file is Copyright 1996-1999
|
1999-09-27 18:44:28 +00:00
|
|
|
|
* Lars Gullik Bj<EFBFBD>nnes
|
|
|
|
|
*
|
1999-11-15 12:01:38 +00:00
|
|
|
|
* ======================================================
|
1999-09-27 18:44:28 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
1999-12-07 00:44:53 +00:00
|
|
|
|
#include <fstream>
|
|
|
|
|
#include <iomanip>
|
1999-12-07 10:49:58 +00:00
|
|
|
|
|
1999-10-02 16:21:10 +00:00
|
|
|
|
#include <cstdlib>
|
2000-11-21 15:46:13 +00:00
|
|
|
|
#include <cmath>
|
1999-09-27 18:44:28 +00:00
|
|
|
|
#include <unistd.h>
|
2000-02-22 00:36:17 +00:00
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
#include <utime.h>
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2000-05-19 16:46:01 +00:00
|
|
|
|
#include <algorithm>
|
|
|
|
|
|
2000-09-14 17:53:12 +00:00
|
|
|
|
#ifdef HAVE_LOCALE
|
|
|
|
|
#include <locale>
|
|
|
|
|
#endif
|
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
#ifdef __GNUG__
|
|
|
|
|
#pragma implementation "buffer.h"
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#include "buffer.h"
|
|
|
|
|
#include "bufferlist.h"
|
|
|
|
|
#include "lyx_main.h"
|
|
|
|
|
#include "lyx_gui_misc.h"
|
1999-12-10 00:07:59 +00:00
|
|
|
|
#include "LyXAction.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
|
#include "lyxrc.h"
|
|
|
|
|
#include "lyxlex.h"
|
|
|
|
|
#include "tex-strings.h"
|
|
|
|
|
#include "layout.h"
|
2000-04-12 14:20:08 +00:00
|
|
|
|
#include "bufferview_funcs.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
|
#include "minibuffer.h"
|
|
|
|
|
#include "lyxfont.h"
|
1999-12-15 17:42:22 +00:00
|
|
|
|
#include "version.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
|
#include "mathed/formulamacro.h"
|
|
|
|
|
#include "insets/lyxinset.h"
|
|
|
|
|
#include "insets/inseterror.h"
|
|
|
|
|
#include "insets/insetlabel.h"
|
|
|
|
|
#include "insets/insetref.h"
|
|
|
|
|
#include "insets/inseturl.h"
|
|
|
|
|
#include "insets/insetinfo.h"
|
|
|
|
|
#include "insets/insetquotes.h"
|
|
|
|
|
#include "insets/insetlatexaccent.h"
|
|
|
|
|
#include "insets/insetbib.h"
|
2000-06-07 08:53:40 +00:00
|
|
|
|
#include "insets/insetcite.h"
|
2000-06-12 11:27:15 +00:00
|
|
|
|
#include "insets/insetexternal.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
|
#include "insets/insetindex.h"
|
|
|
|
|
#include "insets/insetinclude.h"
|
|
|
|
|
#include "insets/insettoc.h"
|
|
|
|
|
#include "insets/insetparent.h"
|
|
|
|
|
#include "insets/insetspecialchar.h"
|
|
|
|
|
#include "insets/figinset.h"
|
2000-02-25 12:06:15 +00:00
|
|
|
|
#include "insets/insettext.h"
|
|
|
|
|
#include "insets/insetert.h"
|
2000-02-29 02:19:17 +00:00
|
|
|
|
#include "insets/insetgraphics.h"
|
2000-03-08 13:52:57 +00:00
|
|
|
|
#include "insets/insetfoot.h"
|
2000-06-28 13:35:52 +00:00
|
|
|
|
#include "insets/insetmarginal.h"
|
|
|
|
|
#include "insets/insetminipage.h"
|
|
|
|
|
#include "insets/insetfloat.h"
|
|
|
|
|
#include "insets/insetlist.h"
|
2000-05-04 08:14:34 +00:00
|
|
|
|
#include "insets/insettabular.h"
|
2000-07-04 19:16:35 +00:00
|
|
|
|
#include "insets/insettheorem.h"
|
2000-07-18 17:45:27 +00:00
|
|
|
|
#include "insets/insetcaption.h"
|
1999-10-02 16:21:10 +00:00
|
|
|
|
#include "support/filetools.h"
|
1999-10-13 17:32:46 +00:00
|
|
|
|
#include "support/path.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
|
#include "LaTeX.h"
|
|
|
|
|
#include "Chktex.h"
|
|
|
|
|
#include "LyXView.h"
|
1999-10-07 18:44:17 +00:00
|
|
|
|
#include "debug.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
|
#include "LaTeXFeatures.h"
|
1999-10-02 16:21:10 +00:00
|
|
|
|
#include "support/syscall.h"
|
|
|
|
|
#include "support/lyxlib.h"
|
|
|
|
|
#include "support/FileInfo.h"
|
2000-10-11 21:06:43 +00:00
|
|
|
|
#include "support/lyxmanip.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
|
#include "lyxtext.h"
|
|
|
|
|
#include "gettext.h"
|
2000-03-17 10:14:46 +00:00
|
|
|
|
#include "language.h"
|
2000-06-12 11:27:15 +00:00
|
|
|
|
#include "lyx_gui_misc.h" // WarnReadonly()
|
|
|
|
|
#include "frontends/Dialogs.h"
|
2000-07-04 20:32:37 +00:00
|
|
|
|
#include "encoding.h"
|
2000-08-30 03:40:51 +00:00
|
|
|
|
#include "exporter.h"
|
2000-09-26 15:25:14 +00:00
|
|
|
|
#include "Lsstream.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2000-04-04 00:19:15 +00:00
|
|
|
|
using std::ostream;
|
|
|
|
|
using std::ofstream;
|
|
|
|
|
using std::ifstream;
|
|
|
|
|
using std::fstream;
|
|
|
|
|
using std::ios;
|
|
|
|
|
using std::setw;
|
2000-03-28 02:18:55 +00:00
|
|
|
|
using std::endl;
|
2000-04-04 00:19:15 +00:00
|
|
|
|
using std::pair;
|
2000-05-19 16:46:01 +00:00
|
|
|
|
using std::vector;
|
|
|
|
|
using std::max;
|
2000-07-04 20:32:37 +00:00
|
|
|
|
using std::set;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
// all these externs should eventually be removed.
|
|
|
|
|
extern BufferList bufferlist;
|
|
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
|
extern LyXAction lyxaction;
|
|
|
|
|
|
|
|
|
|
|
2001-01-11 11:06:10 +00:00
|
|
|
|
#if 0
|
2000-08-24 23:10:28 +00:00
|
|
|
|
static const float LYX_FORMAT = 2.17;
|
2001-01-11 11:06:10 +00:00
|
|
|
|
#else
|
|
|
|
|
static const int LYX_FORMAT = 218;
|
|
|
|
|
#endif
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
extern int tex_code_break_column;
|
|
|
|
|
|
|
|
|
|
|
2000-03-12 10:35:05 +00:00
|
|
|
|
Buffer::Buffer(string const & file, bool ronly)
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
1999-11-09 23:52:04 +00:00
|
|
|
|
lyxerr[Debug::INFO] << "Buffer::Buffer()" << endl;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
filename = file;
|
|
|
|
|
filepath = OnlyPath(file);
|
1999-10-02 16:21:10 +00:00
|
|
|
|
paragraph = 0;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
lyx_clean = true;
|
|
|
|
|
bak_clean = true;
|
1999-10-02 16:21:10 +00:00
|
|
|
|
dep_clean = 0;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
read_only = ronly;
|
2000-07-26 13:43:16 +00:00
|
|
|
|
unnamed = false;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
users = 0;
|
1999-11-09 23:52:04 +00:00
|
|
|
|
lyxvc.buffer(this);
|
2000-03-12 10:35:05 +00:00
|
|
|
|
if (read_only || (lyxrc.use_tempdir)) {
|
1999-09-27 18:44:28 +00:00
|
|
|
|
tmppath = CreateBufferTmpDir();
|
2000-05-04 10:57:00 +00:00
|
|
|
|
} else tmppath.erase();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Buffer::~Buffer()
|
|
|
|
|
{
|
1999-11-09 23:52:04 +00:00
|
|
|
|
lyxerr[Debug::INFO] << "Buffer::~Buffer()" << endl;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
// here the buffer should take care that it is
|
|
|
|
|
// saved properly, before it goes into the void.
|
|
|
|
|
|
|
|
|
|
// make sure that views using this buffer
|
|
|
|
|
// forgets it.
|
|
|
|
|
if (users)
|
1999-11-09 23:52:04 +00:00
|
|
|
|
users->buffer(0);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
if (!tmppath.empty()) {
|
|
|
|
|
DestroyBufferTmpDir(tmppath);
|
|
|
|
|
}
|
|
|
|
|
|
1999-11-04 01:40:20 +00:00
|
|
|
|
LyXParagraph * par = paragraph;
|
|
|
|
|
LyXParagraph * tmppar;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
while (par) {
|
|
|
|
|
tmppar = par->next;
|
|
|
|
|
delete par;
|
|
|
|
|
par = tmppar;
|
|
|
|
|
}
|
1999-10-02 16:21:10 +00:00
|
|
|
|
paragraph = 0;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2000-09-14 17:53:12 +00:00
|
|
|
|
string const Buffer::getLatexName(bool no_path) const
|
2000-04-08 17:02:02 +00:00
|
|
|
|
{
|
2000-05-11 16:12:46 +00:00
|
|
|
|
if (no_path)
|
|
|
|
|
return OnlyFilename(ChangeExtension(MakeLatexName(filename),
|
|
|
|
|
".tex"));
|
|
|
|
|
else
|
|
|
|
|
return ChangeExtension(MakeLatexName(filename),
|
|
|
|
|
".tex");
|
2000-04-08 17:02:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2000-04-26 13:57:28 +00:00
|
|
|
|
void Buffer::setReadonly(bool flag)
|
2000-04-08 17:02:02 +00:00
|
|
|
|
{
|
|
|
|
|
if (read_only != flag) {
|
|
|
|
|
read_only = flag;
|
|
|
|
|
updateTitles();
|
2000-10-13 05:57:05 +00:00
|
|
|
|
users->owner()->getDialogs()->updateBufferDependent(false);
|
2000-04-08 17:02:02 +00:00
|
|
|
|
}
|
|
|
|
|
if (read_only) {
|
|
|
|
|
WarnReadonly(filename);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2000-09-26 13:54:57 +00:00
|
|
|
|
bool Buffer::saveParamsAsDefaults() // const
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
2000-09-26 13:54:57 +00:00
|
|
|
|
string const fname = AddName(AddPath(user_lyxdir, "templates/"),
|
2000-04-26 13:57:28 +00:00
|
|
|
|
"defaults.lyx");
|
1999-09-27 18:44:28 +00:00
|
|
|
|
Buffer defaults = Buffer(fname);
|
|
|
|
|
|
|
|
|
|
// Use the current buffer's parameters as default
|
1999-11-15 12:01:38 +00:00
|
|
|
|
defaults.params = params;
|
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
// add an empty paragraph. Is this enough?
|
1999-11-05 06:02:34 +00:00
|
|
|
|
defaults.paragraph = new LyXParagraph;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
1999-11-15 12:01:38 +00:00
|
|
|
|
return defaults.writeFile(defaults.filename, false);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Update window titles of all users
|
|
|
|
|
// Should work on a list
|
2000-02-22 00:36:17 +00:00
|
|
|
|
void Buffer::updateTitles() const
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
1999-11-09 23:52:04 +00:00
|
|
|
|
if (users) users->owner()->updateWindowTitle();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Reset autosave timer of all users
|
|
|
|
|
// Should work on a list
|
2000-02-22 00:36:17 +00:00
|
|
|
|
void Buffer::resetAutosaveTimers() const
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
1999-11-09 23:52:04 +00:00
|
|
|
|
if (users) users->owner()->resetAutosaveTimer();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2000-10-12 00:11:06 +00:00
|
|
|
|
void Buffer::setFileName(string const & newfile)
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
|
|
|
|
filename = MakeAbsPath(newfile);
|
|
|
|
|
filepath = OnlyPath(filename);
|
|
|
|
|
setReadonly(IsFileWriteable(filename) == 0);
|
|
|
|
|
updateTitles();
|
|
|
|
|
}
|
|
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
|
|
|
|
// candidate for move to BufferView
|
|
|
|
|
// (at least some parts in the beginning of the func)
|
1999-09-27 18:44:28 +00:00
|
|
|
|
//
|
|
|
|
|
// Uwe C. Schroeder
|
|
|
|
|
// changed to be public and have one parameter
|
1999-10-02 16:21:10 +00:00
|
|
|
|
// if par = 0 normal behavior
|
1999-09-27 18:44:28 +00:00
|
|
|
|
// else insert behavior
|
|
|
|
|
// Returns false if "\the_end" is not read for formats >= 2.13. (Asger)
|
1999-11-15 12:01:38 +00:00
|
|
|
|
bool Buffer::readLyXformat2(LyXLex & lex, LyXParagraph * par)
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
|
|
|
|
int pos = 0;
|
|
|
|
|
char depth = 0; // signed or unsigned?
|
2000-07-19 17:16:27 +00:00
|
|
|
|
#ifndef NEW_INSETS
|
1999-09-27 18:44:28 +00:00
|
|
|
|
LyXParagraph::footnote_flag footnoteflag = LyXParagraph::NO_FOOTNOTE;
|
|
|
|
|
LyXParagraph::footnote_kind footnotekind = LyXParagraph::FOOTNOTE;
|
2000-07-19 17:16:27 +00:00
|
|
|
|
#endif
|
1999-09-27 18:44:28 +00:00
|
|
|
|
bool the_end_read = false;
|
|
|
|
|
|
1999-11-15 12:01:38 +00:00
|
|
|
|
LyXParagraph * return_par = 0;
|
2000-10-10 12:36:36 +00:00
|
|
|
|
LyXFont font(LyXFont::ALL_INHERIT, params.language);
|
2001-01-11 11:06:10 +00:00
|
|
|
|
#if 0
|
2000-10-10 12:36:36 +00:00
|
|
|
|
if (format < 2.16 && params.language->lang() == "hebrew")
|
2000-03-17 10:14:46 +00:00
|
|
|
|
font.setLanguage(default_language);
|
2001-01-11 11:06:10 +00:00
|
|
|
|
#else
|
|
|
|
|
if (file_format < 216 && params.language->lang() == "hebrew")
|
|
|
|
|
font.setLanguage(default_language);
|
|
|
|
|
#endif
|
1999-09-27 18:44:28 +00:00
|
|
|
|
// If we are inserting, we cheat and get a token in advance
|
|
|
|
|
bool has_token = false;
|
1999-10-02 16:21:10 +00:00
|
|
|
|
string pretoken;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2000-11-04 10:00:12 +00:00
|
|
|
|
if (!par) {
|
1999-11-05 06:02:34 +00:00
|
|
|
|
par = new LyXParagraph;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
} else {
|
2000-06-12 11:27:15 +00:00
|
|
|
|
users->text->BreakParagraph(users);
|
1999-12-10 00:07:59 +00:00
|
|
|
|
return_par = users->text->FirstParagraph();
|
1999-11-15 12:01:38 +00:00
|
|
|
|
pos = 0;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
markDirty();
|
|
|
|
|
// We don't want to adopt the parameters from the
|
|
|
|
|
// document we insert, so we skip until the text begins:
|
|
|
|
|
while (lex.IsOK()) {
|
|
|
|
|
lex.nextToken();
|
|
|
|
|
pretoken = lex.GetString();
|
|
|
|
|
if (pretoken == "\\layout") {
|
|
|
|
|
has_token = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
while (lex.IsOK()) {
|
|
|
|
|
if (has_token) {
|
|
|
|
|
has_token = false;
|
|
|
|
|
} else {
|
|
|
|
|
lex.nextToken();
|
|
|
|
|
pretoken = lex.GetString();
|
|
|
|
|
}
|
|
|
|
|
|
2000-09-26 13:54:57 +00:00
|
|
|
|
if (pretoken.empty()) continue;
|
|
|
|
|
|
|
|
|
|
the_end_read =
|
|
|
|
|
parseSingleLyXformat2Token(lex, par, return_par,
|
|
|
|
|
pretoken, pos, depth,
|
|
|
|
|
font
|
2000-07-19 17:16:27 +00:00
|
|
|
|
#ifndef NEW_INSETS
|
2000-09-26 13:54:57 +00:00
|
|
|
|
, footnoteflag,
|
|
|
|
|
footnotekind
|
2000-07-19 17:16:27 +00:00
|
|
|
|
#endif
|
2000-09-26 13:54:57 +00:00
|
|
|
|
);
|
2000-03-01 14:13:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!return_par)
|
|
|
|
|
return_par = par;
|
|
|
|
|
|
|
|
|
|
paragraph = return_par;
|
|
|
|
|
|
|
|
|
|
return the_end_read;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2000-07-24 21:49:58 +00:00
|
|
|
|
// We'll remove this later. (Lgb)
|
|
|
|
|
static string last_inset_read;
|
|
|
|
|
|
|
|
|
|
|
2000-04-24 20:58:23 +00:00
|
|
|
|
bool
|
|
|
|
|
Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par,
|
|
|
|
|
LyXParagraph *& return_par,
|
|
|
|
|
string const & token, int & pos,
|
2000-07-19 17:16:27 +00:00
|
|
|
|
char & depth, LyXFont & font
|
|
|
|
|
#ifndef NEW_INSETS
|
|
|
|
|
, LyXParagraph::footnote_flag & footnoteflag,
|
|
|
|
|
LyXParagraph::footnote_kind & footnotekind
|
|
|
|
|
#endif
|
|
|
|
|
)
|
2000-03-01 14:13:21 +00:00
|
|
|
|
{
|
|
|
|
|
bool the_end_read = false;
|
2000-07-15 23:51:46 +00:00
|
|
|
|
|
2000-03-01 14:13:21 +00:00
|
|
|
|
if (token[0] != '\\') {
|
2000-04-24 20:58:23 +00:00
|
|
|
|
for (string::const_iterator cit = token.begin();
|
|
|
|
|
cit != token.end(); ++cit) {
|
2000-06-28 13:35:52 +00:00
|
|
|
|
par->InsertChar(pos, (*cit), font);
|
2000-01-24 18:34:46 +00:00
|
|
|
|
++pos;
|
2000-03-01 14:13:21 +00:00
|
|
|
|
}
|
|
|
|
|
} else if (token == "\\i") {
|
2000-04-24 20:58:23 +00:00
|
|
|
|
Inset * inset = new InsetLatexAccent;
|
2000-06-12 11:27:15 +00:00
|
|
|
|
inset->Read(this, lex);
|
2000-06-28 13:35:52 +00:00
|
|
|
|
par->InsertInset(pos, inset, font);
|
2000-03-01 14:13:21 +00:00
|
|
|
|
++pos;
|
|
|
|
|
} else if (token == "\\layout") {
|
|
|
|
|
if (!return_par)
|
|
|
|
|
return_par = par;
|
|
|
|
|
else {
|
2000-03-16 04:29:22 +00:00
|
|
|
|
par->fitToSize();
|
2000-03-01 14:13:21 +00:00
|
|
|
|
par = new LyXParagraph(par);
|
|
|
|
|
}
|
|
|
|
|
pos = 0;
|
|
|
|
|
lex.EatLine();
|
2000-09-26 13:54:57 +00:00
|
|
|
|
string const layoutname = lex.GetString();
|
2000-03-01 14:13:21 +00:00
|
|
|
|
pair<bool, LyXTextClass::LayoutList::size_type> pp
|
|
|
|
|
= textclasslist.NumberOfLayout(params.textclass,
|
|
|
|
|
layoutname);
|
|
|
|
|
if (pp.first) {
|
|
|
|
|
par->layout = pp.second;
|
|
|
|
|
} else { // layout not found
|
2000-04-24 20:58:23 +00:00
|
|
|
|
// use default layout "Standard" (0)
|
2000-03-01 14:13:21 +00:00
|
|
|
|
par->layout = 0;
|
|
|
|
|
}
|
|
|
|
|
// Test whether the layout is obsolete.
|
|
|
|
|
LyXLayout const & layout =
|
|
|
|
|
textclasslist.Style(params.textclass,
|
|
|
|
|
par->layout);
|
|
|
|
|
if (!layout.obsoleted_by().empty())
|
|
|
|
|
par->layout =
|
|
|
|
|
textclasslist.NumberOfLayout(params.textclass,
|
|
|
|
|
layout.obsoleted_by()).second;
|
2000-07-19 17:16:27 +00:00
|
|
|
|
#ifndef NEW_INSETS
|
2000-03-01 14:13:21 +00:00
|
|
|
|
par->footnoteflag = footnoteflag;
|
|
|
|
|
par->footnotekind = footnotekind;
|
2000-07-19 17:16:27 +00:00
|
|
|
|
#endif
|
2000-03-01 14:13:21 +00:00
|
|
|
|
par->depth = depth;
|
2000-10-10 12:36:36 +00:00
|
|
|
|
font = LyXFont(LyXFont::ALL_INHERIT, params.language);
|
2001-01-11 11:06:10 +00:00
|
|
|
|
#if 0
|
2000-10-10 12:36:36 +00:00
|
|
|
|
if (format < 2.16 && params.language->lang() == "hebrew")
|
2000-03-17 10:14:46 +00:00
|
|
|
|
font.setLanguage(default_language);
|
2001-01-11 11:06:10 +00:00
|
|
|
|
#else
|
|
|
|
|
if (file_format < 216 && params.language->lang() == "hebrew")
|
|
|
|
|
font.setLanguage(default_language);
|
|
|
|
|
#endif
|
2000-06-28 13:35:52 +00:00
|
|
|
|
#ifndef NEW_INSETS
|
2000-03-01 14:13:21 +00:00
|
|
|
|
} else if (token == "\\end_float") {
|
|
|
|
|
if (!return_par)
|
|
|
|
|
return_par = par;
|
|
|
|
|
else {
|
2000-03-16 04:29:22 +00:00
|
|
|
|
par->fitToSize();
|
2000-03-01 14:13:21 +00:00
|
|
|
|
par = new LyXParagraph(par);
|
|
|
|
|
}
|
|
|
|
|
footnotekind = LyXParagraph::FOOTNOTE;
|
|
|
|
|
footnoteflag = LyXParagraph::NO_FOOTNOTE;
|
|
|
|
|
pos = 0;
|
|
|
|
|
lex.EatLine();
|
|
|
|
|
par->layout = LYX_DUMMY_LAYOUT;
|
2000-10-10 12:36:36 +00:00
|
|
|
|
font = LyXFont(LyXFont::ALL_INHERIT, params.language);
|
2001-01-11 11:06:10 +00:00
|
|
|
|
#if 0
|
2000-10-10 12:36:36 +00:00
|
|
|
|
if (format < 2.16 && params.language->lang() == "hebrew")
|
2000-03-17 10:14:46 +00:00
|
|
|
|
font.setLanguage(default_language);
|
2001-01-11 11:06:10 +00:00
|
|
|
|
#else
|
|
|
|
|
if (file_format < 216 && params.language->lang() == "hebrew")
|
|
|
|
|
font.setLanguage(default_language);
|
|
|
|
|
#endif
|
2000-03-01 14:13:21 +00:00
|
|
|
|
} else if (token == "\\begin_float") {
|
2000-04-26 13:57:28 +00:00
|
|
|
|
int tmpret = lex.FindToken(string_footnotekinds);
|
2000-03-01 14:13:21 +00:00
|
|
|
|
if (tmpret == -1) ++tmpret;
|
|
|
|
|
if (tmpret != LYX_LAYOUT_DEFAULT)
|
|
|
|
|
footnotekind = static_cast<LyXParagraph::footnote_kind>(tmpret); // bad
|
|
|
|
|
if (footnotekind == LyXParagraph::FOOTNOTE
|
|
|
|
|
|| footnotekind == LyXParagraph::MARGIN)
|
|
|
|
|
footnoteflag = LyXParagraph::CLOSED_FOOTNOTE;
|
|
|
|
|
else
|
|
|
|
|
footnoteflag = LyXParagraph::OPEN_FOOTNOTE;
|
2000-06-28 13:35:52 +00:00
|
|
|
|
#else
|
|
|
|
|
} else if (token == "\\begin_float") {
|
|
|
|
|
// This is the compability reader, unfinished but tested.
|
|
|
|
|
// (Lgb)
|
|
|
|
|
lex.next();
|
2000-09-26 13:54:57 +00:00
|
|
|
|
string const tmptok = lex.GetString();
|
2000-06-28 13:35:52 +00:00
|
|
|
|
//lyxerr << "old float: " << tmptok << endl;
|
|
|
|
|
|
|
|
|
|
Inset * inset = 0;
|
2000-07-21 14:59:00 +00:00
|
|
|
|
string old_float;
|
2000-06-28 13:35:52 +00:00
|
|
|
|
|
|
|
|
|
if (tmptok == "footnote") {
|
|
|
|
|
inset = new InsetFoot;
|
|
|
|
|
} else if (tmptok == "margin") {
|
|
|
|
|
inset = new InsetMarginal;
|
|
|
|
|
} else if (tmptok == "fig") {
|
2000-07-15 23:51:46 +00:00
|
|
|
|
inset = new InsetFloat("figure");
|
2000-07-21 14:59:00 +00:00
|
|
|
|
old_float += "placement htbp\n";
|
2000-06-28 13:35:52 +00:00
|
|
|
|
} else if (tmptok == "tab") {
|
2000-07-15 23:51:46 +00:00
|
|
|
|
inset = new InsetFloat("table");
|
2000-07-21 14:59:00 +00:00
|
|
|
|
old_float += "placement htbp\n";
|
2000-06-28 13:35:52 +00:00
|
|
|
|
} else if (tmptok == "alg") {
|
2000-07-15 23:51:46 +00:00
|
|
|
|
inset = new InsetFloat("algorithm");
|
2000-07-21 14:59:00 +00:00
|
|
|
|
old_float += "placement htbp\n";
|
2000-06-28 13:35:52 +00:00
|
|
|
|
} else if (tmptok == "wide-fig") {
|
2000-07-19 17:16:27 +00:00
|
|
|
|
InsetFloat * tmp = new InsetFloat("figure");
|
2000-07-15 23:51:46 +00:00
|
|
|
|
tmp->wide(true);
|
|
|
|
|
inset = tmp;
|
2000-07-21 14:59:00 +00:00
|
|
|
|
old_float += "placement htbp\n";
|
2000-06-28 13:35:52 +00:00
|
|
|
|
} else if (tmptok == "wide-tab") {
|
2000-07-19 17:16:27 +00:00
|
|
|
|
InsetFloat * tmp = new InsetFloat("table");
|
2000-07-15 23:51:46 +00:00
|
|
|
|
tmp->wide(true);
|
|
|
|
|
inset = tmp;
|
2000-07-21 14:59:00 +00:00
|
|
|
|
old_float += "placement htbp\n";
|
2000-06-28 13:35:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!inset) return false; // no end read yet
|
|
|
|
|
|
2000-07-21 14:59:00 +00:00
|
|
|
|
old_float += "collapsed true\n";
|
|
|
|
|
|
|
|
|
|
// Here we need to check for \end_deeper and handle that
|
|
|
|
|
// before we do the footnote parsing.
|
|
|
|
|
// This _is_ a hack! (Lgb)
|
|
|
|
|
while(true) {
|
|
|
|
|
lex.next();
|
2000-09-26 13:54:57 +00:00
|
|
|
|
string const tmp = lex.GetString();
|
2000-07-21 14:59:00 +00:00
|
|
|
|
if (tmp == "\\end_deeper") {
|
|
|
|
|
lyxerr << "\\end_deeper caught!" << endl;
|
|
|
|
|
if (!depth) {
|
|
|
|
|
lex.printError("\\end_deeper: "
|
|
|
|
|
"depth is already null");
|
|
|
|
|
} else
|
|
|
|
|
--depth;
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
old_float += tmp;
|
|
|
|
|
old_float += ' ';
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2000-06-28 13:35:52 +00:00
|
|
|
|
old_float += lex.getLongString("\\end_float");
|
|
|
|
|
old_float += "\n\\end_inset\n";
|
2000-07-21 14:59:00 +00:00
|
|
|
|
//lyxerr << "float body: " << old_float << endl;
|
2000-07-19 17:16:27 +00:00
|
|
|
|
|
2000-08-05 05:17:18 +00:00
|
|
|
|
istringstream istr(old_float);
|
2000-07-19 17:16:27 +00:00
|
|
|
|
|
2000-06-28 13:35:52 +00:00
|
|
|
|
LyXLex nylex(0, 0);
|
|
|
|
|
nylex.setStream(istr);
|
|
|
|
|
|
|
|
|
|
inset->Read(this, nylex);
|
|
|
|
|
par->InsertInset(pos, inset, font);
|
|
|
|
|
++pos;
|
|
|
|
|
#endif
|
2000-03-01 14:13:21 +00:00
|
|
|
|
} else if (token == "\\begin_deeper") {
|
|
|
|
|
++depth;
|
|
|
|
|
} else if (token == "\\end_deeper") {
|
|
|
|
|
if (!depth) {
|
|
|
|
|
lex.printError("\\end_deeper: "
|
|
|
|
|
"depth is already null");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
--depth;
|
|
|
|
|
} else if (token == "\\begin_preamble") {
|
|
|
|
|
params.readPreamble(lex);
|
|
|
|
|
} else if (token == "\\textclass") {
|
|
|
|
|
lex.EatLine();
|
|
|
|
|
pair<bool, LyXTextClassList::size_type> pp =
|
|
|
|
|
textclasslist.NumberOfClass(lex.GetString());
|
|
|
|
|
if (pp.first) {
|
|
|
|
|
params.textclass = pp.second;
|
|
|
|
|
} else {
|
2000-11-29 15:34:56 +00:00
|
|
|
|
WriteAlert(string(_("Textclass error")),
|
|
|
|
|
string(_("The document uses an unknown textclass \"")) +
|
|
|
|
|
lex.GetString() + string("\"."),
|
|
|
|
|
string(_("LyX will not be able to produce output correctly.")));
|
2000-03-01 14:13:21 +00:00
|
|
|
|
params.textclass = 0;
|
|
|
|
|
}
|
|
|
|
|
if (!textclasslist.Load(params.textclass)) {
|
1999-09-27 18:44:28 +00:00
|
|
|
|
// if the textclass wasn't loaded properly
|
|
|
|
|
// we need to either substitute another
|
|
|
|
|
// or stop loading the file.
|
|
|
|
|
// I can substitute but I don't see how I can
|
|
|
|
|
// stop loading... ideas?? ARRae980418
|
2000-03-01 14:13:21 +00:00
|
|
|
|
WriteAlert(_("Textclass Loading Error!"),
|
|
|
|
|
string(_("Can't load textclass ")) +
|
|
|
|
|
textclasslist.NameOfClass(params.textclass),
|
|
|
|
|
_("-- substituting default"));
|
|
|
|
|
params.textclass = 0;
|
|
|
|
|
}
|
|
|
|
|
} else if (token == "\\options") {
|
|
|
|
|
lex.EatLine();
|
|
|
|
|
params.options = lex.GetString();
|
|
|
|
|
} else if (token == "\\language") {
|
|
|
|
|
params.readLanguage(lex);
|
|
|
|
|
} else if (token == "\\fontencoding") {
|
|
|
|
|
lex.EatLine();
|
|
|
|
|
} else if (token == "\\inputencoding") {
|
|
|
|
|
lex.EatLine();
|
|
|
|
|
params.inputenc = lex.GetString();
|
|
|
|
|
} else if (token == "\\graphics") {
|
|
|
|
|
params.readGraphicsDriver(lex);
|
|
|
|
|
} else if (token == "\\fontscheme") {
|
|
|
|
|
lex.EatLine();
|
|
|
|
|
params.fonts = lex.GetString();
|
|
|
|
|
} else if (token == "\\noindent") {
|
|
|
|
|
par->noindent = true;
|
|
|
|
|
} else if (token == "\\fill_top") {
|
|
|
|
|
par->added_space_top = VSpace(VSpace::VFILL);
|
|
|
|
|
} else if (token == "\\fill_bottom") {
|
|
|
|
|
par->added_space_bottom = VSpace(VSpace::VFILL);
|
|
|
|
|
} else if (token == "\\line_top") {
|
|
|
|
|
par->line_top = true;
|
|
|
|
|
} else if (token == "\\line_bottom") {
|
|
|
|
|
par->line_bottom = true;
|
|
|
|
|
} else if (token == "\\pagebreak_top") {
|
|
|
|
|
par->pagebreak_top = true;
|
|
|
|
|
} else if (token == "\\pagebreak_bottom") {
|
|
|
|
|
par->pagebreak_bottom = true;
|
|
|
|
|
} else if (token == "\\start_of_appendix") {
|
|
|
|
|
par->start_of_appendix = true;
|
|
|
|
|
} else if (token == "\\paragraph_separation") {
|
2000-04-26 13:57:28 +00:00
|
|
|
|
int tmpret = lex.FindToken(string_paragraph_separation);
|
2000-03-01 14:13:21 +00:00
|
|
|
|
if (tmpret == -1) ++tmpret;
|
|
|
|
|
if (tmpret != LYX_LAYOUT_DEFAULT)
|
|
|
|
|
params.paragraph_separation =
|
|
|
|
|
static_cast<BufferParams::PARSEP>(tmpret);
|
|
|
|
|
} else if (token == "\\defskip") {
|
|
|
|
|
lex.nextToken();
|
|
|
|
|
params.defskip = VSpace(lex.GetString());
|
|
|
|
|
} else if (token == "\\epsfig") { // obsolete
|
|
|
|
|
// Indeed it is obsolete, but we HAVE to be backwards
|
|
|
|
|
// compatible until 0.14, because otherwise all figures
|
|
|
|
|
// in existing documents are irretrivably lost. (Asger)
|
|
|
|
|
params.readGraphicsDriver(lex);
|
|
|
|
|
} else if (token == "\\quotes_language") {
|
2000-04-26 13:57:28 +00:00
|
|
|
|
int tmpret = lex.FindToken(string_quotes_language);
|
2000-03-01 14:13:21 +00:00
|
|
|
|
if (tmpret == -1) ++tmpret;
|
|
|
|
|
if (tmpret != LYX_LAYOUT_DEFAULT) {
|
|
|
|
|
InsetQuotes::quote_language tmpl =
|
|
|
|
|
InsetQuotes::EnglishQ;
|
2000-11-04 10:00:12 +00:00
|
|
|
|
switch (tmpret) {
|
2000-03-01 14:13:21 +00:00
|
|
|
|
case 0:
|
|
|
|
|
tmpl = InsetQuotes::EnglishQ;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
break;
|
2000-03-01 14:13:21 +00:00
|
|
|
|
case 1:
|
|
|
|
|
tmpl = InsetQuotes::SwedishQ;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
break;
|
2000-03-01 14:13:21 +00:00
|
|
|
|
case 2:
|
|
|
|
|
tmpl = InsetQuotes::GermanQ;
|
|
|
|
|
break;
|
|
|
|
|
case 3:
|
|
|
|
|
tmpl = InsetQuotes::PolishQ;
|
|
|
|
|
break;
|
|
|
|
|
case 4:
|
|
|
|
|
tmpl = InsetQuotes::FrenchQ;
|
|
|
|
|
break;
|
|
|
|
|
case 5:
|
|
|
|
|
tmpl = InsetQuotes::DanishQ;
|
|
|
|
|
break;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
2000-03-01 14:13:21 +00:00
|
|
|
|
params.quotes_language = tmpl;
|
|
|
|
|
}
|
|
|
|
|
} else if (token == "\\quotes_times") {
|
|
|
|
|
lex.nextToken();
|
2000-11-04 10:00:12 +00:00
|
|
|
|
switch (lex.GetInteger()) {
|
2000-03-01 14:13:21 +00:00
|
|
|
|
case 1:
|
|
|
|
|
params.quotes_times = InsetQuotes::SingleQ;
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
params.quotes_times = InsetQuotes::DoubleQ;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
} else if (token == "\\papersize") {
|
2000-04-26 13:57:28 +00:00
|
|
|
|
int tmpret = lex.FindToken(string_papersize);
|
2000-03-01 14:13:21 +00:00
|
|
|
|
if (tmpret == -1)
|
|
|
|
|
++tmpret;
|
|
|
|
|
else
|
|
|
|
|
params.papersize2 = tmpret;
|
|
|
|
|
} else if (token == "\\paperpackage") {
|
2000-04-26 13:57:28 +00:00
|
|
|
|
int tmpret = lex.FindToken(string_paperpackages);
|
2000-03-01 14:13:21 +00:00
|
|
|
|
if (tmpret == -1) {
|
|
|
|
|
++tmpret;
|
|
|
|
|
params.paperpackage = BufferParams::PACKAGE_NONE;
|
|
|
|
|
} else
|
|
|
|
|
params.paperpackage = tmpret;
|
|
|
|
|
} else if (token == "\\use_geometry") {
|
|
|
|
|
lex.nextToken();
|
|
|
|
|
params.use_geometry = lex.GetInteger();
|
|
|
|
|
} else if (token == "\\use_amsmath") {
|
|
|
|
|
lex.nextToken();
|
|
|
|
|
params.use_amsmath = lex.GetInteger();
|
|
|
|
|
} else if (token == "\\paperorientation") {
|
2000-04-26 13:57:28 +00:00
|
|
|
|
int tmpret = lex.FindToken(string_orientation);
|
2000-03-01 14:13:21 +00:00
|
|
|
|
if (tmpret == -1) ++tmpret;
|
|
|
|
|
if (tmpret != LYX_LAYOUT_DEFAULT)
|
|
|
|
|
params.orientation = static_cast<BufferParams::PAPER_ORIENTATION>(tmpret);
|
|
|
|
|
} else if (token == "\\paperwidth") {
|
|
|
|
|
lex.next();
|
|
|
|
|
params.paperwidth = lex.GetString();
|
|
|
|
|
} else if (token == "\\paperheight") {
|
|
|
|
|
lex.next();
|
|
|
|
|
params.paperheight = lex.GetString();
|
|
|
|
|
} else if (token == "\\leftmargin") {
|
|
|
|
|
lex.next();
|
|
|
|
|
params.leftmargin = lex.GetString();
|
|
|
|
|
} else if (token == "\\topmargin") {
|
|
|
|
|
lex.next();
|
|
|
|
|
params.topmargin = lex.GetString();
|
|
|
|
|
} else if (token == "\\rightmargin") {
|
|
|
|
|
lex.next();
|
|
|
|
|
params.rightmargin = lex.GetString();
|
|
|
|
|
} else if (token == "\\bottommargin") {
|
|
|
|
|
lex.next();
|
|
|
|
|
params.bottommargin = lex.GetString();
|
|
|
|
|
} else if (token == "\\headheight") {
|
|
|
|
|
lex.next();
|
|
|
|
|
params.headheight = lex.GetString();
|
|
|
|
|
} else if (token == "\\headsep") {
|
|
|
|
|
lex.next();
|
|
|
|
|
params.headsep = lex.GetString();
|
|
|
|
|
} else if (token == "\\footskip") {
|
|
|
|
|
lex.next();
|
|
|
|
|
params.footskip = lex.GetString();
|
|
|
|
|
} else if (token == "\\paperfontsize") {
|
|
|
|
|
lex.nextToken();
|
|
|
|
|
params.fontsize = strip(lex.GetString());
|
|
|
|
|
} else if (token == "\\papercolumns") {
|
|
|
|
|
lex.nextToken();
|
|
|
|
|
params.columns = lex.GetInteger();
|
|
|
|
|
} else if (token == "\\papersides") {
|
|
|
|
|
lex.nextToken();
|
2000-11-04 10:00:12 +00:00
|
|
|
|
switch (lex.GetInteger()) {
|
2000-03-01 14:13:21 +00:00
|
|
|
|
default:
|
|
|
|
|
case 1: params.sides = LyXTextClass::OneSide; break;
|
|
|
|
|
case 2: params.sides = LyXTextClass::TwoSides; break;
|
|
|
|
|
}
|
|
|
|
|
} else if (token == "\\paperpagestyle") {
|
|
|
|
|
lex.nextToken();
|
|
|
|
|
params.pagestyle = strip(lex.GetString());
|
|
|
|
|
} else if (token == "\\bullet") {
|
|
|
|
|
lex.nextToken();
|
2000-09-26 13:54:57 +00:00
|
|
|
|
int const index = lex.GetInteger();
|
2000-03-01 14:13:21 +00:00
|
|
|
|
lex.nextToken();
|
|
|
|
|
int temp_int = lex.GetInteger();
|
|
|
|
|
params.user_defined_bullets[index].setFont(temp_int);
|
|
|
|
|
params.temp_bullets[index].setFont(temp_int);
|
|
|
|
|
lex.nextToken();
|
|
|
|
|
temp_int = lex.GetInteger();
|
|
|
|
|
params.user_defined_bullets[index].setCharacter(temp_int);
|
|
|
|
|
params.temp_bullets[index].setCharacter(temp_int);
|
|
|
|
|
lex.nextToken();
|
|
|
|
|
temp_int = lex.GetInteger();
|
|
|
|
|
params.user_defined_bullets[index].setSize(temp_int);
|
|
|
|
|
params.temp_bullets[index].setSize(temp_int);
|
|
|
|
|
lex.nextToken();
|
2000-09-26 13:54:57 +00:00
|
|
|
|
string const temp_str = lex.GetString();
|
2000-03-01 14:13:21 +00:00
|
|
|
|
if (temp_str != "\\end_bullet") {
|
1999-09-27 18:44:28 +00:00
|
|
|
|
// this element isn't really necessary for
|
|
|
|
|
// parsing but is easier for humans
|
|
|
|
|
// to understand bullets. Put it back and
|
|
|
|
|
// set a debug message?
|
2000-03-01 14:13:21 +00:00
|
|
|
|
lex.printError("\\end_bullet expected, got" + temp_str);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
//how can I put it back?
|
2000-03-01 14:13:21 +00:00
|
|
|
|
}
|
|
|
|
|
} else if (token == "\\bulletLaTeX") {
|
|
|
|
|
lex.nextToken();
|
2000-09-26 13:54:57 +00:00
|
|
|
|
int const index = lex.GetInteger();
|
2000-03-01 14:13:21 +00:00
|
|
|
|
lex.next();
|
2000-09-26 13:54:57 +00:00
|
|
|
|
string temp_str = lex.GetString();
|
|
|
|
|
string sum_str;
|
2000-03-01 14:13:21 +00:00
|
|
|
|
while (temp_str != "\\end_bullet") {
|
1999-09-27 18:44:28 +00:00
|
|
|
|
// this loop structure is needed when user
|
|
|
|
|
// enters an empty string since the first
|
|
|
|
|
// thing returned will be the \\end_bullet
|
|
|
|
|
// OR
|
|
|
|
|
// if the LaTeX entry has spaces. Each element
|
|
|
|
|
// therefore needs to be read in turn
|
2000-03-01 14:13:21 +00:00
|
|
|
|
sum_str += temp_str;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
lex.next();
|
2000-03-01 14:13:21 +00:00
|
|
|
|
temp_str = lex.GetString();
|
|
|
|
|
}
|
|
|
|
|
params.user_defined_bullets[index].setText(sum_str);
|
|
|
|
|
params.temp_bullets[index].setText(sum_str);
|
|
|
|
|
} else if (token == "\\secnumdepth") {
|
|
|
|
|
lex.nextToken();
|
|
|
|
|
params.secnumdepth = lex.GetInteger();
|
|
|
|
|
} else if (token == "\\tocdepth") {
|
|
|
|
|
lex.nextToken();
|
|
|
|
|
params.tocdepth = lex.GetInteger();
|
|
|
|
|
} else if (token == "\\spacing") {
|
|
|
|
|
lex.next();
|
2000-09-26 13:54:57 +00:00
|
|
|
|
string const tmp = strip(lex.GetString());
|
2000-04-24 20:58:23 +00:00
|
|
|
|
Spacing::Space tmp_space = Spacing::Default;
|
2000-04-26 13:57:28 +00:00
|
|
|
|
float tmp_val = 0.0;
|
2000-03-01 14:13:21 +00:00
|
|
|
|
if (tmp == "single") {
|
2000-04-26 13:57:28 +00:00
|
|
|
|
tmp_space = Spacing::Single;
|
2000-03-01 14:13:21 +00:00
|
|
|
|
} else if (tmp == "onehalf") {
|
2000-04-26 13:57:28 +00:00
|
|
|
|
tmp_space = Spacing::Onehalf;
|
2000-03-01 14:13:21 +00:00
|
|
|
|
} else if (tmp == "double") {
|
2000-04-26 13:57:28 +00:00
|
|
|
|
tmp_space = Spacing::Double;
|
2000-03-01 14:13:21 +00:00
|
|
|
|
} else if (tmp == "other") {
|
1999-09-27 18:44:28 +00:00
|
|
|
|
lex.next();
|
2000-04-26 13:57:28 +00:00
|
|
|
|
tmp_space = Spacing::Other;
|
|
|
|
|
tmp_val = lex.GetFloat();
|
2000-03-01 14:13:21 +00:00
|
|
|
|
} else {
|
|
|
|
|
lex.printError("Unknown spacing token: '$$Token'");
|
|
|
|
|
}
|
2000-04-24 20:58:23 +00:00
|
|
|
|
// Small hack so that files written with klyx will be
|
|
|
|
|
// parsed correctly.
|
|
|
|
|
if (return_par) {
|
2000-04-26 13:57:28 +00:00
|
|
|
|
par->spacing.set(tmp_space, tmp_val);
|
2000-04-24 20:58:23 +00:00
|
|
|
|
} else {
|
2000-04-26 13:57:28 +00:00
|
|
|
|
params.spacing.set(tmp_space, tmp_val);
|
2000-04-24 20:58:23 +00:00
|
|
|
|
}
|
2000-04-11 22:55:29 +00:00
|
|
|
|
} else if (token == "\\paragraph_spacing") {
|
|
|
|
|
lex.next();
|
2000-09-26 13:54:57 +00:00
|
|
|
|
string const tmp = strip(lex.GetString());
|
2000-04-11 22:55:29 +00:00
|
|
|
|
if (tmp == "single") {
|
|
|
|
|
par->spacing.set(Spacing::Single);
|
|
|
|
|
} else if (tmp == "onehalf") {
|
|
|
|
|
par->spacing.set(Spacing::Onehalf);
|
|
|
|
|
} else if (tmp == "double") {
|
|
|
|
|
par->spacing.set(Spacing::Double);
|
|
|
|
|
} else if (tmp == "other") {
|
|
|
|
|
lex.next();
|
|
|
|
|
par->spacing.set(Spacing::Other,
|
|
|
|
|
lex.GetFloat());
|
|
|
|
|
} else {
|
|
|
|
|
lex.printError("Unknown spacing token: '$$Token'");
|
|
|
|
|
}
|
2000-03-01 14:13:21 +00:00
|
|
|
|
} else if (token == "\\float_placement") {
|
|
|
|
|
lex.nextToken();
|
|
|
|
|
params.float_placement = lex.GetString();
|
|
|
|
|
} else if (token == "\\family") {
|
|
|
|
|
lex.next();
|
|
|
|
|
font.setLyXFamily(lex.GetString());
|
|
|
|
|
} else if (token == "\\series") {
|
|
|
|
|
lex.next();
|
|
|
|
|
font.setLyXSeries(lex.GetString());
|
|
|
|
|
} else if (token == "\\shape") {
|
|
|
|
|
lex.next();
|
|
|
|
|
font.setLyXShape(lex.GetString());
|
|
|
|
|
} else if (token == "\\size") {
|
|
|
|
|
lex.next();
|
|
|
|
|
font.setLyXSize(lex.GetString());
|
|
|
|
|
} else if (token == "\\latex") {
|
|
|
|
|
lex.next();
|
2000-09-26 13:54:57 +00:00
|
|
|
|
string const tok = lex.GetString();
|
2000-03-01 14:13:21 +00:00
|
|
|
|
// This is dirty, but gone with LyX3. (Asger)
|
|
|
|
|
if (tok == "no_latex")
|
|
|
|
|
font.setLatex(LyXFont::OFF);
|
|
|
|
|
else if (tok == "latex")
|
|
|
|
|
font.setLatex(LyXFont::ON);
|
|
|
|
|
else if (tok == "default")
|
|
|
|
|
font.setLatex(LyXFont::INHERIT);
|
|
|
|
|
else
|
|
|
|
|
lex.printError("Unknown LaTeX font flag "
|
|
|
|
|
"`$$Token'");
|
2000-03-17 10:14:46 +00:00
|
|
|
|
} else if (token == "\\lang") {
|
2000-03-01 14:13:21 +00:00
|
|
|
|
lex.next();
|
2000-09-26 13:54:57 +00:00
|
|
|
|
string const tok = lex.GetString();
|
2000-10-10 12:36:36 +00:00
|
|
|
|
Language const * lang = languages.getLanguage(tok);
|
|
|
|
|
if (lang) {
|
|
|
|
|
font.setLanguage(lang);
|
2000-03-17 10:14:46 +00:00
|
|
|
|
} else {
|
2000-10-10 12:36:36 +00:00
|
|
|
|
font.setLanguage(params.language);
|
2000-03-17 10:14:46 +00:00
|
|
|
|
lex.printError("Unknown language `$$Token'");
|
|
|
|
|
}
|
2000-10-09 12:30:52 +00:00
|
|
|
|
} else if (token == "\\numeric") {
|
|
|
|
|
lex.next();
|
|
|
|
|
font.setNumber(font.setLyXMisc(lex.GetString()));
|
2000-03-01 14:13:21 +00:00
|
|
|
|
} else if (token == "\\emph") {
|
|
|
|
|
lex.next();
|
|
|
|
|
font.setEmph(font.setLyXMisc(lex.GetString()));
|
|
|
|
|
} else if (token == "\\bar") {
|
|
|
|
|
lex.next();
|
2000-09-26 13:54:57 +00:00
|
|
|
|
string const tok = lex.GetString();
|
2000-03-01 14:13:21 +00:00
|
|
|
|
// This is dirty, but gone with LyX3. (Asger)
|
|
|
|
|
if (tok == "under")
|
|
|
|
|
font.setUnderbar(LyXFont::ON);
|
|
|
|
|
else if (tok == "no")
|
|
|
|
|
font.setUnderbar(LyXFont::OFF);
|
|
|
|
|
else if (tok == "default")
|
|
|
|
|
font.setUnderbar(LyXFont::INHERIT);
|
|
|
|
|
else
|
|
|
|
|
lex.printError("Unknown bar font flag "
|
|
|
|
|
"`$$Token'");
|
|
|
|
|
} else if (token == "\\noun") {
|
|
|
|
|
lex.next();
|
|
|
|
|
font.setNoun(font.setLyXMisc(lex.GetString()));
|
|
|
|
|
} else if (token == "\\color") {
|
|
|
|
|
lex.next();
|
|
|
|
|
font.setLyXColor(lex.GetString());
|
|
|
|
|
} else if (token == "\\align") {
|
2000-04-26 13:57:28 +00:00
|
|
|
|
int tmpret = lex.FindToken(string_align);
|
2000-03-01 14:13:21 +00:00
|
|
|
|
if (tmpret == -1) ++tmpret;
|
|
|
|
|
if (tmpret != LYX_LAYOUT_DEFAULT) { // tmpret != 99 ???
|
2000-11-21 15:46:13 +00:00
|
|
|
|
#if 0
|
2000-04-26 13:57:28 +00:00
|
|
|
|
int tmpret2 = 1;
|
2000-03-01 14:13:21 +00:00
|
|
|
|
for (; tmpret > 0; --tmpret)
|
|
|
|
|
tmpret2 = tmpret2 * 2;
|
2000-11-21 15:46:13 +00:00
|
|
|
|
#else
|
2000-11-21 21:51:25 +00:00
|
|
|
|
int const tmpret2 = int(pow(2.0, tmpret));
|
2000-11-21 15:46:13 +00:00
|
|
|
|
#endif
|
2000-11-21 22:16:14 +00:00
|
|
|
|
//lyxerr << "Tmpret2 = " << tmpret2 << endl;
|
2000-03-01 14:13:21 +00:00
|
|
|
|
par->align = LyXAlignment(tmpret2);
|
|
|
|
|
}
|
|
|
|
|
} else if (token == "\\added_space_top") {
|
|
|
|
|
lex.nextToken();
|
2000-04-08 17:02:02 +00:00
|
|
|
|
par->added_space_top = VSpace(lex.GetString());
|
2000-03-01 14:13:21 +00:00
|
|
|
|
} else if (token == "\\added_space_bottom") {
|
|
|
|
|
lex.nextToken();
|
2000-04-08 17:02:02 +00:00
|
|
|
|
par->added_space_bottom = VSpace(lex.GetString());
|
2000-03-01 14:13:21 +00:00
|
|
|
|
} else if (token == "\\pextra_type") {
|
|
|
|
|
lex.nextToken();
|
|
|
|
|
par->pextra_type = lex.GetInteger();
|
|
|
|
|
} else if (token == "\\pextra_width") {
|
|
|
|
|
lex.nextToken();
|
|
|
|
|
par->pextra_width = lex.GetString();
|
|
|
|
|
} else if (token == "\\pextra_widthp") {
|
|
|
|
|
lex.nextToken();
|
|
|
|
|
par->pextra_widthp = lex.GetString();
|
|
|
|
|
} else if (token == "\\pextra_alignment") {
|
|
|
|
|
lex.nextToken();
|
|
|
|
|
par->pextra_alignment = lex.GetInteger();
|
|
|
|
|
} else if (token == "\\pextra_hfill") {
|
|
|
|
|
lex.nextToken();
|
|
|
|
|
par->pextra_hfill = lex.GetInteger();
|
|
|
|
|
} else if (token == "\\pextra_start_minipage") {
|
|
|
|
|
lex.nextToken();
|
|
|
|
|
par->pextra_start_minipage = lex.GetInteger();
|
|
|
|
|
} else if (token == "\\labelwidthstring") {
|
|
|
|
|
lex.EatLine();
|
|
|
|
|
par->labelwidthstring = lex.GetString();
|
2000-04-26 13:57:28 +00:00
|
|
|
|
// do not delete this token, it is still needed!
|
2000-03-01 14:13:21 +00:00
|
|
|
|
} else if (token == "\\end_inset") {
|
2000-07-15 23:51:46 +00:00
|
|
|
|
lyxerr << "Solitary \\end_inset. Missing \\begin_inset?.\n"
|
|
|
|
|
<< "Last inset read was: " << last_inset_read
|
|
|
|
|
<< endl;
|
2000-04-26 13:57:28 +00:00
|
|
|
|
// Simply ignore this. The insets do not have
|
|
|
|
|
// to read this.
|
|
|
|
|
// But insets should read it, it is a part of
|
|
|
|
|
// the inset isn't it? Lgb.
|
2000-03-01 14:13:21 +00:00
|
|
|
|
} else if (token == "\\begin_inset") {
|
2000-07-24 21:49:58 +00:00
|
|
|
|
readInset(lex, par, pos, font);
|
2000-03-01 14:13:21 +00:00
|
|
|
|
} else if (token == "\\SpecialChar") {
|
2000-03-09 03:36:48 +00:00
|
|
|
|
LyXLayout const & layout =
|
|
|
|
|
textclasslist.Style(params.textclass,
|
|
|
|
|
par->GetLayout());
|
|
|
|
|
|
|
|
|
|
// Insets don't make sense in a free-spacing context! ---Kayvan
|
2000-04-24 20:58:23 +00:00
|
|
|
|
if (layout.free_spacing) {
|
2000-03-09 03:36:48 +00:00
|
|
|
|
if (lex.IsOK()) {
|
|
|
|
|
lex.next();
|
2000-07-15 23:51:46 +00:00
|
|
|
|
string next_token = lex.GetString();
|
2000-03-09 03:36:48 +00:00
|
|
|
|
if (next_token == "\\-") {
|
2000-06-28 13:35:52 +00:00
|
|
|
|
par->InsertChar(pos, '-', font);
|
2000-05-05 11:42:00 +00:00
|
|
|
|
} else if (next_token == "\\protected_separator"
|
2000-05-05 12:27:42 +00:00
|
|
|
|
|| next_token == "~") {
|
2000-06-28 13:35:52 +00:00
|
|
|
|
par->InsertChar(pos, ' ', font);
|
2000-03-09 03:36:48 +00:00
|
|
|
|
} else {
|
|
|
|
|
lex.printError("Token `$$Token' "
|
|
|
|
|
"is in free space "
|
|
|
|
|
"paragraph layout!");
|
2000-04-24 20:58:23 +00:00
|
|
|
|
--pos;
|
2000-03-09 03:36:48 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2000-04-24 20:58:23 +00:00
|
|
|
|
} else {
|
|
|
|
|
Inset * inset = new InsetSpecialChar;
|
2000-06-12 11:27:15 +00:00
|
|
|
|
inset->Read(this, lex);
|
2000-06-28 13:35:52 +00:00
|
|
|
|
par->InsertInset(pos, inset, font);
|
2000-03-09 03:36:48 +00:00
|
|
|
|
}
|
2000-03-01 14:13:21 +00:00
|
|
|
|
++pos;
|
2000-04-24 20:58:23 +00:00
|
|
|
|
} else if (token == "\\newline") {
|
2000-06-28 13:35:52 +00:00
|
|
|
|
par->InsertChar(pos, LyXParagraph::META_NEWLINE, font);
|
2000-03-01 14:13:21 +00:00
|
|
|
|
++pos;
|
|
|
|
|
} else if (token == "\\LyXTable") {
|
2000-10-10 11:50:43 +00:00
|
|
|
|
Inset * inset = new InsetTabular(*this);
|
2000-06-12 11:27:15 +00:00
|
|
|
|
inset->Read(this, lex);
|
2000-06-28 13:35:52 +00:00
|
|
|
|
par->InsertInset(pos, inset, font);
|
2000-05-17 14:43:09 +00:00
|
|
|
|
++pos;
|
2000-03-01 14:13:21 +00:00
|
|
|
|
} else if (token == "\\hfill") {
|
2000-06-28 13:35:52 +00:00
|
|
|
|
par->InsertChar(pos, LyXParagraph::META_HFILL, font);
|
2000-03-01 14:13:21 +00:00
|
|
|
|
++pos;
|
|
|
|
|
} else if (token == "\\protected_separator") { // obsolete
|
2000-04-26 13:57:28 +00:00
|
|
|
|
// This is a backward compability thingie. (Lgb)
|
|
|
|
|
// Remove it later some time...introduced with fileformat
|
|
|
|
|
// 2.16. (Lgb)
|
2000-03-09 03:36:48 +00:00
|
|
|
|
LyXLayout const & layout =
|
|
|
|
|
textclasslist.Style(params.textclass,
|
|
|
|
|
par->GetLayout());
|
|
|
|
|
|
|
|
|
|
if (layout.free_spacing) {
|
2000-06-28 13:35:52 +00:00
|
|
|
|
par->InsertChar(pos, ' ', font);
|
2000-03-09 03:36:48 +00:00
|
|
|
|
} else {
|
2000-04-24 20:58:23 +00:00
|
|
|
|
Inset * inset = new InsetSpecialChar(InsetSpecialChar::PROTECTED_SEPARATOR);
|
2000-06-28 13:35:52 +00:00
|
|
|
|
par->InsertInset(pos, inset, font);
|
2000-03-09 03:36:48 +00:00
|
|
|
|
}
|
2000-03-01 14:13:21 +00:00
|
|
|
|
++pos;
|
|
|
|
|
} else if (token == "\\bibitem") { // ale970302
|
2000-08-04 13:12:30 +00:00
|
|
|
|
if (!par->bibkey) {
|
|
|
|
|
InsetCommandParams p( "bibitem" );
|
|
|
|
|
par->bibkey = new InsetBibKey(p);
|
|
|
|
|
}
|
2000-06-12 11:27:15 +00:00
|
|
|
|
par->bibkey->Read(this, lex);
|
2000-08-05 05:17:18 +00:00
|
|
|
|
} else if (token == "\\backslash") {
|
2000-06-28 13:35:52 +00:00
|
|
|
|
par->InsertChar(pos, '\\', font);
|
2000-03-01 14:13:21 +00:00
|
|
|
|
++pos;
|
2000-08-05 05:17:18 +00:00
|
|
|
|
} else if (token == "\\the_end") {
|
2000-03-01 14:13:21 +00:00
|
|
|
|
the_end_read = true;
|
|
|
|
|
} else {
|
|
|
|
|
// This should be insurance for the future: (Asger)
|
|
|
|
|
lex.printError("Unknown token `$$Token'. "
|
|
|
|
|
"Inserting as text.");
|
2000-08-05 05:17:18 +00:00
|
|
|
|
string::const_iterator cit = token.begin();
|
|
|
|
|
string::const_iterator end = token.end();
|
2000-11-04 10:00:12 +00:00
|
|
|
|
for (; cit != end; ++cit) {
|
2000-06-28 13:35:52 +00:00
|
|
|
|
par->InsertChar(pos, (*cit), font);
|
2000-03-01 14:13:21 +00:00
|
|
|
|
++pos;
|
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
return the_end_read;
|
|
|
|
|
}
|
|
|
|
|
|
2000-07-24 21:49:58 +00:00
|
|
|
|
|
|
|
|
|
void Buffer::readInset(LyXLex & lex, LyXParagraph *& par,
|
|
|
|
|
int & pos, LyXFont & font)
|
|
|
|
|
{
|
|
|
|
|
// consistency check
|
|
|
|
|
if (lex.GetString() != "\\begin_inset") {
|
|
|
|
|
lyxerr << "Buffer::readInset: Consistency check failed."
|
|
|
|
|
<< endl;
|
|
|
|
|
}
|
|
|
|
|
|
2000-09-27 05:40:29 +00:00
|
|
|
|
Inset * inset = 0;
|
|
|
|
|
|
2000-07-24 21:49:58 +00:00
|
|
|
|
lex.next();
|
2000-09-26 13:54:57 +00:00
|
|
|
|
string const tmptok = lex.GetString();
|
2000-07-24 21:49:58 +00:00
|
|
|
|
last_inset_read = tmptok;
|
2000-09-27 05:40:29 +00:00
|
|
|
|
|
2000-07-24 21:49:58 +00:00
|
|
|
|
// test the different insets
|
2000-09-27 05:40:29 +00:00
|
|
|
|
if (tmptok == "LatexCommand") {
|
2000-08-04 13:12:30 +00:00
|
|
|
|
InsetCommandParams inscmd;
|
|
|
|
|
inscmd.Read(lex);
|
2000-09-27 05:40:29 +00:00
|
|
|
|
|
2000-07-24 21:49:58 +00:00
|
|
|
|
if (inscmd.getCmdName() == "cite") {
|
2000-08-04 13:12:30 +00:00
|
|
|
|
inset = new InsetCitation(inscmd);
|
2000-07-24 21:49:58 +00:00
|
|
|
|
} else if (inscmd.getCmdName() == "bibitem") {
|
|
|
|
|
lex.printError("Wrong place for bibitem");
|
2000-08-04 13:12:30 +00:00
|
|
|
|
inset = new InsetBibKey(inscmd);
|
2000-07-24 21:49:58 +00:00
|
|
|
|
} else if (inscmd.getCmdName() == "BibTeX") {
|
2000-10-03 09:13:34 +00:00
|
|
|
|
inset = new InsetBibtex(inscmd);
|
2000-07-24 21:49:58 +00:00
|
|
|
|
} else if (inscmd.getCmdName() == "index") {
|
2000-08-04 13:12:30 +00:00
|
|
|
|
inset = new InsetIndex(inscmd);
|
2000-07-24 21:49:58 +00:00
|
|
|
|
} else if (inscmd.getCmdName() == "include") {
|
2000-10-10 11:50:43 +00:00
|
|
|
|
inset = new InsetInclude(inscmd, *this);
|
2000-07-24 21:49:58 +00:00
|
|
|
|
} else if (inscmd.getCmdName() == "label") {
|
2000-08-04 13:12:30 +00:00
|
|
|
|
inset = new InsetLabel(inscmd);
|
2000-07-24 21:49:58 +00:00
|
|
|
|
} else if (inscmd.getCmdName() == "url"
|
|
|
|
|
|| inscmd.getCmdName() == "htmlurl") {
|
2000-08-04 13:12:30 +00:00
|
|
|
|
inset = new InsetUrl(inscmd);
|
2000-07-24 21:49:58 +00:00
|
|
|
|
} else if (inscmd.getCmdName() == "ref"
|
|
|
|
|
|| inscmd.getCmdName() == "pageref"
|
|
|
|
|
|| inscmd.getCmdName() == "vref"
|
|
|
|
|
|| inscmd.getCmdName() == "vpageref"
|
|
|
|
|
|| inscmd.getCmdName() == "prettyref") {
|
|
|
|
|
if (!inscmd.getOptions().empty()
|
|
|
|
|
|| !inscmd.getContents().empty()) {
|
2000-10-10 11:50:43 +00:00
|
|
|
|
inset = new InsetRef(inscmd, *this);
|
2000-07-24 21:49:58 +00:00
|
|
|
|
}
|
2000-08-01 17:33:32 +00:00
|
|
|
|
} else if (inscmd.getCmdName() == "tableofcontents"
|
|
|
|
|
|| inscmd.getCmdName() == "listofalgorithms"
|
|
|
|
|
|| inscmd.getCmdName() == "listoffigures"
|
|
|
|
|
|| inscmd.getCmdName() == "listoftables") {
|
2000-08-04 13:12:30 +00:00
|
|
|
|
inset = new InsetTOC(inscmd);
|
2000-07-24 21:49:58 +00:00
|
|
|
|
} else if (inscmd.getCmdName() == "printindex") {
|
2000-08-04 13:12:30 +00:00
|
|
|
|
inset = new InsetPrintIndex(inscmd);
|
2000-07-24 21:49:58 +00:00
|
|
|
|
} else if (inscmd.getCmdName() == "lyxparent") {
|
2000-10-10 11:50:43 +00:00
|
|
|
|
inset = new InsetParent(inscmd, *this);
|
2000-07-24 21:49:58 +00:00
|
|
|
|
}
|
2000-09-27 05:40:29 +00:00
|
|
|
|
} else {
|
|
|
|
|
if (tmptok == "Quotes") {
|
|
|
|
|
inset = new InsetQuotes;
|
|
|
|
|
} else if (tmptok == "External") {
|
|
|
|
|
inset = new InsetExternal;
|
|
|
|
|
} else if (tmptok == "FormulaMacro") {
|
|
|
|
|
inset = new InsetFormulaMacro;
|
|
|
|
|
} else if (tmptok == "Formula") {
|
|
|
|
|
inset = new InsetFormula;
|
|
|
|
|
} else if (tmptok == "Figure") {
|
2000-10-10 11:50:43 +00:00
|
|
|
|
inset = new InsetFig(100, 100, *this);
|
2000-09-27 05:40:29 +00:00
|
|
|
|
} else if (tmptok == "Info") {
|
|
|
|
|
inset = new InsetInfo;
|
|
|
|
|
} else if (tmptok == "Include") {
|
|
|
|
|
InsetCommandParams p( "Include" );
|
2000-10-10 11:50:43 +00:00
|
|
|
|
inset = new InsetInclude(p, *this);
|
2000-09-27 05:40:29 +00:00
|
|
|
|
} else if (tmptok == "ERT") {
|
|
|
|
|
inset = new InsetERT;
|
|
|
|
|
} else if (tmptok == "Tabular") {
|
2000-10-10 11:50:43 +00:00
|
|
|
|
inset = new InsetTabular(*this);
|
2000-09-27 05:40:29 +00:00
|
|
|
|
} else if (tmptok == "Text") {
|
|
|
|
|
inset = new InsetText;
|
|
|
|
|
} else if (tmptok == "Foot") {
|
|
|
|
|
inset = new InsetFoot;
|
|
|
|
|
} else if (tmptok == "Marginal") {
|
|
|
|
|
inset = new InsetMarginal;
|
|
|
|
|
} else if (tmptok == "Minipage") {
|
|
|
|
|
inset = new InsetMinipage;
|
|
|
|
|
} else if (tmptok == "Float") {
|
|
|
|
|
lex.next();
|
|
|
|
|
string tmptok = lex.GetString();
|
|
|
|
|
inset = new InsetFloat(tmptok);
|
|
|
|
|
} else if (tmptok == "List") {
|
|
|
|
|
inset = new InsetList;
|
|
|
|
|
} else if (tmptok == "Theorem") {
|
|
|
|
|
inset = new InsetList;
|
|
|
|
|
} else if (tmptok == "Caption") {
|
|
|
|
|
inset = new InsetCaption;
|
|
|
|
|
} else if (tmptok == "GRAPHICS") {
|
|
|
|
|
inset = new InsetGraphics;
|
2000-07-24 21:49:58 +00:00
|
|
|
|
}
|
2000-09-27 05:40:29 +00:00
|
|
|
|
|
|
|
|
|
if (inset) inset->Read(this, lex);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (inset) {
|
|
|
|
|
par->InsertInset(pos, inset, font);
|
|
|
|
|
++pos;
|
2000-07-24 21:49:58 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
1999-11-04 01:40:20 +00:00
|
|
|
|
bool Buffer::readFile(LyXLex & lex, LyXParagraph * par)
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
|
|
|
|
if (lex.IsOK()) {
|
|
|
|
|
lex.next();
|
2000-09-26 13:54:57 +00:00
|
|
|
|
string const token(lex.GetString());
|
1999-09-27 18:44:28 +00:00
|
|
|
|
if (token == "\\lyxformat") { // the first token _must_ be...
|
2000-09-26 13:10:34 +00:00
|
|
|
|
lex.EatLine();
|
2001-01-11 11:06:10 +00:00
|
|
|
|
#if 0
|
1999-09-27 18:44:28 +00:00
|
|
|
|
format = lex.GetFloat();
|
2000-10-26 17:31:11 +00:00
|
|
|
|
if (format > 1.0) {
|
1999-09-27 18:44:28 +00:00
|
|
|
|
if (LYX_FORMAT - format > 0.05) {
|
2000-10-11 21:06:43 +00:00
|
|
|
|
lyxerr << fmt(_("Warning: need lyxformat %.2f but found %.2f"),
|
|
|
|
|
LYX_FORMAT, format) << endl;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
if (format - LYX_FORMAT > 0.05) {
|
2000-10-11 21:06:43 +00:00
|
|
|
|
lyxerr << fmt(_("ERROR: need lyxformat %.2f but found %.2f"),
|
|
|
|
|
LYX_FORMAT, format) << endl;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
bool the_end = readLyXformat2(lex, par);
|
|
|
|
|
// Formats >= 2.13 support "\the_end" marker
|
|
|
|
|
if (format < 2.13)
|
|
|
|
|
the_end = true;
|
2000-02-04 09:38:32 +00:00
|
|
|
|
|
|
|
|
|
setPaperStuff();
|
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
if (!the_end)
|
|
|
|
|
WriteAlert(_("Warning!"),
|
|
|
|
|
_("Reading of document is not complete"),
|
|
|
|
|
_("Maybe the document is truncated"));
|
|
|
|
|
// We simulate a safe reading anyways to allow
|
|
|
|
|
// users to take the chance... (Asger)
|
|
|
|
|
return true;
|
2000-10-26 17:31:11 +00:00
|
|
|
|
} // format < 1.0
|
1999-09-27 18:44:28 +00:00
|
|
|
|
else {
|
|
|
|
|
WriteAlert(_("ERROR!"),
|
|
|
|
|
_("Old LyX file format found. "
|
|
|
|
|
"Use LyX 0.10.x to read this!"));
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2001-01-11 11:06:10 +00:00
|
|
|
|
#else
|
|
|
|
|
string tmp_format = lex.GetString();
|
|
|
|
|
//lyxerr << "LyX Format: `" << tmp_format << "'" << endl;
|
|
|
|
|
// if present remove ".," from string.
|
|
|
|
|
string::size_type dot = tmp_format.find_first_of(".,");
|
|
|
|
|
//lyxerr << " dot found at " << dot << endl;
|
|
|
|
|
if (dot != string::npos)
|
|
|
|
|
tmp_format.erase(dot, 1);
|
|
|
|
|
file_format = strToInt(tmp_format);
|
|
|
|
|
if (file_format == LYX_FORMAT) {
|
|
|
|
|
// current format
|
|
|
|
|
} else if (file_format > LYX_FORMAT) {
|
|
|
|
|
// future format
|
|
|
|
|
WriteAlert(_("Warning!"),
|
|
|
|
|
_("LyX file format is newer that what"),
|
|
|
|
|
_("is supported in this LyX version. Expect some problems."));
|
|
|
|
|
|
|
|
|
|
} else if (file_format < LYX_FORMAT) {
|
|
|
|
|
// old formats
|
|
|
|
|
if (file_format < 200) {
|
|
|
|
|
WriteAlert(_("ERROR!"),
|
|
|
|
|
_("Old LyX file format found. "
|
|
|
|
|
"Use LyX 0.10.x to read this!"));
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
bool the_end = readLyXformat2(lex, par);
|
|
|
|
|
setPaperStuff();
|
|
|
|
|
// the_end was added in 213
|
|
|
|
|
if (file_format < 213)
|
|
|
|
|
the_end = true;
|
|
|
|
|
|
|
|
|
|
if (!the_end)
|
|
|
|
|
WriteAlert(_("Warning!"),
|
|
|
|
|
_("Reading of document is not complete"),
|
|
|
|
|
_("Maybe the document is truncated"));
|
|
|
|
|
return true;
|
|
|
|
|
#endif
|
1999-09-27 18:44:28 +00:00
|
|
|
|
} else { // "\\lyxformat" not found
|
|
|
|
|
WriteAlert(_("ERROR!"), _("Not a LyX file!"));
|
|
|
|
|
}
|
|
|
|
|
} else
|
|
|
|
|
WriteAlert(_("ERROR!"), _("Unable to read file!"));
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2000-02-22 00:36:17 +00:00
|
|
|
|
|
|
|
|
|
// Should probably be moved to somewhere else: BufferView? LyXView?
|
2000-03-20 14:49:54 +00:00
|
|
|
|
bool Buffer::save() const
|
2000-02-22 00:36:17 +00:00
|
|
|
|
{
|
|
|
|
|
// We don't need autosaves in the immediate future. (Asger)
|
|
|
|
|
resetAutosaveTimers();
|
|
|
|
|
|
|
|
|
|
// make a backup
|
2000-03-20 14:49:54 +00:00
|
|
|
|
string s;
|
|
|
|
|
if (lyxrc.make_backup) {
|
|
|
|
|
s = fileName() + '~';
|
|
|
|
|
if (!lyxrc.backupdir_path.empty())
|
|
|
|
|
s = AddName(lyxrc.backupdir_path,
|
|
|
|
|
subst(CleanupPath(s),'/','!'));
|
|
|
|
|
|
2000-02-22 00:36:17 +00:00
|
|
|
|
// Rename is the wrong way of making a backup,
|
|
|
|
|
// this is the correct way.
|
|
|
|
|
/* truss cp fil fil2:
|
|
|
|
|
lstat("LyXVC3.lyx", 0xEFFFF898) Err#2 ENOENT
|
|
|
|
|
stat("LyXVC.lyx", 0xEFFFF688) = 0
|
|
|
|
|
open("LyXVC.lyx", O_RDONLY) = 3
|
|
|
|
|
open("LyXVC3.lyx", O_WRONLY|O_CREAT|O_TRUNC, 0600) = 4
|
|
|
|
|
fstat(4, 0xEFFFF508) = 0
|
|
|
|
|
fstat(3, 0xEFFFF508) = 0
|
|
|
|
|
read(3, " # T h i s f i l e w".., 8192) = 5579
|
|
|
|
|
write(4, " # T h i s f i l e w".., 5579) = 5579
|
|
|
|
|
read(3, 0xEFFFD4A0, 8192) = 0
|
|
|
|
|
close(4) = 0
|
|
|
|
|
close(3) = 0
|
|
|
|
|
chmod("LyXVC3.lyx", 0100644) = 0
|
|
|
|
|
lseek(0, 0, SEEK_CUR) = 46440
|
|
|
|
|
_exit(0)
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
// Should proabaly have some more error checking here.
|
|
|
|
|
// Should be cleaned up in 0.13, at least a bit.
|
|
|
|
|
// Doing it this way, also makes the inodes stay the same.
|
|
|
|
|
// This is still not a very good solution, in particular we
|
|
|
|
|
// might loose the owner of the backup.
|
|
|
|
|
FileInfo finfo(fileName());
|
|
|
|
|
if (finfo.exist()) {
|
|
|
|
|
mode_t fmode = finfo.getMode();
|
2000-03-28 02:18:55 +00:00
|
|
|
|
struct utimbuf times = {
|
|
|
|
|
finfo.getAccessTime(),
|
|
|
|
|
finfo.getModificationTime() };
|
2000-02-22 00:36:17 +00:00
|
|
|
|
|
|
|
|
|
ifstream ifs(fileName().c_str());
|
|
|
|
|
ofstream ofs(s.c_str(), ios::out|ios::trunc);
|
|
|
|
|
if (ifs && ofs) {
|
|
|
|
|
ofs << ifs.rdbuf();
|
|
|
|
|
ifs.close();
|
|
|
|
|
ofs.close();
|
|
|
|
|
::chmod(s.c_str(), fmode);
|
|
|
|
|
|
2000-03-28 02:18:55 +00:00
|
|
|
|
if (::utime(s.c_str(), ×)) {
|
2000-02-22 00:36:17 +00:00
|
|
|
|
lyxerr << "utime error." << endl;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
lyxerr << "LyX was not able to make "
|
|
|
|
|
"backupcopy. Beware." << endl;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (writeFile(fileName(), false)) {
|
|
|
|
|
markLyxClean();
|
2000-08-08 15:36:25 +00:00
|
|
|
|
removeAutosaveFile(fileName());
|
2000-02-22 00:36:17 +00:00
|
|
|
|
} else {
|
|
|
|
|
// Saving failed, so backup is not backup
|
2000-03-20 14:49:54 +00:00
|
|
|
|
if (lyxrc.make_backup) {
|
2000-09-26 13:54:57 +00:00
|
|
|
|
lyx::rename(s, fileName());
|
2000-02-22 00:36:17 +00:00
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
// Returns false if unsuccesful
|
2000-02-22 00:36:17 +00:00
|
|
|
|
bool Buffer::writeFile(string const & fname, bool flag) const
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
|
|
|
|
// if flag is false writeFile will not create any GUI
|
1999-10-07 18:44:17 +00:00
|
|
|
|
// warnings, only cerr.
|
1999-09-27 18:44:28 +00:00
|
|
|
|
// Needed for autosave in background or panic save (Matthias 120496)
|
|
|
|
|
|
1999-12-21 06:10:21 +00:00
|
|
|
|
if (read_only && (fname == filename)) {
|
1999-09-27 18:44:28 +00:00
|
|
|
|
// Here we should come with a question if we should
|
|
|
|
|
// perform the write anyway.
|
|
|
|
|
if (flag)
|
1999-10-07 18:44:17 +00:00
|
|
|
|
lyxerr << _("Error! Document is read-only: ")
|
1999-12-21 06:10:21 +00:00
|
|
|
|
<< fname << endl;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
else
|
1999-11-15 12:01:38 +00:00
|
|
|
|
WriteAlert(_("Error! Document is read-only: "),
|
1999-12-21 06:10:21 +00:00
|
|
|
|
fname);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
1999-12-21 06:10:21 +00:00
|
|
|
|
FileInfo finfo(fname);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
if (finfo.exist() && !finfo.writable()) {
|
|
|
|
|
// Here we should come with a question if we should
|
|
|
|
|
// try to do the save anyway. (i.e. do a chmod first)
|
|
|
|
|
if (flag)
|
1999-10-07 18:44:17 +00:00
|
|
|
|
lyxerr << _("Error! Cannot write file: ")
|
1999-12-21 06:10:21 +00:00
|
|
|
|
<< fname << endl;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
else
|
1999-11-15 12:01:38 +00:00
|
|
|
|
WriteFSAlert(_("Error! Cannot write file: "),
|
1999-12-21 06:10:21 +00:00
|
|
|
|
fname);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
1999-12-21 06:10:21 +00:00
|
|
|
|
ofstream ofs(fname.c_str());
|
1999-12-07 00:44:53 +00:00
|
|
|
|
if (!ofs) {
|
1999-09-27 18:44:28 +00:00
|
|
|
|
if (flag)
|
1999-12-07 00:44:53 +00:00
|
|
|
|
lyxerr << _("Error! Cannot open file: ")
|
1999-12-21 06:10:21 +00:00
|
|
|
|
<< fname << endl;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
else
|
1999-12-13 21:59:26 +00:00
|
|
|
|
WriteFSAlert(_("Error! Cannot open file: "),
|
1999-12-21 06:10:21 +00:00
|
|
|
|
fname);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
return false;
|
|
|
|
|
}
|
2000-09-14 17:53:12 +00:00
|
|
|
|
|
|
|
|
|
#ifdef HAVE_LOCALE
|
|
|
|
|
// Use the standard "C" locale for file output.
|
2000-09-15 10:24:15 +00:00
|
|
|
|
ofs.imbue(std::locale::classic());
|
2000-09-14 17:53:12 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
// The top of the file should not be written by params.
|
|
|
|
|
|
|
|
|
|
// write out a comment in the top of the file
|
1999-12-15 17:42:22 +00:00
|
|
|
|
ofs << '#' << LYX_DOCVERSION
|
|
|
|
|
<< " created this file. For more info see http://www.lyx.org/\n";
|
2001-01-11 11:06:10 +00:00
|
|
|
|
#if 0
|
1999-12-07 00:44:53 +00:00
|
|
|
|
ofs.setf(ios::showpoint|ios::fixed);
|
|
|
|
|
ofs.precision(2);
|
2000-09-14 17:53:12 +00:00
|
|
|
|
#ifndef HAVE_LOCALE
|
|
|
|
|
char dummy_format[512];
|
|
|
|
|
sprintf(dummy_format, "%.2f", LYX_FORMAT);
|
|
|
|
|
ofs << "\\lyxformat " << dummy_format << "\n";
|
|
|
|
|
#else
|
1999-12-07 00:44:53 +00:00
|
|
|
|
ofs << "\\lyxformat " << setw(4) << LYX_FORMAT << "\n";
|
2001-01-11 11:06:10 +00:00
|
|
|
|
#endif
|
|
|
|
|
#else
|
2001-01-11 11:12:33 +00:00
|
|
|
|
ofs << "\\lyxformat " << LYX_FORMAT << "\n";
|
2000-09-14 17:53:12 +00:00
|
|
|
|
#endif
|
1999-12-07 00:44:53 +00:00
|
|
|
|
// now write out the buffer paramters.
|
|
|
|
|
params.writeFile(ofs);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
char footnoteflag = 0;
|
|
|
|
|
char depth = 0;
|
|
|
|
|
|
|
|
|
|
// this will write out all the paragraphs
|
|
|
|
|
// using recursive descent.
|
2000-06-12 11:27:15 +00:00
|
|
|
|
paragraph->writeFile(this, ofs, params, footnoteflag, depth);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
// Write marker that shows file is complete
|
1999-12-07 00:44:53 +00:00
|
|
|
|
ofs << "\n\\the_end" << endl;
|
2000-10-13 12:20:38 +00:00
|
|
|
|
|
1999-12-07 00:44:53 +00:00
|
|
|
|
ofs.close();
|
2000-10-13 12:20:38 +00:00
|
|
|
|
|
1999-12-07 00:44:53 +00:00
|
|
|
|
// how to check if close went ok?
|
2000-10-13 12:20:38 +00:00
|
|
|
|
// Following is an attempt... (BE 20001011)
|
|
|
|
|
|
|
|
|
|
// good() returns false if any error occured, including some
|
|
|
|
|
// formatting error.
|
|
|
|
|
// bad() returns true if something bad happened in the buffer,
|
|
|
|
|
// which should include file system full errors.
|
|
|
|
|
|
|
|
|
|
bool status = true;
|
|
|
|
|
if (!ofs.good()) {
|
|
|
|
|
status = false;
|
|
|
|
|
#if 0
|
|
|
|
|
if (ofs.bad()) {
|
|
|
|
|
lyxerr << "Buffer::writeFile: BAD ERROR!" << endl;
|
|
|
|
|
} else {
|
|
|
|
|
lyxerr << "Buffer::writeFile: NOT SO BAD ERROR!"
|
|
|
|
|
<< endl;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return status;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2000-09-27 17:07:33 +00:00
|
|
|
|
string const Buffer::asciiParagraph(LyXParagraph const * par,
|
|
|
|
|
unsigned int linelen) const
|
2000-09-26 15:25:14 +00:00
|
|
|
|
{
|
|
|
|
|
ostringstream buffer;
|
2000-09-29 18:44:07 +00:00
|
|
|
|
LyXFont font1;
|
|
|
|
|
LyXFont font2;
|
2000-09-26 15:25:14 +00:00
|
|
|
|
Inset const * inset;
|
2000-09-27 17:07:33 +00:00
|
|
|
|
char c;
|
2000-12-06 22:24:17 +00:00
|
|
|
|
#ifndef NEW_INSETS
|
2000-09-27 17:07:33 +00:00
|
|
|
|
LyXParagraph::footnote_flag footnoteflag = LyXParagraph::NO_FOOTNOTE;
|
2000-12-06 22:24:17 +00:00
|
|
|
|
#endif
|
2000-09-27 17:07:33 +00:00
|
|
|
|
char depth = 0;
|
2000-09-26 15:25:14 +00:00
|
|
|
|
int ltype = 0;
|
|
|
|
|
int ltype_depth = 0;
|
2000-09-27 17:07:33 +00:00
|
|
|
|
unsigned int currlinelen = 0;
|
2000-09-26 15:25:14 +00:00
|
|
|
|
bool ref_printed = false;
|
|
|
|
|
|
|
|
|
|
int noparbreak = 0;
|
|
|
|
|
int islatex = 0;
|
|
|
|
|
if (
|
|
|
|
|
#ifndef NEW_INSETS
|
|
|
|
|
par->footnoteflag != LyXParagraph::NO_FOOTNOTE ||
|
|
|
|
|
#endif
|
|
|
|
|
!par->previous
|
|
|
|
|
#ifndef NEW_INSETS
|
|
|
|
|
|| par->previous->footnoteflag == LyXParagraph::NO_FOOTNOTE
|
|
|
|
|
#endif
|
|
|
|
|
){
|
|
|
|
|
#ifndef NEW_INSETS
|
|
|
|
|
/* begins a footnote environment ? */
|
|
|
|
|
if (footnoteflag != par->footnoteflag) {
|
|
|
|
|
footnoteflag = par->footnoteflag;
|
|
|
|
|
if (footnoteflag) {
|
2000-09-29 18:44:07 +00:00
|
|
|
|
size_t const j = strlen(string_footnotekinds[par->footnotekind]) + 4;
|
2000-09-26 15:25:14 +00:00
|
|
|
|
if ((linelen > 0) &&
|
|
|
|
|
((currlinelen + j) > linelen)) {
|
|
|
|
|
buffer << "\n";
|
|
|
|
|
currlinelen = 0;
|
|
|
|
|
}
|
2000-09-29 18:44:07 +00:00
|
|
|
|
buffer << "(["
|
|
|
|
|
<< string_footnotekinds[par->footnotekind]
|
|
|
|
|
<< "] ";
|
2000-09-26 15:25:14 +00:00
|
|
|
|
currlinelen += j;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
/* begins or ends a deeper area ?*/
|
|
|
|
|
if (depth != par->depth) {
|
|
|
|
|
if (par->depth > depth) {
|
|
|
|
|
while (par->depth > depth) {
|
|
|
|
|
++depth;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
while (par->depth < depth) {
|
|
|
|
|
--depth;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* First write the layout */
|
2000-09-29 18:44:07 +00:00
|
|
|
|
string const tmp = textclasslist.NameOfLayout(params.textclass, par->layout);
|
2000-09-26 15:25:14 +00:00
|
|
|
|
if (tmp == "Itemize") {
|
|
|
|
|
ltype = 1;
|
|
|
|
|
ltype_depth = depth+1;
|
|
|
|
|
} else if (tmp == "Enumerate") {
|
|
|
|
|
ltype = 2;
|
|
|
|
|
ltype_depth = depth+1;
|
|
|
|
|
} else if (strstr(tmp.c_str(), "ection")) {
|
|
|
|
|
ltype = 3;
|
|
|
|
|
ltype_depth = depth+1;
|
|
|
|
|
} else if (strstr(tmp.c_str(), "aragraph")) {
|
|
|
|
|
ltype = 4;
|
|
|
|
|
ltype_depth = depth+1;
|
|
|
|
|
} else if (tmp == "Description") {
|
|
|
|
|
ltype = 5;
|
|
|
|
|
ltype_depth = depth+1;
|
|
|
|
|
} else if (tmp == "Abstract") {
|
|
|
|
|
ltype = 6;
|
|
|
|
|
ltype_depth = 0;
|
|
|
|
|
} else if (tmp == "Bibliography") {
|
|
|
|
|
ltype = 7;
|
|
|
|
|
ltype_depth = 0;
|
|
|
|
|
} else {
|
|
|
|
|
ltype = 0;
|
|
|
|
|
ltype_depth = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* maybe some vertical spaces */
|
|
|
|
|
|
|
|
|
|
/* the labelwidthstring used in lists */
|
|
|
|
|
|
|
|
|
|
/* some lines? */
|
|
|
|
|
|
|
|
|
|
/* some pagebreaks? */
|
|
|
|
|
|
|
|
|
|
/* noindent ? */
|
|
|
|
|
|
|
|
|
|
/* what about the alignment */
|
|
|
|
|
} else {
|
|
|
|
|
#ifndef NEW_INSETS
|
|
|
|
|
/* dummy layout, that means a footnote ended */
|
|
|
|
|
footnoteflag = LyXParagraph::NO_FOOTNOTE;
|
|
|
|
|
buffer << ") ";
|
|
|
|
|
noparbreak = 1;
|
|
|
|
|
#else
|
|
|
|
|
lyxerr << "Should this ever happen?" << endl;
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
2000-10-10 12:36:36 +00:00
|
|
|
|
font1 = LyXFont(LyXFont::ALL_INHERIT, params.language);
|
2000-09-29 18:44:07 +00:00
|
|
|
|
for (LyXParagraph::size_type i = 0; i < par->size(); ++i) {
|
2000-12-06 22:24:17 +00:00
|
|
|
|
if (!i &&
|
|
|
|
|
#ifndef NEW_INSETS
|
|
|
|
|
!footnoteflag &&
|
|
|
|
|
#endif
|
|
|
|
|
!noparbreak) {
|
2000-10-10 10:38:11 +00:00
|
|
|
|
if (linelen > 0)
|
|
|
|
|
buffer << "\n\n";
|
2000-11-04 10:00:12 +00:00
|
|
|
|
for (char j = 0; j < depth; ++j)
|
2000-09-26 15:25:14 +00:00
|
|
|
|
buffer << " ";
|
|
|
|
|
currlinelen = depth * 2;
|
2000-11-04 10:00:12 +00:00
|
|
|
|
switch (ltype) {
|
2000-09-26 15:25:14 +00:00
|
|
|
|
case 0: /* Standard */
|
|
|
|
|
case 4: /* (Sub)Paragraph */
|
|
|
|
|
case 5: /* Description */
|
|
|
|
|
break;
|
|
|
|
|
case 6: /* Abstract */
|
2000-10-10 10:38:11 +00:00
|
|
|
|
if (linelen > 0)
|
|
|
|
|
buffer << "Abstract\n\n";
|
|
|
|
|
else
|
|
|
|
|
buffer << "Abstract: ";
|
2000-09-26 15:25:14 +00:00
|
|
|
|
break;
|
|
|
|
|
case 7: /* Bibliography */
|
|
|
|
|
if (!ref_printed) {
|
2000-10-10 10:38:11 +00:00
|
|
|
|
if (linelen > 0)
|
|
|
|
|
buffer << "References\n\n";
|
|
|
|
|
else
|
|
|
|
|
buffer << "References: ";
|
2000-09-26 15:25:14 +00:00
|
|
|
|
ref_printed = true;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
buffer << par->labelstring << " ";
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if (ltype_depth > depth) {
|
2000-11-04 10:00:12 +00:00
|
|
|
|
for (char j = ltype_depth - 1; j > depth; --j)
|
2000-09-26 15:25:14 +00:00
|
|
|
|
buffer << " ";
|
|
|
|
|
currlinelen += (ltype_depth-depth)*2;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
font2 = par->GetFontSettings(params, i);
|
|
|
|
|
if (font1.latex() != font2.latex()) {
|
|
|
|
|
if (font2.latex() == LyXFont::OFF)
|
|
|
|
|
islatex = 0;
|
|
|
|
|
else
|
|
|
|
|
islatex = 1;
|
|
|
|
|
} else {
|
|
|
|
|
islatex = 0;
|
|
|
|
|
}
|
|
|
|
|
c = par->GetChar(i);
|
|
|
|
|
if (islatex)
|
|
|
|
|
continue;
|
|
|
|
|
switch (c) {
|
|
|
|
|
case LyXParagraph::META_INSET:
|
|
|
|
|
if ((inset = par->GetInset(i))) {
|
|
|
|
|
if (!inset->Ascii(this, buffer)) {
|
|
|
|
|
string dummy;
|
2000-11-06 15:47:22 +00:00
|
|
|
|
string s = rsplit(buffer.str().c_str(),
|
2000-09-26 15:25:14 +00:00
|
|
|
|
dummy, '\n');
|
|
|
|
|
currlinelen += s.length();
|
|
|
|
|
} else {
|
|
|
|
|
// to be sure it breaks paragraph
|
|
|
|
|
currlinelen += linelen;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case LyXParagraph::META_NEWLINE:
|
2000-10-10 10:38:11 +00:00
|
|
|
|
if (linelen > 0) {
|
|
|
|
|
buffer << "\n";
|
2000-11-04 10:00:12 +00:00
|
|
|
|
for (char j = 0; j < depth; ++j)
|
2000-10-10 10:38:11 +00:00
|
|
|
|
buffer << " ";
|
|
|
|
|
}
|
2000-09-26 15:25:14 +00:00
|
|
|
|
currlinelen = depth * 2;
|
|
|
|
|
if (ltype_depth > depth) {
|
2000-11-04 10:00:12 +00:00
|
|
|
|
for (char j = ltype_depth;
|
2000-09-26 15:25:14 +00:00
|
|
|
|
j > depth; --j)
|
|
|
|
|
buffer << " ";
|
|
|
|
|
currlinelen += (ltype_depth - depth) * 2;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case LyXParagraph::META_HFILL:
|
|
|
|
|
buffer << "\t";
|
|
|
|
|
break;
|
|
|
|
|
case '\\':
|
|
|
|
|
buffer << "\\";
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
if ((linelen > 0) && (currlinelen > (linelen - 10)) &&
|
|
|
|
|
(c == ' ') && ((i + 2) < par->size()))
|
|
|
|
|
{
|
|
|
|
|
buffer << "\n";
|
2000-11-04 10:00:12 +00:00
|
|
|
|
for (char j = 0; j < depth; ++j)
|
2000-09-26 15:25:14 +00:00
|
|
|
|
buffer << " ";
|
|
|
|
|
currlinelen = depth * 2;
|
|
|
|
|
if (ltype_depth > depth) {
|
2000-11-04 10:00:12 +00:00
|
|
|
|
for (char j = ltype_depth;
|
2000-09-26 15:25:14 +00:00
|
|
|
|
j > depth; --j)
|
|
|
|
|
buffer << " ";
|
|
|
|
|
currlinelen += (ltype_depth-depth)*2;
|
|
|
|
|
}
|
|
|
|
|
} else if (c != '\0')
|
|
|
|
|
buffer << c;
|
|
|
|
|
else if (c == '\0')
|
|
|
|
|
lyxerr.debug() << "writeAsciiFile: NULL char in structure." << endl;
|
|
|
|
|
++currlinelen;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2000-11-06 15:47:22 +00:00
|
|
|
|
return buffer.str().c_str();
|
2000-09-26 15:25:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Buffer::writeFileAscii(string const & fname, int linelen)
|
|
|
|
|
{
|
|
|
|
|
ofstream ofs(fname.c_str());
|
|
|
|
|
if (!ofs) {
|
|
|
|
|
WriteFSAlert(_("Error: Cannot write file:"), fname);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
writeFileAscii(ofs, linelen);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Buffer::writeFileAscii(ostream & ofs, int linelen)
|
|
|
|
|
{
|
|
|
|
|
LyXParagraph * par = paragraph;
|
|
|
|
|
while (par) {
|
|
|
|
|
ofs << asciiParagraph(par, linelen);
|
|
|
|
|
par = par->next;
|
|
|
|
|
}
|
|
|
|
|
ofs << "\n";
|
|
|
|
|
}
|
2000-11-15 03:22:08 +00:00
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2000-03-06 02:42:40 +00:00
|
|
|
|
void Buffer::makeLaTeXFile(string const & fname,
|
|
|
|
|
string const & original_path,
|
|
|
|
|
bool nice, bool only_body)
|
|
|
|
|
{
|
|
|
|
|
lyxerr[Debug::LATEX] << "makeLaTeXFile..." << endl;
|
|
|
|
|
|
|
|
|
|
niceFile = nice; // this will be used by Insetincludes.
|
|
|
|
|
|
2000-03-12 10:35:05 +00:00
|
|
|
|
tex_code_break_column = lyxrc.ascii_linelen;
|
2000-03-06 02:42:40 +00:00
|
|
|
|
|
|
|
|
|
LyXTextClass const & tclass =
|
|
|
|
|
textclasslist.TextClass(params.textclass);
|
|
|
|
|
|
|
|
|
|
ofstream ofs(fname.c_str());
|
|
|
|
|
if (!ofs) {
|
|
|
|
|
WriteFSAlert(_("Error: Cannot open file: "), fname);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// validate the buffer.
|
|
|
|
|
lyxerr[Debug::LATEX] << " Validating buffer..." << endl;
|
2000-04-10 21:40:13 +00:00
|
|
|
|
LaTeXFeatures features(params, tclass.numLayouts());
|
2000-03-06 02:42:40 +00:00
|
|
|
|
validate(features);
|
|
|
|
|
lyxerr[Debug::LATEX] << " Buffer validation done." << endl;
|
|
|
|
|
|
|
|
|
|
texrow.reset();
|
|
|
|
|
// The starting paragraph of the coming rows is the
|
|
|
|
|
// first paragraph of the document. (Asger)
|
|
|
|
|
texrow.start(paragraph, 0);
|
|
|
|
|
|
|
|
|
|
if (!only_body && nice) {
|
|
|
|
|
ofs << "%% " LYX_DOCVERSION " created this file. "
|
|
|
|
|
"For more info, see http://www.lyx.org/.\n"
|
|
|
|
|
"%% Do not edit unless you really know what "
|
|
|
|
|
"you are doing.\n";
|
|
|
|
|
texrow.newline();
|
|
|
|
|
texrow.newline();
|
|
|
|
|
}
|
|
|
|
|
lyxerr.debug() << "lyx header finished" << endl;
|
|
|
|
|
// There are a few differences between nice LaTeX and usual files:
|
|
|
|
|
// usual is \batchmode and has a
|
|
|
|
|
// special input@path to allow the including of figures
|
|
|
|
|
// with either \input or \includegraphics (what figinsets do).
|
|
|
|
|
// batchmode is not set if there is a tex_code_break_column.
|
|
|
|
|
// In this case somebody is interested in the generated LaTeX,
|
|
|
|
|
// so this is OK. input@path is set when the actual parameter
|
|
|
|
|
// original_path is set. This is done for usual tex-file, but not
|
|
|
|
|
// for nice-latex-file. (Matthias 250696)
|
|
|
|
|
if (!only_body) {
|
|
|
|
|
if (!nice){
|
|
|
|
|
// code for usual, NOT nice-latex-file
|
|
|
|
|
ofs << "\\batchmode\n"; // changed
|
|
|
|
|
// from \nonstopmode
|
|
|
|
|
texrow.newline();
|
|
|
|
|
}
|
|
|
|
|
if (!original_path.empty()) {
|
|
|
|
|
ofs << "\\makeatletter\n"
|
|
|
|
|
<< "\\def\\input@path{{"
|
|
|
|
|
<< original_path << "/}}\n"
|
|
|
|
|
<< "\\makeatother\n";
|
|
|
|
|
texrow.newline();
|
|
|
|
|
texrow.newline();
|
|
|
|
|
texrow.newline();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ofs << "\\documentclass";
|
|
|
|
|
|
|
|
|
|
string options; // the document class options.
|
|
|
|
|
|
2000-07-04 19:16:35 +00:00
|
|
|
|
if (tokenPos(tclass.opt_fontsize(),
|
|
|
|
|
'|', params.fontsize) >= 0) {
|
2000-03-06 02:42:40 +00:00
|
|
|
|
// only write if existing in list (and not default)
|
|
|
|
|
options += params.fontsize;
|
|
|
|
|
options += "pt,";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!params.use_geometry &&
|
|
|
|
|
(params.paperpackage == BufferParams::PACKAGE_NONE)) {
|
|
|
|
|
switch (params.papersize) {
|
|
|
|
|
case BufferParams::PAPER_A4PAPER:
|
|
|
|
|
options += "a4paper,";
|
|
|
|
|
break;
|
|
|
|
|
case BufferParams::PAPER_USLETTER:
|
|
|
|
|
options += "letterpaper,";
|
|
|
|
|
break;
|
|
|
|
|
case BufferParams::PAPER_A5PAPER:
|
|
|
|
|
options += "a5paper,";
|
|
|
|
|
break;
|
|
|
|
|
case BufferParams::PAPER_B5PAPER:
|
|
|
|
|
options += "b5paper,";
|
|
|
|
|
break;
|
|
|
|
|
case BufferParams::PAPER_EXECUTIVEPAPER:
|
|
|
|
|
options += "executivepaper,";
|
|
|
|
|
break;
|
|
|
|
|
case BufferParams::PAPER_LEGALPAPER:
|
|
|
|
|
options += "legalpaper,";
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// if needed
|
|
|
|
|
if (params.sides != tclass.sides()) {
|
|
|
|
|
switch (params.sides) {
|
|
|
|
|
case LyXTextClass::OneSide:
|
|
|
|
|
options += "oneside,";
|
|
|
|
|
break;
|
|
|
|
|
case LyXTextClass::TwoSides:
|
|
|
|
|
options += "twoside,";
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// if needed
|
|
|
|
|
if (params.columns != tclass.columns()) {
|
|
|
|
|
if (params.columns == 2)
|
|
|
|
|
options += "twocolumn,";
|
|
|
|
|
else
|
|
|
|
|
options += "onecolumn,";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!params.use_geometry
|
|
|
|
|
&& params.orientation == BufferParams::ORIENTATION_LANDSCAPE)
|
|
|
|
|
options += "landscape,";
|
|
|
|
|
|
2000-03-17 10:14:46 +00:00
|
|
|
|
// language should be a parameter to \documentclass
|
|
|
|
|
bool use_babel = false;
|
2000-10-10 12:36:36 +00:00
|
|
|
|
if (params.language->babel() == "hebrew") // This seems necessary
|
2000-05-12 13:11:20 +00:00
|
|
|
|
features.UsedLanguages.insert(default_language);
|
2000-10-10 12:36:36 +00:00
|
|
|
|
#ifdef DO_USE_DEFAULT_LANGUAGE
|
|
|
|
|
if (params.language->lang() != "default" ||
|
2000-11-04 10:00:12 +00:00
|
|
|
|
!features.UsedLanguages.empty()) {
|
2000-10-10 12:36:36 +00:00
|
|
|
|
#endif
|
2000-03-17 10:14:46 +00:00
|
|
|
|
use_babel = true;
|
|
|
|
|
for (LaTeXFeatures::LanguageList::const_iterator cit =
|
|
|
|
|
features.UsedLanguages.begin();
|
2000-05-05 10:17:05 +00:00
|
|
|
|
cit != features.UsedLanguages.end(); ++cit)
|
2000-10-10 12:36:36 +00:00
|
|
|
|
options += (*cit)->babel() + ",";
|
|
|
|
|
options += params.language->babel() + ',';
|
|
|
|
|
#ifdef DO_USE_DEFAULT_LANGUAGE
|
2000-03-10 13:22:20 +00:00
|
|
|
|
}
|
2000-10-10 12:36:36 +00:00
|
|
|
|
#endif
|
2000-03-06 02:42:40 +00:00
|
|
|
|
|
|
|
|
|
// the user-defined options
|
|
|
|
|
if (!params.options.empty()) {
|
|
|
|
|
options += params.options + ',';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!options.empty()){
|
|
|
|
|
options = strip(options, ',');
|
|
|
|
|
ofs << '[' << options << ']';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ofs << '{'
|
|
|
|
|
<< textclasslist.LatexnameOfClass(params.textclass)
|
|
|
|
|
<< "}\n";
|
|
|
|
|
texrow.newline();
|
|
|
|
|
// end of \documentclass defs
|
|
|
|
|
|
|
|
|
|
// font selection must be done before loading fontenc.sty
|
|
|
|
|
if (params.fonts != "default") {
|
|
|
|
|
ofs << "\\usepackage{" << params.fonts << "}\n";
|
|
|
|
|
texrow.newline();
|
|
|
|
|
}
|
|
|
|
|
// this one is not per buffer
|
2000-03-12 10:35:05 +00:00
|
|
|
|
if (lyxrc.fontenc != "default") {
|
|
|
|
|
ofs << "\\usepackage[" << lyxrc.fontenc
|
2000-03-06 02:42:40 +00:00
|
|
|
|
<< "]{fontenc}\n";
|
|
|
|
|
texrow.newline();
|
|
|
|
|
}
|
2000-07-04 20:32:37 +00:00
|
|
|
|
|
|
|
|
|
if (params.inputenc == "auto") {
|
2000-09-26 13:54:57 +00:00
|
|
|
|
string const doc_encoding =
|
2000-10-10 12:36:36 +00:00
|
|
|
|
params.language->encoding()->LatexName();
|
2000-07-04 20:32:37 +00:00
|
|
|
|
|
|
|
|
|
// Create a list with all the input encodings used
|
|
|
|
|
// in the document
|
|
|
|
|
set<string> encodings;
|
|
|
|
|
for (LaTeXFeatures::LanguageList::const_iterator it =
|
|
|
|
|
features.UsedLanguages.begin();
|
|
|
|
|
it != features.UsedLanguages.end(); ++it)
|
|
|
|
|
if ((*it)->encoding()->LatexName() != doc_encoding)
|
|
|
|
|
encodings.insert((*it)->encoding()->LatexName());
|
|
|
|
|
|
|
|
|
|
ofs << "\\usepackage[";
|
2000-10-12 15:17:42 +00:00
|
|
|
|
std::copy(encodings.begin(), encodings.end(),
|
|
|
|
|
std::ostream_iterator<string>(ofs, ","));
|
2000-07-04 20:32:37 +00:00
|
|
|
|
ofs << doc_encoding << "]{inputenc}\n";
|
|
|
|
|
texrow.newline();
|
|
|
|
|
} else if (params.inputenc != "default") {
|
2000-03-06 02:42:40 +00:00
|
|
|
|
ofs << "\\usepackage[" << params.inputenc
|
|
|
|
|
<< "]{inputenc}\n";
|
|
|
|
|
texrow.newline();
|
|
|
|
|
}
|
2000-07-04 20:32:37 +00:00
|
|
|
|
|
2000-04-26 13:57:28 +00:00
|
|
|
|
// At the very beginning the text parameters.
|
2000-03-06 02:42:40 +00:00
|
|
|
|
if (params.paperpackage != BufferParams::PACKAGE_NONE) {
|
|
|
|
|
switch (params.paperpackage) {
|
|
|
|
|
case BufferParams::PACKAGE_A4:
|
|
|
|
|
ofs << "\\usepackage{a4}\n";
|
|
|
|
|
texrow.newline();
|
|
|
|
|
break;
|
|
|
|
|
case BufferParams::PACKAGE_A4WIDE:
|
|
|
|
|
ofs << "\\usepackage{a4wide}\n";
|
|
|
|
|
texrow.newline();
|
|
|
|
|
break;
|
|
|
|
|
case BufferParams::PACKAGE_WIDEMARGINSA4:
|
|
|
|
|
ofs << "\\usepackage[widemargins]{a4}\n";
|
|
|
|
|
texrow.newline();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (params.use_geometry) {
|
|
|
|
|
ofs << "\\usepackage{geometry}\n";
|
|
|
|
|
texrow.newline();
|
|
|
|
|
ofs << "\\geometry{verbose";
|
|
|
|
|
if (params.orientation == BufferParams::ORIENTATION_LANDSCAPE)
|
|
|
|
|
ofs << ",landscape";
|
|
|
|
|
switch (params.papersize2) {
|
|
|
|
|
case BufferParams::VM_PAPER_CUSTOM:
|
|
|
|
|
if (!params.paperwidth.empty())
|
|
|
|
|
ofs << ",paperwidth="
|
|
|
|
|
<< params.paperwidth;
|
|
|
|
|
if (!params.paperheight.empty())
|
|
|
|
|
ofs << ",paperheight="
|
|
|
|
|
<< params.paperheight;
|
|
|
|
|
break;
|
|
|
|
|
case BufferParams::VM_PAPER_USLETTER:
|
|
|
|
|
ofs << ",letterpaper";
|
|
|
|
|
break;
|
|
|
|
|
case BufferParams::VM_PAPER_USLEGAL:
|
|
|
|
|
ofs << ",legalpaper";
|
|
|
|
|
break;
|
|
|
|
|
case BufferParams::VM_PAPER_USEXECUTIVE:
|
|
|
|
|
ofs << ",executivepaper";
|
|
|
|
|
break;
|
|
|
|
|
case BufferParams::VM_PAPER_A3:
|
|
|
|
|
ofs << ",a3paper";
|
|
|
|
|
break;
|
|
|
|
|
case BufferParams::VM_PAPER_A4:
|
|
|
|
|
ofs << ",a4paper";
|
|
|
|
|
break;
|
|
|
|
|
case BufferParams::VM_PAPER_A5:
|
|
|
|
|
ofs << ",a5paper";
|
|
|
|
|
break;
|
|
|
|
|
case BufferParams::VM_PAPER_B3:
|
|
|
|
|
ofs << ",b3paper";
|
|
|
|
|
break;
|
|
|
|
|
case BufferParams::VM_PAPER_B4:
|
|
|
|
|
ofs << ",b4paper";
|
|
|
|
|
break;
|
|
|
|
|
case BufferParams::VM_PAPER_B5:
|
|
|
|
|
ofs << ",b5paper";
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
// default papersize ie BufferParams::VM_PAPER_DEFAULT
|
2000-03-12 10:35:05 +00:00
|
|
|
|
switch (lyxrc.default_papersize) {
|
2000-03-06 02:42:40 +00:00
|
|
|
|
case BufferParams::PAPER_DEFAULT: // keep compiler happy
|
|
|
|
|
case BufferParams::PAPER_USLETTER:
|
|
|
|
|
ofs << ",letterpaper";
|
|
|
|
|
break;
|
|
|
|
|
case BufferParams::PAPER_LEGALPAPER:
|
|
|
|
|
ofs << ",legalpaper";
|
|
|
|
|
break;
|
|
|
|
|
case BufferParams::PAPER_EXECUTIVEPAPER:
|
|
|
|
|
ofs << ",executivepaper";
|
|
|
|
|
break;
|
|
|
|
|
case BufferParams::PAPER_A3PAPER:
|
|
|
|
|
ofs << ",a3paper";
|
|
|
|
|
break;
|
|
|
|
|
case BufferParams::PAPER_A4PAPER:
|
|
|
|
|
ofs << ",a4paper";
|
|
|
|
|
break;
|
|
|
|
|
case BufferParams::PAPER_A5PAPER:
|
|
|
|
|
ofs << ",a5paper";
|
|
|
|
|
break;
|
|
|
|
|
case BufferParams::PAPER_B5PAPER:
|
|
|
|
|
ofs << ",b5paper";
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!params.topmargin.empty())
|
|
|
|
|
ofs << ",tmargin=" << params.topmargin;
|
|
|
|
|
if (!params.bottommargin.empty())
|
|
|
|
|
ofs << ",bmargin=" << params.bottommargin;
|
|
|
|
|
if (!params.leftmargin.empty())
|
|
|
|
|
ofs << ",lmargin=" << params.leftmargin;
|
|
|
|
|
if (!params.rightmargin.empty())
|
|
|
|
|
ofs << ",rmargin=" << params.rightmargin;
|
|
|
|
|
if (!params.headheight.empty())
|
|
|
|
|
ofs << ",headheight=" << params.headheight;
|
|
|
|
|
if (!params.headsep.empty())
|
|
|
|
|
ofs << ",headsep=" << params.headsep;
|
|
|
|
|
if (!params.footskip.empty())
|
|
|
|
|
ofs << ",footskip=" << params.footskip;
|
|
|
|
|
ofs << "}\n";
|
|
|
|
|
texrow.newline();
|
|
|
|
|
}
|
|
|
|
|
if (params.use_amsmath
|
2000-05-05 10:17:05 +00:00
|
|
|
|
&& !tclass.provides(LyXTextClass::amsmath)) {
|
2000-03-06 02:42:40 +00:00
|
|
|
|
ofs << "\\usepackage{amsmath}\n";
|
|
|
|
|
texrow.newline();
|
|
|
|
|
}
|
|
|
|
|
|
2000-07-04 19:16:35 +00:00
|
|
|
|
if (tokenPos(tclass.opt_pagestyle(),
|
|
|
|
|
'|', params.pagestyle) >= 0) {
|
2000-03-06 02:42:40 +00:00
|
|
|
|
if (params.pagestyle == "fancy") {
|
|
|
|
|
ofs << "\\usepackage{fancyhdr}\n";
|
|
|
|
|
texrow.newline();
|
|
|
|
|
}
|
|
|
|
|
ofs << "\\pagestyle{" << params.pagestyle << "}\n";
|
|
|
|
|
texrow.newline();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// We try to load babel late, in case it interferes
|
|
|
|
|
// with other packages.
|
2000-03-17 10:14:46 +00:00
|
|
|
|
if (use_babel) {
|
|
|
|
|
ofs << lyxrc.language_package << endl;
|
2000-03-06 02:42:40 +00:00
|
|
|
|
texrow.newline();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (params.secnumdepth != tclass.secnumdepth()) {
|
|
|
|
|
ofs << "\\setcounter{secnumdepth}{"
|
|
|
|
|
<< params.secnumdepth
|
|
|
|
|
<< "}\n";
|
|
|
|
|
texrow.newline();
|
|
|
|
|
}
|
|
|
|
|
if (params.tocdepth != tclass.tocdepth()) {
|
|
|
|
|
ofs << "\\setcounter{tocdepth}{"
|
|
|
|
|
<< params.tocdepth
|
|
|
|
|
<< "}\n";
|
|
|
|
|
texrow.newline();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (params.paragraph_separation) {
|
|
|
|
|
switch (params.defskip.kind()) {
|
|
|
|
|
case VSpace::SMALLSKIP:
|
|
|
|
|
ofs << "\\setlength\\parskip{\\smallskipamount}\n";
|
|
|
|
|
break;
|
|
|
|
|
case VSpace::MEDSKIP:
|
|
|
|
|
ofs << "\\setlength\\parskip{\\medskipamount}\n";
|
|
|
|
|
break;
|
|
|
|
|
case VSpace::BIGSKIP:
|
|
|
|
|
ofs << "\\setlength\\parskip{\\bigskipamount}\n";
|
|
|
|
|
break;
|
|
|
|
|
case VSpace::LENGTH:
|
|
|
|
|
ofs << "\\setlength\\parskip{"
|
|
|
|
|
<< params.defskip.length().asLatexString()
|
|
|
|
|
<< "}\n";
|
|
|
|
|
break;
|
|
|
|
|
default: // should never happen // Then delete it.
|
|
|
|
|
ofs << "\\setlength\\parskip{\\medskipamount}\n";
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
texrow.newline();
|
|
|
|
|
|
|
|
|
|
ofs << "\\setlength\\parindent{0pt}\n";
|
|
|
|
|
texrow.newline();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Now insert the LyX specific LaTeX commands...
|
|
|
|
|
|
|
|
|
|
// The optional packages;
|
2000-07-04 19:16:35 +00:00
|
|
|
|
string preamble(features.getPackages());
|
2000-03-06 02:42:40 +00:00
|
|
|
|
|
|
|
|
|
// this might be useful...
|
2000-07-04 19:16:35 +00:00
|
|
|
|
preamble += "\n\\makeatletter\n";
|
2000-03-06 02:42:40 +00:00
|
|
|
|
|
|
|
|
|
// Some macros LyX will need
|
2000-07-04 19:16:35 +00:00
|
|
|
|
string tmppreamble(features.getMacros());
|
2000-03-06 02:42:40 +00:00
|
|
|
|
|
|
|
|
|
if (!tmppreamble.empty()) {
|
|
|
|
|
preamble += "\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% "
|
|
|
|
|
"LyX specific LaTeX commands.\n"
|
|
|
|
|
+ tmppreamble + '\n';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// the text class specific preamble
|
2000-04-10 21:40:13 +00:00
|
|
|
|
tmppreamble = features.getTClassPreamble();
|
2000-03-06 02:42:40 +00:00
|
|
|
|
if (!tmppreamble.empty()) {
|
|
|
|
|
preamble += "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% "
|
|
|
|
|
"Textclass specific LaTeX commands.\n"
|
|
|
|
|
+ tmppreamble + '\n';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* the user-defined preamble */
|
|
|
|
|
if (!params.preamble.empty()) {
|
|
|
|
|
preamble += "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% "
|
|
|
|
|
"User specified LaTeX commands.\n"
|
|
|
|
|
+ params.preamble + '\n';
|
|
|
|
|
}
|
|
|
|
|
|
2000-07-04 19:16:35 +00:00
|
|
|
|
preamble += "\\makeatother\n";
|
2000-03-06 02:42:40 +00:00
|
|
|
|
|
|
|
|
|
// Itemize bullet settings need to be last in case the user
|
|
|
|
|
// defines their own bullets that use a package included
|
|
|
|
|
// in the user-defined preamble -- ARRae
|
|
|
|
|
// Actually it has to be done much later than that
|
|
|
|
|
// since some packages like frenchb make modifications
|
|
|
|
|
// at \begin{document} time -- JMarc
|
|
|
|
|
string bullets_def;
|
|
|
|
|
for (int i = 0; i < 4; ++i) {
|
|
|
|
|
if (params.user_defined_bullets[i] != ITEMIZE_DEFAULTS[i]) {
|
|
|
|
|
if (bullets_def.empty())
|
|
|
|
|
bullets_def="\\AtBeginDocument{\n";
|
|
|
|
|
bullets_def += " \\renewcommand{\\labelitemi";
|
|
|
|
|
switch (i) {
|
|
|
|
|
// `i' is one less than the item to modify
|
|
|
|
|
case 0:
|
|
|
|
|
break;
|
|
|
|
|
case 1:
|
|
|
|
|
bullets_def += 'i';
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
bullets_def += "ii";
|
|
|
|
|
break;
|
|
|
|
|
case 3:
|
|
|
|
|
bullets_def += 'v';
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
bullets_def += "}{" +
|
|
|
|
|
params.user_defined_bullets[i].getText()
|
|
|
|
|
+ "}\n";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!bullets_def.empty())
|
|
|
|
|
preamble += bullets_def + "}\n\n";
|
|
|
|
|
|
|
|
|
|
for (int j = countChar(preamble, '\n'); j-- ;) {
|
|
|
|
|
texrow.newline();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ofs << preamble;
|
|
|
|
|
|
|
|
|
|
// make the body.
|
2000-07-04 19:16:35 +00:00
|
|
|
|
ofs << "\\begin{document}\n";
|
2000-03-06 02:42:40 +00:00
|
|
|
|
texrow.newline();
|
|
|
|
|
} // only_body
|
|
|
|
|
lyxerr.debug() << "preamble finished, now the body." << endl;
|
2000-10-10 12:36:36 +00:00
|
|
|
|
#ifdef DO_USE_DEFAULT_LANGUAGE
|
|
|
|
|
if (!lyxrc.language_auto_begin && params.language->lang() != "default") {
|
|
|
|
|
#else
|
|
|
|
|
if (!lyxrc.language_auto_begin) {
|
|
|
|
|
#endif
|
2000-03-17 10:14:46 +00:00
|
|
|
|
ofs << subst(lyxrc.language_command_begin, "$$lang",
|
2000-10-10 12:36:36 +00:00
|
|
|
|
params.language->babel())
|
2000-03-17 10:14:46 +00:00
|
|
|
|
<< endl;
|
|
|
|
|
texrow.newline();
|
|
|
|
|
}
|
2000-03-06 02:42:40 +00:00
|
|
|
|
|
2000-05-04 08:14:34 +00:00
|
|
|
|
latexParagraphs(ofs, paragraph, 0, texrow);
|
|
|
|
|
|
|
|
|
|
// add this just in case after all the paragraphs
|
|
|
|
|
ofs << endl;
|
|
|
|
|
texrow.newline();
|
|
|
|
|
|
2000-10-10 12:36:36 +00:00
|
|
|
|
#ifdef DO_USE_DEFAULT_LANGUAGE
|
|
|
|
|
if (!lyxrc.language_auto_end && params.language->lang() != "default") {
|
|
|
|
|
#else
|
|
|
|
|
if (!lyxrc.language_auto_end) {
|
|
|
|
|
#endif
|
2000-05-04 08:14:34 +00:00
|
|
|
|
ofs << subst(lyxrc.language_command_end, "$$lang",
|
2000-10-10 12:36:36 +00:00
|
|
|
|
params.language->babel())
|
2000-05-04 08:14:34 +00:00
|
|
|
|
<< endl;
|
|
|
|
|
texrow.newline();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!only_body) {
|
|
|
|
|
ofs << "\\end{document}\n";
|
|
|
|
|
texrow.newline();
|
|
|
|
|
|
|
|
|
|
lyxerr[Debug::LATEX] << "makeLaTeXFile...done" << endl;
|
|
|
|
|
} else {
|
|
|
|
|
lyxerr[Debug::LATEX] << "LaTeXFile for inclusion made."
|
|
|
|
|
<< endl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Just to be sure. (Asger)
|
|
|
|
|
texrow.newline();
|
|
|
|
|
|
|
|
|
|
// tex_code_break_column's value is used to decide
|
|
|
|
|
// if we are in batchmode or not (within mathed_write()
|
|
|
|
|
// in math_write.C) so we must set it to a non-zero
|
|
|
|
|
// value when we leave otherwise we save incorrect .lyx files.
|
|
|
|
|
tex_code_break_column = lyxrc.ascii_linelen;
|
|
|
|
|
|
|
|
|
|
ofs.close();
|
|
|
|
|
if (ofs.fail()) {
|
|
|
|
|
lyxerr << "File was not closed properly." << endl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
lyxerr.debug() << "Finished making latex file." << endl;
|
|
|
|
|
}
|
|
|
|
|
|
2000-07-04 19:16:35 +00:00
|
|
|
|
|
2000-05-04 08:14:34 +00:00
|
|
|
|
//
|
|
|
|
|
// LaTeX all paragraphs from par to endpar, if endpar == 0 then to the end
|
|
|
|
|
//
|
2000-07-04 19:16:35 +00:00
|
|
|
|
void Buffer::latexParagraphs(ostream & ofs, LyXParagraph * par,
|
|
|
|
|
LyXParagraph * endpar, TexRow & texrow) const
|
2000-05-04 08:14:34 +00:00
|
|
|
|
{
|
2000-03-06 02:42:40 +00:00
|
|
|
|
bool was_title = false;
|
|
|
|
|
bool already_title = false;
|
2000-04-04 00:19:15 +00:00
|
|
|
|
std::ostringstream ftnote;
|
2000-03-06 02:42:40 +00:00
|
|
|
|
TexRow ft_texrow;
|
|
|
|
|
int ftcount = 0;
|
|
|
|
|
|
|
|
|
|
// if only_body
|
2000-05-04 08:14:34 +00:00
|
|
|
|
while (par != endpar) {
|
2000-07-19 17:16:27 +00:00
|
|
|
|
#ifndef NEW_INSETS
|
2000-03-06 02:42:40 +00:00
|
|
|
|
if (par->IsDummy())
|
2000-05-04 08:14:34 +00:00
|
|
|
|
lyxerr[Debug::LATEX] << "Error in latexParagraphs."
|
2000-03-06 02:42:40 +00:00
|
|
|
|
<< endl;
|
2000-07-19 17:16:27 +00:00
|
|
|
|
#endif
|
2000-03-06 02:42:40 +00:00
|
|
|
|
LyXLayout const & layout =
|
|
|
|
|
textclasslist.Style(params.textclass,
|
|
|
|
|
par->layout);
|
|
|
|
|
|
|
|
|
|
if (layout.intitle) {
|
|
|
|
|
if (already_title) {
|
2000-05-04 08:14:34 +00:00
|
|
|
|
lyxerr <<"Error in latexParagraphs: You"
|
2000-03-06 02:42:40 +00:00
|
|
|
|
" should not mix title layouts"
|
|
|
|
|
" with normal ones." << endl;
|
|
|
|
|
} else
|
|
|
|
|
was_title = true;
|
|
|
|
|
} else if (was_title && !already_title) {
|
|
|
|
|
ofs << "\\maketitle\n";
|
|
|
|
|
texrow.newline();
|
|
|
|
|
already_title = true;
|
|
|
|
|
was_title = false;
|
|
|
|
|
}
|
|
|
|
|
// We are at depth 0 so we can just use
|
|
|
|
|
// ordinary \footnote{} generation
|
|
|
|
|
// flag this with ftcount
|
|
|
|
|
ftcount = -1;
|
|
|
|
|
if (layout.isEnvironment()
|
|
|
|
|
|| par->pextra_type != LyXParagraph::PEXTRA_NONE) {
|
2000-07-24 21:49:58 +00:00
|
|
|
|
par = par->TeXEnvironment(this, params, ofs, texrow
|
|
|
|
|
#ifndef NEW_INSETS
|
|
|
|
|
,ftnote, ft_texrow, ftcount
|
|
|
|
|
#endif
|
|
|
|
|
);
|
2000-03-06 02:42:40 +00:00
|
|
|
|
} else {
|
2000-07-19 17:16:27 +00:00
|
|
|
|
par = par->TeXOnePar(this, params, ofs, texrow, false
|
|
|
|
|
#ifndef NEW_INSETS
|
|
|
|
|
,
|
|
|
|
|
ftnote, ft_texrow, ftcount
|
|
|
|
|
#endif
|
|
|
|
|
);
|
2000-03-06 02:42:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Write out what we've generated...
|
|
|
|
|
if (ftcount >= 1) {
|
|
|
|
|
if (ftcount > 1) {
|
|
|
|
|
ofs << "\\addtocounter{footnote}{-"
|
|
|
|
|
<< ftcount - 1
|
|
|
|
|
<< '}';
|
|
|
|
|
}
|
|
|
|
|
ofs << ftnote.str();
|
|
|
|
|
texrow += ft_texrow;
|
2000-09-18 17:39:21 +00:00
|
|
|
|
|
2000-03-06 16:05:12 +00:00
|
|
|
|
// The extra .c_str() is needed when we use
|
|
|
|
|
// lyxstring instead of the STL string class.
|
|
|
|
|
ftnote.str(string().c_str());
|
2000-03-06 02:42:40 +00:00
|
|
|
|
ft_texrow.reset();
|
|
|
|
|
ftcount = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// It might be that we only have a title in this document
|
|
|
|
|
if (was_title && !already_title) {
|
|
|
|
|
ofs << "\\maketitle\n";
|
|
|
|
|
texrow.newline();
|
|
|
|
|
}
|
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2000-07-04 19:16:35 +00:00
|
|
|
|
|
1999-11-15 12:01:38 +00:00
|
|
|
|
bool Buffer::isLatex() const
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
1999-11-04 01:40:20 +00:00
|
|
|
|
return textclasslist.TextClass(params.textclass).outputType() == LATEX;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
1999-11-15 12:01:38 +00:00
|
|
|
|
bool Buffer::isLinuxDoc() const
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
1999-11-04 01:40:20 +00:00
|
|
|
|
return textclasslist.TextClass(params.textclass).outputType() == LINUXDOC;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
1999-11-15 12:01:38 +00:00
|
|
|
|
bool Buffer::isLiterate() const
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
1999-11-04 01:40:20 +00:00
|
|
|
|
return textclasslist.TextClass(params.textclass).outputType() == LITERATE;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
1999-11-15 12:01:38 +00:00
|
|
|
|
bool Buffer::isDocBook() const
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
1999-11-04 01:40:20 +00:00
|
|
|
|
return textclasslist.TextClass(params.textclass).outputType() == DOCBOOK;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
1999-11-15 12:01:38 +00:00
|
|
|
|
bool Buffer::isSGML() const
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
1999-11-04 01:40:20 +00:00
|
|
|
|
return textclasslist.TextClass(params.textclass).outputType() == LINUXDOC ||
|
|
|
|
|
textclasslist.TextClass(params.textclass).outputType() == DOCBOOK;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
1999-12-07 00:44:53 +00:00
|
|
|
|
void Buffer::sgmlOpenTag(ostream & os, int depth,
|
|
|
|
|
string const & latexname) const
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
2000-11-13 15:43:36 +00:00
|
|
|
|
if (latexname != "!-- --")
|
|
|
|
|
os << string(depth, ' ') << "<" << latexname << ">\n";
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
1999-12-07 00:44:53 +00:00
|
|
|
|
void Buffer::sgmlCloseTag(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-11-13 15:43:36 +00:00
|
|
|
|
if (latexname != "!-- --")
|
|
|
|
|
os << string(depth, ' ') << "</" << latexname << ">\n";
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2000-07-01 12:54:45 +00:00
|
|
|
|
void Buffer::makeLinuxDocFile(string const & fname, bool nice, bool body_only)
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
1999-11-04 01:40:20 +00:00
|
|
|
|
LyXParagraph * par = paragraph;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2000-07-01 12:54:45 +00:00
|
|
|
|
niceFile = nice; // this will be used by Insetincludes.
|
|
|
|
|
|
1999-11-15 12:01:38 +00:00
|
|
|
|
string top_element = textclasslist.LatexnameOfClass(params.textclass);
|
1999-10-02 16:21:10 +00:00
|
|
|
|
string environment_stack[10];
|
|
|
|
|
string item_name;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2000-04-26 13:57:28 +00:00
|
|
|
|
int depth = 0; // paragraph depth
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
1999-12-21 06:10:21 +00:00
|
|
|
|
ofstream ofs(fname.c_str());
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
1999-12-07 00:44:53 +00:00
|
|
|
|
if (!ofs) {
|
1999-12-21 06:10:21 +00:00
|
|
|
|
WriteAlert(_("LYX_ERROR:"), _("Cannot write file"), fname);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
2000-07-01 12:54:45 +00:00
|
|
|
|
|
|
|
|
|
LyXTextClass const & tclass =
|
|
|
|
|
textclasslist.TextClass(params.textclass);
|
|
|
|
|
|
|
|
|
|
LaTeXFeatures features(params, tclass.numLayouts());
|
|
|
|
|
validate(features);
|
|
|
|
|
|
2000-11-04 10:00:12 +00:00
|
|
|
|
//if (nice)
|
2000-07-04 19:16:35 +00:00
|
|
|
|
tex_code_break_column = lyxrc.ascii_linelen;
|
|
|
|
|
//else
|
|
|
|
|
//tex_code_break_column = 0;
|
2000-07-01 12:54:45 +00:00
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
texrow.reset();
|
2000-07-01 12:54:45 +00:00
|
|
|
|
|
|
|
|
|
if (!body_only) {
|
2000-11-13 15:43:36 +00:00
|
|
|
|
string sgml_includedfiles=features.getIncludedFiles(fname);
|
2000-07-01 12:54:45 +00:00
|
|
|
|
|
|
|
|
|
if (params.preamble.empty() && sgml_includedfiles.empty()) {
|
|
|
|
|
ofs << "<!doctype linuxdoc system>\n\n";
|
2000-07-04 19:16:35 +00:00
|
|
|
|
} else {
|
2000-07-01 12:54:45 +00:00
|
|
|
|
ofs << "<!doctype linuxdoc system [ "
|
|
|
|
|
<< params.preamble << sgml_includedfiles << " \n]>\n\n";
|
|
|
|
|
}
|
|
|
|
|
|
2000-11-04 10:00:12 +00:00
|
|
|
|
if (params.options.empty())
|
2000-07-01 12:54:45 +00:00
|
|
|
|
sgmlOpenTag(ofs, 0, top_element);
|
|
|
|
|
else {
|
|
|
|
|
string top = top_element;
|
|
|
|
|
top += " ";
|
|
|
|
|
top += params.options;
|
|
|
|
|
sgmlOpenTag(ofs, 0, top);
|
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-01-19 14:07:39 +00:00
|
|
|
|
ofs << "<!-- " << LYX_DOCVERSION
|
|
|
|
|
<< " created this file. For more info see http://www.lyx.org/"
|
|
|
|
|
<< " -->\n";
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
while (par) {
|
2000-04-26 13:57:28 +00:00
|
|
|
|
int desc_on = 0; // description mode
|
1999-11-15 12:01:38 +00:00
|
|
|
|
LyXLayout const & style =
|
2000-07-01 12:54:45 +00:00
|
|
|
|
textclasslist.Style(params.textclass,
|
1999-11-15 12:01:38 +00:00
|
|
|
|
par->layout);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2000-04-26 13:57:28 +00:00
|
|
|
|
// treat <toc> as a special case for compatibility with old code
|
1999-11-15 12:01:38 +00:00
|
|
|
|
if (par->GetChar(0) == LyXParagraph::META_INSET) {
|
1999-12-07 00:44:53 +00:00
|
|
|
|
Inset * inset = par->GetInset(0);
|
2000-05-18 13:26:04 +00:00
|
|
|
|
Inset::Code lyx_code = inset->LyxCode();
|
1999-11-15 12:01:38 +00:00
|
|
|
|
if (lyx_code == Inset::TOC_CODE){
|
2000-09-26 13:54:57 +00:00
|
|
|
|
string const temp = "toc";
|
1999-12-07 00:44:53 +00:00
|
|
|
|
sgmlOpenTag(ofs, depth, temp);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
par = par->next;
|
2000-07-19 17:16:27 +00:00
|
|
|
|
#ifndef NEW_INSETS
|
1999-12-07 00:44:53 +00:00
|
|
|
|
linuxDocHandleFootnote(ofs, par, depth);
|
2000-07-19 17:16:27 +00:00
|
|
|
|
#endif
|
1999-09-27 18:44:28 +00:00
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2000-01-08 21:02:58 +00:00
|
|
|
|
// environment tag closing
|
2000-09-26 13:54:57 +00:00
|
|
|
|
for (; depth > par->depth; --depth) {
|
1999-12-07 00:44:53 +00:00
|
|
|
|
sgmlCloseTag(ofs, depth, environment_stack[depth]);
|
2000-05-04 10:57:00 +00:00
|
|
|
|
environment_stack[depth].erase();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-01-08 21:02:58 +00:00
|
|
|
|
// write opening SGML tags
|
2000-09-26 13:54:57 +00:00
|
|
|
|
switch (style.latextype) {
|
1999-09-27 18:44:28 +00:00
|
|
|
|
case LATEX_PARAGRAPH:
|
2000-11-04 10:00:12 +00:00
|
|
|
|
if (depth == par->depth
|
1999-09-27 18:44:28 +00:00
|
|
|
|
&& !environment_stack[depth].empty()) {
|
1999-12-07 00:44:53 +00:00
|
|
|
|
sgmlCloseTag(ofs, depth, environment_stack[depth]);
|
2000-05-04 10:57:00 +00:00
|
|
|
|
environment_stack[depth].erase();
|
2000-11-04 10:00:12 +00:00
|
|
|
|
if (depth)
|
1999-12-07 00:44:53 +00:00
|
|
|
|
--depth;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
else
|
1999-12-07 00:44:53 +00:00
|
|
|
|
ofs << "</p>";
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
1999-12-07 00:44:53 +00:00
|
|
|
|
sgmlOpenTag(ofs, depth, style.latexname());
|
1999-09-27 18:44:28 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case LATEX_COMMAND:
|
1999-11-15 12:01:38 +00:00
|
|
|
|
if (depth!= 0)
|
2000-04-26 13:57:28 +00:00
|
|
|
|
LinuxDocError(par, 0,
|
|
|
|
|
_("Error : Wrong depth for"
|
|
|
|
|
" LatexType Command.\n"));
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
if (!environment_stack[depth].empty()){
|
1999-12-07 00:44:53 +00:00
|
|
|
|
sgmlCloseTag(ofs, depth,
|
|
|
|
|
environment_stack[depth]);
|
|
|
|
|
ofs << "</p>";
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-05-04 10:57:00 +00:00
|
|
|
|
environment_stack[depth].erase();
|
1999-12-07 00:44:53 +00:00
|
|
|
|
sgmlOpenTag(ofs, depth, style.latexname());
|
1999-09-27 18:44:28 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case LATEX_ENVIRONMENT:
|
|
|
|
|
case LATEX_ITEM_ENVIRONMENT:
|
2000-09-26 13:54:57 +00:00
|
|
|
|
if (depth == par->depth
|
1999-11-04 01:40:20 +00:00
|
|
|
|
&& environment_stack[depth] != style.latexname()
|
1999-09-27 18:44:28 +00:00
|
|
|
|
&& !environment_stack[depth].empty()) {
|
|
|
|
|
|
1999-12-07 00:44:53 +00:00
|
|
|
|
sgmlCloseTag(ofs, depth,
|
1999-11-15 12:01:38 +00:00
|
|
|
|
environment_stack[depth]);
|
2000-05-04 10:57:00 +00:00
|
|
|
|
environment_stack[depth].erase();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
if (depth < par->depth) {
|
|
|
|
|
depth = par->depth;
|
2000-05-04 10:57:00 +00:00
|
|
|
|
environment_stack[depth].erase();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
1999-11-04 01:40:20 +00:00
|
|
|
|
if (environment_stack[depth] != style.latexname()) {
|
2000-11-04 10:00:12 +00:00
|
|
|
|
if (depth == 0) {
|
2000-09-26 13:54:57 +00:00
|
|
|
|
string const temp = "p";
|
1999-12-07 00:44:53 +00:00
|
|
|
|
sgmlOpenTag(ofs, depth, temp);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
1999-11-04 01:40:20 +00:00
|
|
|
|
environment_stack[depth] = style.latexname();
|
2000-04-26 13:57:28 +00:00
|
|
|
|
sgmlOpenTag(ofs, depth,
|
|
|
|
|
environment_stack[depth]);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
2000-11-04 10:00:12 +00:00
|
|
|
|
if (style.latextype == LATEX_ENVIRONMENT) break;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
1999-11-15 12:01:38 +00:00
|
|
|
|
desc_on = (style.labeltype == LABEL_MANUAL);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2000-11-04 10:00:12 +00:00
|
|
|
|
if (desc_on)
|
1999-11-15 12:01:38 +00:00
|
|
|
|
item_name = "tag";
|
1999-09-27 18:44:28 +00:00
|
|
|
|
else
|
1999-11-15 12:01:38 +00:00
|
|
|
|
item_name = "item";
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
1999-12-07 00:44:53 +00:00
|
|
|
|
sgmlOpenTag(ofs, depth + 1, item_name);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
break;
|
|
|
|
|
default:
|
1999-12-07 00:44:53 +00:00
|
|
|
|
sgmlOpenTag(ofs, depth, style.latexname());
|
1999-09-27 18:44:28 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2000-07-19 17:16:27 +00:00
|
|
|
|
#ifndef NEW_INSETS
|
1999-09-27 18:44:28 +00:00
|
|
|
|
do {
|
2000-07-19 17:16:27 +00:00
|
|
|
|
#endif
|
1999-12-07 00:44:53 +00:00
|
|
|
|
SimpleLinuxDocOnePar(ofs, par, desc_on, depth);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
par = par->next;
|
2000-07-19 17:16:27 +00:00
|
|
|
|
#ifndef NEW_INSETS
|
1999-12-07 00:44:53 +00:00
|
|
|
|
linuxDocHandleFootnote(ofs, par, depth);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
while(par && par->IsDummy());
|
2000-07-19 17:16:27 +00:00
|
|
|
|
#endif
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
1999-12-07 00:44:53 +00:00
|
|
|
|
ofs << "\n";
|
2000-04-26 13:57:28 +00:00
|
|
|
|
// write closing SGML tags
|
2000-11-04 10:00:12 +00:00
|
|
|
|
switch (style.latextype) {
|
1999-09-27 18:44:28 +00:00
|
|
|
|
case LATEX_COMMAND:
|
|
|
|
|
case LATEX_ENVIRONMENT:
|
|
|
|
|
case LATEX_ITEM_ENVIRONMENT:
|
|
|
|
|
break;
|
|
|
|
|
default:
|
1999-12-07 00:44:53 +00:00
|
|
|
|
sgmlCloseTag(ofs, depth, style.latexname());
|
1999-09-27 18:44:28 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2000-04-26 13:57:28 +00:00
|
|
|
|
// Close open tags
|
2000-11-04 10:00:12 +00:00
|
|
|
|
for (; depth > 0; --depth)
|
1999-12-07 00:44:53 +00:00
|
|
|
|
sgmlCloseTag(ofs, depth, environment_stack[depth]);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2000-11-04 10:00:12 +00:00
|
|
|
|
if (!environment_stack[depth].empty())
|
1999-12-07 00:44:53 +00:00
|
|
|
|
sgmlCloseTag(ofs, depth, environment_stack[depth]);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2000-07-01 12:54:45 +00:00
|
|
|
|
if (!body_only) {
|
|
|
|
|
ofs << "\n\n";
|
|
|
|
|
sgmlCloseTag(ofs, 0, top_element);
|
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
1999-12-07 00:44:53 +00:00
|
|
|
|
ofs.close();
|
|
|
|
|
// How to check for successful close
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2000-07-19 17:16:27 +00:00
|
|
|
|
#ifndef NEW_INSETS
|
1999-12-07 00:44:53 +00:00
|
|
|
|
void Buffer::linuxDocHandleFootnote(ostream & os, LyXParagraph * & par,
|
2000-10-02 14:35:11 +00:00
|
|
|
|
int depth)
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
2000-09-26 13:54:57 +00:00
|
|
|
|
string const tag = "footnote";
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
while (par && par->footnoteflag != LyXParagraph::NO_FOOTNOTE) {
|
1999-12-07 00:44:53 +00:00
|
|
|
|
sgmlOpenTag(os, depth + 1, tag);
|
|
|
|
|
SimpleLinuxDocOnePar(os, par, 0, depth + 1);
|
|
|
|
|
sgmlCloseTag(os, depth + 1, tag);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
par = par->next;
|
|
|
|
|
}
|
|
|
|
|
}
|
2000-07-19 17:16:27 +00:00
|
|
|
|
#endif
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
1999-12-07 00:44:53 +00:00
|
|
|
|
|
|
|
|
|
void Buffer::DocBookHandleCaption(ostream & os, string & inner_tag,
|
2000-10-02 14:35:11 +00:00
|
|
|
|
int depth, int desc_on,
|
1999-11-15 12:01:38 +00:00
|
|
|
|
LyXParagraph * & par)
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
1999-11-15 12:01:38 +00:00
|
|
|
|
LyXParagraph * tpar = par;
|
2000-07-19 17:16:27 +00:00
|
|
|
|
while (tpar
|
|
|
|
|
#ifndef NEW_INSETS
|
|
|
|
|
&& (tpar->footnoteflag != LyXParagraph::NO_FOOTNOTE)
|
|
|
|
|
#endif
|
|
|
|
|
&& (tpar->layout != textclasslist.NumberOfLayout(params.textclass,
|
1999-12-07 00:44:53 +00:00
|
|
|
|
"Caption").second))
|
1999-09-27 18:44:28 +00:00
|
|
|
|
tpar = tpar->next;
|
|
|
|
|
if (tpar &&
|
1999-11-15 12:01:38 +00:00
|
|
|
|
tpar->layout == textclasslist.NumberOfLayout(params.textclass,
|
|
|
|
|
"Caption").second) {
|
1999-12-07 00:44:53 +00:00
|
|
|
|
sgmlOpenTag(os, depth + 1, inner_tag);
|
2000-03-06 02:42:40 +00:00
|
|
|
|
string extra_par;
|
|
|
|
|
SimpleDocBookOnePar(os, extra_par, tpar,
|
|
|
|
|
desc_on, depth + 2);
|
2000-03-09 03:36:48 +00:00
|
|
|
|
sgmlCloseTag(os, depth+1, inner_tag);
|
2000-11-04 10:00:12 +00:00
|
|
|
|
if (!extra_par.empty())
|
2000-03-09 03:36:48 +00:00
|
|
|
|
os << extra_par;
|
1999-12-07 00:44:53 +00:00
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-12-07 00:44:53 +00:00
|
|
|
|
|
2000-07-19 17:16:27 +00:00
|
|
|
|
#ifndef NEW_INSETS
|
1999-12-07 00:44:53 +00:00
|
|
|
|
void Buffer::DocBookHandleFootnote(ostream & os, LyXParagraph * & par,
|
2000-10-02 14:35:11 +00:00
|
|
|
|
int depth)
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
1999-11-15 12:01:38 +00:00
|
|
|
|
string tag, inner_tag;
|
|
|
|
|
string tmp_par, extra_par;
|
1999-10-02 16:21:10 +00:00
|
|
|
|
bool inner_span = false;
|
1999-11-15 12:01:38 +00:00
|
|
|
|
int desc_on = 4;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2000-03-09 03:36:48 +00:00
|
|
|
|
// Someone should give this enum a proper name (Lgb)
|
2000-03-06 02:42:40 +00:00
|
|
|
|
enum SOME_ENUM {
|
1999-09-27 18:44:28 +00:00
|
|
|
|
NO_ONE,
|
|
|
|
|
FOOTNOTE_LIKE,
|
|
|
|
|
MARGIN_LIKE,
|
|
|
|
|
FIG_LIKE,
|
|
|
|
|
TAB_LIKE
|
2000-03-06 02:42:40 +00:00
|
|
|
|
};
|
|
|
|
|
SOME_ENUM last = NO_ONE;
|
|
|
|
|
SOME_ENUM present = FOOTNOTE_LIKE;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
while (par && par->footnoteflag != LyXParagraph::NO_FOOTNOTE) {
|
2000-09-26 13:54:57 +00:00
|
|
|
|
if (last == present) {
|
|
|
|
|
if (inner_span) {
|
|
|
|
|
if (!tmp_par.empty()) {
|
1999-12-07 00:44:53 +00:00
|
|
|
|
os << tmp_par;
|
2000-05-04 10:57:00 +00:00
|
|
|
|
tmp_par.erase();
|
2000-03-09 03:36:48 +00:00
|
|
|
|
sgmlCloseTag(os, depth + 1, inner_tag);
|
|
|
|
|
sgmlOpenTag(os, depth + 1, inner_tag);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
2000-04-26 13:57:28 +00:00
|
|
|
|
} else {
|
1999-12-07 00:44:53 +00:00
|
|
|
|
os << "\n";
|
2000-04-26 13:57:28 +00:00
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
} else {
|
1999-12-07 00:44:53 +00:00
|
|
|
|
os << tmp_par;
|
2000-09-26 13:54:57 +00:00
|
|
|
|
if (!inner_tag.empty()) sgmlCloseTag(os, depth + 1,
|
2000-03-06 02:42:40 +00:00
|
|
|
|
inner_tag);
|
2000-09-26 13:54:57 +00:00
|
|
|
|
if (!extra_par.empty()) os << extra_par;
|
|
|
|
|
if (!tag.empty()) sgmlCloseTag(os, depth, tag);
|
2000-05-04 10:57:00 +00:00
|
|
|
|
extra_par.erase();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
switch (par->footnotekind) {
|
|
|
|
|
case LyXParagraph::FOOTNOTE:
|
|
|
|
|
case LyXParagraph::ALGORITHM:
|
1999-11-15 12:01:38 +00:00
|
|
|
|
tag = "footnote";
|
|
|
|
|
inner_tag = "para";
|
|
|
|
|
present = FOOTNOTE_LIKE;
|
|
|
|
|
inner_span = true;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
break;
|
|
|
|
|
case LyXParagraph::MARGIN:
|
1999-11-15 12:01:38 +00:00
|
|
|
|
tag = "sidebar";
|
|
|
|
|
inner_tag = "para";
|
|
|
|
|
present = MARGIN_LIKE;
|
|
|
|
|
inner_span = true;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
break;
|
|
|
|
|
case LyXParagraph::FIG:
|
|
|
|
|
case LyXParagraph::WIDE_FIG:
|
1999-11-15 12:01:38 +00:00
|
|
|
|
tag = "figure";
|
|
|
|
|
inner_tag = "title";
|
|
|
|
|
present = FIG_LIKE;
|
|
|
|
|
inner_span = false;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
break;
|
|
|
|
|
case LyXParagraph::TAB:
|
|
|
|
|
case LyXParagraph::WIDE_TAB:
|
1999-11-15 12:01:38 +00:00
|
|
|
|
tag = "table";
|
|
|
|
|
inner_tag = "title";
|
|
|
|
|
present = TAB_LIKE;
|
|
|
|
|
inner_span = false;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
1999-12-07 00:44:53 +00:00
|
|
|
|
sgmlOpenTag(os, depth, tag);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
if ((present == TAB_LIKE) || (present == FIG_LIKE)) {
|
1999-12-07 00:44:53 +00:00
|
|
|
|
DocBookHandleCaption(os, inner_tag, depth,
|
1999-09-27 18:44:28 +00:00
|
|
|
|
desc_on, par);
|
2000-05-04 10:57:00 +00:00
|
|
|
|
inner_tag.erase();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
} else {
|
1999-12-07 00:44:53 +00:00
|
|
|
|
sgmlOpenTag(os, depth + 1, inner_tag);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// ignore all caption here, we processed them above!!!
|
2000-03-09 03:36:48 +00:00
|
|
|
|
if (par->layout != textclasslist
|
|
|
|
|
.NumberOfLayout(params.textclass,
|
|
|
|
|
"Caption").second) {
|
2000-04-04 00:19:15 +00:00
|
|
|
|
std::ostringstream ost;
|
2000-03-06 02:42:40 +00:00
|
|
|
|
SimpleDocBookOnePar(ost, extra_par, par,
|
1999-12-07 00:44:53 +00:00
|
|
|
|
desc_on, depth + 2);
|
2000-03-06 02:42:40 +00:00
|
|
|
|
tmp_par += ost.str().c_str();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
1999-10-02 16:21:10 +00:00
|
|
|
|
tmp_par = frontStrip(strip(tmp_par));
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
1999-11-15 12:01:38 +00:00
|
|
|
|
last = present;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
par = par->next;
|
|
|
|
|
}
|
1999-12-07 00:44:53 +00:00
|
|
|
|
os << tmp_par;
|
2000-11-04 10:00:12 +00:00
|
|
|
|
if (!inner_tag.empty()) sgmlCloseTag(os, depth + 1, inner_tag);
|
|
|
|
|
if (!extra_par.empty()) os << extra_par;
|
|
|
|
|
if (!tag.empty()) sgmlCloseTag(os, depth, tag);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
2000-07-19 17:16:27 +00:00
|
|
|
|
#endif
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
|
2000-04-26 13:57:28 +00:00
|
|
|
|
// push a tag in a style stack
|
2000-09-14 17:53:12 +00:00
|
|
|
|
void Buffer::push_tag(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
|
|
|
|
{
|
2000-10-11 21:06:43 +00:00
|
|
|
|
#ifdef WITH_WARNINGS
|
2000-09-14 17:53:12 +00:00
|
|
|
|
#warning Use a real stack! (Lgb)
|
2000-10-11 21:06:43 +00:00
|
|
|
|
#endif
|
2000-04-26 13:57:28 +00:00
|
|
|
|
// pop all previous tags
|
2000-01-06 02:44:26 +00:00
|
|
|
|
for (int j = pos; j >= 0; --j)
|
1999-12-07 00:44:53 +00:00
|
|
|
|
os << "</" << stack[j] << ">";
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2000-04-26 13:57:28 +00:00
|
|
|
|
// add new tag
|
2000-09-14 17:53:12 +00:00
|
|
|
|
sprintf(stack[++pos], "%s", tag.c_str());
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2000-04-26 13:57:28 +00:00
|
|
|
|
// push all tags
|
2000-01-06 02:44:26 +00:00
|
|
|
|
for (int i = 0; i <= pos; ++i)
|
|
|
|
|
os << "<" << stack[i] << ">";
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-03-28 02:18:55 +00:00
|
|
|
|
|
2000-09-14 17:53:12 +00:00
|
|
|
|
void Buffer::pop_tag(ostream & os, string const & tag,
|
2000-02-10 17:06:12 +00:00
|
|
|
|
int & pos, char stack[5][3])
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
2000-09-15 10:24:15 +00:00
|
|
|
|
#ifdef WITH_WARNINGS
|
2000-09-14 17:53:12 +00:00
|
|
|
|
#warning Use a real stack! (Lgb)
|
2000-09-15 10:24:15 +00:00
|
|
|
|
#endif
|
|
|
|
|
// Please, Lars, do not remove the global variable. I already
|
2000-11-21 15:46:13 +00:00
|
|
|
|
// had to reintroduce it twice! (JMarc)
|
|
|
|
|
// but...but... I'll remove it anyway. (well not quite) (Lgb)
|
|
|
|
|
#if 0
|
2000-09-15 10:24:15 +00:00
|
|
|
|
int j;
|
|
|
|
|
|
2000-02-10 17:06:12 +00:00
|
|
|
|
// pop all tags till specified one
|
2000-09-15 10:24:15 +00:00
|
|
|
|
for (j = pos; (j >= 0) && (strcmp(stack[j], tag.c_str())); --j)
|
2000-02-10 17:06:12 +00:00
|
|
|
|
os << "</" << stack[j] << ">";
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2000-02-10 17:06:12 +00:00
|
|
|
|
// closes the tag
|
|
|
|
|
os << "</" << tag << ">";
|
2000-09-15 10:24:15 +00:00
|
|
|
|
|
2000-02-10 17:06:12 +00:00
|
|
|
|
// push all tags, but the specified one
|
2000-09-15 10:24:15 +00:00
|
|
|
|
for (j = j + 1; j <= pos; ++j) {
|
2000-02-10 17:06:12 +00:00
|
|
|
|
os << "<" << stack[j] << ">";
|
2000-11-21 15:46:13 +00:00
|
|
|
|
strcpy(stack[j - 1], stack[j]);
|
2000-02-10 17:06:12 +00:00
|
|
|
|
}
|
|
|
|
|
--pos;
|
2000-11-21 15:46:13 +00:00
|
|
|
|
#else
|
|
|
|
|
// pop all tags till specified one
|
|
|
|
|
int j = pos;
|
|
|
|
|
for (int j = pos; (j >= 0) && (strcmp(stack[j], tag.c_str())); --j)
|
|
|
|
|
os << "</" << stack[j] << ">";
|
|
|
|
|
|
|
|
|
|
// closes the tag
|
|
|
|
|
os << "</" << tag << ">";
|
|
|
|
|
|
|
|
|
|
// push all tags, but the specified one
|
|
|
|
|
for (int i = j + 1; i <= pos; ++i) {
|
|
|
|
|
os << "<" << stack[i] << ">";
|
|
|
|
|
strcpy(stack[i - 1], stack[i]);
|
|
|
|
|
}
|
|
|
|
|
--pos;
|
|
|
|
|
#endif
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2000-04-26 13:57:28 +00:00
|
|
|
|
// Handle internal paragraph parsing -- layout already processed.
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
// checks, if newcol chars should be put into this line
|
|
|
|
|
// writes newline, if necessary.
|
|
|
|
|
static
|
2000-09-27 17:07:33 +00:00
|
|
|
|
void linux_doc_line_break(ostream & os, string::size_type & colcount,
|
|
|
|
|
string::size_type newcol)
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
|
|
|
|
colcount += newcol;
|
2000-03-12 10:35:05 +00:00
|
|
|
|
if (colcount > lyxrc.ascii_linelen) {
|
1999-12-07 00:44:53 +00:00
|
|
|
|
os << "\n";
|
1999-09-27 18:44:28 +00:00
|
|
|
|
colcount = newcol; // assume write after this call
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
1999-12-07 00:44:53 +00:00
|
|
|
|
void Buffer::SimpleLinuxDocOnePar(ostream & os, LyXParagraph * par,
|
2000-10-02 14:35:11 +00:00
|
|
|
|
int desc_on, int /*depth*/)
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
2000-09-26 13:54:57 +00:00
|
|
|
|
LyXFont font1;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
char c;
|
1999-11-04 01:40:20 +00:00
|
|
|
|
Inset * inset;
|
|
|
|
|
LyXParagraph::size_type main_body;
|
|
|
|
|
int j;
|
1999-11-15 12:01:38 +00:00
|
|
|
|
LyXLayout const & style = textclasslist.Style(params.textclass,
|
|
|
|
|
par->GetLayout());
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
char family_type = 0; // family font flag
|
|
|
|
|
bool is_bold = false; // series font flag
|
|
|
|
|
char shape_type = 0; // shape font flag
|
|
|
|
|
bool is_em = false; // emphasis (italic) font flag
|
|
|
|
|
|
2000-04-26 13:57:28 +00:00
|
|
|
|
int stack_num = -1; // style stack position
|
|
|
|
|
// Can this be rewritten to use a std::stack, please. (Lgb)
|
1999-09-27 18:44:28 +00:00
|
|
|
|
char stack[5][3]; // style stack
|
2000-09-27 17:07:33 +00:00
|
|
|
|
string::size_type char_line_count = 5; // Heuristic choice ;-)
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
1999-11-04 01:40:20 +00:00
|
|
|
|
if (style.labeltype != LABEL_MANUAL)
|
1999-09-27 18:44:28 +00:00
|
|
|
|
main_body = 0;
|
|
|
|
|
else
|
|
|
|
|
main_body = par->BeginningOfMainBody();
|
|
|
|
|
|
2000-04-26 13:57:28 +00:00
|
|
|
|
// gets paragraph main font
|
1999-09-27 18:44:28 +00:00
|
|
|
|
if (main_body > 0)
|
1999-11-04 01:40:20 +00:00
|
|
|
|
font1 = style.labelfont;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
else
|
1999-11-04 01:40:20 +00:00
|
|
|
|
font1 = style.font;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
|
2000-04-26 13:57:28 +00:00
|
|
|
|
// parsing main loop
|
1999-11-04 01:40:20 +00:00
|
|
|
|
for (LyXParagraph::size_type i = 0;
|
|
|
|
|
i < par->size(); ++i) {
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2000-04-26 13:57:28 +00:00
|
|
|
|
// handle quote tag
|
2000-07-19 17:16:27 +00:00
|
|
|
|
if (i == main_body
|
|
|
|
|
#ifndef NEW_INSETS
|
|
|
|
|
&& !par->IsDummy()
|
|
|
|
|
#endif
|
|
|
|
|
) {
|
1999-09-27 18:44:28 +00:00
|
|
|
|
if (main_body > 0)
|
1999-11-04 01:40:20 +00:00
|
|
|
|
font1 = style.font;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-09-26 13:54:57 +00:00
|
|
|
|
LyXFont const font2 = par->getFont(params, i);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
if (font1.family() != font2.family()) {
|
2000-11-04 10:00:12 +00:00
|
|
|
|
switch (family_type) {
|
1999-09-27 18:44:28 +00:00
|
|
|
|
case 0:
|
|
|
|
|
if (font2.family() == LyXFont::TYPEWRITER_FAMILY) {
|
1999-12-07 00:44:53 +00:00
|
|
|
|
push_tag(os, "tt", stack_num, stack);
|
2000-07-04 19:16:35 +00:00
|
|
|
|
family_type = 1;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
else if (font2.family() == LyXFont::SANS_FAMILY) {
|
1999-12-07 00:44:53 +00:00
|
|
|
|
push_tag(os, "sf", stack_num, stack);
|
2000-07-04 19:16:35 +00:00
|
|
|
|
family_type = 2;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 1:
|
1999-12-07 00:44:53 +00:00
|
|
|
|
pop_tag(os, "tt", stack_num, stack);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
if (font2.family() == LyXFont::SANS_FAMILY) {
|
1999-12-07 00:44:53 +00:00
|
|
|
|
push_tag(os, "sf", stack_num, stack);
|
2000-07-04 19:16:35 +00:00
|
|
|
|
family_type = 2;
|
|
|
|
|
} else {
|
|
|
|
|
family_type = 0;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
1999-12-07 00:44:53 +00:00
|
|
|
|
pop_tag(os, "sf", stack_num, stack);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
if (font2.family() == LyXFont::TYPEWRITER_FAMILY) {
|
1999-12-07 00:44:53 +00:00
|
|
|
|
push_tag(os, "tt", stack_num, stack);
|
2000-07-04 19:16:35 +00:00
|
|
|
|
family_type = 1;
|
|
|
|
|
} else {
|
|
|
|
|
family_type = 0;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2000-04-26 13:57:28 +00:00
|
|
|
|
// handle bold face
|
1999-09-27 18:44:28 +00:00
|
|
|
|
if (font1.series() != font2.series()) {
|
|
|
|
|
if (font2.series() == LyXFont::BOLD_SERIES) {
|
1999-12-07 00:44:53 +00:00
|
|
|
|
push_tag(os, "bf", stack_num, stack);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
is_bold = true;
|
2000-07-04 19:16:35 +00:00
|
|
|
|
} else if (is_bold) {
|
1999-12-07 00:44:53 +00:00
|
|
|
|
pop_tag(os, "bf", stack_num, stack);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
is_bold = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2000-04-26 13:57:28 +00:00
|
|
|
|
// handle italic and slanted fonts
|
1999-09-27 18:44:28 +00:00
|
|
|
|
if (font1.shape() != font2.shape()) {
|
2000-11-04 10:00:12 +00:00
|
|
|
|
switch (shape_type) {
|
1999-09-27 18:44:28 +00:00
|
|
|
|
case 0:
|
|
|
|
|
if (font2.shape() == LyXFont::ITALIC_SHAPE) {
|
1999-12-07 00:44:53 +00:00
|
|
|
|
push_tag(os, "it", stack_num, stack);
|
2000-07-04 19:16:35 +00:00
|
|
|
|
shape_type = 1;
|
|
|
|
|
} else if (font2.shape() == LyXFont::SLANTED_SHAPE) {
|
1999-12-07 00:44:53 +00:00
|
|
|
|
push_tag(os, "sl", stack_num, stack);
|
2000-07-04 19:16:35 +00:00
|
|
|
|
shape_type = 2;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 1:
|
1999-12-07 00:44:53 +00:00
|
|
|
|
pop_tag(os, "it", stack_num, stack);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
if (font2.shape() == LyXFont::SLANTED_SHAPE) {
|
1999-12-07 00:44:53 +00:00
|
|
|
|
push_tag(os, "sl", stack_num, stack);
|
2000-07-04 19:16:35 +00:00
|
|
|
|
shape_type = 2;
|
|
|
|
|
} else {
|
|
|
|
|
shape_type = 0;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
1999-12-07 00:44:53 +00:00
|
|
|
|
pop_tag(os, "sl", stack_num, stack);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
if (font2.shape() == LyXFont::ITALIC_SHAPE) {
|
1999-12-07 00:44:53 +00:00
|
|
|
|
push_tag(os, "it", stack_num, stack);
|
2000-07-04 19:16:35 +00:00
|
|
|
|
shape_type = 1;
|
|
|
|
|
} else {
|
|
|
|
|
shape_type = 0;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2000-04-26 13:57:28 +00:00
|
|
|
|
// handle <em> tag
|
1999-09-27 18:44:28 +00:00
|
|
|
|
if (font1.emph() != font2.emph()) {
|
|
|
|
|
if (font2.emph() == LyXFont::ON) {
|
1999-12-07 00:44:53 +00:00
|
|
|
|
push_tag(os, "em", stack_num, stack);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
is_em = true;
|
|
|
|
|
} else if (is_em) {
|
1999-12-07 00:44:53 +00:00
|
|
|
|
pop_tag(os, "em", stack_num, stack);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
is_em = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
c = par->GetChar(i);
|
2000-07-01 12:54:45 +00:00
|
|
|
|
|
|
|
|
|
if (c == LyXParagraph::META_INSET) {
|
|
|
|
|
inset = par->GetInset(i);
|
|
|
|
|
inset->Linuxdoc(this, os);
|
|
|
|
|
}
|
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
if (font2.latex() == LyXFont::ON) {
|
1999-11-15 12:01:38 +00:00
|
|
|
|
// "TeX"-Mode on == > SGML-Mode on.
|
2000-03-09 03:36:48 +00:00
|
|
|
|
if (c != '\0')
|
1999-12-07 00:44:53 +00:00
|
|
|
|
os << c; // see LaTeX-Generation...
|
2000-01-24 18:34:46 +00:00
|
|
|
|
++char_line_count;
|
2000-03-09 23:58:55 +00:00
|
|
|
|
} else {
|
1999-10-02 16:21:10 +00:00
|
|
|
|
string sgml_string;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
if (par->linuxDocConvertChar(c, sgml_string)
|
1999-11-04 01:40:20 +00:00
|
|
|
|
&& !style.free_spacing) { // in freespacing
|
1999-09-27 18:44:28 +00:00
|
|
|
|
// mode, spaces are
|
|
|
|
|
// non-breaking characters
|
|
|
|
|
// char is ' '
|
|
|
|
|
if (desc_on == 1) {
|
2000-01-24 18:34:46 +00:00
|
|
|
|
++char_line_count;
|
1999-12-07 00:44:53 +00:00
|
|
|
|
linux_doc_line_break(os, char_line_count, 6);
|
|
|
|
|
os << "</tag>";
|
1999-09-27 18:44:28 +00:00
|
|
|
|
desc_on = 2;
|
2000-07-04 19:16:35 +00:00
|
|
|
|
} else {
|
1999-12-07 00:44:53 +00:00
|
|
|
|
linux_doc_line_break(os, char_line_count, 1);
|
|
|
|
|
os << c;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
2000-07-04 19:16:35 +00:00
|
|
|
|
} else {
|
1999-12-07 00:44:53 +00:00
|
|
|
|
os << sgml_string;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
char_line_count += sgml_string.length();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
font1 = font2;
|
|
|
|
|
}
|
|
|
|
|
|
2000-04-26 13:57:28 +00:00
|
|
|
|
// needed if there is an optional argument but no contents
|
1999-11-04 01:40:20 +00:00
|
|
|
|
if (main_body > 0 && main_body == par->size()) {
|
|
|
|
|
font1 = style.font;
|
|
|
|
|
}
|
1999-11-15 12:01:38 +00:00
|
|
|
|
|
2000-04-26 13:57:28 +00:00
|
|
|
|
// pop all defined Styles
|
1999-12-07 00:44:53 +00:00
|
|
|
|
for (j = stack_num; j >= 0; --j) {
|
|
|
|
|
linux_doc_line_break(os,
|
1999-09-27 18:44:28 +00:00
|
|
|
|
char_line_count,
|
1999-12-07 00:44:53 +00:00
|
|
|
|
3 + strlen(stack[j]));
|
|
|
|
|
os << "</" << stack[j] << ">";
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-04-26 13:57:28 +00:00
|
|
|
|
// resets description flag correctly
|
2000-11-04 10:00:12 +00:00
|
|
|
|
switch (desc_on){
|
1999-09-27 18:44:28 +00:00
|
|
|
|
case 1:
|
2000-04-26 13:57:28 +00:00
|
|
|
|
// <tag> not closed...
|
1999-12-07 00:44:53 +00:00
|
|
|
|
linux_doc_line_break(os, char_line_count, 6);
|
|
|
|
|
os << "</tag>";
|
1999-09-27 18:44:28 +00:00
|
|
|
|
break;
|
|
|
|
|
case 2:
|
2000-04-26 13:57:28 +00:00
|
|
|
|
// fprintf(file, "</p>");
|
1999-09-27 18:44:28 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2000-04-26 13:57:28 +00:00
|
|
|
|
// Print an error message.
|
1999-11-04 01:40:20 +00:00
|
|
|
|
void Buffer::LinuxDocError(LyXParagraph * par, int pos,
|
2000-09-14 17:53:12 +00:00
|
|
|
|
string const & message)
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
2000-04-26 13:57:28 +00:00
|
|
|
|
// insert an error marker in text
|
2000-06-28 13:35:52 +00:00
|
|
|
|
InsetError * new_inset = new InsetError(message);
|
|
|
|
|
par->InsertInset(pos, new_inset);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// This constant defines the maximum number of
|
|
|
|
|
// environment layouts that can be nesteded.
|
|
|
|
|
// The same applies for command layouts.
|
|
|
|
|
// These values should be more than enough.
|
|
|
|
|
// Jos<6F> Matos (1999/07/22)
|
|
|
|
|
|
|
|
|
|
enum { MAX_NEST_LEVEL = 25};
|
|
|
|
|
|
2000-07-01 12:54:45 +00:00
|
|
|
|
void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body)
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
1999-11-04 01:40:20 +00:00
|
|
|
|
LyXParagraph * par = paragraph;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2000-07-01 12:54:45 +00:00
|
|
|
|
niceFile = nice; // this will be used by Insetincludes.
|
|
|
|
|
|
1999-11-15 12:01:38 +00:00
|
|
|
|
string top_element= textclasslist.LatexnameOfClass(params.textclass);
|
2000-04-26 13:57:28 +00:00
|
|
|
|
// Please use a real stack.
|
1999-10-02 16:21:10 +00:00
|
|
|
|
string environment_stack[MAX_NEST_LEVEL];
|
|
|
|
|
string environment_inner[MAX_NEST_LEVEL];
|
2000-04-26 13:57:28 +00:00
|
|
|
|
// Please use a real stack.
|
1999-10-02 16:21:10 +00:00
|
|
|
|
string command_stack[MAX_NEST_LEVEL];
|
1999-11-15 12:01:38 +00:00
|
|
|
|
bool command_flag= false;
|
|
|
|
|
int command_depth= 0, command_base= 0, cmd_depth= 0;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
1999-11-15 12:01:38 +00:00
|
|
|
|
string item_name, command_name;
|
|
|
|
|
string c_depth, c_params, tmps;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2000-04-26 13:57:28 +00:00
|
|
|
|
int depth = 0; // paragraph depth
|
2000-07-01 12:54:45 +00:00
|
|
|
|
LyXTextClass const & tclass =
|
|
|
|
|
textclasslist.TextClass(params.textclass);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2000-07-01 12:54:45 +00:00
|
|
|
|
LaTeXFeatures features(params, tclass.numLayouts());
|
|
|
|
|
validate(features);
|
|
|
|
|
|
2000-11-04 10:00:12 +00:00
|
|
|
|
//if (nice)
|
2000-07-04 19:16:35 +00:00
|
|
|
|
tex_code_break_column = lyxrc.ascii_linelen;
|
|
|
|
|
//else
|
|
|
|
|
//tex_code_break_column = 0;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
1999-12-21 06:10:21 +00:00
|
|
|
|
ofstream ofs(fname.c_str());
|
1999-12-07 00:44:53 +00:00
|
|
|
|
if (!ofs) {
|
1999-12-21 06:10:21 +00:00
|
|
|
|
WriteAlert(_("LYX_ERROR:"), _("Cannot write file"), fname);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
texrow.reset();
|
|
|
|
|
|
2000-11-04 10:00:12 +00:00
|
|
|
|
if (!only_body) {
|
2000-11-13 15:43:36 +00:00
|
|
|
|
string sgml_includedfiles=features.getIncludedFiles(fname);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2000-07-01 12:54:45 +00:00
|
|
|
|
ofs << "<!doctype " << top_element
|
|
|
|
|
<< " public \"-//OASIS//DTD DocBook V3.1//EN\"";
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2000-07-01 12:54:45 +00:00
|
|
|
|
if (params.preamble.empty() && sgml_includedfiles.empty())
|
|
|
|
|
ofs << ">\n\n";
|
|
|
|
|
else
|
|
|
|
|
ofs << "\n [ " << params.preamble
|
|
|
|
|
<< sgml_includedfiles << " \n]>\n\n";
|
2000-11-13 15:43:36 +00:00
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2000-11-13 15:43:36 +00:00
|
|
|
|
if (params.options.empty())
|
|
|
|
|
sgmlOpenTag(ofs, 0, top_element);
|
|
|
|
|
else {
|
|
|
|
|
string top = top_element;
|
|
|
|
|
top += " ";
|
|
|
|
|
top += params.options;
|
|
|
|
|
sgmlOpenTag(ofs, 0, top);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-07-01 12:54:45 +00:00
|
|
|
|
ofs << "<!-- DocBook file was created by " << LYX_DOCVERSION
|
|
|
|
|
<< "\n See http://www.lyx.org/ for more information -->\n";
|
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
while (par) {
|
2000-04-26 13:57:28 +00:00
|
|
|
|
int desc_on = 0; // description mode
|
2000-02-29 02:19:17 +00:00
|
|
|
|
LyXLayout const & style =
|
2000-07-01 12:54:45 +00:00
|
|
|
|
textclasslist.Style(params.textclass,
|
2000-02-29 02:19:17 +00:00
|
|
|
|
par->layout);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2000-04-26 13:57:28 +00:00
|
|
|
|
// environment tag closing
|
2000-11-04 10:00:12 +00:00
|
|
|
|
for (; depth > par->depth; --depth) {
|
|
|
|
|
if (environment_inner[depth] != "!-- --") {
|
1999-11-15 12:01:38 +00:00
|
|
|
|
item_name= "listitem";
|
1999-12-07 00:44:53 +00:00
|
|
|
|
sgmlCloseTag(ofs, command_depth + depth,
|
1999-09-27 18:44:28 +00:00
|
|
|
|
item_name);
|
2000-11-04 10:00:12 +00:00
|
|
|
|
if (environment_inner[depth] == "varlistentry")
|
1999-12-07 00:44:53 +00:00
|
|
|
|
sgmlCloseTag(ofs, depth+command_depth,
|
1999-09-27 18:44:28 +00:00
|
|
|
|
environment_inner[depth]);
|
|
|
|
|
}
|
1999-12-07 00:44:53 +00:00
|
|
|
|
sgmlCloseTag(ofs, depth + command_depth,
|
1999-09-27 18:44:28 +00:00
|
|
|
|
environment_stack[depth]);
|
2000-05-04 10:57:00 +00:00
|
|
|
|
environment_stack[depth].erase();
|
|
|
|
|
environment_inner[depth].erase();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-11-04 10:00:12 +00:00
|
|
|
|
if (depth == par->depth
|
1999-11-04 01:40:20 +00:00
|
|
|
|
&& environment_stack[depth] != style.latexname()
|
1999-09-27 18:44:28 +00:00
|
|
|
|
&& !environment_stack[depth].empty()) {
|
2000-11-04 10:00:12 +00:00
|
|
|
|
if (environment_inner[depth] != "!-- --") {
|
1999-11-15 12:01:38 +00:00
|
|
|
|
item_name= "listitem";
|
1999-12-07 00:44:53 +00:00
|
|
|
|
sgmlCloseTag(ofs, command_depth+depth,
|
1999-09-27 18:44:28 +00:00
|
|
|
|
item_name);
|
2000-11-04 10:00:12 +00:00
|
|
|
|
if (environment_inner[depth] == "varlistentry")
|
1999-12-07 00:44:53 +00:00
|
|
|
|
sgmlCloseTag(ofs,
|
|
|
|
|
depth + command_depth,
|
1999-09-27 18:44:28 +00:00
|
|
|
|
environment_inner[depth]);
|
|
|
|
|
}
|
|
|
|
|
|
1999-12-07 00:44:53 +00:00
|
|
|
|
sgmlCloseTag(ofs, depth + command_depth,
|
1999-09-27 18:44:28 +00:00
|
|
|
|
environment_stack[depth]);
|
|
|
|
|
|
2000-05-04 10:57:00 +00:00
|
|
|
|
environment_stack[depth].erase();
|
|
|
|
|
environment_inner[depth].erase();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Write opening SGML tags.
|
2000-11-04 10:00:12 +00:00
|
|
|
|
switch (style.latextype) {
|
1999-09-27 18:44:28 +00:00
|
|
|
|
case LATEX_PARAGRAPH:
|
2000-11-13 15:43:36 +00:00
|
|
|
|
sgmlOpenTag(ofs, depth+command_depth, style.latexname());
|
1999-09-27 18:44:28 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case LATEX_COMMAND:
|
1999-11-15 12:01:38 +00:00
|
|
|
|
if (depth!= 0)
|
1999-09-27 18:44:28 +00:00
|
|
|
|
LinuxDocError(par, 0,
|
|
|
|
|
_("Error : Wrong depth for "
|
|
|
|
|
"LatexType Command.\n"));
|
|
|
|
|
|
1999-11-04 01:40:20 +00:00
|
|
|
|
command_name = style.latexname();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
1999-11-04 01:40:20 +00:00
|
|
|
|
tmps = style.latexparam();
|
|
|
|
|
c_params = split(tmps, c_depth,'|');
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2000-09-26 13:54:57 +00:00
|
|
|
|
cmd_depth= lyx::atoi(c_depth);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2000-11-04 10:00:12 +00:00
|
|
|
|
if (command_flag) {
|
|
|
|
|
if (cmd_depth<command_base) {
|
|
|
|
|
for (int j = command_depth;
|
1999-12-07 00:44:53 +00:00
|
|
|
|
j >= command_base; --j)
|
2000-11-04 10:00:12 +00:00
|
|
|
|
if (!command_stack[j].empty())
|
1999-12-07 00:44:53 +00:00
|
|
|
|
sgmlCloseTag(ofs, j, command_stack[j]);
|
1999-11-15 12:01:38 +00:00
|
|
|
|
command_depth= command_base= cmd_depth;
|
2000-11-04 10:00:12 +00:00
|
|
|
|
} else if (cmd_depth <= command_depth) {
|
|
|
|
|
for (int j = command_depth;
|
1999-12-07 00:44:53 +00:00
|
|
|
|
j >= cmd_depth; --j)
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2000-11-04 10:00:12 +00:00
|
|
|
|
if (!command_stack[j].empty())
|
1999-12-07 00:44:53 +00:00
|
|
|
|
sgmlCloseTag(ofs, j, command_stack[j]);
|
1999-11-15 12:01:38 +00:00
|
|
|
|
command_depth= cmd_depth;
|
2000-07-04 19:16:35 +00:00
|
|
|
|
} else
|
1999-11-15 12:01:38 +00:00
|
|
|
|
command_depth= cmd_depth;
|
2000-07-04 19:16:35 +00:00
|
|
|
|
} else {
|
1999-09-27 18:44:28 +00:00
|
|
|
|
command_depth = command_base = cmd_depth;
|
|
|
|
|
command_flag = true;
|
|
|
|
|
}
|
1999-11-15 12:01:38 +00:00
|
|
|
|
command_stack[command_depth]= command_name;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
// treat label as a special case for
|
|
|
|
|
// more WYSIWYM handling.
|
1999-11-15 12:01:38 +00:00
|
|
|
|
if (par->GetChar(0) == LyXParagraph::META_INSET) {
|
1999-12-07 00:44:53 +00:00
|
|
|
|
Inset * inset = par->GetInset(0);
|
2000-05-18 13:26:04 +00:00
|
|
|
|
Inset::Code lyx_code = inset->LyxCode();
|
1999-11-15 12:01:38 +00:00
|
|
|
|
if (lyx_code == Inset::LABEL_CODE){
|
1999-12-07 00:44:53 +00:00
|
|
|
|
command_name += " id=\"";
|
|
|
|
|
command_name += (static_cast<InsetCommand *>(inset))->getContents();
|
|
|
|
|
command_name += "\"";
|
|
|
|
|
desc_on = 3;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-18 13:26:04 +00:00
|
|
|
|
sgmlOpenTag(ofs, depth + command_depth, command_name);
|
1999-12-07 00:44:53 +00:00
|
|
|
|
item_name = "title";
|
2000-11-13 15:43:36 +00:00
|
|
|
|
if (command_name != "!-- --")
|
|
|
|
|
sgmlOpenTag(ofs, depth + 1 + command_depth, item_name);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case LATEX_ENVIRONMENT:
|
|
|
|
|
case LATEX_ITEM_ENVIRONMENT:
|
|
|
|
|
if (depth < par->depth) {
|
|
|
|
|
depth = par->depth;
|
2000-05-04 10:57:00 +00:00
|
|
|
|
environment_stack[depth].erase();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-11-04 01:40:20 +00:00
|
|
|
|
if (environment_stack[depth] != style.latexname()) {
|
1999-12-07 00:44:53 +00:00
|
|
|
|
environment_stack[depth] = style.latexname();
|
|
|
|
|
environment_inner[depth] = "!-- --";
|
|
|
|
|
sgmlOpenTag(ofs, depth + command_depth,
|
1999-09-27 18:44:28 +00:00
|
|
|
|
environment_stack[depth]);
|
|
|
|
|
} else {
|
2000-11-04 10:00:12 +00:00
|
|
|
|
if (environment_inner[depth] != "!-- --") {
|
1999-11-15 12:01:38 +00:00
|
|
|
|
item_name= "listitem";
|
1999-12-07 00:44:53 +00:00
|
|
|
|
sgmlCloseTag(ofs,
|
1999-09-27 18:44:28 +00:00
|
|
|
|
command_depth + depth,
|
|
|
|
|
item_name);
|
|
|
|
|
if (environment_inner[depth] == "varlistentry")
|
1999-12-07 00:44:53 +00:00
|
|
|
|
sgmlCloseTag(ofs,
|
|
|
|
|
depth + command_depth,
|
1999-09-27 18:44:28 +00:00
|
|
|
|
environment_inner[depth]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2000-11-04 10:00:12 +00:00
|
|
|
|
if (style.latextype == LATEX_ENVIRONMENT) {
|
|
|
|
|
if (!style.latexparam().empty())
|
1999-12-07 00:44:53 +00:00
|
|
|
|
sgmlOpenTag(ofs, depth + command_depth,
|
1999-11-04 01:40:20 +00:00
|
|
|
|
style.latexparam());
|
1999-09-27 18:44:28 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
1999-11-15 12:01:38 +00:00
|
|
|
|
desc_on = (style.labeltype == LABEL_MANUAL);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2000-11-04 10:00:12 +00:00
|
|
|
|
if (desc_on)
|
1999-11-15 12:01:38 +00:00
|
|
|
|
environment_inner[depth]= "varlistentry";
|
1999-09-27 18:44:28 +00:00
|
|
|
|
else
|
1999-11-15 12:01:38 +00:00
|
|
|
|
environment_inner[depth]= "listitem";
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
1999-12-07 00:44:53 +00:00
|
|
|
|
sgmlOpenTag(ofs, depth + 1 + command_depth,
|
1999-09-27 18:44:28 +00:00
|
|
|
|
environment_inner[depth]);
|
|
|
|
|
|
2000-11-04 10:00:12 +00:00
|
|
|
|
if (desc_on) {
|
1999-11-15 12:01:38 +00:00
|
|
|
|
item_name= "term";
|
1999-12-07 00:44:53 +00:00
|
|
|
|
sgmlOpenTag(ofs, depth + 1 + command_depth,
|
1999-09-27 18:44:28 +00:00
|
|
|
|
item_name);
|
2000-07-04 19:16:35 +00:00
|
|
|
|
} else {
|
1999-11-15 12:01:38 +00:00
|
|
|
|
item_name= "para";
|
1999-12-07 00:44:53 +00:00
|
|
|
|
sgmlOpenTag(ofs, depth + 1 + command_depth,
|
1999-09-27 18:44:28 +00:00
|
|
|
|
item_name);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
1999-12-07 00:44:53 +00:00
|
|
|
|
sgmlOpenTag(ofs, depth + command_depth,
|
1999-11-04 01:40:20 +00:00
|
|
|
|
style.latexname());
|
1999-09-27 18:44:28 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2000-07-19 17:16:27 +00:00
|
|
|
|
#ifndef NEW_INSETS
|
1999-09-27 18:44:28 +00:00
|
|
|
|
do {
|
2000-07-19 17:16:27 +00:00
|
|
|
|
#endif
|
2000-03-06 02:42:40 +00:00
|
|
|
|
string extra_par;
|
|
|
|
|
SimpleDocBookOnePar(ofs, extra_par, par, desc_on,
|
|
|
|
|
depth + 1 + command_depth);
|
|
|
|
|
par = par->next;
|
2000-07-19 17:16:27 +00:00
|
|
|
|
#ifndef NEW_INSETS
|
2000-03-06 02:42:40 +00:00
|
|
|
|
DocBookHandleFootnote(ofs, par,
|
|
|
|
|
depth + 1 + command_depth);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
while(par && par->IsDummy());
|
2000-07-19 17:16:27 +00:00
|
|
|
|
#endif
|
1999-10-02 16:21:10 +00:00
|
|
|
|
string end_tag;
|
2000-04-26 13:57:28 +00:00
|
|
|
|
// write closing SGML tags
|
2000-11-04 10:00:12 +00:00
|
|
|
|
switch (style.latextype) {
|
1999-09-27 18:44:28 +00:00
|
|
|
|
case LATEX_COMMAND:
|
1999-11-04 01:40:20 +00:00
|
|
|
|
end_tag = "title";
|
2000-11-13 15:43:36 +00:00
|
|
|
|
if (command_name != "!-- --")
|
|
|
|
|
sgmlCloseTag(ofs, depth + command_depth, end_tag);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
break;
|
|
|
|
|
case LATEX_ENVIRONMENT:
|
2000-11-04 10:00:12 +00:00
|
|
|
|
if (!style.latexparam().empty())
|
1999-12-07 00:44:53 +00:00
|
|
|
|
sgmlCloseTag(ofs, depth + command_depth,
|
1999-11-04 01:40:20 +00:00
|
|
|
|
style.latexparam());
|
1999-09-27 18:44:28 +00:00
|
|
|
|
break;
|
|
|
|
|
case LATEX_ITEM_ENVIRONMENT:
|
2000-11-04 10:00:12 +00:00
|
|
|
|
if (desc_on == 1) break;
|
1999-11-15 12:01:38 +00:00
|
|
|
|
end_tag= "para";
|
1999-12-07 00:44:53 +00:00
|
|
|
|
sgmlCloseTag(ofs, depth + 1 + command_depth, end_tag);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
break;
|
|
|
|
|
case LATEX_PARAGRAPH:
|
2000-11-13 15:43:36 +00:00
|
|
|
|
sgmlCloseTag(ofs, depth + command_depth, style.latexname());
|
1999-09-27 18:44:28 +00:00
|
|
|
|
break;
|
|
|
|
|
default:
|
2000-11-13 15:43:36 +00:00
|
|
|
|
sgmlCloseTag(ofs, depth + command_depth, style.latexname());
|
1999-09-27 18:44:28 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Close open tags
|
2000-11-04 10:00:12 +00:00
|
|
|
|
for (; depth >= 0; --depth) {
|
|
|
|
|
if (!environment_stack[depth].empty()) {
|
|
|
|
|
if (environment_inner[depth] != "!-- --") {
|
1999-11-15 12:01:38 +00:00
|
|
|
|
item_name= "listitem";
|
1999-12-07 00:44:53 +00:00
|
|
|
|
sgmlCloseTag(ofs, command_depth + depth,
|
1999-10-02 14:01:04 +00:00
|
|
|
|
item_name);
|
2000-11-04 10:00:12 +00:00
|
|
|
|
if (environment_inner[depth] == "varlistentry")
|
1999-12-07 00:44:53 +00:00
|
|
|
|
sgmlCloseTag(ofs, depth + command_depth,
|
1999-10-02 14:01:04 +00:00
|
|
|
|
environment_inner[depth]);
|
|
|
|
|
}
|
|
|
|
|
|
1999-12-07 00:44:53 +00:00
|
|
|
|
sgmlCloseTag(ofs, depth + command_depth,
|
1999-10-02 14:01:04 +00:00
|
|
|
|
environment_stack[depth]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2000-11-04 10:00:12 +00:00
|
|
|
|
for (int j = command_depth; j >= command_base; --j)
|
|
|
|
|
if (!command_stack[j].empty())
|
1999-12-07 00:44:53 +00:00
|
|
|
|
sgmlCloseTag(ofs, j, command_stack[j]);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2000-11-13 15:43:36 +00:00
|
|
|
|
ofs << "\n\n";
|
|
|
|
|
sgmlCloseTag(ofs, 0, top_element);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
1999-12-07 00:44:53 +00:00
|
|
|
|
ofs.close();
|
|
|
|
|
// How to check for successful close
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2000-03-06 02:42:40 +00:00
|
|
|
|
void Buffer::SimpleDocBookOnePar(ostream & os, string & extra,
|
|
|
|
|
LyXParagraph * par, int & desc_on,
|
2000-10-27 10:04:51 +00:00
|
|
|
|
int depth) const
|
2000-03-06 02:42:40 +00:00
|
|
|
|
{
|
|
|
|
|
bool emph_flag = false;
|
|
|
|
|
|
|
|
|
|
LyXLayout const & style = textclasslist.Style(params.textclass,
|
|
|
|
|
par->GetLayout());
|
|
|
|
|
|
2000-03-09 03:36:48 +00:00
|
|
|
|
LyXParagraph::size_type main_body;
|
2000-03-06 02:42:40 +00:00
|
|
|
|
if (style.labeltype != LABEL_MANUAL)
|
|
|
|
|
main_body = 0;
|
|
|
|
|
else
|
|
|
|
|
main_body = par->BeginningOfMainBody();
|
|
|
|
|
|
|
|
|
|
// gets paragraph main font
|
2000-03-09 03:36:48 +00:00
|
|
|
|
LyXFont font1 = main_body > 0 ? style.labelfont : style.font;
|
|
|
|
|
|
|
|
|
|
int char_line_count = depth;
|
2000-11-04 10:00:12 +00:00
|
|
|
|
if (!style.free_spacing)
|
2000-03-09 03:36:48 +00:00
|
|
|
|
for (int j = 0; j < depth; ++j)
|
2000-03-06 02:42:40 +00:00
|
|
|
|
os << ' ';
|
|
|
|
|
|
|
|
|
|
// parsing main loop
|
|
|
|
|
for (LyXParagraph::size_type i = 0;
|
|
|
|
|
i < par->size(); ++i) {
|
2000-06-08 23:16:16 +00:00
|
|
|
|
LyXFont font2 = par->getFont(params, i);
|
2000-03-06 02:42:40 +00:00
|
|
|
|
|
|
|
|
|
// handle <emphasis> tag
|
|
|
|
|
if (font1.emph() != font2.emph() && i) {
|
|
|
|
|
if (font2.emph() == LyXFont::ON) {
|
|
|
|
|
os << "<emphasis>";
|
2000-03-09 03:36:48 +00:00
|
|
|
|
emph_flag = true;
|
2000-03-06 02:42:40 +00:00
|
|
|
|
}else {
|
|
|
|
|
os << "</emphasis>";
|
2000-03-09 03:36:48 +00:00
|
|
|
|
emph_flag = false;
|
2000-03-06 02:42:40 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2000-03-09 03:36:48 +00:00
|
|
|
|
char c = par->GetChar(i);
|
2000-03-06 02:42:40 +00:00
|
|
|
|
|
|
|
|
|
if (c == LyXParagraph::META_INSET) {
|
2000-03-09 03:36:48 +00:00
|
|
|
|
Inset * inset = par->GetInset(i);
|
2000-04-04 00:19:15 +00:00
|
|
|
|
std::ostringstream ost;
|
2000-06-12 11:27:15 +00:00
|
|
|
|
inset->DocBook(this, ost);
|
2000-03-06 02:42:40 +00:00
|
|
|
|
string tmp_out = ost.str().c_str();
|
2000-09-18 17:39:21 +00:00
|
|
|
|
|
2000-03-06 02:42:40 +00:00
|
|
|
|
//
|
|
|
|
|
// This code needs some explanation:
|
|
|
|
|
// Two insets are treated specially
|
|
|
|
|
// label if it is the first element in a command paragraph
|
|
|
|
|
// desc_on == 3
|
|
|
|
|
// graphics inside tables or figure floats can't go on
|
|
|
|
|
// title (the equivalente in latex for this case is caption
|
|
|
|
|
// and title should come first
|
|
|
|
|
// desc_on == 4
|
|
|
|
|
//
|
2000-11-04 10:00:12 +00:00
|
|
|
|
if (desc_on!= 3 || i!= 0) {
|
|
|
|
|
if (!tmp_out.empty() && tmp_out[0] == '@') {
|
|
|
|
|
if (desc_on == 4)
|
2000-03-06 02:42:40 +00:00
|
|
|
|
extra += frontStrip(tmp_out, '@');
|
|
|
|
|
else
|
|
|
|
|
os << frontStrip(tmp_out, '@');
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
os << tmp_out;
|
|
|
|
|
}
|
|
|
|
|
} else if (font2.latex() == LyXFont::ON) {
|
|
|
|
|
// "TeX"-Mode on ==> SGML-Mode on.
|
2000-03-09 03:36:48 +00:00
|
|
|
|
if (c != '\0')
|
2000-03-06 02:42:40 +00:00
|
|
|
|
os << c;
|
|
|
|
|
++char_line_count;
|
2000-04-26 13:57:28 +00:00
|
|
|
|
} else {
|
2000-03-06 02:42:40 +00:00
|
|
|
|
string sgml_string;
|
|
|
|
|
if (par->linuxDocConvertChar(c, sgml_string)
|
|
|
|
|
&& !style.free_spacing) { // in freespacing
|
|
|
|
|
// mode, spaces are
|
|
|
|
|
// non-breaking characters
|
|
|
|
|
// char is ' '
|
|
|
|
|
if (desc_on == 1) {
|
|
|
|
|
++char_line_count;
|
|
|
|
|
os << "\n</term><listitem><para>";
|
|
|
|
|
desc_on = 2;
|
2000-04-26 13:57:28 +00:00
|
|
|
|
} else {
|
2000-03-06 02:42:40 +00:00
|
|
|
|
os << c;
|
|
|
|
|
}
|
2000-04-26 13:57:28 +00:00
|
|
|
|
} else {
|
2000-03-06 02:42:40 +00:00
|
|
|
|
os << sgml_string;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
font1 = font2;
|
|
|
|
|
}
|
|
|
|
|
|
2000-04-26 13:57:28 +00:00
|
|
|
|
// needed if there is an optional argument but no contents
|
2000-03-06 02:42:40 +00:00
|
|
|
|
if (main_body > 0 && main_body == par->size()) {
|
|
|
|
|
font1 = style.font;
|
|
|
|
|
}
|
|
|
|
|
if (emph_flag) {
|
|
|
|
|
os << "</emphasis>";
|
|
|
|
|
}
|
|
|
|
|
|
2000-04-26 13:57:28 +00:00
|
|
|
|
// resets description flag correctly
|
2000-11-04 10:00:12 +00:00
|
|
|
|
switch (desc_on){
|
2000-03-06 02:42:40 +00:00
|
|
|
|
case 1:
|
2000-04-26 13:57:28 +00:00
|
|
|
|
// <term> not closed...
|
2000-03-06 02:42:40 +00:00
|
|
|
|
os << "</term>";
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
os << '\n';
|
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// This should be enabled when the Chktex class is implemented. (Asger)
|
|
|
|
|
// chktex should be run with these flags disabled: 3, 22, 25, 30, 38(?)
|
|
|
|
|
// Other flags: -wall -v0 -x
|
|
|
|
|
int Buffer::runChktex()
|
|
|
|
|
{
|
1999-12-10 00:07:59 +00:00
|
|
|
|
if (!users->text) return 0;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2000-04-11 22:55:29 +00:00
|
|
|
|
ProhibitInput(users);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
// get LaTeX-Filename
|
2000-09-26 13:54:57 +00:00
|
|
|
|
string const name = getLatexName();
|
1999-10-02 16:21:10 +00:00
|
|
|
|
string path = OnlyPath(filename);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2000-09-26 13:54:57 +00:00
|
|
|
|
string const org_path = path;
|
2000-03-12 10:35:05 +00:00
|
|
|
|
if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)) {
|
1999-09-27 18:44:28 +00:00
|
|
|
|
path = tmppath;
|
|
|
|
|
}
|
|
|
|
|
|
1999-10-13 17:32:46 +00:00
|
|
|
|
Path p(path); // path to LaTeX file
|
1999-11-09 23:52:04 +00:00
|
|
|
|
users->owner()->getMiniBuffer()->Set(_("Running chktex..."));
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
// Remove all error insets
|
2000-09-26 13:54:57 +00:00
|
|
|
|
bool const removedErrorInsets = users->removeAutoInsets();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
// Generate the LaTeX file if neccessary
|
2000-06-20 12:49:14 +00:00
|
|
|
|
makeLaTeXFile(name, org_path, false);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
TeXErrors terr;
|
2000-03-12 10:35:05 +00:00
|
|
|
|
Chktex chktex(lyxrc.chktex_command, name, filepath);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
int res = chktex.run(terr); // run chktex
|
|
|
|
|
|
|
|
|
|
if (res == -1) {
|
|
|
|
|
WriteAlert(_("chktex did not work!"),
|
|
|
|
|
_("Could not run with file:"), name);
|
|
|
|
|
} else if (res > 0) {
|
|
|
|
|
// Insert all errors as errors boxes
|
2000-01-08 21:02:58 +00:00
|
|
|
|
users->insertErrors(terr);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// if we removed error insets before we ran chktex or if we inserted
|
|
|
|
|
// error insets after we ran chktex, this must be run:
|
2000-06-20 12:49:14 +00:00
|
|
|
|
if (removedErrorInsets || res){
|
1999-09-27 18:44:28 +00:00
|
|
|
|
users->redraw();
|
2000-09-28 14:05:24 +00:00
|
|
|
|
users->fitCursor(users->text);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
2000-04-11 22:55:29 +00:00
|
|
|
|
AllowInput(users);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2000-02-04 09:38:32 +00:00
|
|
|
|
void Buffer::validate(LaTeXFeatures & features) const
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
1999-11-04 01:40:20 +00:00
|
|
|
|
LyXParagraph * par = paragraph;
|
1999-11-15 12:01:38 +00:00
|
|
|
|
LyXTextClass const & tclass =
|
1999-11-04 01:40:20 +00:00
|
|
|
|
textclasslist.TextClass(params.textclass);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
// AMS Style is at document level
|
|
|
|
|
|
|
|
|
|
features.amsstyle = (params.use_amsmath ||
|
1999-11-04 01:40:20 +00:00
|
|
|
|
tclass.provides(LyXTextClass::amsmath));
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
while (par) {
|
|
|
|
|
// We don't use "lyxerr.debug" because of speed. (Asger)
|
1999-10-07 18:44:17 +00:00
|
|
|
|
if (lyxerr.debugging(Debug::LATEX))
|
|
|
|
|
lyxerr << "Paragraph: " << par << endl;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
// Now just follow the list of paragraphs and run
|
|
|
|
|
// validate on each of them.
|
|
|
|
|
par->validate(features);
|
|
|
|
|
|
|
|
|
|
// and then the next paragraph
|
|
|
|
|
par = par->next;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// the bullet shapes are buffer level not paragraph level
|
|
|
|
|
// so they are tested here
|
|
|
|
|
for (int i = 0; i < 4; ++i) {
|
|
|
|
|
if (params.user_defined_bullets[i] != ITEMIZE_DEFAULTS[i]) {
|
2000-09-26 13:54:57 +00:00
|
|
|
|
int const font = params.user_defined_bullets[i].getFont();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
if (font == 0) {
|
2000-09-26 13:54:57 +00:00
|
|
|
|
int const c = params
|
1999-11-04 01:40:20 +00:00
|
|
|
|
.user_defined_bullets[i]
|
|
|
|
|
.getCharacter();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
if (c == 16
|
|
|
|
|
|| c == 17
|
|
|
|
|
|| c == 25
|
|
|
|
|
|| c == 26
|
|
|
|
|
|| c == 31) {
|
|
|
|
|
features.latexsym = true;
|
|
|
|
|
}
|
2000-09-26 13:54:57 +00:00
|
|
|
|
} else if (font == 1) {
|
1999-09-27 18:44:28 +00:00
|
|
|
|
features.amssymb = true;
|
2000-09-26 13:54:57 +00:00
|
|
|
|
} else if ((font >= 2 && font <= 5)) {
|
1999-09-27 18:44:28 +00:00
|
|
|
|
features.pifont = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1999-10-07 18:44:17 +00:00
|
|
|
|
if (lyxerr.debugging(Debug::LATEX)) {
|
2000-04-10 21:40:13 +00:00
|
|
|
|
features.showStruct();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Buffer::setPaperStuff()
|
|
|
|
|
{
|
1999-11-15 12:01:38 +00:00
|
|
|
|
params.papersize = BufferParams::PAPER_DEFAULT;
|
2000-09-26 13:54:57 +00:00
|
|
|
|
char const c1 = params.paperpackage;
|
1999-11-15 12:01:38 +00:00
|
|
|
|
if (c1 == BufferParams::PACKAGE_NONE) {
|
2000-09-26 13:54:57 +00:00
|
|
|
|
char const c2 = params.papersize2;
|
1999-11-15 12:01:38 +00:00
|
|
|
|
if (c2 == BufferParams::VM_PAPER_USLETTER)
|
|
|
|
|
params.papersize = BufferParams::PAPER_USLETTER;
|
|
|
|
|
else if (c2 == BufferParams::VM_PAPER_USLEGAL)
|
|
|
|
|
params.papersize = BufferParams::PAPER_LEGALPAPER;
|
|
|
|
|
else if (c2 == BufferParams::VM_PAPER_USEXECUTIVE)
|
|
|
|
|
params.papersize = BufferParams::PAPER_EXECUTIVEPAPER;
|
|
|
|
|
else if (c2 == BufferParams::VM_PAPER_A3)
|
|
|
|
|
params.papersize = BufferParams::PAPER_A3PAPER;
|
|
|
|
|
else if (c2 == BufferParams::VM_PAPER_A4)
|
|
|
|
|
params.papersize = BufferParams::PAPER_A4PAPER;
|
|
|
|
|
else if (c2 == BufferParams::VM_PAPER_A5)
|
|
|
|
|
params.papersize = BufferParams::PAPER_A5PAPER;
|
|
|
|
|
else if ((c2 == BufferParams::VM_PAPER_B3) || (c2 == BufferParams::VM_PAPER_B4) ||
|
|
|
|
|
(c2 == BufferParams::VM_PAPER_B5))
|
|
|
|
|
params.papersize = BufferParams::PAPER_B5PAPER;
|
|
|
|
|
} else if ((c1 == BufferParams::PACKAGE_A4) || (c1 == BufferParams::PACKAGE_A4WIDE) ||
|
|
|
|
|
(c1 == BufferParams::PACKAGE_WIDEMARGINSA4))
|
|
|
|
|
params.papersize = BufferParams::PAPER_A4PAPER;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2000-01-08 21:02:58 +00:00
|
|
|
|
// This function should be in Buffer because it's a buffer's property (ale)
|
2000-09-14 17:53:12 +00:00
|
|
|
|
string const Buffer::getIncludeonlyList(char delim)
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
1999-11-04 01:40:20 +00:00
|
|
|
|
string lst;
|
2000-05-19 16:46:01 +00:00
|
|
|
|
for (inset_iterator it = inset_iterator_begin();
|
|
|
|
|
it != inset_iterator_end(); ++it) {
|
|
|
|
|
if ((*it)->LyxCode() == Inset::INCLUDE_CODE) {
|
|
|
|
|
InsetInclude * insetinc =
|
|
|
|
|
static_cast<InsetInclude *>(*it);
|
|
|
|
|
if (insetinc->isInclude()
|
|
|
|
|
&& insetinc->isNoLoad()) {
|
|
|
|
|
if (!lst.empty())
|
|
|
|
|
lst += delim;
|
|
|
|
|
lst += OnlyFilename(ChangeExtension(insetinc->getContents(), string()));
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
2000-05-19 16:46:01 +00:00
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
1999-11-04 01:40:20 +00:00
|
|
|
|
lyxerr.debug() << "Includeonly(" << lst << ')' << endl;
|
|
|
|
|
return lst;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2000-09-14 17:53:12 +00:00
|
|
|
|
vector<string> const Buffer::getLabelList()
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
|
|
|
|
/// if this is a child document and the parent is already loaded
|
|
|
|
|
/// Use the parent's list instead [ale990407]
|
2000-01-25 12:35:27 +00:00
|
|
|
|
if (!params.parentname.empty()
|
|
|
|
|
&& bufferlist.exists(params.parentname)) {
|
1999-12-10 00:07:59 +00:00
|
|
|
|
Buffer * tmp = bufferlist.getBuffer(params.parentname);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
if (tmp)
|
2000-05-19 16:46:01 +00:00
|
|
|
|
return tmp->getLabelList();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-05-19 16:46:01 +00:00
|
|
|
|
vector<string> label_list;
|
|
|
|
|
for (inset_iterator it = inset_iterator_begin();
|
|
|
|
|
it != inset_iterator_end(); ++it) {
|
2000-09-26 13:54:57 +00:00
|
|
|
|
vector<string> const l = (*it)->getLabelList();
|
2000-05-19 16:46:01 +00:00
|
|
|
|
label_list.insert(label_list.end(), l.begin(), l.end());
|
|
|
|
|
}
|
|
|
|
|
return label_list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2001-01-11 14:55:36 +00:00
|
|
|
|
vector<vector<Buffer::TocItem> > const Buffer::getTocList() const
|
2000-05-19 16:46:01 +00:00
|
|
|
|
{
|
2000-11-13 10:35:02 +00:00
|
|
|
|
int figs = 0;
|
|
|
|
|
int tables = 0;
|
|
|
|
|
int algs = 0;
|
2000-05-19 16:46:01 +00:00
|
|
|
|
vector<vector<TocItem> > l(4);
|
1999-12-10 00:07:59 +00:00
|
|
|
|
LyXParagraph * par = paragraph;
|
2000-01-25 12:35:27 +00:00
|
|
|
|
while (par) {
|
2000-07-19 17:16:27 +00:00
|
|
|
|
#ifndef NEW_INSETS
|
2000-05-19 16:46:01 +00:00
|
|
|
|
if (par->footnoteflag != LyXParagraph::NO_FOOTNOTE) {
|
|
|
|
|
if (textclasslist.Style(params.textclass,
|
|
|
|
|
par->GetLayout()).labeltype
|
|
|
|
|
== LABEL_SENSITIVE) {
|
|
|
|
|
TocItem tmp;
|
|
|
|
|
tmp.par = par;
|
|
|
|
|
tmp.depth = 0;
|
2000-06-12 11:27:15 +00:00
|
|
|
|
tmp.str = par->String(this, false);
|
2000-05-19 16:46:01 +00:00
|
|
|
|
switch (par->footnotekind) {
|
|
|
|
|
case LyXParagraph::FIG:
|
|
|
|
|
case LyXParagraph::WIDE_FIG:
|
2000-11-13 10:35:02 +00:00
|
|
|
|
tmp.str = tostr(++figs) + ". "
|
|
|
|
|
+ tmp.str;
|
2000-05-20 21:37:05 +00:00
|
|
|
|
l[TOC_LOF].push_back(tmp);
|
2000-05-19 16:46:01 +00:00
|
|
|
|
break;
|
|
|
|
|
case LyXParagraph::TAB:
|
|
|
|
|
case LyXParagraph::WIDE_TAB:
|
2000-11-13 10:35:02 +00:00
|
|
|
|
tmp.str = tostr(++tables) + ". "
|
|
|
|
|
+ tmp.str;
|
2000-05-20 21:37:05 +00:00
|
|
|
|
l[TOC_LOT].push_back(tmp);
|
2000-05-19 16:46:01 +00:00
|
|
|
|
break;
|
|
|
|
|
case LyXParagraph::ALGORITHM:
|
2000-11-13 10:35:02 +00:00
|
|
|
|
tmp.str = tostr(++algs) + ". "
|
|
|
|
|
+ tmp.str;
|
2000-05-20 21:37:05 +00:00
|
|
|
|
l[TOC_LOA].push_back(tmp);
|
2000-05-19 16:46:01 +00:00
|
|
|
|
break;
|
|
|
|
|
case LyXParagraph::FOOTNOTE:
|
|
|
|
|
case LyXParagraph::MARGIN:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else if (!par->IsDummy()) {
|
2000-07-19 17:16:27 +00:00
|
|
|
|
#endif
|
2000-09-26 13:54:57 +00:00
|
|
|
|
char const labeltype =
|
|
|
|
|
textclasslist.Style(params.textclass,
|
|
|
|
|
par->GetLayout()).labeltype;
|
2000-05-19 16:46:01 +00:00
|
|
|
|
|
|
|
|
|
if (labeltype >= LABEL_COUNTER_CHAPTER
|
|
|
|
|
&& labeltype <= LABEL_COUNTER_CHAPTER + params.tocdepth) {
|
|
|
|
|
// insert this into the table of contents
|
|
|
|
|
TocItem tmp;
|
|
|
|
|
tmp.par = par;
|
|
|
|
|
tmp.depth = max(0,
|
|
|
|
|
labeltype -
|
|
|
|
|
textclasslist.TextClass(params.textclass).maxcounter());
|
2000-06-12 11:27:15 +00:00
|
|
|
|
tmp.str = par->String(this, true);
|
2000-05-20 21:37:05 +00:00
|
|
|
|
l[TOC_TOC].push_back(tmp);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
2000-07-19 17:16:27 +00:00
|
|
|
|
#ifndef NEW_INSETS
|
2000-01-25 12:35:27 +00:00
|
|
|
|
}
|
2000-07-19 17:16:27 +00:00
|
|
|
|
#endif
|
1999-09-27 18:44:28 +00:00
|
|
|
|
par = par->next;
|
|
|
|
|
}
|
2000-05-19 16:46:01 +00:00
|
|
|
|
return l;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-09-14 17:53:12 +00:00
|
|
|
|
|
2000-01-08 21:02:58 +00:00
|
|
|
|
// This is also a buffer property (ale)
|
2000-09-14 17:53:12 +00:00
|
|
|
|
vector<pair<string,string> > const Buffer::getBibkeyList()
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
|
|
|
|
/// if this is a child document and the parent is already loaded
|
|
|
|
|
/// Use the parent's list instead [ale990412]
|
|
|
|
|
if (!params.parentname.empty() && bufferlist.exists(params.parentname)) {
|
1999-12-10 00:07:59 +00:00
|
|
|
|
Buffer * tmp = bufferlist.getBuffer(params.parentname);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
if (tmp)
|
2000-06-07 08:53:40 +00:00
|
|
|
|
return tmp->getBibkeyList();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-06-08 23:16:16 +00:00
|
|
|
|
vector<pair<string, string> > keys;
|
1999-11-04 01:40:20 +00:00
|
|
|
|
LyXParagraph * par = paragraph;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
while (par) {
|
2000-06-07 08:53:40 +00:00
|
|
|
|
if (par->bibkey)
|
2000-07-19 17:16:27 +00:00
|
|
|
|
keys.push_back(pair<string, string>(par->bibkey->getContents(),
|
2000-06-12 11:27:15 +00:00
|
|
|
|
par->String(this, false)));
|
1999-09-27 18:44:28 +00:00
|
|
|
|
par = par->next;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Might be either using bibtex or a child has bibliography
|
2000-06-07 08:53:40 +00:00
|
|
|
|
if (keys.empty()) {
|
2000-05-19 16:46:01 +00:00
|
|
|
|
for (inset_iterator it = inset_iterator_begin();
|
2000-06-07 08:53:40 +00:00
|
|
|
|
it != inset_iterator_end(); ++it) {
|
1999-09-27 18:44:28 +00:00
|
|
|
|
// Search for Bibtex or Include inset
|
2000-05-19 16:46:01 +00:00
|
|
|
|
if ((*it)->LyxCode() == Inset::BIBTEX_CODE) {
|
2000-06-07 08:53:40 +00:00
|
|
|
|
vector<pair<string,string> > tmp =
|
2000-10-03 09:13:34 +00:00
|
|
|
|
static_cast<InsetBibtex*>(*it)->getKeys(this);
|
2000-06-07 08:53:40 +00:00
|
|
|
|
keys.insert(keys.end(), tmp.begin(), tmp.end());
|
2000-05-19 16:46:01 +00:00
|
|
|
|
} else if ((*it)->LyxCode() == Inset::INCLUDE_CODE) {
|
2000-09-26 13:54:57 +00:00
|
|
|
|
vector<pair<string,string> > const tmp =
|
2000-06-07 08:53:40 +00:00
|
|
|
|
static_cast<InsetInclude*>(*it)->getKeys();
|
|
|
|
|
keys.insert(keys.end(), tmp.begin(), tmp.end());
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2000-06-07 08:53:40 +00:00
|
|
|
|
return keys;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
1999-10-02 16:21:10 +00:00
|
|
|
|
bool Buffer::isDepClean(string const & name) const
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
1999-11-04 01:40:20 +00:00
|
|
|
|
DEPCLEAN * item = dep_clean;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
while (item && item->master != name)
|
|
|
|
|
item = item->next;
|
|
|
|
|
if (!item) return true;
|
|
|
|
|
return item->clean;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
1999-10-02 16:21:10 +00:00
|
|
|
|
void Buffer::markDepClean(string const & name)
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
|
|
|
|
if (!dep_clean) {
|
|
|
|
|
dep_clean = new DEPCLEAN;
|
|
|
|
|
dep_clean->clean = true;
|
|
|
|
|
dep_clean->master = name;
|
1999-10-02 16:21:10 +00:00
|
|
|
|
dep_clean->next = 0;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
} else {
|
2000-09-26 13:54:57 +00:00
|
|
|
|
DEPCLEAN * item = dep_clean;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
while (item && item->master != name)
|
|
|
|
|
item = item->next;
|
|
|
|
|
if (item) {
|
|
|
|
|
item->clean = true;
|
|
|
|
|
} else {
|
|
|
|
|
item = new DEPCLEAN;
|
|
|
|
|
item->clean = true;
|
|
|
|
|
item->master = name;
|
2000-05-26 00:00:02 +00:00
|
|
|
|
item->next = 0;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
2000-01-08 21:02:58 +00:00
|
|
|
|
|
2000-04-28 11:18:04 +00:00
|
|
|
|
bool Buffer::Dispatch(string const & command)
|
1999-12-10 00:07:59 +00:00
|
|
|
|
{
|
|
|
|
|
// Split command string into command and argument
|
2000-09-26 13:54:57 +00:00
|
|
|
|
string cmd;
|
|
|
|
|
string line = frontStrip(command);
|
|
|
|
|
string const arg = strip(frontStrip(split(line, cmd, ' ')));
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
2000-09-26 13:54:57 +00:00
|
|
|
|
return Dispatch(lyxaction.LookupFunc(cmd), arg);
|
1999-12-10 00:07:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-01-08 21:02:58 +00:00
|
|
|
|
|
2000-04-28 11:18:04 +00:00
|
|
|
|
bool Buffer::Dispatch(int action, string const & argument)
|
1999-12-10 00:07:59 +00:00
|
|
|
|
{
|
2000-04-28 11:18:04 +00:00
|
|
|
|
bool dispatched = true;
|
1999-12-10 00:07:59 +00:00
|
|
|
|
switch (action) {
|
1999-12-15 17:42:22 +00:00
|
|
|
|
case LFUN_EXPORT:
|
2000-08-30 03:40:51 +00:00
|
|
|
|
Exporter::Export(this, argument, false);
|
1999-12-15 17:42:22 +00:00
|
|
|
|
break;
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
|
|
|
|
default:
|
2000-04-28 11:18:04 +00:00
|
|
|
|
dispatched = false;
|
|
|
|
|
}
|
|
|
|
|
return dispatched;
|
1999-12-10 00:07:59 +00:00
|
|
|
|
}
|
2000-04-10 21:40:13 +00:00
|
|
|
|
|
2000-04-26 13:57:28 +00:00
|
|
|
|
|
2000-06-23 15:02:46 +00:00
|
|
|
|
void Buffer::resize()
|
|
|
|
|
{
|
2000-07-14 14:57:20 +00:00
|
|
|
|
/// resize the BufferViews!
|
|
|
|
|
if (users)
|
2000-06-23 15:02:46 +00:00
|
|
|
|
users->resize();
|
2000-07-14 14:57:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Buffer::resizeInsets(BufferView * bv)
|
|
|
|
|
{
|
2000-06-23 15:02:46 +00:00
|
|
|
|
/// then remove all LyXText in text-insets
|
|
|
|
|
LyXParagraph * par = paragraph;
|
2000-11-04 10:00:12 +00:00
|
|
|
|
for (; par; par = par->next) {
|
2000-07-14 14:57:20 +00:00
|
|
|
|
par->resizeInsetsLyXText(bv);
|
2000-06-23 15:02:46 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2000-04-10 21:40:13 +00:00
|
|
|
|
void Buffer::ChangeLanguage(Language const * from, Language const * to)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
LyXParagraph * par = paragraph;
|
|
|
|
|
while (par) {
|
2000-06-08 23:16:16 +00:00
|
|
|
|
par->ChangeLanguage(params, from, to);
|
2000-04-10 21:40:13 +00:00
|
|
|
|
par = par->next;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2000-04-26 13:57:28 +00:00
|
|
|
|
|
2000-04-10 21:40:13 +00:00
|
|
|
|
bool Buffer::isMultiLingual()
|
|
|
|
|
{
|
|
|
|
|
LyXParagraph * par = paragraph;
|
|
|
|
|
while (par) {
|
2000-06-08 23:16:16 +00:00
|
|
|
|
if (par->isMultiLingual(params))
|
2000-04-10 21:40:13 +00:00
|
|
|
|
return true;
|
|
|
|
|
par = par->next;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2000-05-19 16:46:01 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Buffer::inset_iterator::inset_iterator(LyXParagraph * paragraph,
|
|
|
|
|
LyXParagraph::size_type pos)
|
2000-09-26 13:54:57 +00:00
|
|
|
|
: par(paragraph)
|
|
|
|
|
{
|
2000-05-19 16:46:01 +00:00
|
|
|
|
it = par->InsetIterator(pos);
|
|
|
|
|
if (it == par->inset_iterator_end()) {
|
|
|
|
|
par = par->next;
|
|
|
|
|
SetParagraph();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2000-09-26 13:54:57 +00:00
|
|
|
|
void Buffer::inset_iterator::SetParagraph()
|
|
|
|
|
{
|
2000-05-19 16:46:01 +00:00
|
|
|
|
while (par) {
|
|
|
|
|
it = par->inset_iterator_begin();
|
|
|
|
|
if (it != par->inset_iterator_end())
|
|
|
|
|
return;
|
|
|
|
|
par = par->next;
|
|
|
|
|
}
|
|
|
|
|
//it = 0;
|
2000-05-20 21:37:05 +00:00
|
|
|
|
// We maintain an invariant that whenever par = 0 then it = 0
|
2000-05-19 16:46:01 +00:00
|
|
|
|
}
|