]> git.lyx.org Git - lyx.git/blobdiff - src/Buffer.cpp
Track whether title has been issued via OutputParams.
[lyx.git] / src / Buffer.cpp
index 9b6727fd46c54af1751b59b5af1ff5069c5fc1fb..ec11ac2c88b3ca433b9d3d04495dec41b4cfc863 100644 (file)
@@ -2261,10 +2261,6 @@ Buffer::ExportStatus Buffer::writeLyXHTMLSource(odocstream & os,
                if (!styles.empty())
                        os << "\n<!-- Text Class Preamble -->\n" << styles << '\n';
 
-               styles = features.getPreambleSnippets().str;
-               if (!styles.empty())
-                       os << "\n<!-- Preamble Snippets -->\n" << styles << '\n';
-
                // we will collect CSS information in a stream, and then output it
                // either here, as part of the header, or else in a separate file.
                odocstringstream css;
@@ -3177,7 +3173,7 @@ Language const * Buffer::language() const
 }
 
 
-docstring const Buffer::B_(string const & l10n) const
+docstring Buffer::B_(string const & l10n) const
 {
        return params().B_(l10n);
 }
@@ -3408,7 +3404,7 @@ vector<pair<docstring, string>> const Buffer::prepareBibFilePaths(OutputParams c
                        enc = params().bibFileEncoding(utf8input);
 
                bool recorded = false;
-               for (pair<docstring, string> pe : res) {
+               for (auto const & pe : res) {
                        if (pe.first == path) {
                                recorded = true;
                                break;
@@ -3996,7 +3992,7 @@ void Buffer::setInsetLabel(docstring const & label, InsetLabel const * il,
 InsetLabel const * Buffer::insetLabel(docstring const & label,
                                      bool const active) const
 {
-       for (auto & rc : masterBuffer()->d->label_cache_) {
+       for (auto const & rc : masterBuffer()->d->label_cache_) {
                if (rc.label == label && (rc.active || !active))
                        return rc.inset;
        }
@@ -4235,91 +4231,6 @@ void Buffer::setGuiDelegate(frontend::GuiBufferDelegate * gui)
 }
 
 
-
-namespace {
-
-class AutoSaveBuffer : public ForkedProcess {
-public:
-       ///
-       AutoSaveBuffer(Buffer const & buffer, FileName const & fname)
-               : buffer_(buffer), fname_(fname) {}
-       ///
-       virtual shared_ptr<ForkedProcess> clone() const
-       {
-               return make_shared<AutoSaveBuffer>(*this);
-       }
-       ///
-       int start()
-       {
-               command_ = to_utf8(bformat(_("Auto-saving %1$s"),
-                                                from_utf8(fname_.absFileName())));
-               return run(DontWait);
-       }
-private:
-       ///
-       virtual int generateChild();
-       ///
-       Buffer const & buffer_;
-       FileName fname_;
-};
-
-
-int AutoSaveBuffer::generateChild()
-{
-#if defined(__APPLE__)
-       /* FIXME fork() is not usable for autosave on Mac OS X 10.6 (snow leopard)
-        *   We should use something else like threads.
-        *
-        * Since I do not know how to determine at run time what is the OS X
-        * version, I just disable forking altogether for now (JMarc)
-        */
-       pid_t const pid = -1;
-#else
-       // tmp_ret will be located (usually) in /tmp
-       // will that be a problem?
-       // Note that this calls ForkedCalls::fork(), so it's
-       // ok cross-platform.
-       pid_t const pid = fork();
-       // If you want to debug the autosave
-       // you should set pid to -1, and comment out the fork.
-       if (pid != 0 && pid != -1)
-               return pid;
-#endif
-
-       // pid = -1 signifies that lyx was unable
-       // to fork. But we will do the save
-       // anyway.
-       bool failed = false;
-       TempFile tempfile("lyxautoXXXXXX.lyx");
-       tempfile.setAutoRemove(false);
-       FileName const tmp_ret = tempfile.name();
-       if (!tmp_ret.empty()) {
-               if (!buffer_.writeFile(tmp_ret))
-                       failed = true;
-               else if (!tmp_ret.moveTo(fname_))
-                       failed = true;
-       } else
-               failed = true;
-
-       if (failed) {
-               // failed to write/rename tmp_ret so try writing direct
-               if (!buffer_.writeFile(fname_)) {
-                       // It is dangerous to do this in the child,
-                       // but safe in the parent, so...
-                       if (pid == -1) // emit message signal.
-                               buffer_.message(_("Autosave failed!"));
-               }
-       }
-
-       if (pid == 0) // we are the child so...
-               _exit(0);
-
-       return pid;
-}
-
-} // namespace
-
-
 FileName Buffer::getEmergencyFileName() const
 {
        return FileName(d->filename.absFileName() + ".emergency");
@@ -4416,7 +4327,7 @@ Buffer::ExportStatus Buffer::doExport(string const & target, bool put_in_tempdir
        string & result_file) const
 {
        bool const update_unincluded =
-                       params().maintain_unincluded_children
+                       params().maintain_unincluded_children != BufferParams::CM_None
                        && !params().getIncludedChildren().empty();
 
        // (1) export with all included children (omit \includeonly)
@@ -4587,8 +4498,9 @@ Buffer::ExportStatus Buffer::doExport(string const & target, bool put_in_tempdir
        string const ext = theFormats().extension(format);
        FileName const tmp_result_file(changeExtension(filename, ext));
        Converters::RetVal const retval = 
-               converters.convert(this, FileName(filename), tmp_result_file, 
-               FileName(absFileName()), backend_format, format, error_list);
+               converters.convert(this, FileName(filename), tmp_result_file,
+                                  FileName(absFileName()), backend_format, format,
+                                  error_list, Converters::none, includeall);
        if (retval == Converters::KILLED)
                return ExportCancel;
        bool success = (retval == Converters::SUCCESS);
@@ -4703,7 +4615,7 @@ Buffer::ExportStatus Buffer::doExport(string const & target, bool put_in_tempdir
 Buffer::ExportStatus Buffer::preview(string const & format) const
 {
        bool const update_unincluded =
-                       params().maintain_unincluded_children
+                       params().maintain_unincluded_children != BufferParams::CM_None
                        && !params().getIncludedChildren().empty();
        return preview(format, update_unincluded);
 }
@@ -5304,7 +5216,7 @@ void Buffer::Impl::setLabel(ParIterator & it, UpdateType utype) const
 }
 
 
-void Buffer::updateBuffer(ParIterator & parit, UpdateType utype) const
+void Buffer::updateBuffer(ParIterator & parit, UpdateType utype, bool const deleted) const
 {
        // LASSERT: Is it safe to continue here, or should we just return?
        LASSERT(parit.pit() == 0, /**/);
@@ -5350,7 +5262,7 @@ void Buffer::updateBuffer(ParIterator & parit, UpdateType utype) const
                // now the insets
                for (auto const & insit : parit->insetList()) {
                        parit.pos() = insit.pos;
-                       insit.inset->updateBuffer(parit, utype);
+                       insit.inset->updateBuffer(parit, utype, deleted || parit->isDeleted(insit.pos));
                        changed |= insit.inset->isChanged();
                }