2002-03-07 15:06:57 +00:00
|
|
|
/**
|
2007-04-25 18:04:04 +00:00
|
|
|
* \file ControlSendto.cpp
|
2002-09-05 15:14:23 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
2002-03-07 15:06:57 +00:00
|
|
|
*
|
2002-09-05 14:10:50 +00:00
|
|
|
* \author Angus Leeming
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
* Full author contact details are available in file CREDITS.
|
2002-03-07 15:06:57 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#include "ControlSendto.h"
|
2005-04-26 09:37:52 +00:00
|
|
|
|
2007-04-26 04:41:58 +00:00
|
|
|
#include "Buffer.h"
|
|
|
|
#include "Converter.h"
|
|
|
|
#include "Format.h"
|
|
|
|
#include "FuncRequest.h"
|
|
|
|
#include "LyXRC.h"
|
2002-05-29 16:21:03 +00:00
|
|
|
|
2002-03-07 15:06:57 +00:00
|
|
|
#include "support/filetools.h"
|
|
|
|
#include "support/lstrings.h"
|
|
|
|
|
2002-03-07 15:46:34 +00:00
|
|
|
using std::vector;
|
2003-10-06 15:43:21 +00:00
|
|
|
using std::string;
|
2002-03-07 15:06:57 +00:00
|
|
|
|
2004-05-19 15:11:37 +00:00
|
|
|
namespace lyx {
|
|
|
|
|
|
|
|
using support::trim;
|
|
|
|
|
|
|
|
namespace frontend {
|
|
|
|
|
2002-06-18 15:44:30 +00:00
|
|
|
|
2004-03-27 23:11:46 +00:00
|
|
|
ControlSendto::ControlSendto(Dialog & parent)
|
2007-09-08 21:16:54 +00:00
|
|
|
: Controller(parent)
|
2002-06-18 15:44:30 +00:00
|
|
|
{}
|
2002-03-07 15:06:57 +00:00
|
|
|
|
|
|
|
|
2004-03-27 23:11:46 +00:00
|
|
|
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_;
|
2005-04-26 09:37:52 +00:00
|
|
|
kernel().dispatch(FuncRequest(getLfun(), data));
|
2004-03-27 23:11:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-03-07 15:06:57 +00:00
|
|
|
vector<Format const *> const ControlSendto::allFormats() const
|
|
|
|
{
|
2002-03-07 15:46:34 +00:00
|
|
|
// What formats can we output natively?
|
|
|
|
vector<string> exports;
|
|
|
|
exports.push_back("lyx");
|
|
|
|
exports.push_back("text");
|
|
|
|
|
2004-03-27 23:11:46 +00:00
|
|
|
Buffer const & buffer = kernel().buffer();
|
|
|
|
|
|
|
|
if (buffer.isLatex())
|
2002-03-07 15:46:34 +00:00
|
|
|
exports.push_back("latex");
|
2004-03-27 23:11:46 +00:00
|
|
|
else if (buffer.isDocBook())
|
2002-03-07 15:46:34 +00:00
|
|
|
exports.push_back("docbook");
|
2004-03-27 23:11:46 +00:00
|
|
|
else if (buffer.isLiterate())
|
2002-03-07 15:46:34 +00:00
|
|
|
exports.push_back("literate");
|
|
|
|
|
|
|
|
// Loop over these native formats and ascertain what formats we
|
|
|
|
// can convert to
|
|
|
|
vector<Format const *> to;
|
|
|
|
|
|
|
|
vector<string>::const_iterator ex_it = exports.begin();
|
|
|
|
vector<string>::const_iterator ex_end = exports.end();
|
|
|
|
for (; ex_it != ex_end; ++ex_it) {
|
|
|
|
// Start off with the native export format.
|
|
|
|
// "formats" is LyX's list of recognised formats
|
|
|
|
to.push_back(formats.getFormat(*ex_it));
|
|
|
|
|
|
|
|
Formats::const_iterator fo_it = formats.begin();
|
|
|
|
Formats::const_iterator fo_end = formats.end();
|
|
|
|
for (; fo_it != fo_end; ++fo_it) {
|
2002-04-29 09:50:34 +00:00
|
|
|
// we need to hide the default graphic export formats
|
|
|
|
// from the external menu, because we need them only
|
|
|
|
// for the internal lyx-view and external latex run
|
|
|
|
string const name = fo_it->name();
|
|
|
|
if (name != "eps" && name != "xpm" && name != "png" &&
|
2007-01-17 13:18:16 +00:00
|
|
|
theConverters().isReachable(*ex_it, name))
|
2002-03-07 18:59:07 +00:00
|
|
|
to.push_back(&(*fo_it));
|
2002-03-07 15:06:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-03-07 15:46:34 +00:00
|
|
|
// Remove repeated formats.
|
|
|
|
std::sort(to.begin(), to.end());
|
2004-01-07 17:57:47 +00:00
|
|
|
to.erase(std::unique(to.begin(), to.end()), to.end());
|
2002-03-07 15:46:34 +00:00
|
|
|
|
|
|
|
return to;
|
2002-03-07 15:06:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ControlSendto::setFormat(Format const * fmt)
|
|
|
|
{
|
|
|
|
format_ = fmt;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ControlSendto::setCommand(string const & cmd)
|
|
|
|
{
|
2002-07-28 22:50:13 +00:00
|
|
|
command_ = trim(cmd);
|
2002-03-07 15:06:57 +00:00
|
|
|
}
|
2004-05-19 15:11:37 +00:00
|
|
|
|
|
|
|
} // namespace frontend
|
|
|
|
} // namespace lyx
|