*
* LyX, The Document Processor
*
- * Copyright (C) 1995 Matthias Ettrich
- * Copyright (C) 1995-1998 The LyX Team.
+ * Copyright 1995 Matthias Ettrich
+ * Copyright 1995-1999 The LyX Team.
*
- * This file is Copyright (C) 1996-1998
+ * This file is Copyright 1996-1999
* Lars Gullik Bjønnes
*
- *======================================================
+ * ======================================================
*/
// Change Log:
#include <config.h>
-#include <stdlib.h>
+#include <cstdlib>
#include <unistd.h>
#ifdef __GNUG__
#include "insets/insetparent.h"
#include "insets/insetspecialchar.h"
#include "insets/figinset.h"
-#include "filetools.h"
-#include "pathstack.h"
+#include "support/filetools.h"
+#include "support/path.h"
#include "LaTeX.h"
#include "Literate.h"
#include "Chktex.h"
#include "LyXView.h"
-#include "error.h"
+#include "debug.h"
#include "LaTeXFeatures.h"
-#include "syscall.h"
-#include "lyxlib.h"
-#include "FileInfo.h"
+#include "support/syscall.h"
+#include "support/lyxlib.h"
+#include "support/FileInfo.h"
#include "lyxtext.h"
#include "gettext.h"
-
-// $Id: buffer.C,v 1.2 1999/10/02 14:01:03 larsbj Exp $
-
-#if !defined(lint) && !defined(WITH_WARNINGS)
-static char vcid[] = "$Id: buffer.C,v 1.2 1999/10/02 14:01:03 larsbj Exp $";
-#endif /* lint */
-
-
// Uncomment this line to enable a workaround for the weird behaviour
// of the cursor between a displayed inset and last character
// at the upper line. (Alejandro 20.9.96)
extern void FreeUpdateTimer();
-Buffer::Buffer(LString const & file, LyXRC *lyxrc, bool ronly)
+Buffer::Buffer(string const & file, LyXRC *lyxrc, bool ronly)
{
filename = file;
filepath = OnlyPath(file);
- paragraph = NULL;
- text = NULL;
- the_locking_inset = NULL;
+ paragraph = 0;
+ text = 0;
+ the_locking_inset = 0;
lyx_clean = true;
bak_clean = true;
dvi_clean_orgd = false; // Heinrich Bauer, 23/03/98
dvi_clean_tmpd = false; // Heinrich Bauer, 23/03/98
- dep_clean = NULL;
+ dep_clean = 0;
read_only = ronly;
inset_slept = false;
users = 0;
lyxvc.setBuffer(this);
- lyxerr.debug("Buffer::Buffer()");
+ lyxerr.debug() << "Buffer::Buffer()" << endl;
if (read_only || (lyxrc && lyxrc->use_tempdir)) {
tmppath = CreateBufferTmpDir();
- } else tmppath.clean();
+ } else tmppath.erase();
}
Buffer::~Buffer()
{
- lyxerr.debug("Buffer::~Buffer()");
+ lyxerr.debug() << "Buffer::~Buffer()" << endl;
// here the buffer should take care that it is
// saved properly, before it goes into the void.
delete par;
par = tmppar;
}
- paragraph = NULL;
+ paragraph = 0;
delete text;
}
bool Buffer::saveParamsAsDefaults()
{
- LString fname = AddName(AddPath(user_lyxdir, "templates/"),
+ string fname = AddName(AddPath(user_lyxdir, "templates/"),
"defaults.lyx");
Buffer defaults = Buffer(fname);
}
-void Buffer::setFileName(LString const & newfile)
+void Buffer::setFileName(string const & newfile)
{
filename = MakeAbsPath(newfile);
filepath = OnlyPath(filename);
{
if (the_locking_inset) {
if (!inset_slept) the_locking_inset->InsetUnlock();
- the_locking_inset = NULL;
+ the_locking_inset = 0;
text->FinishUndo();
inset_slept = false;
}
// Inserts a file into current document
-bool Buffer::insertLyXFile(LString const & filen)
+bool Buffer::insertLyXFile(string const & filen)
//
// (c) CHT Software Service GmbH
// Uwe C. Schroeder
{
if (filen.empty()) return false;
- LString filename = MakeAbsPath(filen);
+ string filename = MakeAbsPath(filen);
// check if file exist
FileInfo fi(filename);
MakeDisplayPath(filename,50));
return false;
}
- LyXLex lex(NULL, 0);
+ LyXLex lex(0, 0);
lex.setFile(myfile);
int c = fgetc(myfile());
ungetc(c, myfile);
bool res = true;
if (c=='#') {
- lyxerr.debug("Will insert file with header");
+ lyxerr.debug() << "Will insert file with header" << endl;
res = readFile(lex, text->cursor.par);
} else {
- lyxerr.debug("Will insert file without header");
+ lyxerr.debug() << "Will insert file without header" << endl;
res = readLyXformat2(lex, text->cursor.par);
}
resize();
//
// Uwe C. Schroeder
// changed to be public and have one parameter
-// if par = NULL normal behavior
+// if par = 0 normal behavior
// else insert behavior
// Returns false if "\the_end" is not read for formats >= 2.13. (Asger)
bool Buffer::readLyXformat2(LyXLex &lex, LyXParagraph *par)
{
- LString tmptok;
+ string tmptok;
Inset *inset = 0;
int pos = 0;
int tmpret, tmpret2;
LyXParagraph::footnote_kind footnotekind = LyXParagraph::FOOTNOTE;
bool the_end_read = false;
- LyXParagraph *return_par = NULL;
+ LyXParagraph *return_par = 0;
LyXFont font = LyXFont(LyXFont::ALL_INHERIT);
// If we are inserting, we cheat and get a token in advance
bool has_token = false;
- LString pretoken;
+ string pretoken;
if(!par) {
par = new LyXParagraph();
}
// Profiling show this should give a lot: (Asger)
- LString const token = pretoken;
+ string const token = pretoken;
if (token.empty())
continue;
// I can substitute but I don't see how I can
// stop loading... ideas?? ARRae980418
WriteAlert(_("Textclass Loading Error!"),
- LString(_("Can't load textclass ")) +
+ string(_("Can't load textclass ")) +
lyxstyle.NameOfClass(params.textclass),
_("-- substituting default"));
params.textclass = 0;
params.footskip = lex.GetString();
} else if (token == "\\paperfontsize") {
lex.nextToken();
- params.fontsize = lex.GetString();
- params.fontsize.strip();
+ params.fontsize = strip(lex.GetString());
} else if (token == "\\papercolumns") {
lex.nextToken();
params.columns = lex.GetInteger();
params.sides = lex.GetInteger();
} else if (token == "\\paperpagestyle") {
lex.nextToken();
- params.pagestyle = lex.GetString();
- params.pagestyle.strip();
+ params.pagestyle = strip(lex.GetString());
} else if (token == "\\bullet") {
lex.nextToken();
int index = lex.GetInteger();
params.user_defined_bullets[index].setSize(temp_int);
params.temp_bullets[index].setSize(temp_int);
lex.nextToken();
- LString temp_str = lex.GetString();
+ string temp_str = lex.GetString();
if (temp_str != "\\end_bullet") {
// this element isn't really necessary for
// parsing but is easier for humans
lex.nextToken();
int index = lex.GetInteger();
lex.next();
- LString temp_str = lex.GetString(), sum_str;
+ string temp_str = lex.GetString(), sum_str;
while (temp_str != "\\end_bullet") {
// this loop structure is needed when user
// enters an empty string since the first
params.spacing.set(Spacing::Other, lex.GetFloat());
} else if (token == "\\spacing") {
lex.next();
- LString tmp = lex.GetString().strip();
+ string tmp = strip(lex.GetString());
if (tmp == "single") {
params.spacing.set(Spacing::Single);
} else if (tmp == "onehalf") {
font.setLyXSize(lex.GetString());
} else if (token == "\\latex") {
lex.next();
- LString tok = lex.GetString();
+ string tok = lex.GetString();
// This is dirty, but gone with LyX3. (Asger)
if (tok == "no_latex")
font.setLatex(LyXFont::OFF);
font.setEmph(font.setLyXMisc(lex.GetString()));
} else if (token == "\\bar") {
lex.next();
- LString tok = lex.GetString();
+ string tok = lex.GetString();
// This is dirty, but gone with LyX3. (Asger)
if (tok == "under")
font.setUnderbar(LyXFont::ON);
} else if (tmptok == "Latex") {
// This one is on its way out
lex.EatLine();
- tmptok = lex.GetString().strip();
- //lyxerr.print(LString(tmptok[0]));
+ tmptok = strip(lex.GetString());
+ //lyxerr <<string(tmptok[0]));
if (tmptok[0] == '\\') {
// then this latex is a
// latex command
} else if (tmptok == "LatexDel") {
// This one is on its way out...
lex.EatLine();
- tmptok = lex.GetString().strip();
- //lyxerr.print(LString(tmptok[0]));
+ tmptok = strip(lex.GetString());
+ //lyxerr <<string(tmptok[0]));
if (tmptok == "\\tableofcontents") {
inset = new InsetTOC(this);
} else if (tmptok == "\\listoffigures") {
inset = new InsetLOT(this);
} else if (tmptok == "\\listofalgorithms") {
inset = new InsetLOA(this);
- } else if (tmptok.contains("\\ref{")
- || tmptok.contains("\\pageref{")) {
+ } else if (contains(tmptok, "\\ref{")
+ || contains(tmptok, "\\pageref{")) {
inset = new InsetRef(tmptok, this);
- } else if (tmptok.contains("\\url{")
- || tmptok.contains("\\htmlurl{")) {
- LString cont,opt,tmptmptok,cmdname;
+ } else if (contains(tmptok, "\\url{")
+ || contains(tmptok, "\\htmlurl{")) {
+ string cont,opt,tmptmptok,cmdname;
lex.next();
while(lex.IsOK() && lex.GetString() != "\\end_inset" ) {
lex.next();
while(lex.IsOK() && lex.GetString() != "\\end_inset" ) {
lex.next();
}
- if(tmptok.contains("\\url{"))
- cmdname = LString("url");
+ if(contains(tmptok, "\\url{"))
+ cmdname = string("url");
else
- cmdname = LString("htmlurl");
- cont.strip();
- opt.strip();
+ cmdname = string("htmlurl");
+ cont = strip(cont);
+ opt = strip(opt);
inset = new InsetUrl(cmdname,cont,opt);
} else if (tmptok[0] == '\\') {
// then this latex del is a
} else if (tmptok == "Label") {
// Kept for compability. Remove in 0.13.
if (lex.EatLine()) {
- LString tmp;
+ string tmp;
tmp += "\\label{";
tmp += lex.GetString();
tmp += '}';
par->SetFont(pos, font);
pos++;
} else if (tmptok == "Include") {
- inset = new InsetInclude(LString(), this);
+ inset = new InsetInclude(string(), this);
inset->Read(lex);
par->InsertChar(pos, LYX_META_INSET);
par->InsertInset(pos, inset);
to the latexdel ref inset that was transformed to an empty ref
inset plus the body surronded by latexdel insets */
else {
- LString cont,opt,tmptmptok,cmdname;
+ string cont,opt,tmptmptok,cmdname;
lex.next();
while(lex.IsOK() && lex.GetString() != "\\end_inset" ) {
lex.next();
lex.next();
}
- cont.strip();
- opt.strip();
+ cont = strip(cont);
+ opt = strip(opt);
cmdname = "\\" + inscmd.getCmdName();
cmdname += "[" + cont + "]";
cmdname += "{" + opt + "}";
bool Buffer::readFile(LyXLex &lex, LyXParagraph *par)
{
- LString token;
+ string token;
if (lex.IsOK()) {
lex.next();
// Returns false if unsuccesful
-bool Buffer::writeFile(LString const & filename, bool flag)
+bool Buffer::writeFile(string const & filename, bool flag)
{
// if flag is false writeFile will not create any GUI
- // warnings, only stderr.
+ // warnings, only cerr.
// Needed for autosave in background or panic save (Matthias 120496)
if (read_only && (filename == this->filename)) {
// Here we should come with a question if we should
// perform the write anyway.
if (flag)
- lyxerr.print(_("Error! Document is read-only: ") + filename);
+ lyxerr << _("Error! Document is read-only: ")
+ << filename << endl;
else
WriteAlert(_("Error! Document is read-only: "), filename);
return false;
// Here we should come with a question if we should
// try to do the save anyway. (i.e. do a chmod first)
if (flag)
- lyxerr.print(_("Error! Cannot write file: ") + filename);
+ lyxerr << _("Error! Cannot write file: ")
+ << filename << endl;
else
WriteFSAlert(_("Error! Cannot write file: "), filename);
return false;
FilePtr file(filename, FilePtr::truncate);
if (!file()) {
if (flag)
- lyxerr.print(_("Error! Cannot write file: ") + filename);
+ lyxerr << _("Error! Cannot write file: ")
+ << filename << endl;
else
WriteFSAlert(_("Error! Cannot write file: "), filename);
return false;
}
// The top of the file should not be written by params.
// collect some very important information
- LString userName(getUserName()) ;
+ string userName(getUserName()) ;
// write out a comment in the top of the file
fprintf(file,
fprintf(file, "\n\\the_end\n");
if (file.close()) {
if (flag)
- lyxerr.print(_("Error! Could not close file properly: ")
- + filename);
+ lyxerr << _("Error! Could not close file properly: ")
+ << filename << endl;
else
WriteFSAlert(_("Error! Could not close file properly: "),
filename);
}
-void Buffer::writeFileAscii(LString const & filename, int linelen)
+void Buffer::writeFileAscii(string const & filename, int linelen)
{
FilePtr file(filename, FilePtr::write);
LyXFont
footnoteflag = 0,
depth = 0;
- LString
+ string
fname1,
tmp;
ltype_depth=0,
noparbreak=0,
islatex=0,
- *clen=NULL,
+ *clen=0,
actcell=0,
actpos=0,
cell=0,
} else if (c != '\0')
fprintf(file, "%c", c);
else if (c == '\0')
- lyxerr.debug("writeAsciiFile: NULL char in structure.");
+ lyxerr.debug() << "writeAsciiFile: NULL char in structure." << endl;
currlinelen++;
break;
}
}
-void Buffer::makeLaTeXFile(LString const & filename,
- LString const & original_path,
+void Buffer::makeLaTeXFile(string const & filename,
+ string const & original_path,
bool nice, bool only_body)
{
- lyxerr.debug("makeLaTeXFile...", Error::LATEX);
+ lyxerr[Debug::LATEX] << "makeLaTeXFile..." << endl;
params.textclass = GetCurrentTextClass();
niceFile = nice; // this will be used by Insetincludes.
}
// validate the buffer.
- lyxerr.debug(" Validating buffer...", Error::LATEX);
+ lyxerr[Debug::LATEX] << " Validating buffer..." << endl;
LaTeXFeatures features(tclass->number_of_defined_layouts);
validate(features);
- lyxerr.debug(" Buffer validation done.", Error::LATEX);
+ 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);
- LString userName(getUserName());
- LString LFile;
+ string userName(getUserName());
+ string LFile;
if (!only_body && nice) {
LFile += "%% This LaTeX-file was created by <";
texrow.newline();
texrow.newline();
}
- lyxerr.debug("lyx header finished");
+ lyxerr.debug() << "lyx header finished" << endl;
// There are a few differences between nice LaTeX and usual files:
// usual is \batchmode, uses \listfiles and has a
// special input@path to allow the including of figures
LFile += "\\documentclass";
- LString options; // the document class options.
+ string options; // the document class options.
- if (tclass->opt_fontsize.tokenPos('|',params.fontsize) >= 0) {
+ if (tokenPos(tclass->opt_fontsize, '|',params.fontsize) >= 0) {
// only write if existing in list (and not default)
options += params.fontsize;
options += "pt,";
}
if (!options.empty()){
- options.strip(',');
+ options = strip(options, ',');
LFile += '[';
LFile += options;
LFile += ']';
texrow.newline();
}
if (params.use_amsmath
- && !lyxstyle.LatexnameOfClass(params.textclass).prefixIs("ams")) {
+ && !prefixIs(lyxstyle.LatexnameOfClass(params.textclass), "ams")) {
LFile += "\\usepackage{amsmath}\n";
}
- if (tclass->opt_pagestyle.tokenPos('|',params.pagestyle) >= 0) {
+ if (tokenPos(tclass->opt_pagestyle, '|',params.pagestyle) >= 0) {
if (params.pagestyle == "fancy") {
LFile += "\\usepackage{fancyhdr}\n";
texrow.newline();
// Write out what we've generated so far...and reset LFile
fwrite(LFile.c_str(), sizeof(char), LFile.length(), file);
- LFile.clean();
+ LFile.erase();
// Now insert the LyX specific LaTeX commands...
- LString preamble, tmppreamble;
+ string preamble, tmppreamble;
// The optional packages;
preamble = features.getPackages(params);
}
}
- for (int j = preamble.countChar('\n'); j-- ;) {
+ for (int j = countChar(preamble, '\n'); j-- ;) {
texrow.newline();
}
texrow.newline();
texrow.newline();
} // only_body
- lyxerr.debug("preamble finished, now the body.");
+ lyxerr.debug() << "preamble finished, now the body." << endl;
bool was_title = false;
bool already_title = false;
- LString ftnote;
+ string ftnote;
TexRow ft_texrow;
int ftcount = 0;
int loop_count = 0;
while (par) {
++loop_count;
if (par->IsDummy())
- lyxerr.debug("Error in MakeLateXFile.", Error::LATEX);
+ lyxerr[Debug::LATEX] << "Error in MakeLateXFile."
+ << endl;
LyXLayout * layout = lyxstyle.Style(params.textclass,
par->layout);
if (layout->intitle) {
if (already_title) {
- lyxerr.print("Error in MakeLatexFile: You"
- " should not mix title layouts"
- " with normal ones.");
+ lyxerr <<"Error in MakeLatexFile: You"
+ " should not mix title layouts"
+ " with normal ones." << endl;
} else
was_title = true;
} else if (was_title && !already_title) {
}
LFile += ftnote;
texrow += ft_texrow;
- ftnote.clean();
+ ftnote.erase();
ft_texrow.reset();
ftcount = 0;
}
// LFile.length() in a future revision. ARRae
fwrite(LFile.c_str(), sizeof(char),
LFile.length(), file);
- LFile.clean();
+ LFile.erase();
loop_count = 0;
}
}
LFile += "\\end{document}\n";
texrow.newline();
- lyxerr.debug("makeLaTeXFile...done", Error::LATEX);
+ lyxerr[Debug::LATEX] << "makeLaTeXFile...done" << endl;
} else {
- lyxerr.debug("LaTeXFile for inclusion made.", Error::LATEX);
+ lyxerr[Debug::LATEX] << "LaTeXFile for inclusion made."
+ << endl;
}
// Just to be sure. (Asger)
// Write out what we've generated...and reset LFile
fwrite(LFile.c_str(), sizeof(char), LFile.length(), file);
- LFile.clean();
+ LFile.erase();
// tex_code_break_column's value is used to decide
// if we are in batchmode or not (within mathed_write()
if (file.close()) {
WriteFSAlert(_("Error! Could not close file properly:"), filename);
}
- lyxerr.debug("Finished making latex file.");
+ lyxerr.debug() << "Finished making latex file." << endl;
}
}
-void Buffer::sgmlOpenTag(FILE * file,int depth,LString & latexname)
+void Buffer::sgmlOpenTag(FILE * file,int depth,string & latexname)
{
static char *space[] = {" "," "," "," "," "," "," ",
" "," "," "," "};
}
-void Buffer::sgmlCloseTag(FILE * file,int depth,LString & latexname)
+void Buffer::sgmlCloseTag(FILE * file,int depth,string & latexname)
{
static char *space[] = {" "," "," "," "," "," "," ",
" "," "," "," "};
}
-void Buffer::makeLinuxDocFile(LString const & filename, int column)
+void Buffer::makeLinuxDocFile(string const & filename, int column)
{
LyXParagraph *par = paragraph;
- LString top_element=lyxstyle.LatexnameOfClass(params.textclass);
- LString environment_stack[10];
- LString item_name;
+ string top_element=lyxstyle.LatexnameOfClass(params.textclass);
+ string environment_stack[10];
+ string item_name;
int depth=0; /* paragraph depth */
params.preamble.c_str() );
}
- LString userName(getUserName());
+ string userName(getUserName());
fprintf(file, "<!-- LinuxDoc file was created by LyX 1.0 (C) 1995-1999 ");
fprintf(file, "by <%s> %s -->\n", userName.c_str(), (char *)date());
if(params.options.empty())
sgmlOpenTag(file,0,top_element);
else {
- LString top = top_element;
+ string top = top_element;
top += " ";
top += params.options;
sgmlOpenTag(file,0,top);
Inset *inset = par->GetInset(0);
char lyx_code = inset->LyxCode();
if (lyx_code ==Inset::TOC_CODE){
- LString temp= "toc";
+ string temp= "toc";
sgmlOpenTag(file, depth, temp);
par = par->next;
/* environment tag closing */
for( ;depth > par->depth; depth--) {
sgmlCloseTag(file,depth,environment_stack[depth]);
- environment_stack[depth].clean();
+ environment_stack[depth].erase();
}
/* write opening SGML tags */
if(depth == par->depth
&& !environment_stack[depth].empty()) {
sgmlCloseTag(file,depth,environment_stack[depth]);
- environment_stack[depth].clean();
+ environment_stack[depth].erase();
if(depth)
depth--;
else
fprintf(file, "</p>");
}
- environment_stack[depth].clean();
+ environment_stack[depth].erase();
sgmlOpenTag(file,depth, style->latexname);
break;
&& !environment_stack[depth].empty()) {
sgmlCloseTag(file,depth,environment_stack[depth]);
- environment_stack[depth].clean();
+ environment_stack[depth].erase();
}
if (depth < par->depth) {
depth = par->depth;
- environment_stack[depth].clean();
+ environment_stack[depth].erase();
}
if (environment_stack[depth] != style->latexname) {
if(depth==0) {
- LString temp="p";
+ string temp="p";
sgmlOpenTag(file,depth,temp);
}
environment_stack[depth]= style->latexname;
void Buffer::linuxDocHandleFootnote(FILE *file,LyXParagraph* &par, int const depth)
{
- LString tag="footnote";
+ string tag="footnote";
while (par && par->footnoteflag != LyXParagraph::NO_FOOTNOTE) {
sgmlOpenTag(file,depth+1,tag);
}
}
-void Buffer::DocBookHandleCaption(FILE *file, LString &inner_tag,
+void Buffer::DocBookHandleCaption(FILE *file, string &inner_tag,
int const depth, int desc_on,
LyXParagraph* &par)
{
LyXParagraph *tpar = par;
- LString tmp_par, extra_par;
+ string tmp_par, extra_par;
while (tpar && (tpar->footnoteflag != LyXParagraph::NO_FOOTNOTE) &&
(tpar->layout != lyxstyle.NumberOfLayout(params.textclass,"Caption")))
tpar = tpar->next;
tpar->layout==lyxstyle.NumberOfLayout(params.textclass,"Caption")) {
sgmlOpenTag(file,depth+1,inner_tag);
SimpleDocBookOnePar(tmp_par,extra_par,tpar,desc_on,depth+2);
- tmp_par.strip();
- tmp_par.frontStrip();
+ tmp_par = strip(tmp_par);
+ tmp_par = frontStrip(tmp_par);
fprintf(file,"%s",tmp_par.c_str());
sgmlCloseTag(file,depth+1,inner_tag);
if(!extra_par.empty())
void Buffer::DocBookHandleFootnote(FILE *file,LyXParagraph* &par, int const depth)
{
- LString tag,inner_tag;
- LString tmp_par,extra_par;
- bool inner_span;
+ string tag,inner_tag;
+ string tmp_par,extra_par;
+ bool inner_span = false;
int desc_on=4;
// This is not how I like to see enums. They should not be anonymous
if(inner_span) {
if(!tmp_par.empty()) {
fprintf(file,"%s",tmp_par.c_str());
- tmp_par.clean();
+ tmp_par.erase();
sgmlCloseTag(file,depth+1,inner_tag);
sgmlOpenTag(file,depth+1,inner_tag);
}
if(!inner_tag.empty()) sgmlCloseTag(file,depth+1,inner_tag);
if(!extra_par.empty()) fprintf(file,"%s",extra_par.c_str());
if(!tag.empty()) sgmlCloseTag(file,depth,tag);
- extra_par.clean();
+ extra_par.erase();
switch (par->footnotekind) {
case LyXParagraph::FOOTNOTE:
if ((present == TAB_LIKE) || (present == FIG_LIKE)) {
DocBookHandleCaption(file, inner_tag, depth,
desc_on, par);
- inner_tag.clean();
+ inner_tag.erase();
} else {
sgmlOpenTag(file,depth+1,inner_tag);
}
SimpleDocBookOnePar(tmp_par,extra_par,par,
desc_on,depth+2);
}
- tmp_par.strip();
- tmp_par.frontStrip();
+ tmp_par = frontStrip(strip(tmp_par));
last=present;
par = par->next;
char_line_count++;
} else if (c == LYX_META_INSET) {
inset = par->GetInset(i);
- LString tmp_out;
+ string tmp_out;
inset->Linuxdoc(tmp_out);
fprintf(file,"%s",tmp_out.c_str());
}
else {
- LString sgml_string;
+ string sgml_string;
if (par->linuxDocConvertChar(c, sgml_string)
&& !style->free_spacing) { // in freespacing
// mode, spaces are
enum { MAX_NEST_LEVEL = 25};
-void Buffer::makeDocBookFile(LString const & filename, int column)
+void Buffer::makeDocBookFile(string const & filename, int column)
{
LyXParagraph *par = paragraph;
- LString top_element=lyxstyle.LatexnameOfClass(params.textclass);
- LString environment_stack[MAX_NEST_LEVEL];
- LString environment_inner[MAX_NEST_LEVEL];
- LString command_stack[MAX_NEST_LEVEL];
+ string top_element=lyxstyle.LatexnameOfClass(params.textclass);
+ string environment_stack[MAX_NEST_LEVEL];
+ string environment_inner[MAX_NEST_LEVEL];
+ string command_stack[MAX_NEST_LEVEL];
bool command_flag=false;
- int command_depth=0,command_base,cmd_depth;
+ int command_depth=0,command_base=0,cmd_depth=0;
- LString item_name,command_name;
- LString c_depth,c_params,tmps;
+ string item_name,command_name;
+ string c_depth,c_params,tmps;
int depth=0; /* paragraph depth */
else
fprintf(file, "\n [ %s \n]>\n\n",params.preamble.c_str() );
- LString userName(getUserName());
+ string userName(getUserName());
fprintf(file,
"<!-- DocBook file was created by LyX 1.0 (C) 1995-1999\n");
fprintf(file, "by <%s> %s -->\n", userName.c_str(), (char *)date());
if(params.options.empty())
sgmlOpenTag(file,0,top_element);
else {
- LString top = top_element;
+ string top = top_element;
top += " ";
top += params.options;
sgmlOpenTag(file,0,top);
}
sgmlCloseTag(file,depth+command_depth,
environment_stack[depth]);
- environment_stack[depth].clean();
- environment_inner[depth].clean();
+ environment_stack[depth].erase();
+ environment_inner[depth].erase();
}
if(depth == par->depth
sgmlCloseTag(file,depth+command_depth,
environment_stack[depth]);
- environment_stack[depth].clean();
- environment_inner[depth].clean();
+ environment_stack[depth].erase();
+ environment_inner[depth].erase();
}
// Write opening SGML tags.
command_name=style->latexname;
tmps=style->latexparam;
- c_params=tmps.split(c_depth,'|');
+ c_params= split(tmps, c_depth,'|');
cmd_depth=atoi(c_depth.c_str());
case LATEX_ITEM_ENVIRONMENT:
if (depth < par->depth) {
depth = par->depth;
- environment_stack[depth].clean();
+ environment_stack[depth].erase();
}
if (environment_stack[depth] != style->latexname) {
}
do {
- LString tmp_par,extra_par;
+ string tmp_par,extra_par;
SimpleDocBookOnePar(tmp_par,extra_par, par, desc_on,
depth+1+command_depth);
}
while(par && par->IsDummy());
- LString end_tag;
+ string end_tag;
/* write closing SGML tags */
switch(style->latextype) {
case LATEX_COMMAND:
}
-void Buffer::SimpleDocBookOnePar(LString & file, LString & extra,
+void Buffer::SimpleDocBookOnePar(string & file, string & extra,
LyXParagraph * par, int & desc_on,
int const depth)
{
char c;
Inset *inset;
int main_body, j;
- LString emph="emphasis";
+ string emph="emphasis";
bool emph_flag=false;
int char_line_count=0;
if (c == LYX_META_INSET) {
inset = par->GetInset(i);
- LString tmp_out;
+ string tmp_out;
inset->DocBook(tmp_out);
//
// This code needs some explanation:
if(desc_on!=3 || i!=0) {
if(tmp_out[0]=='@') {
if(desc_on==4)
- extra += tmp_out.frontStrip('@');
+ extra += frontStrip(tmp_out, '@');
else
- file += tmp_out.frontStrip('@');
+ file += frontStrip(tmp_out, '@');
}
else
file += tmp_out;
char_line_count++;
}
else {
- LString sgml_string;
+ string sgml_string;
if (par->linuxDocConvertChar(c, sgml_string)
&& !style->free_spacing) { // in freespacing
// mode, spaces are
ProhibitInput();
// get LaTeX-Filename
- LString name = SpaceLess(ChangeExtension (filename, ".tex", true));
+ string name = SpaceLess(ChangeExtension (filename, ".tex", true));
- LString path = OnlyPath(filename);
+ string path = OnlyPath(filename);
- LString org_path = path;
+ string org_path = path;
if (lyxrc->use_tempdir || (IsDirWriteable(path) < 1)) {
path = tmppath;
}
- PathPush(path); // path to LaTeX file
+ Path p(path); // path to LaTeX file
users->getOwner()->getMiniBuffer()->Set(_("Running LaTeX..."));
// Remove all error insets
users->updateScrollbar();
}
AllowInput();
- PathPop(); // path to LaTeX file
return latex.getNumErrors();
}
ProhibitInput();
// get LaTeX-Filename
- LString name = SpaceLess(ChangeExtension (filename, ".tex", true));
+ string name = SpaceLess(ChangeExtension (filename, ".tex", true));
// get Literate-Filename
- LString lit_name = SpaceLess(ChangeExtension (filename, lyxrc->literate_extension, true));
+ string lit_name = SpaceLess(ChangeExtension (filename, lyxrc->literate_extension, true));
- LString path = OnlyPath(filename);
+ string path = OnlyPath(filename);
- LString org_path = path;
+ string org_path = path;
if (lyxrc->use_tempdir || (IsDirWriteable(path) < 1)) {
path = tmppath;
}
- PathPush(path); // path to Literate file
+ Path p(path); // path to Literate file
users->getOwner()->getMiniBuffer()->Set(_("Running Literate..."));
// Remove all error insets
users->updateScrollbar();
}
AllowInput();
- PathPop(); // path to LaTeX file
return literate.getNumErrors();
}
ProhibitInput();
// get LaTeX-Filename
- LString name = SpaceLess(ChangeExtension (filename, ".tex", true));
+ string name = SpaceLess(ChangeExtension (filename, ".tex", true));
// get Literate-Filename
- LString lit_name = SpaceLess(ChangeExtension (filename, lyxrc->literate_extension, true));
+ string lit_name = SpaceLess(ChangeExtension (filename, lyxrc->literate_extension, true));
- LString path = OnlyPath(filename);
+ string path = OnlyPath(filename);
- LString org_path = path;
+ string org_path = path;
if (lyxrc->use_tempdir || (IsDirWriteable(path) < 1)) {
path = tmppath;
}
- PathPush(path); // path to Literate file
+ Path p(path); // path to Literate file
users->getOwner()->getMiniBuffer()->Set(_("Building Program..."));
// Remove all error insets
users->updateScrollbar();
}
AllowInput();
- PathPop(); // path to LaTeX file
return literate.getNumErrors();
}
ProhibitInput();
// get LaTeX-Filename
- LString name = SpaceLess(ChangeExtension (filename, ".tex", true));
- LString path = OnlyPath(filename);
+ string name = SpaceLess(ChangeExtension (filename, ".tex", true));
+ string path = OnlyPath(filename);
- LString org_path = path;
+ string org_path = path;
if (lyxrc->use_tempdir || (IsDirWriteable(path) < 1)) {
path = tmppath;
}
- PathPush(path); // path to LaTeX file
+ Path p(path); // path to LaTeX file
users->getOwner()->getMiniBuffer()->Set(_("Running chktex..."));
// Remove all error insets
users->updateScrollbar();
}
AllowInput();
- PathPop(); // path to LaTeX file
return res;
}
AllFloats(1,1);
while (more) {
- LString errortext;
+ string errortext;
int errorrow = 0;
if (firsterror) {
cell = 0;
char
c;
- LString
+ string
fname1,
fname2;
FILE
*fp,*fp2;
- fname1 = TmpFileName(LString(),"RAT1");
- fname2 = TmpFileName(LString(),"RAT2");
+ fname1 = TmpFileName(string(),"RAT1");
+ fname2 = TmpFileName(string(),"RAT2");
if (!(fp=fopen(fname1.c_str(),"w"))) {
WriteAlert(_("LYX_ERROR:"),
_("Cannot open temporary file:"), fname1);
if (c != '\0')
fprintf(fp, "%c", c);
else if (c == '\0')
- lyxerr.debug("RoffAsciiTable:"
- " NULL char in structure.");
+ lyxerr.debug()
+ << "RoffAsciiTable:"
+ " NULL char in structure." << endl;
break;
}
}
par->table->RoffEndOfCell(fp, cell);
fclose(fp);
- LString cmd = lyxrc->ascii_roff_command + " >" + fname2;
- cmd.subst("$$FName",fname1);
+ string cmd = lyxrc->ascii_roff_command + " >" + fname2;
+ subst(cmd, "$$FName",fname1);
Systemcalls one(Systemcalls::System, cmd);
- if (!(lyxerr.debugging(Error::ROFF))) {
+ if (!(lyxerr.debugging(Debug::ROFF))) {
remove(fname1.c_str());
}
if (!(fp=fopen(fname2.c_str(),"r"))) {
while (par) {
// We don't use "lyxerr.debug" because of speed. (Asger)
- if (lyxerr.debugging(Error::LATEX))
- lyxerr.print(LString("Paragraph: ") + long(par));
+ if (lyxerr.debugging(Debug::LATEX))
+ lyxerr << "Paragraph: " << par << endl;
// Now just follow the list of paragraphs and run
// validate on each of them.
}
}
- if (lyxerr.debugging(Error::LATEX)) {
+ if (lyxerr.debugging(Debug::LATEX)) {
features.showStruct(params);
}
}
}
-void Buffer::insertInset(Inset *inset, LString const &lout,
+void Buffer::insertInset(Inset *inset, string const &lout,
bool no_table)
{
// check for table/list in tables
0, 0,
VSpace(VSpace::NONE), VSpace(VSpace::NONE),
LYX_ALIGN_LAYOUT,
- LString(),
+ string(),
0);
update(-1);
/* This function should be in Buffer because it's a buffer's property (ale) */
-LString Buffer::getIncludeonlyList(char delim)
+string Buffer::getIncludeonlyList(char delim)
{
- LString list;
+ string list;
LyXParagraph *par = paragraph;
int pos;
Inset* inset;
&& insetinc->isNoLoad()) {
if (!list.empty())
list += delim;
- list += ChangeExtension(insetinc->getContents(), LString(), true);
+ list += ChangeExtension(insetinc->getContents(), string(), true);
}
}
pos++;
}
par = par->next;
}
- lyxerr.debug(LString("Includeonly(") + list + ')');
+ lyxerr.debug() << "Includeonly(" << list << ')' << endl;
return list;
}
/* This is also a buffer property (ale) */
-LString Buffer::getReferenceList(char delim)
+string Buffer::getReferenceList(char delim)
{
/// if this is a child document and the parent is already loaded
/// Use the parent's list instead [ale990407]
LyXParagraph *par = paragraph;
int pos;
Inset* inset;
- LString list;
+ string list;
while (par){
pos = -1;
while ((inset = par->ReturnNextInsetPointer(pos))){
}
par = par->next;
}
- lyxerr.debug(LString("References(") + list + LString(')'));
+ lyxerr.debug() << "References(" << list << ")" << endl;
return list;
}
/* This is also a buffer property (ale) */
-LString Buffer::getBibkeyList(char delim)
+string Buffer::getBibkeyList(char delim)
{
/// if this is a child document and the parent is already loaded
/// Use the parent's list instead [ale990412]
return tmp->getBibkeyList(delim);
}
- LString bibkeys;
+ string bibkeys;
LyXParagraph *par = paragraph;
while (par) {
if (par->bibkey) {
bibkeys += delim;
bibkeys += ((InsetBibtex*)inset)->getKeys();
} else if (inset-> LyxCode()==Inset::INCLUDE_CODE) {
- LString bk = ((InsetInclude*)inset)->getKeys();
+ string bk = ((InsetInclude*)inset)->getKeys();
if (!bk.empty()) {
if (!bibkeys.empty())
bibkeys += delim;
}
}
- lyxerr.debug(LString("Bibkeys(") + bibkeys + LString(')'));
+ lyxerr.debug() << "Bibkeys(" << bibkeys << ")" << endl;
return bibkeys;
}
// think how this will work in a multiwindo/buffer environment, all the
// cursors in all the views showing this buffer will move. (Lgb)
// OK, then no cursor action should be allowed in buffer. (ale)
-bool Buffer::gotoLabel(const LString &label)
+bool Buffer::gotoLabel(const string &label)
{
LyXParagraph *par = paragraph;
int pos;
Inset* inset;
- LString list;
+ string list;
while (par) {
pos = -1;
while ((inset = par->ReturnNextInsetPointer(pos))){
}
-bool Buffer::isDepClean(LString const & name) const
+bool Buffer::isDepClean(string const & name) const
{
DEPCLEAN* item = dep_clean;
while (item && item->master != name)
}
-void Buffer::markDepClean(LString const & name)
+void Buffer::markDepClean(string const & name)
{
if (!dep_clean) {
dep_clean = new DEPCLEAN;
dep_clean->clean = true;
dep_clean->master = name;
- dep_clean->next = NULL;
+ dep_clean->next = 0;
} else {
DEPCLEAN* item = dep_clean;
while (item && item->master != name)
item = new DEPCLEAN;
item->clean = true;
item->master = name;
- item->next = NULL;;
+ item->next = 0;;
}
}
//return false; // why use that in a void method??