2002-09-05 14:10:50 +00:00
|
|
|
/**
|
|
|
|
* \file ControlLog.C
|
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.
|
2001-03-20 10:14:03 +00:00
|
|
|
*
|
2002-09-05 14:10:50 +00:00
|
|
|
* \author John Levon
|
|
|
|
* \author Angus Leeming
|
2001-03-20 10:14:03 +00:00
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
* Full author contact details are available in file CREDITS.
|
2001-03-20 10:14:03 +00:00
|
|
|
*/
|
|
|
|
|
2001-04-26 18:40:38 +00:00
|
|
|
#include <config.h>
|
|
|
|
|
2002-05-29 16:21:03 +00:00
|
|
|
#include "ControlLog.h"
|
|
|
|
|
2003-12-05 13:37:23 +00:00
|
|
|
#include "gettext.h"
|
|
|
|
#include "lyxlex.h"
|
2001-03-20 10:14:03 +00:00
|
|
|
|
2004-07-24 10:55:30 +00:00
|
|
|
#include <sstream>
|
2003-12-05 13:37:23 +00:00
|
|
|
#include <fstream>
|
|
|
|
|
|
|
|
using std::istringstream;
|
|
|
|
using std::ostream;
|
2003-10-06 15:43:21 +00:00
|
|
|
using std::string;
|
|
|
|
|
2004-05-19 15:11:37 +00:00
|
|
|
namespace lyx {
|
2006-12-04 15:07:05 +00:00
|
|
|
|
|
|
|
using support::FileName;
|
|
|
|
|
2004-05-19 15:11:37 +00:00
|
|
|
namespace frontend {
|
2003-10-06 15:43:21 +00:00
|
|
|
|
2003-03-25 18:13:46 +00:00
|
|
|
ControlLog::ControlLog(Dialog & parent)
|
2003-12-05 13:37:23 +00:00
|
|
|
: Dialog::Controller(parent),
|
|
|
|
type_(LatexLog)
|
2002-06-18 15:44:30 +00:00
|
|
|
{}
|
2001-03-20 10:14:03 +00:00
|
|
|
|
|
|
|
|
2003-12-05 13:37:23 +00:00
|
|
|
bool ControlLog::initialiseParams(string const & data)
|
2001-03-20 10:14:03 +00:00
|
|
|
{
|
2003-12-05 13:37:23 +00:00
|
|
|
istringstream is(data);
|
|
|
|
LyXLex lex(0,0);
|
|
|
|
lex.setStream(is);
|
|
|
|
|
|
|
|
string logtype, logfile;
|
2006-07-17 20:06:58 +00:00
|
|
|
lex >> logtype;
|
|
|
|
if (lex.isOK()) {
|
|
|
|
lex.next(true);
|
|
|
|
logfile = lex.getString();
|
|
|
|
}
|
2003-12-05 13:37:23 +00:00
|
|
|
if (!lex)
|
|
|
|
// Parsing of the data failed.
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (logtype == "latex")
|
|
|
|
type_ = LatexLog;
|
|
|
|
else if (logtype == "literate")
|
|
|
|
type_ = LiterateLog;
|
|
|
|
else if (logtype == "lyx2lyx")
|
|
|
|
type_ = Lyx2lyxLog;
|
|
|
|
else if (logtype == "vc")
|
|
|
|
type_ = VCLog;
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
|
2006-12-04 15:07:05 +00:00
|
|
|
logfile_ = FileName(logfile);
|
2003-03-25 18:13:46 +00:00
|
|
|
return true;
|
2001-03-20 10:14:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-03-22 11:24:36 +00:00
|
|
|
void ControlLog::clearParams()
|
2001-03-20 10:14:03 +00:00
|
|
|
{
|
2003-12-05 13:37:23 +00:00
|
|
|
logfile_.erase();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-10-09 10:35:14 +00:00
|
|
|
docstring const ControlLog::title() const
|
2003-12-05 13:37:23 +00:00
|
|
|
{
|
2006-10-09 10:35:14 +00:00
|
|
|
docstring t;
|
2003-12-05 13:37:23 +00:00
|
|
|
switch (type_) {
|
|
|
|
case LatexLog:
|
2006-10-09 10:35:14 +00:00
|
|
|
t = _("LaTeX Log");
|
2003-12-05 13:37:23 +00:00
|
|
|
break;
|
|
|
|
case LiterateLog:
|
2006-10-09 10:35:14 +00:00
|
|
|
t = _("Literate Programming Build Log");
|
2003-12-05 13:37:23 +00:00
|
|
|
break;
|
|
|
|
case Lyx2lyxLog:
|
2006-10-09 10:35:14 +00:00
|
|
|
t = _("lyx2lyx Error Log");
|
2003-12-05 13:37:23 +00:00
|
|
|
break;
|
|
|
|
case VCLog:
|
2006-10-09 10:35:14 +00:00
|
|
|
t = _("Version Control Log");
|
2003-12-05 13:37:23 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
return t;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ControlLog::getContents(std::ostream & ss) const
|
|
|
|
{
|
2006-12-04 15:07:05 +00:00
|
|
|
std::ifstream in(logfile_.toFilesystemEncoding().c_str());
|
2003-12-05 13:37:23 +00:00
|
|
|
|
|
|
|
bool success = false;
|
|
|
|
|
2006-12-16 10:38:01 +00:00
|
|
|
// FIXME UNICODE
|
|
|
|
// Our caller interprets the file contents as UTF8, but is that
|
|
|
|
// correct?
|
2003-12-05 13:37:23 +00:00
|
|
|
if (in) {
|
|
|
|
ss << in.rdbuf();
|
|
|
|
success = ss.good();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (success)
|
|
|
|
return;
|
|
|
|
|
|
|
|
switch (type_) {
|
|
|
|
case LatexLog:
|
2006-09-09 15:27:44 +00:00
|
|
|
ss << lyx::to_utf8(_("No LaTeX log file found."));
|
2003-12-05 13:37:23 +00:00
|
|
|
break;
|
|
|
|
case LiterateLog:
|
2006-09-09 15:27:44 +00:00
|
|
|
ss << lyx::to_utf8(_("No literate programming build log file found."));
|
2003-12-05 13:37:23 +00:00
|
|
|
break;
|
|
|
|
case Lyx2lyxLog:
|
2006-09-09 15:27:44 +00:00
|
|
|
ss << lyx::to_utf8(_("No lyx2lyx error log file found."));
|
2003-12-05 13:37:23 +00:00
|
|
|
break;
|
|
|
|
case VCLog:
|
2006-09-09 15:27:44 +00:00
|
|
|
ss << lyx::to_utf8(_("No version control log file found."));
|
2003-12-05 13:37:23 +00:00
|
|
|
break;
|
|
|
|
}
|
2001-03-20 10:14:03 +00:00
|
|
|
}
|
2004-05-19 15:11:37 +00:00
|
|
|
|
|
|
|
} // namespace frontend
|
|
|
|
} // namespace lyx
|