#include "insets/insettoc.h"
#include "insets/insetparent.h"
#include "insets/insetspecialchar.h"
-#include "insets/figinset.h"
#include "insets/insettext.h"
#include "insets/insetert.h"
#include "insets/insetgraphics.h"
#include "support/filetools.h"
#include "support/path.h"
#include "support/os.h"
-#include "support/syscall.h"
#include "support/lyxlib.h"
#include "support/FileInfo.h"
#include "support/lyxmanip.h"
+#include "support/lyxalgo.h" // for lyx::count
#include <fstream>
#include <iomanip>
Buffer::Buffer(string const & file, bool ronly)
+ : paragraph(0), lyx_clean(true), bak_clean(true),
+ unnamed(false), dep_clean(0), read_only(ronly),
+ filename_(file), users(0)
{
lyxerr[Debug::INFO] << "Buffer::Buffer()" << endl;
- filename = file;
- filepath = OnlyPath(file);
- paragraph = 0;
- lyx_clean = true;
- bak_clean = true;
- dep_clean = 0;
- read_only = ronly;
- unnamed = false;
- users = 0;
+// filename = file;
+ filepath_ = OnlyPath(file);
+// paragraph = 0;
+// lyx_clean = true;
+// bak_clean = true;
+// dep_clean = 0;
+// read_only = ronly;
+// unnamed = false;
+// users = 0;
lyxvc.buffer(this);
- if (read_only || (lyxrc.use_tempdir)) {
+ if (read_only || lyxrc.use_tempdir) {
tmppath = CreateBufferTmpDir();
- } else tmppath.erase();
+ } else {
+ tmppath.erase();
+ }
}
string const Buffer::getLatexName(bool no_path) const
{
- string const name = ChangeExtension(MakeLatexName(filename), ".tex");
+ string const name = ChangeExtension(MakeLatexName(fileName()), ".tex");
if (no_path)
return OnlyFilename(name);
else
void Buffer::setFileName(string const & newfile)
{
- filename = MakeAbsPath(newfile);
- filepath = OnlyPath(filename);
- setReadonly(IsFileWriteable(filename) == 0);
+ filename_ = MakeAbsPath(newfile);
+ filepath_ = OnlyPath(filename_);
+ setReadonly(IsFileWriteable(filename_) == 0);
updateTitles();
}
string contents;
bool active;
bool in_tabular;
+ LyXFont font;
};
std::stack<ErtComp> ert_stack;
ErtComp ert_comp;
#endif
+#ifdef WITH_WARNINGS
#warning And _why_ is this here? (Lgb)
+#endif
int unknown_layouts;
int unknown_tokens;
} else {
// We are inserting into an existing document
users->text->breakParagraph(users);
- first_par = users->text->firstParagraph();
+ first_par = users->text->ownerParagraph();
pos = 0;
markDirty();
// We don't want to adopt the parameters from the
#ifndef NO_COMPABILITY
-void Buffer::insertErtContents(Paragraph * par, int & pos,
- LyXFont const & f, bool set_inactive)
+void Buffer::insertErtContents(Paragraph * par, int & pos, bool set_inactive)
{
if (!ert_comp.contents.empty()) {
lyxerr[Debug::INSETS] << "ERT contents:\n'"
<< ert_comp.contents << "'" << endl;
- Inset * inset = new InsetERT(ert_comp.contents, true);
- LyXFont font;
- font.setLanguage(f.language());
- par->insertInset(pos++, inset, font);
+ Inset * inset = new InsetERT(params.language, ert_comp.contents, true);
+ par->insertInset(pos++, inset, ert_comp.font);
ert_comp.contents.erase();
}
if (set_inactive) {
#ifndef NO_COMPABILITY
ert_comp.in_tabular = false;
// Do the insetert.
- insertErtContents(par, pos, font);
+ insertErtContents(par, pos);
#endif
lex.eatLine();
string const layoutname = lex.getString();
#ifndef NO_COMPABILITY
if (compare_no_case(layoutname, "latex") == 0) {
ert_comp.active = true;
+ ert_comp.font = font;
}
#endif
#ifdef USE_CAPTION
#ifndef NO_COMPABILITY
} else if (token == "\\begin_float") {
- insertErtContents(par, pos, font);
- //insertErtContents(par, pos, font, false);
+ insertErtContents(par, pos);
+ //insertErtContents(par, pos, false);
//ert_stack.push(ert_comp);
//ert_comp = ErtComp();
inset->read(this, nylex);
par->insertInset(pos, inset, font);
++pos;
- insertErtContents(par, pos, font);
+ insertErtContents(par, pos);
#endif
} else if (token == "\\begin_deeper") {
++depth;
//how can I put it back?
}
} else if (token == "\\bulletLaTeX") {
+ // The bullet class should be able to read this.
lex.nextToken();
int const index = lex.getInteger();
lex.next();
lex.next();
temp_str = lex.getString();
}
+
params.user_defined_bullets[index].setText(sum_str);
params.temp_bullets[index].setText(sum_str);
} else if (token == "\\secnumdepth") {
string const tok = lex.getString();
if (tok == "no_latex") {
// Do the insetert.
- insertErtContents(par, pos, font);
+ insertErtContents(par, pos);
} else if (tok == "latex") {
ert_comp.active = true;
+ ert_comp.font = font;
} else if (tok == "default") {
// Do the insetert.
- insertErtContents(par, pos, font);
+ insertErtContents(par, pos);
} else {
lex.printError("Unknown LaTeX font flag "
"`$$Token'");
}
} else if (token == "\\added_space_top") {
lex.nextToken();
- par->params().spaceTop(VSpace(lex.getString()));
+ VSpace value = VSpace(lex.getString());
+ if ((value.length().len().value() != 0) ||
+ (value.kind() != VSpace::LENGTH))
+ par->params().spaceTop(value);
} else if (token == "\\added_space_bottom") {
lex.nextToken();
- par->params().spaceBottom(VSpace(lex.getString()));
+ VSpace value = VSpace(lex.getString());
+ if ((value.length().len().value() != 0) ||
+ (value.kind() != VSpace::LENGTH))
+ par->params().spaceBottom(value);
#ifndef NO_COMPABILITY
#ifndef NO_PEXTRA_REALLY
} else if (token == "\\pextra_type") {
// the inset isn't it? Lgb.
} else if (token == "\\begin_inset") {
#ifndef NO_COMPABILITY
- insertErtContents(par, pos, font, false);
+ insertErtContents(par, pos, false);
ert_stack.push(ert_comp);
ert_comp = ErtComp();
#endif
#ifndef NO_COMPABILITY
ert_comp = ert_stack.top();
ert_stack.pop();
- insertErtContents(par, pos, font);
+ insertErtContents(par, pos);
#endif
} else if (token == "\\SpecialChar") {
LyXLayout const & layout =
// Since we cannot know it this is only a regular
// newline or a tabular cell delimter we have to
// handle the ERT here.
- insertErtContents(par, pos, font, false);
+ insertErtContents(par, pos, false);
par->insertChar(pos, Paragraph::META_NEWLINE, font);
++pos;
#ifndef NO_COMPABILITY
// If we still have some ert active here we have to insert
// it so we don't loose it. (Lgb)
- insertErtContents(par, pos, font);
+ insertErtContents(par, pos);
#endif
the_end_read = true;
#ifndef NO_COMPABILITY
}
InsetMinipage * mini = new InsetMinipage;
mini->pos(static_cast<InsetMinipage::Position>(par->params().pextraAlignment()));
- mini->width(par->params().pextraWidth());
+ mini->pageWidth(LyXLength(par->params().pextraWidth()));
if (!par->params().pextraWidthp().empty()) {
- lyxerr << "WP:" << mini->width() << endl;
- mini->width(tostr(par->params().pextraWidthp())+"%");
+ lyxerr << "WP:" << mini->pageWidth().asString() << endl;
+ mini->pageWidth(LyXLength((par->params().pextraWidthp())+"%"));
}
Paragraph * op = mini->firstParagraph();
mini->inset.paragraph(par);
InsetMinipage * mini = new InsetMinipage;
mini->pos(static_cast<InsetMinipage::Position>(minipar->params().pextraAlignment()));
- mini->width(minipar->params().pextraWidth());
+ mini->pageWidth(LyXLength(minipar->params().pextraWidth()));
if (!par->params().pextraWidthp().empty()) {
- lyxerr << "WP:" << mini->width() << endl;
- mini->width(tostr(par->params().pextraWidthp())+"%");
+ lyxerr << "WP:" << mini->pageWidth().asString() << endl;
+ mini->pageWidth(LyXLength((par->params().pextraWidthp())+"%"));
}
mini->inset.paragraph(minipar);
} else if (tmptok == "Formula") {
inset = new InsetFormula;
} else if (tmptok == "Figure") { // Backward compatibility
- inset = new InsetFig(100, 100, *this);
- //inset = new InsetGraphics;
+// inset = new InsetFig(100, 100, *this);
+ inset = new InsetGraphics;
} else if (tmptok == "Graphics") {
inset = new InsetGraphics;
} else if (tmptok == "Info") {// backwards compatibility
} else if (tmptok == "Note") {
inset = new InsetNote;
} else if (tmptok == "Include") {
- InsetCommandParams p( "Include" );
+ InsetCommandParams p("Include");
inset = new InsetInclude(p, *this);
} else if (tmptok == "ERT") {
inset = new InsetERT;
// warnings, only cerr.
// Needed for autosave in background or panic save (Matthias 120496)
- if (read_only && (fname == filename)) {
+ if (read_only && (fname == fileName())) {
// Here we should come with a question if we should
// perform the write anyway.
if (flag)
{
Inset const * inset = par->getInset(i);
if (inset) {
- if (linelen > 0)
+ if (linelen > 0) {
buffer << word.str();
+ word.str("");
+ }
if (inset->ascii(this, buffer, linelen)) {
// to be sure it breaks paragraph
currlinelen += linelen;
// original_path is set. This is done for usual tex-file, but not
// for nice-latex-file. (Matthias 250696)
if (!only_body) {
- if (!nice){
+ if (!nice) {
// code for usual, NOT nice-latex-file
ofs << "\\batchmode\n"; // changed
// from \nonstopmode
}
string strOptions(options.str().c_str());
- if (!strOptions.empty()){
+ if (!strOptions.empty()) {
strOptions = strip(strOptions, ',');
ofs << '[' << strOptions << ']';
}
texrow.newline();
}
- if (features.isRequired("amsstyle")
- && !tclass.provides(LyXTextClass::amsmath)) {
- ofs << "\\usepackage{amsmath}\n";
- texrow.newline();
- }
-
if (tokenPos(tclass.opt_pagestyle(),
'|', params.pagestyle) >= 0) {
if (params.pagestyle == "fancy") {
if (!bullets_def.empty())
preamble += bullets_def + "}\n\n";
- for (int j = countChar(preamble, '\n'); j-- ;) {
+ int const nlines =
+ int(lyx::count(preamble.begin(), preamble.end(), '\n'));
+ for (int j = 0; j != nlines; ++j) {
texrow.newline();
}
if ((in == 0) || !in->forceDefaultParagraphs(in)) {
LyXLayout const & layout =
textclasslist.Style(params.textclass, par->layout);
-
- if (layout.intitle) {
+
+ if (layout.intitle) {
if (already_title) {
lyxerr <<"Error in latexParagraphs: You"
" should not mix title layouts"
" with normal ones." << endl;
} else
was_title = true;
- } else if (was_title && !already_title) {
+ } else if (was_title && !already_title) {
ofs << "\\maketitle\n";
texrow.newline();
already_title = true;
if (par->isInset(0)) {
Inset * inset = par->getInset(0);
Inset::Code lyx_code = inset->lyxCode();
- if (lyx_code == Inset::TOC_CODE){
+ if (lyx_code == Inset::TOC_CODE) {
string const temp = "toc";
sgmlOpenTag(ofs, depth, temp);
_("Error : Wrong depth for"
" LatexType Command.\n"));
- if (!environment_stack[depth].empty()){
+ if (!environment_stack[depth].empty()) {
sgmlCloseTag(ofs, depth,
environment_stack[depth]);
ofs << "</p>";
inline
void reset(PAR_TAG & p1, PAR_TAG const & p2)
{
- p1 = static_cast<PAR_TAG>( p1 & ~p2);
+ p1 = static_cast<PAR_TAG>(p1 & ~p2);
}
} // namespace anon
}
list < PAR_TAG > temp;
- while (!tag_state.empty() && tag_close ) {
+ while (!tag_state.empty() && tag_close) {
PAR_TAG k = tag_state.top();
tag_state.pop();
os << "</" << tag_name(k) << ">";
if (par->isInset(0)) {
Inset * inset = par->getInset(0);
Inset::Code lyx_code = inset->lyxCode();
- if (lyx_code == Inset::LABEL_CODE){
+ if (lyx_code == Inset::LABEL_CODE) {
command_name += " id=\"";
command_name += (static_cast<InsetCommand *>(inset))->getContents();
command_name += "\"";
}
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("!-- --");
}
if (style.latextype == LATEX_ENVIRONMENT) {
if (!style.latexparam().empty()) {
- if(style.latexparam() == "CDATA")
+ if (style.latexparam() == "CDATA")
ofs << "<![CDATA[";
else
sgmlOpenTag(ofs, depth + command_depth,
break;
case LATEX_ENVIRONMENT:
if (!style.latexparam().empty()) {
- if(style.latexparam() == "CDATA")
+ if (style.latexparam() == "CDATA")
ofs << "]]>";
else
sgmlCloseTag(ofs, depth + command_depth,
if (font.emph() == LyXFont::ON) {
os << "<emphasis>";
emph_flag = true;
- }else if(i) {
+ } else if (i) {
os << "</emphasis>";
emph_flag = false;
}
}
- if ( par->isInset(i) ) {
+ if (par->isInset(i)) {
Inset * inset = par->getInset(i);
// don't print the inset in position 0 if desc_on == 3 (label)
- if ( i || desc_on != 3)
+ if ( i || desc_on != 3) {
+ if(style.latexparam() == "CDATA")
+ os << "]]>";
inset->docbook(this, os);
+ if(style.latexparam() == "CDATA")
+ os << "<![CDATA[";
+ }
} else {
char c = par->getChar(i);
string sgml_string;
if (style.pass_thru) {
os << c;
- } else if(style.free_spacing || par->isFreeSpacing() || c != ' ') {
+ } else if (style.free_spacing || par->isFreeSpacing() || c != ' ') {
os << sgml_string;
} else if (desc_on ==1) {
++char_line_count;
// <term> not closed...
os << "</term>";
}
- if(style.free_spacing) os << '\n';
+ if (style.free_spacing) os << '\n';
}
// get LaTeX-Filename
string const name = getLatexName();
- string path = OnlyPath(filename);
+ string path = filePath();
string const org_path = path;
if (lyxrc.use_tempdir || !IsDirWriteable(path)) {
makeLaTeXFile(name, org_path, false);
TeXErrors terr;
- Chktex chktex(lyxrc.chktex_command, name, filepath);
+ Chktex chktex(lyxrc.chktex_command, name, filePath());
int res = chktex.run(terr); // run chktex
if (res == -1) {
// if we removed error insets before we ran chktex or if we inserted
// error insets after we ran chktex, this must be run:
- if (removedErrorInsets || res){
+ if (removedErrorInsets || res) {
users->redraw();
users->fitCursor();
}
// AMS Style is at document level
if (params.use_amsmath || tclass.provides(LyXTextClass::amsmath))
- features.require("amsstyle");
+ features.require("amsmath");
while (par) {
// We don't use "lyxerr.debug" because of speed. (Asger)