]> git.lyx.org Git - features.git/commitdiff
This commit creates a error_lists map member inside the Buffer class.
authorAbdelrazak Younes <younes@lyx.org>
Sun, 13 Aug 2006 16:16:43 +0000 (16:16 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Sun, 13 Aug 2006 16:16:43 +0000 (16:16 +0000)
I had no choice but to use string for the map key. This is
because the only information that could be passed to the controller is a
string.

With this new architecture, persistent error lists are now possible.

* Buffer
  - errorList_, addError(),  : deleted
  - std::map<std::string, ErrorList> errorLists_ : new member
  - errorList(std::string const & type): associated accessors

* buffer_funcs.C
  - bufferErrors(Buffer const & buf, TeXErrors const & terr): now needs a third errorList argument
  - bufferErrors(Buffer const & buf, ErrorList const & el): deleted.

* Converter
  - convert(): now needs an ErrorList argument instead of filling the Buffer errorList member directly.
  - runLaTeX(): ditto
  - scanLog(): ditto

* CutAndPaste.C
  - pasteParagraphList(): ditto
  - pasteSelection(): ditto

* lyxtext.h/text.C
  - readParagraph(): ditto
  - LyXText::read(): ditto

* importer:
  - Importer::Import(): ditto

* BufferView_pimpl.C
  - loadLyXFile(): send the Buffer::errors() signal instead of calling LyXView::showErrorList() directly.

* exporter.C
  - Export(): send the Buffer::errors() signal instead of calling LyXView::showErrorList() directly in lyxfunc.C

* ControlErrorList.C
  - initialiseParams(): translation operation transfered here from LyXView::showErrorList().

* LyXView.C
  - LoadLyXFile(): add a showErrorList("Parse") call.
  - showErrorList(): simplified due to code transferred to the ControlErrorList.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@14652 a592a061-630c-0410-9148-cb99ea01b6c8

22 files changed:
src/BufferView_pimpl.C
src/CutAndPaste.C
src/CutAndPaste.h
src/buffer.C
src/buffer.h
src/buffer_funcs.C
src/buffer_funcs.h
src/converter.C
src/converter.h
src/exporter.C
src/frontends/LyXView.C
src/frontends/controllers/ControlErrorList.C
src/importer.C
src/importer.h
src/insets/ExternalSupport.C
src/insets/insetgraphics.C
src/insets/insettext.C
src/lyx_main.C
src/lyxfunc.C
src/lyxtext.h
src/text.C
src/text3.C

index d1c7dd04a7d1b8ef0a12fcf7c939a44914975d8b..527dc2693b59f6bac283ba340b27fd2ee101f095 100644 (file)
@@ -28,6 +28,7 @@
 #include "CutAndPaste.h"
 #include "debug.h"
 #include "dispatchresult.h"
+#include "errorlist.h"
 #include "factory.h"
 #include "FloatList.h"
 #include "funcrequest.h"
@@ -198,7 +199,8 @@ bool BufferView::Pimpl::loadLyXFile(string const & filename, bool tolastfiles)
        }
 
        setBuffer(b);
-       owner_->showErrorList(_("Parse"));
+       // Send the "errors" signal in case of parsing errors
+       b->errors("Parse");
 
        // scroll to the position when the file was last closed
        if (lyxrc.use_lastfilepos) {
@@ -789,17 +791,18 @@ void BufferView::Pimpl::menuInsertLyXFile(string const & filenm)
 
        string res;
        Buffer buf("", false);
-       // FIXME: is there a need for something like that?
-       //buf.errors.connect(boost::bind(&LyXView::showErrorList, owner_, _1));
        if (::loadLyXFile(&buf, makeAbsPath(filename))) {
+               ErrorList & el = buffer_->errorList("Parse");
+               // Copy the inserted document error list into the current buffer one.
+               el = buf.errorList("Parse");
                lyx::cap::pasteParagraphList(cursor_, buf.paragraphs(),
-                                            buf.params().textclass);
+                                            buf.params().textclass, el);
                res = _("Document %1$s inserted.");
        } else
                res = _("Could not insert document %1$s");
 
        owner_->message(bformat(res, disp_fn));
-       owner_->showErrorList(_("Document insertion"));
+       buffer_->errors("Parse");
        resizeCurrentBuffer();
 }
 
