]> git.lyx.org Git - features.git/blobdiff - src/frontends/controllers/ControlDocument.C
make ParagraphList::push_back take a reference instead of a pointer.
[features.git] / src / frontends / controllers / ControlDocument.C
index 8684470c8b7852aa3061af6af40ce95accad31bb..58b6877adf0e15d97617e63721ce37c039da633f 100644 (file)
@@ -11,7 +11,6 @@
 
 #include <config.h>
 
-
 #include "BufferView.h"
 #include "ControlDocument.h"
 #include "ViewBase.h"
@@ -20,6 +19,7 @@
 #include "lyxfind.h"
 
 #include "buffer.h"
+#include "errorlist.h"
 #include "language.h"
 #include "lyx_main.h"
 #include "lyxtextclass.h"
 #include "support/lstrings.h"
 #include "support/filetools.h"
 
-#include "support/BoostFormat.h"
-
 using std::endl;
 
 
 ControlDocument::ControlDocument(LyXView & lv, Dialogs & d)
        : ControlDialogBD(lv, d), bp_(0)
-{
-}
+{}
+
 
 ControlDocument::~ControlDocument()
 {}
@@ -65,7 +63,6 @@ void ControlDocument::apply()
        if (!bufferIsAvailable())
                return;
 
-
        classApply();
 
        view().apply();
@@ -121,40 +118,14 @@ void ControlDocument::classApply()
        buffer()->params = *bp_;
 
        lv_.message(_("Converting document to new document class..."));
-       int ret = CutAndPaste::SwitchLayoutsBetweenClasses(
-               old_class, new_class,
-               lv_.buffer()->paragraphs);
 
-       if (!ret)
-               return;
+       ErrorList el;
+       CutAndPaste::SwitchLayoutsBetweenClasses(old_class, new_class,
+                                                lv_.buffer()->paragraphs,
+                                                el);
 
-       string s;
-#if USE_BOOST_FORMAT
-       if (ret == 1) {
-               boost::format fmt(_("One paragraph could not be converted\n"
-                       "into the document class %1$s."));
-               fmt % textclasslist[new_class].name();
-               s = fmt.str();
-       } else {
-               boost::format fmt(_("%1$s paragraphs could not be converted\n"
-                       "into the document class %2$s."));
-               fmt % tostr(ret);
-               fmt % textclasslist[new_class].name();
-               s = fmt.str();
-       }
-#else
-       if (ret == 1) {
-               s += _("One paragraph could not be converted\n"
-                       "into the document class ");
-               s += textclasslist[new_class].name() + ".";
-       } else {
-               s += tostr(ret);
-               s += _(" paragraphs could not be converted\n"
-                       "into the document class ");
-               s += textclasslist[new_class].name() + ".";
-       }
-#endif
-       Alert::warning(_("Class conversion errors"), s);
+       bufferview()->setErrorList(el);
+       bufferview()->showErrorList(_("Class switch"));
 }
 
 
@@ -164,18 +135,9 @@ bool ControlDocument::loadTextclass(lyx::textclass_type tc) const
        if (success)
                return success;
 
-       string s;
-
-#if USE_BOOST_FORMAT
-       boost::format fmt(_("The document could not be converted\n"
-                       "into the document class %1$s."));
-       fmt % textclasslist[tc].name();
-       s = fmt.str();
-#else
-       s += _("The document could not be converted\n"
-              "into the document class ");
-       s += textclasslist[tc].name() + ".";
-#endif
+       string s = bformat(_("The document could not be converted\n"
+                       "into the document class %1$s."),
+                       textclasslist[tc].name());
        Alert::error(_("Could not change class"), s);
 
        return success;
@@ -200,8 +162,8 @@ void ControlDocument::saveAsDefault()
        defaults.params = params();
 
        // add an empty paragraph. Is this enough?
-       Paragraph * par = new Paragraph;
-       par->layout(params().getLyXTextClass().defaultLayout());
+       Paragraph par;
+       par.layout(params().getLyXTextClass().defaultLayout());
        defaults.paragraphs.push_back(par);
 
        defaults.writeFile(defaults.fileName());