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"
29 using support::AddName;
35 ControlSendto::ControlSendto(Dialog & parent)
36 : Dialog::Controller(parent)
40 bool ControlSendto::initialiseParams(std::string const &)
43 command_ = lyxrc.custom_export_command;
48 void ControlSendto::dispatchParams()
50 if (command_.empty() || !format_ || format_->name().empty())
53 string const data = format_->name() + " " + command_;
54 kernel().dispatch(FuncRequest(getLfun(), data));
58 vector<Format const *> const ControlSendto::allFormats() const
60 // What formats can we output natively?
61 vector<string> exports;
62 exports.push_back("lyx");
63 exports.push_back("text");
65 Buffer const & buffer = kernel().buffer();
68 exports.push_back("latex");
69 else if (buffer.isLinuxDoc())
70 exports.push_back("linuxdoc");
71 else if (buffer.isDocBook())
72 exports.push_back("docbook");
73 else if (buffer.isLiterate())
74 exports.push_back("literate");
76 // Loop over these native formats and ascertain what formats we
78 vector<Format const *> to;
80 vector<string>::const_iterator ex_it = exports.begin();
81 vector<string>::const_iterator ex_end = exports.end();
82 for (; ex_it != ex_end; ++ex_it) {
83 // Start off with the native export format.
84 // "formats" is LyX's list of recognised formats
85 to.push_back(formats.getFormat(*ex_it));
87 Formats::const_iterator fo_it = formats.begin();
88 Formats::const_iterator fo_end = formats.end();
89 for (; fo_it != fo_end; ++fo_it) {
90 // we need to hide the default graphic export formats
91 // from the external menu, because we need them only
92 // for the internal lyx-view and external latex run
93 string const name = fo_it->name();
94 if (name != "eps" && name != "xpm" && name != "png" &&
95 converters.isReachable(*ex_it, name))
96 to.push_back(&(*fo_it));
100 // Remove repeated formats.
101 std::sort(to.begin(), to.end());
102 to.erase(std::unique(to.begin(), to.end()), to.end());
108 void ControlSendto::setFormat(Format const * fmt)
114 void ControlSendto::setCommand(string const & cmd)
116 command_ = trim(cmd);
119 } // namespace frontend