#include "gettext.h"
#include "language.h"
#include "exporter.h"
+#include "errorlist.h"
#include "Lsstream.h"
#include "format.h"
#include "BufferView.h"
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));
}
string const Buffer::getLatexName(bool no_path) const
{
string const name = ChangeExtension(MakeLatexName(fileName()), ".tex");
- if (no_path)
- return OnlyFilename(name);
- else
- return name;
+ return no_path ? OnlyFilename(name) : name;
}
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;
string item_name;
vector<string> environment_stack(5);
+ users->resetErrorList();
+
ParagraphList::iterator pit = paragraphs.begin();
ParagraphList::iterator pend = paragraphs.end();
for (; pit != pend; ++pit) {
case LATEX_COMMAND:
if (depth != 0)
- sgmlError(&*pit, 0,
+ sgmlError(pit, 0,
_("Error: Wrong depth for LatexType Command.\n"));
if (!environment_stack[depth].empty()) {
// we want this to be true outside previews (for insetexternal)
niceFile = true;
+
+ users->showErrorList(_("LinuxDoc"));
}
// Print an error message.
-void Buffer::sgmlError(ParagraphList::iterator /*par*/, int /*pos*/,
- string const & /*message*/) const
-{
-#ifdef WITH_WARNINGS
-#warning This is wrong we cannot insert an inset like this!!!
- // I guess this was Jose' so I explain you more or less why this
- // is wrong. This way you insert something in the paragraph and
- // don't tell it to LyXText (row rebreaking and undo handling!!!)
- // I deactivate this code, have a look at BufferView::insertErrors
- // how you should do this correctly! (Jug 20020315)
-#endif
-#if 0
- // insert an error marker in text
- InsetError * new_inset = new InsetError(message);
- par->insertInset(pos, new_inset, LyXFont(LyXFont::ALL_INHERIT,
- params.language));
-#endif
+void Buffer::sgmlError(ParagraphList::iterator pit, int pos,
+ string const & message) const
+{
+ users->addError(ErrorItem(message, string(), pit->id(), pos, pos));
}
string item_name;
string command_name;
+ users->resetErrorList();
+
ParagraphList::iterator par = paragraphs.begin();
ParagraphList::iterator pend = paragraphs.end();
// we want this to be true outside previews (for insetexternal)
niceFile = true;
+ users->showErrorList(_("DocBook"));
}
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
- users->showErrorList();
+ 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()
{}