#endif
#ifdef __GNUG__
-#pragma implementation "buffer.h"
+#pragma implementation
#endif
#include "buffer.h"
#include "tex-strings.h"
#include "layout.h"
#include "bufferview_funcs.h"
-#include "minibuffer.h"
#include "lyxfont.h"
#include "version.h"
#include "mathed/formulamacro.h"
#include "insets/insettabular.h"
#include "insets/insettheorem.h"
#include "insets/insetcaption.h"
+#include "insets/insetfloatlist.h"
#include "support/filetools.h"
#include "support/path.h"
+#include "support/os.h"
#include "LaTeX.h"
#include "Chktex.h"
#include "LyXView.h"
LyXParagraph * par = paragraph;
LyXParagraph * tmppar;
-#ifndef NEW_INSETS
- while (par) {
- tmppar = par->next_;
- delete par;
- par = tmppar;
- }
-#else
while (par) {
tmppar = par->next();
delete par;
par = tmppar;
}
-#endif
paragraph = 0;
}
{
int pos = 0;
char depth = 0; // signed or unsigned?
-#ifndef NEW_INSETS
- LyXParagraph::footnote_flag footnoteflag = LyXParagraph::NO_FOOTNOTE;
- LyXParagraph::footnote_kind footnotekind = LyXParagraph::FOOTNOTE;
-#endif
bool the_end_read = false;
LyXParagraph * return_par = 0;
parseSingleLyXformat2Token(lex, par, return_par,
pretoken, pos, depth,
font
-#ifndef NEW_INSETS
- , footnoteflag,
- footnotekind
-#endif
);
}
LyXParagraph *& return_par,
string const & token, int & pos,
char & depth, LyXFont & font
-#ifndef NEW_INSETS
- , LyXParagraph::footnote_flag & footnoteflag,
- LyXParagraph::footnote_kind & footnotekind
-#endif
)
{
bool the_end_read = false;
#ifndef NO_PEXTRA_REALLY
-#ifdef NEW_INSETS
// This is super temporary but is needed to get the compability
// mode for minipages work correctly together with new tabulars.
static int call_depth = 0;
++call_depth;
-#endif
bool checkminipage = false;
static LyXParagraph * minipar = 0;
static LyXParagraph * parBeforeMinipage = 0;
par->InsertInset(pos, inset, font);
++pos;
} else if (token == "\\layout") {
-#ifndef NEW_INSETS
- if (!return_par)
- return_par = par;
- else {
- par->fitToSize();
- par = new LyXParagraph(par);
- }
- pos = 0;
- lex.EatLine();
- string const layoutname = lex.GetString();
- pair<bool, LyXTextClass::LayoutList::size_type> pp
- = textclasslist.NumberOfLayout(params.textclass,
- layoutname);
- if (pp.first) {
- par->layout = pp.second;
- } else { // layout not found
- // use default layout "Standard" (0)
- 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;
- par->footnoteflag = footnoteflag;
- par->footnotekind = footnotekind;
- par->params.depth(depth);
- font = LyXFont(LyXFont::ALL_INHERIT, params.language);
- if (file_format < 216 && params.language->lang() == "hebrew")
- font.setLanguage(default_language);
-#else
lex.EatLine();
string const layoutname = lex.GetString();
pair<bool, LyXTextClass::LayoutList::size_type> pp
#if USE_CAPTION
}
#endif
-#endif
-#ifndef NEW_INSETS
- } else if (token == "\\end_float") {
- if (!return_par)
- return_par = par;
- else {
- par->fitToSize();
- par = new LyXParagraph(par);
- }
- footnotekind = LyXParagraph::FOOTNOTE;
- footnoteflag = LyXParagraph::NO_FOOTNOTE;
- pos = 0;
- lex.EatLine();
- par->layout = LYX_DUMMY_LAYOUT;
- font = LyXFont(LyXFont::ALL_INHERIT, params.language);
- if (file_format < 216 && params.language->lang() == "hebrew")
- font.setLanguage(default_language);
- } else if (token == "\\begin_float") {
- int tmpret = lex.FindToken(string_footnotekinds);
- 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;
-#else
+
} else if (token == "\\begin_float") {
// This is the compability reader. It can be removed in
// LyX version 1.3.0. (Lgb)
inset->Read(this, nylex);
par->InsertInset(pos, inset, font);
++pos;
-#endif
} else if (token == "\\begin_deeper") {
++depth;
} else if (token == "\\end_deeper") {
lyxerr << "WP:" << mini->width() << endl;
mini->width(tostr(par->params.pextraWidthp())+"%");
}
- mini->inset->par = par;
+ mini->inset.par = par;
// Insert the minipage last in the
// previous paragraph.
if (par->params.pextraHfill()) {
lyxerr << "WP:" << mini->width() << endl;
mini->width(tostr(par->params.pextraWidthp())+"%");
}
- mini->inset->par = minipar;
+ mini->inset.par = minipar;
// Insert the minipage last in the
// previous paragraph.
InsetCommandParams inscmd;
inscmd.Read(lex);
- if (inscmd.getCmdName() == "cite") {
+ string const cmdName = inscmd.getCmdName();
+
+ if (cmdName == "cite") {
inset = new InsetCitation(inscmd);
- } else if (inscmd.getCmdName() == "bibitem") {
+ } else if (cmdName == "bibitem") {
lex.printError("Wrong place for bibitem");
inset = new InsetBibKey(inscmd);
- } else if (inscmd.getCmdName() == "BibTeX") {
+ } else if (cmdName == "BibTeX") {
inset = new InsetBibtex(inscmd);
- } else if (inscmd.getCmdName() == "index") {
+ } else if (cmdName == "index") {
inset = new InsetIndex(inscmd);
- } else if (inscmd.getCmdName() == "include") {
+ } else if (cmdName == "include") {
inset = new InsetInclude(inscmd, *this);
- } else if (inscmd.getCmdName() == "label") {
+ } else if (cmdName == "label") {
inset = new InsetLabel(inscmd);
- } else if (inscmd.getCmdName() == "url"
- || inscmd.getCmdName() == "htmlurl") {
+ } else if (cmdName == "url"
+ || cmdName == "htmlurl") {
inset = new InsetUrl(inscmd);
- } else if (inscmd.getCmdName() == "ref"
- || inscmd.getCmdName() == "pageref"
- || inscmd.getCmdName() == "vref"
- || inscmd.getCmdName() == "vpageref"
- || inscmd.getCmdName() == "prettyref") {
+ } else if (cmdName == "ref"
+ || cmdName == "pageref"
+ || cmdName == "vref"
+ || cmdName == "vpageref"
+ || cmdName == "prettyref") {
if (!inscmd.getOptions().empty()
|| !inscmd.getContents().empty()) {
inset = new InsetRef(inscmd, *this);
}
- } else if (inscmd.getCmdName() == "tableofcontents"
- || inscmd.getCmdName() == "listofalgorithms"
- || inscmd.getCmdName() == "listoffigures"
- || inscmd.getCmdName() == "listoftables") {
+ } else if (cmdName == "tableofcontents") {
inset = new InsetTOC(inscmd);
- } else if (inscmd.getCmdName() == "printindex") {
+ } else if (cmdName == "listofalgorithms") {
+ inset = new InsetFloatList("algorithm");
+ } else if (cmdName == "listoffigures") {
+ inset = new InsetFloatList("figure");
+ } else if (cmdName == "listoftables") {
+ inset = new InsetFloatList("table");
+ } else if (cmdName == "printindex") {
inset = new InsetPrintIndex(inscmd);
- } else if (inscmd.getCmdName() == "lyxparent") {
+ } else if (cmdName == "lyxparent") {
inset = new InsetParent(inscmd, *this);
}
} else {
inset = new InsetCaption;
} else if (tmptok == "GRAPHICS") {
inset = new InsetGraphics;
+ } else if (tmptok == "FloatList") {
+ inset = new InsetFloatList;
}
if (inset) inset->Read(this, lex);
s = fileName() + '~';
if (!lyxrc.backupdir_path.empty())
s = AddName(lyxrc.backupdir_path,
- subst(CleanupPath(s),'/','!'));
+ subst(os::slashify_path(s),'/','!'));
// Rename is the wrong way of making a backup,
// this is the correct way.
// now write out the buffer paramters.
params.writeFile(ofs);
- char footnoteflag = 0;
char depth = 0;
// this will write out all the paragraphs
// using recursive descent.
- paragraph->writeFile(this, ofs, params, footnoteflag, depth);
+ paragraph->writeFile(this, ofs, params, depth);
// Write marker that shows file is complete
ofs << "\n\\the_end" << endl;
unsigned int linelen) const
{
ostringstream buffer;
- LyXFont font1;
- LyXFont font2;
- Inset const * inset;
- char c;
-#ifndef NEW_INSETS
- LyXParagraph::footnote_flag footnoteflag = LyXParagraph::NO_FOOTNOTE;
-#endif
char depth = 0;
int ltype = 0;
int ltype_depth = 0;
int noparbreak = 0;
int islatex = 0;
-#ifndef NEW_INSETS
- if (par->footnoteflag != LyXParagraph::NO_FOOTNOTE ||
- !par->previous_
- || par->previous()->footnoteflag == LyXParagraph::NO_FOOTNOTE) {
- /* begins a footnote environment ? */
- if (footnoteflag != par->footnoteflag) {
- footnoteflag = par->footnoteflag;
- if (footnoteflag) {
- size_t const j = strlen(string_footnotekinds[par->footnotekind]) + 4;
- if ((linelen > 0) &&
- ((currlinelen + j) > linelen)) {
- buffer << "\n";
- currlinelen = 0;
- }
- buffer << "(["
- << string_footnotekinds[par->footnotekind]
- << "] ";
- currlinelen += j;
- }
- }
-#else
- if (!par->previous()) {
-#endif
- /* begins or ends a deeper area ?*/
+ if (!par->previous()) {
+ // begins or ends a deeper area ?
if (depth != par->params.depth()) {
if (par->params.depth() > depth) {
while (par->params.depth() > depth) {
}
}
- /* First write the layout */
+ // First write the layout
string const tmp = textclasslist.NameOfLayout(params.textclass, par->layout);
if (tmp == "Itemize") {
ltype = 1;
/* 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
}
- font1 = LyXFont(LyXFont::ALL_INHERIT, params.language);
+ LyXFont const font1 = LyXFont(LyXFont::ALL_INHERIT, params.language);
for (LyXParagraph::size_type i = 0; i < par->size(); ++i) {
- if (!i &&
-#ifndef NEW_INSETS
- !footnoteflag &&
-#endif
- !noparbreak) {
+ if (!i && !noparbreak) {
if (linelen > 0)
buffer << "\n\n";
for (char j = 0; j < depth; ++j)
buffer << " ";
currlinelen = depth * 2;
switch (ltype) {
- case 0: /* Standard */
- case 4: /* (Sub)Paragraph */
- case 5: /* Description */
+ case 0: // Standard
+ case 4: // (Sub)Paragraph
+ case 5: // Description
break;
- case 6: /* Abstract */
+ case 6: // Abstract
if (linelen > 0)
buffer << "Abstract\n\n";
else
buffer << "Abstract: ";
break;
- case 7: /* Bibliography */
+ case 7: // Bibliography
if (!ref_printed) {
if (linelen > 0)
buffer << "References\n\n";
currlinelen += (ltype_depth-depth)*2;
}
}
- font2 = par->GetFontSettings(params, i);
+ LyXFont const font2 = par->GetFontSettings(params, i);
if (font1.latex() != font2.latex()) {
if (font2.latex() == LyXFont::OFF)
islatex = 0;
} else {
islatex = 0;
}
- c = par->GetUChar(params, i);
+
+ char c = par->GetUChar(params, i);
if (islatex)
continue;
switch (c) {
case LyXParagraph::META_INSET:
- if ((inset = par->GetInset(i))) {
+ {
+ Inset const * inset = par->GetInset(i);
+ if (inset) {
if (!inset->Ascii(this, buffer)) {
string dummy;
- string s = rsplit(buffer.str().c_str(),
- dummy, '\n');
+ string const s =
+ rsplit(buffer.str().c_str(),
+ dummy, '\n');
currlinelen += s.length();
} else {
// to be sure it breaks paragraph
currlinelen += linelen;
}
}
- break;
+ }
+ break;
+
case LyXParagraph::META_NEWLINE:
if (linelen > 0) {
buffer << "\n";
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()))
if (!original_path.empty()) {
ofs << "\\makeatletter\n"
<< "\\def\\input@path{{"
- << original_path << "/}}\n"
+ << os::external_path(original_path) << "/}}\n"
<< "\\makeatother\n";
texrow.newline();
texrow.newline();
ofs << "\\documentclass";
- string options; // the document class options.
+ ostringstream options; // the document class options.
if (tokenPos(tclass.opt_fontsize(),
'|', params.fontsize) >= 0) {
// only write if existing in list (and not default)
- options += params.fontsize;
- options += "pt,";
+ options << params.fontsize << "pt,";
}
(params.paperpackage == BufferParams::PACKAGE_NONE)) {
switch (params.papersize) {
case BufferParams::PAPER_A4PAPER:
- options += "a4paper,";
+ options << "a4paper,";
break;
case BufferParams::PAPER_USLETTER:
- options += "letterpaper,";
+ options << "letterpaper,";
break;
case BufferParams::PAPER_A5PAPER:
- options += "a5paper,";
+ options << "a5paper,";
break;
case BufferParams::PAPER_B5PAPER:
- options += "b5paper,";
+ options << "b5paper,";
break;
case BufferParams::PAPER_EXECUTIVEPAPER:
- options += "executivepaper,";
+ options << "executivepaper,";
break;
case BufferParams::PAPER_LEGALPAPER:
- options += "legalpaper,";
+ options << "legalpaper,";
break;
}
}
if (params.sides != tclass.sides()) {
switch (params.sides) {
case LyXTextClass::OneSide:
- options += "oneside,";
+ options << "oneside,";
break;
case LyXTextClass::TwoSides:
- options += "twoside,";
+ options << "twoside,";
break;
}
-
}
// if needed
if (params.columns != tclass.columns()) {
if (params.columns == 2)
- options += "twocolumn,";
+ options << "twocolumn,";
else
- options += "onecolumn,";
+ options << "onecolumn,";
}
if (!params.use_geometry
&& params.orientation == BufferParams::ORIENTATION_LANDSCAPE)
- options += "landscape,";
+ options << "landscape,";
// language should be a parameter to \documentclass
use_babel = false;
- string language_options;
+ ostringstream language_options;
if (params.language->babel() == "hebrew"
&& default_language->babel() != "hebrew")
// This seems necessary
for (LaTeXFeatures::LanguageList::const_iterator cit =
features.UsedLanguages.begin();
cit != features.UsedLanguages.end(); ++cit)
- language_options += (*cit)->babel() + ',';
- language_options += params.language->babel();
+ language_options << (*cit)->babel() << ',';
+ language_options << params.language->babel();
if (lyxrc.language_global_options)
- options += language_options + ',';
+ options << language_options.str() << ',';
}
// the user-defined options
if (!params.options.empty()) {
- options += params.options + ',';
+ options << params.options << ',';
}
-
- if (!options.empty()){
- options = strip(options, ',');
- ofs << '[' << options << ']';
+
+ string strOptions(options.str().c_str());
+ if (!strOptions.empty()){
+ strOptions = strip(strOptions, ',');
+ ofs << '[' << strOptions << ']';
}
ofs << '{'
string tmp = lyxrc.language_package;
if (!lyxrc.language_global_options
&& tmp == "\\usepackage{babel}")
- tmp = "\\usepackage[" +
- language_options + "]{babel}";
+ tmp = string("\\usepackage[") +
+ language_options.str().c_str() +
+ "]{babel}";
ofs << tmp << "\n";
texrow.newline();
}
{
bool was_title = false;
bool already_title = false;
- std::ostringstream ftnote;
- TexRow ft_texrow;
- int ftcount = 0;
// if only_body
while (par != endpar) {
-#ifndef NEW_INSETS
- if (par->IsDummy())
- lyxerr[Debug::LATEX] << "Error in latexParagraphs."
- << endl;
-#endif
LyXLayout const & layout =
textclasslist.Style(params.textclass,
par->layout);
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()
-#ifndef NEW_INSETS
- || par->params.pextraType() != LyXParagraph::PEXTRA_NONE
-#endif
- ) {
- par = par->TeXEnvironment(this, params, ofs, texrow
-#ifndef NEW_INSETS
- ,ftnote, ft_texrow, ftcount
-#endif
- );
+
+ if (layout.isEnvironment()) {
+ par = par->TeXEnvironment(this, params, ofs, texrow);
} else {
- par = par->TeXOnePar(this, params, ofs, texrow, false
-#ifndef NEW_INSETS
- ,
- ftnote, ft_texrow, ftcount
-#endif
- );
- }
-
- // Write out what we've generated...
- if (ftcount >= 1) {
- if (ftcount > 1) {
- ofs << "\\addtocounter{footnote}{-"
- << ftcount - 1
- << '}';
- }
- ofs << ftnote.str();
- texrow += ft_texrow;
-
- // The extra .c_str() is needed when we use
- // lyxstring instead of the STL string class.
- ftnote.str(string().c_str());
- ft_texrow.reset();
- ftcount = 0;
+ par = par->TeXOnePar(this, params, ofs, texrow, false);
}
}
// It might be that we only have a title in this document
string const temp = "toc";
sgmlOpenTag(ofs, depth, temp);
-#ifndef NEW_INSETS
- par = par->next_;
- linuxDocHandleFootnote(ofs, par, depth);
-#else
par = par->next();
-#endif
continue;
}
}
}
sgmlOpenTag(ofs, depth, style.latexname());
- if (environment_stack.size() == depth+1)
+ if (environment_stack.size() == depth + 1)
environment_stack.push_back("!-- --");
environment_stack[depth] = style.latexname();
}
break;
}
-#ifndef NEW_INSETS
- do {
- SimpleLinuxDocOnePar(ofs, par, depth);
-
- par = par->next_;
- linuxDocHandleFootnote(ofs, par, depth);
- }
- while(par && par->IsDummy());
-#else
SimpleLinuxDocOnePar(ofs, par, depth);
par = par->next();
-#endif
ofs << "\n";
// write closing SGML tags
}
-#ifndef NEW_INSETS
-void Buffer::linuxDocHandleFootnote(ostream & os, LyXParagraph * & par,
- int depth)
-{
- string const tag = "footnote";
-
- while (par && par->footnoteflag != LyXParagraph::NO_FOOTNOTE) {
- sgmlOpenTag(os, depth + 1, tag);
- SimpleLinuxDocOnePar(os, par, 0, depth + 1);
- sgmlCloseTag(os, depth + 1, tag);
- par = par->next_;
- }
-}
-#endif
-
-
void Buffer::DocBookHandleCaption(ostream & os, string & inner_tag,
int depth, int desc_on,
LyXParagraph * & par)
{
LyXParagraph * tpar = par;
-#ifndef NEW_INSETS
- while (tpar
- && (tpar->footnoteflag != LyXParagraph::NO_FOOTNOTE)
- && (tpar->layout != textclasslist.NumberOfLayout(params.textclass,
- "Caption").second))
- tpar = tpar->next_;
-#else
while (tpar
&& (tpar->layout != textclasslist.NumberOfLayout(params.textclass,
"Caption").second))
tpar = tpar->next();
-#endif
+
if (tpar &&
tpar->layout == textclasslist.NumberOfLayout(params.textclass,
"Caption").second) {
}
-#ifndef NEW_INSETS
-void Buffer::DocBookHandleFootnote(ostream & os, LyXParagraph * & par,
- int depth)
-{
- string tag, inner_tag;
- string tmp_par, extra_par;
- bool inner_span = false;
- int desc_on = 4;
-
- // Someone should give this enum a proper name (Lgb)
- enum SOME_ENUM {
- NO_ONE,
- FOOTNOTE_LIKE,
- MARGIN_LIKE,
- FIG_LIKE,
- TAB_LIKE
- };
- SOME_ENUM last = NO_ONE;
- SOME_ENUM present = FOOTNOTE_LIKE;
-
- while (par && par->footnoteflag != LyXParagraph::NO_FOOTNOTE) {
- if (last == present) {
- if (inner_span) {
- if (!tmp_par.empty()) {
- os << tmp_par;
- tmp_par.erase();
- sgmlCloseTag(os, depth + 1, inner_tag);
- sgmlOpenTag(os, depth + 1, inner_tag);
- }
- } else {
- os << "\n";
- }
- } else {
- os << tmp_par;
- if (!inner_tag.empty()) sgmlCloseTag(os, depth + 1,
- inner_tag);
- if (!extra_par.empty()) os << extra_par;
- if (!tag.empty()) sgmlCloseTag(os, depth, tag);
- extra_par.erase();
-
- switch (par->footnotekind) {
- case LyXParagraph::FOOTNOTE:
- case LyXParagraph::ALGORITHM:
- tag = "footnote";
- inner_tag = "para";
- present = FOOTNOTE_LIKE;
- inner_span = true;
- break;
- case LyXParagraph::MARGIN:
- tag = "sidebar";
- inner_tag = "para";
- present = MARGIN_LIKE;
- inner_span = true;
- break;
- case LyXParagraph::FIG:
- case LyXParagraph::WIDE_FIG:
- tag = "figure";
- inner_tag = "title";
- present = FIG_LIKE;
- inner_span = false;
- break;
- case LyXParagraph::TAB:
- case LyXParagraph::WIDE_TAB:
- tag = "table";
- inner_tag = "title";
- present = TAB_LIKE;
- inner_span = false;
- break;
- }
- sgmlOpenTag(os, depth, tag);
- if ((present == TAB_LIKE) || (present == FIG_LIKE)) {
- DocBookHandleCaption(os, inner_tag, depth,
- desc_on, par);
- inner_tag.erase();
- } else {
- sgmlOpenTag(os, depth + 1, inner_tag);
- }
- }
- // ignore all caption here, we processed them above!!!
- if (par->layout != textclasslist
- .NumberOfLayout(params.textclass,
- "Caption").second) {
- std::ostringstream ost;
- SimpleDocBookOnePar(ost, extra_par, par,
- desc_on, depth + 2);
- tmp_par += ost.str().c_str();
- }
- tmp_par = frontStrip(strip(tmp_par));
-
- last = present;
- par = par->next_;
- }
- os << tmp_par;
- if (!inner_tag.empty()) sgmlCloseTag(os, depth + 1, inner_tag);
- if (!extra_par.empty()) os << extra_par;
- if (!tag.empty()) sgmlCloseTag(os, depth, tag);
-}
-#endif
-
-
// checks, if newcol chars should be put into this line
// writes newline, if necessary.
namespace {
texrow.reset();
- string top_element= textclasslist.LatexnameOfClass(params.textclass);
+ string top_element = textclasslist.LatexnameOfClass(params.textclass);
if (!only_body) {
- string sgml_includedfiles=features.getIncludedFiles(fname);
+ string sgml_includedfiles = features.getIncludedFiles(fname);
ofs << "<!doctype " << top_element
<< " public \"-//OASIS//DTD DocBook V3.1//EN\"";
ofs << "<!-- DocBook file was created by " << LYX_DOCVERSION
<< "\n See http://www.lyx.org/ for more information -->\n";
- vector <string> environment_stack(10);
- vector <string> environment_inner(10);
- vector <string> command_stack(10);
+ vector<string> environment_stack(10);
+ vector<string> environment_inner(10);
+ vector<string> command_stack(10);
- bool command_flag= false;
- int command_depth= 0, command_base= 0, cmd_depth= 0;
+ bool command_flag = false;
+ int command_depth = 0;
+ int command_base = 0;
+ int cmd_depth = 0;
int depth = 0; // paragraph depth
- string item_name, command_name;
+ string item_name;
+ string command_name;
while (par) {
- string sgmlparam, c_depth, c_params;
+ string sgmlparam;
+ string c_depth;
+ string c_params;
int desc_on = 0; // description mode
LyXLayout const & style =
// environment tag closing
for (; depth > par->params.depth(); --depth) {
if (environment_inner[depth] != "!-- --") {
- item_name= "listitem";
+ item_name = "listitem";
sgmlCloseTag(ofs, command_depth + depth,
item_name);
if (environment_inner[depth] == "varlistentry")
// Write opening SGML tags.
switch (style.latextype) {
case LATEX_PARAGRAPH:
- sgmlOpenTag(ofs, depth+command_depth, style.latexname());
+ sgmlOpenTag(ofs, depth + command_depth,
+ style.latexname());
break;
case LATEX_COMMAND:
- if (depth!= 0)
+ if (depth != 0)
LinuxDocError(par, 0,
_("Error : Wrong depth for "
"LatexType Command.\n"));
sgmlparam = style.latexparam();
c_params = split(sgmlparam, c_depth,'|');
- cmd_depth= lyx::atoi(c_depth);
+ cmd_depth = lyx::atoi(c_depth);
if (command_flag) {
- if (cmd_depth<command_base) {
+ if (cmd_depth < command_base) {
for (int j = command_depth; j >= command_base; --j)
sgmlCloseTag(ofs, j, command_stack[j]);
- command_depth= command_base= cmd_depth;
+ command_depth = command_base = cmd_depth;
} else if (cmd_depth <= command_depth) {
for (int j = command_depth; j >= cmd_depth; --j)
sgmlCloseTag(ofs, j, command_stack[j]);
- command_depth= cmd_depth;
+ command_depth = cmd_depth;
} else
- command_depth= cmd_depth;
+ command_depth = cmd_depth;
} else {
command_depth = command_base = cmd_depth;
command_flag = true;
}
- if (command_stack.size() == command_depth +1)
+ if (command_stack.size() == command_depth + 1)
command_stack.push_back("");
- command_stack[command_depth]= command_name;
+ command_stack[command_depth] = command_name;
// treat label as a special case for
// more WYSIWYM handling.
}
if (environment_stack[depth] != style.latexname()) {
- if(environment_stack.size() == depth+1) {
+ if(environment_stack.size() == depth + 1) {
environment_stack.push_back("!-- --");
environment_inner.push_back("!-- --");
}
break;
}
-#ifndef NEW_INSETS
- do {
- string extra_par;
- SimpleDocBookOnePar(ofs, extra_par, par, desc_on,
- depth + 1 + command_depth);
- par = par->next_;
- DocBookHandleFootnote(ofs, par,
- depth + 1 + command_depth);
- } while(par && par->IsDummy());
-#else
string extra_par;
SimpleDocBookOnePar(ofs, extra_par, par, desc_on,
depth + 1 + command_depth);
par = par->next();
-#endif
+
string end_tag;
// write closing SGML tags
switch (style.latextype) {
for (; depth >= 0; --depth) {
if (!environment_stack[depth].empty()) {
if (environment_inner[depth] != "!-- --") {
- item_name= "listitem";
+ item_name = "listitem";
sgmlCloseTag(ofs, command_depth + depth,
item_name);
if (environment_inner[depth] == "varlistentry")
}
Path p(path); // path to LaTeX file
- users->owner()->getMiniBuffer()->Set(_("Running chktex..."));
+ users->owner()->message(_("Running chktex..."));
// Remove all error insets
bool const removedErrorInsets = users->removeAutoInsets();
par->validate(features);
// and then the next paragraph
-#ifndef NEW_INSETS
- par = par->next_;
-#else
par = par->next();
-#endif
}
// the bullet shapes are buffer level not paragraph level
{
Lists l;
LyXParagraph * par = paragraph;
-#ifdef NEW_INSETS
bool found;
LyXTextClassList::size_type cap;
boost::tie(found, cap) = textclasslist
.NumberOfLayout(params.textclass, "Caption");
-#endif
while (par) {
-#ifndef NEW_INSETS
- if (par->footnoteflag != LyXParagraph::NO_FOOTNOTE) {
- if (textclasslist.Style(params.textclass,
- par->GetLayout()).labeltype
- == LABEL_SENSITIVE) {
- string type;
- switch (par->footnotekind) {
- case LyXParagraph::FIG:
- case LyXParagraph::WIDE_FIG:
- type = "LOF";
- break;
- case LyXParagraph::TAB:
- case LyXParagraph::WIDE_TAB:
- type = "LOT";
- break;
- case LyXParagraph::ALGORITHM:
- type = "LOA";
- break;
- case LyXParagraph::FOOTNOTE:
- case LyXParagraph::MARGIN:
- break;
- }
- if (!type.empty()) {
- SingleList & item = l[type];
- string const str =
- tostr(item.size()+1) + ". " + par->String(this, false);
- item.push_back(TocItem(par, 0, str));
- }
- }
- } else if (!par->IsDummy()) {
-#endif
- char const labeltype =
- textclasslist.Style(params.textclass,
- par->GetLayout()).labeltype;
-
- if (labeltype >= LABEL_COUNTER_CHAPTER
- && labeltype <= LABEL_COUNTER_CHAPTER + params.tocdepth) {
+ char const labeltype =
+ textclasslist.Style(params.textclass,
+ par->GetLayout()).labeltype;
+
+ if (labeltype >= LABEL_COUNTER_CHAPTER
+ && labeltype <= LABEL_COUNTER_CHAPTER + params.tocdepth) {
// insert this into the table of contents
- SingleList & item = l["TOC"];
- int depth = max(0,
- labeltype -
- textclasslist.TextClass(params.textclass).maxcounter());
- item.push_back(TocItem(par, depth, par->String(this, true)));
- }
-#ifdef NEW_INSETS
- // For each paragrph, traverse its insets and look for
- // FLOAT_CODE
+ SingleList & item = l["TOC"];
+ int depth = max(0,
+ labeltype -
+ textclasslist.TextClass(params.textclass).maxcounter());
+ item.push_back(TocItem(par, depth, par->String(this, true)));
+ }
+ // For each paragrph, traverse its insets and look for
+ // FLOAT_CODE
+
+ if (found) {
+ LyXParagraph::inset_iterator it =
+ par->inset_iterator_begin();
+ LyXParagraph::inset_iterator end =
+ par->inset_iterator_end();
- if (found) {
- LyXParagraph::inset_iterator it =
- par->inset_iterator_begin();
- LyXParagraph::inset_iterator end =
- par->inset_iterator_end();
-
- for (; it != end; ++it) {
- if ((*it)->LyxCode() == Inset::FLOAT_CODE) {
- InsetFloat * il =
- static_cast<InsetFloat*>(*it);
-
- string const type = il->type();
-
- // Now find the caption in the float...
- // We now tranverse the paragraphs of
- // the inset...
- LyXParagraph * tmp = il->inset->par;
- while (tmp) {
- if (tmp->layout == cap) {
- SingleList & item = l[type];
- string const str =
- tostr(item.size()+1) + ". " + tmp->String(this, false);
- item.push_back(TocItem(tmp, 0 , str));
- }
- tmp = tmp->next();
+ for (; it != end; ++it) {
+ if ((*it)->LyxCode() == Inset::FLOAT_CODE) {
+ InsetFloat * il =
+ static_cast<InsetFloat*>(*it);
+
+ string const type = il->type();
+
+ // Now find the caption in the float...
+ // We now tranverse the paragraphs of
+ // the inset...
+ LyXParagraph * tmp = il->inset.par;
+ while (tmp) {
+ if (tmp->layout == cap) {
+ SingleList & item = l[type];
+ string const str =
+ tostr(item.size()+1) + ". " + tmp->String(this, false);
+ item.push_back(TocItem(tmp, 0 , str));
}
+ tmp = tmp->next();
}
}
- } else {
- lyxerr << "caption not found" << endl;
}
-
-#endif
-#ifndef NEW_INSETS
+ } else {
+ lyxerr << "caption not found" << endl;
}
- par = par->next_;
-#else
+
par = par->next();
-#endif
}
return l;
}
if (par->bibkey)
keys.push_back(pair<string, string>(par->bibkey->getContents(),
par->String(this, false)));
-#ifndef NEW_INSETS
- par = par->next_;
-#else
par = par->next();
-#endif
}
// Might be either using bibtex or a child has bibliography
{
/// then remove all LyXText in text-insets
LyXParagraph * par = paragraph;
-#ifndef NEW_INSETS
- for (; par; par = par->next_) {
- par->resizeInsetsLyXText(bv);
- }
-#else
for (; par; par = par->next()) {
par->resizeInsetsLyXText(bv);
}
-#endif
}
LyXParagraph * par = paragraph;
while (par) {
par->ChangeLanguage(params, from, to);
-#ifndef NEW_INSETS
- par = par->next_;
-#else
par = par->next();
-#endif
}
}
while (par) {
if (par->isMultiLingual(params))
return true;
-#ifndef NEW_INSETS
- par = par->next_;
-#else
par = par->next();
-#endif
}
return false;
}
{
it = par->InsetIterator(pos);
if (it == par->inset_iterator_end()) {
-#ifndef NEW_INSETS
- par = par->next_;
-#else
par = par->next();
-#endif
SetParagraph();
}
}
it = par->inset_iterator_begin();
if (it != par->inset_iterator_end())
return;
-#ifndef NEW_INSETS
- par = par->next_;
-#else
par = par->next();
-#endif
}
//it = 0;
// We maintain an invariant that whenever par = 0 then it = 0