2 * \file ControlSendto.C
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Angus Leeming
8 * Full author contact details are available in file CREDITS.
13 #include "ControlSendto.h"
16 #include "converter.h"
18 #include "funcrequest.h"
21 #include "support/filetools.h"
22 #include "support/lstrings.h"
34 ControlSendto::ControlSendto(Dialog & parent)
35 : Dialog::Controller(parent)
39 bool ControlSendto::initialiseParams(std::string const &)
42 command_ = lyxrc.custom_export_command;
47 void ControlSendto::dispatchParams()
49 if (command_.empty() || !format_ || format_->name().empty())
52 string const data = format_->name() + " " + command_;
53 kernel().dispatch(FuncRequest(getLfun(), data));
57 vector<Format const *> const ControlSendto::allFormats() const
59 // What formats can we output natively?
60 vector<string> exports;
61 exports.push_back("lyx");
62 exports.push_back("text");
64 Buffer const & buffer = kernel().buffer();
67 exports.push_back("latex");
68 else if (buffer.isDocBook())
69 exports.push_back("docbook");
70 else if (buffer.isLiterate())
71 exports.push_back("literate");
73 // Loop over these native formats and ascertain what formats we
75 vector<Format const *> to;
77 vector<string>::const_iterator ex_it = exports.begin();
78 vector<string>::const_iterator ex_end = exports.end();
79 for (; ex_it != ex_end; ++ex_it) {
80 // Start off with the native export format.
81 // "formats" is LyX's list of recognised formats
82 to.push_back(formats.getFormat(*ex_it));
84 Formats::const_iterator fo_it = formats.begin();
85 Formats::const_iterator fo_end = formats.end();
86 for (; fo_it != fo_end; ++fo_it) {
87 // we need to hide the default graphic export formats
88 // from the external menu, because we need them only
89 // for the internal lyx-view and external latex run
90 string const name = fo_it->name();
91 if (name != "eps" && name != "xpm" && name != "png" &&
92 converters.isReachable(*ex_it, name))
93 to.push_back(&(*fo_it));
97 // Remove repeated formats.
98 std::sort(to.begin(), to.end());
99 to.erase(std::unique(to.begin(), to.end()), to.end());
105 void ControlSendto::setFormat(Format const * fmt)
111 void ControlSendto::setCommand(string const & cmd)
113 command_ = trim(cmd);
116 } // namespace frontend