From c4c7053d1d1cfc0b430b6565448e5b9fcacc60be Mon Sep 17 00:00:00 2001 From: Richard Heck Date: Thu, 19 Apr 2018 00:09:41 -0400 Subject: [PATCH] Fix bug #11118. Adds LFUN_MASTER_BUFFER_EXPORT. --- src/FuncCode.h | 1 + src/LyXAction.cpp | 19 +++++++++++++++++++ src/frontends/qt4/GuiView.cpp | 17 +++++++++++++++++ 3 files changed, 37 insertions(+) diff --git a/src/FuncCode.h b/src/FuncCode.h index 6d2839ab07..f19a3e6095 100644 --- a/src/FuncCode.h +++ b/src/FuncCode.h @@ -478,6 +478,7 @@ enum FuncCode LFUN_EXPORT_CANCEL, // rgh, 20171227 LFUN_BUFFER_ANONYMIZE, // sanda, 20180201 LFUN_GRAPHICS_UNIFY, // sanda, 20180207 + LFUN_MASTER_BUFFER_EXPORT, // rkh, 20180417 LFUN_LASTACTION // end of the table }; diff --git a/src/LyXAction.cpp b/src/LyXAction.cpp index 52efe1da12..6e7c96a39c 100644 --- a/src/LyXAction.cpp +++ b/src/LyXAction.cpp @@ -2506,6 +2506,25 @@ void LyXAction::init() { LFUN_MARK_TOGGLE, "mark-toggle", ReadOnly, Edit }, +/*! + * \var lyx::FuncCode lyx::LFUN_MASTER_BUFFER_EXPORT + * \li Action: Exports the master buffer (document) to the given format. + * \li Syntax: master-buffer-export [] [] + * \li Params: is one of the formats which you can find in + Tools->Preferences->File formats->Format. + Usual format you will enter is "pdf2" (pdflatex), + "pdflatex" (plain tex for pdflatex) or "ps" for postscript.\n + Note that "custom" is not allowed in this case.\n + If absent or "default", then the default output format of the + document is used.\n + If present, this argument provides the export destination + filename. Its containing folder will also be the destination + folder, where all the needed external files will be copied. + * \li Origin: rkh, 18 April 2018 + * \endvar + */ + { LFUN_MASTER_BUFFER_EXPORT, "master-buffer-export", ReadOnly, Buffer }, + /*! * \var lyx::FuncCode lyx::LFUN_MASTER_BUFFER_UPDATE * \li Action: Update (export) the document built from the master buffer, diff --git a/src/frontends/qt4/GuiView.cpp b/src/frontends/qt4/GuiView.cpp index 2e6fbd14f8..a858e8d02e 100644 --- a/src/frontends/qt4/GuiView.cpp +++ b/src/frontends/qt4/GuiView.cpp @@ -1865,6 +1865,15 @@ bool GuiView::getStatus(FuncRequest const & cmd, FuncStatus & flag) case LFUN_BUFFER_IMPORT: break; + case LFUN_MASTER_BUFFER_EXPORT: + enable = doc_buffer + && (doc_buffer->parent() != 0 + || doc_buffer->hasChildren()) + && !d.processing_thread_watcher_.isRunning() + // this launches a dialog, which would be in the wrong Buffer + && !(::lyx::operator==(cmd.argument(), "custom")); + break; + case LFUN_MASTER_BUFFER_UPDATE: case LFUN_MASTER_BUFFER_VIEW: enable = doc_buffer @@ -3701,11 +3710,19 @@ void GuiView::dispatch(FuncRequest const & cmd, DispatchResult & dr) importDocument(to_utf8(cmd.argument())); break; + case LFUN_MASTER_BUFFER_EXPORT: + if (doc_buffer) + doc_buffer = const_cast(doc_buffer->masterBuffer()); + // fall through case LFUN_BUFFER_EXPORT: { if (!doc_buffer) break; // GCC only sees strfwd.h when building merged if (::lyx::operator==(cmd.argument(), "custom")) { + // LFUN_MASTER_BUFFER_EXPORT is not enabled for this case, + // so the following test should not be needed. + // In principle, we could try to switch to such a view... + // if (cmd.action() == LFUN_BUFFER_EXPORT) dispatch(FuncRequest(LFUN_DIALOG_SHOW, "sendto"), dr); break; }