]> git.lyx.org Git - lyx.git/blobdiff - src/Buffer.cpp
Add an update parameter to BufferView::scrollToCursor and BufferView::scrollDocView...
[lyx.git] / src / Buffer.cpp
index dad081932be7661be9b8926fcd426e0fb73791b7..bb4fe6e4b02565f7ce93d9d4dc332071611f5cfc 100644 (file)
 #include "support/textutils.h"
 #include "support/types.h"
 
-#include <boost/bind.hpp>
-#include <boost/shared_ptr.hpp>
+#include "support/bind.h"
+#include "support/shared_ptr.h"
 
 #include <algorithm>
 #include <fstream>
@@ -126,7 +126,7 @@ namespace {
 
 // Do not remove the comment below, so we get merge conflict in
 // independent branches. Instead add your own.
-int const LYX_FORMAT = 386; // rgh: LyX version for InsetInfo
+int const LYX_FORMAT = 393; // rgh: rename OptArg to Argument in LyX format
 
 typedef map<string, bool> DepClean;
 typedef map<docstring, pair<InsetLabel const *, Buffer::References> > RefCache;
@@ -553,7 +553,7 @@ string Buffer::latexName(bool const no_path) const
 FileName Buffer::Impl::exportFileName() const
 {
        docstring const branch_suffix =
-               params.branchlist().getFilenameSuffix();
+               params.branchlist().getFileNameSuffix();
        if (branch_suffix.empty())
                return filename;
 
@@ -673,6 +673,10 @@ int Buffer::readHeader(Lexer & lex)
        params().isfontcolor = false;
        params().notefontcolor = lyx::rgbFromHexName("#cccccc");
        params().boxbgcolor = lyx::rgbFromHexName("#ff0000");
+       params().html_latex_start.clear();
+       params().html_latex_end.clear();
+       params().html_math_img_scale = 1.0;
+       params().output_sync_macro.erase();
 
        for (int i = 0; i < 4; ++i) {
                params().user_defined_bullet(i) = ITEMIZE_DEFAULTS[i];
@@ -771,7 +775,7 @@ bool Buffer::readDocument(Lexer & lex)
        if (!params().master.empty()) {
                FileName const master_file = makeAbsPath(params().master,
                           onlyPath(absFileName()));
-               if (isLyXFilename(master_file.absFileName())) {
+               if (isLyXFileName(master_file.absFileName())) {
                        Buffer * master = 
                                checkAndLoadLyXFile(master_file, true);
                        if (master) {
@@ -1006,6 +1010,7 @@ bool Buffer::save() const
                        backupName = FileName(addName(lyxrc.backupdir_path,
                                                      mangledName));
                }
+               // do not copy because of #6587
                if (fileName().moveTo(backupName)) {
                        madeBackup = true;
                } else {
@@ -1656,7 +1661,7 @@ void Buffer::validate(LaTeXFeatures & features) const
        updateMacros();
 
        for_each(paragraphs().begin(), paragraphs().end(),
-                boost::bind(&Paragraph::validate, _1, boost::ref(features)));
+                bind(&Paragraph::validate, _1, ref(features)));
 
        if (lyxerr.debugging(Debug::LATEX)) {
                features.showStruct();
@@ -1978,28 +1983,37 @@ void Buffer::dispatch(FuncRequest const & func, DispatchResult & dr)
                break;
 
        case LFUN_BRANCH_ADD: {
-               docstring const branch_name = func.argument();
+               docstring branch_name = func.argument();
                if (branch_name.empty()) {
                        dispatched = false;
                        break;
                }
                BranchList & branch_list = params().branchlist();
-               Branch * branch = branch_list.find(branch_name);
-               if (branch) {
-                       LYXERR0("Branch " << branch_name << " already exists.");
-                       dr.setError(true);
-                       docstring const msg = 
-                               bformat(_("Branch \"%1$s\" already exists."), branch_name);
-                       dr.setMessage(msg);
-               } else {
-                       branch_list.add(branch_name);
-                       branch = branch_list.find(branch_name);
-                       string const x11hexname = X11hexname(branch->color());
-                       docstring const str = branch_name + ' ' + from_ascii(x11hexname);
-                       lyx::dispatch(FuncRequest(LFUN_SET_COLOR, str));        
-                       dr.setError(false);
-                       dr.update(Update::Force);
+               vector<docstring> const branches =
+                       getVectorFromString(branch_name, branch_list.separator());
+               docstring msg;
+               for (vector<docstring>::const_iterator it = branches.begin();
+                    it != branches.end(); ++it) {
+                       branch_name = *it;
+                       Branch * branch = branch_list.find(branch_name);
+                       if (branch) {
+                               LYXERR0("Branch " << branch_name << " already exists.");
+                               dr.setError(true);
+                               if (!msg.empty())
+                                       msg += ("\n");
+                               msg += bformat(_("Branch \"%1$s\" already exists."), branch_name);
+                       } else {
+                               branch_list.add(branch_name);
+                               branch = branch_list.find(branch_name);
+                               string const x11hexname = X11hexname(branch->color());
+                               docstring const str = branch_name + ' ' + from_ascii(x11hexname);
+                               lyx::dispatch(FuncRequest(LFUN_SET_COLOR, str));
+                               dr.setError(false);
+                               dr.update(Update::Force);
+                       }
                }
+               if (!msg.empty())
+                       dr.setMessage(msg);
                break;
        }
 
@@ -3067,9 +3081,9 @@ public:
        AutoSaveBuffer(Buffer const & buffer, FileName const & fname)
                : buffer_(buffer), fname_(fname) {}
        ///
-       virtual boost::shared_ptr<ForkedProcess> clone() const
+       virtual shared_ptr<ForkedProcess> clone() const
        {
-               return boost::shared_ptr<ForkedProcess>(new AutoSaveBuffer(*this));
+               return shared_ptr<ForkedProcess>(new AutoSaveBuffer(*this));
        }
        ///
        int start()
@@ -3141,7 +3155,7 @@ int AutoSaveBuffer::generateChild()
 } // namespace anon
 
 
-FileName Buffer::getAutosaveFilename() const
+FileName Buffer::getAutosaveFileName() const
 {
        // if the document is unnamed try to save in the backup dir, else
        // in the default document path, and as a last try in the filePath, 
@@ -3160,7 +3174,7 @@ FileName Buffer::getAutosaveFilename() const
 
 void Buffer::removeAutosaveFile() const
 {
-       FileName const f = getAutosaveFilename();
+       FileName const f = getAutosaveFileName();
        if (f.exists())
                f.removeFile();
 }
@@ -3168,7 +3182,7 @@ void Buffer::removeAutosaveFile() const
 
 void Buffer::moveAutosaveFile(support::FileName const & oldauto) const
 {
-       FileName const newauto = getAutosaveFilename();
+       FileName const newauto = getAutosaveFileName();
        oldauto.refresh();
        if (newauto != oldauto && oldauto.exists())
                if (!oldauto.moveTo(newauto))
@@ -3187,7 +3201,7 @@ void Buffer::autoSave() const
 
        // emit message signal.
        message(_("Autosaving current document..."));
-       AutoSaveBuffer autosave(*this, getAutosaveFilename());
+       AutoSaveBuffer autosave(*this, getAutosaveFileName());
        autosave.start();
 
        d->bak_clean = true;
@@ -3961,6 +3975,7 @@ bool Buffer::reload()
        if (success) {
                updateBuffer();
                changed(true);
+               updateTitles();
                markClean();
                message(bformat(_("Document %1$s reloaded."), disp_fn));
        } else {