users->buffer(0);
if (!tmppath.empty() && destroyDir(tmppath) != 0) {
- Alert::warning(_("Could not remove temporary directory"),
+ Alert::warning(_("Could not remove temporary directory"),
bformat(_("Could not remove the temporary directory %1$s"), tmppath));
}
void unknownClass(string const & unknown)
{
- Alert::warning(_("Unknown document class"),
+ Alert::warning(_("Unknown document class"),
bformat(_("Using the default document class, because the "
" class %1$s is unknown."), unknown));
}
if (token == "\\layout") {
lex.pushToken(token);
- Paragraph * par = new Paragraph();
- par->params().depth(depth);
+ Paragraph par;
+ par.owningBuffer(*this);
+ par.params().depth(depth);
if (params.tracking_changes)
- par->trackChanges();
+ par.trackChanges();
LyXFont f(LyXFont::ALL_INHERIT, params.language);
- par->setFont(0, f);
+ par.setFont(0, f);
// FIXME: goddamn InsetTabular makes us pass a Buffer
// not BufferParams
- unknown += ::readParagraph(*this, *par, lex);
+ unknown += ::readParagraph(*this, par, lex);
// insert after
if (pit != pars.end())
// this will write out all the paragraphs
// using recursive descent.
- ParagraphList::iterator pit = paragraphs.begin();
- ParagraphList::iterator pend = paragraphs.end();
+ ParagraphList::const_iterator pit = paragraphs.begin();
+ ParagraphList::const_iterator pend = paragraphs.end();
for (; pit != pend; ++pit)
pit->write(this, ofs, params, depth);
void Buffer::makeLaTeXFile(string const & fname,
string const & original_path,
- bool nice, bool only_body, bool only_preamble)
+ LatexRunParams const & runparams,
+ bool only_body, bool only_preamble)
{
lyxerr[Debug::LATEX] << "makeLaTeXFile..." << endl;
return;
}
- makeLaTeXFile(ofs, original_path, nice, only_body, only_preamble);
+ makeLaTeXFile(ofs, original_path,
+ runparams, only_body, only_preamble);
ofs.close();
if (ofs.fail()) {
void Buffer::makeLaTeXFile(ostream & os,
string const & original_path,
- bool nice, bool only_body, bool only_preamble)
+ LatexRunParams const & runparams_in,
+ bool only_body, bool only_preamble)
{
- niceFile = nice; // this will be used by Insetincludes.
+ LatexRunParams runparams = runparams_in;
+ niceFile = runparams.nice; // this will be used by Insetincludes.
// validate the buffer.
lyxerr[Debug::LATEX] << " Validating buffer..." << endl;
// first paragraph of the document. (Asger)
texrow.start(paragraphs.begin()->id(), 0);
- if (!only_body && nice) {
+ if (!only_body && runparams.nice) {
os << "%% " << lyx_docversion << " created this file. "
"For more info, see http://www.lyx.org/.\n"
"%% Do not edit unless you really know what "
// 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 (!runparams.nice) {
// code for usual, NOT nice-latex-file
os << "\\batchmode\n"; // changed
// from \nonstopmode
}
// Write the preamble
- params.writeLaTeX(os, features, texrow);
+ runparams.use_babel = params.writeLaTeX(os, features, texrow);
if (only_preamble)
return;
texrow.newline();
}
- latexParagraphs(this, paragraphs, os, texrow, false);
+ latexParagraphs(this, paragraphs, os, texrow, runparams);
// add this just in case after all the paragraphs
os << endl;
Path p(path); // path to LaTeX file
users->owner()->message(_("Running chktex..."));
- // Remove all error insets
- bool const removedErrorInsets = users->removeAutoInsets();
-
// Generate the LaTeX file if neccessary
- makeLaTeXFile(name, org_path, false);
+ LatexRunParams runparams;
+ runparams.flavor = LatexRunParams::LATEX;
+ runparams.nice = false;
+ makeLaTeXFile(name, org_path, runparams);
TeXErrors terr;
Chktex chktex(lyxrc.chktex_command, name, filePath());
_("Could not run chktex successfully."));
} else if (res > 0) {
// Insert all errors as errors boxes
- ErrorList el (*this, terr);
+ ErrorList el (*this, terr);
users->setErrorList(el);
users->showErrorList(_("ChkTeX"));
}
- // 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) {
-#warning repaint needed here, or do you mean update() ?
- users->repaint();
- users->fitCursor();
- }
users->owner()->busy(false);
return res;
}
-ParagraphList::iterator Buffer::getParFromID(int id) const
+ParIterator Buffer::getParFromID(int id) const
{
#warning FIXME: const correctness! (Andre)
- ParIterator it(const_cast<Buffer*>(this)->par_iterator_begin());
- ParIterator end(const_cast<Buffer*>(this)->par_iterator_end());
+ ParIterator it = const_cast<Buffer*>(this)->par_iterator_begin();
+ ParIterator end = const_cast<Buffer*>(this)->par_iterator_end();
#warning FIXME, perhaps this func should return a ParIterator? (Lgb)
if (id < 0) {
// John says this is called with id == -1 from undo
lyxerr << "getParFromID(), id: " << id << endl;
- return 0;
+ return end;
}
- for (; it != end; ++it) {
- // go on then, show me how to remove
- // the cast
- if ((*it)->id() == id) {
- return *it;
- }
- }
+ for (; it != end; ++it)
+ if ((*it)->id() == id)
+ return it;
- return 0;
+ return end;
}
ParIterator Buffer::par_iterator_begin()
{
- return ParIterator(&*(paragraphs.begin()));
+ return ParIterator(paragraphs.begin(), paragraphs);
}
ParIterator Buffer::par_iterator_end()
{
- return ParIterator();
+ return ParIterator(paragraphs.end(), paragraphs);
}
ParConstIterator Buffer::par_iterator_begin() const
{
- return ParConstIterator(&*(paragraphs.begin()));
+ return ParConstIterator(const_cast<ParagraphList&>(paragraphs).begin(), paragraphs);
}
ParConstIterator Buffer::par_iterator_end() const
{
- return ParConstIterator();
+ return ParConstIterator(const_cast<ParagraphList&>(paragraphs).end(), paragraphs);
}
Buffer::inset_iterator::inset_iterator()
- : pit(0), pend(0)
+ : pit(), pend()
{}