2000-08-30 03:40:51 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/* This file is part of
|
|
|
|
* ======================================================
|
|
|
|
*
|
|
|
|
* LyX, The Document Processor
|
|
|
|
*
|
|
|
|
* Copyright 1995 Matthias Ettrich
|
|
|
|
* Copyright 1995-2000 The LyX Team.
|
|
|
|
*
|
|
|
|
* ====================================================== */
|
|
|
|
|
|
|
|
#ifndef CONVERTER_H
|
|
|
|
#define CONVERTER_H
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma interface
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <map>
|
|
|
|
#include <vector>
|
|
|
|
#include "LString.h"
|
|
|
|
|
|
|
|
class Buffer;
|
|
|
|
|
2000-08-30 04:38:32 +00:00
|
|
|
///
|
2000-08-30 03:40:51 +00:00
|
|
|
struct Command {
|
2000-08-30 04:38:32 +00:00
|
|
|
///
|
2000-09-11 15:42:17 +00:00
|
|
|
Command(string const & f, string const & t, string const & c)
|
|
|
|
: from(f), to(t), command(c),
|
|
|
|
original_dir(false), need_aux(false) {}
|
2000-08-30 03:40:51 +00:00
|
|
|
///
|
|
|
|
string from;
|
|
|
|
///
|
|
|
|
string to;
|
|
|
|
///
|
|
|
|
string command;
|
2000-09-11 15:42:17 +00:00
|
|
|
/// Do we need to run the converter in the original directory?
|
2000-08-30 03:40:51 +00:00
|
|
|
bool original_dir;
|
2000-09-11 15:42:17 +00:00
|
|
|
/// This converter needs the .aux files
|
|
|
|
bool need_aux;
|
|
|
|
/// If the converter put the result in a directory, then result_dir
|
|
|
|
/// is the name of the directory
|
|
|
|
string result_dir;
|
|
|
|
/// If the converter put the result in a directory, then result_file
|
|
|
|
/// is the name of the main file in that directory
|
|
|
|
string result_file;
|
2000-08-30 03:40:51 +00:00
|
|
|
///
|
|
|
|
bool visited;
|
|
|
|
///
|
|
|
|
std::vector<Command>::iterator previous;
|
|
|
|
};
|
|
|
|
|
2000-08-30 04:38:32 +00:00
|
|
|
///
|
2000-08-30 03:40:51 +00:00
|
|
|
class Format {
|
|
|
|
public:
|
2000-08-30 04:38:32 +00:00
|
|
|
///
|
2000-08-30 03:40:51 +00:00
|
|
|
Format() : in_degree(0) {}
|
|
|
|
///
|
|
|
|
Format(string const & n);
|
|
|
|
///
|
|
|
|
string name;
|
|
|
|
///
|
|
|
|
string prettyname;
|
|
|
|
///
|
|
|
|
string viewer;
|
|
|
|
///
|
|
|
|
int in_degree;
|
|
|
|
};
|
|
|
|
|
2000-08-30 04:38:32 +00:00
|
|
|
///
|
2000-08-30 03:40:51 +00:00
|
|
|
class Formats {
|
|
|
|
public:
|
|
|
|
///
|
|
|
|
static
|
|
|
|
void Add(string const & name);
|
|
|
|
///
|
|
|
|
static
|
|
|
|
void SetViewer(string const & name, string const & command);
|
|
|
|
///
|
|
|
|
static
|
2000-09-05 13:16:19 +00:00
|
|
|
bool View(Buffer * buffer, string const & filename);
|
2000-08-30 03:40:51 +00:00
|
|
|
///
|
|
|
|
static
|
|
|
|
Format * GetFormat(string const & name);
|
|
|
|
///
|
|
|
|
static
|
2000-08-30 04:38:32 +00:00
|
|
|
string const PrettyName(string const & name);
|
2000-08-30 03:40:51 +00:00
|
|
|
private:
|
|
|
|
///
|
|
|
|
static
|
|
|
|
std::map<string, Format> formats;
|
|
|
|
};
|
|
|
|
|
2000-08-30 04:38:32 +00:00
|
|
|
///
|
2000-08-30 03:40:51 +00:00
|
|
|
class Converter {
|
|
|
|
public:
|
|
|
|
///
|
|
|
|
static
|
|
|
|
void Add(string const & from, string const & to,
|
|
|
|
string const & command, string const & flags);
|
|
|
|
///
|
|
|
|
static
|
2000-08-30 04:38:32 +00:00
|
|
|
std::vector<std::pair<string, string> > const
|
|
|
|
GetReachable(string const & from,
|
|
|
|
bool only_viewable = false);
|
2000-08-30 03:40:51 +00:00
|
|
|
///
|
|
|
|
static
|
2000-09-05 13:16:19 +00:00
|
|
|
bool Convert(Buffer * buffer, string const & from_file,
|
2000-09-11 15:42:17 +00:00
|
|
|
string const & to_file, string const & using_format,
|
|
|
|
string * view_file = 0);
|
2000-09-14 17:53:12 +00:00
|
|
|
///
|
2000-09-05 13:16:19 +00:00
|
|
|
static
|
|
|
|
string const SplitFormat(string const & str, string & format);
|
|
|
|
///
|
|
|
|
static
|
2000-09-14 17:53:12 +00:00
|
|
|
string const dvi_papersize(Buffer const * buffer);
|
2000-08-30 03:40:51 +00:00
|
|
|
///
|
|
|
|
static
|
2000-09-14 17:53:12 +00:00
|
|
|
string const dvips_options(Buffer const * buffer);
|
2000-08-30 03:40:51 +00:00
|
|
|
private:
|
|
|
|
///
|
|
|
|
static
|
|
|
|
bool runLaTeX(Buffer * buffer, string const & command);
|
|
|
|
///
|
|
|
|
static
|
|
|
|
std::vector<Command> commands;
|
2000-09-11 15:42:17 +00:00
|
|
|
///
|
|
|
|
static
|
|
|
|
string latex_command;
|
2000-08-30 03:40:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|