index a492d65196387bf009c8260d5c85051c1723448e..566d63016fb676e4f726ca00baf14a47ed9fb26c 100644 (file)
@@ -612,7 +612,7 @@ std::string getSelection(Buffer const & buf, size_t sel_index)
 
 
 void pasteParagraphList(LCursor & cur, ParagraphList const & parlist,
-                       textclass_type textclass)
+                       textclass_type textclass, ErrorList & errorList)
 {
        if (cur.inTexted()) {
                LyXText * text = cur.text();
@@ -622,15 +622,13 @@ void pasteParagraphList(LCursor & cur, ParagraphList const & parlist,
 
                pit_type endpit;
                PitPosPair ppp;
-               ErrorList el;
 
                boost::tie(ppp, endpit) =
                        pasteSelectionHelper(cur.buffer(),
                                             text->paragraphs(),
                                             cur.pit(), cur.pos(),
                                             parlist, textclass,
-                                            el);
-               bufferErrors(cur.buffer(), el);
+                                            errorList);
                updateLabels(cur.buffer());
                cur.clearSelection();
                text->setCursor(cur, ppp.first, ppp.second);
@@ -641,15 +639,14 @@ void pasteParagraphList(LCursor & cur, ParagraphList const & parlist,
 }
 
 
-void pasteSelection(LCursor & cur, size_t sel_index)
+void pasteSelection(LCursor & cur, ErrorList & errorList, size_t sel_index)
 {
        // this does not make sense, if there is nothing to paste
        if (!checkPastePossible(sel_index))
                return;
 
        pasteParagraphList(cur, theCuts[sel_index].first,
-                          theCuts[sel_index].second);
-       cur.bv().owner()->showErrorList(_("Paste"));
+                          theCuts[sel_index].second, errorList);
        cur.setSelection();
 }
 
index c92bb3a24ffeb3c156012929ffe7a46c3cfd050a..2b3a1c36bece216e0e5958ad97112af2f7f457fd 100644 (file)
@@ -56,11 +56,11 @@ void cutSelection(LCursor & cur, bool doclear = true, bool realcut = true);
 ///
 void copySelection(LCursor & cur);
 ///
-void pasteSelection(LCursor & cur, size_t sel_index = 0);
+void pasteSelection(LCursor & cur, ErrorList &, size_t sel_index = 0);
 
 ///
 void pasteParagraphList(LCursor & cur, ParagraphList const & parlist,
-                       textclass_type textclass);
+                       textclass_type textclass, ErrorList & errorList);
 
 
 /** Needed to switch between different classes. This works
index 696b84a20f5a2a56d2204b103a722f77052f705a..367ef539a6d7e2f49abecab5631556642703cd62 100644 (file)
@@ -22,6 +22,7 @@
 #include "Chktex.h"
 #include "debug.h"
 #include "encoding.h"
+#include "errorlist.h"
 #include "exporter.h"
 #include "format.h"
 #include "funcrequest.h"
@@ -416,6 +417,8 @@ int Buffer::readHeader(LyXLex & lex)
        params().headsep.erase();
        params().footskip.erase();
 
+       ErrorList & errorList = errorLists_["Parse"];
+
        while (lex.isOK()) {
                lex.next();
                string const token = lex.getString();
@@ -445,14 +448,14 @@ int Buffer::readHeader(LyXLex & lex)
                                                           "%1$s %2$s\n"),
                                                         token,
                                                         lex.getString());
-                               errorList_.push_back(ErrorItem(_("Document header error"),
+                               errorList.push_back(ErrorItem(_("Document header error"),
                                        s, -1, 0, 0));
                        }
                }
        }
        if (begin_header_line) {
                string const s = _("\\begin_header is missing");
-               errorList_.push_back(ErrorItem(_("Document header error"),
+               errorList.push_back(ErrorItem(_("Document header error"),
                        s, -1, 0, 0));
        }
 
@@ -465,13 +468,14 @@ int Buffer::readHeader(LyXLex & lex)
 // Returns false if "\end_document" is not read (Asger)
 bool Buffer::readDocument(LyXLex & lex)
 {
-       errorList_.clear();
+       ErrorList & errorList = errorLists_["Parse"];
+       errorList.clear();
 
        lex.next();
        string const token = lex.getString();
        if (token != "\\begin_document") {
                string const s = _("\\begin_document is missing");
-               errorList_.push_back(ErrorItem(_("Document header error"),
+               errorList.push_back(ErrorItem(_("Document header error"),
                        s, -1, 0, 0));
        }
 
@@ -487,22 +491,12 @@ bool Buffer::readDocument(LyXLex & lex)
                params().textclass = 0;
        }
 
-       bool const res = text().read(*this, lex);
+       bool const res = text().read(*this, lex, errorList);
        for_each(text().paragraphs().begin(),
                 text().paragraphs().end(),
                 bind(&Paragraph::setInsetOwner, _1, &inset()));
        updateBibfilesCache();
 
-       // FIXME: the signal emission below is not needed for now because
-       // there is a manual call to "LyXView::showErrorList(_("Parse"))"
-       // in  BufferView::pimpl::loadLyXFile()
-       // Eventually, all manual call to "LyXView::showErrorList()" should
-       // be replace with this signal emission.
-       //
-       // Send the "errors" signal in case of parsing errors
-       //if (!errorList_.empty())
-       //      errors(_("Parse"));
-
        return res;
 }
 
@@ -1175,12 +1169,14 @@ int Buffer::runChktex()
                Alert::error(_("chktex failure"),
                             _("Could not run chktex successfully."));
        } else if (res > 0) {
-               // Insert all errors as errors boxes
-               bufferErrors(*this, terr);
+               // Fill-in the error list with the TeX errors
+               bufferErrors(*this, terr, errorLists_["ChkTex"]);
        }
 
        busy(false);
 
+       errors("ChkTeX");
+
        return res;
 }
 
@@ -1705,19 +1701,23 @@ void Buffer::getSourceCode(ostream & os, lyx::pit_type par_begin, lyx::pit_type
 }
 
 
-ErrorList const & Buffer::getErrorList() const
+ErrorList const & Buffer::errorList(string const & type) const
 {
-       return errorList_;
-}
+       std::map<std::string, ErrorList>::const_iterator I = errorLists_.find(type);
+       if (I == errorLists_.end())
+               return emptyErrorList_;
 
-
-void Buffer::setErrorList(ErrorList const & errorList) const
-{
-       errorList_ = errorList;
+       return I->second;
 }
 
 
-void Buffer::addError(ErrorItem const & errorItem) const
+ErrorList & Buffer::errorList(string const & type)
 {
-       errorList_.push_back(errorItem);
+       std::map<std::string, ErrorList>::iterator I = errorLists_.find(type);
+       if (I == errorLists_.end()) {
+               errorLists_[type] = emptyErrorList_;
+               return errorLists_[type];
+       }
+
+       return I->second;
 }
index 1ec123a005b83048d469186ecc3b331f09309d3f..429d0ac1cc49bf6fe6939850f8295325728abed6 100644 (file)
@@ -357,20 +357,11 @@ public:
        /// including preamble
        void getSourceCode(std::ostream & os, lyx::pit_type par_begin, lyx::pit_type par_end, bool full_source);
 
-       /// errorList_ accessor.
-       ErrorList const & getErrorList() const;
-       /// replace the internal errorList_
-       /** FIXME: This method is const for now because the ErrorList GUI
-       * showing mechanism is used by other classes in order to show their
-       * own processing errors (ex: Converter.C).
-       */
-       void setErrorList(ErrorList const &) const;
-       /// add an error to the errorList_
-       /** FIXME: This method is const for now because the ErrorList GUI
-       * showing mechanism is used by other classes in order to show their
-       * own processing errors (ex: Converter.C).
-       */
-       void addError(ErrorItem const &) const;
+       /// errorLists_ accessors.
+       //@{
+       ErrorList const & errorList(std::string const & type) const;
+       ErrorList & errorList(std::string const & type);
+       //@}
 
 private:
        /** Inserts a file into a document
@@ -394,12 +385,11 @@ private:
        /// documents), needed for appropriate update of natbib labels.
        std::vector<std::string> bibfilesCache_;
 
-       /// An error list (replaces the error insets)
-       /** FIXME: This member is mutable for now because the ErrorList GUI
-       * showing mechanism is used by other classes in order to show their
-       * own processing errors (ex: Converter.C).
-       */
-       mutable ErrorList errorList_;
+       /// Container for all sort of Buffer dependant errors.
+       std::map<std::string, ErrorList> errorLists_;
+
+       /// Empty Error List
+       ErrorList const emptyErrorList_;
 };
 
 #endif
