#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"
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"
- || inscmd.getCmdName() == "listof{algorithm}{List of Algorithms}") {
+ } 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;
char depth = 0;
int ltype = 0;
int ltype_depth = 0;
int noparbreak = 0;
int islatex = 0;
if (!par->previous()) {
- /* begins or ends a deeper area ?*/
+ // 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;
lyxerr << "Should this ever happen?" << endl;
}
- 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 && !noparbreak) {
if (linelen > 0)
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) {
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 = par->TeXEnvironment(this, params, ofs, texrow);
} else {
par = par->TeXOnePar(this, params, ofs, texrow, false);
}
-
- // 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;
- }
}
// It might be that we only have a title in this document
if (was_title && !already_title) {
.NumberOfLayout(params.textclass, "Caption");
while (par) {
- 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)));
- }
- // 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;
}
-
+ } else {
+ lyxerr << "caption not found" << endl;
+ }
+
par = par->next();
}
return l;