From a7eb3c4c6e822657e4ace3473be7ede095906671 Mon Sep 17 00:00:00 2001 From: Vincent van Ravesteijn Date: Thu, 27 Oct 2011 15:50:50 +0000 Subject: [PATCH] Simplify the public interface of Buffer::doExport All calls to doExport from outside of Buffer have the same algorithm to determine whether the included children parameter should be true. Moreover, this decision is only based on information from the Buffer itself. Now, Buffer only has 1 public function doExport and preview. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@40041 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/Buffer.cpp | 21 +++++++++++++++++---- src/Buffer.h | 10 ++++++++-- src/frontends/qt4/GuiView.cpp | 30 ++++++++++++------------------ 3 files changed, 37 insertions(+), 24 deletions(-) diff --git a/src/Buffer.cpp b/src/Buffer.cpp index 8204fe1aea..e6f69c8244 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -2283,10 +2283,7 @@ void Buffer::dispatch(FuncRequest const & func, DispatchResult & dr) break; } - bool const update_unincluded = - params().maintain_unincluded_children - && !params().getIncludedChildren().empty(); - if (!doExport("dvi", true, update_unincluded)) { + if (!doExport("dvi", true)) { showPrintError(absFileName()); dr.setMessage(_("Error exporting to DVI.")); break; @@ -3486,6 +3483,14 @@ bool Buffer::isExporting() const } +bool Buffer::doExport(string const & target, bool put_in_tempdir) const +{ + bool const update_unincluded = + params().maintain_unincluded_children + && !params().getIncludedChildren().empty(); + return doExport(target, put_in_tempdir, update_unincluded); +} + bool Buffer::doExport(string const & target, bool put_in_tempdir, bool includeall, string & result_file) const { @@ -3730,6 +3735,14 @@ bool Buffer::doExport(string const & target, bool put_in_tempdir, } +bool Buffer::preview(string const & format) const +{ + bool const update_unincluded = + params().maintain_unincluded_children + && !params().getIncludedChildren().empty(); + return preview(format, update_unincluded); +} + bool Buffer::preview(string const & format, bool includeall) const { MarkAsExporting exporting(this); diff --git a/src/Buffer.h b/src/Buffer.h index b6ae1f338d..135fdf8526 100644 --- a/src/Buffer.h +++ b/src/Buffer.h @@ -602,17 +602,23 @@ public: /// bool hasGuiDelegate() const; - + /// + bool doExport(std::string const & target, bool put_in_tempdir) const; + /// + bool preview(std::string const & format) const; +private: /// target is a format name optionally followed by a space /// and a destination file-name bool doExport(std::string const & target, bool put_in_tempdir, bool includeall, std::string & result_file) const; /// bool doExport(std::string const & target, bool put_in_tempdir, - bool includeall) const; + bool includeall) const; /// bool preview(std::string const & format, bool includeall = false) const; + +public: /// mark the buffer as busy exporting something, or not void setExportStatus(bool e) const; /// diff --git a/src/frontends/qt4/GuiView.cpp b/src/frontends/qt4/GuiView.cpp index d1d0336be5..a75b1ae2c6 100644 --- a/src/frontends/qt4/GuiView.cpp +++ b/src/frontends/qt4/GuiView.cpp @@ -404,8 +404,8 @@ public: Buffer const * used_buffer, docstring const & msg, docstring (*asyncFunc)(Buffer const *, Buffer *, string const &), - bool (Buffer::*syncFunc)(string const &, bool, bool) const, - bool (Buffer::*previewFunc)(string const &, bool) const); + bool (Buffer::*syncFunc)(string const &, bool) const, + bool (Buffer::*previewFunc)(string const &) const); QVector guiWorkAreas(); }; @@ -3019,10 +3019,7 @@ bool GuiView::goToFileRow(string const & argument) template docstring GuiView::GuiViewPrivate::runAndDestroy(const T& func, Buffer const * orig, Buffer * buffer, string const & format, string const & msg) { - bool const update_unincluded = - buffer->params().maintain_unincluded_children - && !buffer->params().getIncludedChildren().empty(); - bool const success = func(format, update_unincluded); + bool const success = func(format); // the cloning operation will have produced a clone of the entire set of // documents, starting from the master. so we must delete those. @@ -3042,22 +3039,22 @@ docstring GuiView::GuiViewPrivate::runAndDestroy(const T& func, Buffer const * o docstring GuiView::GuiViewPrivate::compileAndDestroy(Buffer const * orig, Buffer * buffer, string const & format) { - bool (Buffer::* mem_func)(std::string const &, bool, bool) const = &Buffer::doExport; - return runAndDestroy(bind(mem_func, buffer, _1, true, _2), orig, buffer, format, "export"); + bool (Buffer::* mem_func)(std::string const &, bool) const = &Buffer::doExport; + return runAndDestroy(bind(mem_func, buffer, _1, true), orig, buffer, format, "export"); } docstring GuiView::GuiViewPrivate::exportAndDestroy(Buffer const * orig, Buffer * buffer, string const & format) { - bool (Buffer::* mem_func)(std::string const &, bool, bool) const = &Buffer::doExport; - return runAndDestroy(bind(mem_func, buffer, _1, false, _2), orig, buffer, format, "export"); + bool (Buffer::* mem_func)(std::string const &, bool) const = &Buffer::doExport; + return runAndDestroy(bind(mem_func, buffer, _1, false), orig, buffer, format, "export"); } docstring GuiView::GuiViewPrivate::previewAndDestroy(Buffer const * orig, Buffer * buffer, string const & format) { - bool(Buffer::* mem_func)(std::string const &, bool) const = &Buffer::preview; - return runAndDestroy(bind(mem_func, buffer, _1, _2), orig, buffer, format, "preview"); + bool(Buffer::* mem_func)(std::string const &) const = &Buffer::preview; + return runAndDestroy(bind(mem_func, buffer, _1), orig, buffer, format, "preview"); } #else @@ -3092,8 +3089,8 @@ bool GuiView::GuiViewPrivate::asyncBufferProcessing( Buffer const * used_buffer, docstring const & msg, docstring (*asyncFunc)(Buffer const *, Buffer *, string const &), - bool (Buffer::*syncFunc)(string const &, bool, bool) const, - bool (Buffer::*previewFunc)(string const &, bool) const) + bool (Buffer::*syncFunc)(string const &, bool) const, + bool (Buffer::*previewFunc)(string const &) const) { if (!used_buffer) return false; @@ -3122,10 +3119,7 @@ bool GuiView::GuiViewPrivate::asyncBufferProcessing( #else if (syncFunc) { // TODO check here if it breaks exporting with Qt < 4.4 - bool const update_unincluded = - used_buffer->params().maintain_unincluded_children && - !used_buffer->params().getIncludedChildren().empty(); - return (used_buffer->*syncFunc)(format, true, update_unincluded); + return (used_buffer->*syncFunc)(format, true); } else if (previewFunc) { return (used_buffer->*previewFunc)(format, false); }