X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FBuffer.cpp;h=aa6d936aec8e6fa00b4c92a4e71c386280e21078;hb=94f0968e9212f24997cfee0d17c6f060210edbc6;hp=237a7924a1bf94b4d133f87aa724283fcac71a09;hpb=9eaa64b2cbcbfd6ef99f8ae5e0e53e533f5242c8;p=lyx.git diff --git a/src/Buffer.cpp b/src/Buffer.cpp index 237a7924a1..aa6d936aec 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -400,7 +400,7 @@ Buffer::~Buffer() Impl::BufferPositionMap::iterator end = d->children_positions.end(); for (; it != end; ++it) { Buffer * child = const_cast(it->first); - if (d->cloned_buffer_) + if (isClone()) delete child; // The child buffer might have been closed already. else if (theBufferList().isLoaded(child)) @@ -1714,7 +1714,9 @@ void Buffer::writeLyXHTMLSource(odocstream & os, docstring const & doctitle = features.htmlTitle(); os << "" - << (doctitle.empty() ? from_ascii("LyX Document") : doctitle) + << (doctitle.empty() ? + from_ascii("LyX Document") : + html::htmlize(doctitle, XHTMLStream::ESCAPE_ALL)) << "\n"; os << "\n\n" @@ -2116,7 +2118,7 @@ void Buffer::dispatch(FuncRequest const & func, DispatchResult & dr) break; case LFUN_BUFFER_EXPORT: { - ExportStatus const status = doExport(argument, false, false); + ExportStatus const status = doExport(argument, false); dr.setError(status != ExportSuccess); if (status != ExportSuccess) dr.setMessage(bformat(_("Error exporting to format: %1$s."), @@ -2125,7 +2127,7 @@ void Buffer::dispatch(FuncRequest const & func, DispatchResult & dr) } case LFUN_BUILD_PROGRAM: - doExport("program", true, false); + doExport("program", true); break; case LFUN_BUFFER_CHKTEX: @@ -2157,7 +2159,7 @@ void Buffer::dispatch(FuncRequest const & func, DispatchResult & dr) break; } else { - doExport(format_name, true, false, filename); + doExport(format_name, true, filename); } // Substitute $$FName for filename @@ -3475,23 +3477,22 @@ bool Buffer::autoSave() const } -namespace { - // helper class, to guarantee this gets reset properly - class MarkAsExporting { - public: - MarkAsExporting(Buffer const * buf) : buf_(buf) - { - LASSERT(buf_, /* */); - buf_->setExportStatus(true); - } - ~MarkAsExporting() - { - buf_->setExportStatus(false); - } - private: - Buffer const * const buf_; - }; -} +// helper class, to guarantee this gets reset properly +class Buffer::MarkAsExporting { +public: + MarkAsExporting(Buffer const * buf) : buf_(buf) + { + LASSERT(buf_, /* */); + buf_->setExportStatus(true); + } + ~MarkAsExporting() + { + buf_->setExportStatus(false); + } +private: + Buffer const * const buf_; +}; + void Buffer::setExportStatus(bool e) const @@ -3511,12 +3512,29 @@ bool Buffer::isExporting() const } -Buffer::ExportStatus Buffer::doExport(string const & target, bool put_in_tempdir) const +Buffer::ExportStatus Buffer::doExport(string const & target, bool put_in_tempdir) + const +{ + string result_file; + return doExport(target, put_in_tempdir, result_file); +} + +Buffer::ExportStatus Buffer::doExport(string const & target, bool put_in_tempdir, + string & result_file) const { bool const update_unincluded = params().maintain_unincluded_children && !params().getIncludedChildren().empty(); - return doExport(target, put_in_tempdir, update_unincluded); + + // (1) export with all included children (omit \includeonly) + if (update_unincluded) { + ExportStatus const status = + doExport(target, put_in_tempdir, true, result_file); + if (status != ExportSuccess) + return status; + } + // (2) export with included children only + return doExport(target, put_in_tempdir, false, result_file); } @@ -3729,7 +3747,10 @@ Buffer::ExportStatus Buffer::doExport(string const & target, bool put_in_tempdir if (status == CANCEL) { message(_("Document export cancelled.")); - } else if (tmp_result_file.exists()) { + return ExportCancel; + } + + if (tmp_result_file.exists()) { // Finally copy the main file use_force = use_gui ? lyxrc.export_overwrite != NO_FILES : force_overwrite != NO_FILES; @@ -3738,10 +3759,15 @@ Buffer::ExportStatus Buffer::doExport(string const & target, bool put_in_tempdir status = copyFile(format, tmp_result_file, FileName(result_file), result_file, status == FORCE); - message(bformat(_("Document exported as %1$s " - "to file `%2$s'"), - formats.prettyName(format), - makeDisplayPath(result_file))); + if (status == CANCEL) { + message(_("Document export cancelled.")); + return ExportCancel; + } else { + message(bformat(_("Document exported as %1$s " + "to file `%2$s'"), + formats.prettyName(format), + makeDisplayPath(result_file))); + } } else { // This must be a dummy converter like fax (bug 1888) message(bformat(_("Document exported as %1$s"), @@ -3752,22 +3778,6 @@ Buffer::ExportStatus Buffer::doExport(string const & target, bool put_in_tempdir } -Buffer::ExportStatus Buffer::doExport(string const & target, bool put_in_tempdir, - bool includeall) const -{ - string result_file; - // (1) export with all included children (omit \includeonly) - if (includeall) { - ExportStatus const status = - doExport(target, put_in_tempdir, true, result_file); - if (status != ExportSuccess) - return status; - } - // (2) export with included children only - return doExport(target, put_in_tempdir, false, result_file); -} - - Buffer::ExportStatus Buffer::preview(string const & format) const { bool const update_unincluded = @@ -3782,7 +3792,7 @@ Buffer::ExportStatus Buffer::preview(string const & format, bool includeall) con string result_file; // (1) export with all included children (omit \includeonly) if (includeall) { - ExportStatus const status = doExport(format, true, true); + ExportStatus const status = doExport(format, true, true, result_file); if (status != ExportSuccess) return status; }