From 71a40af1346133f40c416a478f9f1303c8fb93c9 Mon Sep 17 00:00:00 2001 From: Angus Leeming Date: Sat, 27 Mar 2004 23:11:46 +0000 Subject: [PATCH] New LFUN_EXPORT_CUSTOM. Convert the Sendto dialog to the Dialog-based scheme. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8551 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/ChangeLog | 7 ++ src/LyXAction.C | 1 + src/frontends/ChangeLog | 6 ++ src/frontends/Dialogs.h | 2 - src/frontends/controllers/ChangeLog | 4 ++ src/frontends/controllers/ControlSendto.C | 83 ++++++++--------------- src/frontends/controllers/ControlSendto.h | 18 +++-- src/frontends/gtk/ChangeLog | 7 ++ src/frontends/gtk/Dialogs.C | 45 +++++++++--- src/frontends/gtk/Makefile.am | 2 + src/frontends/guiapi.C | 6 -- src/frontends/guiapi.h | 1 - src/frontends/qt2/ChangeLog | 7 ++ src/frontends/qt2/Dialogs.C | 8 ++- src/frontends/qt2/Dialogs2.C | 14 ---- src/frontends/qt2/QSendto.C | 7 +- src/frontends/qt2/QSendto.h | 7 +- src/frontends/xforms/ChangeLog | 8 +++ src/frontends/xforms/Dialogs.C | 10 ++- src/frontends/xforms/Dialogs2.C | 15 ---- src/frontends/xforms/FormSendto.C | 6 +- src/frontends/xforms/FormSendto.h | 10 +-- src/frontends/xforms/forms/form_sendto.fd | 10 +-- src/lfuns.h | 1 + src/lyxfunc.C | 50 +++++++++++++- 25 files changed, 199 insertions(+), 136 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 8ca0c1cf0b..d97b711834 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,10 @@ +2004-03-27 Angus Leeming + + * lfuns.h: + * LyXAction.C (init): new LFUN_EXPORT_CUSTOM + + * lyxfunc.C (getStatus, dispatch): handle LFUN_EXPORT_CUSTOM. + 2004-03-27 Angus Leeming * paragraph_funcs.C (moveItem): fix memory leaks, ensure that diff --git a/src/LyXAction.C b/src/LyXAction.C index c166089e2c..ed5f0ced58 100644 --- a/src/LyXAction.C +++ b/src/LyXAction.C @@ -114,6 +114,7 @@ void LyXAction::init() { LFUN_ENDBUF, "buffer-end", ReadOnly }, { LFUN_ENDBUFSEL, "buffer-end-select", ReadOnly }, { LFUN_EXPORT, "buffer-export", ReadOnly }, + { LFUN_EXPORT_CUSTOM, "buffer-export-custom", ReadOnly }, { LFUN_IMPORT, "buffer-import", NoBuffer }, { LFUN_MENUNEW, "buffer-new", NoBuffer }, { LFUN_MENUNEWTMPLT,"buffer-new-template", NoBuffer }, diff --git a/src/frontends/ChangeLog b/src/frontends/ChangeLog index b143e27c1e..298b589597 100644 --- a/src/frontends/ChangeLog +++ b/src/frontends/ChangeLog @@ -1,3 +1,9 @@ +2004-03-27 Angus Leeming + + * Dialogs.h (showSendto): removed. + + * guiapi.[Ch] (gui_ShowSendto): removed. + 2004-03-17 Angus Leeming * Dialogs.h (showFoks): removed. diff --git a/src/frontends/Dialogs.h b/src/frontends/Dialogs.h index daf888cfba..e066fb76d6 100644 --- a/src/frontends/Dialogs.h +++ b/src/frontends/Dialogs.h @@ -73,8 +73,6 @@ public: void showPreferences(); /// void showPrint(); - /// - void showSendto(); /// bring up the spellchecker void showSpellchecker(); //@} diff --git a/src/frontends/controllers/ChangeLog b/src/frontends/controllers/ChangeLog index 965b47df86..447f87fec5 100644 --- a/src/frontends/controllers/ChangeLog +++ b/src/frontends/controllers/ChangeLog @@ -1,3 +1,7 @@ +2004-03-27 Angus Leeming + + * ControlSendto.[Ch]: converted to the dialog-based scheme. + 2004-03-24 Angus Leeming 64-bit compile fixes. diff --git a/src/frontends/controllers/ControlSendto.C b/src/frontends/controllers/ControlSendto.C index 3216d101db..4daa3abde5 100644 --- a/src/frontends/controllers/ControlSendto.C +++ b/src/frontends/controllers/ControlSendto.C @@ -10,37 +10,46 @@ #include - #include "ControlSendto.h" -#include "ViewBase.h" #include "buffer.h" #include "converter.h" #include "format.h" -#include "exporter.h" +#include "funcrequest.h" #include "lyxrc.h" #include "support/filetools.h" #include "support/lstrings.h" -#include "support/systemcall.h" using lyx::support::AddName; -using lyx::support::ChangeExtension; -using lyx::support::contains; -using lyx::support::subst; -using lyx::support::Systemcall; using lyx::support::trim; using std::vector; using std::string; -ControlSendto::ControlSendto(LyXView & lv, Dialogs & d) - : ControlDialogBD(lv, d), - format_(0), - command_(lyxrc.custom_export_command) +ControlSendto::ControlSendto(Dialog & parent) + : Dialog::Controller(parent) {} +bool ControlSendto::initialiseParams(std::string const &) +{ + format_ = 0; + command_ = lyxrc.custom_export_command; + return true; +} + + +void ControlSendto::dispatchParams() +{ + if (command_.empty() || !format_ || format_->name().empty()) + return; + + string const data = format_->name() + " " + command_; + kernel().dispatch(FuncRequest(LFUN_EXPORT_CUSTOM, data)); +} + + vector const ControlSendto::allFormats() const { // What formats can we output natively? @@ -48,15 +57,15 @@ vector const ControlSendto::allFormats() const exports.push_back("lyx"); exports.push_back("text"); -#warning Can the doc ever be all/any of these at the same time? (Lgb) - // I think some if else if is in order. - if (buffer().isLatex()) + Buffer const & buffer = kernel().buffer(); + + if (buffer.isLatex()) exports.push_back("latex"); - if (buffer().isLinuxDoc()) + else if (buffer.isLinuxDoc()) exports.push_back("linuxdoc"); - if (buffer().isDocBook()) + else if (buffer.isDocBook()) exports.push_back("docbook"); - if (buffer().isLiterate()) + else if (buffer.isLiterate()) exports.push_back("literate"); // Loop over these native formats and ascertain what formats we @@ -101,41 +110,3 @@ void ControlSendto::setCommand(string const & cmd) { command_ = trim(cmd); } - - -void ControlSendto::apply() -{ - if (!bufferIsAvailable()) - return; - - view().apply(); - - if (command_.empty() || !format_) - return; - - // The name of the file created by the conversion process - string filename; - - // Output to filename - if (format_->name() == "lyx") { - filename = ChangeExtension(buffer()->getLatexName(false), - format_->extension()); - filename = AddName(buffer()->temppath(), filename); - - if (!buffer()->writeFile(filename)) - return; - - } else { - Exporter::Export(buffer(), format_->name(), true, filename); - } - - // Substitute $$FName for filename - string command = command_; - if (!contains(command, "$$FName")) - command = "( " + command + " ) < $$FName"; - command = subst(command, "$$FName", filename); - - // Execute the command in the background - Systemcall call; - call.startscript(Systemcall::DontWait, command); -} diff --git a/src/frontends/controllers/ControlSendto.h b/src/frontends/controllers/ControlSendto.h index a86a67615e..f8e8c04808 100644 --- a/src/frontends/controllers/ControlSendto.h +++ b/src/frontends/controllers/ControlSendto.h @@ -12,19 +12,25 @@ #ifndef CONTROLSENDTO_H #define CONTROLSENDTO_H - -#include "ControlDialog_impl.h" - +#include "Dialog.h" #include class Format; /** A controller for the Custom Export dialogs. */ -class ControlSendto : public ControlDialogBD { +class ControlSendto : public Dialog::Controller { public: /// - ControlSendto(LyXView &, Dialogs &); + ControlSendto(Dialog &); + /// + virtual bool initialiseParams(std::string const & data); + /// + virtual void clearParams() {} + /// + virtual void dispatchParams(); + /// + virtual bool isBufferDependent() const { return true; } /// Return a vector of those formats that can be exported from "lyx". std::vector const allFormats() const; @@ -37,8 +43,6 @@ public: std::string const getCommand() const { return command_; }; void setCommand(std::string const &); private: - /// - virtual void apply(); /// Format const * format_; /// diff --git a/src/frontends/gtk/ChangeLog b/src/frontends/gtk/ChangeLog index 81a702872b..51a3e11341 100644 --- a/src/frontends/gtk/ChangeLog +++ b/src/frontends/gtk/ChangeLog @@ -1,3 +1,10 @@ +2004-03-27 Angus Leeming + + * Dialogs.C (build): added box, fidreplace, log, sendto, vspace + dialogs. Removed latexlog. + + * Makefile.am: associated changes. + 2004-03-26 Angus Leeming * Makefile.am: ensure that the build can find lyx_forms.h when diff --git a/src/frontends/gtk/Dialogs.C b/src/frontends/gtk/Dialogs.C index 77787c843b..86457e37b8 100644 --- a/src/frontends/gtk/Dialogs.C +++ b/src/frontends/gtk/Dialogs.C @@ -17,6 +17,7 @@ #include "ControlAboutlyx.h" #include "ControlBibtex.h" +#include "ControlBox.h" #include "ControlBranch.h" #include "ControlChanges.h" #include "ControlCharacter.h" @@ -33,11 +34,14 @@ #include "ControlNote.h" #include "ControlParagraph.h" #include "ControlRef.h" +#include "ControlSearch.h" +#include "ControlSendto.h" #include "ControlShowFile.h" #include "ControlTabular.h" #include "ControlTabularCreate.h" #include "ControlTexinfo.h" #include "ControlToc.h" +#include "ControlVSpace.h" #include "ControlWrap.h" #include "GAboutlyx.h" @@ -45,6 +49,7 @@ #include "GMathDelim.h" #include "FormBibitem.h" #include "FormBibtex.h" +#include "FormBox.h" #include "FormBranch.h" #include "FormChanges.h" #include "FormCharacter.h" @@ -64,12 +69,15 @@ #include "FormNote.h" #include "FormParagraph.h" #include "FormRef.h" +#include "FormSearch.h" +#include "FormSendto.h" #include "FormTabular.h" #include "FormTexinfo.h" #include "FormShowFile.h" #include "GTableCreate.h" #include "FormToc.h" #include "GUrl.h" +#include "FormVSpace.h" #include "FormWrap.h" #ifdef HAVE_LIBAIKSAURUS @@ -110,20 +118,21 @@ FormMathsBitmap * createFormBitmap(Dialog & parent, string const & title, } -char const * const dialognames[] = { "aboutlyx", "bibitem", "bibtex", "branch", "changes", -"character", "citation", "error", "errorlist" , "ert", "external", "file", -"float", "graphics", "include", "index", "label", "latexlog", "mathpanel", -"mathaccents", "matharrows", "mathoperators", "mathrelations", "mathgreek", -"mathmisc", "mathdots", "mathbigoperators", "mathamsmisc", -"mathamsarrows", "mathamsrelations", "mathamsnegatedrelations", "mathamsoperators", -"mathdelimiter", "mathmatrix", "mathspace", "mathstyle", -"box", "note", "paragraph", "ref", "tabular", "tabularcreate", "texinfo", +char const * const dialognames[] = { +"aboutlyx", "bibitem", "bibtex", "box", "branch", "changes", "character", +"citation", "error", "errorlist" , "ert", "external", "file", "findreplace", +"float", "graphics", "include", "index", "label", "log", "mathpanel", +"mathaccents", "matharrows", "mathoperators", "mathrelations", +"mathgreek", "mathmisc", "mathdots", "mathbigoperators", "mathamsmisc", +"mathamsarrows", "mathamsrelations", "mathamsnegatedrelations", +"mathamsoperators", "mathdelimiter", "mathmatrix", "mathspace", "mathstyle", +"box", "note", "paragraph", "ref", "sendto", "tabular", "tabularcreate", "texinfo", #ifdef HAVE_LIBAIKSAURUS "thesaurus", #endif -"toc", "url", "wrap" }; +"toc", "url", "vspace", "wrap" }; char const * const * const end_dialognames = dialognames + (sizeof(dialognames) / sizeof(char *)); @@ -168,6 +177,10 @@ Dialog * Dialogs::build(string const & name) dialog->setController(new ControlBibtex(*dialog)); dialog->setView(new FormBibtex(*dialog)); dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy); + } else if (name == "box") { + dialog->setController(new ControlBox(*dialog)); + dialog->setView(new FormBox(*dialog)); + dialog->bc().bp(new OkApplyCancelReadOnlyPolicy); } else if (name == "character") { dialog->setController(new ControlCharacter(*dialog)); dialog->setView(new FormCharacter(*dialog)); @@ -196,6 +209,10 @@ Dialog * Dialogs::build(string const & name) dialog->setController(new ControlShowFile(*dialog)); dialog->setView(new FormShowFile(*dialog)); dialog->bc().bp(new OkCancelPolicy); + } else if (name == "findreplace") { + dialog->setController(new ControlSearch(*dialog)); + dialog->setView(new FormSearch(*dialog)); + dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy); } else if (name == "float") { dialog->setController(new ControlFloat(*dialog)); dialog->setView(new FormFloat(*dialog)); @@ -220,7 +237,7 @@ Dialog * Dialogs::build(string const & name) dialog->setView(new GText(*dialog, _("Label"), _("Label:|#L"))); dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy); - } else if (name == "latexlog") { + } else if (name == "log") { dialog->setController(new ControlLog(*dialog)); dialog->setView(new FormLog(*dialog)); dialog->bc().bp(new OkCancelPolicy); @@ -424,6 +441,10 @@ Dialog * Dialogs::build(string const & name) dialog->setController(new ControlRef(*dialog)); dialog->setView(new FormRef(*dialog)); dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy); + } else if (name == "sendto") { + dialog->setController(new ControlSendto(*dialog)); + dialog->setView(new FormSendto(*dialog)); + dialog->bc().bp(new OkApplyCancelPolicy); } else if (name == "tabular") { dialog->setController(new ControlTabular(*dialog)); dialog->setView(new FormTabular(*dialog)); @@ -452,6 +473,10 @@ Dialog * Dialogs::build(string const & name) dialog->setController(new ControlCommand(*dialog, name)); dialog->setView(new GUrl(*dialog)); dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy); + } else if (name == "vspace") { + dialog->setController(new ControlVSpace(*dialog)); + dialog->setView(new FormVSpace(*dialog)); + dialog->bc().bp(new OkApplyCancelReadOnlyPolicy); } else if (name == "wrap") { dialog->setController(new ControlWrap(*dialog)); dialog->setView(new FormWrap(*dialog)); diff --git a/src/frontends/gtk/Makefile.am b/src/frontends/gtk/Makefile.am index d010a565a9..0400248a57 100644 --- a/src/frontends/gtk/Makefile.am +++ b/src/frontends/gtk/Makefile.am @@ -82,6 +82,7 @@ xforms_objects = \ ../xforms/FormBase.lo \ ../xforms/FormBibitem.lo \ ../xforms/FormBibtex.lo \ + ../xforms/FormBox.lo \ ../xforms/FormBranch.lo \ ../xforms/FormBrowser.lo \ ../xforms/FormChanges.lo \ @@ -118,6 +119,7 @@ xforms_objects = \ ../xforms/FormText.lo \ ../xforms/FormThesaurus.lo \ ../xforms/FormToc.lo \ + ../xforms/FormVSpace.lo \ ../xforms/FormWrap.lo \ ../xforms/freebrowser.lo \ ../xforms/input_validators.lo \ diff --git a/src/frontends/guiapi.C b/src/frontends/guiapi.C index 49edd6ae41..d5b455ccaf 100644 --- a/src/frontends/guiapi.C +++ b/src/frontends/guiapi.C @@ -46,12 +46,6 @@ void gui_ShowPrint(Dialogs & d) } -void gui_ShowSendto(Dialogs & d) -{ - d.showSendto(); -} - - void gui_ShowSpellchecker(Dialogs & d) { d.showSpellchecker(); diff --git a/src/frontends/guiapi.h b/src/frontends/guiapi.h index 4250df825c..7072cc0e42 100644 --- a/src/frontends/guiapi.h +++ b/src/frontends/guiapi.h @@ -24,7 +24,6 @@ void gui_ShowDocument(Dialogs &); void gui_ShowPreamble(Dialogs &); void gui_ShowPreferences(Dialogs &); void gui_ShowPrint(Dialogs &); -void gui_ShowSendto(Dialogs &); void gui_ShowSpellchecker(Dialogs &); } // extern "C" diff --git a/src/frontends/qt2/ChangeLog b/src/frontends/qt2/ChangeLog index 342f85fde2..714aaa00cb 100644 --- a/src/frontends/qt2/ChangeLog +++ b/src/frontends/qt2/ChangeLog @@ -1,3 +1,10 @@ +2004-03-27 Angus Leeming + + * Dialogs.C (build): added sendto, dialog. + * Dialogs2.C (showSendto): removed. + + * QSendto.[Ch]: converted to the Dialog-based scheme. + 2004-03-25 Jean-Marc Lasgouttes * QLyXKeySym.C (print): new method; print a KeySym using Qt syntax diff --git a/src/frontends/qt2/Dialogs.C b/src/frontends/qt2/Dialogs.C index ecbd3a1332..c9b973a64c 100644 --- a/src/frontends/qt2/Dialogs.C +++ b/src/frontends/qt2/Dialogs.C @@ -31,6 +31,7 @@ #include "ControlParagraph.h" #include "ControlRef.h" #include "ControlSearch.h" +#include "ControlSendto.h" #include "ControlShowFile.h" #include "ControlTabular.h" #include "ControlTabularCreate.h" @@ -65,6 +66,7 @@ #include "QParagraph.h" #include "QRef.h" #include "QSearch.h" +#include "QSendto.h" #include "QShowFile.h" #include "QTabular.h" #include "QTabularCreate.h" @@ -91,7 +93,7 @@ char const * const dialognames[] = { "citation", "error", "errorlist", "ert", "external", "file", "findreplace", "float", "graphics", "include", "index", "label", "log", "mathpanel", "mathdelimiter", "mathmatrix", -"note", "paragraph", "ref", "tabular", "tabularcreate", "texinfo", +"note", "paragraph", "ref", "sendto", "tabular", "tabularcreate", "texinfo", #ifdef HAVE_LIBAIKSAURUS "thesaurus", @@ -234,6 +236,10 @@ Dialog * Dialogs::build(string const & name) dialog->setController(new ControlRef(*dialog)); dialog->setView(new QRef(*dialog)); dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy); + } else if (name == "sendto") { + dialog->setController(new ControlSendto(*dialog)); + dialog->setView(new QSendto(*dialog)); + dialog->bc().bp(new OkApplyCancelPolicy); } else if (name == "tabular") { dialog->setController(new ControlTabular(*dialog)); dialog->setView(new QTabular(*dialog)); diff --git a/src/frontends/qt2/Dialogs2.C b/src/frontends/qt2/Dialogs2.C index 1cf38f7789..0dbd726562 100644 --- a/src/frontends/qt2/Dialogs2.C +++ b/src/frontends/qt2/Dialogs2.C @@ -19,7 +19,6 @@ #include "ControlDocument.h" #include "ControlPrint.h" -#include "ControlSendto.h" #include "ControlSpellchecker.h" #include "QDocument.h" @@ -32,8 +31,6 @@ #include "QPrefsDialog.h" #include "QPrint.h" #include "QLPrintDialog.h" -#include "QSendto.h" -#include "QSendtoDialog.h" #include "QSpellchecker.h" #include "QSpellcheckerDialog.h" @@ -49,9 +46,6 @@ PrefsDialog; typedef GUI PrintDialog; -typedef GUI -SendtoDialog; - typedef GUI SpellcheckerDialog; @@ -61,7 +55,6 @@ struct Dialogs::Impl { DocumentDialog document; PrefsDialog prefs; PrintDialog print; - SendtoDialog sendto; SpellcheckerDialog spellchecker; }; @@ -70,7 +63,6 @@ Dialogs::Impl::Impl(LyXView & lv, Dialogs & d) : document(lv, d), prefs(lv, d), print(lv, d), - sendto(lv, d), spellchecker(lv, d) {} @@ -113,12 +105,6 @@ void Dialogs::showPrint() } -void Dialogs::showSendto() -{ - pimpl_->sendto.controller().show(); -} - - void Dialogs::showSpellchecker() { pimpl_->spellchecker.controller().show(); diff --git a/src/frontends/qt2/QSendto.C b/src/frontends/qt2/QSendto.C index eaed4b15aa..5bfb010f1c 100644 --- a/src/frontends/qt2/QSendto.C +++ b/src/frontends/qt2/QSendto.C @@ -10,7 +10,6 @@ #include - #include "Qt2BC.h" #include "ControlSendto.h" #include "QSendtoDialog.h" @@ -26,11 +25,11 @@ using std::vector; using std::string; -typedef Qt2CB > base_class; +typedef QController > base_class; -QSendto::QSendto() - : base_class(_("LyX: Send Document to Command")) +QSendto::QSendto(Dialog & parent) + : base_class(parent, _("LyX: Send Document to Command")) { } diff --git a/src/frontends/qt2/QSendto.h b/src/frontends/qt2/QSendto.h index 7477702886..7234756736 100644 --- a/src/frontends/qt2/QSendto.h +++ b/src/frontends/qt2/QSendto.h @@ -12,8 +12,7 @@ #ifndef QSENDTO_H #define QSENDTO_H - -#include "Qt2Base.h" +#include "QDialogView.h" #include @@ -24,13 +23,13 @@ class Format; /** This class provides a Qt implementation of the Custom Export Dialog. */ class QSendto - : public Qt2CB > + : public QController > { public: /// friend class QSendtoDialog; /// - QSendto(); + QSendto(Dialog &); protected: virtual bool isValid(); private: diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index 4d8f60dace..dd23ea4d62 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -1,3 +1,11 @@ +2004-03-27 Angus Leeming + + * Dialogs.C (build): added sendto, dialog. + * Dialogs2.C (showSendto): removed. + + * FormSendto.[Ch]: + * forms/form_sendto.fd: converted to the Dialog-based scheme. + 2004-03-26 Jean-Marc Lasgouttes * XLyXKeySym.C (print): new method; print a keysym using diff --git a/src/frontends/xforms/Dialogs.C b/src/frontends/xforms/Dialogs.C index 831ff2f9dd..2e07275727 100644 --- a/src/frontends/xforms/Dialogs.C +++ b/src/frontends/xforms/Dialogs.C @@ -32,6 +32,7 @@ #include "ControlParagraph.h" #include "ControlRef.h" #include "ControlSearch.h" +#include "ControlSendto.h" #include "ControlShowFile.h" #include "ControlTabular.h" #include "ControlTabularCreate.h" @@ -66,6 +67,7 @@ #include "FormTabular.h" #include "FormTexinfo.h" #include "FormSearch.h" +#include "FormSendto.h" #include "FormShowFile.h" #include "FormTabularCreate.h" #include "FormText.h" @@ -112,14 +114,14 @@ FormMathsBitmap * createFormBitmap(Dialog & parent, string const & title, char const * const dialognames[] = { -"aboutlyx", "bibitem", "bibtex", "branch", "box", "changes", "character", +"aboutlyx", "bibitem", "bibtex", "box", "branch", "changes", "character", "citation", "error", "errorlist" , "ert", "external", "file", "findreplace", "float", "graphics", "include", "index", "label", "log", "mathpanel", "mathaccents", "matharrows", "mathoperators", "mathrelations", "mathgreek", "mathmisc", "mathdots", "mathbigoperators", "mathamsmisc", "mathamsarrows", "mathamsrelations", "mathamsnegatedrelations", "mathamsoperators", "mathdelimiter", "mathmatrix", "mathspace", "mathstyle", -"note", "paragraph", "ref", "tabular", "tabularcreate", "texinfo", +"note", "paragraph", "ref", "sendto", "tabular", "tabularcreate", "texinfo", #ifdef HAVE_LIBAIKSAURUS "thesaurus", @@ -429,6 +431,10 @@ Dialog * Dialogs::build(string const & name) dialog->setController(new ControlRef(*dialog)); dialog->setView(new FormRef(*dialog)); dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy); + } else if (name == "sendto") { + dialog->setController(new ControlSendto(*dialog)); + dialog->setView(new FormSendto(*dialog)); + dialog->bc().bp(new OkApplyCancelPolicy); } else if (name == "tabular") { dialog->setController(new ControlTabular(*dialog)); dialog->setView(new FormTabular(*dialog)); diff --git a/src/frontends/xforms/Dialogs2.C b/src/frontends/xforms/Dialogs2.C index 082c8398d8..bdaa5ec709 100644 --- a/src/frontends/xforms/Dialogs2.C +++ b/src/frontends/xforms/Dialogs2.C @@ -35,10 +35,6 @@ #include "FormPrint.h" #include "forms/form_print.h" -#include "ControlSendto.h" -#include "FormSendto.h" -#include "forms/form_sendto.h" - #include "ControlSpellchecker.h" #include "FormSpellchecker.h" #include "forms/form_spellchecker.h" @@ -55,9 +51,6 @@ PreferencesDialog; typedef GUI PrintDialog; -typedef GUI -SendtoDialog; - typedef GUI SpellcheckerDialog; @@ -69,7 +62,6 @@ struct Dialogs::Impl { PreambleDialog preamble; PreferencesDialog preferences; PrintDialog print; - SendtoDialog sendto; SpellcheckerDialog spellchecker; }; @@ -79,7 +71,6 @@ Dialogs::Impl::Impl(LyXView & lv, Dialogs & d) preamble(lv, d), preferences(lv, d), print(lv, d), - sendto(lv, d), spellchecker(lv, d) {} @@ -120,12 +111,6 @@ void Dialogs::showPrint() } -void Dialogs::showSendto() -{ - pimpl_->sendto.controller().show(); -} - - void Dialogs::showSpellchecker() { pimpl_->spellchecker.controller().show(); diff --git a/src/frontends/xforms/FormSendto.C b/src/frontends/xforms/FormSendto.C index 589610c8d2..b1b08ffdcb 100644 --- a/src/frontends/xforms/FormSendto.C +++ b/src/frontends/xforms/FormSendto.C @@ -30,10 +30,10 @@ using std::vector; using std::string; -typedef FormCB > base_class; +typedef FormController > base_class; -FormSendto::FormSendto() - : base_class(_("Send document to command")) +FormSendto::FormSendto(Dialog & parent) + : base_class(parent, _("Send document to command")) {} diff --git a/src/frontends/xforms/FormSendto.h b/src/frontends/xforms/FormSendto.h index c750a841ee..b4c85937e6 100644 --- a/src/frontends/xforms/FormSendto.h +++ b/src/frontends/xforms/FormSendto.h @@ -12,20 +12,20 @@ #ifndef FORMSENDTO_H #define FORMSENDTO_H - -#include "FormBase.h" +#include "FormDialogView.h" #include +struct FD_sendto; class ControlSendto; class Format; -struct FD_sendto; /** This class provides an XForms implementation of the Custom Export Dialog. */ -class FormSendto : public FormCB > { +class FormSendto + : public FormController > { public: /// - FormSendto(); + FormSendto(Dialog &); private: /// Apply from dialog (modify or create inset) virtual void apply(); diff --git a/src/frontends/xforms/forms/form_sendto.fd b/src/frontends/xforms/forms/form_sendto.fd index 67c6b5a5bb..3a178d106a 100644 --- a/src/frontends/xforms/forms/form_sendto.fd +++ b/src/frontends/xforms/forms/form_sendto.fd @@ -45,7 +45,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NorthWest FL_SouthEast name: browser_formats -callback: C_FormBaseInputCB +callback: C_FormDialogView_InputCB argument: 0 -------------------- @@ -63,7 +63,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_SouthWest FL_SouthEast name: input_command -callback: C_FormBaseInputCB +callback: C_FormDialogView_InputCB argument: 0 -------------------- @@ -81,7 +81,7 @@ shortcut: ^M resize: FL_RESIZE_ALL gravity: FL_SouthEast FL_SouthEast name: button_ok -callback: C_FormBaseOKCB +callback: C_FormDialogView_OKCB argument: 0 -------------------- @@ -99,7 +99,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_SouthEast FL_SouthEast name: button_apply -callback: C_FormBaseApplyCB +callback: C_FormDialogView_ApplyCB argument: 0 -------------------- @@ -117,7 +117,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_SouthEast FL_SouthEast name: button_close -callback: C_FormBaseCancelCB +callback: C_FormDialogView_CancelCB argument: 0 ============================== diff --git a/src/lfuns.h b/src/lfuns.h index 118a032a9a..1718935518 100644 --- a/src/lfuns.h +++ b/src/lfuns.h @@ -335,6 +335,7 @@ enum kb_action { LFUN_WORD_FIND, LFUN_WORD_REPLACE, // 255 + LFUN_EXPORT_CUSTOM, LFUN_LASTACTION // end of the table }; diff --git a/src/lyxfunc.C b/src/lyxfunc.C index 68ba1ef6c6..d52e650baf 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -78,6 +78,7 @@ #include "support/globbing.h" #include "support/path.h" #include "support/path_defines.h" +#include "support/systemcall.h" #include "support/tostr.h" #include "support/std_sstream.h" #include "support/os.h" @@ -88,6 +89,7 @@ using lyx::support::AddName; using lyx::support::AddPath; using lyx::support::bformat; using lyx::support::ChangeExtension; +using lyx::support::contains; using lyx::support::FileFilterList; using lyx::support::FileInfo; using lyx::support::FileSearch; @@ -103,7 +105,9 @@ using lyx::support::rtrim; using lyx::support::split; using lyx::support::strToInt; using lyx::support::strToUnsignedInt; +using lyx::support::subst; using lyx::support::system_lyxdir; +using lyx::support::Systemcall; using lyx::support::token; using lyx::support::trim; using lyx::support::user_lyxdir; @@ -477,6 +481,7 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const case LFUN_KMAP_SEC: case LFUN_KMAP_TOGGLE: case LFUN_REPEAT: + case LFUN_EXPORT_CUSTOM: case LFUN_SEQUENCE: case LFUN_SAVEPREFERENCES: case LFUN_SCREEN_FONT_UPDATE: @@ -675,13 +680,56 @@ void LyXFunc::dispatch(FuncRequest const & cmd, bool verbose) case LFUN_EXPORT: if (argument == "custom") - owner->getDialogs().showSendto(); + owner->getDialogs().show("sendto"); else { Exporter::Export(owner->buffer(), argument, false); view()->showErrorList(BufferFormat(*owner->buffer())); } break; + case LFUN_EXPORT_CUSTOM: { + string format_name; + string command = split(argument, format_name, ' '); + Format const * format = formats.getFormat(format_name); + if (!format) { + lyxerr << "Format \"" << format_name + << "\" not recognized!" + << std::endl; + break; + } + + Buffer * buffer = owner->buffer(); + + // The name of the file created by the conversion process + string filename; + + // Output to filename + if (format->name() == "lyx") { + string const latexname = + buffer->getLatexName(false); + filename = ChangeExtension(latexname, + format->extension()); + filename = AddName(buffer->temppath(), filename); + + if (!buffer->writeFile(filename)) + break; + + } else { + Exporter::Export(buffer, format_name, true, + filename); + } + + // Substitute $$FName for filename + if (!contains(command, "$$FName")) + command = "( " + command + " ) < $$FName"; + command = subst(command, "$$FName", filename); + + // Execute the command in the background + Systemcall call; + call.startscript(Systemcall::DontWait, command); + break; + } + case LFUN_IMPORT: doImport(argument); break; -- 2.39.2