index a306de412efbce0716e08b1f3e0d13519da27e2d..ae975e1b5ecb7ccd2efde7374beb914bf0099569 100644 (file)
@@ -212,7 +212,8 @@ Buffer * newFile(string const & filename, string const & templatename,
 }
 
 
-void bufferErrors(Buffer const & buf, TeXErrors const & terr)
+void bufferErrors(Buffer const & buf, TeXErrors const & terr,
+                                 ErrorList & errorList)
 {
        TeXErrors::Errors::const_iterator cit = terr.begin();
        TeXErrors::Errors::const_iterator end = terr.end();
@@ -231,18 +232,12 @@ void bufferErrors(Buffer const & buf, TeXErrors const & terr)
                                                          pos_end);
                } while (found && id_start == id_end && pos_start == pos_end);
 
-               buf.addError(ErrorItem(cit->error_desc,
+               errorList.push_back(ErrorItem(cit->error_desc,
                        cit->error_text, id_start, pos_start, pos_end));
        }
 }
 
 
-void bufferErrors(Buffer const & buf, ErrorList const & el)
-{
-       buf.setErrorList(el);
-}
-
-
 string const bufferFormat(Buffer const & buffer)
 {
        if (buffer.isLinuxDoc())
index dba8ec93b591957539613394505dd3c5f9075ff3..599a2dbc714f1196a1f729a8671ce6cf87b77e80 100644 (file)
@@ -37,10 +37,9 @@ Buffer * newFile(std::string const & filename, std::string const & templatename,
 
 ///return the format of the buffer on a string
 std::string const bufferFormat(Buffer const & buffer);
-///
-void bufferErrors(Buffer const &, TeXErrors const &);
-///
-void bufferErrors(Buffer const &, ErrorList const &);
+
+/// Fill in the ErrorList with the TeXErrors
+void bufferErrors(Buffer const &, TeXErrors const &, ErrorList &);
 
 /// Count the number of words in the text between these two iterators
 int countWords(DocIterator const & from, DocIterator const & to);
index 01da621ade4a1f2a2c0d707123fe50c3b9930407..5dc703fed9e1dfbc5f23fe74735f94b8868abd7c 100644 (file)
@@ -282,7 +282,7 @@ OutputParams::FLAVOR Converters::getFlavor(Graph::EdgePath const & path)
 bool Converters::convert(Buffer const * buffer,
                         string const & from_file, string const & to_file_base,
                         string const & from_format, string const & to_format,
-                        string & to_file, bool try_default)
+                        string & to_file, ErrorList & errorList, bool try_default)
 {
        string const to_ext = formats.extension(to_format);
        to_file = changeExtension(to_file_base, to_ext);
@@ -326,6 +326,8 @@ bool Converters::convert(Buffer const * buffer,
        runparams.flavor = getFlavor(edgepath);
        string path = onlyPath(from_file);
        Path p(path);
+       // empty the error list before any new conversion takes place.
+       errorList.clear();
 
        bool run_latex = false;
        string from_base = changeExtension(from_file, "");
@@ -359,7 +361,7 @@ bool Converters::convert(Buffer const * buffer,
                        run_latex = true;
                        string const command = subst(conv.command, token_from, "");
                        lyxerr[Debug::FILES] << "Running " << command << endl;
-                       if (!runLaTeX(*buffer, command, runparams))
+                       if (!runLaTeX(*buffer, command, runparams, errorList))
                                return false;
                } else {
                        if (conv.need_aux && !run_latex
@@ -367,7 +369,7 @@ bool Converters::convert(Buffer const * buffer,
                                lyxerr[Debug::FILES]
                                        << "Running " << latex_command_
                                        << " to update aux file"<<  endl;
-                               runLaTeX(*buffer, latex_command_, runparams);
+                               runLaTeX(*buffer, latex_command_, runparams, errorList);
                        }
 
                        string const infile2 = (conv.original_dir)
@@ -427,7 +429,7 @@ bool Converters::convert(Buffer const * buffer,
                                        " < " + quoteName(infile2 + ".out") +
                                        " > " + quoteName(logfile);
                                one.startscript(Systemcall::Wait, command2);
-                               if (!scanLog(*buffer, command, logfile))
+                               if (!scanLog(*buffer, command, logfile, errorList))
                                        return false;
                        }
 
@@ -516,11 +518,11 @@ bool Converters::move(string const & fmt,
 bool Converters::convert(Buffer const * buffer,
                         string const & from_file, string const & to_file_base,
                         string const & from_format, string const & to_format,
-                        bool try_default)
+                        ErrorList & errorList, bool try_default)
 {
        string to_file;
        return convert(buffer, from_file, to_file_base, from_format, to_format,
-                      to_file, try_default);
+                      to_file, errorList, try_default);
 }
 
 
@@ -537,7 +539,7 @@ bool Converters::formatIsUsed(string const & format)
 
 
 bool Converters::scanLog(Buffer const & buffer, string const & /*command*/,
-                        string const & filename)
+                        string const & filename, ErrorList & errorList)
 {
        OutputParams runparams;
        runparams.flavor = OutputParams::LATEX;
@@ -546,7 +548,7 @@ bool Converters::scanLog(Buffer const & buffer, string const & /*command*/,
        int const result = latex.scanLogFile(terr);
 
        if (result & LaTeX::ERRORS)
-               bufferErrors(buffer, terr);
+               bufferErrors(buffer, terr, errorList);
 
        return true;
 }
@@ -569,7 +571,7 @@ private:
 
 
 bool Converters::runLaTeX(Buffer const & buffer, string const & command,
-                         OutputParams const & runparams)
+                         OutputParams const & runparams, ErrorList & errorList)
 {
        buffer.busy(true);
        buffer.message(_("Running LaTeX..."));
@@ -585,7 +587,7 @@ bool Converters::runLaTeX(Buffer const & buffer, string const & command,
        int const result = latex.run(terr);
 
        if (result & LaTeX::ERRORS)
-               bufferErrors(buffer, terr);
+               bufferErrors(buffer, terr, errorList);
 
        // check return value from latex.run().
        if ((result & LaTeX::NO_LOGFILE)) {
index d2bf17328748281e16b5aa8b3b949de9c9f944e1..84841e82a82a8358b3461c65a814d707ac64f4c8 100644 (file)
@@ -20,6 +20,7 @@
 
 
 class Buffer;
+class ErrorList;
 class Format;
 class Formats;
 class OutputParams;
@@ -107,12 +108,13 @@ public:
        bool convert(Buffer const * buffer,
                     std::string const & from_file, std::string const & to_file_base,
                     std::string const & from_format, std::string const & to_format,
-                    std::string & to_file, bool try_default = false);
+                    std::string & to_file, ErrorList & errorList,
+                        bool try_default = false);
        ///
        bool convert(Buffer const * buffer,
                     std::string const & from_file, std::string const & to_file_base,
                     std::string const & from_format, std::string const & to_format,
-                    bool try_default = false);
+                        ErrorList & errorList, bool try_default = false);
        ///
        void update(Formats const & formats);
        ///
@@ -134,10 +136,10 @@ private:
        intToFormat(std::vector<int> const & input);
        ///
        bool scanLog(Buffer const & buffer, std::string const & command,
-                    std::string const & filename);
+                    std::string const & filename, ErrorList & errorList);
        ///
        bool runLaTeX(Buffer const & buffer, std::string const & command,
-                     OutputParams const &);
+                     OutputParams const &, ErrorList & errorList);
        ///
        ConverterList converterlist_;
        ///
index a60fee117c2f08f2770a0429ab22c60775f1c211..63d9aefaee11fa224a3cc89413729e6ab611abd1 100644 (file)
@@ -215,8 +215,13 @@ bool Exporter::Export(Buffer * buffer, string const & format,
                buffer->makeLaTeXFile(filename, buffer->filePath(), runparams);
        }
 
-       if (!converters.convert(buffer, filename, filename,
-                               backend_format, format, result_file))
+       string const error_type = (format == "program")? "Build" : bufferFormat(*buffer);
+       bool const success = converters.convert(buffer, filename, filename,
+               backend_format, format, result_file,
+               buffer->errorList(error_type));
+       // Emit the signal to show the error list.
+       buffer->errors(error_type);
+       if (!success)
                return false;
 
        if (!put_in_tempdir) {
index b7de9834c6ed3b1571dd800e8bc88b4b0075d62b..1bfeddc89e6f9ac7ba78c3cedb9420cbb6beb1a0 100644 (file)
@@ -25,6 +25,7 @@
 #include "bufferview_funcs.h"
 #include "cursor.h"
 #include "debug.h"
+#include "errorlist.h"
 #include "funcrequest.h"
 #include "gettext.h"
 #include "intl.h"
@@ -152,6 +153,8 @@ bool LyXView::loadLyXFile(string const & filename, bool tolastfiles)
                disconnectBuffer();
 
        bool loaded = work_area_->bufferView().loadLyXFile(filename, tolastfiles);
+       showErrorList("Parse");
+
        updateMenubar();
        updateToolbars();
        updateLayoutChoice();
@@ -170,11 +173,6 @@ void LyXView::connectBuffer(Buffer & buf)
        if (errorsConnection_.connected())
                disconnectBuffer();
 
-       // FIXME: (Abdel 15/07/2006) The connection below is not used for
-       // now.
-       // Nevertheless, it would be a very good idea to replace all manual
-       // calls of showErrorList to a call of the new modified
-       // "Buffer::errors" boost signal.
        errorsConnection_ =
                buf.errors.connect(
                        boost::bind(&LyXView::showErrorList, this, _1));
@@ -216,13 +214,11 @@ void LyXView::disconnectBuffer()
 }
 
 
-void LyXView::showErrorList(string const & action)
+void LyXView::showErrorList(string const & error_type)
 {
-       Buffer * b = work_area_->bufferView().buffer();
-       if (!b->getErrorList().empty()) {
-               string const title = bformat(_("%1$s Errors (%2$s)"),
-                       action, buffer()->fileName());
-               getDialogs().show("errorlist", title);
+       ErrorList & el = buffer()->errorList(error_type);
+       if (!el.empty()) {
+               getDialogs().show("errorlist", error_type);
        }
 }
 
index d9e8c082ec1a1e373f914152d8a4349f4ef4701f..4ea92b835ace206d0e9891527bb272868a32ab84 100644 (file)
 #include "buffer.h"
 #include "BufferView.h"
 #include "debug.h"
+#include "gettext.h"
 #include "lyxtext.h"
 #include "paragraph.h"
 #include "pariterator.h"
 
+#include "support/lstrings.h"
+
+using lyx::support::bformat;
+
 using std::endl;
 using std::string;
 
@@ -39,10 +44,13 @@ ErrorList const & ControlErrorList::errorList() const
 }
 
 
-bool ControlErrorList::initialiseParams(string const & name)
+bool ControlErrorList::initialiseParams(string const & error_type)
 {
-       errorlist_ = kernel().bufferview()->buffer()->getErrorList();
-       name_ = name;
+       Buffer * buf = kernel().bufferview()->buffer();
+       string const title = bformat(_("%1$s Errors (%2$s)"),
+               _(error_type), buf->fileName());
+       errorlist_ = buf->errorList(error_type);
+       name_ = title;
        return true;
 }
 
index b4e135cc8b60c94f991e799bbd52beedfd50c5ea..3f333515d7f33c39045f2bdd04bd4b92117f4adc 100644 (file)
@@ -39,7 +39,7 @@ extern BufferList bufferlist;
 
 
 bool Importer::Import(LyXView * lv, string const & filename,
-                     string const & format)
+                     string const & format, ErrorList & errorList)
 {
        string const displaypath = makeDisplayPath(filename);
        lv->message(bformat(_("Importing %1$s..."), displaypath));
@@ -53,7 +53,7 @@ bool Importer::Import(LyXView * lv, string const & filename,
                     it != loaders.end(); ++it) {
                        if (converters.isReachable(format, *it)) {
                                if (!converters.convert(0, filename, filename,
-                                                       format, *it))
+                                                       format, *it, errorList))
                                        return false;
                                loader_format = *it;
                                break;
index 7d62799cabd20e6034281f3c9069b3bdd7d1f55c..b63358de30346277b8b5b1d19bf31a8c8cc50589 100644 (file)
@@ -19,6 +19,7 @@
 
 
 class LyXView;
+class ErrorList;
 class Format;
 
 class Importer {
@@ -26,7 +27,7 @@ public:
        ///
        static
        bool Import(LyXView * lv, std::string const & filename,
-                   std::string const & format);
+                   std::string const & format, ErrorList & errorList);
 
        ///
        static
index d8fd28e7bd99d30c19c6726b188c984352593f7c..ac6de16921da4a95069f171a4dec6386ef13165b 100644 (file)
@@ -313,9 +313,12 @@ void updateExternal(InsetExternalParams const & params,
                return; // SUCCESS
        string const to_file_base =
                support::changeExtension(to_file, string());
+
+       // FIXME (Abdel 12/08/06): Is there a need to show these errors?
+       ErrorList el;
        /* bool const success = */
                converters.convert(&buffer, temp_file, to_file_base,
-                                  from_format, to_format, true);
+                                  from_format, to_format, el, true);
        // return success
 }
 
index 1440e9bad6c2eebe70c97ca8b8adfffe727e9bba..f4e01ea3e0a4a3297df6d19428b27695a0d4c040 100644 (file)
@@ -720,7 +720,9 @@ string const InsetGraphics::prepareFile(Buffer const & buf,
                << "\tfile to convert = " << temp_file << '\n'
                << "\t from " << from << " to " << to << '\n';
 
-       if (converters.convert(&buf, temp_file, temp_file, from, to, true)) {
+       // FIXME (Abdel 12/08/06): Is there a need to show these errors?
+       ErrorList el;
+       if (converters.convert(&buf, temp_file, temp_file, from, to, el, true)) {
                runparams.exportdata->addExternalFile(tex_format,
                                to_file, output_to_file);
                runparams.exportdata->addExternalFile("dvi",
index f6e5a6ae8de1d0f46e8bfd530ce3578cb57dfc4b..1c69cb7d1c8f0313946495210a24ff9e8f95926e 100644 (file)
@@ -163,7 +163,8 @@ void InsetText::read(Buffer const & buf, LyXLex & lex)
        // delete the initial paragraph
        Paragraph oldpar = *paragraphs().begin();
        paragraphs().clear();
-       bool res = text_.read(buf, lex);
+       ErrorList errorList;
+       bool res = text_.read(buf, lex, errorList);
        init();
 
        if (!res) {
index 422ecc0308892b827cf742728befe9b77d1eb008..9f3dddbb92bd90f8dea0f497ac9fb3b41cc364a6 100644 (file)
@@ -280,21 +280,21 @@ int LyX::exec2(int & argc, char * argv[])
                                        last_loaded = b;
                        } else {
                                Buffer * buf = bufferlist.newBuffer(s, false);
-                               if (loadLyXFile(buf, s))
+                               if (loadLyXFile(buf, s)) {
                                        last_loaded = buf;
-                               else
-                                       bufferlist.release(buf);
-
-                               ErrorList const & el = buf->getErrorList();
-                               if (!el.empty()) {
-                                       // There should be a way to use the following but I (abdel) don't know
-                                       // how to make it compile on MSVC2005.
-                                       //for_each(el.begin(), el.end(), mem_fun_ref(&LyX::printError));
-                                       for (ErrorList::const_iterator it = el.begin();
-                                               it != el.end(); ++it) {
-                                                       printError(*it);
+                                       ErrorList const & el = buf->errorList("Parse");
+                                       if (!el.empty()) {
+                                               // There should be a way to use the following but I (abdel) don't know
+                                               // how to make it compile on MSVC2005.
+                                               //for_each(el.begin(), el.end(), mem_fun_ref(&LyX::printError));
+                                               for (ErrorList::const_iterator it = el.begin();
+                                                       it != el.end(); ++it) {
+                                                               printError(*it);
+                                               }
                                        }
                                }
+                               else
+                                       bufferlist.release(buf);
                        }
                }
 
index eff30115100cfb46d06f28c5a5de4c5afb402b4d..fbce9de95a40bb0991510cf8fd3ea21bb9d04b7c 100644 (file)
@@ -837,22 +837,18 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
 
                case LFUN_BUFFER_UPDATE:
                        Exporter::Export(owner->buffer(), argument, true);
-                       owner->showErrorList(bufferFormat(*owner->buffer()));
                        break;
 
                case LFUN_BUFFER_VIEW:
                        Exporter::preview(owner->buffer(), argument);
-                       owner->showErrorList(bufferFormat(*owner->buffer()));
                        break;
 
                case LFUN_BUILD_PROGRAM:
                        Exporter::Export(owner->buffer(), "program", true);
-                       owner->showErrorList(_("Build"));
                        break;
 
                case LFUN_BUFFER_CHKTEX:
                        owner->buffer()->runChktex();
-                       owner->showErrorList(_("ChkTeX"));
                        break;
 
                case LFUN_BUFFER_EXPORT:
@@ -860,7 +856,6 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                                owner->getDialogs().show("sendto");
                        else {
                                Exporter::Export(owner->buffer(), argument, false);
-                               owner->showErrorList(bufferFormat(*owner->buffer()));
                        }
                        break;
 
@@ -892,8 +887,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                                        break;
 
                        } else {
-                               Exporter::Export(buffer, format_name, true,
-                                                filename);
+                               Exporter::Export(buffer, format_name, true, filename);
                        }
 
                        // Substitute $$FName for filename
@@ -1555,14 +1549,14 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                        recordUndoFullDocument(view());
                        buffer->params().textclass = new_class;
                        StableDocIterator backcur(view()->cursor());
-                       ErrorList el;
+                       ErrorList & el = buffer->errorList("Class Switch");
                        lyx::cap::switchBetweenClasses(
                                old_class, new_class,
                                static_cast<InsetText &>(buffer->inset()), el);
 
                        view()->setCursor(backcur.asDocIterator(&(buffer->inset())));
-                       bufferErrors(*buffer, el);
-                       owner->showErrorList(_("Class switch"));
+
+                       buffer->errors("Class Switch");
                        updateLabels(*buffer);
                        updateforce = true;
                        break;
@@ -1889,7 +1883,9 @@ void LyXFunc::doImport(string const & argument)
                }
        }
 
-       Importer::Import(owner, filename, format);
+       ErrorList errorList;
+       Importer::Import(owner, filename, format, errorList);
+       // FIXME (Abdel 12/08/06): Is there a need to display the error list here?
 }
 
 
index 8eb3931562fb88622b3d429c3ebdf7cd4e7f792f..118d832d6646c9d7275a98391ebffa62858596bc 100644 (file)
@@ -30,6 +30,7 @@ class BufferParams;
 class BufferView;
 class CursorSlice;
 class Dimension;
+class ErrorList;
 class InsetBase;
 class InsetBase_code;
 class FuncRequest;
@@ -320,7 +321,7 @@ public:
        ///
        void write(Buffer const & buf, std::ostream & os) const;
        /// returns whether we've seen our usual 'end' marker
-       bool read(Buffer const & buf, LyXLex & lex);
+       bool read(Buffer const & buf, LyXLex & lex, ErrorList & errorList);
 
        ///
        int ascent() const;
index 88904b4d0d00116437ad73c803fd126cf800f33e..a29c214577990b89877e40aa78f3efdbb827941d 100644 (file)
@@ -156,7 +156,7 @@ int numberOfHfills(Paragraph const & par, Row const & row)
 
 
 void readParToken(Buffer const & buf, Paragraph & par, LyXLex & lex,
-       string const & token, LyXFont & font, Change & change)
+       string const & token, LyXFont & font, Change & change, ErrorList & errorList)
 {
        BufferParams const & bp = buf.params();
 
@@ -180,7 +180,7 @@ void readParToken(Buffer const & buf, Paragraph & par, LyXLex & lex,
                bool hasLayout = tclass.hasLayout(layoutname);
 
                if (!hasLayout) {
-                       buf.addError(ErrorItem(_("Unknown layout"),
+                       errorList.push_back(ErrorItem(_("Unknown layout"),
                        bformat(_("Layout '%1$s' does not exist in textclass '%2$s'\nTrying to use the default instead.\n"),
                                layoutname, tclass.name()), par.id(), 0, par.size()));
                        layoutname = tclass.defaultLayoutName();
@@ -212,7 +212,7 @@ void readParToken(Buffer const & buf, Paragraph & par, LyXLex & lex,
                else {
                        lex.eatLine();
                        string line = lex.getString();
-                       buf.addError(ErrorItem(_("Unknown Inset"), line,
+                       errorList.push_back(ErrorItem(_("Unknown Inset"), line,
                                            par.id(), 0, par.size()));
                }
        } else if (token == "\\family") {
@@ -329,7 +329,7 @@ void readParToken(Buffer const & buf, Paragraph & par, LyXLex & lex,
                lyx::time_type ct;
                is >> aid >> ct;
                if (aid >= bp.author_map.size()) {
-                       buf.addError(ErrorItem(_("Change tracking error"),
+                       errorList.push_back(ErrorItem(_("Change tracking error"),
                                            bformat(_("Unknown author index for insertion: %1$d\n"), aid),
                                            par.id(), 0, par.size()));
 
@@ -343,7 +343,7 @@ void readParToken(Buffer const & buf, Paragraph & par, LyXLex & lex,
                lyx::time_type ct;
                is >> aid >> ct;
                if (aid >= bp.author_map.size()) {
-                       buf.addError(ErrorItem(_("Change tracking error"),
+                       errorList.push_back(ErrorItem(_("Change tracking error"),
                                            bformat(_("Unknown author index for deletion: %1$d\n"), aid),
                                            par.id(), 0, par.size()));
 
@@ -352,14 +352,14 @@ void readParToken(Buffer const & buf, Paragraph & par, LyXLex & lex,
                        change = Change(Change::DELETED, bp.author_map[aid], ct);
        } else {
                lex.eatLine();
-               buf.addError(ErrorItem(_("Unknown token"),
+               errorList.push_back(ErrorItem(_("Unknown token"),
                        bformat(_("Unknown token: %1$s %2$s\n"), token, lex.getString()),
                        par.id(), 0, par.size()));
        }
 }
 
 
-void readParagraph(Buffer const & buf, Paragraph & par, LyXLex & lex)
+void readParagraph(Buffer const & buf, Paragraph & par, LyXLex & lex, ErrorList & errorList)
 {
        lex.nextToken();
        string token = lex.getString();
@@ -368,7 +368,7 @@ void readParagraph(Buffer const & buf, Paragraph & par, LyXLex & lex)
 
        while (lex.isOK()) {
 
-               readParToken(buf, par, lex, token, font, change);
+               readParToken(buf, par, lex, token, font, change, errorList);
 
                lex.nextToken();
                token = lex.getString();
@@ -2083,7 +2083,7 @@ void LyXText::write(Buffer const & buf, std::ostream & os) const
 }
 
 
-bool LyXText::read(Buffer const & buf, LyXLex & lex)
+bool LyXText::read(Buffer const & buf, LyXLex & lex, ErrorList & errorList)
 {
        Paragraph::depth_type depth = 0;
 
@@ -2122,7 +2122,7 @@ bool LyXText::read(Buffer const & buf, LyXLex & lex)
 
                        // FIXME: goddamn InsetTabular makes us pass a Buffer
                        // not BufferParams
-                       ::readParagraph(buf, pars_.back(), lex);
+                       ::readParagraph(buf, pars_.back(), lex, errorList);
 
                } else if (token == "\\begin_deeper") {
                        ++depth;
index 33eec5dbe2afa5aa01da2ad151390f0d30ba9b07..027343eb4b3438ff5089f752d63a7fa1cd7751e9 100644 (file)
@@ -29,6 +29,7 @@
 #include "CutAndPaste.h"
 #include "debug.h"
 #include "dispatchresult.h"
+#include "errorlist.h"
 #include "factory.h"
 #include "funcrequest.h"
 #include "gettext.h"
@@ -731,7 +732,7 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
                        cur.setSelection();
                if (content) {
                        lyx::cap::replaceSelection(cur);
-                       pasteSelection(cur, 0);
+                       pasteSelection(cur, bv->buffer()->errorList("Paste"), 0);
                        cur.clearSelection();
                        // restore position
                        cur.pit() = std::min(cur.lastpit(), spit);
@@ -797,9 +798,12 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
                cur.message(_("Paste"));
                lyx::cap::replaceSelection(cur);
                if (isStrUnsignedInt(cmd.argument))
-                       pasteSelection(cur, convert<unsigned int>(cmd.argument));
+                       pasteSelection(cur, bv->buffer()->errorList("Paste"),
+                       convert<unsigned int>(cmd.argument));
                else
-                       pasteSelection(cur, 0);
+                       pasteSelection(cur, bv->buffer()->errorList("Paste"),
+                       0);
+               bv->buffer()->errors("Paste");
                cur.clearSelection(); // bug 393
                bv->switchKeyMap();
                finishUndo();