From: Vincent van Ravesteijn Date: Thu, 27 Oct 2011 20:00:08 +0000 (+0000) Subject: Let Buffer::preview return an error value X-Git-Tag: 2.1.0beta1~2457 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=e74468b4beaebd4b6d5983c28f38b5cb1331e574;p=features.git Let Buffer::preview return an error value TODO: - Also let the public function return an error value, - Move all user interaction (Alerts etc.) out of Buffer. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@40044 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/Buffer.cpp b/src/Buffer.cpp index ad00008b88..53fa935451 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -3744,20 +3744,27 @@ bool Buffer::preview(string const & format) const bool const update_unincluded = params().maintain_unincluded_children && !params().getIncludedChildren().empty(); - return preview(format, update_unincluded); + ExportStatus const status = preview(format, update_unincluded); + return (status == PreviewSuccess); } -bool Buffer::preview(string const & format, bool includeall) const +Buffer::ExportStatus Buffer::preview(string const & format, bool includeall) const { MarkAsExporting exporting(this); string result_file; // (1) export with all included children (omit \includeonly) - if (includeall && (doExport(format, true, true) != ExportSuccess)) - return false; + if (includeall) { + ExportStatus const status = doExport(format, true, true); + if (status != ExportSuccess) + return status; + } // (2) export with included children only - if (doExport(format, true, false, result_file) != ExportSuccess) - return false; - return formats.view(*this, FileName(result_file), format); + ExportStatus const status = doExport(format, true, false, result_file); + if (status != ExportSuccess) + return status; + if (!formats.view(*this, FileName(result_file), format)) + return PreviewError; + return PreviewSuccess; } diff --git a/src/Buffer.h b/src/Buffer.h index e225f650a3..589c4500e4 100644 --- a/src/Buffer.h +++ b/src/Buffer.h @@ -123,11 +123,15 @@ public: }; enum ExportStatus { + // export ExportSuccess, ExportError, ExportNoPathToFormat, ExportTexPathHasSpaces, - ExportConverterError + ExportConverterError, + // preview + PreviewSuccess, + PreviewError }; /// Method to check if a file is externally modified, used by @@ -623,7 +627,7 @@ private: ExportStatus doExport(std::string const & target, bool put_in_tempdir, bool includeall) const; /// - bool preview(std::string const & format, bool includeall = false) const; + ExportStatus preview(std::string const & format, bool includeall = false) const; public: /// mark the buffer as busy exporting something, or not